diff --git a/stdlib/_collections_abc.pyi b/stdlib/_collections_abc.pyi index 0fa81662d..8b0ec29c5 100644 --- a/stdlib/_collections_abc.pyi +++ b/stdlib/_collections_abc.pyi @@ -80,7 +80,7 @@ class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final -class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented +class dict_values(Generic[_KT_co, _VT_co], ValuesView[_VT_co]): # undocumented def __reversed__(self) -> Iterator[_VT_co]: ... if sys.version_info >= (3, 10): @property diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 5657ac74a..0fd014104 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -72,7 +72,7 @@ from typing_extensions import ( # noqa: Y023 TypeIs, TypeVarTuple, deprecated, - disjoint_base, +# disjoint_base, ) if sys.version_info >= (3, 14): @@ -1045,9 +1045,9 @@ class tuple(Sequence[_T_co]): def __len__(self) -> int: ... def __contains__(self, key: object, /) -> bool: ... @overload - def __getitem__(self, key: SupportsIndex, /) -> _T_co: ... + def __getitem__(self, key: int, /) -> _T_co: ... @overload - def __getitem__(self, key: slice[SupportsIndex | None], /) -> tuple[_T_co, ...]: ... + def __getitem__(self, key: slice[int | None], /) -> tuple[_T_co, ...]: ... def __iter__(self) -> Iterator[_T_co]: ... def __lt__(self, value: tuple[_T_co, ...], /) -> bool: ... def __le__(self, value: tuple[_T_co, ...], /) -> bool: ... @@ -1065,57 +1065,6 @@ class tuple(Sequence[_T_co]): def index(self, value: Any, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... -# Doesn't exist at runtime, but deleting this breaks mypy and pyright. See: -# https://github.com/python/typeshed/issues/7580 -# https://github.com/python/mypy/issues/8240 -# Obsolete, use types.FunctionType instead. -@final -@type_check_only -class function: - # Make sure this class definition stays roughly in line with `types.FunctionType` - @property - def __closure__(self) -> tuple[CellType, ...] | None: ... - __code__: CodeType - __defaults__: tuple[Any, ...] | None - __dict__: dict[str, Any] - @property - def __globals__(self) -> dict[str, Any]: ... - __name__: str - __qualname__: str - __annotations__: dict[str, AnnotationForm] - if sys.version_info >= (3, 14): - __annotate__: AnnotateFunc | None - __kwdefaults__: dict[str, Any] | None - if sys.version_info >= (3, 10): - @property - def __builtins__(self) -> dict[str, Any]: ... - if sys.version_info >= (3, 12): - __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] - - __module__: str - if sys.version_info >= (3, 13): - def __new__( - cls, - code: CodeType, - globals: dict[str, Any], - name: str | None = None, - argdefs: tuple[object, ...] | None = None, - closure: tuple[CellType, ...] | None = None, - kwdefaults: dict[str, object] | None = None, - ) -> Self: ... - else: - def __new__( - cls, - code: CodeType, - globals: dict[str, Any], - name: str | None = None, - argdefs: tuple[object, ...] | None = None, - closure: tuple[CellType, ...] | None = None, - ) -> Self: ... - - # mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any. - def __get__(self, instance: object, owner: type | None = None, /) -> Any: ... - @disjoint_base class list(MutableSequence[_T]): @overload @@ -1145,9 +1094,9 @@ class list(MutableSequence[_T]): def __iter__(self) -> Iterator[_T]: ... __hash__: ClassVar[None] # type: ignore[assignment] @overload - def __getitem__(self, i: SupportsIndex, /) -> _T: ... + def __getitem__(self, i: int, /) -> _T: ... @overload - def __getitem__(self, s: slice[SupportsIndex | None], /) -> list[_T]: ... + def __getitem__(self, s: slice[int | None], /) -> list[_T]: ... @overload def __setitem__(self, key: SupportsIndex, value: _T, /) -> None: ... @overload @@ -1178,13 +1127,13 @@ class dict(MutableMapping[_KT, _VT]): @overload def __init__(self, /) -> None: ... @overload - def __init__(self: dict[str, _VT], /, **kwargs: _VT) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 + def __init__(self, /, **kwargs: _VT) -> None: ... @overload - def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ... + def __init__(self, map: Mapping[_KT, _VT], /) -> None: ... @overload def __init__( - self: dict[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780 - map: SupportsKeysAndGetItem[str, _VT], + self, + map: Mapping[str, _VT], /, **kwargs: _VT, ) -> None: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index af1d1650d..aaa512bb0 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -776,7 +776,7 @@ class ValuesView(MappingView, Collection[_VT_co]): # but dict and types.MappingProxyType (the vast majority of Mapping types) # don't allow keyword arguments. -class Mapping(Collection[_KT], Generic[_KT, _VT_co]): +class Mapping(Generic[_KT, _VT_co], Collection[_KT]): # TODO: We wish the key type could also be covariant, but that doesn't work, # see discussion in https://github.com/python/typing/pull/273. @abstractmethod