From c1917556d1467c0876ed15805c848ce26cd34046 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Wed, 13 May 2020 23:37:07 -0700 Subject: [PATCH] Updated typeshed fallback stubs from the typeshed repo. --- .../typeshed-fallback/stdlib/2and3/_msi.pyi | 62 ++++ .../stdlib/2and3/builtins.pyi | 10 + .../stdlib/2and3/ctypes/__init__.pyi | 2 +- .../stdlib/2and3/datetime.pyi | 2 +- .../typeshed-fallback/stdlib/2and3/ftplib.pyi | 2 +- .../stdlib/2and3/msilib/__init__.pyi | 134 +++++++++ .../stdlib/2and3/msilib/schema.pyi | 96 ++++++ .../stdlib/2and3/msilib/sequence.pyi | 15 + .../stdlib/2and3/msilib/text.pyi | 10 + .../typeshed-fallback/stdlib/2and3/socket.pyi | 10 +- .../typeshed-fallback/stdlib/2and3/wave.pyi | 4 +- client/typeshed-fallback/stdlib/3/_ast.pyi | 7 +- .../stdlib/3/_bootlocale.pyi | 2 + .../stdlib/3/asyncio/__init__.pyi | 7 +- .../stdlib/3/asyncio/base_events.pyi | 6 +- .../stdlib/3/asyncio/constants.pyi | 9 +- .../stdlib/3/asyncio/events.pyi | 19 +- .../stdlib/3/asyncio/futures.pyi | 10 +- .../stdlib/3/asyncio/locks.pyi | 34 ++- .../stdlib/3/asyncio/proactor_events.pyi | 31 -- .../stdlib/3/asyncio/protocols.pyi | 2 +- .../stdlib/3/asyncio/queues.pyi | 2 - .../stdlib/3/asyncio/selector_events.pyi | 31 +- .../stdlib/3/asyncio/streams.pyi | 10 +- .../stdlib/3/asyncio/subprocess.pyi | 8 +- .../stdlib/3/asyncio/tasks.pyi | 7 +- .../stdlib/3/asyncio/transports.pyi | 3 +- .../stdlib/3/concurrent/futures/process.pyi | 5 +- .../stdlib/3/email/errors.pyi | 3 +- client/typeshed-fallback/stdlib/3/gettext.pyi | 20 +- .../stdlib/3/http/__init__.pyi | 8 + .../stdlib/3/http/server.pyi | 2 - client/typeshed-fallback/stdlib/3/io.pyi | 2 +- .../stdlib/3/multiprocessing/connection.pyi | 8 + client/typeshed-fallback/stdlib/3/pathlib.pyi | 3 +- .../stdlib/3/socketserver.pyi | 9 +- .../typeshed-fallback/stdlib/3/statistics.pyi | 11 +- .../typeshed-fallback/stdlib/3/subprocess.pyi | 2 +- client/typeshed-fallback/stdlib/3/typing.pyi | 35 +-- .../stdlib/3/unittest/mock.pyi | 23 +- .../stdlib/3/urllib/request.pyi | 6 +- .../stdlib/3/xmlrpc/__init__.pyi | 0 .../stdlib/3/xmlrpc/client.pyi | 283 ++++++++++++++++++ .../stdlib/3/xmlrpc/server.pyi | 105 +++++++ server/src/analyzer/binder.ts | 2 + server/src/analyzer/typeEvaluator.ts | 4 +- 46 files changed, 894 insertions(+), 172 deletions(-) create mode 100644 client/typeshed-fallback/stdlib/2and3/_msi.pyi create mode 100644 client/typeshed-fallback/stdlib/2and3/msilib/__init__.pyi create mode 100644 client/typeshed-fallback/stdlib/2and3/msilib/schema.pyi create mode 100644 client/typeshed-fallback/stdlib/2and3/msilib/sequence.pyi create mode 100644 client/typeshed-fallback/stdlib/2and3/msilib/text.pyi create mode 100644 client/typeshed-fallback/stdlib/3/_bootlocale.pyi create mode 100644 client/typeshed-fallback/stdlib/3/xmlrpc/__init__.pyi create mode 100644 client/typeshed-fallback/stdlib/3/xmlrpc/client.pyi create mode 100644 client/typeshed-fallback/stdlib/3/xmlrpc/server.pyi diff --git a/client/typeshed-fallback/stdlib/2and3/_msi.pyi b/client/typeshed-fallback/stdlib/2and3/_msi.pyi new file mode 100644 index 000000000..092edf993 --- /dev/null +++ b/client/typeshed-fallback/stdlib/2and3/_msi.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/2and3/builtins.pyi b/client/typeshed-fallback/stdlib/2and3/builtins.pyi index 746190072..a4ed1f738 100644 --- a/client/typeshed-fallback/stdlib/2and3/builtins.pyi +++ b/client/typeshed-fallback/stdlib/2and3/builtins.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/2and3/ctypes/__init__.pyi b/client/typeshed-fallback/stdlib/2and3/ctypes/__init__.pyi index d07efd65e..616d9df92 100644 --- a/client/typeshed-fallback/stdlib/2and3/ctypes/__init__.pyi +++ b/client/typeshed-fallback/stdlib/2and3/ctypes/__init__.pyi @@ -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 = ..., diff --git a/client/typeshed-fallback/stdlib/2and3/datetime.pyi b/client/typeshed-fallback/stdlib/2and3/datetime.pyi index e80bb83f8..e0ae3fa16 100644 --- a/client/typeshed-fallback/stdlib/2and3/datetime.pyi +++ b/client/typeshed-fallback/stdlib/2and3/datetime.pyi @@ -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] = ..., diff --git a/client/typeshed-fallback/stdlib/2and3/ftplib.pyi b/client/typeshed-fallback/stdlib/2and3/ftplib.pyi index 13825c4a8..0e484a0cb 100644 --- a/client/typeshed-fallback/stdlib/2and3/ftplib.pyi +++ b/client/typeshed-fallback/stdlib/2and3/ftplib.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/2and3/msilib/__init__.pyi b/client/typeshed-fallback/stdlib/2and3/msilib/__init__.pyi new file mode 100644 index 000000000..b61b7d642 --- /dev/null +++ b/client/typeshed-fallback/stdlib/2and3/msilib/__init__.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/2and3/msilib/schema.pyi b/client/typeshed-fallback/stdlib/2and3/msilib/schema.pyi new file mode 100644 index 000000000..251e1ea39 --- /dev/null +++ b/client/typeshed-fallback/stdlib/2and3/msilib/schema.pyi @@ -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]] diff --git a/client/typeshed-fallback/stdlib/2and3/msilib/sequence.pyi b/client/typeshed-fallback/stdlib/2and3/msilib/sequence.pyi new file mode 100644 index 000000000..4f75d0dd3 --- /dev/null +++ b/client/typeshed-fallback/stdlib/2and3/msilib/sequence.pyi @@ -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] diff --git a/client/typeshed-fallback/stdlib/2and3/msilib/text.pyi b/client/typeshed-fallback/stdlib/2and3/msilib/text.pyi new file mode 100644 index 000000000..c27aebb52 --- /dev/null +++ b/client/typeshed-fallback/stdlib/2and3/msilib/text.pyi @@ -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] diff --git a/client/typeshed-fallback/stdlib/2and3/socket.pyi b/client/typeshed-fallback/stdlib/2and3/socket.pyi index 2535cea38..b33efbefd 100644 --- a/client/typeshed-fallback/stdlib/2and3/socket.pyi +++ b/client/typeshed-fallback/stdlib/2and3/socket.pyi @@ -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]: ... diff --git a/client/typeshed-fallback/stdlib/2and3/wave.pyi b/client/typeshed-fallback/stdlib/2and3/wave.pyi index 52bc9b156..ca76ca5e2 100644 --- a/client/typeshed-fallback/stdlib/2and3/wave.pyi +++ b/client/typeshed-fallback/stdlib/2and3/wave.pyi @@ -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): ... diff --git a/client/typeshed-fallback/stdlib/3/_ast.pyi b/client/typeshed-fallback/stdlib/3/_ast.pyi index f13c550ba..789c0a3bf 100644 --- a/client/typeshed-fallback/stdlib/3/_ast.pyi +++ b/client/typeshed-fallback/stdlib/3/_ast.pyi @@ -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): diff --git a/client/typeshed-fallback/stdlib/3/_bootlocale.pyi b/client/typeshed-fallback/stdlib/3/_bootlocale.pyi new file mode 100644 index 000000000..a29c066eb --- /dev/null +++ b/client/typeshed-fallback/stdlib/3/_bootlocale.pyi @@ -0,0 +1,2 @@ + +def getpreferredencoding(do_setlocale: bool = ...) -> str: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/__init__.pyi b/client/typeshed-fallback/stdlib/3/asyncio/__init__.pyi index d52787f25..996796ec3 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/__init__.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/__init__.pyi @@ -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, ) diff --git a/client/typeshed-fallback/stdlib/3/asyncio/base_events.pyi b/client/typeshed-fallback/stdlib/3/asyncio/base_events.pyi index 43ea39b62..db62aebe8 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/base_events.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/base_events.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/3/asyncio/constants.pyi b/client/typeshed-fallback/stdlib/3/asyncio/constants.pyi index f15ea4fe2..0b28309e9 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/constants.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/constants.pyi @@ -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 = ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/events.pyi b/client/typeshed-fallback/stdlib/3/asyncio/events.pyi index f90c98cbe..a5815c8bd 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/events.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/events.pyi @@ -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): diff --git a/client/typeshed-fallback/stdlib/3/asyncio/futures.pyi b/client/typeshed-fallback/stdlib/3/asyncio/futures.pyi index f4f97c607..1e492e1b5 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/futures.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/futures.pyi @@ -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]: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/locks.pyi b/client/typeshed-fallback/stdlib/3/asyncio/locks.pyi index 19d472760..55eabfffc 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/locks.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/locks.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/proactor_events.pyi b/client/typeshed-fallback/stdlib/3/asyncio/proactor_events.pyi index f7bc90db1..0ad5451fd 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/proactor_events.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/proactor_events.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/protocols.pyi b/client/typeshed-fallback/stdlib/3/asyncio/protocols.pyi index 0fa75a507..2c11849a3 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/protocols.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/protocols.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/queues.pyi b/client/typeshed-fallback/stdlib/3/asyncio/queues.pyi index 420c67a9d..75340e67e 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/queues.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/queues.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/selector_events.pyi b/client/typeshed-fallback/stdlib/3/asyncio/selector_events.pyi index 5d63cdf8f..1af86855b 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/selector_events.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/selector_events.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/streams.pyi b/client/typeshed-fallback/stdlib/3/asyncio/streams.pyi index e85170089..b691798ab 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/streams.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/streams.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/subprocess.pyi b/client/typeshed-fallback/stdlib/3/asyncio/subprocess.pyi index 14137447c..d968a156c 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/subprocess.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/subprocess.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/tasks.pyi b/client/typeshed-fallback/stdlib/3/asyncio/tasks.pyi index a209adfc1..a0a5f2253 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/tasks.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/tasks.pyi @@ -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]]: ... diff --git a/client/typeshed-fallback/stdlib/3/asyncio/transports.pyi b/client/typeshed-fallback/stdlib/3/asyncio/transports.pyi index a0b0fdd8b..10a2dd9b9 100644 --- a/client/typeshed-fallback/stdlib/3/asyncio/transports.pyi +++ b/client/typeshed-fallback/stdlib/3/asyncio/transports.pyi @@ -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): diff --git a/client/typeshed-fallback/stdlib/3/concurrent/futures/process.pyi b/client/typeshed-fallback/stdlib/3/concurrent/futures/process.pyi index ca22879c0..960a59f50 100644 --- a/client/typeshed-fallback/stdlib/3/concurrent/futures/process.pyi +++ b/client/typeshed-fallback/stdlib/3/concurrent/futures/process.pyi @@ -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): diff --git a/client/typeshed-fallback/stdlib/3/email/errors.pyi b/client/typeshed-fallback/stdlib/3/email/errors.pyi index 77d9902cc..73e0b800f 100644 --- a/client/typeshed-fallback/stdlib/3/email/errors.pyi +++ b/client/typeshed-fallback/stdlib/3/email/errors.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/3/gettext.pyi b/client/typeshed-fallback/stdlib/3/gettext.pyi index ad1ba3c82..8469c3d5e 100644 --- a/client/typeshed-fallback/stdlib/3/gettext.pyi +++ b/client/typeshed-fallback/stdlib/3/gettext.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/http/__init__.pyi b/client/typeshed-fallback/stdlib/3/http/__init__.pyi index 3abd978a5..2c61bd9d7 100644 --- a/client/typeshed-fallback/stdlib/3/http/__init__.pyi +++ b/client/typeshed-fallback/stdlib/3/http/__init__.pyi @@ -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] diff --git a/client/typeshed-fallback/stdlib/3/http/server.pyi b/client/typeshed-fallback/stdlib/3/http/server.pyi index 8682b9c14..fe9fc2384 100644 --- a/client/typeshed-fallback/stdlib/3/http/server.pyi +++ b/client/typeshed-fallback/stdlib/3/http/server.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/3/io.pyi b/client/typeshed-fallback/stdlib/3/io.pyi index efc77b970..1f3ca4973 100644 --- a/client/typeshed-fallback/stdlib/3/io.pyi +++ b/client/typeshed-fallback/stdlib/3/io.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/3/multiprocessing/connection.pyi b/client/typeshed-fallback/stdlib/3/multiprocessing/connection.pyi index cd03b7cb9..0fb97b107 100644 --- a/client/typeshed-fallback/stdlib/3/multiprocessing/connection.pyi +++ b/client/typeshed-fallback/stdlib/3/multiprocessing/connection.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/3/pathlib.pyi b/client/typeshed-fallback/stdlib/3/pathlib.pyi index b470d1f0d..4c4f9ee72 100644 --- a/client/typeshed-fallback/stdlib/3/pathlib.pyi +++ b/client/typeshed-fallback/stdlib/3/pathlib.pyi @@ -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: diff --git a/client/typeshed-fallback/stdlib/3/socketserver.pyi b/client/typeshed-fallback/stdlib/3/socketserver.pyi index 001e3fad9..41152a2e0 100644 --- a/client/typeshed-fallback/stdlib/3/socketserver.pyi +++ b/client/typeshed-fallback/stdlib/3/socketserver.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/3/statistics.pyi b/client/typeshed-fallback/stdlib/3/statistics.pyi index 5041933c4..bd30885c6 100644 --- a/client/typeshed-fallback/stdlib/3/statistics.pyi +++ b/client/typeshed-fallback/stdlib/3/statistics.pyi @@ -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): diff --git a/client/typeshed-fallback/stdlib/3/subprocess.pyi b/client/typeshed-fallback/stdlib/3/subprocess.pyi index 12ef94d3d..6bd98f739 100644 --- a/client/typeshed-fallback/stdlib/3/subprocess.pyi +++ b/client/typeshed-fallback/stdlib/3/subprocess.pyi @@ -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: diff --git a/client/typeshed-fallback/stdlib/3/typing.pyi b/client/typeshed-fallback/stdlib/3/typing.pyi index 11e7ed76a..046d0cf42 100644 --- a/client/typeshed-fallback/stdlib/3/typing.pyi +++ b/client/typeshed-fallback/stdlib/3/typing.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/3/unittest/mock.pyi b/client/typeshed-fallback/stdlib/3/unittest/mock.pyi index dca9986b1..9df57a9ec 100644 --- a/client/typeshed-fallback/stdlib/3/unittest/mock.pyi +++ b/client/typeshed-fallback/stdlib/3/unittest/mock.pyi @@ -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: ... diff --git a/client/typeshed-fallback/stdlib/3/urllib/request.pyi b/client/typeshed-fallback/stdlib/3/urllib/request.pyi index 6bc9a2327..143b6a850 100644 --- a/client/typeshed-fallback/stdlib/3/urllib/request.pyi +++ b/client/typeshed-fallback/stdlib/3/urllib/request.pyi @@ -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, diff --git a/client/typeshed-fallback/stdlib/3/xmlrpc/__init__.pyi b/client/typeshed-fallback/stdlib/3/xmlrpc/__init__.pyi new file mode 100644 index 000000000..e69de29bb diff --git a/client/typeshed-fallback/stdlib/3/xmlrpc/client.pyi b/client/typeshed-fallback/stdlib/3/xmlrpc/client.pyi new file mode 100644 index 000000000..e54c928b2 --- /dev/null +++ b/client/typeshed-fallback/stdlib/3/xmlrpc/client.pyi @@ -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 diff --git a/client/typeshed-fallback/stdlib/3/xmlrpc/server.pyi b/client/typeshed-fallback/stdlib/3/xmlrpc/server.pyi new file mode 100644 index 000000000..48e68a998 --- /dev/null +++ b/client/typeshed-fallback/stdlib/3/xmlrpc/server.pyi @@ -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: ... diff --git a/server/src/analyzer/binder.ts b/server/src/analyzer/binder.ts index 4e9d6826c..323bc7518 100644 --- a/server/src/analyzer/binder.ts +++ b/server/src/analyzer/binder.ts @@ -2426,6 +2426,8 @@ export class Binder extends ParseTreeWalker { Final: true, Literal: true, TypedDict: true, + Union: true, + Optional: true, }; const assignedName = assignedNameNode.value; diff --git a/server/src/analyzer/typeEvaluator.ts b/server/src/analyzer/typeEvaluator.ts index 06c1d90e4..47fe640b8 100644 --- a/server/src/analyzer/typeEvaluator.ts +++ b/server/src/analyzer/typeEvaluator.ts @@ -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' },