Skip to content

Commit

Permalink
Switch to black formatting in stubs
Browse files Browse the repository at this point in the history
Also block isort from stubs -- it plays ping-pong with black about an empty
line after imports.
  • Loading branch information
hynek committed May 20, 2021
1 parent 0112392 commit 0c76909
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/attr/__init__.pyi
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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: ...
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/attr/_cmp.pyi
Expand Up @@ -2,7 +2,6 @@ from typing import Type

from . import _CompareWithType


def cmp_using(
eq: Optional[_CompareWithType],
lt: Optional[_CompareWithType],
Expand Down
1 change: 0 additions & 1 deletion src/attr/converters.pyi
Expand Up @@ -2,7 +2,6 @@ from typing import Callable, Optional, TypeVar, overload

from . import _ConverterType


_T = TypeVar("_T")

def pipe(*validators: _ConverterType) -> _ConverterType: ...
Expand Down
1 change: 0 additions & 1 deletion src/attr/exceptions.pyi
@@ -1,6 +1,5 @@
from typing import Any


class FrozenError(AttributeError):
msg: str = ...

Expand Down
1 change: 0 additions & 1 deletion src/attr/filters.pyi
Expand Up @@ -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]: ...
1 change: 0 additions & 1 deletion src/attr/setters.pyi
Expand Up @@ -2,7 +2,6 @@ from typing import Any, NewType, NoReturn, TypeVar, cast

from . import Attribute, _OnSetAttrType


_T = TypeVar("_T")

def frozen(
Expand Down
1 change: 0 additions & 1 deletion src/attr/validators.pyi
Expand Up @@ -17,7 +17,6 @@ from typing import (

from . import _ValidatorType


_T = TypeVar("_T")
_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
Expand Down

0 comments on commit 0c76909

Please sign in to comment.