diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 7ea887da9..b6b76af97 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -1,4 +1,5 @@ import sys +import types from typing import Any, Callable, Generic, Iterable, Mapping, Tuple, Type, TypeVar, overload from typing_extensions import Protocol @@ -77,7 +78,7 @@ class Field(Generic[_T]): hash: bool | None init: bool compare: bool - metadata: Mapping[Any, Any] + metadata: types.MappingProxyType[Any, Any] if sys.version_info >= (3, 10): kw_only: bool def __init__( diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index dc5dac90e..69e7bf315 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -1,4 +1,5 @@ import sys +import types from datetime import datetime as _datetime from email._header_value_parser import ( AddressList, @@ -11,7 +12,7 @@ from email._header_value_parser import ( ) from email.errors import MessageDefect from email.policy import Policy -from typing import Any, Iterable, Mapping, Tuple, Type +from typing import Any, Iterable, Tuple, Type class BaseHeader(str): @property @@ -74,7 +75,7 @@ class MIMEVersionHeader: class ParameterizedMIMEHeader: @property - def params(self) -> Mapping[str, Any]: ... + def params(self) -> types.MappingProxyType[str, Any]: ... @classmethod def parse(cls, value: str, kwds: dict[str, Any]) -> None: ... diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index 3488a7916..426bda857 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -1,7 +1,8 @@ import sys +import types from abc import ABCMeta from builtins import property as _builtins_property -from typing import Any, Iterator, Mapping, Type, TypeVar +from typing import Any, Iterator, Type, TypeVar _T = TypeVar("_T") _S = TypeVar("_S", bound=Type[Enum]) @@ -17,7 +18,7 @@ class EnumMeta(ABCMeta): def __contains__(self: Type[Any], member: object) -> bool: ... def __getitem__(self: Type[_T], name: str) -> _T: ... @_builtins_property - def __members__(self: Type[_T]) -> Mapping[str, _T]: ... + def __members__(self: Type[_T]) -> types.MappingProxyType[str, _T]: ... def __len__(self) -> int: ... _member_names_: list[str] # undocumented _member_map_: dict[str, Enum] # undocumented diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index a6327c3a8..6fe4bb6f8 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -1,21 +1,7 @@ import sys +import types from _typeshed import SupportsItems, SupportsLessThan -from typing import ( - Any, - Callable, - Generic, - Hashable, - Iterable, - Mapping, - NamedTuple, - Sequence, - Set, - Sized, - Tuple, - Type, - TypeVar, - overload, -) +from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Set, Sized, Tuple, Type, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -86,7 +72,7 @@ class partialmethod(Generic[_T]): def __class_getitem__(cls, item: Any) -> GenericAlias: ... class _SingleDispatchCallable(Generic[_T]): - registry: Mapping[Any, Callable[..., _T]] + registry: types.MappingProxyType[Any, Callable[..., _T]] def dispatch(self, cls: Any) -> Callable[..., _T]: ... # @fun.register(complex) # def _(arg, verbose=False): ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 8f8535314..4b53b8745 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -1,5 +1,6 @@ import enum import sys +import types from _typeshed import Self from collections import OrderedDict from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence, Set @@ -120,11 +121,11 @@ class Signature: def __init__(self, parameters: Sequence[Parameter] | None = ..., *, return_annotation: Any = ...) -> None: ... # TODO: can we be more specific here? empty: object - - parameters: Mapping[str, Parameter] - + @property + def parameters(self) -> types.MappingProxyType[str, Parameter]: ... # TODO: can we be more specific here? - return_annotation: Any + @property + def return_annotation(self) -> Any: ... def bind(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def replace(self: Self, *, parameters: Sequence[Parameter] | None = ..., return_annotation: Any = ...) -> Self: ...