Updated to the latest version of typeshed type stubs.

This commit is contained in:
Eric Traut 2020-01-02 15:31:11 -07:00
parent 95b7b3488e
commit e75af3d0b0
44 changed files with 1167 additions and 460 deletions

View File

@ -4,6 +4,7 @@ from typing import List
class _Feature:
def getOptionalRelease(self) -> sys._version_info: ...
def getMandatoryRelease(self) -> sys._version_info: ...
compiler_flag: int
absolute_import: _Feature
division: _Feature
@ -21,4 +22,4 @@ if sys.version_info >= (3, 5):
if sys.version_info >= (3, 7):
annotations: _Feature
all_feature_names: List[str]
all_feature_names: List[str] # undocumented

View File

@ -0,0 +1,64 @@
import sys
from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload
if sys.version_info >= (3, 0):
_defaultaction: str
_onceregistry: Dict[Any, Any]
else:
default_action: str
once_registry: Dict[Any, Any]
filters: List[Tuple[Any, ...]]
if sys.version_info >= (3, 6):
@overload
def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ...) -> None: ...
@overload
def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Optional[Any] = ...) -> None: ...
@overload
def warn_explicit(
message: str,
category: Type[Warning],
filename: str,
lineno: int,
module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...,
source: Optional[Any] = ...,
) -> None: ...
@overload
def warn_explicit(
message: Warning,
category: Any,
filename: str,
lineno: int,
module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...,
source: Optional[Any] = ...,
) -> None: ...
else:
@overload
def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
@overload
def warn(message: Warning, category: Any = ..., stacklevel: int = ...) -> None: ...
@overload
def warn_explicit(
message: str,
category: Type[Warning],
filename: str,
lineno: int,
module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...,
) -> None: ...
@overload
def warn_explicit(
message: Warning,
category: Any,
filename: str,
lineno: int,
module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...,
) -> None: ...

View File

@ -0,0 +1,5 @@
import sys
if sys.version_info >= (3, 0):
def geohash(latitude: float, longitude: float, datedow: bytes) -> None: ...

View File

@ -1351,12 +1351,16 @@ def ord(__c: Union[Text, bytes]) -> int: ...
if sys.version_info >= (3,):
class _Writer(Protocol):
def write(self, __s: str) -> Any: ...
def print(*values: object, sep: Text = ..., end: Text = ..., file: Optional[_Writer] = ..., flush: bool = ...) -> None: ...
def print(
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ..., flush: bool = ...
) -> None: ...
else:
class _Writer(Protocol):
def write(self, __s: Any) -> Any: ...
# This is only available after from __future__ import print_function.
def print(*values: object, sep: Text = ..., end: Text = ..., file: Optional[_Writer] = ...) -> None: ...
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ...
@overload
def pow(__x: int, __y: int) -> Any: ... # The return type can be int or float, depending on y
@overload
@ -1531,9 +1535,10 @@ class AttributeError(_StandardError): ...
class BufferError(_StandardError): ...
class EOFError(_StandardError): ...
class ImportError(_StandardError):
if sys.version_info >= (3,):
name: str
path: str
if sys.version_info >= (3, 3):
def __init__(self, *args, name: Optional[str] = ..., path: Optional[str] = ...) -> None: ...
name: Optional[str]
path: Optional[str]
class LookupError(_StandardError): ...
class MemoryError(_StandardError): ...
class NameError(_StandardError): ...

View File

@ -1,23 +1,23 @@
from collections import OrderedDict
import sys
from _csv import (
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Error as Error,
_reader,
_writer,
field_size_limit as field_size_limit,
get_dialect as get_dialect,
list_dialects as list_dialects,
reader as reader,
register_dialect as register_dialect,
unregister_dialect as unregister_dialect,
writer as writer,
)
from collections import OrderedDict
from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, Union
from _csv import (_reader,
_writer,
reader as reader,
writer as writer,
register_dialect as register_dialect,
unregister_dialect as unregister_dialect,
get_dialect as get_dialect,
list_dialects as list_dialects,
field_size_limit as field_size_limit,
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Error as Error,
)
_Dialect = Union[str, Dialect, Type[Dialect]]
_DictRow = Mapping[str, Any]
@ -56,7 +56,6 @@ if sys.version_info >= (3, 6):
else:
_DRMapping = Dict[str, str]
class DictReader(Iterator[_DRMapping]):
restkey: Optional[str]
restval: Optional[str]
@ -64,24 +63,37 @@ class DictReader(Iterator[_DRMapping]):
dialect: _Dialect
line_num: int
fieldnames: Sequence[str]
def __init__(self, f: Iterable[Text], fieldnames: Sequence[str] = ...,
restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ...,
*args: Any, **kwds: Any) -> None: ...
def __init__(
self,
f: Iterable[Text],
fieldnames: Optional[Sequence[str]] = ...,
restkey: Optional[str] = ...,
restval: Optional[str] = ...,
dialect: _Dialect = ...,
*args: Any,
**kwds: Any,
) -> None: ...
def __iter__(self) -> DictReader: ...
if sys.version_info >= (3,):
def __next__(self) -> _DRMapping: ...
else:
def next(self) -> _DRMapping: ...
class DictWriter(object):
fieldnames: Sequence[str]
restval: Optional[Any]
extrasaction: str
writer: _writer
def __init__(self, f: Any, fieldnames: Iterable[str],
restval: Optional[Any] = ..., extrasaction: str = ..., dialect: _Dialect = ...,
*args: Any, **kwds: Any) -> None: ...
def __init__(
self,
f: Any,
fieldnames: Iterable[str],
restval: Optional[Any] = ...,
extrasaction: str = ...,
dialect: _Dialect = ...,
*args: Any,
**kwds: Any,
) -> None: ...
def writeheader(self) -> None: ...
def writerow(self, rowdict: _DictRow) -> None: ...
def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ...

View File

@ -72,8 +72,10 @@ class date:
def __gt__(self, other: date) -> bool: ...
if sys.version_info >= (3, 8):
def __add__(self: _S, other: timedelta) -> _S: ...
def __radd__(self: _S, other: timedelta) -> _S: ...
else:
def __add__(self, other: timedelta) -> date: ...
def __radd__(self, other: timedelta) -> date: ...
@overload
def __sub__(self, other: timedelta) -> date: ...
@overload
@ -299,8 +301,10 @@ class datetime(date):
def __gt__(self, other: datetime) -> bool: ... # type: ignore
if sys.version_info >= (3, 8):
def __add__(self: _S, other: timedelta) -> _S: ...
def __radd__(self: _S, other: timedelta) -> _S: ...
else:
def __add__(self, other: timedelta) -> datetime: ...
def __radd__(self, other: timedelta) -> datetime: ...
@overload # type: ignore
def __sub__(self, other: datetime) -> timedelta: ...
@overload

View File

@ -29,7 +29,7 @@ class IMAP4:
welcome: bytes = ...
capabilities: Tuple[str] = ...
PROTOCOL_VERSION: str = ...
def __init__(self, host: str, port: int) -> None: ...
def __init__(self, host: str = ..., port: int = ...) -> None: ...
def __getattr__(self, attr: str) -> Any: ...
host: str = ...
port: int = ...
@ -54,6 +54,8 @@ class IMAP4:
def deleteacl(self, mailbox: str, who: str) -> CommandResults: ...
if sys.version_info >= (3, 5):
def enable(self, capability: str) -> CommandResults: ...
def __enter__(self) -> IMAP4: ...
def __exit__(self, *args) -> None: ...
def expunge(self) -> CommandResults: ...
def fetch(self, message_set: str, message_parts: str) -> CommandResults: ...
def getacl(self, mailbox: str) -> CommandResults: ...

View File

@ -29,16 +29,8 @@ SYSLOG_UDP_PORT: int
SYSLOG_TCP_PORT: int
class WatchedFileHandler(FileHandler):
@overload
def __init__(self, filename: _Path) -> None: ...
@overload
def __init__(self, filename: _Path, mode: str) -> None: ...
@overload
def __init__(self, filename: _Path, mode: str,
encoding: Optional[str]) -> None: ...
@overload
def __init__(self, filename: _Path, mode: str, encoding: Optional[str],
delay: bool) -> None: ...
def __init__(self, filename: _Path, mode: str = ..., encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
if sys.version_info >= (3,):

View File

@ -0,0 +1,199 @@
from typing import Optional, Union, Text, AnyStr, Callable, IO, Any, Iterator, List, Tuple, TypeVar, Protocol, Dict, Sequence, Iterable, Generic, Type, Mapping, overload
from types import TracebackType
import sys
import email
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if sys.version_info >= (3, 6):
from builtins import _PathLike
_PathType = Union[bytes, Text, _PathLike]
else:
_PathType = Union[bytes, Text]
_T = TypeVar("_T")
_MessageType = TypeVar("_MessageType", bound=Message)
_MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]]
class _HasIteritems(Protocol):
def iteritems(self) -> Iterator[Tuple[str, _MessageData]]: ...
class _HasItems(Protocol):
def items(self) -> Iterator[Tuple[str, _MessageData]]: ...
linesep: bytes
class Mailbox(Generic[_MessageType]):
_path: Union[bytes, str] # undocumented
_factory: Optional[Callable[[IO[Any]], _MessageType]] # undocumented
def __init__(self, path: _PathType, factory: Optional[Callable[[IO[Any]], _MessageType]] = ..., create: bool = ...) -> None: ...
def add(self, message: _MessageData) -> str: ...
def remove(self, key: str) -> None: ...
def __delitem__(self, key: str) -> None: ...
def discard(self, key: str) -> None: ...
def __setitem__(self, key: str, message: _MessageData) -> None: ...
@overload
def get(self, key: str, default: None = ...) -> Optional[_MessageType]: ...
@overload
def get(self, key: str, default: _T) -> Union[_MessageType, _T]: ...
def __getitem__(self, key: str) -> _MessageType: ...
def get_message(self, key: str) -> _MessageType: ...
def get_string(self, key: str) -> str: ...
def get_bytes(self, key: str) -> bytes: ...
# As '_ProxyFile' doesn't implement the full IO spec, and BytesIO is incompatible with it, get_file return is Any here
def get_file(self, key: str) -> Any: ...
def iterkeys(self) -> Iterator[str]: ...
def keys(self) -> List[str]: ...
def itervalues(self) -> Iterator[_MessageType]: ...
def __iter__(self) -> Iterator[_MessageType]: ...
def values(self) -> List[_MessageType]: ...
def iteritems(self) -> Iterator[Tuple[str, _MessageType]]: ...
def items(self) -> List[Tuple[str, _MessageType]]: ...
def __contains__(self, key: str) -> bool: ...
def __len__(self) -> int: ...
def clear(self) -> None: ...
@overload
def pop(self, key: str, default: None = ...) -> Optional[_MessageType]: ...
@overload
def pop(self, key: str, default: _T = ...) -> Union[_MessageType, _T]: ...
def popitem(self) -> Tuple[str, _MessageType]: ...
def update(self, arg: Optional[Union[_HasIteritems, _HasItems, Iterable[Tuple[str, _MessageData]]]] = ...) -> None: ...
def flush(self) -> None: ...
def lock(self) -> None: ...
def unlock(self) -> None: ...
def close(self) -> None: ...
class Maildir(Mailbox[MaildirMessage]):
colon: str
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ...) -> None: ...
def get_file(self, key: str) -> _ProxyFile[bytes]: ...
def list_folders(self) -> List[str]: ...
def get_folder(self, folder: Text) -> Maildir: ...
def add_folder(self, folder: Text) -> Maildir: ...
def remove_folder(self, folder: Text) -> None: ...
def clean(self) -> None: ...
def next(self) -> Optional[str]: ...
class _singlefileMailbox(Mailbox[_MessageType]): ...
class _mboxMMDF(_singlefileMailbox[_MessageType]):
def get_file(self, key: str) -> _PartialFile[bytes]: ...
class mbox(_mboxMMDF[mboxMessage]):
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ...) -> None: ...
class MMDF(_mboxMMDF[MMDFMessage]):
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ...) -> None: ...
class MH(Mailbox[MHMessage]):
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ...) -> None: ...
def get_file(self, key: str) -> _ProxyFile[bytes]: ...
def list_folders(self) -> List[str]: ...
def get_folder(self, folder: _PathType) -> MH: ...
def add_folder(self, folder: _PathType) -> MH: ...
def remove_folder(self, folder: _PathType) -> None: ...
def get_sequences(self) -> Dict[str, List[int]]: ...
def set_sequences(self, sequences: Mapping[str, Sequence[int]]) -> None: ...
def pack(self) -> None: ...
class Babyl(_singlefileMailbox[BabylMessage]):
def __init__(self, dirname: _PathType, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ...) -> None: ...
def get_file(self, key: str) -> IO[bytes]: ...
def get_labels(self) -> List[str]: ...
class Message(email.message.Message):
def __init__(self, message: Optional[_MessageData] = ...) -> None: ...
class MaildirMessage(Message):
def get_subdir(self) -> str: ...
def set_subdir(self, subdir: Literal["new", "cur"]) -> None: ...
def get_flags(self) -> str: ...
def set_flags(self, flags: Iterable[str]) -> None: ...
def add_flag(self, flag: str) -> None: ...
def remove_flag(self, flag: str) -> None: ...
def get_date(self) -> int: ...
def set_date(self, date: int) -> None: ...
def get_info(self) -> str: ...
def set_info(self, info: str) -> None: ...
class _mboxMMDFMessage(Message):
def get_from(self) -> str: ...
def set_from(self, from_: str, time_: Optional[Union[bool, Tuple[int, int, int, int, int, int, int, int, int]]] = ...) -> None: ...
def get_flags(self) -> str: ...
def set_flags(self, flags: Iterable[str]) -> None: ...
def add_flag(self, flag: str) -> None: ...
def remove_flag(self, flag: str) -> None: ...
class mboxMessage(_mboxMMDFMessage): ...
class MHMessage(Message):
def get_sequences(self) -> List[str]: ...
def set_sequences(self, sequences: Iterable[str]) -> None: ...
def add_sequence(self, sequence: str) -> None: ...
def remove_sequence(self, sequence: str) -> None: ...
class BabylMessage(Message):
def get_labels(self) -> List[str]: ...
def set_labels(self, labels: Iterable[str]) -> None: ...
def add_label(self, label: str) -> None: ...
def remove_label(self, label: str) -> None: ...
def get_visible(self) -> Message: ...
def set_visible(self, visible: _MessageData) -> None: ...
def update_visible(self) -> None: ...
class MMDFMessage(_mboxMMDFMessage): ...
class _ProxyFile(Generic[AnyStr]):
def __init__(self, f: IO[AnyStr], pos: Optional[int] = ...) -> None: ...
def read(self, size: Optional[int] = ...) -> AnyStr: ...
def read1(self, size: Optional[int] = ...) -> AnyStr: ...
def readline(self, size: Optional[int] = ...) -> AnyStr: ...
def readlines(self, sizehint: Optional[int] = ...) -> List[AnyStr]: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def tell(self) -> int: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def close(self) -> None: ...
def __enter__(self) -> _ProxyFile[AnyStr]: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> None: ...
def readable(self) -> bool: ...
def writable(self) -> bool: ...
def seekable(self) -> bool: ...
def flush(self) -> None: ...
@property
def closed(self) -> bool: ...
class _PartialFile(_ProxyFile[AnyStr]):
def __init__(self, f: IO[AnyStr], start: Optional[int] = ..., stop: Optional[int] = ...) -> None: ...
class Error(Exception): ...
class NoSuchMailboxError(Error): ...
class NotEmptyError(Error): ...
class ExternalClashError(Error): ...
class FormatError(Error): ...

View File

@ -0,0 +1,7 @@
from typing import Sequence, Dict, List, Union, Tuple, Optional, Mapping
_Cap = Dict[str, Union[str, int]]
def findmatch(caps: Mapping[str, List[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ...) -> Tuple[Optional[str], Optional[_Cap]]: ...
def getcaps() -> Dict[str, List[_Cap]]: ...

View File

@ -0,0 +1,48 @@
from typing import Optional, Container, Dict, Sequence, Tuple, List, Any, Iterator, IO, Iterable
from types import CodeType
LOAD_CONST: int # undocumented
IMPORT_NAME: int # undocumented
STORE_NAME: int # undocumented
STORE_GLOBAL: int # undocumented
STORE_OPS: Tuple[int, int] # undocumented
EXTENDED_ARG: int # undocumented
packagePathMap: Dict[str, List[str]] # undocumented
def AddPackagePath(packagename: str, path: str) -> None: ...
replacePackageMap: Dict[str, str] # undocumented
def ReplacePackage(oldname: str, newname: str) -> None: ...
class Module: # undocumented
def __init__(self, name: str, file: Optional[str] = ..., path: Optional[str] = ...) -> None: ...
def __repr__(self) -> str: ...
class ModuleFinder:
modules: Dict[str, Module]
def __init__(self, path: Optional[List[str]] = ..., debug: int = ..., excludes: Container[str] = ..., replace_paths: Sequence[Tuple[str, str]] = ...) -> None: ...
def msg(self, level: int, str: str, *args: Any) -> None: ... # undocumented
def msgin(self, *args: Any) -> None: ... # undocumented
def msgout(self, *args: Any) -> None: ... # undocumented
def run_script(self, pathname: str) -> None: ...
def load_file(self, pathname: str) -> None: ... # undocumented
def import_hook(self, name: str, caller: Optional[Module] = ..., fromlist: Optional[List[str]] = ..., level: int = ...) -> Optional[Module]: ... # undocumented
def determine_parent(self, caller: Optional[Module], level: int = ...) -> Optional[Module]: ... # undocumented
def find_head_package(self, parent: Module, name: str) -> Tuple[Module, str]: ... # undocumented
def load_tail(self, q: Module, tail: str) -> Module: ... # undocumented
def ensure_fromlist(self, m: Module, fromlist: Iterable[str], recursive: int = ...) -> None: ... # undocumented
def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented
def import_module(self, partname: str, fqname: str, parent: Module) -> Optional[Module]: ... # undocumented
def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: Tuple[str, str, str]) -> Module: ... # undocumented
def scan_opcodes(self, co: CodeType) -> Iterator[Tuple[str, Tuple[Any, ...]]]: ... # undocumented
def scan_code(self, co: CodeType, m: Module) -> None: ... # undocumented
def load_package(self, fqname: str, pathname: str) -> Module: ... # undocumented
def add_module(self, fqname: str) -> Module: ... # undocumented
def find_module(self, name: str, path: Optional[str], parent: Optional[Module] = ...) -> Tuple[Optional[IO[Any]], Optional[str], Tuple[str, str, int]]: ... # undocumented
def report(self) -> None: ...
def any_missing(self) -> List[str]: ... # undocumented
def any_missing_maybe(self) -> Tuple[List[str], List[str]]: ... # undocumented
def replace_paths_in_code(self, co: CodeType) -> CodeType: ... # undocumented

View File

@ -14,10 +14,10 @@ else:
depth: Optional[int] = ...) -> str: ...
if sys.version_info >= (3, 4):
def pprint(o: object, stream: IO[str] = ..., indent: int = ..., width: int = ...,
def pprint(o: object, stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ...,
depth: Optional[int] = ..., compact: bool = ...) -> None: ...
else:
def pprint(o: object, stream: IO[str] = ..., indent: int = ..., width: int = ...,
def pprint(o: object, stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ...,
depth: Optional[int] = ...) -> None: ...
def isreadable(o: object) -> bool: ...
@ -27,10 +27,10 @@ def saferepr(o: object) -> str: ...
class PrettyPrinter:
if sys.version_info >= (3, 4):
def __init__(self, indent: int = ..., width: int = ..., depth: Optional[int] = ...,
stream: IO[str] = ..., compact: bool = ...) -> None: ...
stream: Optional[IO[str]] = ..., compact: bool = ...) -> None: ...
else:
def __init__(self, indent: int = ..., width: int = ..., depth: Optional[int] = ...,
stream: IO[str] = ...) -> None: ...
stream: Optional[IO[str]] = ...) -> None: ...
def pformat(self, o: object) -> str: ...
def pprint(self, o: object) -> None: ...

View File

