@@ -24,7 +24,6 @@ from . import setters as setters
2424from . import validators as validators
2525from ._version_info import VersionInfo
2626
27-
2827__version__ : str
2928__version_info__ : VersionInfo
3029__title__ : str
@@ -49,7 +48,10 @@ _OnSetAttrType = Callable[[Any, Attribute[Any], Any], Any]
4948_OnSetAttrArgType = Union [
5049 _OnSetAttrType , List [_OnSetAttrType ], setters ._NoOpType
5150]
52- _FieldTransformer = Callable [[type , List [Attribute [Any ]]], List [Attribute [Any ]]]
51+ _FieldTransformer = Callable [
52+ [type , List [Attribute [Any ]]], List [Attribute [Any ]]
53+ ]
54+ _CompareWithType = Callable [[Any , Any ], bool ]
5355# FIXME: in reality, if multiple validators are passed they must be in a list
5456# or tuple, but those are invariant and so would prevent subtypes of
5557# _ValidatorType from working when passed in a list or tuple.
@@ -64,7 +66,6 @@ NOTHING: object
6466# Work around mypy issue #4554 in the common case by using an overload.
6567if sys .version_info >= (3 , 8 ):
6668 from typing import Literal
67-
6869 @overload
6970 def Factory (factory : Callable [[], _T ]) -> _T : ...
7071 @overload
@@ -77,6 +78,7 @@ if sys.version_info >= (3, 8):
7778 factory : Callable [[], _T ],
7879 takes_self : Literal [False ],
7980 ) -> _T : ...
81+
8082else :
8183 @overload
8284 def Factory (factory : Callable [[], _T ]) -> _T : ...
@@ -117,7 +119,6 @@ class Attribute(Generic[_T]):
117119 type : Optional [Type [_T ]]
118120 kw_only : bool
119121 on_setattr : _OnSetAttrType
120-
121122 def evolve (self , ** changes : Any ) -> "Attribute[Any]" : ...
122123
123124# NOTE: We had several choices for the annotation to use for type arg:
@@ -315,6 +316,7 @@ def attrs(
315316 getstate_setstate : Optional [bool ] = ...,
316317 on_setattr : Optional [_OnSetAttrArgType ] = ...,
317318 field_transformer : Optional [_FieldTransformer ] = ...,
319+ match_args : bool = ...,
318320) -> _C : ...
319321@overload
320322@__dataclass_transform__ (order_default = True , field_descriptors = (attrib , field ))
@@ -341,6 +343,7 @@ def attrs(
341343 getstate_setstate : Optional [bool ] = ...,
342344 on_setattr : Optional [_OnSetAttrArgType ] = ...,
343345 field_transformer : Optional [_FieldTransformer ] = ...,
346+ match_args : bool = ...,
344347) -> Callable [[_C ], _C ]: ...
345348@overload
346349@__dataclass_transform__ (field_descriptors = (attrib , field ))
@@ -365,6 +368,7 @@ def define(
365368 getstate_setstate : Optional [bool ] = ...,
366369 on_setattr : Optional [_OnSetAttrArgType ] = ...,
367370 field_transformer : Optional [_FieldTransformer ] = ...,
371+ match_args : bool = ...,
368372) -> _C : ...
369373@overload
370374@__dataclass_transform__ (field_descriptors = (attrib , field ))
@@ -389,6 +393,7 @@ def define(
389393 getstate_setstate : Optional [bool ] = ...,
390394 on_setattr : Optional [_OnSetAttrArgType ] = ...,
391395 field_transformer : Optional [_FieldTransformer ] = ...,
396+ match_args : bool = ...,
392397) -> Callable [[_C ], _C ]: ...
393398
394399mutable = define
@@ -442,13 +447,17 @@ def make_class(
442447# these:
443448# https://github.com/python/mypy/issues/4236
444449# https://github.com/python/typing/issues/253
450+ # XXX: remember to fix attrs.asdict/astuple too!
445451def asdict (
446452 inst : Any ,
447453 recurse : bool = ...,
448454 filter : Optional [_FilterType [Any ]] = ...,
449455 dict_factory : Type [Mapping [Any , Any ]] = ...,
450456 retain_collection_types : bool = ...,
451- value_serializer : Optional [Callable [[type , Attribute [Any ], Any ], Any ]] = ...,
457+ value_serializer : Optional [
458+ Callable [[type , Attribute [Any ], Any ], Any ]
459+ ] = ...,
460+ tuple_keys : Optional [bool ] = ...,
452461) -> Dict [str , Any ]: ...
453462
454463# TODO: add support for returning NamedTuple from the mypy plugin
0 commit comments