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 , TypedDict , final
6
+ from typing_extensions import Literal , Self , TypeAlias , TypedDict , 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
- _RWrapper = TypeVar ("_RWrapper" )
37
35
38
36
@overload
39
37
def reduce (__function : Callable [[_T , _S ], _T ], __sequence : Iterable [_S ], __initial : _T ) -> _T : ...
@@ -87,41 +85,31 @@ else:
87
85
]
88
86
WRAPPER_UPDATES : tuple [Literal ["__dict__" ]]
89
87
90
- class _Wrapped (Generic [_PWrapped , _RWrapped , _PWrapper , _RWrapper ]):
91
- __wrapped__ : Callable [_PWrapped , _RWrapped ]
92
- def __call__ (self , * args : _PWrapper .args , ** kwargs : _PWrapper .kwargs ) -> _RWrapper : ...
93
- # as with ``Callable``, we'll assume that these attributes exist
94
- __name__ : str
95
- __qualname__ : str
96
-
97
- class _Wrapper (Generic [_PWrapped , _RWrapped ]):
98
- def __call__ (self , f : Callable [_PWrapper , _RWrapper ]) -> _Wrapped [_PWrapped , _RWrapped , _PWrapper , _RWrapper ]: ...
99
-
100
88
if sys .version_info >= (3 , 12 ):
101
89
def update_wrapper (
102
- wrapper : Callable [ _PWrapper , _RWrapper ] ,
103
- wrapped : Callable [ _PWrapped , _RWrapped ] ,
90
+ wrapper : _T ,
91
+ wrapped : _AnyCallable ,
104
92
assigned : Sequence [str ] = ("__module__" , "__name__" , "__qualname__" , "__doc__" , "__annotations__" , "__type_params__" ),
105
93
updated : Sequence [str ] = ("__dict__" ,),
106
- ) -> _Wrapped [ _PWrapped , _RWrapped , _PWrapper , _RWrapper ] : ...
94
+ ) -> _T : ...
107
95
def wraps (
108
- wrapped : Callable [ _PWrapped , _RWrapped ] ,
96
+ wrapped : _AnyCallable ,
109
97
assigned : Sequence [str ] = ("__module__" , "__name__" , "__qualname__" , "__doc__" , "__annotations__" , "__type_params__" ),
110
98
updated : Sequence [str ] = ("__dict__" ,),
111
- ) -> _Wrapper [ _PWrapped , _RWrapped ] : ...
99
+ ) -> IdentityFunction : ...
112
100
113
101
else :
114
102
def update_wrapper (
115
- wrapper : Callable [ _PWrapper , _RWrapper ] ,
116
- wrapped : Callable [ _PWrapped , _RWrapped ] ,
103
+ wrapper : _T ,
104
+ wrapped : _AnyCallable ,
117
105
assigned : Sequence [str ] = ("__module__" , "__name__" , "__qualname__" , "__doc__" , "__annotations__" ),
118
106
updated : Sequence [str ] = ("__dict__" ,),
119
- ) -> _Wrapped [ _PWrapped , _RWrapped , _PWrapper , _RWrapper ] : ...
107
+ ) -> _T : ...
120
108
def wraps (
121
- wrapped : Callable [ _PWrapped , _RWrapped ] ,
109
+ wrapped : _AnyCallable ,
122
110
assigned : Sequence [str ] = ("__module__" , "__name__" , "__qualname__" , "__doc__" , "__annotations__" ),
123
111
updated : Sequence [str ] = ("__dict__" ,),
124
- ) -> _Wrapper [ _PWrapped , _RWrapped ] : ...
112
+ ) -> IdentityFunction : ...
125
113
126
114
def total_ordering (cls : type [_T ]) -> type [_T ]: ...
127
115
def cmp_to_key (mycmp : Callable [[_T , _T ], int ]) -> Callable [[_T ], SupportsAllComparisons ]: ...
0 commit comments