mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-45663: Fix is_dataclass() for dataclasses which are subclasses of types.GenericAlias (GH-29294)
(cherry picked from commit 446be16686
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
52a9a71fe6
commit
19050711f5
3 changed files with 15 additions and 1 deletions
|
@ -1047,7 +1047,7 @@ def _is_dataclass_instance(obj):
|
|||
def is_dataclass(obj):
|
||||
"""Returns True if obj is a dataclass or an instance of a
|
||||
dataclass."""
|
||||
cls = obj if isinstance(obj, type) else type(obj)
|
||||
cls = obj if isinstance(obj, type) and not isinstance(obj, GenericAlias) else type(obj)
|
||||
return hasattr(cls, _FIELDS)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue