Enable --disallow-any-generics for stubs (#3288)

This commit is contained in:
Sebastian Rittau
2019-10-01 14:31:34 +02:00
committed by Jelle Zijlstra
parent 23b353303b
commit c32e1e2280
77 changed files with 386 additions and 329 deletions

View File

@@ -55,8 +55,8 @@ class _Readable(Protocol):
class RawConfigParser:
_dict: Any
_sections: dict
_defaults: dict
_sections: Dict[Any, Any]
_defaults: Dict[Any, Any]
_optcre: Any
SECTCRE: Any
OPTCRE: Any
@@ -86,12 +86,14 @@ class RawConfigParser:
class ConfigParser(RawConfigParser):
_KEYCRE: Any
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[dict] = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Optional[dict] = ...) -> List[Tuple[str, Any]]: ...
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> List[Tuple[str, Any]]: ...
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolation_replace(self, match: Any) -> str: ...
class SafeConfigParser(ConfigParser):
_interpvar_re: Any
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolate_some(self, option: str, accum: list, rest: str, section: str, map: dict, depth: int) -> None: ...
def _interpolate_some(
self, option: str, accum: List[Any], rest: str, section: str, map: Dict[Any, Any], depth: int,
) -> None: ...

View File

@@ -1,8 +1,8 @@
from typing import Any, Optional
from typing import Any, Dict, Optional
class CookieError(Exception): ...
class Morsel(dict):
class Morsel(Dict[Any, Any]):
key: Any
def __init__(self): ...
def __setitem__(self, K, V): ...
@@ -14,7 +14,7 @@ class Morsel(dict):
def js_output(self, attrs: Optional[Any] = ...): ...
def OutputString(self, attrs: Optional[Any] = ...): ...
class BaseCookie(dict):
class BaseCookie(Dict[Any, Any]):
def value_decode(self, val): ...
def value_encode(self, val): ...
def __init__(self, input: Optional[Any] = ...): ...

View File

@@ -1,7 +1,7 @@
# Stubs for Queue (Python 2)
from collections import deque
from typing import Any, TypeVar, Generic, Optional
from typing import Any, Deque, TypeVar, Generic, Optional
_T = TypeVar('_T')
@@ -15,7 +15,7 @@ class Queue(Generic[_T]):
not_full: Any
all_tasks_done: Any
unfinished_tasks: Any
queue: deque # undocumented
queue: Deque[Any] # undocumented
def __init__(self, maxsize: int = ...) -> None: ...
def task_done(self) -> None: ...
def join(self) -> None: ...

View File

@@ -9,7 +9,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self) -> None: ...
def do_HEAD(self) -> None: ...
def send_head(self) -> Optional[IO[str]]: ...
def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO]: ...
def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO[Any]]: ...
def translate_path(self, path: AnyStr) -> AnyStr: ...
def copyfile(self, source: IO[AnyStr], outputfile: IO[AnyStr]): ...
def guess_type(self, path: Union[str, unicode]) -> str: ...

View File

@@ -1,7 +1,7 @@
from typing import Iterable, MutableSequence, TypeVar, Union, overload
_T = TypeVar("_T")
_ULT = TypeVar("_ULT", bound=UserList)
_S = TypeVar("_S")
class UserList(MutableSequence[_T]):
def insert(self, index: int, object: _T) -> None: ...
@@ -14,5 +14,5 @@ class UserList(MutableSequence[_T]):
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
def __getitem__(self: _ULT, s: slice) -> _ULT: ...
def __getitem__(self: _S, s: slice) -> _S: ...
def sort(self) -> None: ...

View File

@@ -870,7 +870,7 @@ class tuple(Sequence[_T_co], Generic[_T_co]):
@overload
def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ...
@overload
def __add__(self, x: tuple) -> tuple: ...
def __add__(self, x: Tuple[Any, ...]) -> Tuple[Any, ...]: ...
def __mul__(self, n: int) -> Tuple[_T_co, ...]: ...
def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ...
def count(self, x: Any) -> int: ...

View File

