Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump #134

Closed
wants to merge 3 commits into from
Closed

bump #134

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
History
=======

0.25.1 (2024-11-04)
-------------------

**Bugfixes**

* Fix for :issue:`67`: ``LiteralParser``'s ``__contains__`` method compares value of item with ``Literal`` arguments -- contributed by :user:`mikeweltevrede` in :pr:`111`.

0.25.0 (2024-11-03)
-------------------

Expand Down
8 changes: 4 additions & 4 deletions dataclass_wizard/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def message(self) -> str:
obj_type=self.name(self.obj_type))

if self.json_object:
self.kwargs['json_object'] = json.dumps(self.json_object)
self.kwargs['json_object'] = json.dumps(self.json_object, default=str)

if self.kwargs:
sep = '\n '
Expand Down Expand Up @@ -168,7 +168,7 @@ def name(obj) -> str:
def message(self) -> str:
msg = self._TEMPLATE.format(
cls=self.class_name,
json_string=json.dumps(self.obj),
json_string=json.dumps(self.obj, default=str),
e=self.base_error,
fields=self.fields,
missing_fields=self.missing_fields)
Expand Down Expand Up @@ -217,7 +217,7 @@ def name(obj) -> str:
def message(self) -> str:
msg = self._TEMPLATE.format(
cls=self.class_name,
json_string=json.dumps(self.obj),
json_string=json.dumps(self.obj, default=str),
fields=self.fields,
json_key=self.json_key)

Expand Down Expand Up @@ -255,7 +255,7 @@ def message(self) -> str:
msg = self._TEMPLATE.format(
cls=self.class_name,
nested_cls=self.nested_class_name,
json_string=json.dumps(self.obj),
json_string=json.dumps(self.obj, default=str),
field=self.field_name,
o=self.obj,
)
Expand Down
5 changes: 4 additions & 1 deletion dataclass_wizard/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def __contains__(self, item) -> bool:
type. Checks that the item is incorporated in the given expected values of
the Literal.
"""
return item in self.value_to_type.keys()
try:
return item in self.value_to_type
except TypeError:
return False

def __call__(self, o: Any) -> M:
"""
Expand Down
Loading