@ -96,12 +96,8 @@ else:
Iterable[AnyStr]]] = ...) -> _PathReturn: ...
if sys.version_info >= (3,):
@overload
def rmtree(path: bytes, ignore_errors: bool = ...,
onerror: Optional[Callable[[Any, str, Any], Any]] = ...) -> None: ...
@overload
def rmtree(path: _AnyPath, ignore_errors: bool = ...,
onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ...
def rmtree(path: Union[bytes, _Path], ignore_errors: bool = ...,
onerror: Optional[Callable[[Any, Any, Any], Any]] = ...) -> None: ...
else:
def rmtree(path: _AnyPath, ignore_errors: bool = ...,
onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ...
@ -136,9 +132,13 @@ def register_archive_format(name: str, function: Callable[..., Any],
def unregister_archive_format(name: str) -> None: ...
if sys.version_info >= (3,):
# Should be _Path once http://bugs.python.org/issue30218 is fixed
def unpack_archive(filename: str, extract_dir: Optional[_Path] = ...,
format: Optional[str] = ...) -> None: ...
if sys.version_info >= (3, 7):
def unpack_archive(filename: _Path, extract_dir: Optional[_Path] = ...,
format: Optional[str] = ...) -> None: ...
else:
# See http://bugs.python.org/issue30218
def unpack_archive(filename: str, extract_dir: Optional[_Path] = ...,
format: Optional[str] = ...) -> None: ...
def register_unpack_format(name: str, extensions: List[str], function: Any,
extra_args: Sequence[Tuple[str, Any]] = ...,
description: str = ...) -> None: ...

View File

@ -40,7 +40,8 @@ class SMTPChannel(asynchat.async_chat):
map: Optional[asyncore._maptype] = ..., enable_SMTPUTF8: bool = ..., decode_data: bool = ...) -> None: ...
else:
def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ...
def push(self, msg: bytes) -> None: ...
# base asynchat.async_chat.push() accepts bytes
def push(self, msg: Text) -> None: ... # type: ignore
def collect_incoming_data(self, data: bytes) -> None: ...
def found_terminator(self) -> None: ...
def smtp_HELO(self, arg: str) -> None: ...

View File

@ -1,43 +1,73 @@
# Stubs for socket
# Ron Murawski <ron@horizonchess.com>
"""Stub for the socket module
# based on: http://docs.python.org/3.2/library/socket.html
# see: http://hg.python.org/cpython/file/3d0686d90f55/Lib/socket.py
# see: http://nullege.com/codes/search/socket
# adapted for Python 2.7 by Michal Pokorny
This file is organized to mirror the module's documentation, with a very small
number of exceptions.
To avoid requiring tests on all platforms, platform checks are included only
where the documentation notes platform availability (as opposed to following
actual availability), with one or two exceptions.
Module documentation: https://docs.python.org/3/library/socket.html
CPython module source: https://github.com/python/cpython/blob/master/Lib/socket.py
CPython C source: https://github.com/python/cpython/blob/master/Modules/socketmodule.c
"""
# Authorship from original mypy stubs (not in typeshed git history):
# Ron Murawski <ron@horizonchess.com>
# adapted for Python 2.7 by Michal Pokorny
import sys
from typing import Any, Iterable, Tuple, List, Optional, Union, overload, TypeVar, Text
from typing import Any, BinaryIO, Iterable, List, Optional, Text, TextIO, Tuple, TypeVar, Union, overload
_WriteBuffer = Union[bytearray, memoryview]
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
# ----- variables and constants -----
# ----- Constants -----
# Some socket families are listed in the "Socket families" section of the docs,
# but not the "Constants" section. These are listed at the end of the list of
# constants.
#
# Besides those and the first few constants listed, the constants are listed in
# documentation order.
# Constants defined by Python (i.e. not OS constants re-exported from C)
has_ipv6: bool
SocketType: Any
if sys.version_info >= (3,):
SocketIO: Any
# Re-exported errno
EAGAIN: int
EBADF: int
EINTR: int
EWOULDBLOCK: int
# Constants re-exported from C
# Per socketmodule.c, only these three families are portable
AF_UNIX: AddressFamily
AF_INET: AddressFamily
AF_INET6: AddressFamily
SOCK_STREAM: SocketKind
SOCK_DGRAM: SocketKind
SOCK_RAW: SocketKind
SOCK_RDM: SocketKind
SOCK_SEQPACKET: SocketKind
SOCK_CLOEXEC: SocketKind
SOCK_NONBLOCK: SocketKind
SOMAXCONN: int
has_ipv6: bool
_GLOBAL_DEFAULT_TIMEOUT: Any
SocketType: Any
SocketIO: Any
# These are flags that may exist on Python 3.6. Many don't exist on all platforms.
if sys.platform == 'linux' and sys.version_info >= (3,):
SOCK_CLOEXEC: SocketKind
SOCK_NONBLOCK: SocketKind
# Address families not mentioned in the docs
AF_AAL5: AddressFamily
AF_APPLETALK: AddressFamily
AF_ASH: AddressFamily
AF_ATMPVC: AddressFamily
AF_ATMSVC: AddressFamily
AF_AX25: AddressFamily
AF_BLUETOOTH: AddressFamily
AF_BRIDGE: AddressFamily
AF_CAN: AddressFamily
AF_DECnet: AddressFamily
AF_ECONET: AddressFamily
AF_IPX: AddressFamily
@ -45,20 +75,19 @@ AF_IRDA: AddressFamily
AF_KEY: AddressFamily
AF_LLC: AddressFamily
AF_NETBEUI: AddressFamily
AF_NETLINK: AddressFamily
AF_NETROM: AddressFamily
AF_PACKET: AddressFamily
AF_PPPOX: AddressFamily
AF_RDS: AddressFamily
AF_ROSE: AddressFamily
AF_ROUTE: AddressFamily
AF_SECURITY: AddressFamily
AF_SNA: AddressFamily
AF_SYSTEM: AddressFamily
AF_TIPC: AddressFamily
AF_UNSPEC: AddressFamily
AF_WANPIPE: AddressFamily
AF_X25: AddressFamily
# The "many constants" referenced by the docs
SOMAXCONN: int
AI_ADDRCONFIG: AddressInfo
AI_ALL: AddressInfo
AI_CANONNAME: AddressInfo
@ -69,26 +98,7 @@ AI_NUMERICSERV: AddressInfo
AI_PASSIVE: AddressInfo
AI_V4MAPPED: AddressInfo
AI_V4MAPPED_CFG: AddressInfo
BDADDR_ANY: str
BDADDR_LOCAL: str
BTPROTO_HCI: int
BTPROTO_L2CAP: int
BTPROTO_RFCOMM: int
BTPROTO_SCO: int
CAN_EFF_FLAG: int
CAN_EFF_MASK: int
CAN_ERR_FLAG: int
CAN_ERR_MASK: int
CAN_RAW: int
CAN_RAW_ERR_FILTER: int
CAN_RAW_FILTER: int
CAN_RAW_LOOPBACK: int
CAN_RAW_RECV_OWN_MSGS: int
CAN_RTR_FLAG: int
CAN_SFF_MASK: int
CAPI: int
EAGAIN: int
EAI_ADDRFAMILY: int
EAIEAI_ADDRFAMILY: int
EAI_AGAIN: int
EAI_BADFLAGS: int
EAI_BADHINTS: int
@ -103,12 +113,6 @@ EAI_PROTOCOL: int
EAI_SERVICE: int
EAI_SOCKTYPE: int
EAI_SYSTEM: int
EBADF: int
EINTR: int
EWOULDBLOCK: int
HCI_DATA_DIR: int
HCI_FILTER: int
HCI_TIME_STAMP: int
INADDR_ALLHOSTS_GROUP: int
INADDR_ANY: int
INADDR_BROADCAST: int
@ -174,12 +178,13 @@ IPV6_RECVPKTINFO: int
IPV6_RECVRTHDR: int
IPV6_RECVTCLASS: int
IPV6_RTHDR: int
IPV6_RTHDR_TYPE_0: int
IPV6_RTHDRDSTOPTS: int
IPV6_RTHDR_TYPE_0: int
IPV6_TCLASS: int
IPV6_UNICAST_HOPS: int
IPV6_USE_MIN_MTU: int
IPV6_V6ONLY: int
IPX_TYPE: int
IP_ADD_MEMBERSHIP: int
IP_DEFAULT_MULTICAST_LOOP: int
IP_DEFAULT_MULTICAST_TTL: int
@ -197,7 +202,6 @@ IP_RETOPTS: int
IP_TOS: int
IP_TRANSPARENT: int
IP_TTL: int
IPX_TYPE: int
LOCAL_PEERCRED: int
MSG_BCAST: MsgFlag
MSG_BTAG: MsgFlag
@ -219,20 +223,6 @@ MSG_OOB: MsgFlag
MSG_PEEK: MsgFlag
MSG_TRUNC: MsgFlag
MSG_WAITALL: MsgFlag
NETLINK_ARPD: int
NETLINK_CRYPTO: int
NETLINK_DNRTMSG: int
NETLINK_FIREWALL: int
NETLINK_IP6_FW: int
NETLINK_NFLOG: int
NETLINK_ROUTE6: int
NETLINK_ROUTE: int
NETLINK_SKIP: int
NETLINK_TAPBASE: int
NETLINK_TCPDIAG: int
NETLINK_USERSOCK: int
NETLINK_W1: int
NETLINK_XFRM: int
NI_DGRAM: int
NI_MAXHOST: int
NI_MAXSERV: int
@ -240,17 +230,6 @@ NI_NAMEREQD: int
NI_NOFQDN: int
NI_NUMERICHOST: int
NI_NUMERICSERV: int
PACKET_BROADCAST: int
PACKET_FASTROUTE: int
PACKET_HOST: int
PACKET_LOOPBACK: int
PACKET_MULTICAST: int
PACKET_OTHERHOST: int
PACKET_OUTGOING: int
PF_CAN: int
PF_PACKET: int
PF_RDS: int
PF_SYSTEM: int
SCM_CREDENTIALS: int
SCM_CREDS: int
SCM_RIGHTS: int
@ -259,17 +238,13 @@ SHUT_RDWR: int
SHUT_WR: int
SOL_ATALK: int
SOL_AX25: int
SOL_CAN_BASE: int
SOL_CAN_RAW: int
SOL_HCI: int
SOL_IP: int
SOL_IPX: int
SOL_NETROM: int
SOL_RDS: int
SOL_ROSE: int
SOL_SOCKET: int
SOL_TCP: int
SOL_TIPC: int
SOL_UDP: int
SO_ACCEPTCONN: int
SO_BINDTODEVICE: int
@ -296,7 +271,6 @@ SO_SNDLOWAT: int
SO_SNDTIMEO: int
SO_TYPE: int
SO_USELOOPBACK: int
SYSPROTO_CONTROL: int
TCP_CORK: int
TCP_DEFER_ACCEPT: int
TCP_FASTOPEN: int
@ -307,35 +281,65 @@ TCP_KEEPINTVL: int
TCP_LINGER2: int
TCP_MAXSEG: int
TCP_NODELAY: int
TCP_NOTSENT_LOWAT: int
TCP_QUICKACK: int
TCP_SYNCNT: int
TCP_WINDOW_CLAMP: int
TIPC_ADDR_ID: int
TIPC_ADDR_NAME: int
TIPC_ADDR_NAMESEQ: int
TIPC_CFG_SRV: int
TIPC_CLUSTER_SCOPE: int
TIPC_CONN_TIMEOUT: int
TIPC_CRITICAL_IMPORTANCE: int
TIPC_DEST_DROPPABLE: int
TIPC_HIGH_IMPORTANCE: int
TIPC_IMPORTANCE: int
TIPC_LOW_IMPORTANCE: int
TIPC_MEDIUM_IMPORTANCE: int
TIPC_NODE_SCOPE: int
TIPC_PUBLISHED: int
TIPC_SRC_DROPPABLE: int
TIPC_SUB_CANCEL: int
TIPC_SUB_PORTS: int
TIPC_SUB_SERVICE: int
TIPC_SUBSCR_TIMEOUT: int
TIPC_TOP_SRV: int
TIPC_WAIT_FOREVER: int
TIPC_WITHDRAWN: int
TIPC_ZONE_SCOPE: int
if sys.version_info >= (3, 7):
TCP_NOTSENT_LOWAT: int
if sys.version_info >= (3, 3):
# Specifically-documented constants
if sys.platform == 'linux' and sys.version_info >= (3,):
AF_CAN: AddressFamily
PF_CAN: int
SOL_CAN_BASE: int
SOL_CAN_RAW: int
CAN_EFF_FLAG: int
CAN_EFF_MASK: int
CAN_ERR_FLAG: int
CAN_ERR_MASK: int
CAN_RAW: int
CAN_RAW_ERR_FILTER: int
CAN_RAW_FILTER: int
CAN_RAW_LOOPBACK: int
CAN_RAW_RECV_OWN_MSGS: int
CAN_RTR_FLAG: int
CAN_SFF_MASK: int
CAN_BCM: int
CAN_BCM_TX_SETUP: int
CAN_BCM_TX_DELETE: int
CAN_BCM_TX_READ: int
CAN_BCM_TX_SEND: int
CAN_BCM_RX_SETUP: int
CAN_BCM_RX_DELETE: int
CAN_BCM_RX_READ: int
CAN_BCM_TX_STATUS: int
CAN_BCM_TX_EXPIRED: int
CAN_BCM_RX_STATUS: int
CAN_BCM_RX_TIMEOUT: int
CAN_BCM_RX_CHANGED: int
CAN_RAW_FD_FRAMES: int
if sys.platform == 'linux' and sys.version_info >= (3, 7):
CAN_ISOTP: int
if sys.platform == 'linux':
AF_PACKET: AddressFamily
PF_PACKET: int
PACKET_BROADCAST: int
PACKET_FASTROUTE: int
PACKET_HOST: int
PACKET_LOOPBACK: int
PACKET_MULTICAST: int
PACKET_OTHERHOST: int
PACKET_OUTGOING: int
if sys.platform == 'linux' and sys.version_info >= (3,):
AF_RDS: AddressFamily
PF_RDS: int
SOL_RDS: int
RDS_CANCEL_SENT_TO: int
RDS_CMSG_RDMA_ARGS: int
RDS_CMSG_RDMA_DEST: int
@ -355,58 +359,130 @@ if sys.version_info >= (3, 3):
RDS_RDMA_USE_ONCE: int
RDS_RECVERR: int
if sys.version_info >= (3, 4):
CAN_BCM: int
CAN_BCM_TX_SETUP: int
CAN_BCM_TX_DELETE: int
CAN_BCM_TX_READ: int
CAN_BCM_TX_SEND: int
CAN_BCM_RX_SETUP: int
CAN_BCM_RX_DELETE: int
CAN_BCM_RX_READ: int
CAN_BCM_TX_STATUS: int
CAN_BCM_TX_EXPIRED: int
CAN_BCM_RX_STATUS: int
CAN_BCM_RX_TIMEOUT: int
CAN_BCM_RX_CHANGED: int
AF_LINK: AddressFamily
if sys.version_info >= (3, 5):
CAN_RAW_FD_FRAMES: int
if sys.version_info >= (3, 6):
SO_DOMAIN: int
SO_PROTOCOL: int
SO_PEERSEC: int
SO_PASSSEC: int
TCP_USER_TIMEOUT: int
TCP_CONGESTION: int
AF_ALG: AddressFamily
SOL_ALG: int
ALG_SET_KEY: int
ALG_SET_IV: int
ALG_SET_OP: int
ALG_SET_AEAD_ASSOCLEN: int
ALG_SET_AEAD_AUTHSIZE: int
ALG_SET_PUBKEY: int
ALG_OP_DECRYPT: int
ALG_OP_ENCRYPT: int
ALG_OP_SIGN: int
ALG_OP_VERIFY: int
if sys.platform == 'win32':
SIO_RCVALL: int
SIO_KEEPALIVE_VALS: int
if sys.version_info >= (3, 6):
SIO_LOOPBACK_FAST_PATH: int
RCVALL_IPLEVEL: int
RCVALL_MAX: int
RCVALL_OFF: int
RCVALL_ON: int
RCVALL_SOCKETLEVELONLY: int
if sys.version_info >= (3, 6):
SIO_LOOPBACK_FAST_PATH: int
if sys.platform == 'linux':
AF_TIPC: AddressFamily
SOL_TIPC: int
TIPC_ADDR_ID: int
TIPC_ADDR_NAME: int
TIPC_ADDR_NAMESEQ: int
TIPC_CFG_SRV: int
TIPC_CLUSTER_SCOPE: int
TIPC_CONN_TIMEOUT: int
TIPC_CRITICAL_IMPORTANCE: int
TIPC_DEST_DROPPABLE: int
TIPC_HIGH_IMPORTANCE: int
TIPC_IMPORTANCE: int
TIPC_LOW_IMPORTANCE: int
TIPC_MEDIUM_IMPORTANCE: int
TIPC_NODE_SCOPE: int
TIPC_PUBLISHED: int
TIPC_SRC_DROPPABLE: int
TIPC_SUBSCR_TIMEOUT: int
TIPC_SUB_CANCEL: int
TIPC_SUB_PORTS: int
TIPC_SUB_SERVICE: int
TIPC_TOP_SRV: int
TIPC_WAIT_FOREVER: int
TIPC_WITHDRAWN: int
TIPC_ZONE_SCOPE: int
# enum versions of above flags py 3.4+
if sys.platform == 'linux' and sys.version_info >= (3, 6):
AF_ALG: AddressFamily
SOL_ALG: int
ALG_OP_DECRYPT: int
ALG_OP_ENCRYPT: int
ALG_OP_SIGN: int
ALG_OP_VERIFY: int
ALG_SET_AEAD_ASSOCLEN: int
ALG_SET_AEAD_AUTHSIZE: int
ALG_SET_IV: int
ALG_SET_KEY: int
ALG_SET_OP: int
ALG_SET_PUBKEY: int
if sys.platform == 'linux' and sys.version_info >= (3, 7):
AF_VSOCK: AddressFamily
IOCTL_VM_SOCKETS_GET_LOCAL_CID: int
VMADDR_CID_ANY: int
VMADDR_CID_HOST: int
VMADDR_PORT_ANY: int
SO_VM_SOCKETS_BUFFER_MAX_SIZE: int
SO_VM_SOCKETS_BUFFER_SIZE: int
SO_VM_SOCKETS_BUFFER_MIN_SIZE: int
VM_SOCKETS_INVALID_VERSION: int
AF_LINK: AddressFamily # Availability: BSD, macOS
# BDADDR_* and HCI_* listed with other bluetooth constants below
if sys.version_info >= (3, 6):
SO_DOMAIN: int
SO_PASSSEC: int
SO_PEERSEC: int
SO_PROTOCOL: int
TCP_CONGESTION: int
TCP_USER_TIMEOUT: int
if sys.platform == 'linux' and sys.version_info >= (3, 8):
AF_QIPCRTR: AddressFamily
# Semi-documented constants
# (Listed under "Socket families" in the docs, but not "Constants")
if sys.platform == 'linux':
# Netlink is defined by Linux
AF_NETLINK: AddressFamily
NETLINK_ARPD: int
NETLINK_CRYPTO: int
NETLINK_DNRTMSG: int
NETLINK_FIREWALL: int
NETLINK_IP6_FW: int
NETLINK_NFLOG: int
NETLINK_ROUTE6: int
NETLINK_ROUTE: int
NETLINK_SKIP: int
NETLINK_TAPBASE: int
NETLINK_TCPDIAG: int
NETLINK_USERSOCK: int
NETLINK_W1: int
NETLINK_XFRM: int
if sys.platform != 'win32' and sys.platform != 'darwin':
# Linux and some BSD support is explicit in the docs
# Windows and macOS do not support in practice
AF_BLUETOOTH: AddressFamily
BTPROTO_HCI: int
BTPROTO_L2CAP: int
BTPROTO_RFCOMM: int
BTPROTO_SCO: int # not in FreeBSD
BDADDR_ANY: str
BDADDR_LOCAL: str
HCI_FILTER: int # not in NetBSD or DragonFlyBSD
# not in FreeBSD, NetBSD, or DragonFlyBSD
HCI_TIME_STAMP: int
HCI_DATA_DIR: int
if sys.platform == 'darwin':
# PF_SYSTEM is defined by macOS
PF_SYSTEM: int
SYSPROTO_CONTROL: int
# enum versions of above flags
if sys.version_info >= (3, 4):
from enum import IntEnum
@ -414,6 +490,8 @@ if sys.version_info >= (3, 4):
AF_UNIX: int
AF_INET: int
AF_INET6: int
AF_AAL5: int
AF_ALG: int
AF_APPLETALK: int
AF_ASH: int
AF_ATMPVC: int
@ -421,26 +499,31 @@ if sys.version_info >= (3, 4):
AF_AX25: int
AF_BLUETOOTH: int
AF_BRIDGE: int
AF_CAN: int
AF_DECnet: int
AF_ECONET: int
AF_IPX: int
AF_IRDA: int
AF_KEY: int
AF_LINK: int
AF_LLC: int
AF_NETBEUI: int
AF_NETLINK: int
AF_NETROM: int
AF_PACKET: int
AF_PPPOX: int
AF_QIPCRTR: int
AF_RDS: int
AF_ROSE: int
AF_ROUTE: int
AF_SECURITY: int
AF_SNA: int
AF_SYSTEM: int
AF_TIPC: int
AF_UNSPEC: int
AF_VSOCK: int
AF_WANPIPE: int
AF_X25: int
AF_LINK: int
class SocketKind(IntEnum):
SOCK_STREAM: int
@ -480,7 +563,8 @@ else:
MsgFlag = int
# ----- exceptions -----
# ----- Exceptions -----
if sys.version_info < (3,):
class error(IOError): ...
else:
@ -496,18 +580,19 @@ class timeout(error):
def __init__(self, error: int = ..., string: str = ...) -> None: ...
# ----- Classes -----
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
# AF_NETLINK, AF_TIPC) or strings (AF_UNIX).
_Address = Union[tuple, str]
_RetAddress = Any
# TODO Most methods allow bytes as address objects
# TODO AF_PACKET and AF_BLUETOOTH address objects
_WriteBuffer = Union[bytearray, memoryview]
_CMSG = Tuple[int, int, bytes]
_SelfT = TypeVar('_SelfT', bound=socket)
# ----- classes -----
class socket:
family: int
type: int
@ -517,8 +602,6 @@ class socket:
def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ...
else:
def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: Optional[int] = ...) -> None: ...
if sys.version_info >= (3, 2):
def __enter__(self: _SelfT) -> _SelfT: ...
def __exit__(self, *args: Any) -> None: ...
@ -529,8 +612,10 @@ class socket:
def connect(self, address: Union[_Address, bytes]) -> None: ...
def connect_ex(self, address: Union[_Address, bytes]) -> int: ...
def detach(self) -> int: ...
def dup(self) -> socket: ...
def fileno(self) -> int: ...
if sys.version_info >= (3, 4):
def get_inheritable(self) -> bool: ...
def getpeername(self) -> _RetAddress: ...
def getsockname(self) -> _RetAddress: ...
@ -539,71 +624,118 @@ class socket:
@overload
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
if sys.version_info >= (3, 7):
def getblocking(self) -> bool: ...
def gettimeout(self) -> Optional[float]: ...
def ioctl(self, control: object,
option: Tuple[int, int, int]) -> None: ...
if sys.version_info < (3, 5):
def listen(self, backlog: int) -> None: ...
else:
def listen(self, backlog: int = ...) -> None: ...
# TODO the return value may be BinaryIO or TextIO, depending on mode
def makefile(self, mode: str = ..., buffering: int = ...,
encoding: str = ..., errors: str = ...,
newline: str = ...) -> Any:
...
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
if sys.platform == 'win32':
def ioctl(self, control: object, option: Tuple[int, int, int]) -> None: ...
if sys.version_info >= (3, 5):
def listen(self, __backlog: int = ...) -> None: ...
else:
def listen(self, __backlog: int) -> None: ...
# Note that the makefile's documented windows-specific behavior is not represented
if sys.version_info < (3,):
def makefile(self, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ...
else:
# mode strings with duplicates are intentionally excluded
@overload
def makefile(self,
mode: Literal['r', 'w', 'rw', 'wr', ''],
buffering: Optional[int] = ...,
*,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...) -> TextIO: ...
@overload
def makefile(self,
mode: Literal['b', 'rb', 'br', 'wb', 'bw', 'rwb', 'rbw', 'wrb', 'wbr', 'brw', 'bwr'] = ...,
buffering: Optional[int] = ...,
*,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...) -> BinaryIO: ...
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
def recvfrom(self, bufsize: int, flags: int = ...) -> Tuple[bytes, _RetAddress]: ...
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int,
flags: int = ...) -> Tuple[int, _RetAddress]: ...
def recv_into(self, buffer: _WriteBuffer, nbytes: int,
flags: int = ...) -> int: ...
if sys.version_info >= (3, 3):
def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ...
def recvmsg_into(self,
__buffers: Iterable[_WriteBuffer],
__ancbufsize: int = ...,
__flags: int = ...) -> Tuple[int, List[_CMSG], int, Any]: ...
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> Tuple[int, _RetAddress]: ...
def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ...
def send(self, data: bytes, flags: int = ...) -> int: ...
def sendall(self, data: bytes, flags: int = ...) -> None:
... # return type: None on success
def sendall(self, data: bytes, flags: int = ...) -> None: ... # return type: None on success
@overload
def sendto(self, data: bytes, address: _Address) -> int: ...
@overload
def sendto(self, data: bytes, flags: int, address: _Address) -> int: ...
if sys.version_info >= (3, 3):
def sendmsg(self,
__buffers: Iterable[bytes],
__ancdata: Iterable[_CMSG] = ...,
__flags: int = ...,
__address: _Address = ...) -> int: ...
if sys.platform == 'linux' and sys.version_info >= (3, 6):
# TODO add the parameter types for sendmsg_afalg
def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> int: ...
if sys.version_info >= (3,):
# TODO determine legal types for file parameter
def sendfile(self, file, offset: int = ..., count: Optional[int] = ...) -> int: ...
def set_inheritable(self, inheritable: bool) -> None: ...
def setblocking(self, flag: bool) -> None: ...
def settimeout(self, value: Optional[float]) -> None: ...
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
if sys.version_info < (3, 6):
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
else:
@overload
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
@overload
def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ...
if sys.platform == 'win32':
def share(self, process_id: int) -> bytes: ...
def shutdown(self, how: int) -> None: ...
if sys.version_info >= (3, 3):
def recvmsg(self, __bufsize: int, __ancbufsize: int = ...,
__flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ...
def recvmsg_into(self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ...,
__flags: int = ...) -> Tuple[int, List[_CMSG], int, Any]: ...
def sendmsg(self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ...,
__flags: int = ..., __address: _Address = ...) -> int: ...
if sys.version_info >= (3, 4):
def set_inheritable(self, inheritable: bool) -> None: ...
# ----- Functions -----
if sys.version_info >= (3, 7):
def close(fd: int) -> None: ...
# ----- functions -----
def create_connection(address: Tuple[Optional[str], int],
timeout: Optional[float] = ...,
source_address: Tuple[Union[bytearray, bytes, Text], int] = ...) -> socket: ...
if sys.version_info >= (3, 8):
def create_server(address: _Address,
*,
family: int = ...,
backlog: Optional[int] = ...,
reuse_port: bool = ...,
dualstack_ipv6: bool = ...) -> socket: ...
def has_dualstack_ipv6() -> bool: ...
def create_server(
address: Tuple[str, int],
*,
family: AddressFamily = ...,
backlog: Optional[int] = ...,
reuse_port: bool = ...,
dualstack_ipv6: bool = ...,
) -> socket: ...
def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ...
if sys.platform == 'win32' and sys.version_info >= (3, 3):
def fromshare(data: bytes) -> socket: ...
# the 5th tuple item is an address
# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers
# https://github.com/python/mypy/issues/2509
def getaddrinfo(
host: Optional[Union[bytearray, bytes, Text]], port: Union[str, int, None], family: int = ...,
socktype: int = ..., proto: int = ...,
flags: int = ...) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]]:
...
def getaddrinfo(host: Optional[Union[bytearray, bytes, Text]],
port: Union[str, int, None],
family: int = ...,
socktype: int = ...,
proto: int = ...,
flags: int = ...) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]]: ...
def getfqdn(name: str = ...) -> str: ...
def gethostbyname(hostname: str) -> str: ...
@ -614,10 +746,7 @@ def getnameinfo(sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], fla
def getprotobyname(protocolname: str) -> int: ...
def getservbyname(servicename: str, protocolname: str = ...) -> int: ...
def getservbyport(port: int, protocolname: str = ...) -> str: ...
def socketpair(family: int = ...,
type: int = ...,
proto: int = ...) -> Tuple[socket, socket]: ...
def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ...
def socketpair(family: int = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ...
def ntohl(x: int) -> int: ... # param & ret val are 32-bit ints
def ntohs(x: int) -> int: ... # param & ret val are 16-bit ints
def htonl(x: int) -> int: ... # param & ret val are 32-bit ints
@ -626,12 +755,12 @@ def inet_aton(ip_string: str) -> bytes: ... # ret val 4 bytes in length
def inet_ntoa(packed_ip: bytes) -> str: ...
def inet_pton(address_family: int, ip_string: str) -> bytes: ...
def inet_ntop(address_family: int, packed_ip: bytes) -> str: ...
def getdefaulttimeout() -> Optional[float]: ...
def setdefaulttimeout(timeout: Optional[float]) -> None: ...
if sys.version_info >= (3, 3):
def CMSG_LEN(length: int) -> int: ...
def CMSG_SPACE(length: int) -> int: ...
def getdefaulttimeout() -> Optional[float]: ...
def setdefaulttimeout(timeout: Optional[float]) -> None: ...
if sys.version_info >= (3, 3):
def sethostname(name: str) -> None: ...
def if_nameindex() -> List[Tuple[int, str]]: ...
def if_nametoindex(name: str) -> int: ...

View File

@ -154,7 +154,7 @@ class Connection(object):
progress: Optional[Callable[[int, int, int], object]] = ..., name: str = ...,
sleep: float = ...) -> None: ...
def __call__(self, *args, **kwargs): ...
def __enter__(self, *args, **kwargs): ...
def __enter__(self, *args, **kwargs) -> Connection: ...
def __exit__(self, *args, **kwargs): ...
class Cursor(Iterator[Any]):

