@@ -151,20 +151,25 @@ class partialmethod(Generic[_T]):
151
151
if sys .version_info >= (3 , 9 ):
152
152
def __class_getitem__ (cls , item : Any , / ) -> GenericAlias : ...
153
153
154
+ if sys .version_info >= (3 , 11 ):
155
+ _RegType : TypeAlias = type [Any ] | types .UnionType
156
+ else :
157
+ _RegType : TypeAlias = type [Any ]
158
+
154
159
class _SingleDispatchCallable (Generic [_T ]):
155
160
registry : types .MappingProxyType [Any , Callable [..., _T ]]
156
161
def dispatch (self , cls : Any ) -> Callable [..., _T ]: ...
157
162
# @fun.register(complex)
158
163
# def _(arg, verbose=False): ...
159
164
@overload
160
- def register (self , cls : type [ Any ] , func : None = None ) -> Callable [[Callable [..., _T ]], Callable [..., _T ]]: ...
165
+ def register (self , cls : _RegType , func : None = None ) -> Callable [[Callable [..., _T ]], Callable [..., _T ]]: ...
161
166
# @fun.register
162
167
# def _(arg: int, verbose=False):
163
168
@overload
164
169
def register (self , cls : Callable [..., _T ], func : None = None ) -> Callable [..., _T ]: ...
165
170
# fun.register(int, lambda x: x)
166
171
@overload
167
- def register (self , cls : type [ Any ] , func : Callable [..., _T ]) -> Callable [..., _T ]: ...
172
+ def register (self , cls : _RegType , func : Callable [..., _T ]) -> Callable [..., _T ]: ...
168
173
def _clear_cache (self ) -> None : ...
169
174
def __call__ (self , / , * args : Any , ** kwargs : Any ) -> _T : ...
170
175
@@ -177,11 +182,11 @@ class singledispatchmethod(Generic[_T]):
177
182
@property
178
183
def __isabstractmethod__ (self ) -> bool : ...
179
184
@overload
180
- def register (self , cls : type [ Any ] , method : None = None ) -> Callable [[Callable [..., _T ]], Callable [..., _T ]]: ...
185
+ def register (self , cls : _RegType , method : None = None ) -> Callable [[Callable [..., _T ]], Callable [..., _T ]]: ...
181
186
@overload
182
187
def register (self , cls : Callable [..., _T ], method : None = None ) -> Callable [..., _T ]: ...
183
188
@overload
184
- def register (self , cls : type [ Any ] , method : Callable [..., _T ]) -> Callable [..., _T ]: ...
189
+ def register (self , cls : _RegType , method : Callable [..., _T ]) -> Callable [..., _T ]: ...
185
190
def __get__ (self , obj : _S , cls : type [_S ] | None = None ) -> Callable [..., _T ]: ...
186
191
187
192
class cached_property (Generic [_T_co ]):
0 commit comments