Fix singledispatch register signature (#13578)

This commit is contained in:
Philipp A.
2025-03-04 14:52:07 +01:00
committed by GitHub
parent 63e6ea8821
commit 714c99bbdb
+9 -4
View File
@@ -151,20 +151,25 @@ class partialmethod(Generic[_T]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 11):
_RegType: TypeAlias = type[Any] | types.UnionType
else:
_RegType: TypeAlias = type[Any]
class _SingleDispatchCallable(Generic[_T]):
registry: types.MappingProxyType[Any, Callable[..., _T]]
def dispatch(self, cls: Any) -> Callable[..., _T]: ...
# @fun.register(complex)
# def _(arg, verbose=False): ...
@overload
def register(self, cls: type[Any], func: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def register(self, cls: _RegType, func: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
# @fun.register
# def _(arg: int, verbose=False):
@overload
def register(self, cls: Callable[..., _T], func: None = None) -> Callable[..., _T]: ...
# fun.register(int, lambda x: x)
@overload
def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ...
def register(self, cls: _RegType, func: Callable[..., _T]) -> Callable[..., _T]: ...
def _clear_cache(self) -> None: ...
def __call__(self, /, *args: Any, **kwargs: Any) -> _T: ...
@@ -177,11 +182,11 @@ class singledispatchmethod(Generic[_T]):
@property
def __isabstractmethod__(self) -> bool: ...
@overload
def register(self, cls: type[Any], method: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def register(self, cls: _RegType, method: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
@overload
def register(self, cls: Callable[..., _T], method: None = None) -> Callable[..., _T]: ...
@overload
def register(self, cls: type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ...
def register(self, cls: _RegType, method: Callable[..., _T]) -> Callable[..., _T]: ...
def __get__(self, obj: _S, cls: type[_S] | None = None) -> Callable[..., _T]: ...
class cached_property(Generic[_T_co]):