builtins, collections: Fix unconstrained overloads for container constructors (#7944)

See https://github.com/microsoft/pyright/issues/3501#issuecomment-1135979479

Related to #7928
This commit is contained in:
Jelle Zijlstra
2022-05-25 02:07:23 -07:00
committed by GitHub
parent 773ddb15bb
commit d5bc48d29b
2 changed files with 20 additions and 8 deletions

View File

@@ -909,7 +909,7 @@ class list(MutableSequence[_T], Generic[_T]):
class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
# __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics
@overload
def __init__(self: dict[_KT, _VT]) -> None: ...
def __init__(self) -> None: ...
@overload
def __init__(self: dict[str, _VT], **kwargs: _VT) -> None: ...
@overload
@@ -962,7 +962,10 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __ior__(self: Self, __value: Iterable[tuple[_KT, _VT]]) -> Self: ...
class set(MutableSet[_T], Generic[_T]):
def __init__(self, __iterable: Iterable[_T] = ...) -> None: ...
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, __iterable: Iterable[_T]) -> None: ...
def add(self, __element: _T) -> None: ...
def copy(self) -> set[_T]: ...
def difference(self, *s: Iterable[Any]) -> set[_T]: ...
@@ -998,7 +1001,10 @@ class set(MutableSet[_T], Generic[_T]):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
class frozenset(AbstractSet[_T_co], Generic[_T_co]):
def __init__(self, __iterable: Iterable[_T_co] = ...) -> None: ...
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, __iterable: Iterable[_T_co]) -> None: ...
def copy(self) -> frozenset[_T_co]: ...
def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ...