You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the dataclass with the TypedJsonMixin has a attribute with None as default value, and you want to properly annotate for mypy, the dataclass becomes unusable.
Would have expected it to still be usable. Perhaps it is desired behavior due to how json is specified, and as such a non-issue. But maybe you're still interested in such a report.
Actual behaviour
Ends up raising
TypeError: typing.Union cannot be used with isinstance()
because under the hood Optional is a particular type Union[NonType, int].
Post Scriptum: Nice project and very clear coding! Good job.
The text was updated successfully, but these errors were encountered:
Thank you so much for taking the time to report this issue. I've addressed this in the following commit: f71809f
And version 0.2.2 should be available on PyPI shortly.
Reminder that the to_dict and to_json methods have a keyword parameter for keep_none for handling whether or not you want to expose that some of these variables are in fact undefined.
Subject of the issue
If the dataclass with the
TypedJsonMixin
has a attribute withNone
as default value, and you want to properly annotate for mypy, the dataclass becomes unusable.Steps to reproduce
Here is the code to reproduce the situation
Expected behaviour
Would have expected it to still be usable. Perhaps it is desired behavior due to how json is specified, and as such a non-issue. But maybe you're still interested in such a report.
Actual behaviour
Ends up raising
because under the hood
Optional
is a particular typeUnion[NonType, int]
.Post Scriptum: Nice project and very clear coding! Good job.
The text was updated successfully, but these errors were encountered: