mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-10 18:36:31 +08:00
Add @disjoint_base decorator in the stdlib (#14599)
And fix some other new stubtest finds.
This commit is contained in:
@@ -3,7 +3,7 @@ from _collections_abc import dict_items, dict_keys, dict_values
|
||||
from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
|
||||
from types import GenericAlias
|
||||
from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload, type_check_only
|
||||
from typing_extensions import Self
|
||||
from typing_extensions import Self, disjoint_base
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
from collections.abc import (
|
||||
@@ -231,6 +231,7 @@ class UserString(Sequence[UserString]):
|
||||
def upper(self) -> Self: ...
|
||||
def zfill(self, width: int) -> Self: ...
|
||||
|
||||
@disjoint_base
|
||||
class deque(MutableSequence[_T]):
|
||||
@property
|
||||
def maxlen(self) -> int | None: ...
|
||||
@@ -356,6 +357,7 @@ class _odict_items(dict_items[_KT_co, _VT_co]): # type: ignore[misc] # pyright
|
||||
class _odict_values(dict_values[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
|
||||
def __reversed__(self) -> Iterator[_VT_co]: ...
|
||||
|
||||
@disjoint_base
|
||||
class OrderedDict(dict[_KT, _VT]):
|
||||
def popitem(self, last: bool = True) -> tuple[_KT, _VT]: ...
|
||||
def move_to_end(self, key: _KT, last: bool = True) -> None: ...
|
||||
@@ -395,6 +397,7 @@ class OrderedDict(dict[_KT, _VT]):
|
||||
@overload
|
||||
def __ror__(self, value: dict[_T1, _T2], /) -> OrderedDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
|
||||
|
||||
@disjoint_base
|
||||
class defaultdict(dict[_KT, _VT]):
|
||||
default_factory: Callable[[], _VT] | None
|
||||
@overload
|
||||
@@ -477,9 +480,15 @@ class ChainMap(MutableMapping[_KT, _VT]):
|
||||
__copy__ = copy
|
||||
# All arguments to `fromkeys` are passed to `dict.fromkeys` at runtime,
|
||||
# so the signature should be kept in line with `dict.fromkeys`.
|
||||
@classmethod
|
||||
@overload
|
||||
def fromkeys(cls, iterable: Iterable[_T]) -> ChainMap[_T, Any | None]: ...
|
||||
if sys.version_info >= (3, 13):
|
||||
@classmethod
|
||||
@overload
|
||||
def fromkeys(cls, iterable: Iterable[_T], /) -> ChainMap[_T, Any | None]: ...
|
||||
else:
|
||||
@classmethod
|
||||
@overload
|
||||
def fromkeys(cls, iterable: Iterable[_T]) -> ChainMap[_T, Any | None]: ...
|
||||
|
||||
@classmethod
|
||||
@overload
|
||||
# Special-case None: the user probably wants to add non-None values later.
|
||||
|
||||
Reference in New Issue
Block a user