1
1
import sys
2
2
import types
3
- from _typeshed import SupportsAllComparisons , SupportsItems
3
+ from _typeshed import IdentityFunction , SupportsAllComparisons , SupportsItems
4
4
from collections .abc import Callable , Hashable , Iterable , Sequence , Sized
5
5
from typing import Any , Generic , NamedTuple , TypeVar , overload
6
- from typing_extensions import Literal , ParamSpec , Self , TypeAlias , final
6
+ from typing_extensions import Literal , Self , TypeAlias , final
7
7
8
8
if sys .version_info >= (3 , 9 ):
9
9
from types import GenericAlias
@@ -28,12 +28,10 @@ if sys.version_info >= (3, 8):
28
28
if sys .version_info >= (3 , 9 ):
29
29
__all__ += ["cache" ]
30
30
31
+ _AnyCallable : TypeAlias = Callable [..., object ]
32
+
31
33
_T = TypeVar ("_T" )
32
34
_S = TypeVar ("_S" )
33
- _PWrapped = ParamSpec ("_PWrapped" )
34
- _RWrapped = TypeVar ("_RWrapped" )
35
- _PWrapper = ParamSpec ("_PWrapper" )
36
- _RWapper = TypeVar ("_RWapper" )
37
35
38
36
@overload
39
37
def reduce (function : Callable [[_T , _S ], _T ], sequence : Iterable [_S ], initial : _T ) -> _T : ...
@@ -69,27 +67,17 @@ WRAPPER_ASSIGNMENTS: tuple[
69
67
]
70
68
WRAPPER_UPDATES : tuple [Literal ["__dict__" ]]
71
69
72
- class _Wrapped (Generic [_PWrapped , _RWrapped , _PWrapper , _RWapper ]):
73
- __wrapped__ : Callable [_PWrapped , _RWrapped ]
74
- def __call__ (self , * args : _PWrapper .args , ** kwargs : _PWrapper .kwargs ) -> _RWapper : ...
75
- # as with ``Callable``, we'll assume that these attributes exist
76
- __name__ : str
77
- __qualname__ : str
78
-
79
- class _Wrapper (Generic [_PWrapped , _RWrapped ]):
80
- def __call__ (self , f : Callable [_PWrapper , _RWapper ]) -> _Wrapped [_PWrapped , _RWrapped , _PWrapper , _RWapper ]: ...
81
-
82
70
def update_wrapper (
83
- wrapper : Callable [ _PWrapper , _RWapper ] ,
84
- wrapped : Callable [ _PWrapped , _RWrapped ] ,
71
+ wrapper : _T ,
72
+ wrapped : _AnyCallable ,
85
73
assigned : Sequence [str ] = ("__module__" , "__name__" , "__qualname__" , "__doc__" , "__annotations__" ),
86
74
updated : Sequence [str ] = ("__dict__" ,),
87
- ) -> _Wrapped [ _PWrapped , _RWrapped , _PWrapper , _RWapper ] : ...
75
+ ) -> _T : ...
88
76
def wraps (
89
- wrapped : Callable [ _PWrapped , _RWrapped ] ,
77
+ wrapped : _AnyCallable ,
90
78
assigned : Sequence [str ] = ("__module__" , "__name__" , "__qualname__" , "__doc__" , "__annotations__" ),
91
79
updated : Sequence [str ] = ("__dict__" ,),
92
- ) -> _Wrapper [ _PWrapped , _RWrapped ] : ...
80
+ ) -> IdentityFunction : ...
93
81
def total_ordering (cls : type [_T ]) -> type [_T ]: ...
94
82
def cmp_to_key (mycmp : Callable [[_T , _T ], int ]) -> Callable [[_T ], SupportsAllComparisons ]: ...
95
83
0 commit comments