Skip to content

Commit

Permalink
Fix JSON cast for already parsed default configuration (#45)
Browse files Browse the repository at this point in the history
* Fix JSON cast for already parsed default configuration

* Add entry to CHANGES.txt
  • Loading branch information
osantana authored Jan 7, 2021
1 parent 5fa7b48 commit 92ffacd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.2.1
=====

- Fix JSON cast for already parsed default configuration

2.2.0
=====

Expand Down
2 changes: 2 additions & 0 deletions prettyconf/casts.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ def __call__(self, value):
return json.loads(value)
except json.JSONDecodeError as ex:
raise InvalidConfiguration('Invalid option {!r}'.format(value)) from ex
except TypeError:
return value
2 changes: 2 additions & 0 deletions tests/test_casts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def test_if_cast_is_unbounded():
('["obj1", "obj2"]', ['obj1', 'obj2']),
('{"key": "value"}', {'key': 'value'}),
('null', None),
(['already decoded object in default argument'],
['already decoded object in default argument']),
])
def test_basic_json_cast_values(value, result):
json = JSON()
Expand Down

0 comments on commit 92ffacd

Please sign in to comment.