diff --git a/src/attr/__init__.pyi b/src/attr/__init__.pyi index 7221836c1..610eced79 100644 --- a/src/attr/__init__.pyi +++ b/src/attr/__init__.pyi @@ -24,7 +24,6 @@ from . import setters as setters from . import validators as validators from ._version_info import VersionInfo - __version__: str __version_info__: VersionInfo __title__: str @@ -49,7 +48,9 @@ _OnSetAttrType = Callable[[Any, Attribute[Any], Any], Any] _OnSetAttrArgType = Union[ _OnSetAttrType, List[_OnSetAttrType], setters._NoOpType ] -_FieldTransformer = Callable[[type, List[Attribute[Any]]], List[Attribute[Any]]] +_FieldTransformer = Callable[ + [type, List[Attribute[Any]]], List[Attribute[Any]] +] # FIXME: in reality, if multiple validators are passed they must be in a list # or tuple, but those are invariant and so would prevent subtypes of # _ValidatorType from working when passed in a list or tuple. @@ -64,7 +65,6 @@ NOTHING: object # Work around mypy issue #4554 in the common case by using an overload. if sys.version_info >= (3, 8): from typing import Literal - @overload def Factory(factory: Callable[[], _T]) -> _T: ... @overload @@ -77,6 +77,7 @@ if sys.version_info >= (3, 8): factory: Callable[[], _T], takes_self: Literal[False], ) -> _T: ... + else: @overload def Factory(factory: Callable[[], _T]) -> _T: ... @@ -117,7 +118,6 @@ class Attribute(Generic[_T]): type: Optional[Type[_T]] kw_only: bool on_setattr: _OnSetAttrType - def evolve(self, **changes: Any) -> "Attribute[Any]": ... # NOTE: We had several choices for the annotation to use for type arg: @@ -452,7 +452,9 @@ def asdict( filter: Optional[_FilterType[Any]] = ..., dict_factory: Type[Mapping[Any, Any]] = ..., retain_collection_types: bool = ..., - value_serializer: Optional[Callable[[type, Attribute[Any], Any], Any]] = ..., + value_serializer: Optional[ + Callable[[type, Attribute[Any], Any], Any] + ] = ..., ) -> Dict[str, Any]: ... # TODO: add support for returning NamedTuple from the mypy plugin diff --git a/src/attr/_cmp.pyi b/src/attr/_cmp.pyi index 7093550f0..e71aaff7a 100644 --- a/src/attr/_cmp.pyi +++ b/src/attr/_cmp.pyi @@ -2,7 +2,6 @@ from typing import Type from . import _CompareWithType - def cmp_using( eq: Optional[_CompareWithType], lt: Optional[_CompareWithType], diff --git a/src/attr/converters.pyi b/src/attr/converters.pyi index 84a57590b..d180e4646 100644 --- a/src/attr/converters.pyi +++ b/src/attr/converters.pyi @@ -2,7 +2,6 @@ from typing import Callable, Optional, TypeVar, overload from . import _ConverterType - _T = TypeVar("_T") def pipe(*validators: _ConverterType) -> _ConverterType: ... diff --git a/src/attr/exceptions.pyi b/src/attr/exceptions.pyi index a800fb26b..f2680118b 100644 --- a/src/attr/exceptions.pyi +++ b/src/attr/exceptions.pyi @@ -1,6 +1,5 @@ from typing import Any - class FrozenError(AttributeError): msg: str = ... diff --git a/src/attr/filters.pyi b/src/attr/filters.pyi index f7b63f1bb..993866865 100644 --- a/src/attr/filters.pyi +++ b/src/attr/filters.pyi @@ -2,6 +2,5 @@ from typing import Any, Union from . import Attribute, _FilterType - def include(*what: Union[type, Attribute[Any]]) -> _FilterType[Any]: ... def exclude(*what: Union[type, Attribute[Any]]) -> _FilterType[Any]: ... diff --git a/src/attr/setters.pyi b/src/attr/setters.pyi index a921e07de..3f5603c2b 100644 --- a/src/attr/setters.pyi +++ b/src/attr/setters.pyi @@ -2,7 +2,6 @@ from typing import Any, NewType, NoReturn, TypeVar, cast from . import Attribute, _OnSetAttrType - _T = TypeVar("_T") def frozen( diff --git a/src/attr/validators.pyi b/src/attr/validators.pyi index fe92aac42..14101bf3b 100644 --- a/src/attr/validators.pyi +++ b/src/attr/validators.pyi @@ -17,7 +17,6 @@ from typing import ( from . import _ValidatorType - _T = TypeVar("_T") _T1 = TypeVar("_T1") _T2 = TypeVar("_T2")