11import sys
2- import typing
32from dataclasses import (_FIELD , _FIELD_INITVAR , _POST_INIT_NAME , MISSING ,
43 _fields_in_init_order , _init_fn , _process_class ,
5- _set_new_attribute )
6- from typing import Any , Generator , Tuple
4+ _set_new_attribute , Field , field )
5+ from typing import (Any , Generic , TypeVar , Type , Callable , Generator , Tuple ,
6+ dataclass_transform )
7+ try :
8+ from typing import overload
9+ except ImportError :
10+ from typing_extensions import overload
11+
12+
13+ __all__ = ['dataclassabc' ]
14+ _T = TypeVar ("_T" )
715
816
917def resolve_abc_prop (cls ):
@@ -54,7 +62,7 @@ def set_func(self, val, key=key):
5462 get_set_properties = dict (gen_get_set_properties ())
5563
5664 mro_filtered = tuple (
57- mro for mro in cls .__mro__ if mro is not typing . Generic )
65+ mro for mro in cls .__mro__ if mro is not Generic )
5866
5967 new_cls = type (
6068 cls .__name__ ,
@@ -65,6 +73,43 @@ def set_func(self, val, key=key):
6573 return new_cls
6674
6775
76+ @overload
77+ @dataclass_transform (field_specifiers = (Field , field ))
78+ def dataclassabc (
79+ _cls : None = None , / , * ,
80+ init : bool = True ,
81+ repr : bool = True ,
82+ eq : bool = True ,
83+ order : bool = False ,
84+ unsafe_hash : bool = False ,
85+ frozen : bool = False ,
86+ match_args : bool = True ,
87+ kw_only : bool = False ,
88+ slots : bool = False ,
89+ weakref_slot : bool = False
90+ ) -> Callable [[Type [_T ]], Type [_T ]]:
91+ ...
92+
93+
94+ @overload
95+ @dataclass_transform (field_specifiers = (Field , field ))
96+ def dataclassabc (
97+ _cls : Type [_T ], / , * ,
98+ init : bool = True ,
99+ repr : bool = True ,
100+ eq : bool = True ,
101+ order : bool = False ,
102+ unsafe_hash : bool = False ,
103+ frozen : bool = False ,
104+ match_args : bool = True ,
105+ kw_only : bool = False ,
106+ slots : bool = False ,
107+ weakref_slot : bool = False
108+ ) -> Type [_T ]:
109+ ...
110+
111+
112+ @dataclass_transform (field_specifiers = (Field , field ))
68113def dataclassabc (_cls = None , / , * , init = True , repr = True , eq = True , order = False ,
69114 unsafe_hash = False , frozen = False , match_args = True ,
70115 kw_only = False , slots = False , weakref_slot = False ):
0 commit comments