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
and this works as expected with dataclasses on mypy and pyright, but it doesn't currently work on pyre because pyre doesn't know yet that dataclasses have the __dataclass_fields__ classvar. (I haven't checked other type checkers.)
At runtime, is_dataclass really only checks for the __dataclass_fields__ attribute:
@AlexWaygood proposed the following stubs in this comment: python/mypy#14263 (comment)
and this works as expected with dataclasses on mypy and pyright, but it doesn't currently work on pyre because pyre doesn't know yet that dataclasses have the
__dataclass_fields__
classvar. (I haven't checked other type checkers.)At runtime,
is_dataclass
really only checks for the__dataclass_fields__
attribute:https://github.com/python/cpython/blob/7a0f3c1d92ef0768e082ace19d970b0ef12e7346/Lib/dataclasses.py#L1263-L1267
However, it also works with types in addition to instances, so an overload would be needed.
See also this issue for context: python/mypy#14215
The text was updated successfully, but these errors were encountered: