PEP-563 breaks SerializationStrategy
See original GitHub issue-
SerializationStrategy
example withDateTimeFormats
works fine in py3.7 https://github.com/Fatal1ty/mashumaro#user-defined-classes -
however introduction of PEP-563 via
from __future__ import annotations
https://www.python.org/dev/peps/pep-0563/ breaks usage ofSerializationStrategy
with error trace:
Traceback (most recent call last):
File ".../src/verify/code/mashu/mashu_pep563.py", line 22, in <module>
class DateTimeFormats(DataClassDictMixin):
File "/usr/lib/python3.7/site-packages/mashumaro/serializer/base/dict.py", line 19, in __init_subclass__
raise exc
File "/usr/lib/python3.7/site-packages/mashumaro/serializer/base/dict.py", line 15, in __init_subclass__
builder.add_to_dict()
File "/usr/lib/python3.7/site-packages/mashumaro/serializer/base/metaprogramming.py", line 163, in add_to_dict
for fname, ftype in self.fields.items():
File "/usr/lib/python3.7/site-packages/mashumaro/serializer/base/metaprogramming.py", line 53, in fields
for fname, ftype in typing.get_type_hints(self.cls).items():
File "/usr/lib/python3.7/typing.py", line 973, in get_type_hints
value = _eval_type(value, base_globals, localns)
File "/usr/lib/python3.7/typing.py", line 260, in _eval_type
return t._evaluate(globalns, localns)
File "/usr/lib/python3.7/typing.py", line 466, in _evaluate
is_argument=self.__forward_is_argument__)
File "/usr/lib/python3.7/typing.py", line 139, in _type_check
raise TypeError(f"{msg} Got {arg!r:.100}.")
TypeError: Forward references must evaluate to types. Got <__main__.FormattedDateTime object at 0x7faec3540f60>.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top Results From Across the Web
PEP 563 getting rolled back from Python 3.10 - Reddit
This decision was made after third-party library maintainers (primarily Pydantic) raised an issue on how PEP 563 was going to break their ...
Read more >mashumaro Changelog - pyup.io
Added support for PEP 563 postponed evaluation of annotations. ... Fixed broken serialization of data classes that also inherit another supported ...
Read more >Type annotations, PEP 649 and PEP 563 - Core Development
Are there cases of type annotations for static checking or runtime use that PEP 563 enables, which would break with PEP 649? Is...
Read more >PEP 563, PEP 649 and the future of pydantic and FastAPI
It's fine to wait more than two releases." PEP 563, the one that apparently breaks pydantic, was accepted during Python 3.7. This was...
Read more >Sebastián Ramírez on Twitter: "Great news for pydantic and ...
Great news for pydantic and FastAPI The Python steering council decided to delay making PEP 563 the default until Python 3.11 It's a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I changed the way how
SerializationStrategy
classes are used. @rominf you might be interested in reading README here and here. At the moment these changes are in the master branch but I will release 2.0 version soon since it’s not backward compatible.The new changes are in 2.0 now.