mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-30 16:14:24 +08:00
Avoid using string literals in type annotations (#2294)
This commit is contained in:
committed by
Jelle Zijlstra
parent
25ad95de4f
commit
6192cce9d9
@@ -35,7 +35,7 @@ class BaseServer:
|
||||
def verify_request(self, request: bytes,
|
||||
client_address: Tuple[str, int]) -> bool: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
def __enter__(self) -> 'BaseServer': ...
|
||||
def __enter__(self) -> BaseServer: ...
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]],
|
||||
exc_val: Optional[BaseException],
|
||||
exc_tb: Optional[types.TracebackType]) -> bool: ...
|
||||
|
||||
@@ -7,8 +7,8 @@ class defaultdict(dict):
|
||||
def __init__(self, default: Any = ..., init: Any = ...) -> None: ...
|
||||
def __missing__(self, key) -> Any:
|
||||
raise KeyError()
|
||||
def __copy__(self) -> "defaultdict": ...
|
||||
def copy(self) -> "defaultdict": ...
|
||||
def __copy__(self) -> defaultdict: ...
|
||||
def copy(self) -> defaultdict: ...
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T2 = TypeVar('_T2')
|
||||
@@ -31,10 +31,10 @@ class deque(Generic[_T]):
|
||||
def reverse(self) -> None: ...
|
||||
def rotate(self, n: int = ...) -> None: ...
|
||||
def __contains__(self, o: Any) -> bool: ...
|
||||
def __copy__(self) -> "deque[_T]": ...
|
||||
def __copy__(self) -> deque[_T]: ...
|
||||
def __getitem__(self, i: int) -> _T:
|
||||
raise IndexError()
|
||||
def __iadd__(self, other: "deque[_T2]") -> "deque[Union[_T, _T2]]": ...
|
||||
def __iadd__(self, other: deque[_T2]) -> deque[Union[_T, _T2]]: ...
|
||||
def __iter__(self) -> Iterator[_T]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __reversed__(self) -> Iterator[_T]: ...
|
||||
|
||||
@@ -5,7 +5,7 @@ class MD5Type(object):
|
||||
name = ... # type: str
|
||||
block_size = ... # type: int
|
||||
digest_size = ... # type: int
|
||||
def copy(self) -> "MD5Type": ...
|
||||
def copy(self) -> MD5Type: ...
|
||||
def digest(self) -> str: ...
|
||||
def hexdigest(self) -> str: ...
|
||||
def update(self, arg: str) -> None: ...
|
||||
|
||||
@@ -7,7 +7,7 @@ class sha(object): # not actually exposed
|
||||
block_size = ... # type: int
|
||||
digest_size = ... # type: int
|
||||
digestsize = ... # type: int
|
||||
def copy(self) -> "sha": ...
|
||||
def copy(self) -> sha: ...
|
||||
def digest(self) -> str: ...
|
||||
def hexdigest(self) -> str: ...
|
||||
def update(self, arg: str) -> None: ...
|
||||
|
||||
@@ -6,7 +6,7 @@ class sha224(object):
|
||||
digest_size = ... # type: int
|
||||
digestsize = ... # type: int
|
||||
def __init__(self, init: Optional[str]) -> None: ...
|
||||
def copy(self) -> "sha224": ...
|
||||
def copy(self) -> sha224: ...
|
||||
def digest(self) -> str: ...
|
||||
def hexdigest(self) -> str: ...
|
||||
def update(self, arg: str) -> None: ...
|
||||
@@ -17,7 +17,7 @@ class sha256(object):
|
||||
digest_size = ... # type: int
|
||||
digestsize = ... # type: int
|
||||
def __init__(self, init: Optional[str]) -> None: ...
|
||||
def copy(self) -> "sha256": ...
|
||||
def copy(self) -> sha256: ...
|
||||
def digest(self) -> str: ...
|
||||
def hexdigest(self) -> str: ...
|
||||
def update(self, arg: str) -> None: ...
|
||||
|
||||
@@ -6,7 +6,7 @@ class sha384(object):
|
||||
digest_size = ... # type: int
|
||||
digestsize = ... # type: int
|
||||
def __init__(self, init: Optional[str]) -> None: ...
|
||||
def copy(self) -> "sha384": ...
|
||||
def copy(self) -> sha384: ...
|
||||
def digest(self) -> str: ...
|
||||
def hexdigest(self) -> str: ...
|
||||
def update(self, arg: str) -> None: ...
|
||||
@@ -17,7 +17,7 @@ class sha512(object):
|
||||
digest_size = ... # type: int
|
||||
digestsize = ... # type: int
|
||||
def __init__(self, init: Optional[str]) -> None: ...
|
||||
def copy(self) -> "sha512": ...
|
||||
def copy(self) -> sha512: ...
|
||||
def digest(self) -> str: ...
|
||||
def hexdigest(self) -> str: ...
|
||||
def update(self, arg: str) -> None: ...
|
||||
|
||||
@@ -253,14 +253,14 @@ class SocketType(object):
|
||||
timeout = ... # type: float
|
||||
|
||||
def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ...
|
||||
def accept(self) -> Tuple['SocketType', tuple]: ...
|
||||
def accept(self) -> Tuple[SocketType, tuple]: ...
|
||||
def bind(self, address: tuple) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def connect(self, address: tuple) -> None:
|
||||
raise gaierror
|
||||
raise timeout
|
||||
def connect_ex(self, address: tuple) -> int: ...
|
||||
def dup(self) -> "SocketType": ...
|
||||
def dup(self) -> SocketType: ...
|
||||
def fileno(self) -> int: ...
|
||||
def getpeername(self) -> tuple: ...
|
||||
def getsockname(self) -> tuple: ...
|
||||
|
||||
@@ -14,10 +14,10 @@ class ABCMeta(type):
|
||||
_abc_negative_cache_version = ... # type: int
|
||||
_abc_registry = ... # type: _weakrefset.WeakSet
|
||||
def __init__(self, name: str, bases: Tuple[type, ...], namespace: Dict[Any, Any]) -> None: ...
|
||||
def __instancecheck__(cls: "ABCMeta", instance: Any) -> Any: ...
|
||||
def __subclasscheck__(cls: "ABCMeta", subclass: Any) -> Any: ...
|
||||
def _dump_registry(cls: "ABCMeta", *args: Any, **kwargs: Any) -> None: ...
|
||||
def register(cls: "ABCMeta", subclass: Type[Any]) -> None: ...
|
||||
def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ...
|
||||
def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ...
|
||||
def _dump_registry(cls: ABCMeta, *args: Any, **kwargs: Any) -> None: ...
|
||||
def register(cls: ABCMeta, subclass: Type[Any]) -> None: ...
|
||||
|
||||
# TODO: The real abc.abstractproperty inherits from "property".
|
||||
class abstractproperty(object):
|
||||
|
||||
@@ -22,7 +22,7 @@ class InputType(IO[str], Iterator[str], metaclass=ABCMeta):
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: Optional[int] = ...) -> int: ...
|
||||
def __iter__(self) -> 'InputType': ...
|
||||
def __iter__(self) -> InputType: ...
|
||||
def next(self) -> str: ...
|
||||
def reset(self) -> None: ...
|
||||
|
||||
@@ -42,7 +42,7 @@ class OutputType(IO[str], Iterator[str], metaclass=ABCMeta):
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: Optional[int] = ...) -> int: ...
|
||||
def __iter__(self) -> 'OutputType': ...
|
||||
def __iter__(self) -> OutputType: ...
|
||||
def next(self) -> str: ...
|
||||
def reset(self) -> None: ...
|
||||
def write(self, b: Union[str, unicode]) -> int: ...
|
||||
|
||||
@@ -100,7 +100,7 @@ class Popen:
|
||||
def send_signal(self, signal: int) -> None: ...
|
||||
def terminate(self) -> None: ...
|
||||
def kill(self) -> None: ...
|
||||
def __enter__(self) -> 'Popen': ...
|
||||
def __enter__(self) -> Popen: ...
|
||||
def __exit__(self, type, value, traceback) -> bool: ...
|
||||
|
||||
# Windows-only: STARTUPINFO etc.
|
||||
|
||||
@@ -44,7 +44,7 @@ class FunctionType:
|
||||
__globals__ = func_globals
|
||||
__name__ = func_name
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __get__(self, obj: Optional[object], type: Optional[type]) -> 'UnboundMethodType': ...
|
||||
def __get__(self, obj: Optional[object], type: Optional[type]) -> UnboundMethodType: ...
|
||||
|
||||
LambdaType = FunctionType
|
||||
|
||||
@@ -68,14 +68,14 @@ class GeneratorType:
|
||||
gi_code = ... # type: CodeType
|
||||
gi_frame = ... # type: FrameType
|
||||
gi_running = ... # type: int
|
||||
def __iter__(self) -> 'GeneratorType': ...
|
||||
def __iter__(self) -> GeneratorType: ...
|
||||
def close(self) -> None: ...
|
||||
def next(self) -> Any: ...
|
||||
def send(self, arg: Any) -> Any: ...
|
||||
@overload
|
||||
def throw(self, val: BaseException) -> Any: ...
|
||||
@overload
|
||||
def throw(self, typ: type, val: BaseException = ..., tb: 'TracebackType' = ...) -> Any: ...
|
||||
def throw(self, typ: type, val: BaseException = ..., tb: TracebackType = ...) -> Any: ...
|
||||
|
||||
class ClassType: ...
|
||||
class UnboundMethodType:
|
||||
|
||||
@@ -360,7 +360,7 @@ class Match(Generic[AnyStr]):
|
||||
|
||||
# The regular expression object whose match() or search() method produced
|
||||
# this match instance.
|
||||
re = ... # type: 'Pattern[AnyStr]'
|
||||
re = ... # type: Pattern[AnyStr]
|
||||
|
||||
def expand(self, template: AnyStr) -> AnyStr: ...
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ _Regexp = Union[Text, Pattern[Text]]
|
||||
|
||||
class Testable(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def run(self, result: 'TestResult') -> None: ...
|
||||
def run(self, result: TestResult) -> None: ...
|
||||
@abstractmethod
|
||||
def debug(self) -> None: ...
|
||||
@abstractmethod
|
||||
|
||||
Reference in New Issue
Block a user