mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 14:01:55 +08:00
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:
@@ -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]: ...
|
||||
|
||||
Reference in New Issue
Block a user