From a0cadcce854dc1c83ecd3aa45882a183904dedc2 Mon Sep 17 00:00:00 2001 From: Tim Rid <6593626+timrid@users.noreply.github.com> Date: Sat, 19 Feb 2022 21:54:04 +0100 Subject: [PATCH] removed things that not work in Python 3.8 --- construct_typed/dataclass_py310.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/construct_typed/dataclass_py310.py b/construct_typed/dataclass_py310.py index fb3c7d5..9d6d9bb 100644 --- a/construct_typed/dataclass_py310.py +++ b/construct_typed/dataclass_py310.py @@ -8,7 +8,7 @@ import builtins import functools import abc import _thread -from types import FunctionType, GenericAlias +from types import FunctionType __all__ = ['dataclass', @@ -229,7 +229,7 @@ class InitVar: self.type = type def __repr__(self): - if isinstance(self.type, type) and not isinstance(self.type, GenericAlias): + if isinstance(self.type, type): type_name = self.type.__name__ else: # typing objects, e.g. List[int] @@ -309,8 +309,6 @@ class Field: # it. func(self.default, owner, name) - __class_getitem__ = classmethod(GenericAlias) - class _DataclassParams: __slots__ = ('init', @@ -1101,8 +1099,6 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, if slots: cls = _add_slots(cls, frozen) - abc.update_abstractmethods(cls) - return cls @@ -1211,7 +1207,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) and not isinstance(obj, GenericAlias) else type(obj) + cls = obj if isinstance(obj, type) else type(obj) return hasattr(cls, _FIELDS)