Skip to content

Commit 5e23409

Browse files
committed
Use defaults for _SingleDispatchCallable
1 parent ba3c5da commit 5e23409

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

stdlib/functools.pyi

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ __all__ = [
2626
_T = TypeVar("_T")
2727
_T_co = TypeVar("_T_co", covariant=True)
2828
_S = TypeVar("_S")
29-
_P = ParamSpec("_P")
29+
_P = ParamSpec("_P", default=Any)
30+
_R = TypeVar("_R", default=Any)
3031
_PWrapped = ParamSpec("_PWrapped")
3132
_RWrapped = TypeVar("_RWrapped")
3233
_PWrapper = ParamSpec("_PWrapper")
@@ -191,68 +192,68 @@ class partialmethod(Generic[_T]):
191192
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
192193

193194
@type_check_only
194-
class _SingleDispatchCallable(Generic[_P, _T]):
195+
class _SingleDispatchCallable(Generic[_P, _R]):
195196
# First argument pf the callables in the registry is the type to dispatch on.
196-
registry: types.MappingProxyType[Any, Callable[Concatenate[Any, _P], _T]]
197-
def dispatch(self, cls: type[_S]) -> Callable[Concatenate[_S, _P], _T]: ...
197+
registry: types.MappingProxyType[Any, Callable[Concatenate[Any, _P], _R]]
198+
def dispatch(self, cls: type[_S]) -> Callable[Concatenate[_S, _P], _R]: ...
198199
if sys.version_info >= (3, 11):
199200
# @fun.register(complex | str)
200201
# def _(arg, verbose=False): ...
201202
@overload
202203
def register(
203204
self, cls: types.UnionType, func: None = None
204-
) -> Callable[[Callable[Concatenate[_S, _P], _T]], Callable[Concatenate[_S, _P], _T]]: ...
205+
) -> Callable[[Callable[Concatenate[_S, _P], _R]], Callable[Concatenate[_S, _P], _R]]: ...
205206
# @fun.register(complex)
206207
# def _(arg, verbose=False): ...
207208
@overload
208209
def register( # type: ignore[overload-overlap]
209210
self, cls: type[_S], func: None = None
210-
) -> Callable[[Callable[Concatenate[_S, _P], _T]], Callable[Concatenate[_S, _P], _T]]: ...
211+
) -> Callable[[Callable[Concatenate[_S, _P], _R]], Callable[Concatenate[_S, _P], _R]]: ...
211212
# @fun.register
212213
# def _(arg: int, verbose=False):
213214
@overload
214-
def register(self, cls: Callable[Concatenate[_S, _P], _T], func: None = None) -> Callable[Concatenate[_S, _P], _T]: ...
215+
def register(self, cls: Callable[Concatenate[_S, _P], _R], func: None = None) -> Callable[Concatenate[_S, _P], _R]: ...
215216
if sys.version_info >= (3, 11):
216217
# fun.register(int, lambda x: x)
217218
@overload
218219
def register(
219-
self, cls: types.UnionType, func: Callable[Concatenate[_S, _P], _T]
220-
) -> Callable[Concatenate[_S, _P], _T]: ...
220+
self, cls: types.UnionType, func: Callable[Concatenate[_S, _P], _R]
221+
) -> Callable[Concatenate[_S, _P], _R]: ...
221222
# fun.register(int, lambda x: x)
222223
@overload
223-
def register(self, cls: type[_S], func: Callable[Concatenate[_S, _P], _T]) -> Callable[Concatenate[_S, _P], _T]: ...
224+
def register(self, cls: type[_S], func: Callable[Concatenate[_S, _P], _R]) -> Callable[Concatenate[_S, _P], _R]: ...
224225
def _clear_cache(self) -> None: ...
225-
def __call__(self, arg: object, /, *args: _P.args, **kwargs: _P.kwargs) -> _T: ...
226+
def __call__(self, arg: object, /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ...
226227

227-
def singledispatch(func: Callable[Concatenate[object, _P], _T]) -> _SingleDispatchCallable[_P, _T]: ...
228+
def singledispatch(func: Callable[Concatenate[object, _P], _R]) -> _SingleDispatchCallable[_P, _R]: ...
228229

229-
class singledispatchmethod(Generic[_P, _T]):
230-
dispatcher: _SingleDispatchCallable[_P, _T]
231-
func: Callable[_P, _T]
232-
def __init__(self, func: Callable[Concatenate[object, _P], _T]) -> None: ...
230+
class singledispatchmethod(Generic[_P, _R]):
231+
dispatcher: _SingleDispatchCallable[_P, _R]
232+
func: Callable[_P, _R]
233+
def __init__(self, func: Callable[Concatenate[object, _P], _R]) -> None: ...
233234
@property
234235
def __isabstractmethod__(self) -> bool: ...
235236
if sys.version_info >= (3, 11):
236237
@overload
237238
def register(
238239
self, cls: types.UnionType, method: None = None
239-
) -> Callable[[Callable[Concatenate[_S, _P], _T]], Callable[Concatenate[_S, _P], _T]]: ...
240+
) -> Callable[[Callable[Concatenate[_S, _P], _R]], Callable[Concatenate[_S, _P], _R]]: ...
240241

241242
@overload
242243
def register( # type: ignore[overload-overlap]
243244
self, cls: type[_S], method: None = None
244-
) -> Callable[[Callable[Concatenate[_S, _P], _T]], Callable[Concatenate[_S, _P], _T]]: ...
245+
) -> Callable[[Callable[Concatenate[_S, _P], _R]], Callable[Concatenate[_S, _P], _R]]: ...
245246
@overload
246-
def register(self, cls: Callable[Concatenate[_S, _P], _T], method: None = None) -> Callable[Concatenate[_S, _P], _T]: ...
247+
def register(self, cls: Callable[Concatenate[_S, _P], _R], method: None = None) -> Callable[Concatenate[_S, _P], _R]: ...
247248
if sys.version_info >= (3, 11):
248249
@overload
249250
def register(
250-
self, cls: types.UnionType, method: Callable[Concatenate[_S, _P], _T]
251-
) -> Callable[Concatenate[_S, _P], _T]: ...
251+
self, cls: types.UnionType, method: Callable[Concatenate[_S, _P], _R]
252+
) -> Callable[Concatenate[_S, _P], _R]: ...
252253

253254
@overload
254-
def register(self, cls: type[_S], method: Callable[Concatenate[_S, _P], _T]) -> Callable[Concatenate[_S, _P], _T]: ...
255-
def __get__(self, obj: _S, cls: type[_S] | None = None) -> Callable[Concatenate[_S, _P], _T]: ...
255+
def register(self, cls: type[_S], method: Callable[Concatenate[_S, _P], _R]) -> Callable[Concatenate[_S, _P], _R]: ...
256+
def __get__(self, obj: _S, cls: type[_S] | None = None) -> Callable[Concatenate[_S, _P], _R]: ...
256257

257258
class cached_property(Generic[_T_co]):
258259
func: Callable[[Any], _T_co]

0 commit comments

Comments
 (0)