@@ -1,18 +1,19 @@
"""Stub file for the '_collections' module."""
from typing import Any, Generic, Iterator, TypeVar, Optional, Union
class defaultdict(dict):
default_factory: None
def __init__(self, default: Any = ..., init: Any = ...) -> None: ...
def __missing__(self, key) -> Any:
raise KeyError()
def __copy__(self) -> defaultdict: ...
def copy(self) -> defaultdict: ...
from typing import Any, Callable, Dict, Generic, Iterator, TypeVar, Optional, Union
_K = TypeVar("_K")
_V = TypeVar("_V")
_T = TypeVar('_T')
_T2 = TypeVar('_T2')
class defaultdict(Dict[_K, _V]):
default_factory: None
def __init__(self, __default_factory: Callable[[], _V] = ..., init: Any = ...) -> None: ...
def __missing__(self, key: _K) -> _V: ...
def __copy__(self: _T) -> _T: ...
def copy(self: _T) -> _T: ...
class deque(Generic[_T]):
maxlen: Optional[int]
def __init__(self, iterable: Iterator[_T] = ..., maxlen: int = ...) -> None: ...

View File

@@ -14,7 +14,7 @@ def logreader(a: str) -> LogReaderType:
def profiler(a: str, *args, **kwargs) -> Any:
raise IOError()
def resolution() -> tuple: ...
def resolution() -> Tuple[Any, ...]: ...
class LogReaderType(object):

View File

