mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-02 17:43:25 +08:00
Add singledispatchmethod to singledispatch (#6089)
This commit is contained in:
1
stubs/singledispatch/@tests/stubtest_allowlist.txt
Normal file
1
stubs/singledispatch/@tests/stubtest_allowlist.txt
Normal file
@@ -0,0 +1 @@
|
||||
singledispatch.singledispatchmethod.__call__ # A lie to reflect that the descriptor get returns a callable
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable, Generic, Mapping, TypeVar, overload
|
||||
from typing import Any, Callable, Generic, Mapping, Type, TypeVar, overload
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@@ -13,3 +13,15 @@ class _SingleDispatchCallable(Generic[_T]):
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
|
||||
|
||||
def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ...
|
||||
|
||||
class singledispatchmethod(Generic[_T]):
|
||||
dispatcher: _SingleDispatchCallable[_T]
|
||||
func: Callable[..., _T]
|
||||
def __init__(self, func: Callable[..., _T]) -> None: ...
|
||||
@overload
|
||||
def register(self, cls: Type[Any], method: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
|
||||
@overload
|
||||
def register(self, cls: Callable[..., _T], method: None = ...) -> Callable[..., _T]: ...
|
||||
@overload
|
||||
def register(self, cls: Type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
|
||||
|
||||
Reference in New Issue
Block a user