Updated typeshed fallback stubs from the typeshed repo.

This commit is contained in:
Eric Traut 2020-05-13 23:37:07 -07:00
parent 3b806dd477
commit c1917556d1
46 changed files with 894 additions and 172 deletions

View File

@ -0,0 +1,62 @@
import sys
from typing import List, Optional, Union
if sys.platform == 'win32':
# Actual typename View, not exposed by the implementation
class _View:
def Execute(self, params: Optional[_Record] = ...) -> None: ...
def GetColumnInfo(self, kind: int) -> _Record: ...
def Fetch(self) -> _Record: ...
def Modify(self, mode: int, record: _Record) -> None: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
# Actual typename Summary, not exposed by the implementation
class _Summary:
def GetProperty(self, propid: int) -> Optional[Union[str, bytes]]: ...
def GetPropertyCount(self) -> int: ...
def SetProperty(self, propid: int, value: Union[str, bytes]) -> None: ...
def Persist(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
# Actual typename Database, not exposed by the implementation
class _Database:
def OpenView(self, sql: str) -> _View: ...
def Commit(self) -> None: ...
def GetSummaryInformation(self, updateCount: int) -> _Summary: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
# Actual typename Record, not exposed by the implementation
class _Record:
def GetFieldCount(self) -> int: ...
def GetInteger(self, field: int) -> int: ...
def GetString(self, field: int) -> str: ...
def SetString(self, field: int, str: str) -> None: ...
def SetStream(self, field: int, stream: str) -> None: ...
def SetInteger(self, field: int, int: int) -> None: ...
def ClearData(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
def UuidCreate() -> str: ...
def FCICreate(cabname: str, files: List[str]) -> None: ...
def OpenDatabase(name: str, flags: int) -> _Database: ...
def CreateRecord(count: int) -> _Record: ...

View File

@ -1444,6 +1444,16 @@ if sys.version_info < (3,):
def unichr(__i: int) -> unicode: ...
def vars(__object: Any = ...) -> Dict[str, Any]: ...
if sys.version_info >= (3,):
# Some overloads to better support zipping heterogeneous tuples
@overload
def zip(*iterables: Tuple[_T1, _T2]) -> Tuple[Tuple[_T1, ...], Tuple[_T2, ...]]: ... # type: ignore
@overload
def zip(*iterables: Tuple[_T1, _T2, _T3]) -> Tuple[Tuple[_T1, ...], Tuple[_T2, ...], Tuple[_T3, ...]]: ... # type: ignore
@overload
def zip(*iterables: Tuple[_T1, _T2, _T3, _T4]) -> Tuple[Tuple[_T1, ...], Tuple[_T2, ...], Tuple[_T3, ...], Tuple[_T4, ...]]: ... # type: ignore
@overload
def zip(*iterables: Tuple[_T1, _T2, _T3, _T4, _T5]) -> Tuple[Tuple[_T1, ...], Tuple[_T2, ...], Tuple[_T3, ...], Tuple[_T4, ...], Tuple[_T5, ...]]: ... # type: ignore
@overload
def zip(__iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ...
@overload

View File

@ -26,7 +26,7 @@ class CDLL(object):
_FuncPtr: Type[_FuncPointer] = ...
def __init__(
self,
name: str,
name: Optional[str],
mode: int = ...,
handle: Optional[int] = ...,
use_errno: bool = ...,

View File

@ -130,7 +130,7 @@ class time:
def __format__(self, fmt: AnyStr) -> AnyStr: ...
def utcoffset(self) -> Optional[timedelta]: ...
def tzname(self) -> Optional[str]: ...
def dst(self) -> Optional[int]: ...
def dst(self) -> Optional[timedelta]: ...
if sys.version_info >= (3, 6):
def replace(self, hour: int = ..., minute: int = ..., second: int = ...,
microsecond: int = ..., tzinfo: Optional[_tzinfo] = ...,

View File

@ -134,7 +134,7 @@ class FTP:
def rename(self, fromname: Text, toname: Text) -> str: ...
def delete(self, filename: Text) -> str: ...
def cwd(self, dirname: Text) -> str: ...
def size(self, filename: Text) -> str: ...
def size(self, filename: Text) -> Optional[int]: ...
def mkd(self, dirname: Text) -> str: ...
def rmd(self, dirname: Text) -> str: ...
def pwd(self) -> str: ...

View File

@ -0,0 +1,134 @@
import sys
from typing import List, Tuple, Union, Set, Optional, Dict, Container, Any, Type, Iterable, Sequence
from types import ModuleType
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if sys.platform == 'win32':
from _msi import _Database
AMD64: bool
if sys.version_info < (3, 7):
Itanium: bool
Win64: bool
datasizemask: Literal[0x00ff]
type_valid: Literal[0x0100]
type_localizable: Literal[0x0200]
typemask: Literal[0x0c00]
type_long: Literal[0x0000]
type_short: Literal[0x0400]
type_string: Literal[0x0c00]
type_binary: Literal[0x0800]
type_nullable: Literal[0x1000]
type_key: Literal[0x2000]
knownbits: Literal[0x3fff]
class Table:
name: str
fields: List[Tuple[int, str, int]]
def __init__(self, name: str) -> None: ...
def add_field(self, index: int, name: str, type: int) -> None: ...
def sql(self) -> str: ...
def create(self, db: _Database) -> None: ...
class _Unspecified: ...
def change_sequence(seq: Sequence[Tuple[str, Optional[str], int]], action: str, seqno: Union[int, Type[_Unspecified]] = ..., cond: Union[str, Type[_Unspecified]] = ...) -> None: ...
def add_data(db: _Database, table: str, values: Iterable[Tuple[Any, ...]]) -> None: ...
def add_stream(db: _Database, name: str, path: str) -> None: ...
def init_database(name: str, schema: ModuleType, ProductName: str, ProductCode: str, ProductVersion: str, Manufacturer: str) -> _Database: ...
def add_tables(db: _Database, module: ModuleType) -> None: ...
def make_id(str: str) -> str: ...
def gen_uuid() -> str: ...
class CAB:
name: str
files: List[Tuple[str, str]]
filenames: Set[str]
index: int
def __init__(self, name: str) -> None: ...
def gen_id(self, file: str) -> str: ...
def append(self, full: str, file: str, logical: str) -> Tuple[int, str]: ...
def commit(self, db: _Database) -> None: ...
_directories: Set[str]
class Directory:
db: _Database
cab: CAB
basedir: str
physical: str
logical: str
component: Optional[str]
short_names: Set[str]
ids: Set[str]
keyfiles: Dict[str, str]
componentflags: Optional[int]
absolute: str
def __init__(self, db: _Database, cab: CAB, basedir: str, physical: str, _logical: str, default: str, componentflags: Optional[int] = ...) -> None: ...
def start_component(self, component: Optional[str] = ..., feature: Optional[Feature] = ..., flags: Optional[int] = ..., keyfile: Optional[str] = ..., uuid: Optional[str] = ...) -> None: ...
def make_short(self, file: str) -> str: ...
def add_file(self, file: str, src: Optional[str] = ..., version: Optional[str] = ..., language: Optional[str] = ...) -> str: ...
def glob(self, pattern: str, exclude: Optional[Container[str]] = ...) -> List[str]: ...
def remove_pyc(self) -> None: ...
class Binary:
name: str
def __init__(self, fname: str) -> None: ...
def __repr__(self) -> str: ...
class Feature:
id: str
def __init__(self, db: _Database, id: str, title: str, desc: str, display: int, level: int = ..., parent: Optional[Feature] = ..., directory: Optional[str] = ..., attributes: int = ...) -> None: ...
def set_current(self) -> None: ...
class Control:
dlg: Dialog
name: str
def __init__(self, dlg: Dialog, name: str) -> None: ...
def event(self, event: str, argument: str, condition: str = ..., ordering: Optional[int] = ...) -> None: ...
def mapping(self, event: str, attribute: str) -> None: ...
def condition(self, action: str, condition: str) -> None: ...
class RadioButtonGroup(Control):
property: str
index: int
def __init__(self, dlg: Dialog, name: str, property: str) -> None: ...
def add(self, name: str, x: int, y: int, w: int, h: int, text: str, value: Optional[str] = ...) -> None: ...
class Dialog:
db: _Database
name: str
x: int
y: int
w: int
h: int
def __init__(self, db: _Database, name: str, x: int, y: int, w: int, h: int, attr: int, title: str, first: str, default: str, cancel: str) -> None: ...
def control(self, name: str, type: str, x: int, y: int, w: int, h: int, attr: int, prop: Optional[str], text: Optional[str], next: Optional[str], help: Optional[str]) -> Control: ...
def text(self, name: str, x: int, y: int, w: int, h: int, attr: int, text: Optional[str]) -> Control: ...
def bitmap(self, name: str, x: int, y: int, w: int, h: int, text: Optional[str]) -> Control: ...
def line(self, name: str, x: int, y: int, w: int, h: int) -> Control: ...
def pushbutton(self, name: str, x: int, y: int, w: int, h: int, attr: int, text: Optional[str], next: Optional[str]) -> Control: ...
def radiogroup(self, name: str, x: int, y: int, w: int, h: int, attr: int, prop: Optional[str], text: Optional[str], next: Optional[str]) -> RadioButtonGroup: ...
def checkbox(self, name: str, x: int, y: int, w: int, h: int, attr: int, prop: Optional[str], text: Optional[str], next: Optional[str]) -> Control: ...

View File

@ -0,0 +1,96 @@
import sys
from typing import List, Tuple, Optional
if sys.platform == 'win32':
from . import Table
_Validation: Table
ActionText: Table
AdminExecuteSequence: Table
Condition: Table
AdminUISequence: Table
AdvtExecuteSequence: Table
AdvtUISequence: Table
AppId: Table
AppSearch: Table
Property: Table
BBControl: Table
Billboard: Table
Feature: Table
Binary: Table
BindImage: Table
File: Table
CCPSearch: Table
CheckBox: Table
Class: Table
Component: Table
Icon: Table
ProgId: Table
ComboBox: Table
CompLocator: Table
Complus: Table
Directory: Table
Control: Table
Dialog: Table
ControlCondition: Table
ControlEvent: Table
CreateFolder: Table
CustomAction: Table
DrLocator: Table
DuplicateFile: Table
Environment: Table
Error: Table
EventMapping: Table
Extension: Table
MIME: Table
FeatureComponents: Table
FileSFPCatalog: Table
SFPCatalog: Table
Font: Table
IniFile: Table
IniLocator: Table
InstallExecuteSequence: Table
InstallUISequence: Table
IsolatedComponent: Table
LaunchCondition: Table
ListBox: Table
ListView: Table
LockPermissions: Table
Media: Table
MoveFile: Table
MsiAssembly: Table
MsiAssemblyName: Table
MsiDigitalCertificate: Table
MsiDigitalSignature: Table
MsiFileHash: Table
MsiPatchHeaders: Table
ODBCAttribute: Table
ODBCDriver: Table
ODBCDataSource: Table
ODBCSourceAttribute: Table
ODBCTranslator: Table
Patch: Table
PatchPackage: Table
PublishComponent: Table
RadioButton: Table
Registry: Table
RegLocator: Table
RemoveFile: Table
RemoveIniFile: Table
RemoveRegistry: Table
ReserveCost: Table
SelfReg: Table
ServiceControl: Table
ServiceInstall: Table
Shortcut: Table
Signature: Table
TextStyle: Table
TypeLib: Table
UIText: Table
Upgrade: Table
Verb: Table
tables: List[Table]
_Validation_records: List[Tuple[str, str, str, Optional[int], Optional[int], Optional[str], Optional[int], Optional[str], Optional[str], str]]

View File

@ -0,0 +1,15 @@
import sys
from typing import List, Tuple, Optional
if sys.platform == 'win32':
_SequenceType = List[Tuple[str, Optional[str], int]]
AdminExecuteSequence: _SequenceType
AdminUISequence: _SequenceType
AdvtExecuteSequence: _SequenceType
InstallExecuteSequence: _SequenceType
InstallUISequence: _SequenceType
tables: List[str]

View File

@ -0,0 +1,10 @@
import sys
from typing import List, Tuple, Optional
if sys.platform == 'win32':
ActionText: List[Tuple[str, str, Optional[str]]]
UIText: List[Tuple[str, Optional[str]]]
tables: List[str]

View File

@ -638,13 +638,11 @@ class socket:
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:
if sys.version_info >= (3,):
# mode strings with duplicates are intentionally excluded
@overload
def makefile(self,
mode: Literal['r', 'w', 'rw', 'wr', ''],
mode: Literal['r', 'w', 'rw', 'wr', ''] = ...,
buffering: Optional[int] = ...,
*,
encoding: Optional[str] = ...,
@ -652,12 +650,14 @@ class socket:
newline: Optional[str] = ...) -> TextIO: ...
@overload
def makefile(self,
mode: Literal['b', 'rb', 'br', 'wb', 'bw', 'rwb', 'rbw', 'wrb', 'wbr', 'brw', 'bwr'] = ...,
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: ...
else:
def makefile(self, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ...
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
def recvfrom(self, bufsize: int, flags: int = ...) -> Tuple[bytes, _RetAddress]: ...

View File

@ -2,10 +2,10 @@
import sys
from typing import (
Any, NamedTuple, NoReturn, Optional, Text, BinaryIO, Union, Tuple
Any, NamedTuple, NoReturn, Optional, Text, BinaryIO, Union, Tuple, IO
)
_File = Union[Text, BinaryIO]
_File = Union[Text, IO[bytes]]
class Error(Exception): ...

View File

@ -293,9 +293,14 @@ class Attribute(expr):
attr: _identifier
ctx: expr_context
if sys.version_info >= (3, 9):
_SliceT = expr
else:
_SliceT = _slice
class Subscript(expr):
value: expr
slice: _slice
slice: _SliceT
ctx: expr_context
class Starred(expr):

View File

@ -0,0 +1,2 @@
def getpreferredencoding(do_setlocale: bool = ...) -> str: ...

View File

@ -49,10 +49,7 @@ from asyncio.tasks import (
wait_for as wait_for,
Task as Task,
)
from asyncio.base_events import (
BaseEventLoop as BaseEventLoop,
Server as Server
)
from asyncio.base_events import BaseEventLoop as BaseEventLoop
from asyncio.events import (
AbstractEventLoopPolicy as AbstractEventLoopPolicy,
AbstractEventLoop as AbstractEventLoop,
@ -112,7 +109,7 @@ if sys.version_info >= (3, 7):
if sys.platform != 'win32':
from .unix_events import (
AbstractChildWatcher as AbstractChildWatcher,
BaseChildWatcher as BaseChildWatcher,
FastChildWatcher as FastChildWatcher,
SafeChildWatcher as SafeChildWatcher,
SelectorEventLoop as SelectorEventLoop,
)

View File

@ -72,8 +72,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ...
else:
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
async def run_in_executor(self, executor: Any,
func: Callable[..., _T], *args: Any) -> _T: ...
# run_in_executor is defined as a coroutine in AbstractEventLoop but returns a Future in concrete implementation.
# Need to ignore mypy Return type error as a result.
def run_in_executor(self, executor: Any, # type: ignore
func: Callable[..., _T], *args: Any) -> Future[_T]: ...
def set_default_executor(self, executor: Any) -> None: ...
# Network I/O methods returning Futures.
# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers

View File

@ -1,11 +1,14 @@
import enum
import sys
LOG_THRESHOLD_FOR_CONNLOST_WRITES: int
ACCEPT_RETRY_DELAY: int
DEBUG_STACK_DEPTH: int
SSL_HANDSHAKE_TIMEOUT: float
SENDFILE_FALLBACK_READBUFFER_SIZE: int
if sys.version_info >= (3, 6):
DEBUG_STACK_DEPTH: int
if sys.version_info >= (3, 7):
SSL_HANDSHAKE_TIMEOUT: float
SENDFILE_FALLBACK_READBUFFER_SIZE: int
class _SendfileMode(enum.Enum):
UNSUPPORTED: int = ...

View File

@ -192,18 +192,13 @@ class AbstractEventLoop(metaclass=ABCMeta):
family: int = ..., flags: int = ..., sock: socket = ..., backlog: int = ...,
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> AbstractServer: ...
@abstractmethod
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *, ssl: _SSLContext = ...,
sock: Optional[socket] = ..., server_hostname: str = ...,
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: Optional[str] = ..., *, ssl: _SSLContext = ...,
sock: Optional[socket] = ..., server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
@abstractmethod
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *, sock: Optional[socket] = ...,
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: Optional[str] = ..., *, sock: Optional[socket] = ...,
backlog: int = ..., ssl: _SSLContext = ..., ssl_handshake_timeout: Optional[float] = ...,
start_serving: bool = ...) -> AbstractServer: ...
@abstractmethod
async def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...,
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
@abstractmethod
async def sendfile(self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
fallback: bool = ...) -> int: ...
@abstractmethod
@ -225,15 +220,11 @@ class AbstractEventLoop(metaclass=ABCMeta):
sock: socket, backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> AbstractServer: ...
@abstractmethod
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *,
ssl: _SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> _TransProtPair: ...
@abstractmethod
server_hostname: Optional[str] = ...) -> _TransProtPair: ...
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: _SSLContext = ...) -> AbstractServer: ...
@abstractmethod
async def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...) -> _TransProtPair: ...
@abstractmethod
async def create_datagram_endpoint(self, protocol_factory: _ProtocolFactory,
local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *,
@ -332,7 +323,7 @@ def new_event_loop() -> AbstractEventLoop: ...
def get_child_watcher() -> AbstractChildWatcher: ...
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
def _set_running_loop(loop: Optional[AbstractEventLoop]) -> None: ...
def _set_running_loop(__loop: Optional[AbstractEventLoop]) -> None: ...
def _get_running_loop() -> AbstractEventLoop: ...
if sys.version_info >= (3, 7):

View File

@ -47,18 +47,16 @@ class Future(Awaitable[_T], Iterable[_T]):
def _callbacks(self: _S) -> List[Callable[[_S], Any]]: ...
def add_done_callback(self: _S, __fn: Callable[[_S], Any]) -> None: ...
def cancel(self) -> bool: ...
def _schedule_callbacks(self) -> None: ...
def cancelled(self) -> bool: ...
def done(self) -> bool: ...
def result(self) -> _T: ...
def exception(self) -> Optional[BaseException]: ...
def remove_done_callback(self: _S, fn: Callable[[_S], Any]) -> int: ...
def set_result(self, result: _T) -> None: ...
def set_exception(self, exception: Union[type, BaseException]) -> None: ...
def _copy_state(self, other: Any) -> None: ...
def remove_done_callback(self: _S, __fn: Callable[[_S], Any]) -> int: ...
def set_result(self, __result: _T) -> None: ...
def set_exception(self, __exception: Union[type, BaseException]) -> None: ...
def __iter__(self) -> Generator[Any, None, _T]: ...
def __await__(self) -> Generator[Any, None, _T]: ...
@property
def _loop(self) -> AbstractEventLoop: ...
def wrap_future(f: Union[_ConcurrentFuture[_T], Future[_T]], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def wrap_future(future: Union[_ConcurrentFuture[_T], Future[_T]], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...

View File

@ -1,4 +1,5 @@
from typing import Any, Callable, Type, TypeVar, Union, Optional, Awaitable
import sys
from typing import Any, Callable, Iterable, Generator, Type, TypeVar, Union, Optional, Awaitable
from .events import AbstractEventLoop
from .futures import Future
@ -6,17 +7,28 @@ from types import TracebackType
_T = TypeVar('_T')
class _ContextManager:
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
def __enter__(self) -> object: ...
def __exit__(self, *args: Any) -> None: ...
class _ContextManagerMixin(Future[_ContextManager]):
# Apparently this exists to *prohibit* use as a context manager.
def __enter__(self) -> object: ...
def __exit__(self, *args: Any) -> None: ...
def __aenter__(self) -> Awaitable[None]: ...
def __aexit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> Awaitable[None]: ...
if sys.version_info >= (3, 9):
class _ContextManagerMixin:
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
def __aenter__(self) -> Awaitable[None]: ...
def __aexit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> Awaitable[None]: ...
else:
class _ContextManager:
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
def __enter__(self) -> object: ...
def __exit__(self, *args: Any) -> None: ...
class _ContextManagerMixin:
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
# Apparently this exists to *prohibit* use as a context manager.
def __enter__(self) -> object: ...
def __exit__(self, *args: Any) -> None: ...
def __iter__(self) -> Generator[Any, None, _ContextManager]: ...
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
def __aenter__(self) -> Awaitable[None]: ...
def __aexit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> Awaitable[None]: ...
class Lock(_ContextManagerMixin):
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...

View File

@ -46,35 +46,4 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip
def write_eof(self) -> None: ...
class BaseProactorEventLoop(base_events.BaseEventLoop):
def __init__(self, proactor: Any) -> None: ...
# The methods below don't actually exist directly, ProactorEventLoops do not implement them. However, they are
# needed to satisfy mypy
if sys.version_info >= (3, 7):
async def create_unix_connection(
self,
protocol_factory: events._ProtocolFactory,
path: _Path,
*,
ssl: events._SSLContext = ...,
sock: Optional[socket] = ...,
server_hostname: str = ...,
ssl_handshake_timeout: Optional[float] = ...,
) -> events._TransProtPair: ...
async def create_unix_server(
self,
protocol_factory: events._ProtocolFactory,
path: _Path,
*,
sock: Optional[socket] = ...,
backlog: int = ...,
ssl: events._SSLContext = ...,
ssl_handshake_timeout: Optional[float] = ...,
start_serving: bool = ...,
) -> events.AbstractServer: ...
else:
async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> events._TransProtPair: ...
async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> events.AbstractServer: ...

View File

@ -11,7 +11,7 @@ class Protocol(BaseProtocol):
def data_received(self, data: bytes) -> None: ...
def eof_received(self) -> Optional[bool]: ...
class BufferedProtocol(Protocol):
class BufferedProtocol(BaseProtocol):
def get_buffer(self, sizehint: int) -> bytearray: ...
def buffer_updated(self, nbytes: int) -> None: ...

View File

@ -14,8 +14,6 @@ class Queue(Generic[_T]):
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def _format(self) -> str: ...
def _consume_done_getters(self) -> None: ...
def _consume_done_putters(self) -> None: ...
def qsize(self) -> int: ...
@property
def maxsize(self) -> int: ...

View File

@ -1,7 +1,7 @@
import selectors
import sys
from socket import socket
from typing import Optional, Union
from typing import Any, Optional, Union
from . import base_events, events
@ -12,33 +12,4 @@ else:
_Path = str
class BaseSelectorEventLoop(base_events.BaseEventLoop):
def __init__(self, selector: Optional[selectors.BaseSelector] = ...) -> None: ...
if sys.version_info >= (3, 7):
async def create_unix_connection(
self,
protocol_factory: events._ProtocolFactory,
path: _Path,
*,
ssl: events._SSLContext = ...,
sock: Optional[socket] = ...,
server_hostname: str = ...,
ssl_handshake_timeout: Optional[float] = ...,
) -> events._TransProtPair: ...
async def create_unix_server(
self,
protocol_factory: events._ProtocolFactory,
path: _Path,
*,
sock: Optional[socket] = ...,
backlog: int = ...,
ssl: events._SSLContext = ...,
ssl_handshake_timeout: Optional[float] = ...,
start_serving: bool = ...,
) -> events.AbstractServer: ...
else:
async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> events._TransProtPair: ...
async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> events.AbstractServer: ...

View File

@ -18,8 +18,8 @@ if sys.version_info < (3, 8):
def __init__(self, message: str, consumed: int) -> None: ...
async def open_connection(
host: str = ...,
port: Union[int, str] = ...,
host: Optional[str] = ...,
port: Optional[Union[int, str]] = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
@ -46,7 +46,7 @@ if sys.platform != 'win32':
_PathType = str
async def open_unix_connection(
path: _PathType = ...,
path: Optional[_PathType] = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
@ -55,7 +55,7 @@ if sys.platform != 'win32':
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback,
path: _PathType = ...,
path: Optional[_PathType] = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
@ -66,7 +66,7 @@ class FlowControlMixin(protocols.Protocol): ...
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __init__(self,
stream_reader: StreamReader,
client_connected_cb: _ClientConnectedCallback = ...,
client_connected_cb: Optional[_ClientConnectedCallback] = ...,
loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
def connection_made(self, transport: transports.BaseTransport) -> None: ...
def connection_lost(self, exc: Optional[Exception]) -> None: ...

View File

@ -30,7 +30,7 @@ class Process:
protocol: protocols.BaseProtocol,
loop: events.AbstractEventLoop) -> None: ...
@property
def returncode(self) -> int: ...
def returncode(self) -> Optional[int]: ...
async def wait(self) -> int: ...
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
@ -39,11 +39,11 @@ class Process:
async def create_subprocess_shell(
*Args: Union[str, bytes], # Union used instead of AnyStr due to mypy issue #1236
cmd: Union[str, bytes], # Union used instead of AnyStr due to mypy issue #1236
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
stderr: Union[int, IO[Any], None] = ...,
loop: events.AbstractEventLoop = ...,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
**kwds: Any
) -> Process: ...
@ -54,7 +54,7 @@ async def create_subprocess_exec(
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
stderr: Union[int, IO[Any], None] = ...,
loop: events.AbstractEventLoop = ...,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
**kwds: Any
) -> Process: ...

View File

@ -85,7 +85,7 @@ def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_
def run_coroutine_threadsafe(coro: _FutureT[_T],
loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
def shield(arg: _FutureT[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def sleep(delay: float, result: _T = ..., loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def sleep(delay: float, result: _T = ..., *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def wait(fs: Iterable[_FutureT[_T]], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ...,
return_when: str = ...) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ...
def wait_for(fut: _FutureT[_T], timeout: Optional[float],
@ -110,13 +110,12 @@ class Task(Future[_T], Generic[_T]):
if sys.version_info >= (3, 8):
def get_coro(self) -> Any: ...
def get_name(self) -> str: ...
def set_name(self, value: object) -> None: ...
def set_name(self, __value: object) -> None: ...
def get_stack(self, *, limit: int = ...) -> List[FrameType]: ...
def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ...
def cancel(self) -> bool: ...
def _step(self, value: Any = ..., exc: Exception = ...) -> None: ...
if sys.version_info < (3, 7):
def _wakeup(self, future: Future[Any]) -> None: ...
def _wakeup(self, fut: Future[Any]) -> None: ...
if sys.version_info >= (3, 7):
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...

View File

@ -1,4 +1,5 @@
import sys
from socket import _Address
from typing import Any, Mapping, List, Optional, Tuple
from asyncio.protocols import BaseProtocol
from asyncio.events import AbstractEventLoop
@ -32,7 +33,7 @@ class WriteTransport(BaseTransport):
class Transport(ReadTransport, WriteTransport): ...
class DatagramTransport(BaseTransport):
def sendto(self, data: Any, addr: Optional[Tuple[str, int]] = ...) -> None: ...
def sendto(self, data: Any, addr: Optional[_Address] = ...) -> None: ...
def abort(self) -> None: ...
class SubprocessTransport(BaseTransport):

View File

@ -4,7 +4,10 @@ import sys
EXTRA_QUEUED_CALLS: Any
if sys.version_info >= (3,):
if sys.version_info >= (3, 7):
from ._base import BrokenExecutor
class BrokenProcessPool(BrokenExecutor): ...
elif sys.version_info >= (3,):
class BrokenProcessPool(RuntimeError): ...
if sys.version_info >= (3, 7):

View File

@ -11,9 +11,10 @@ class NoBoundaryInMultipartDefect(MessageDefect): ...
class StartBoundaryNotFoundDefect(MessageDefect): ...
class FirstHeaderLineIsContinuationDefect(MessageDefect): ...
class MisplacedEnvelopeHeaderDefect(MessageDefect): ...
class MalformedHeaderDefect(MessageDefect): ...
class MultipartInvariantViolationDefect(MessageDefect): ...
class InvalidBase64PaddingDefect(MessageDefect): ...
class InvalidBase64CharactersDefect(MessageDefect): ...
class CloseBoundaryNotFoundDefect(MessageDefect): ...
class MissingHeaderBodySeparatorDefect(MessageDefect): ...
MalformedHeaderDefect = MissingHeaderBodySeparatorDefect

View File

@ -1,11 +1,17 @@
import sys
from typing import overload, Any, Container, IO, Iterable, Optional, Type, TypeVar
from typing import overload, Any, Container, IO, Iterable, Optional, Type, TypeVar, Union
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if sys.version_info >= (3, 6):
from os import PathLike
_Path = Union[str, PathLike[str]]
else:
_Path = str
class NullTranslations:
def __init__(self, fp: IO[str] = ...) -> None: ...
def _parse(self, fp: IO[str]) -> None: ...
@ -26,25 +32,25 @@ class GNUTranslations(NullTranslations):
LE_MAGIC: int
BE_MAGIC: int
def find(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterable[str]] = ...,
def find(domain: str, localedir: Optional[_Path] = ..., languages: Optional[Iterable[str]] = ...,
all: bool = ...) -> Any: ...
_T = TypeVar('_T')
@overload
def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterable[str]] = ...,
def translation(domain: str, localedir: Optional[_Path] = ..., languages: Optional[Iterable[str]] = ...,
class_: None = ..., fallback: bool = ..., codeset: Optional[str] = ...) -> NullTranslations: ...
@overload
def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterable[str]] = ...,
def translation(domain: str, localedir: Optional[_Path] = ..., languages: Optional[Iterable[str]] = ...,
class_: Type[_T] = ..., fallback: Literal[False] = ..., codeset: Optional[str] = ...) -> _T: ...
@overload
def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Iterable[str]] = ...,
def translation(domain: str, localedir: Optional[_Path] = ..., languages: Optional[Iterable[str]] = ...,
class_: Type[_T] = ..., fallback: Literal[True] = ..., codeset: Optional[str] = ...) -> Any: ...
def install(domain: str, localedir: Optional[str] = ..., codeset: Optional[str] = ...,
def install(domain: str, localedir: Optional[_Path] = ..., codeset: Optional[str] = ...,
names: Optional[Container[str]] = ...) -> None: ...
def textdomain(domain: Optional[str] = ...) -> str: ...
def bindtextdomain(domain: str, localedir: Optional[str] = ...) -> str: ...
def bindtextdomain(domain: str, localedir: Optional[_Path] = ...) -> str: ...
def bind_textdomain_codeset(domain: str, codeset: Optional[str] = ...) -> str: ...
def dgettext(domain: str, message: str) -> str: ...
def ldgettext(domain: str, message: str) -> str: ...

View File

@ -1,5 +1,9 @@
import sys
from enum import IntEnum
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
class HTTPStatus(IntEnum):
@property
@ -67,3 +71,7 @@ class HTTPStatus(IntEnum):
MISDIRECTED_REQUEST: int
if sys.version_info >= (3, 8):
UNAVAILABLE_FOR_LEGAL_REASONS: int
if sys.version_info >= (3, 9):
EARLY_HINTS: Literal[103]
IM_A_TEAPOT: Literal[418]
TOO_EARLY: Literal[425]

View File

@ -27,8 +27,6 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
path: str
request_version: str
headers: email.message.Message
rfile: BinaryIO
wfile: BinaryIO
server_version: str
sys_version: str
error_message_format: str

View File

@ -203,7 +203,7 @@ class TextIOWrapper(TextIO):
def tell(self) -> int: ...
class StringIO(TextIOWrapper):
def __init__(self, initial_value: str = ...,
def __init__(self, initial_value: Optional[str] = ...,
newline: Optional[str] = ...) -> None: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined

View File

@ -3,10 +3,18 @@ import socket
import sys
import types
if sys.version_info >= (3, 8):
from typing import SupportsIndex
# https://docs.python.org/3/library/multiprocessing.html#address-formats
_Address = Union[str, Tuple[str, int]]
class _ConnectionBase:
if sys.version_info >= (3, 8):
def __init__(self, handle: SupportsIndex, readable: bool = ..., writable: bool = ...) -> None: ...
else:
def __init__(self, handle: int, readable: bool = ..., writable: bool = ...) -> None: ...
@property
def closed(self) -> bool: ... # undocumented
@property

View File

@ -99,9 +99,10 @@ class Path(PurePath):
def owner(self) -> str: ...
if sys.version_info >= (3, 8):
def rename(self: _P, target: Union[str, PurePath]) -> _P: ...
def replace(self: _P, target: Union[str, PurePath]) -> _P: ...
else:
def rename(self, target: Union[str, PurePath]) -> None: ...
def replace(self, target: Union[str, PurePath]) -> None: ...
def replace(self, target: Union[str, PurePath]) -> None: ...
if sys.version_info < (3, 6):
def resolve(self: _P) -> _P: ...
else:

View File

@ -1,7 +1,7 @@
# NB: SocketServer.pyi and socketserver.pyi must remain consistent!
# Stubs for socketserver
from typing import Any, BinaryIO, Callable, List, Optional, Tuple, Type, Text, Union
from typing import Any, BinaryIO, Callable, ClassVar, List, Optional, Tuple, Type, Text, Union
from socket import SocketType
import sys
import types
@ -118,9 +118,16 @@ class BaseRequestHandler:
def finish(self) -> None: ...
class StreamRequestHandler(BaseRequestHandler):
rbufsize: ClassVar[int] # Undocumented
wbufsize: ClassVar[int] # Undocumented
timeout: ClassVar[Optional[float]] # Undocumented
disable_nagle_algorithm: ClassVar[bool] # Undocumented
connection: SocketType # Undocumented
rfile: BinaryIO
wfile: BinaryIO
class DatagramRequestHandler(BaseRequestHandler):
packet: SocketType # Undocumented
socket: SocketType # Undocumented
rfile: BinaryIO
wfile: BinaryIO

View File

@ -3,12 +3,17 @@
from decimal import Decimal
from fractions import Fraction
import sys
from typing import Any, Iterable, List, Optional, SupportsFloat, Type, TypeVar, Union
from typing import Any, Iterable, List, Optional, SupportsFloat, Type, TypeVar, Union, Protocol
_T = TypeVar("_T")
# Most functions in this module accept homogeneous collections of one of these types
_Number = TypeVar('_Number', float, Decimal, Fraction)
# Used in median_high, median_low
class _Sortable(Protocol):
def __lt__(self, other) -> bool: ...
_SortableT = TypeVar("_SortableT", bound=_Sortable)
class StatisticsError(ValueError): ...
if sys.version_info >= (3, 8):
@ -18,8 +23,8 @@ def mean(data: Iterable[_Number]) -> _Number: ...
if sys.version_info >= (3, 6):
def harmonic_mean(data: Iterable[_Number]) -> _Number: ...
def median(data: Iterable[_Number]) -> _Number: ...
def median_low(data: Iterable[_Number]) -> _Number: ...
def median_high(data: Iterable[_Number]) -> _Number: ...
def median_low(data: Iterable[_SortableT]) -> _SortableT: ...
def median_high(data: Iterable[_SortableT]) -> _SortableT: ...
def median_grouped(data: Iterable[_Number], interval: _Number = ...) -> _Number: ...
def mode(data: Iterable[_Number]) -> _Number: ...
if sys.version_info >= (3, 8):

View File

@ -1155,7 +1155,7 @@ class Popen(Generic[AnyStr]):
start_new_session: bool = ...,
pass_fds: Any = ...) -> Popen[Any]: ...
def poll(self) -> int: ...
def poll(self) -> Optional[int]: ...
if sys.version_info >= (3, 7):
def wait(self, timeout: Optional[float] = ...) -> int: ...
else:

View File

@ -14,10 +14,13 @@ TypeVar = object()
_promote = object()
class _SpecialForm:
def __getitem__(self, typeargs: Any) -> Any: ...
def __getitem__(self, typeargs: Any) -> object: ...
Union: _SpecialForm = ...
Optional: _SpecialForm = ...
Tuple: _SpecialForm = ...
Generic: _SpecialForm = ...
# Protocol is only present in 3.8 and later, but mypy needs it unconditionally
Protocol: _SpecialForm = ...
Callable: _SpecialForm = ...
Type: _SpecialForm = ...
@ -30,7 +33,8 @@ if sys.version_info >= (3, 8):
# TypedDict is a (non-subscriptable) special form.
TypedDict: object
class GenericMeta(type): ...
if sys.version_info < (3, 7):
class GenericMeta(type): ...
# Return type that indicates a function does not return.
# This type is equivalent to the None type, but the no-op Union is necessary to
@ -55,24 +59,21 @@ def no_type_check_decorator(decorator: _C) -> _C: ...
# Type aliases and type constructors
class TypeAlias:
class _Alias:
# Class for defining generic aliases for library types.
def __init__(self, target_type: type) -> None: ...
def __getitem__(self, typeargs: Any) -> Any: ...
Union = TypeAlias(object)
Optional = TypeAlias(object)
List = TypeAlias(object)
Dict = TypeAlias(object)
DefaultDict = TypeAlias(object)
Set = TypeAlias(object)
FrozenSet = TypeAlias(object)
Counter = TypeAlias(object)
Deque = TypeAlias(object)
ChainMap = TypeAlias(object)
List = _Alias()
Dict = _Alias()
DefaultDict = _Alias()
Set = _Alias()
FrozenSet = _Alias()
Counter = _Alias()
Deque = _Alias()
ChainMap = _Alias()
if sys.version_info >= (3, 7):
OrderedDict = TypeAlias(object)
OrderedDict = _Alias()
if sys.version_info >= (3, 9):
Annotated: _SpecialForm = ...
@ -616,9 +617,9 @@ if sys.version_info >= (3, 8):
def get_args(tp: Any) -> Tuple[Any, ...]: ...
@overload
def cast(tp: Type[_T], obj: Any) -> _T: ...
def cast(typ: Type[_T], val: Any) -> _T: ...
@overload
def cast(tp: str, obj: Any) -> Any: ...
def cast(typ: str, val: Any) -> Any: ...
# Type constructors

View File

@ -1,10 +1,29 @@
# Stubs for mock
import sys
from typing import Any, List, Optional, Text, Tuple, Type, TypeVar
from typing import Any, List, Optional, Sequence, Text, Tuple, Type, TypeVar
_T = TypeVar("_T")
__all__ = [
'Mock',
'MagicMock',
'patch',
'sentinel',
'DEFAULT',
'ANY',
'call',
'create_autospec',
'AsyncMock',
'FILTER_DIR',
'NonCallableMock',
'NonCallableMagicMock',
'mock_open',
'PropertyMock',
'seal',
]
__version__: str
FILTER_DIR: Any
class _slotted: ...
@ -82,7 +101,7 @@ class NonCallableMock(Base, Any): # type: ignore
def _get_call_signature_from_name(self, name: str) -> Any: ...
def assert_any_call(self, *args: Any, **kwargs: Any) -> None: ...
def assert_has_calls(self, calls: _CallList, any_order: bool = ...) -> None: ...
def assert_has_calls(self, calls: Sequence[_Call], any_order: bool = ...) -> None: ...
def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
def _mock_add_spec(self, spec: Any, spec_set, _spec_as_instance: bool = ..., _eat_self: bool = ...) -> None: ...
def attach_mock(self, mock: NonCallableMock, attribute: str) -> None: ...

View File

@ -108,14 +108,14 @@ class HTTPPasswordMgr:
def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ...
class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr):
def add_password(self, realm: str, uri: Union[str, Sequence[str]],
def add_password(self, realm: Optional[str], uri: Union[str, Sequence[str]],
user: str, passwd: str) -> None: ...
def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ...
def find_user_password(self, realm: Optional[str], authuri: str) -> Tuple[Optional[str], Optional[str]]: ...
class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm):
def add_password(
self,
realm: str,
realm: Optional[str],
uri: Union[str, Sequence[str]],
user: str,
passwd: str,

View File

@ -0,0 +1,283 @@
import io
import sys
import time
import gzip
import http.client
from typing import Any, Callable, Dict, IO, Iterable, List, Mapping, Optional, Protocol, Text, Tuple, Type, TypeVar, Union, overload
from types import TracebackType
from datetime import datetime
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
_T = TypeVar("_T")
class _HasTimeTuple(Protocol):
def timetuple(self) -> time.struct_time: ...
class _HasWrite(Protocol):
def write(self, __o: str) -> None: ...
class _HasRead(Protocol):
def read(self) -> bytes: ...
_DateTimeComparable = Union[DateTime, datetime, str, _HasTimeTuple]
_Marshallable = Union[None, bool, int, float, str, bytes, tuple, list, dict, datetime, DateTime, Binary]
_XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time]
_HostType = Union[Tuple[str, Dict[str, str]], str]
def escape(s: str) -> str: ... # undocumented
PARSE_ERROR: int # undocumented
SERVER_ERROR: int # undocumented
APPLICATION_ERROR: int # undocumented
SYSTEM_ERROR: int # undocumented
TRANSPORT_ERROR: int # undocumented
NOT_WELLFORMED_ERROR: int # undocumented
UNSUPPORTED_ENCODING: int # undocumented
INVALID_ENCODING_CHAR: int # undocumented
INVALID_XMLRPC: int # undocumented
METHOD_NOT_FOUND: int # undocumented
INVALID_METHOD_PARAMS: int # undocumented
INTERNAL_ERROR: int # undocumented
class Error(Exception): ...
class ProtocolError(Error):
url: str
errcode: int
errmsg: str
headers: Dict[str, str]
def __init__(self, url: str, errcode: int, errmsg: str, headers: Dict[str, str]) -> None: ...
class ResponseError(Error): ...
class Fault(Error):
faultCode: str
faultString: str
def __init__(self, faultCode: str, faultString: str, **extra: Any) -> None: ...
boolean = bool
Boolean = bool
def _iso8601_format(value: datetime) -> str: ... # undocumented
def _strftime(value: _XMLDate) -> str: ... # undocumented
class DateTime:
value: str # undocumented
def __init__(self, value: Union[int, str, datetime, time.struct_time, Tuple[int, ...]] = ...): ...
def __lt__(self, other: _DateTimeComparable) -> bool: ...
def __le__(self, other: _DateTimeComparable) -> bool: ...
def __gt__(self, other: _DateTimeComparable) -> bool: ...
def __ge__(self, other: _DateTimeComparable) -> bool: ...
def __eq__(self, other: _DateTimeComparable) -> bool: ... # type: ignore
def make_comparable(self, other: _DateTimeComparable) -> Tuple[str, str]: ... # undocumented
def timetuple(self) -> time.struct_time: ... # undocumented
def decode(self, data: Any) -> None: ...
def encode(self, out: _HasWrite) -> None: ...
def _datetime(data: Any) -> DateTime: ... # undocumented
def _datetime_type(data: str) -> datetime: ... # undocumented
class Binary:
data: bytes
def __init__(self, data: Optional[bytes] = ...) -> None: ...
def decode(self, data: bytes) -> None: ...
def encode(self, out: _HasWrite) -> None: ...
def _binary(data: bytes) -> Binary: ... # undocumented
WRAPPERS: Tuple[Type[DateTime], Type[Binary]] # undocumented
class ExpatParser: # undocumented
def __init__(self, target: Unmarshaller) -> None: ...
def feed(self, data: Union[Text, bytes]) -> None: ...
def close(self) -> None: ...
class Marshaller:
dispatch: Dict[Type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None]] = ... # TODO: Replace 'Any' with some kind of binding
memo: Dict[Any, None]
data: None
encoding: Optional[str]
allow_none: bool
def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ...
def dumps(self, values: Union[Fault, Iterable[_Marshallable]]) -> str: ...
def __dump(self, value: Union[_Marshallable], write: Callable[[str], Any]) -> None: ... # undocumented
def dump_nil(self, value: None, write: Callable[[str], Any]) -> None: ...
def dump_bool(self, value: bool, write: Callable[[str], Any]) -> None: ...
def dump_long(self, value: int, write: Callable[[str], Any]) -> None: ...
def dump_int(self, value: int, write: Callable[[str], Any]) -> None: ...
def dump_double(self, value: float, write: Callable[[str], Any]) -> None: ...
def dump_unicode(self, value: str, write: Callable[[str], Any], escape: Callable[[str], str] = ...) -> None: ...
def dump_bytes(self, value: bytes, write: Callable[[str], Any]) -> None: ...
def dump_array(self, value: Iterable[_Marshallable], write: Callable[[str], Any]) -> None: ...
def dump_struct(self, value: Mapping[str, _Marshallable], write: Callable[[str], Any], escape: Callable[[str], str] = ...) -> None: ...
def dump_datetime(self, value: _XMLDate, write: Callable[[str], Any]) -> None: ...
def dump_instance(self, value: object, write: Callable[[str], Any]) -> None: ...
class Unmarshaller:
dispatch: Dict[str, Callable[[Unmarshaller, str], None]] = ...
_type: Optional[str]
_stack: List[_Marshallable]
_marks: List[int]
_data: List[str]
_value: bool
_methodname: Optional[str]
_encoding: str
append: Callable[[Any], None]
_use_datetime: bool
_use_builtin_types: bool
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ...
def close(self) -> Tuple[_Marshallable, ...]: ...
def getmethodname(self) -> Optional[str]: ...
def xml(self, encoding: str, standalone: Any) -> None: ... # Standalone is ignored
def start(self, tag: str, attrs: Dict[str, str]) -> None: ...
def data(self, text: str) -> None: ...
def end(self, tag: str) -> None: ...
def end_dispatch(self, tag: str, data: str) -> None: ...
def end_nil(self, data: str) -> None: ...
def end_boolean(self, data: str) -> None: ...
def end_int(self, data: str) -> None: ...
def end_double(self, data: str) -> None: ...
if sys.version_info >= (3, 6):
def end_bigdecimal(self, data: str) -> None: ...
def end_string(self, data: str) -> None: ...
def end_array(self, data: str) -> None: ...
def end_struct(self, data: str) -> None: ...
def end_base64(self, data: str) -> None: ...
def end_dateTime(self, data: str) -> None: ...
def end_value(self, data: str) -> None: ...
def end_params(self, data: str) -> None: ...
def end_fault(self, data: str) -> None: ...
def end_methodName(self, data: str) -> None: ...
class _MultiCallMethod: # undocumented
__call_list: List[Tuple[str, Tuple[_Marshallable, ...]]]
__name: str
def __init__(self, call_list: List[Tuple[str, _Marshallable]], name: str) -> None: ...
def __getattr__(self, name: str) -> _MultiCallMethod: ...
def __call__(self, *args: _Marshallable) -> None: ...
class MultiCallIterator: # undocumented
results: List[List[_Marshallable]]
def __init__(self, results: List[List[_Marshallable]]) -> None: ...
def __getitem__(self, i: int) -> _Marshallable: ...
class MultiCall:
__server: ServerProxy
__call_list: List[Tuple[str, Tuple[_Marshallable, ...]]]
def __init__(self, server: ServerProxy) -> None: ...
def __getattr__(self, item: str) -> _MultiCallMethod: ...
def __call__(self) -> MultiCallIterator: ...
# A little white lie
FastMarshaller: Optional[Marshaller]
FastParser: Optional[ExpatParser]
FastUnmarshaller: Optional[Unmarshaller]
def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[ExpatParser, Unmarshaller]: ...
def dumps(params: Union[Fault, Tuple[_Marshallable, ...]], methodname: Optional[str] = ..., methodresponse: Optional[bool] = ..., encoding: Optional[str] = ..., allow_none: bool = ...) -> str: ...
def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[Tuple[_Marshallable, ...], Optional[str]]: ...
def gzip_encode(data: bytes) -> bytes: ... # undocumented
def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ... # undocumented
class GzipDecodedResponse(gzip.GzipFile): # undocumented
io: io.BytesIO
def __init__(self, response: _HasRead) -> None: ...
def close(self) -> None: ...
class _Method: # undocumented
__send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable]
__name: str
def __init__(self, send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ...
def __getattr__(self, name: str) -> _Method: ...
def __call__(self, *args: _Marshallable) -> _Marshallable: ...
class Transport:
user_agent: str = ...
accept_gzip_encoding: bool = ...
encode_threshold: Optional[int] = ...
_use_datetime: bool
_use_builtin_types: bool
_connection: Tuple[Optional[_HostType], Optional[http.client.HTTPConnection]]
_headers: List[Tuple[str, str]]
_extra_headers: List[Tuple[str, str]]
if sys.version_info >= (3, 8):
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ...) -> None: ...
else:
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ...
def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> Tuple[_Marshallable, ...]: ...
def single_request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> Tuple[_Marshallable, ...]: ...
def getparser(self) -> Tuple[ExpatParser, Unmarshaller]: ...
def get_host_info(self, host: _HostType) -> Tuple[str, List[Tuple[str, str]], Dict[str, str]]: ...
def make_connection(self, host: _HostType) -> http.client.HTTPConnection: ...
def close(self) -> None: ...
def send_request(self, host: _HostType, handler: str, request_body: bytes, debug: bool) -> http.client.HTTPConnection: ...
def send_headers(self, connection: http.client.HTTPConnection, headers: List[Tuple[str, str]]) -> None: ...
def send_content(self, connection: http.client.HTTPConnection, request_body: bytes) -> None: ...
def parse_response(self, response: http.client.HTTPResponse) -> Tuple[_Marshallable, ...]: ...
class SafeTransport(Transport):
if sys.version_info >= (3, 8):
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ..., context: Optional[Any] = ...) -> None: ...
else:
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Optional[Any] = ...) -> None: ...
def make_connection(self, host: _HostType) -> http.client.HTTPSConnection: ...
class ServerProxy:
__host: str
__handler: str
__transport: Transport
__encoding: str
__verbose: bool
__allow_none: bool
if sys.version_info >= (3, 8):
def __init__(self, uri, transport: Optional[Transport] = ..., encoding: Optional[str] = ..., verbose: bool = ..., allow_none: bool = ..., use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ..., context: Optional[Any] = ...) -> None: ...
else:
def __init__(self, uri, transport: Optional[Transport] = ..., encoding: Optional[str] = ..., verbose: bool = ..., allow_none: bool = ..., use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Optional[Any] = ...) -> None: ...
def __getattr__(self, name: str) -> _Method: ...
@overload
def __call__(self, attr: Literal["close"]) -> Callable[[], None]: ...
@overload
def __call__(self, attr: Literal["transport"]) -> Transport: ...
@overload
def __call__(self, attr: str) -> Union[Callable[[], None], Transport]: ...
def __enter__(self) -> ServerProxy: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
def __close(self) -> None: ... # undocumented
def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ... # undocumented
Server = ServerProxy

View File

@ -0,0 +1,105 @@
import http.server
import socketserver
import pydoc
import sys
from xmlrpc.client import Fault
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Pattern, Protocol, Tuple, Type, Union
from datetime import datetime
_Marshallable = Union[None, bool, int, float, str, bytes, tuple, list, dict, datetime]
class _DispatchProtocol(Protocol):
def __call__(self, *args: _Marshallable) -> _Marshallable: ...
def resolve_dotted_attribute(obj: Any, attr: str, allow_dotted_names: bool = ...) -> Any: ... # undocumented
def list_public_methods(obj: Any) -> List[str]: ... # undocumented
class SimpleXMLRPCDispatcher: # undocumented
funcs: Dict[str, _DispatchProtocol]
instance: Optional[Any]
allow_none: bool
encoding: str
use_builtin_types: bool
def __init__(self, allow_none: bool = ..., encoding: Optional[str] = ..., use_builtin_types: bool = ...) -> None: ...
def register_instance(self, instance: Any, allow_dotted_names: bool = ...) -> None: ...
if sys.version_info >= (3, 7):
def register_function(self, function: Optional[_DispatchProtocol] = ..., name: Optional[str] = ...) -> Callable[..., Any]: ...
else:
def register_function(self, function: _DispatchProtocol, name: Optional[str] = ...) -> Callable[..., Any]: ...
def register_introspection_functions(self) -> None: ...
def register_multicall_functions(self) -> None: ...
def _marshaled_dispatch(self, data: str, dispatch_method: Optional[Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]]] = ..., path: Optional[Any] = ...) -> str: ... # undocumented
def system_listMethods(self) -> List[str]: ... # undocumented
def system_methodSignature(self, method_name: str) -> str: ... # undocumented
def system_methodHelp(self, method_name: str) -> str: ... # undocumented
def system_multicall(self, call_list: List[Dict[str, _Marshallable]]) -> List[_Marshallable]: ... # undocumented
def _dispatch(self, method: str, params: Iterable[_Marshallable]) -> _Marshallable: ... # undocumented
class SimpleXMLRPCRequestHandler(http.server.BaseHTTPRequestHandler):
rpc_paths: Tuple[str, str] = ...
encode_threshold: int = ... # undocumented
aepattern: Pattern[str] # undocumented
def accept_encodings(self) -> Dict[str, float]: ...
def is_rpc_path_valid(self) -> bool: ...
def do_POST(self) -> None: ...
def decode_request_content(self, data: bytes) -> Optional[bytes]: ...
def report_404(self) -> None: ...
def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ...
class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher):
allow_reuse_address: bool = ...
_send_traceback_handler: bool = ...
def __init__(self, addr: Tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: Optional[str] = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ...) -> None: ...
class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented
dispatchers: Dict[str, SimpleXMLRPCDispatcher]
allow_none: bool
encoding: str
def __init__(self, addr: Tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: Optional[str] = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ...) -> None: ...
def add_dispatcher(self, path: str, dispatcher: SimpleXMLRPCDispatcher) -> SimpleXMLRPCDispatcher: ...
def get_dispatcher(self, path: str) -> SimpleXMLRPCDispatcher: ...
def _marshaled_dispatch(self, data: str, dispatch_method: Optional[Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]]] = ..., path: Optional[Any] = ...) -> str: ...
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
def __init__(self, allow_none: bool = ..., encoding: Optional[str] = ..., use_builtin_types: bool = ...) -> None: ...
def handle_xmlrpc(self, request_text: str) -> None: ...
def handle_get(self) -> None: ...
def handle_request(self, request_text: Optional[str] = ...) -> None: ...
class ServerHTMLDoc(pydoc.HTMLDoc): # undocumented
def docroutine(self, object: object, name: str, mod: Optional[str] = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., cl: Optional[type] = ...) -> str: ... # type: ignore
def docserver(self, server_name: str, package_documentation: str, methods: Dict[str, str]) -> str: ...
class XMLRPCDocGenerator: # undocumented
server_name: str
server_documentation: str
server_title: str
def __init__(self) -> None: ...
def set_server_title(self, server_title: str) -> None: ...
def set_server_name(self, server_name: str) -> None: ...
def set_server_documentation(self, server_documentation: str) -> None: ...
def generate_html_documentation(self) -> str: ...
class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
def do_GET(self) -> None: ...
class DocXMLRPCServer(SimpleXMLRPCServer, XMLRPCDocGenerator):
def __init__(self, addr: Tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: Optional[str] = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ...) -> None: ...
class DocCGIXMLRPCRequestHandler(CGIXMLRPCRequestHandler, XMLRPCDocGenerator):
def __init__(self) -> None: ...

View File

@ -2426,6 +2426,8 @@ export class Binder extends ParseTreeWalker {
Final: true,
Literal: true,
TypedDict: true,
Union: true,
Optional: true,
};
const assignedName = assignedNameNode.value;

View File

@ -6725,6 +6725,8 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
Final: { alias: '', module: 'builtins' },
Literal: { alias: '', module: 'builtins' },
TypedDict: { alias: '_TypedDict', module: 'self' },
Union: { alias: '', module: 'builtins' },
Optional: { alias: '', module: 'builtins' },
};
const aliasMapEntry = specialTypes[assignedName];
@ -6755,8 +6757,6 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
_promote: { alias: '', module: 'builtins' },
no_type_check: { alias: '', module: 'builtins' },
NoReturn: { alias: '', module: 'builtins' },
Union: { alias: '', module: 'builtins' },
Optional: { alias: '', module: 'builtins' },
List: { alias: 'list', module: 'builtins' },
Dict: { alias: 'dict', module: 'builtins' },
DefaultDict: { alias: 'defaultdict', module: 'collections' },