mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 14:01:55 +08:00
Fix attr.Factory signature (#2077)
The first overload was catching all calls including take_self=True. Fix it by modifying the overloads. Fixes https://github.com/python-attrs/attrs/issues/366
This commit is contained in:
committed by
Jelle Zijlstra
parent
2dc7d39af5
commit
664d30c44b
6
third_party/2and3/attr/__init__.pyi
vendored
6
third_party/2and3/attr/__init__.pyi
vendored
@@ -21,11 +21,11 @@ _ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]]
|
||||
NOTHING: object
|
||||
|
||||
# NOTE: Factory lies about its return type to make this possible: `x: List[int] = Factory(list)`
|
||||
# Work around mypy issue #4554 by using an overload vs a Union.
|
||||
# Work around mypy issue #4554 in the common case by using an overload.
|
||||
@overload
|
||||
def Factory(factory: Callable[[], _T], takes_self: bool = ...) -> _T: ...
|
||||
def Factory(factory: Callable[[], _T]) -> _T: ...
|
||||
@overload
|
||||
def Factory(factory: Callable[[Any], _T], takes_self: bool = ...) -> _T: ...
|
||||
def Factory(factory: Union[Callable[[Any], _T], Callable[[], _T]], takes_self: bool = ...) -> _T: ...
|
||||
|
||||
class Attribute(Generic[_T]):
|
||||
name: str
|
||||
|
||||
Reference in New Issue
Block a user