View File

@ -2,12 +2,18 @@
from typing import (
Any, Callable, ClassVar, Dict, List, NamedTuple, Optional, Set, Text, Type, Tuple, Union,
overload
)
import enum
import socket
import sys
import os
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
_PCTRTT = Tuple[Tuple[str, str], ...]
_PCTRTTT = Tuple[_PCTRTT, ...]
_PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]]
@ -200,10 +206,15 @@ class SSLSocket(socket.socket):
buffer: Optional[bytearray] = ...) -> bytes: ...
def write(self, buf: bytes) -> int: ...
def do_handshake(self) -> None: ...
def getpeercert(self, binary_form: bool = ...) -> _PeerCertRetType: ...
def cipher(self) -> Tuple[str, int, int]: ...
@overload
def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ...
@overload
def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ...
@overload
def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ...
def cipher(self) -> Optional[Tuple[str, str, int]]: ...
if sys.version_info >= (3, 5):
def shared_cipher(self) -> Optional[List[Tuple[str, int, int]]]: ...
def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ...
def compression(self) -> Optional[str]: ...
def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ...
def selected_alpn_protocol(self) -> Optional[str]: ...
@ -284,14 +295,21 @@ if sys.version_info >= (3, 5):
def read(self, len: int = ...,
buffer: Optional[bytearray] = ...) -> bytes: ...
def write(self, buf: bytes) -> int: ...
def getpeercert(self, binary_form: bool = ...) -> _PeerCertRetType: ...
@overload
def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ...
@overload
def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ...
@overload
def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ...
def selected_alpn_protocol(self) -> Optional[str]: ...
def selected_npn_protocol(self) -> Optional[str]: ...
def cipher(self) -> Tuple[str, int, int]: ...
def shared_cipher(self) -> Optional[List[Tuple[str, int, int]]]: ...
def cipher(self) -> Optional[Tuple[str, str, int]]: ...
def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ...
def compression(self) -> Optional[str]: ...
def pending(self) -> int: ...
def do_handshake(self) -> None: ...
def unwrap(self) -> None: ...
def version(self) -> Optional[str]: ...
def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ...
if sys.version_info >= (3, 8):
def verify_client_post_handshake(self) -> None: ...

