diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index acc45cd42..3003ef061 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -1,6 +1,6 @@ import sys import types -from _typeshed import Self, SupportsAllComparisons, SupportsItems +from _typeshed import IdentityFunction, Self, SupportsAllComparisons, SupportsItems from collections.abc import Callable, Hashable, Iterable, Sequence, Sized from typing import Any, Generic, NamedTuple, TypeVar, overload from typing_extensions import Literal, TypeAlias, final @@ -68,7 +68,7 @@ WRAPPER_ASSIGNMENTS: tuple[ WRAPPER_UPDATES: tuple[Literal["__dict__"]] def update_wrapper(wrapper: _T, wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> _T: ... -def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]: ... +def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> IdentityFunction: ... def total_ordering(cls: type[_T]) -> type[_T]: ... def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], SupportsAllComparisons]: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index fee36e626..969e61952 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -1,6 +1,6 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986 import sys -from _typeshed import ReadableBuffer, Self as TypeshedSelf, SupportsKeysAndGetItem +from _typeshed import IdentityFunction, ReadableBuffer, Self as TypeshedSelf, SupportsKeysAndGetItem from abc import ABCMeta, abstractmethod from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType from typing_extensions import Literal as _Literal, ParamSpec as _ParamSpec, final as _final @@ -874,7 +874,7 @@ if sys.version_info >= (3, 11): kw_only_default: bool = ..., field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = ..., **kwargs: Any, - ) -> Callable[[_T], _T]: ... + ) -> IdentityFunction: ... # Type constructors diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index b94daaba9..38fb9dec1 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -1,6 +1,6 @@ import abc import sys -from _typeshed import Self as TypeshedSelf # see #6932 for why the alias cannot have a leading underscore +from _typeshed import IdentityFunction, Self as TypeshedSelf # see #6932 for why the Self alias cannot have a leading underscore from typing import ( # noqa: Y022,Y027,Y039 TYPE_CHECKING as TYPE_CHECKING, Any, @@ -232,4 +232,4 @@ else: kw_only_default: bool = ..., field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = ..., **kwargs: object, - ) -> Callable[[_T], _T]: ... + ) -> IdentityFunction: ... diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index 705a56507..bf8d72ba8 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -1,6 +1,6 @@ import abc -from _typeshed import Self -from collections.abc import Callable, ItemsView, KeysView, Mapping, ValuesView +from _typeshed import IdentityFunction, Self +from collections.abc import ItemsView, KeysView, Mapping, ValuesView from typing import Any, Generic, TypeVar, overload _T = TypeVar("_T") @@ -54,6 +54,6 @@ class NoReturn: ... # a class decorator, but mypy does not support type[_T] for abstract # classes until this issue is resolved, https://github.com/python/mypy/issues/4717. def trait(cls: _T) -> _T: ... -def mypyc_attr(*attrs: str, **kwattrs: object) -> Callable[[_T], _T]: ... +def mypyc_attr(*attrs: str, **kwattrs: object) -> IdentityFunction: ... class FlexibleAlias(Generic[_T, _U]): ... diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 1c79752e0..79aaf98ba 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -3,6 +3,7 @@ from __future__ import print_function import builtins import types import unittest +from _typeshed import IdentityFunction from builtins import next as next from collections.abc import Callable, ItemsView, Iterable, Iterator as _Iterator, KeysView, Mapping, ValuesView from functools import wraps as wraps @@ -83,7 +84,7 @@ def raise_from(value: BaseException | type[BaseException], from_value: BaseExcep print_ = print def with_metaclass(meta: type, *bases: type) -> type: ... -def add_metaclass(metaclass: type) -> Callable[[_T], _T]: ... +def add_metaclass(metaclass: type) -> IdentityFunction: ... def ensure_binary(s: bytes | str, encoding: str = ..., errors: str = ...) -> bytes: ... def ensure_str(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ... def ensure_text(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ...