@@ -17,14 +17,27 @@ def asdict(obj: Any, *, dict_factory: Callable[[List[Tuple[str, Any]]], _T]) ->
17
17
def astuple (obj : Any ) -> Tuple [Any , ...]: ...
18
18
@overload
19
19
def astuple (obj : Any , * , tuple_factory : Callable [[List [Any ]], _T ]) -> _T : ...
20
- @overload
21
- def dataclass (_cls : Type [_T ]) -> Type [_T ]: ...
22
- @overload
23
- def dataclass (_cls : None ) -> Callable [[Type [_T ]], Type [_T ]]: ...
24
- @overload
25
- def dataclass (
26
- * , init : bool = ..., repr : bool = ..., eq : bool = ..., order : bool = ..., unsafe_hash : bool = ..., frozen : bool = ...
27
- ) -> Callable [[Type [_T ]], Type [_T ]]: ...
20
+
21
+ if sys .version_info >= (3 , 8 ):
22
+ # cls argument is now positional-only
23
+ @overload
24
+ def dataclass (__cls : Type [_T ]) -> Type [_T ]: ...
25
+ @overload
26
+ def dataclass (__cls : None ) -> Callable [[Type [_T ]], Type [_T ]]: ...
27
+ @overload
28
+ def dataclass (
29
+ * , init : bool = ..., repr : bool = ..., eq : bool = ..., order : bool = ..., unsafe_hash : bool = ..., frozen : bool = ...
30
+ ) -> Callable [[Type [_T ]], Type [_T ]]: ...
31
+
32
+ else :
33
+ @overload
34
+ def dataclass (_cls : Type [_T ]) -> Type [_T ]: ...
35
+ @overload
36
+ def dataclass (_cls : None ) -> Callable [[Type [_T ]], Type [_T ]]: ...
37
+ @overload
38
+ def dataclass (
39
+ * , init : bool = ..., repr : bool = ..., eq : bool = ..., order : bool = ..., unsafe_hash : bool = ..., frozen : bool = ...
40
+ ) -> Callable [[Type [_T ]], Type [_T ]]: ...
28
41
29
42
class Field (Generic [_T ]):
30
43
name : str
@@ -36,6 +49,16 @@ class Field(Generic[_T]):
36
49
init : bool
37
50
compare : bool
38
51
metadata : Mapping [str , Any ]
52
+ def __init__ (
53
+ self ,
54
+ default : _T ,
55
+ default_factory : Callable [[], _T ],
56
+ init : bool ,
57
+ repr : bool ,
58
+ hash : Optional [bool ],
59
+ compare : bool ,
60
+ metadata : Mapping [str , Any ],
61
+ ) -> None : ...
39
62
if sys .version_info >= (3 , 9 ):
40
63
def __class_getitem__ (cls , item : Any ) -> GenericAlias : ...
41
64
@@ -76,8 +99,13 @@ def is_dataclass(obj: Any) -> bool: ...
76
99
class FrozenInstanceError (AttributeError ): ...
77
100
78
101
class InitVar (Generic [_T ]):
102
+ type : Type [_T ]
103
+ def __init__ (self , type : Type [_T ]) -> None : ...
79
104
if sys .version_info >= (3 , 9 ):
80
- def __class_getitem__ (cls , type : Any ) -> GenericAlias : ...
105
+ @overload
106
+ def __class_getitem__ (cls , type : Type [_T ]) -> InitVar [_T ]: ...
107
+ @overload
108
+ def __class_getitem__ (cls , type : Any ) -> InitVar [Any ]: ...
81
109
82
110
def make_dataclass (
83
111
cls_name : str ,
@@ -92,4 +120,4 @@ def make_dataclass(
92
120
unsafe_hash : bool = ...,
93
121
frozen : bool = ...,
94
122
) -> type : ...
95
- def replace (obj : _T , ** changes : Any ) -> _T : ...
123
+ def replace (__obj : _T , ** changes : Any ) -> _T : ...
0 commit comments