View File

@ -1,54 +1,49 @@
# Stubs for warnings
import sys
from typing import Any, Dict, List, NamedTuple, Optional, overload, TextIO, Tuple, Type, Union, ContextManager
from types import ModuleType
from typing import Any, List, NamedTuple, Optional, overload, TextIO, Type
from types import ModuleType, TracebackType
from typing_extensions import Literal
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from _warnings import warn as warn, warn_explicit as warn_explicit
@overload
def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
@overload
def warn(message: Warning, category: Any = ..., stacklevel: int = ...) -> None: ...
@overload
def warn_explicit(message: str, category: Type[Warning],
filename: str, lineno: int, module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...) -> None: ...
@overload
def warn_explicit(message: Warning, category: Any,
filename: str, lineno: int, module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...) -> None: ...
def showwarning(message: str, category: Type[Warning], filename: str,
lineno: int, file: Optional[TextIO] = ...,
line: Optional[str] = ...) -> None: ...
def formatwarning(message: str, category: Type[Warning], filename: str,
lineno: int, line: Optional[str] = ...) -> str: ...
def filterwarnings(action: str, message: str = ...,
category: Type[Warning] = ..., module: str = ...,
lineno: int = ..., append: bool = ...) -> None: ...
def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ...,
append: bool = ...) -> None: ...
def showwarning(
message: str, category: Type[Warning], filename: str, lineno: int, file: Optional[TextIO] = ..., line: Optional[str] = ...
) -> None: ...
def formatwarning(message: str, category: Type[Warning], filename: str, lineno: int, line: Optional[str] = ...) -> str: ...
def filterwarnings(
action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ...
) -> None: ...
def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ...
def resetwarnings() -> None: ...
class _Record(NamedTuple):
message: str
class _OptionError(Exception): ...
class WarningMessage:
message: Warning
category: Type[Warning]
filename: str
lineno: int
file: Optional[TextIO]
line: Optional[str]
filename: Any
lineno: Any
file: Optional[Any]
line: Optional[Any]
if sys.version_info >= (3, 6):
source: Optional[Any]
def __init__(self, message: Warning, category: Type[Warning], filename: Any, lineno: Any, file: Optional[Any] = ..., line: Optional[Any] = ..., source: Optional[Any] = ...) -> None: ...
else:
def __init__(self, message: Warning, category: Type[Warning], filename: Any, lineno: Any, file: Optional[Any] = ..., line: Optional[Any] = ...) -> None: ...
class catch_warnings:
@overload
def __new__(cls, *, record: Literal[False] = ..., module: Optional[ModuleType] = ...) -> _catch_warnings_without_records: ...
@overload
def __new__(cls, *, record: Literal[True], module: Optional[ModuleType] = ...) -> _catch_warnings_with_records: ...
@overload
def __new__(cls, *, record: bool, module: Optional[ModuleType] = ...) -> catch_warnings: ...
def __enter__(self) -> Optional[List[WarningMessage]]: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
@overload
def catch_warnings(*, record: Literal[False] = ..., module: Optional[ModuleType] = ...) -> ContextManager[None]: ...
class _catch_warnings_without_records(catch_warnings):
def __enter__(self) -> None: ...
@overload
def catch_warnings(*, record: Literal[True], module: Optional[ModuleType] = ...) -> ContextManager[List[_Record]]: ...
@overload
def catch_warnings(*, record: bool, module: Optional[ModuleType] = ...) -> ContextManager[Optional[List[_Record]]]: ...
class _catch_warnings_with_records(catch_warnings):
def __enter__(self) -> List[WarningMessage]: ...

View File

@ -0,0 +1,32 @@
import sys
from typing import Optional, Union, overload
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if sys.platform == "win32":
SND_FILENAME: int
SND_ALIAS: int
SND_LOOP: int
SND_MEMORY: int
SND_PURGE: int
SND_ASYNC: int
SND_NODEFAULT: int
SND_NOSTOP: int
SND_NOWAIT: int
MB_ICONASTERISK: int
MB_ICONEXCLAMATION: int
MB_ICONHAND: int
MB_ICONQUESTION: int
MB_OK: int
def Beep(frequency: int, duration: int) -> None: ...
# Can actually accept anything ORed with 4, and if not it's definitely str, but that's inexpressible
@overload
def PlaySound(sound: Optional[bytes], flags: Literal[4]) -> None: ...
@overload
def PlaySound(sound: Optional[Union[str, bytes]], flags: int) -> None: ...
def MessageBeep(type: int = ...) -> None: ...

View File

@ -6,7 +6,6 @@ import io
import os
import sys
if sys.version_info >= (3, 6):
_Path = Union[os.PathLike[str], str]
else:
@ -14,12 +13,12 @@ else:
_SZI = Union[Text, ZipInfo]
_DT = Tuple[int, int, int, int, int, int]
if sys.version_info >= (3,):
class BadZipFile(Exception): ...
BadZipfile = BadZipFile
else:
class BadZipfile(Exception): ...
error = BadZipfile
class LargeZipFile(Exception): ...
@ -37,8 +36,14 @@ class ZipExtFile(io.BufferedIOBase):
newlines: Optional[List[bytes]]
mode: str
name: str
def __init__(self, fileobj: IO[bytes], mode: str, zipinfo: ZipInfo, decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., close_fileobj: bool = ...) -> None: ...
def __init__(
self,
fileobj: IO[bytes],
mode: str,
zipinfo: ZipInfo,
decrypter: Optional[Callable[[Sequence[int]], bytes]] = ...,
close_fileobj: bool = ...,
) -> None: ...
def __repr__(self) -> str: ...
def peek(self, n: int = ...) -> bytes: ...
def read1(self, n: Optional[int]) -> bytes: ... # type: ignore
@ -73,47 +78,39 @@ class ZipFile:
) -> None: ...
else:
def __init__(
self, file: Union[_Path, IO[bytes]], mode: Text = ..., compression: int = ..., allowZip64: bool = ...,
self, file: Union[_Path, IO[bytes]], mode: Text = ..., compression: int = ..., allowZip64: bool = ...
) -> None: ...
def __enter__(self) -> ZipFile: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> None: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
def close(self) -> None: ...
def getinfo(self, name: Text) -> ZipInfo: ...
def infolist(self) -> List[ZipInfo]: ...
def namelist(self) -> List[Text]: ...
def open(self, name: _SZI, mode: Text = ...,
pwd: Optional[bytes] = ...) -> IO[bytes]: ...
def extract(self, member: _SZI, path: Optional[_SZI] = ...,
pwd: bytes = ...) -> str: ...
def extractall(self, path: Optional[_Path] = ...,
members: Optional[Iterable[Text]] = ...,
pwd: Optional[bytes] = ...) -> None: ...
def open(self, name: _SZI, mode: Text = ..., pwd: Optional[bytes] = ...) -> IO[bytes]: ...
def extract(self, member: _SZI, path: Optional[_SZI] = ..., pwd: bytes = ...) -> str: ...
def extractall(
self, path: Optional[_Path] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ...
) -> None: ...
def printdir(self) -> None: ...
def setpassword(self, pwd: bytes) -> None: ...
def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ...
def testzip(self) -> Optional[str]: ...
def write(self, filename: _Path, arcname: Optional[_Path] = ...,
compress_type: Optional[int] = ...) -> None: ...
def write(self, filename: _Path, arcname: Optional[_Path] = ..., compress_type: Optional[int] = ...) -> None: ...
if sys.version_info >= (3,):
def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str],
compress_type: Optional[int] = ...) -> None: ...
def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ...) -> None: ...
else:
def writestr(self,
zinfo_or_arcname: _SZI, bytes: bytes,
compress_type: Optional[int] = ...) -> None: ...
def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ...
class PyZipFile(ZipFile):
if sys.version_info >= (3,):
def __init__(self, file: Union[str, IO[bytes]], mode: str = ...,
compression: int = ..., allowZip64: bool = ...,
opimize: int = ...) -> None: ...
def writepy(self, pathname: str, basename: str = ...,
filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ...
def __init__(
self, file: Union[str, IO[bytes]], mode: str = ..., compression: int = ..., allowZip64: bool = ..., opimize: int = ...
) -> None: ...
def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ...
else:
def writepy(self,
pathname: Text, basename: Text = ...) -> None: ...
def writepy(self, pathname: Text, basename: Text = ...) -> None: ...
class ZipInfo:
filename: Text
@ -133,13 +130,13 @@ class ZipInfo:
CRC: int
compress_size: int
file_size: int
def __init__(self, filename: Optional[Text] = ...,
date_time: Optional[_DT] = ...) -> None: ...
def __init__(self, filename: Optional[Text] = ..., date_time: Optional[_DT] = ...) -> None: ...
if sys.version_info >= (3, 6):
def is_dir(self) -> bool: ...
@classmethod
def from_file(cls, filename: _Path, arcname: Optional[_Path] = ...) -> ZipInfo: ...
def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ...
def is_zipfile(filename: Union[_Path, IO[bytes]]) -> bool: ...
ZIP_STORED: int

View File

@ -1,11 +0,0 @@
from typing import Any, Dict, List, Optional, Tuple, Type
_defaultaction: str
_onceregistry: Dict[Any, Any]
filters: List[Tuple[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[Any, Any] = ...,
module_globals: Dict[Any, Any] = ...) -> None: ...

View File

@ -49,6 +49,9 @@ else:
@overload
def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ...
if sys.version_info >= (3, 9):
def unparse(ast_obj: AST) -> str: ...
def copy_location(new_node: _T, old_node: AST) -> _T: ...
def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
def fix_missing_locations(node: _T) -> _T: ...

View File

@ -59,4 +59,4 @@ class Future(Awaitable[_T], Iterable[_T]):
@property
def _loop(self) -> AbstractEventLoop: ...
def wrap_future(f: Union[_ConcurrentFuture[_T], Future[_T]]) -> Future[_T]: ...
def wrap_future(f: Union[_ConcurrentFuture[_T], Future[_T]], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...

View File

@ -1,5 +1,5 @@
from asyncio import transports
from typing import Optional, Text, Tuple, Union
from typing import Optional, Tuple, Union
class BaseProtocol:
def connection_made(self, transport: transports.BaseTransport) -> None: ...
@ -16,10 +16,10 @@ class BufferedProtocol(Protocol):
def buffer_updated(self, nbytes: int) -> None: ...
class DatagramProtocol(BaseProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: Tuple[str, int]) -> None: ...
def datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None: ...
def error_received(self, exc: Exception) -> None: ...
class SubprocessProtocol(BaseProtocol):
def pipe_data_received(self, fd: int, data: Union[bytes, Text]) -> None: ...
def pipe_data_received(self, fd: int, data: bytes) -> None: ...
def pipe_connection_lost(self, fd: int, exc: Optional[Exception]) -> None: ...
def process_exited(self) -> None: ...

View File

@ -11,25 +11,67 @@ else:
_Path = Union[str, bytes, os.PathLike]
_SuccessType = int
# 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[Any]] = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
workers: int = ...,
) -> _SuccessType: ...
def compile_file(
fullname: _Path,
ddir: Optional[_Path] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
) -> _SuccessType: ...
def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ...
if sys.version_info >= (3, 7):
from py_compile import PycInvalidationMode
def compile_dir(
dir: _Path,
maxlevels: int = ...,
ddir: Optional[_Path] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
workers: int = ...,
invalidation_mode: Optional[PycInvalidationMode] = ...,
) -> _SuccessType: ...
def compile_file(
fullname: _Path,
ddir: Optional[_Path] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
invalidation_mode: Optional[PycInvalidationMode] = ...,
) -> _SuccessType: ...
def compile_path(
skip_curdir: bool = ...,
maxlevels: int = ...,
force: bool = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
invalidation_mode: Optional[PycInvalidationMode] = ...,
) -> _SuccessType: ...
else:
# 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[Any]] = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
workers: int = ...,
) -> _SuccessType: ...
def compile_file(
fullname: _Path,
ddir: Optional[_Path] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
) -> _SuccessType: ...
def compile_path(
skip_curdir: bool = ...,
maxlevels: int = ...,
force: bool = ...,
quiet: int = ...,
legacy: bool = ...,
optimize: int = ...,
) -> _SuccessType: ...

View File

@ -0,0 +1,11 @@
from typing import Union, MutableMapping
_KeyType = Union[str, bytes]
_ValueType = Union[str, bytes]
class error(Exception): ...
def whichdb(filename: str) -> str: ...
def open(file: str, flag: str = ..., mode: int = ...) -> MutableMapping[_KeyType, _ValueType]: ...

View File

@ -0,0 +1,31 @@
import sys
from typing import Union, MutableMapping, Iterator, Optional, Type
from types import TracebackType
if sys.version_info >= (3, 8):
from typing import Final
else:
from typing_extensions import Final
_KeyType = Union[str, bytes]
_ValueType = Union[str, bytes]
error = OSError
class _Database(MutableMapping[_KeyType, bytes]):
def __init__(self, filebasename: str, mode: str, flag: str = ...) -> None: ...
def sync(self) -> None: ...
def iterkeys(self) -> Iterator[bytes]: ... # undocumented
def close(self) -> None: ...
def __getitem__(self, key: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __iter__(self) -> Iterator[bytes]: ...
def __len__(self) -> int: ...
def __del__(self) -> None: ...
def __enter__(self) -> _Database: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ...

View File

@ -0,0 +1,36 @@
from typing import Union, Optional, Type, Iterator, overload, List, TypeVar, Generic
from types import TracebackType
_T = TypeVar('_T')
_KeyType = Union[str, bytes]
_ValueType = Union[str, bytes]
class error(OSError): ...
# Actual typename gdbm, not exposed by the implementation
class _gdbm:
def firstkey(self) -> Optional[bytes]: ...
def nextkey(self, key: _KeyType) -> Optional[bytes]: ...
def reorganize(self) -> None: ...
def sync(self) -> None: ...
def close(self) -> None: ...
def __getitem__(self, item: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __len__(self) -> int: ...
def __enter__(self) -> _gdbm: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
@overload
def get(self, k: _KeyType) -> Optional[bytes]: ...
@overload
def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ...
def keys(self) -> List[bytes]: ...
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
def open(file: str, flag: str = ..., mode: int = ...) -> _gdbm: ...

View File

@ -0,0 +1,36 @@
from typing import Generic, Union, Iterator, Optional, Type, TypeVar, overload, List
from types import TracebackType
_T = TypeVar('_T')
_KeyType = Union[str, bytes]
_ValueType = Union[str, bytes]
class error(OSError): ...
library: str = ...
# Actual typename dbm, not exposed by the implementation
class _dbm:
def close(self) -> None: ...
def __getitem__(self, item: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __len__(self) -> int: ...
def __del__(self) -> None: ...
def __enter__(self) -> _dbm: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
@overload
def get(self, k: _KeyType) -> Optional[bytes]: ...
@overload
def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ...
def keys(self) -> List[bytes]: ...
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
def open(filename: str, flag: str = ..., mode: int = ...) -> _dbm: ...

View File

@ -26,7 +26,7 @@ class Message:
def set_unixfrom(self, unixfrom: str) -> None: ...
def get_unixfrom(self) -> Optional[str]: ...
def attach(self, payload: Message) -> None: ...
def get_payload(self, i: int = ..., decode: bool = ...) -> Optional[_PayloadType]: ...
def get_payload(self, i: int = ..., decode: bool = ...) -> Any: ... # returns Optional[_PayloadType]
def set_payload(self, payload: _PayloadType,
charset: _CharsetType = ...) -> None: ...
def set_charset(self, charset: _CharsetType) -> None: ...

View File

@ -39,7 +39,7 @@ WRAPPER_UPDATES: Sequence[str]
def update_wrapper(wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Sequence[str] = ...,
updated: Sequence[str] = ...) -> _AnyCallable: ...
def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_AnyCallable], _AnyCallable]: ...
def total_ordering(cls: type) -> type: ...
def total_ordering(cls: Type[_T]) -> Type[_T]: ...
def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ...
class partial(Generic[_T]):
@ -78,12 +78,12 @@ class _SingleDispatchCallable(Generic[_T]):
def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ...
if sys.version_info >= (3, 8):
class cached_property(Generic[_S, _T]):
func: Callable[[_S], _T]
class cached_property(Generic[_T]):
func: Callable[[Any], _T]
attrname: Optional[str]
def __init__(self, func: Callable[[_S], _T]) -> None: ...
def __init__(self, func: Callable[[Any], _T]) -> None: ...
@overload
def __get__(self, instance: None, owner: Optional[Type[_S]] = ...) -> cached_property[_S, _T]: ...
def __get__(self, instance: None, owner: Optional[Type[Any]] = ...) -> cached_property[_T]: ...
@overload
def __get__(self, instance: _S, owner: Optional[Type[_S]] = ...) -> _T: ...
def __set_name__(self, owner: Type[_S], name: str) -> None: ...
def __get__(self, instance: _S, owner: Optional[Type[Any]] = ...) -> _T: ...
def __set_name__(self, owner: Type[Any], name: str) -> None: ...

View File

@ -1,7 +1,7 @@
# Stubs for http.server (Python 3.4)
import sys
from typing import Any, BinaryIO, ClassVar, Dict, List, Mapping, Optional, Sequence, Tuple, Union
from typing import Any, BinaryIO, Callable, ClassVar, Dict, List, Mapping, Optional, Sequence, Tuple, Union
import socketserver
import email.message
@ -12,7 +12,7 @@ class HTTPServer(socketserver.TCPServer):
server_name: str
server_port: int
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type) -> None: ...
RequestHandlerClass: Callable[..., BaseHTTPRequestHandler]) -> None: ...
if sys.version_info >= (3, 7):
class ThreadingHTTPServer(socketserver.ThreadingMixIn, HTTPServer):

View File

@ -53,6 +53,7 @@ class RawIOBase(IOBase):
def read(self, size: int = ...) -> Optional[bytes]: ...
class BufferedIOBase(IOBase):
raw: RawIOBase # This is not part of the BufferedIOBase API and may not exist on some implementations.
def detach(self) -> RawIOBase: ...
def readinto(self, b: _bytearray_like) -> int: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...
@ -66,7 +67,7 @@ class FileIO(RawIOBase):
name: Union[int, str]
def __init__(
self,
name: Union[str, bytes, int],
file: Union[str, bytes, int],
mode: str = ...,
closefd: bool = ...,
opener: Optional[Callable[[Union[int, str], str], int]] = ...

View File

@ -4,15 +4,13 @@
from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple,
Generic, Optional)
import sys
_T = TypeVar('_T')
_S = TypeVar('_S')
_N = TypeVar('_N', int, float)
Predicate = Callable[[_T], object]
@overload
def count() -> Iterator[int]: ...
@overload
def count(start: _N = ...,
step: _N = ...) -> Iterator[_N]: ... # more general types?
def cycle(iterable: Iterable[_T]) -> Iterator[_T]: ...
@ -22,7 +20,17 @@ def repeat(object: _T) -> Iterator[_T]: ...
@overload
def repeat(object: _T, times: int) -> Iterator[_T]: ...
def accumulate(iterable: Iterable[_T], func: Callable[[_T, _T], _T] = ...) -> Iterator[_T]: ...
if sys.version_info >= (3, 8):
@overload
def accumulate(iterable: Iterable[_T],
func: Callable[[_T, _T], _T] = ...) -> Iterator[_T]: ...
@overload
def accumulate(iterable: Iterable[_T],
func: Callable[[_S, _T], _S],
initial: Optional[_S]) -> Iterator[_S]: ...
else:
def accumulate(iterable: Iterable[_T],
func: Callable[[_T, _T], _T] = ...) -> Iterator[_T]: ...
class chain(Iterator[_T], Generic[_T]):
def __init__(self, *iterables: Iterable[_T]) -> None: ...

View File

@ -38,7 +38,7 @@ class BaseContext(object):
# TODO: change return to SyncManager once a stub exists in multiprocessing.managers
def Manager(self) -> Any: ...
# TODO: change return to Pipe once a stub exists in multiprocessing.connection
def Pipe(self, duplex: bool) -> Any: ...
def Pipe(self, duplex: bool = ...) -> Any: ...
def Barrier(self,
parties: int,

View File

@ -8,10 +8,15 @@
import sys
from typing import (
List, Iterator, overload, Callable, Tuple,
AnyStr, Match, Pattern, Any, Optional, Union
AnyStr, Any, Optional, Union
)
# ----- re variables and constants -----
if sys.version_info >= (3, 7):
from typing import Pattern as Pattern, Match as Match
else:
from typing import Pattern, Match
if sys.version_info >= (3, 6):
import enum
class RegexFlag(enum.IntFlag):

View File

@ -1,14 +1,14 @@
# NB: SocketServer.pyi and socketserver.pyi must remain consistent!
# Stubs for socketserver
from typing import Any, BinaryIO, Optional, Tuple, Type, Text, Union
from typing import Any, BinaryIO, Callable, Optional, Tuple, Type, Text, Union
from socket import SocketType
import sys
import types
class BaseServer:
address_family: int
RequestHandlerClass: type
RequestHandlerClass: Callable[..., BaseRequestHandler]
server_address: Tuple[str, int]
socket: SocketType
allow_reuse_address: bool
@ -16,7 +16,7 @@ class BaseServer:
socket_type: int
timeout: Optional[float]
def __init__(self, server_address: Any,
RequestHandlerClass: type) -> None: ...
RequestHandlerClass: Callable[..., BaseRequestHandler]) -> None: ...
def fileno(self) -> int: ...
def handle_request(self) -> None: ...
def serve_forever(self, poll_interval: float = ...) -> None: ...
@ -44,23 +44,23 @@ class BaseServer:
class TCPServer(BaseServer):
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
class UDPServer(BaseServer):
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
if sys.platform != 'win32':
class UnixStreamServer(BaseServer):
def __init__(self, server_address: Union[Text, bytes],
RequestHandlerClass: type,
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
class UnixDatagramServer(BaseServer):
def __init__(self, server_address: Union[Text, bytes],
RequestHandlerClass: type,
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
class ForkingMixIn: ...

View File

@ -20,9 +20,9 @@ class Template:
template: str
def __init__(self, template: str) -> None: ...
def substitute(self, mapping: Mapping[str, str] = ..., **kwds: str) -> str: ...
def safe_substitute(self, mapping: Mapping[str, str] = ...,
**kwds: str) -> str: ...
def substitute(self, mapping: Mapping[str, object] = ..., **kwds: object) -> str: ...
def safe_substitute(self, mapping: Mapping[str, object] = ...,
**kwds: object) -> str: ...
# TODO(MichalPokorny): This is probably badly and/or loosely typed.
class Formatter:

View File

@ -55,7 +55,6 @@ def TemporaryFile(
prefix: Optional[AnyStr] = ...,
dir: Optional[_DirT[AnyStr]] = ...,
) -> IO[Any]: ...
@overload
def NamedTemporaryFile(
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"],
@ -93,17 +92,48 @@ def NamedTemporaryFile(
# It does not actually derive from IO[AnyStr], but it does implement the
# protocol.
class SpooledTemporaryFile(IO[AnyStr]):
def __init__(self, max_size: int = ..., mode: str = ...,
buffering: int = ..., encoding: Optional[str] = ...,
newline: Optional[str] = ..., suffix: Optional[str] = ...,
prefix: Optional[str] = ..., dir: Optional[str] = ...
) -> None: ...
# bytes needs to go first, as default mode is to open as bytes
@overload
def __init__(
self: SpooledTemporaryFile[bytes],
max_size: int = ...,
mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ...,
buffering: int = ...,
encoding: Optional[str] = ...,
newline: Optional[str] = ...,
suffix: Optional[str] = ...,
prefix: Optional[str] = ...,
dir: Optional[str] = ...,
) -> None: ...
@overload
def __init__(
self: SpooledTemporaryFile[str],
max_size: int = ...,
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"] = ...,
buffering: int = ...,
encoding: Optional[str] = ...,
newline: Optional[str] = ...,
suffix: Optional[str] = ...,
prefix: Optional[str] = ...,
dir: Optional[str] = ...,
) -> None: ...
@overload
def __init__(
self,
max_size: int = ...,
mode: str = ...,
buffering: int = ...,
encoding: Optional[str] = ...,
newline: Optional[str] = ...,
suffix: Optional[str] = ...,
prefix: Optional[str] = ...,
dir: Optional[str] = ...,
) -> None: ...
def rollover(self) -> None: ...
def __enter__(self: _S) -> _S: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> Optional[bool]: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> Optional[bool]: ...
# These methods are copied from the abstract methods of IO, because
# SpooledTemporaryFile implements IO.
# See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918.
@ -127,25 +157,24 @@ class SpooledTemporaryFile(IO[AnyStr]):
class TemporaryDirectory(Generic[AnyStr]):
name: str
def __init__(self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ...,
dir: Optional[_DirT[AnyStr]] = ...) -> None: ...
def __init__(
self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...
) -> None: ...
def cleanup(self) -> None: ...
def __enter__(self) -> AnyStr: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> None: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
def mkstemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...,
text: bool = ...) -> Tuple[int, AnyStr]: ...
def mkstemp(
suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., text: bool = ...
) -> Tuple[int, AnyStr]: ...
@overload
def mkdtemp() -> str: ...
@overload
def mkdtemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ...,
dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ...
def mkdtemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ...
def mktemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ...
def gettempdirb() -> bytes: ...
def gettempprefixb() -> bytes: ...
def gettempdir() -> str: ...
def gettempprefix() -> str: ...

View File

@ -40,7 +40,7 @@ class Untokenizer:
def untokenize(iterable: Iterable[_Token]) -> Any: ...
def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ...
def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ...
def generate_tokens(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... # undocumented
def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... # undocumented
if sys.version_info >= (3, 6):
from os import PathLike

View File

@ -5,14 +5,13 @@ from abc import abstractmethod, ABCMeta
from types import CodeType, FrameType, TracebackType
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
# Definitions of special type checking related constructs. Their definition
# Definitions of special type checking related constructs. Their definitions
# are not used, so their value does not matter.
overload = object()
Any = object()
TypeVar = object()
_promote = object()
no_type_check = object()
class _SpecialForm:
def __getitem__(self, typeargs: Any) -> Any: ...
@ -29,7 +28,7 @@ if sys.version_info >= (3, 8):
def final(f: _F) -> _F: ...
Literal: _SpecialForm = ...
# TypedDict is a (non-subscriptable) special form.
TypedDict: _SpecialForm = ...
TypedDict: object
class GenericMeta(type): ...
@ -38,6 +37,22 @@ class GenericMeta(type): ...
# distinguish the None type from the None value.
NoReturn = Union[None]
# These type variables are used by the container types.
_T = TypeVar('_T')
_S = TypeVar('_S')
_KT = TypeVar('_KT') # Key type.
_VT = TypeVar('_VT') # Value type.
_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers.
_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers.
_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: ...
# Type aliases and type constructors
class TypeAlias:
@ -64,19 +79,6 @@ AnyStr = TypeVar('AnyStr', str, bytes)
# Abstract base classes.
# These type variables are used by the container types.
_T = TypeVar('_T')
_S = TypeVar('_S')
_KT = TypeVar('_KT') # Key type.
_VT = TypeVar('_VT') # Value type.
_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers.
_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers.
_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])
def runtime_checkable(cls: _TC) -> _TC: ...
@runtime_checkable
@ -337,10 +339,12 @@ class MutableSet(AbstractSet[_T], Generic[_T]):
def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ...
def __isub__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...
class MappingView:
class MappingView(Sized):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __len__(self) -> int: ...
class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __and__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ...
def __rand__(self, o: Iterable[_T]) -> Set[_T]: ...
def __contains__(self, o: object) -> bool: ...
@ -355,6 +359,7 @@ class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co,
def __rxor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ...
class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __and__(self, o: Iterable[Any]) -> Set[_KT_co]: ...
def __rand__(self, o: Iterable[_T]) -> Set[_T]: ...
def __contains__(self, o: object) -> bool: ...
@ -369,6 +374,7 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
def __rxor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...
class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __contains__(self, o: object) -> bool: ...
def __iter__(self) -> Iterator[_VT_co]: ...
if sys.version_info >= (3, 8):

View File

@ -2,6 +2,7 @@ import datetime
import logging
import sys
import unittest.result
import warnings
from types import TracebackType
from typing import (
Any, AnyStr, Callable, Container, ContextManager, Dict, FrozenSet, Generic,
@ -115,7 +116,7 @@ class TestCase:
expected_regex: Union[str, bytes, Pattern[str], Pattern[bytes]],
msg: Any = ...) -> _AssertWarnsContext: ...
def assertLogs(
self, logger: Optional[logging.Logger] = ...,
self, logger: Optional[Union[str, logging.Logger]] = ...,
level: Union[int, str, None] = ...
) -> _AssertLogsContext: ...
@overload
@ -233,9 +234,10 @@ class _AssertRaisesContext(Generic[_E]):
exc_tb: Optional[TracebackType]) -> bool: ...
class _AssertWarnsContext:
warning: Warning
warning: warnings.WarningMessage
filename: str
lineno: int
warnings: List[warnings.WarningMessage]
def __enter__(self) -> _AssertWarnsContext: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> None: ...

View File

@ -1,11 +1,12 @@
from typing import List, Optional, Tuple, Type
from typing import List, Optional, Tuple, Type, Union
from types import TracebackType
import unittest.case
_SysExcInfoType = Tuple[Optional[Type[BaseException]],
Optional[BaseException],
Optional[TracebackType]]
_SysExcInfoType = Union[
Tuple[Type[BaseException], BaseException, TracebackType],
Tuple[None, None, None],
]
class TestResult:

View File

@ -15,13 +15,9 @@ import os
_T = TypeVar('_T')
_UrlopenRet = Any
class _HTTPResponse(HTTPResponse):
url: str
msg: str # type: ignore
def urlopen(
url: Union[str, Request], data: Optional[bytes] = ...,
timeout: float = ..., *, cafile: Optional[str] = ...,
timeout: Optional[float] = ..., *, cafile: Optional[str] = ...,
capath: Optional[str] = ..., cadefault: bool = ...,
context: Optional[ssl.SSLContext] = ...
) -> _UrlopenRet: ...
@ -71,7 +67,7 @@ class OpenerDirector:
addheaders: List[Tuple[str, str]]
def add_handler(self, handler: BaseHandler) -> None: ...
def open(self, url: Union[str, Request], data: Optional[bytes] = ...,
timeout: float = ...) -> _UrlopenRet: ...
timeout: Optional[float] = ...) -> _UrlopenRet: ...
def error(self, proto: str, *args: Any) -> _UrlopenRet: ...