Skip to content

Commit b1761f4

Browse files
AlexWaygoodJelleZijlstra
authored andcommitted
Revert use of ParamSpec for functools.wraps
1 parent d198719 commit b1761f4

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

mypy/typeshed/stdlib/functools.pyi

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import sys
22
import types
3-
from _typeshed import SupportsAllComparisons, SupportsItems
3+
from _typeshed import IdentityFunction, SupportsAllComparisons, SupportsItems
44
from collections.abc import Callable, Hashable, Iterable, Sequence, Sized
55
from typing import Any, Generic, NamedTuple, TypeVar, overload
6-
from typing_extensions import Literal, ParamSpec, Self, TypeAlias, TypedDict, final
6+
from typing_extensions import Literal, Self, TypeAlias, TypedDict, final
77

88
if sys.version_info >= (3, 9):
99
from types import GenericAlias
@@ -28,12 +28,10 @@ if sys.version_info >= (3, 8):
2828
if sys.version_info >= (3, 9):
2929
__all__ += ["cache"]
3030

31+
_AnyCallable: TypeAlias = Callable[..., object]
32+
3133
_T = TypeVar("_T")
3234
_S = TypeVar("_S")
33-
_PWrapped = ParamSpec("_PWrapped")
34-
_RWrapped = TypeVar("_RWrapped")
35-
_PWrapper = ParamSpec("_PWrapper")
36-
_RWapper = TypeVar("_RWapper")
3735

3836
@overload
3937
def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ...
@@ -77,27 +75,17 @@ WRAPPER_ASSIGNMENTS: tuple[
7775
]
7876
WRAPPER_UPDATES: tuple[Literal["__dict__"]]
7977

80-
class _Wrapped(Generic[_PWrapped, _RWrapped, _PWrapper, _RWapper]):
81-
__wrapped__: Callable[_PWrapped, _RWrapped]
82-
def __call__(self, *args: _PWrapper.args, **kwargs: _PWrapper.kwargs) -> _RWapper: ...
83-
# as with ``Callable``, we'll assume that these attributes exist
84-
__name__: str
85-
__qualname__: str
86-
87-
class _Wrapper(Generic[_PWrapped, _RWrapped]):
88-
def __call__(self, f: Callable[_PWrapper, _RWapper]) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWapper]: ...
89-
9078
def update_wrapper(
91-
wrapper: Callable[_PWrapper, _RWapper],
92-
wrapped: Callable[_PWrapped, _RWrapped],
79+
wrapper: _T,
80+
wrapped: _AnyCallable,
9381
assigned: Sequence[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotations__"),
9482
updated: Sequence[str] = ("__dict__",),
95-
) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWapper]: ...
83+
) -> _T: ...
9684
def wraps(
97-
wrapped: Callable[_PWrapped, _RWrapped],
85+
wrapped: _AnyCallable,
9886
assigned: Sequence[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotations__"),
9987
updated: Sequence[str] = ("__dict__",),
100-
) -> _Wrapper[_PWrapped, _RWrapped]: ...
88+
) -> IdentityFunction: ...
10189
def total_ordering(cls: type[_T]) -> type[_T]: ...
10290
def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], SupportsAllComparisons]: ...
10391

0 commit comments

Comments
 (0)