Improve abc module and builtin function decorators (#5703)

This commit is contained in:
Sebastian Rittau
2022-02-02 16:22:32 +01:00
committed by GitHub
parent 584336a41e
commit 2dc53caffe
4 changed files with 26 additions and 22 deletions

View File

@@ -1,8 +1,11 @@
import sys
from _typeshed import SupportsWrite
from typing import Any, Callable, TypeVar
from collections.abc import Callable
from typing import Any, Generic, TypeVar
from typing_extensions import Literal
_T = TypeVar("_T")
_R_co = TypeVar("_R_co", covariant=True)
_FuncT = TypeVar("_FuncT", bound=Callable[..., Any])
# These definitions have special processing in mypy
@@ -16,12 +19,15 @@ class ABCMeta(type):
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
class abstractclassmethod(classmethod[_R_co], Generic[_R_co]):
__isabstractmethod__: Literal[True]
def __init__(self: abstractclassmethod[_R_co], callable: Callable[..., _R_co]) -> None: ...
class abstractstaticmethod(staticmethod[_R_co], Generic[_R_co]):
__isabstractmethod__: Literal[True]
def __init__(self, callable: Callable[..., _R_co]) -> None: ...
class abstractproperty(property): ...
# These two are deprecated and not supported by mypy
def abstractstaticmethod(callable: _FuncT) -> _FuncT: ...
def abstractclassmethod(callable: _FuncT) -> _FuncT: ...
class ABC(metaclass=ABCMeta): ...
def get_cache_token() -> object: ...