mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Improve ABCMeta.register signature (#962)
* Improve ABCMeta.register signature * Fix ABCMeta.register return type for Python 3.3+
This commit is contained in:
committed by
Matthias Kramm
parent
8e59579953
commit
4f51a4f2fc
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, Set, Union, Tuple
|
||||
from typing import Any, Dict, Set, Tuple, Type
|
||||
import _weakrefset
|
||||
|
||||
# mypy has special processing for ABCMeta and abstractmethod.
|
||||
@@ -21,8 +21,7 @@ class ABCMeta(type):
|
||||
def __instancecheck__(cls: "ABCMeta", instance: Any) -> Any: ...
|
||||
def __subclasscheck__(cls: "ABCMeta", subclass: Any) -> Any: ...
|
||||
def _dump_registry(cls: "ABCMeta", *args: Any, **kwargs: Any) -> None: ...
|
||||
# TODO: subclass: Union["ABCMeta", type, Tuple[type, ...]]
|
||||
def register(cls: "ABCMeta", subclass: Any) -> None: ...
|
||||
def register(cls: "ABCMeta", subclass: Type[Any]) -> None: ...
|
||||
|
||||
class _C:
|
||||
pass
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
from typing import Any
|
||||
from typing import Any, Type, TypeVar
|
||||
import sys
|
||||
# Stubs for abc.
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
# Thesee definitions have special processing in type checker.
|
||||
class ABCMeta(type):
|
||||
def register(cls: "ABCMeta", subclass: Any) -> None: ...
|
||||
if sys.version_info >= (3, 3):
|
||||
def register(cls: "ABCMeta", subclass: Type[_T]) -> Type[_T]: ...
|
||||
else:
|
||||
def register(cls: "ABCMeta", subclass: Type[Any]) -> None: ...
|
||||
abstractmethod = object()
|
||||
abstractproperty = object()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user