@@ -84,8 +84,8 @@ class BufferedWriter(_BufferedIOBase):
class BytesIO(_BufferedIOBase):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
def __setstate__(self, tuple) -> None: ...
def __getstate__(self) -> tuple: ...
def __setstate__(self, state: Tuple[Any, ...]) -> None: ...
def __getstate__(self) -> Tuple[Any, ...]: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
@@ -129,7 +129,7 @@ class _TextIOBase(TextIO):
def _checkSeekable(self) -> None: ...
def _checkWritable(self) -> None: ...
def close(self) -> None: ...
def detach(self) -> IO: ...
def detach(self) -> IO[Any]: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
@@ -154,8 +154,8 @@ class StringIO(_TextIOBase):
def __init__(self,
initial_value: Optional[unicode] = ...,
newline: Optional[unicode] = ...) -> None: ...
def __setstate__(self, state: tuple) -> None: ...
def __getstate__(self) -> tuple: ...
def __setstate__(self, state: Tuple[Any, ...]) -> None: ...
def __getstate__(self) -> Tuple[Any, ...]: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
@@ -167,12 +167,15 @@ class TextIOWrapper(_TextIOBase):
line_buffering: bool
buffer: BinaryIO
_CHUNK_SIZE: int
def __init__(self, buffer: IO,
encoding: Optional[Text] = ...,
errors: Optional[Text] = ...,
newline: Optional[Text] = ...,
line_buffering: bool = ...,
write_through: bool = ...) -> None: ...
def __init__(
self,
buffer: IO[Any],
encoding: Optional[Text] = ...,
errors: Optional[Text] = ...,
newline: Optional[Text] = ...,
line_buffering: bool = ...,
write_through: bool = ...,
) -> None: ...
def open(file: Union[str, unicode, int],
mode: Text = ...,

View File

@@ -1,17 +1,7 @@
"""Stub file for the '_json' module."""
# This is an autogenerated file. It serves as a starting point
# for a more precise manual annotation of this module.
# Feel free to edit the source below, but remove this header when you do.
from typing import Any, List, Tuple, Dict, Generic
def encode_basestring_ascii(*args, **kwargs) -> str:
raise TypeError()
def scanstring(a, b, *args, **kwargs) -> tuple:
raise TypeError()
from typing import Any, List, Tuple, Dict, Generic, Tuple
def encode_basestring_ascii(*args, **kwargs) -> str: ...
def scanstring(a, b, *args, **kwargs) -> Tuple[Any, ...]: ...
class Encoder(object): ...
class Scanner(object): ...

View File

@@ -253,17 +253,17 @@ class SocketType(object):
timeout: float
def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ...
def accept(self) -> Tuple[SocketType, tuple]: ...
def bind(self, address: tuple) -> None: ...
def accept(self) -> Tuple[SocketType, Tuple[Any, ...]]: ...
def bind(self, address: Tuple[Any, ...]) -> None: ...
def close(self) -> None: ...
def connect(self, address: tuple) -> None:
def connect(self, address: Tuple[Any, ...]) -> None:
raise gaierror
raise timeout
def connect_ex(self, address: tuple) -> int: ...
def connect_ex(self, address: Tuple[Any, ...]) -> int: ...
def dup(self) -> SocketType: ...
def fileno(self) -> int: ...
def getpeername(self) -> tuple: ...
def getsockname(self) -> tuple: ...
def getpeername(self) -> Tuple[Any, ...]: ...
def getsockname(self) -> Tuple[Any, ...]: ...
def getsockopt(self, level: int, option: int, buffersize: int = ...) -> str: ...
def gettimeout(self) -> float: ...
def listen(self, backlog: int) -> None:
@@ -271,16 +271,16 @@ class SocketType(object):
def makefile(self, mode: str = ..., buffersize: int = ...) -> IO[Any]: ...
def recv(self, buffersize: int, flags: int = ...) -> str: ...
def recv_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ...
def recvfrom(self, buffersize: int, flags: int = ...) -> tuple:
def recvfrom(self, buffersize: int, flags: int = ...) -> Tuple[Any, ...]:
raise error
def recvfrom_into(self, buffer: bytearray, nbytes: int = ...,
flags: int = ...) -> int: ...
def send(self, data: str, flags: int = ...) -> int: ...
def sendall(self, data: str, flags: int = ...) -> None: ...
@overload
def sendto(self, data: str, address: tuple) -> int: ...
def sendto(self, data: str, address: Tuple[Any, ...]) -> int: ...
@overload
def sendto(self, data: str, flags: int, address: tuple) -> int: ...
def sendto(self, data: str, flags: int, address: Tuple[Any, ...]) -> int: ...
def setblocking(self, flag: bool) -> None: ...
def setsockopt(self, level: int, option: int, value: Union[int, str]) -> None: ...
def settimeout(self, value: Optional[float]) -> None: ...

View File

@@ -35,14 +35,14 @@ class SRE_Pattern(object):
groups: int
groupindex: Mapping[str, int]
indexgroup: Sequence[int]
def findall(self, source: str, pos: int = ..., endpos: int = ...) -> List[Union[tuple, str]]: ...
def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[Union[tuple, str]]: ...
def findall(self, source: str, pos: int = ..., endpos: int = ...) -> List[Union[Tuple[Any, ...], str]]: ...
def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[Union[Tuple[Any, ...], str]]: ...
def match(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ...
def scanner(self, s: str, start: int = ..., end: int = ...) -> SRE_Scanner: ...
def search(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ...
def split(self, source: str, maxsplit: int = ...) -> List[Optional[str]]: ...
def sub(self, repl: str, string: str, count: int = ...) -> tuple: ...
def subn(self, repl: str, string: str, count: int = ...) -> tuple: ...
def sub(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ...
def subn(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ...
def compile(pattern: str, flags: int, code: List[int],
groups: int = ...,

View File

@@ -1,11 +1,16 @@
from typing import Any, List, Optional, Type
from typing import Any, Dict, List, Optional, Tuple, Type
default_action: str
filters: List[tuple]
once_registry: dict
filters: List[Tuple[Any, ...]]
once_registry: Dict[Any, Any]
def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
def warn_explicit(message: Warning, category: Optional[Type[Warning]],
filename: str, lineno: int,
module: Any = ..., registry: dict = ...,
module_globals: dict = ...) -> None: ...
def warn_explicit(
message: Warning,
category: Optional[Type[Warning]],
filename: str,
lineno: int,
module: Any = ...,
registry: Dict[Any, Any] = ...,
module_globals: Dict[Any, Any] = ...,
) -> None: ...

View File

@@ -10,11 +10,11 @@ def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
class ABCMeta(type):
# TODO: FrozenSet
__abstractmethods__: Set[Any]
_abc_cache: _weakrefset.WeakSet
_abc_cache: _weakrefset.WeakSet[Any]
_abc_invalidation_counter: int
_abc_negative_cache: _weakrefset.WeakSet
_abc_negative_cache: _weakrefset.WeakSet[Any]
_abc_negative_cache_version: int
_abc_registry: _weakrefset.WeakSet
_abc_registry: _weakrefset.WeakSet[Any]
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: ...

View File

@@ -1,5 +1,5 @@
# These are not exported.
from typing import Dict, Generic, TypeVar, Tuple, overload, Type, Optional, List, Union, Reversible
from typing import Any, Dict, Generic, TypeVar, Tuple, overload, Type, Optional, List, Union, Reversible
# These are exported.
from typing import (
@@ -28,7 +28,7 @@ _VT = TypeVar('_VT')
# namedtuple is special-cased in the type checker; the initializer is ignored.
def namedtuple(typename: Union[str, unicode], field_names: Union[str, unicode, Iterable[Union[str, unicode]]],
verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...
verbose: bool = ..., rename: bool = ...) -> Type[Tuple[Any, ...]]: ...
class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...,
@@ -56,8 +56,6 @@ class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
def __reversed__(self) -> Iterator[_T]: ...
def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ...
_CounterT = TypeVar('_CounterT', bound=Counter)
class Counter(Dict[_T, int], Generic[_T]):
@overload
def __init__(self, **kwargs: int) -> None: ...
@@ -65,7 +63,7 @@ class Counter(Dict[_T, int], Generic[_T]):
def __init__(self, mapping: Mapping[_T, int]) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def copy(self: _CounterT) -> _CounterT: ...
def copy(self: _S) -> _S: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...
@overload
@@ -93,15 +91,11 @@ class Counter(Dict[_T, int], Generic[_T]):
def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...
def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...
_OrderedDictT = TypeVar('_OrderedDictT', bound=OrderedDict)
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
def copy(self: _OrderedDictT) -> _OrderedDictT: ...
def copy(self: _S) -> _S: ...
def __reversed__(self) -> Iterator[_KT]: ...
_DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory: Callable[[], _VT]
@overload
@@ -123,4 +117,4 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
def __init__(self, default_factory: Optional[Callable[[], _VT]],
iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
def copy(self: _DefaultDictT) -> _DefaultDictT: ...
def copy(self: _S) -> _S: ...

View File

@@ -1,10 +1,19 @@
# Stubs for compileall (Python 2)
from typing import Optional, Pattern, Union
from typing import Any, Optional, Pattern, Union
_Path = Union[str, bytes]
# rx can be any object with a 'search' method; once we have Protocols we can change the type
def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> int: ...
def compile_file(fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> int: ...
def compile_dir(
dir: _Path,
maxlevels: int = ...,
ddir: Optional[_Path] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
) -> int: ...
def compile_file(
fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ...,
) -> int: ...
def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> int: ...

View File

@@ -1,5 +1,5 @@
from typing import Generator
from typing import Any, Generator
def walk(self) -> Generator: ...
def body_line_iterator(msg, decode: bool = ...) -> Generator: ...
def typed_subpart_iterator(msg, maintype=..., subtype=...) -> Generator: ...
def walk(self) -> Generator[Any, Any, Any]: ...
def body_line_iterator(msg, decode: bool = ...) -> Generator[Any, Any, Any]: ...
def typed_subpart_iterator(msg, maintype=..., subtype=...) -> Generator[Any, Any, Any]: ...

View File

@@ -1,4 +1,4 @@
from typing import Generator
from typing import Any, Generator
class Message:
preamble = ...
@@ -42,4 +42,4 @@ class Message:
def set_boundary(self, boundary) -> None: ...
def get_content_charset(self, failobj=...): ...
def get_charsets(self, failobj=...): ...
def walk(self) -> Generator: ...
def walk(self) -> Generator[Any, Any, Any]: ...

View File

@@ -52,8 +52,7 @@ def isgetsetdescriptor(object: object) -> bool: ...
def ismemberdescriptor(object: object) -> bool: ...
# Retrieving source code
_SourceObjectType = Union[ModuleType, Type, MethodType, FunctionType,
TracebackType, FrameType, CodeType]
_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType]
def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
def getabsfile(object: _SourceObjectType) -> str: ...
@@ -69,13 +68,12 @@ def cleandoc(doc: str) -> str: ...
def indentsize(line: str) -> int: ...
# Classes and functions
def getclasstree(classes: List[type], unique: bool = ...) -> List[
Union[Tuple[type, Tuple[type, ...]], list]]: ...
def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[type, Tuple[type, ...]], List[Any]]]: ...
ArgSpec = NamedTuple('ArgSpec', [('args', List[str]),
('varargs', Optional[str]),
('keywords', Optional[str]),
('defaults', tuple),
('defaults', Tuple[Any, ...]),
])
ArgInfo = NamedTuple('ArgInfo', [('args', List[str]),

View File

@@ -36,7 +36,7 @@ def dump(obj: Any,
def loads(s: Union[Text, bytes],
encoding: Any = ...,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
@@ -49,7 +49,7 @@ class _Reader(Protocol):
def load(fp: _Reader,
encoding: Optional[str] = ...,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,

View File

@@ -14,7 +14,7 @@ from Queue import Queue
class DummyProcess(threading.Thread):
_children: weakref.WeakKeyDictionary
_children: weakref.WeakKeyDictionary[Any, Any]
_parent: threading.Thread
_pid: None
_start_called: bool
@@ -42,10 +42,10 @@ class Value(object):
JoinableQueue = Queue
def Array(typecode, sequence, lock=...) -> array.array: ...
def Array(typecode, sequence, lock=...) -> array.array[Any]: ...
def Manager() -> Any: ...
def Pool(processes=..., initializer=..., initargs=...) -> Any: ...
def active_children() -> List: ...
def active_children() -> List[Any]: ...
def current_process() -> threading.Thread: ...
def freeze_support() -> None: ...
def shutdown() -> None: ...

View File

@@ -15,7 +15,7 @@ class Connection(object):
def poll(self, timeout=...) -> Any: ...
class Listener(object):
_backlog_queue: Optional[Queue]
_backlog_queue: Optional[Queue[Any]]
address: Any
def __init__(self, address=..., family=..., backlog=...) -> None: ...
def accept(self) -> Connection: ...

View File

@@ -1,13 +1,12 @@
# Source: https://hg.python.org/cpython/file/2.7/Lib/mutex.py
from collections import deque
from typing import Any, Callable, TypeVar
from typing import Any, Callable, Deque, TypeVar
_ArgType = TypeVar('_ArgType')
class mutex:
locked: bool
queue: deque
queue: Deque[Any]
def __init__(self) -> None: ...
def test(self) -> bool: ...
def testandset(self) -> bool: ...

View File

@@ -5,24 +5,24 @@ _T = TypeVar('_T')
class Popen3:
sts: int
cmd: Iterable
cmd: Iterable[Any]
pid: int
tochild: TextIO
fromchild: TextIO
childerr: Optional[TextIO]
def __init__(self, cmd: Iterable = ..., capturestderr: bool = ..., bufsize: int = ...) -> None: ...
def __init__(self, cmd: Iterable[Any] = ..., capturestderr: bool = ..., bufsize: int = ...) -> None: ...
def __del__(self) -> None: ...
def poll(self, _deadstate: _T = ...) -> Union[int, _T]: ...
def wait(self) -> int: ...
class Popen4(Popen3):
childerr: None
cmd: Iterable
cmd: Iterable[Any]
pid: int
tochild: TextIO
fromchild: TextIO
def __init__(self, cmd: Iterable = ..., bufsize: int = ...) -> None: ...
def __init__(self, cmd: Iterable[Any] = ..., bufsize: int = ...) -> None: ...
def popen2(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ...
def popen3(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO, TextIO]: ...
def popen4(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ...
def popen2(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ...
def popen3(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO, TextIO]: ...
def popen4(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ...

View File

@@ -1,3 +1,5 @@
from typing import Any, List
class Repr:
maxarray: int
maxdeque: int
@@ -25,7 +27,7 @@ class Repr:
def repr_str(self, x, level: complex) -> str: ...
def repr_tuple(self, x, level: complex) -> str: ...
def _possibly_sorted(x) -> list: ...
def _possibly_sorted(x) -> List[Any]: ...
aRepr: Repr
def repr(x) -> str: ...

View File

@@ -3,7 +3,7 @@ from typing import Any, Callable, Hashable, Iterable, Iterator, MutableMapping,
_T = TypeVar('_T')
_Setlike = Union[BaseSet[_T], Iterable[_T]]
_SelfT = TypeVar('_SelfT', bound=BaseSet)
_SelfT = TypeVar('_SelfT')
class BaseSet(Iterable[_T]):
def __init__(self) -> None: ...
@@ -18,13 +18,13 @@ class BaseSet(Iterable[_T]):
def __copy__(self: _SelfT) -> _SelfT: ...
def __deepcopy__(self: _SelfT, memo: MutableMapping[int, BaseSet[_T]]) -> _SelfT: ...
def __or__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def union(self: _SelfT, other: _Setlike) -> _SelfT: ...
def union(self: _SelfT, other: _Setlike[_T]) -> _SelfT: ...
def __and__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def intersection(self: _SelfT, other: _Setlike) -> _SelfT: ...
def intersection(self: _SelfT, other: _Setlike[Any]) -> _SelfT: ...
def __xor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def symmetric_difference(self: _SelfT, other: _Setlike) -> _SelfT: ...
def symmetric_difference(self: _SelfT, other: _Setlike[_T]) -> _SelfT: ...
def __sub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def difference(self: _SelfT, other: _Setlike) -> _SelfT: ...
def difference(self: _SelfT, other: _Setlike[Any]) -> _SelfT: ...
def __contains__(self, element: Any) -> bool: ...
def issubset(self, other: BaseSet[_T]) -> bool: ...
def issuperset(self, other: BaseSet[_T]) -> bool: ...
@@ -34,20 +34,20 @@ class BaseSet(Iterable[_T]):
def __gt__(self, other: BaseSet[_T]) -> bool: ...
class ImmutableSet(BaseSet[_T], Hashable):
def __init__(self, iterable: Optional[_Setlike] = ...) -> None: ...
def __init__(self, iterable: Optional[_Setlike[_T]] = ...) -> None: ...
def __hash__(self) -> int: ...
class Set(BaseSet[_T]):
def __init__(self, iterable: Optional[_Setlike] = ...) -> None: ...
def __ior__(self, other: BaseSet[_T]) -> Set: ...
def union_update(self, other: _Setlike) -> None: ...
def __iand__(self, other: BaseSet[_T]) -> Set: ...
def intersection_update(self, other: _Setlike) -> None: ...
def __ixor__(self, other: BaseSet[_T]) -> Set: ...
def symmetric_difference_update(self, other: _Setlike) -> None: ...
def __isub__(self, other: BaseSet[_T]) -> Set: ...
def difference_update(self, other: _Setlike) -> None: ...
def update(self, iterable: _Setlike) -> None: ...
def __init__(self, iterable: Optional[_Setlike[_T]] = ...) -> None: ...
def __ior__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def union_update(self, other: _Setlike[_T]) -> None: ...
def __iand__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def intersection_update(self, other: _Setlike[Any]) -> None: ...
def __ixor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def symmetric_difference_update(self, other: _Setlike[_T]) -> None: ...
def __isub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def difference_update(self, other: _Setlike[Any]) -> None: ...
def update(self, iterable: _Setlike[_T]) -> None: ...
def clear(self) -> None: ...
def add(self, element: _T) -> None: ...
def remove(self, element: _T) -> None: ...

View File

@@ -2,7 +2,7 @@ from typing import Any, Dict, Iterator, List, Optional, Tuple
import collections
class Shelf(collections.MutableMapping):
class Shelf(collections.MutableMapping[Any, Any]):
def __init__(self, dict: Dict[Any, Any], protocol: Optional[int] = ..., writeback: bool = ..., keyencoding: str = ...) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def keys(self) -> List[Any]: ...

View File

@@ -4,10 +4,10 @@ from typing import Any, Dict, Iterable, List, Match, Optional, Pattern as _Patte
SPECIAL_CHARS: str
REPEAT_CHARS: str
DIGITS: Set
OCTDIGITS: Set
HEXDIGITS: Set
WHITESPACE: Set
DIGITS: Set[Any]
OCTDIGITS: Set[Any]
HEXDIGITS: Set[Any]
WHITESPACE: Set[Any]
ESCAPES: Dict[str, Tuple[str, int]]
CATEGORIES: Dict[str, Union[Tuple[str, str], Tuple[str, List[Tuple[str, str]]]]]
FLAGS: Dict[str, int]
@@ -59,5 +59,5 @@ def isdigit(char: str) -> bool: ...
def isname(name: str) -> bool: ...
def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ...
_Template = Tuple[List[Tuple[int, int]], List[Optional[int]]]
def parse_template(source: str, pattern: _Pattern) -> _Template: ...
def expand_template(template: _Template, match: Match) -> str: ...
def parse_template(source: str, pattern: _Pattern[Any]) -> _Template: ...
def expand_template(template: _Template, match: Match[Any]) -> str: ...

View File

@@ -105,8 +105,6 @@ class Popen(Generic[_T]):
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
def __enter__(self) -> Popen: ...
def __exit__(self, type, value, traceback) -> None: ...
def list2cmdline(seq: Sequence[str]) -> str: ... # undocumented

View File

@@ -19,9 +19,9 @@ class _RandomNameSequence:
class _TemporaryFileWrapper(IO[str]):
delete: bool
file: IO
file: IO[str]
name: Any
def __init__(self, file: IO, name: Any, delete: bool = ...) -> None: ...
def __init__(self, file: IO[str], name: Any, delete: bool = ...) -> None: ...
def __del__(self) -> None: ...
def __enter__(self) -> _TemporaryFileWrapper: ...
def __exit__(self, exc, value, tb) -> Optional[bool]: ...

View File

@@ -103,7 +103,7 @@ class UnboundMethodType:
__name__: str
__func__ = im_func
__self__ = im_self
def __init__(self, func: Callable, obj: object) -> None: ...
def __init__(self, func: Callable[..., Any], obj: object) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
class InstanceType(object): ...
@@ -154,7 +154,7 @@ class EllipsisType: ...
class DictProxyType:
# TODO is it possible to have non-string keys?
# no __init__
def copy(self) -> dict: ...
def copy(self) -> Dict[Any, Any]: ...
def get(self, key: str, default: _T = ...) -> Union[Any, _T]: ...
def has_key(self, key: str) -> bool: ...
def items(self) -> List[Tuple[str, Any]]: ...

View File

@@ -69,7 +69,7 @@ _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)
_C = TypeVar("_C", bound=Callable[..., Any])
def runtime_checkable(cls: _TC) -> _TC: ...
@@ -447,8 +447,9 @@ class Pattern(Generic[AnyStr]):
# Functions
def get_type_hints(obj: Callable, globalns: Optional[dict[Text, Any]] = ...,
localns: Optional[dict[Text, Any]] = ...) -> None: ...
def get_type_hints(
obj: Callable[..., Any], globalns: Optional[Dict[Text, Any]] = ..., localns: Optional[Dict[Text, Any]] = ...,
) -> None: ...
@overload
def cast(tp: Type[_T], obj: Any) -> _T: ...
@@ -458,7 +459,7 @@ def cast(tp: str, obj: Any) -> Any: ...
# Type constructors
# NamedTuple is special-cased in the type checker
class NamedTuple(tuple):
class NamedTuple(Tuple[Any, ...]):
_fields: Tuple[str, ...]
def __init__(self, typename: Text, fields: Iterable[Tuple[Text, Any]] = ..., *,
@@ -467,7 +468,7 @@ class NamedTuple(tuple):
@classmethod
def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ...
def _asdict(self) -> dict: ...
def _asdict(self) -> Dict[str, Any]: ...
def _replace(self: _T, **kwargs: Any) -> _T: ...
# Internal mypy fallback type for all typed dicts (does not exist at runtime)

View File

@@ -12,7 +12,7 @@ from gzip import GzipFile
_Unmarshaller = Any
_timeTuple = Tuple[int, int, int, int, int, int, int, int, int]
# Represents types that can be compared against a DateTime object
_dateTimeComp = Union[AnyStr, DateTime, datetime, _timeTuple]
_dateTimeComp = Union[unicode, DateTime, datetime]
# A "host description" used by Transport factories
_hostDesc = Union[str, Tuple[str, Mapping[Any, Any]]]
@@ -55,26 +55,26 @@ Boolean: Type[bool]
class DateTime:
value: str
def __init__(self, value: Union[str, unicode, datetime, float, int, _timeTuple, struct_time] = ...) -> None: ...
def make_comparable(self, other: _dateTimeComp) -> Tuple[_dateTimeComp, _dateTimeComp]: ...
def make_comparable(self, other: _dateTimeComp) -> Tuple[unicode, unicode]: ...
def __lt__(self, other: _dateTimeComp) -> bool: ...
def __le__(self, other: _dateTimeComp) -> bool: ...
def __gt__(self, other: _dateTimeComp) -> bool: ...
def __ge__(self, other: _dateTimeComp) -> bool: ...
def __eq__(self, other: _dateTimeComp) -> bool: ...
def __ne__(self, other: _dateTimeComp) -> bool: ...
def __eq__(self, other: _dateTimeComp) -> bool: ... # type: ignore
def __ne__(self, other: _dateTimeComp) -> bool: ... # type: ignore
def timetuple(self) -> struct_time: ...
def __cmp__(self, other: _dateTimeComp) -> int: ...
def decode(self, data: Any) -> None: ...
def encode(self, out: IO) -> None: ...
def encode(self, out: IO[str]) -> None: ...
class Binary:
data: str
def __init__(self, data: Optional[str] = ...) -> None: ...
def __cmp__(self, other: Any) -> int: ...
def decode(self, data: str) -> None: ...
def encode(self, out: IO) -> None: ...
def encode(self, out: IO[str]) -> None: ...
WRAPPERS: tuple
WRAPPERS: Tuple[Type[Any], ...]
# Still part of the public API, but see http://bugs.python.org/issue1773632
FastParser: None
@@ -104,7 +104,28 @@ class Marshaller:
allow_none: bool
def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ...
dispatch: Mapping[type, Callable[[Marshaller, str, Callable[[str], None]], None]]
def dumps(self, values: Union[Iterable[Union[None, int, bool, long, float, str, unicode, List, Tuple, Mapping, datetime, InstanceType]], Fault]) -> str: ...
def dumps(
self,
values: Union[
Iterable[
Union[
None,
int,
bool,
long,
float,
str,
unicode,
List[Any],
Tuple[Any, ...],
Mapping[Any, Any],
datetime,
InstanceType,
],
],
Fault,
],
) -> str: ...
def dump_nil(self, value: None, write: Callable[[str], None]) -> None: ...
def dump_int(self, value: int, write: Callable[[str], None]) -> None: ...
def dump_bool(self, value: bool, write: Callable[[str], None]) -> None: ...
@@ -112,15 +133,20 @@ class Marshaller:
def dump_double(self, value: float, write: Callable[[str], None]) -> None: ...
def dump_string(self, value: str, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ...
def dump_unicode(self, value: unicode, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ...
def dump_array(self, value: Union[List, Tuple], write: Callable[[str], None]) -> None: ...
def dump_struct(self, value: Mapping, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ...
def dump_array(self, value: Iterable[Any], write: Callable[[str], None]) -> None: ...
def dump_struct(
self,
value: Mapping[unicode, Any],
write: Callable[[str], None],
escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...,
) -> None: ...
def dump_datetime(self, value: datetime, write: Callable[[str], None]) -> None: ...
def dump_instance(self, value: InstanceType, write: Callable[[str], None]) -> None: ...
class Unmarshaller:
def append(self, object: Any) -> None: ...
def __init__(self, use_datetime: bool = ...) -> None: ...
def close(self) -> tuple: ...
def close(self) -> Tuple[Any, ...]: ...
def getmethodname(self) -> Optional[str]: ...
def xml(self, encoding: str, standalone: bool) -> None: ...
def start(self, tag: str, attrs: Any) -> None: ...
@@ -143,9 +169,9 @@ class Unmarshaller:
def end_methodName(self, data: str) -> None: ...
class _MultiCallMethod:
def __init__(self, call_list: List[Tuple[str, tuple]], name: str) -> None: ...
def __init__(self, call_list: List[Tuple[str, Tuple[Any, ...]]], name: str) -> None: ...
class MultiCallIterator:
def __init__(self, results: List) -> None: ...
def __init__(self, results: List[Any]) -> None: ...
class MultiCall:
def __init__(self, server: ServerProxy) -> None: ...
@@ -153,19 +179,25 @@ class MultiCall:
def __call__(self) -> MultiCallIterator: ...
def getparser(use_datetime: bool = ...) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ...
def dumps(params: Union[tuple, Fault], methodname: Optional[str] = ..., methodresponse: Optional[bool] = ..., encoding: Optional[str] = ..., allow_none: bool = ...) -> str: ...
def loads(data: str, use_datetime: bool = ...) -> Tuple[tuple, Optional[str]]: ...
def dumps(
params: Union[Tuple[Any, ...], Fault],
methodname: Optional[str] = ...,
methodresponse: Optional[bool] = ...,
encoding: Optional[str] = ...,
allow_none: bool = ...,
) -> str: ...
def loads(data: str, use_datetime: bool = ...) -> Tuple[Tuple[Any, ...], Optional[str]]: ...
def gzip_encode(data: str) -> str: ...
def gzip_decode(data: str, max_decode: int = ...) -> str: ...
class GzipDecodedResponse(GzipFile):
stringio: StringIO
stringio: StringIO[Any]
def __init__(self, response: HTTPResponse) -> None: ...
def close(self): ...
class _Method:
def __init__(self, send: Callable[[str, tuple], Any], name: str) -> None: ...
def __init__(self, send: Callable[[str, Tuple[Any, ...]], Any], name: str) -> None: ...
def __getattr__(self, name: str) -> _Method: ...
def __call__(self, *args: Any) -> Any: ...
@@ -174,9 +206,9 @@ class Transport:
accept_gzip_encoding: bool
encode_threshold: Optional[int]
def __init__(self, use_datetime: bool = ...) -> None: ...
def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> tuple: ...
def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ...
verbose: bool
def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> tuple: ...
def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ...
def getparser(self) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ...
def get_host_info(self, host: _hostDesc) -> Tuple[str, Optional[List[Tuple[str, str]]], Optional[Mapping[Any, Any]]]: ...
def make_connection(self, host: _hostDesc) -> HTTPConnection: ...
@@ -185,7 +217,7 @@ class Transport:
def send_host(self, connection: HTTPConnection, host: str) -> None: ...
def send_user_agent(self, connection: HTTPConnection) -> None: ...
def send_content(self, connection: HTTPConnection, request_body: str) -> None: ...
def parse_response(self, response: HTTPResponse) -> tuple: ...
def parse_response(self, response: HTTPResponse) -> Tuple[Any, ...]: ...
class SafeTransport(Transport):
def __init__(self, use_datetime: bool = ..., context: Optional[SSLContext] = ...) -> None: ...