mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 19:32:13 +08:00
typing: type decorators so they don't count as untyped lines (#5348)
This commit is contained in:
@@ -12,7 +12,6 @@ if sys.version_info >= (3, 9):
|
||||
# Definitions of special type checking related constructs. Their definitions
|
||||
# are not used, so their value does not matter.
|
||||
|
||||
overload = object()
|
||||
Any = object()
|
||||
|
||||
class TypeVar:
|
||||
@@ -35,6 +34,10 @@ _promote = object()
|
||||
class _SpecialForm:
|
||||
def __getitem__(self, typeargs: Any) -> object: ...
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
def overload(func: _F) -> _F: ...
|
||||
|
||||
Union: _SpecialForm = ...
|
||||
Optional: _SpecialForm = ...
|
||||
Tuple: _SpecialForm = ...
|
||||
@@ -46,7 +49,6 @@ Type: _SpecialForm = ...
|
||||
ClassVar: _SpecialForm = ...
|
||||
if sys.version_info >= (3, 8):
|
||||
Final: _SpecialForm = ...
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
def final(f: _F) -> _F: ...
|
||||
Literal: _SpecialForm = ...
|
||||
# TypedDict is a (non-subscriptable) special form.
|
||||
@@ -94,11 +96,9 @@ _KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
|
||||
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
|
||||
_T_contra = TypeVar("_T_contra", contravariant=True) # Ditto contravariant.
|
||||
_TC = TypeVar("_TC", bound=Type[object])
|
||||
_C = TypeVar("_C", bound=Callable[..., Any])
|
||||
|
||||
no_type_check = object()
|
||||
|
||||
def no_type_check_decorator(decorator: _C) -> _C: ...
|
||||
def no_type_check(arg: _F) -> _F: ...
|
||||
def no_type_check_decorator(decorator: _F) -> _F: ...
|
||||
|
||||
# Type aliases and type constructors
|
||||
|
||||
@@ -681,7 +681,7 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
|
||||
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...
|
||||
|
||||
# This itself is only available during type checking
|
||||
def type_check_only(func_or_cls: _C) -> _C: ...
|
||||
def type_check_only(func_or_cls: _F) -> _F: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from types import CodeType
|
||||
|
||||
Reference in New Issue
Block a user