mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-08 20:43:25 +08:00
This makes the following not give a type error: y: DefaultDict[str, List[int]] = Factory(lambda: defaultdict(list))
This commit is contained in:
committed by
Jelle Zijlstra
parent
1c47458ac6
commit
50c7188300
6
third_party/2and3/attr/__init__.pyi
vendored
6
third_party/2and3/attr/__init__.pyi
vendored
@@ -21,7 +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)`
|
||||
def Factory(factory: Union[Callable[[], _T], Callable[[Any], _T]], takes_self: bool = ...) -> _T: ...
|
||||
# Work around mypy issue #4554 by using an overload vs a Union.
|
||||
@overload
|
||||
def Factory(factory: Callable[[], _T], takes_self: bool = ...) -> _T: ...
|
||||
@overload
|
||||
def Factory(factory: Callable[[Any], _T], takes_self: bool = ...) -> _T: ...
|
||||
|
||||
class Attribute(Generic[_T]):
|
||||
name: str
|
||||
|
||||
Reference in New Issue
Block a user