diff --git a/python/helpers/typeshed/.flake8 b/python/helpers/typeshed/.flake8 index 362deab3ccf9..b29cac96951e 100644 --- a/python/helpers/typeshed/.flake8 +++ b/python/helpers/typeshed/.flake8 @@ -1,22 +1,22 @@ # Some PEP8 deviations are considered irrelevant to stub files: -# (error counts as of 2017-05-22) -# 17952 E704 multiple statements on one line (def) -# 12197 E301 expected 1 blank line -# 7155 E302 expected 2 blank lines -# 1463 F401 imported but unused -# 967 E701 multiple statements on one line (colon) -# 457 F811 redefinition (should be fixed in pyflakes 2.1.2) -# 390 E305 expected 2 blank lines -# 4 E741 ambiguous variable name +# E301 expected 1 blank line +# E302 expected 2 blank lines +# E305 expected 2 blank lines +# E701 multiple statements on one line (colon) +# E741 ambiguous variable name +# F401 imported but unused +# F403 import *' used; unable to detect undefined names +# F405 defined from star imports +# F811 redefinition (should be fixed in pyflakes 2.1.2) +# F822 undefined name in __all__ # Nice-to-haves ignored for now -# 2307 E501 line too long - -# Other ignored warnings -# W504 line break after binary operator +# E501 line too long [flake8] -ignore = F401, F403, F405, F811, E301, E302, E305, E501, E701, E704, E741, B303, W504 +per-file-ignores = + *.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822 + # We are checking with Python 3 but many of the stubs are Python 2 stubs. builtins = StandardError,apply,basestring,buffer,cmp,coerce,execfile,file,intern,long,raw_input,reduce,reload,unichr,unicode,xrange exclude = .venv*,@*,.git diff --git a/python/helpers/typeshed/.travis.yml b/python/helpers/typeshed/.travis.yml index d52ed0920939..bb70c9fdb4ad 100644 --- a/python/helpers/typeshed/.travis.yml +++ b/python/helpers/typeshed/.travis.yml @@ -2,6 +2,16 @@ dist: bionic language: python python: 3.8 +aliases: + test_windows: &test_windows + os: windows + language: shell + env: &env_windows + PATH: /c/Python38:/c/Python38/Scripts:/c/Python37:/c/Python37/Scripts:/c/Python36:/c/Python36/Scripts:/c/Python35:/c/Python35/Scripts:$PATH + before_install: + - choco install python --version $PYTHON_VERSION + - python -m pip install -U pip + jobs: include: - name: "pytype" @@ -31,17 +41,45 @@ jobs: script: flake8 - name: "stubtest py38" python: 3.8 - install: pip install -U git+git://github.com/python/mypy@0a05e61a + install: pip install -U git+git://github.com/python/mypy@b3d43984 script: ./tests/stubtest_test.py - name: "stubtest py37" python: 3.7 - install: pip install -U git+git://github.com/python/mypy@0a05e61a + install: pip install -U git+git://github.com/python/mypy@b3d43984 script: ./tests/stubtest_test.py - name: "stubtest py36" python: 3.6 - install: pip install -U git+git://github.com/python/mypy@0a05e61a + install: pip install -U git+git://github.com/python/mypy@b3d43984 script: ./tests/stubtest_test.py - name: "stubtest py35" python: 3.5 - install: pip install -U git+git://github.com/python/mypy@0a05e61a + install: pip install -U git+git://github.com/python/mypy@b3d43984 script: ./tests/stubtest_test.py + - name: "stubtest py38 (Windows)" + <<: *test_windows + env: + <<: *env_windows + PYTHON_VERSION: 3.8.3 + install: pip install -U git+git://github.com/python/mypy@b3d43984 + script: python ./tests/stubtest_test.py + - name: "stubtest py37 (Windows)" + <<: *test_windows + env: + <<: *env_windows + PYTHON_VERSION: 3.7.7 + install: pip install -U git+git://github.com/python/mypy@b3d43984 + script: python ./tests/stubtest_test.py + - name: "stubtest py36 (Windows)" + <<: *test_windows + env: + <<: *env_windows + PYTHON_VERSION: 3.6.8 + install: pip install -U git+git://github.com/python/mypy@b3d43984 + script: python ./tests/stubtest_test.py + - name: "stubtest py35 (Windows)" + <<: *test_windows + env: + <<: *env_windows + PYTHON_VERSION: 3.5.4 + install: pip install -U git+git://github.com/python/mypy@b3d43984 + script: python ./tests/stubtest_test.py diff --git a/python/helpers/typeshed/CONTRIBUTING.md b/python/helpers/typeshed/CONTRIBUTING.md index 219975231586..ea3b7d669a8b 100644 --- a/python/helpers/typeshed/CONTRIBUTING.md +++ b/python/helpers/typeshed/CONTRIBUTING.md @@ -85,6 +85,8 @@ At present the core developers are (alphabetically): * Greg Price (@gnprice) * Sebastian Rittau (@srittau) * Guido van Rossum (@gvanrossum) +* Shantanu (@hauntsaninja) +* Rune Tynan (@CraftSpider) * Jelle Zijlstra (@JelleZijlstra) NOTE: the process for preparing and submitting changes also applies to @@ -373,3 +375,13 @@ Core developers should follow these rules when processing pull requests: * Make sure commit messages to master are meaningful. For example, remove irrelevant intermediate commit messages. * If stubs for a new library are submitted, notify the library's maintainers. + +When reviewing PRs, follow these guidelines: + +* Typing is hard. Try to be helpful and explain issues with the PR, + especially to new contributors. +* When reviewing auto-generated stubs, just scan for red flags and obvious + errors. Leave possible manual improvements for separate PRs. +* When reviewing large, hand-crafted PRs, you only need to look for red flags + and general issues, and do a few spot checks. +* Review smaller, hand-crafted PRs thoroughly. diff --git a/python/helpers/typeshed/requirements-tests-py3.txt b/python/helpers/typeshed/requirements-tests-py3.txt index 2846f3b7e383..ffbbceec9743 100644 --- a/python/helpers/typeshed/requirements-tests-py3.txt +++ b/python/helpers/typeshed/requirements-tests-py3.txt @@ -1,8 +1,8 @@ git+https://github.com/python/mypy.git@master typed-ast>=1.0.4 black==19.3b0 -flake8==3.7.8 -flake8-bugbear==19.8.0 -flake8-pyi==19.3.0 +flake8==3.8.1 +flake8-bugbear==20.1.4 +flake8-pyi==20.5.0 isort==4.3.21 pytype>=2020.01.08 diff --git a/python/helpers/typeshed/stdlib/2/SocketServer.pyi b/python/helpers/typeshed/stdlib/2/SocketServer.pyi index 001e3fad915b..3f57efbe9766 100644 --- a/python/helpers/typeshed/stdlib/2/SocketServer.pyi +++ b/python/helpers/typeshed/stdlib/2/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 @@ -63,23 +63,24 @@ if sys.platform != 'win32': RequestHandlerClass: Callable[..., BaseRequestHandler], bind_and_activate: bool = ...) -> None: ... -class ForkingMixIn: - timeout: Optional[float] # undocumented - active_children: Optional[List[int]] # undocumented - max_children: int # undocumented - if sys.version_info >= (3, 7): - block_on_close: bool - if sys.version_info >= (3, 6): - def collect_children(self, *, blocking: bool = ...) -> None: ... # undocumented - else: - def collect_children(self) -> None: ... # undocumented - def handle_timeout(self) -> None: ... # undocumented - if sys.version_info >= (3, 3): - def service_actions(self) -> None: ... # undocumented - def process_request(self, request: bytes, - client_address: Tuple[str, int]) -> None: ... - if sys.version_info >= (3, 6): - def server_close(self) -> None: ... +if sys.platform != "win32": + class ForkingMixIn: + timeout: Optional[float] # undocumented + active_children: Optional[List[int]] # undocumented + max_children: int # undocumented + if sys.version_info >= (3, 7): + block_on_close: bool + if sys.version_info >= (3, 6): + def collect_children(self, *, blocking: bool = ...) -> None: ... # undocumented + else: + def collect_children(self) -> None: ... # undocumented + def handle_timeout(self) -> None: ... # undocumented + if sys.version_info >= (3, 3): + def service_actions(self) -> None: ... # undocumented + def process_request(self, request: bytes, + client_address: Tuple[str, int]) -> None: ... + if sys.version_info >= (3, 6): + def server_close(self) -> None: ... class ThreadingMixIn: daemon_threads: bool @@ -92,8 +93,9 @@ class ThreadingMixIn: if sys.version_info >= (3, 6): def server_close(self) -> None: ... -class ForkingTCPServer(ForkingMixIn, TCPServer): ... -class ForkingUDPServer(ForkingMixIn, UDPServer): ... +if sys.platform != "win32": + class ForkingTCPServer(ForkingMixIn, TCPServer): ... + class ForkingUDPServer(ForkingMixIn, UDPServer): ... class ThreadingTCPServer(ThreadingMixIn, TCPServer): ... class ThreadingUDPServer(ThreadingMixIn, UDPServer): ... if sys.platform != 'win32': @@ -118,9 +120,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/python/helpers/typeshed/stdlib/2/__builtin__.pyi b/python/helpers/typeshed/stdlib/2/__builtin__.pyi index 14b8f5cdd9da..13921746c9fa 100644 --- a/python/helpers/typeshed/stdlib/2/__builtin__.pyi +++ b/python/helpers/typeshed/stdlib/2/__builtin__.pyi @@ -9,8 +9,12 @@ from typing import ( ItemsView, KeysView, ValuesView, ByteString, Optional, AnyStr, Type, Text, Protocol, ) -from abc import abstractmethod, ABCMeta +from abc import ABCMeta from ast import mod, AST +from io import ( + _OpenBinaryMode, _OpenTextMode, _OpenBinaryModeUpdating, _OpenBinaryModeWriting, _OpenBinaryModeReading, + TextIOWrapper, FileIO, BufferedRandom, BufferedReader, BufferedWriter +) from types import TracebackType, CodeType import sys @@ -344,6 +348,9 @@ class unicode(basestring, Sequence[unicode]): _str_base = basestring +class _FormatMapMapping(Protocol): + def __getitem__(self, __key: str) -> Any: ... + class str(Sequence[str], _str_base): def __init__(self, o: object = ...) -> None: ... @@ -931,6 +938,12 @@ def next(__i: Iterator[_T]) -> _T: ... def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(__number: Union[int, _SupportsIndex]) -> str: ... + + + + + + def open(name: Union[unicode, int], mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... def ord(__c: Union[Text, bytes]) -> int: ... @@ -940,12 +953,22 @@ class _Writer(Protocol): # This is only available after from __future__ import print_function. def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ... +_E = TypeVar("_E", contravariant=True) +_M = TypeVar("_M", contravariant=True) +class _SupportsPow2(Protocol[_E, _T_co]): + def __pow__(self, __other: _E) -> _T_co: ... +class _SupportsPow3(Protocol[_E, _M, _T_co]): + def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ... @overload def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative @overload def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... +@overload +def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... +@overload +def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M) -> _T_co: ... def quit(code: object = ...) -> NoReturn: ... def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... def raw_input(__prompt: Any = ...) -> str: ... @@ -978,6 +1001,7 @@ def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ... def sum(__iterable: Iterable[_T], __start: _S) -> Union[_T, _S]: ... def unichr(__i: int) -> unicode: ... def vars(__object: Any = ...) -> Dict[str, Any]: ... + @overload def zip(__iter1: Iterable[_T1]) -> List[Tuple[_T1]]: ... @overload @@ -1056,10 +1080,10 @@ class ReferenceError(_StandardError): ... class RuntimeError(_StandardError): ... class SyntaxError(_StandardError): msg: str - lineno: int + lineno: Optional[int] offset: Optional[int] text: Optional[str] - filename: str + filename: Optional[str] class SystemError(_StandardError): ... class TypeError(_StandardError): ... class ValueError(_StandardError): ... diff --git a/python/helpers/typeshed/stdlib/2/builtins.pyi b/python/helpers/typeshed/stdlib/2/builtins.pyi index 14b8f5cdd9da..13921746c9fa 100644 --- a/python/helpers/typeshed/stdlib/2/builtins.pyi +++ b/python/helpers/typeshed/stdlib/2/builtins.pyi @@ -9,8 +9,12 @@ from typing import ( ItemsView, KeysView, ValuesView, ByteString, Optional, AnyStr, Type, Text, Protocol, ) -from abc import abstractmethod, ABCMeta +from abc import ABCMeta from ast import mod, AST +from io import ( + _OpenBinaryMode, _OpenTextMode, _OpenBinaryModeUpdating, _OpenBinaryModeWriting, _OpenBinaryModeReading, + TextIOWrapper, FileIO, BufferedRandom, BufferedReader, BufferedWriter +) from types import TracebackType, CodeType import sys @@ -344,6 +348,9 @@ class unicode(basestring, Sequence[unicode]): _str_base = basestring +class _FormatMapMapping(Protocol): + def __getitem__(self, __key: str) -> Any: ... + class str(Sequence[str], _str_base): def __init__(self, o: object = ...) -> None: ... @@ -931,6 +938,12 @@ def next(__i: Iterator[_T]) -> _T: ... def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(__number: Union[int, _SupportsIndex]) -> str: ... + + + + + + def open(name: Union[unicode, int], mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... def ord(__c: Union[Text, bytes]) -> int: ... @@ -940,12 +953,22 @@ class _Writer(Protocol): # This is only available after from __future__ import print_function. def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ... +_E = TypeVar("_E", contravariant=True) +_M = TypeVar("_M", contravariant=True) +class _SupportsPow2(Protocol[_E, _T_co]): + def __pow__(self, __other: _E) -> _T_co: ... +class _SupportsPow3(Protocol[_E, _M, _T_co]): + def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ... @overload def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative @overload def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... +@overload +def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... +@overload +def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M) -> _T_co: ... def quit(code: object = ...) -> NoReturn: ... def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... def raw_input(__prompt: Any = ...) -> str: ... @@ -978,6 +1001,7 @@ def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ... def sum(__iterable: Iterable[_T], __start: _S) -> Union[_T, _S]: ... def unichr(__i: int) -> unicode: ... def vars(__object: Any = ...) -> Dict[str, Any]: ... + @overload def zip(__iter1: Iterable[_T1]) -> List[Tuple[_T1]]: ... @overload @@ -1056,10 +1080,10 @@ class ReferenceError(_StandardError): ... class RuntimeError(_StandardError): ... class SyntaxError(_StandardError): msg: str - lineno: int + lineno: Optional[int] offset: Optional[int] text: Optional[str] - filename: str + filename: Optional[str] class SystemError(_StandardError): ... class TypeError(_StandardError): ... class ValueError(_StandardError): ... diff --git a/python/helpers/typeshed/stdlib/2/io.pyi b/python/helpers/typeshed/stdlib/2/io.pyi index 1ab6b9069505..c4622b135b9b 100644 --- a/python/helpers/typeshed/stdlib/2/io.pyi +++ b/python/helpers/typeshed/stdlib/2/io.pyi @@ -5,6 +5,7 @@ # Only a subset of functionality is included. from typing import List, BinaryIO, TextIO, IO, overload, Iterator, Iterable, Any, Union, Optional +from typing_extensions import Literal import _io from _io import BlockingIOError as BlockingIOError @@ -21,6 +22,27 @@ from _io import TextIOWrapper as TextIOWrapper from _io import UnsupportedOperation as UnsupportedOperation from _io import open as open +_OpenTextMode = Literal[ + 'r', 'r+', '+r', 'rt', 'tr', 'rt+', 'r+t', '+rt', 'tr+', 't+r', '+tr', + 'w', 'w+', '+w', 'wt', 'tw', 'wt+', 'w+t', '+wt', 'tw+', 't+w', '+tw', + 'a', 'a+', '+a', 'at', 'ta', 'at+', 'a+t', '+at', 'ta+', 't+a', '+ta', + 'U', 'rU', 'Ur', 'rtU', 'rUt', 'Urt', 'trU', 'tUr', 'Utr', +] +_OpenBinaryModeUpdating = Literal[ + 'rb+', 'r+b', '+rb', 'br+', 'b+r', '+br', + 'wb+', 'w+b', '+wb', 'bw+', 'b+w', '+bw', + 'ab+', 'a+b', '+ab', 'ba+', 'b+a', '+ba', +] +_OpenBinaryModeWriting = Literal[ + 'wb', 'bw', + 'ab', 'ba', +] +_OpenBinaryModeReading = Literal[ + 'rb', 'br', + 'rbU', 'rUb', 'Urb', 'brU', 'bUr', 'Ubr', +] +_OpenBinaryMode = Union[_OpenBinaryModeUpdating, _OpenBinaryModeReading, _OpenBinaryModeWriting] + def _OpenWrapper(file: Union[str, unicode, int], mode: unicode = ..., buffering: int = ..., encoding: unicode = ..., errors: unicode = ..., newline: unicode = ..., diff --git a/python/helpers/typeshed/stdlib/2/multiprocessing/pool.pyi b/python/helpers/typeshed/stdlib/2/multiprocessing/pool.pyi index 4001a5a2be77..014efd452b7a 100644 --- a/python/helpers/typeshed/stdlib/2/multiprocessing/pool.pyi +++ b/python/helpers/typeshed/stdlib/2/multiprocessing/pool.pyi @@ -1,7 +1,4 @@ -from typing import ( - Any, Callable, ContextManager, Iterable, Optional, Dict, List, - TypeVar, Iterator, -) +from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, TypeVar _T = TypeVar('_T', bound=Pool) @@ -17,7 +14,7 @@ class IMapIterator(Iterator[Any]): class IMapUnorderedIterator(IMapIterator): ... -class Pool(ContextManager[Pool]): +class Pool(object): def __init__(self, processes: Optional[int] = ..., initializer: Optional[Callable[..., None]] = ..., initargs: Iterable[Any] = ..., @@ -50,10 +47,8 @@ class Pool(ContextManager[Pool]): def close(self) -> None: ... def terminate(self) -> None: ... def join(self) -> None: ... - def __enter__(self: _T) -> _T: ... - -class ThreadPool(Pool, ContextManager[ThreadPool]): +class ThreadPool(Pool): def __init__(self, processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/os/__init__.pyi b/python/helpers/typeshed/stdlib/2/os/__init__.pyi index 7041e1fbe48e..8e66b4849142 100644 --- a/python/helpers/typeshed/stdlib/2/os/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2/os/__init__.pyi @@ -291,7 +291,7 @@ if sys.platform != 'win32': # Unix only def fork() -> int: ... def forkpty() -> Tuple[int, int]: ... # some flavors of Unix - def killpg(pgid: int, sig: int) -> None: ... + def killpg(__pgid: int, __signal: int) -> None: ... def nice(increment: int) -> int: ... def plock(op: int) -> None: ... # ???op is int? diff --git a/python/helpers/typeshed/stdlib/2/os/path.pyi b/python/helpers/typeshed/stdlib/2/os/path.pyi index 73c14de7052d..f1496d13a605 100644 --- a/python/helpers/typeshed/stdlib/2/os/path.pyi +++ b/python/helpers/typeshed/stdlib/2/os/path.pyi @@ -5,6 +5,7 @@ import os import sys from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional +from genericpath import exists as exists _T = TypeVar('_T') @@ -100,10 +101,6 @@ elif sys.version_info >= (3, 5): # So, fall back to Any def commonprefix(m: Sequence[_PathType]) -> Any: ... -if sys.version_info >= (3, 3): - def exists(path: Union[_PathType, int]) -> bool: ... -else: - def exists(path: _PathType) -> bool: ... def lexists(path: _PathType) -> bool: ... # These return float if os.stat_float_times() == True, @@ -170,8 +167,8 @@ else: def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -if sys.platform == 'win32': - def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated +if sys.version_info < (3, 7) and sys.platform == 'win32': + def splitunc(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated if sys.version_info < (3,): def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/os2emxpath.pyi b/python/helpers/typeshed/stdlib/2/os2emxpath.pyi index 73c14de7052d..f1496d13a605 100644 --- a/python/helpers/typeshed/stdlib/2/os2emxpath.pyi +++ b/python/helpers/typeshed/stdlib/2/os2emxpath.pyi @@ -5,6 +5,7 @@ import os import sys from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional +from genericpath import exists as exists _T = TypeVar('_T') @@ -100,10 +101,6 @@ elif sys.version_info >= (3, 5): # So, fall back to Any def commonprefix(m: Sequence[_PathType]) -> Any: ... -if sys.version_info >= (3, 3): - def exists(path: Union[_PathType, int]) -> bool: ... -else: - def exists(path: _PathType) -> bool: ... def lexists(path: _PathType) -> bool: ... # These return float if os.stat_float_times() == True, @@ -170,8 +167,8 @@ else: def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -if sys.platform == 'win32': - def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated +if sys.version_info < (3, 7) and sys.platform == 'win32': + def splitunc(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated if sys.version_info < (3,): def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/subprocess.pyi b/python/helpers/typeshed/stdlib/2/subprocess.pyi index d9205b089ca1..4c2f2d8c2f6a 100644 --- a/python/helpers/typeshed/stdlib/2/subprocess.pyi +++ b/python/helpers/typeshed/stdlib/2/subprocess.pyi @@ -98,7 +98,7 @@ class Popen(Generic[_T]): startupinfo: Optional[Any] = ..., creationflags: int = ...) -> Popen[bytes]: ... - def poll(self) -> int: ... + def poll(self) -> Optional[int]: ... def wait(self) -> int: ... # morally: -> Tuple[Optional[bytes], Optional[bytes]] def communicate(self, input: Optional[_TXT] = ...) -> Tuple[bytes, bytes]: ... diff --git a/python/helpers/typeshed/stdlib/2/typing.pyi b/python/helpers/typeshed/stdlib/2/typing.pyi index bea5ba985835..55b91845e0a7 100644 --- a/python/helpers/typeshed/stdlib/2/typing.pyi +++ b/python/helpers/typeshed/stdlib/2/typing.pyi @@ -9,12 +9,22 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986 overload = object() Any = object() -TypeVar = object() + +class TypeVar: + __name__: str + __bound__: Optional[Type[Any]] + __constraints__: Tuple[Type[Any], ...] + __covariant__: bool + __contravariant__: bool + def __init__(self, name: str, *constraints: Type[Any], bound: Optional[Type[Any]] = ..., covariant: bool = ..., contravariant: bool = ...) -> None: ... + _promote = object() class _SpecialForm(object): def __getitem__(self, typeargs: Any) -> object: ... +Union: _SpecialForm = ... +Optional: _SpecialForm = ... Tuple: _SpecialForm = ... Generic: _SpecialForm = ... Protocol: _SpecialForm = ... @@ -53,20 +63,17 @@ 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) +List = _Alias() +Dict = _Alias() +DefaultDict = _Alias() +Set = _Alias() +FrozenSet = _Alias() +Counter = _Alias() +Deque = _Alias() # Predefined type variables. AnyStr = TypeVar('AnyStr', str, unicode) diff --git a/python/helpers/typeshed/stdlib/2and3/_codecs.pyi b/python/helpers/typeshed/stdlib/2and3/_codecs.pyi index db622746dd6e..d933d0917439 100644 --- a/python/helpers/typeshed/stdlib/2and3/_codecs.pyi +++ b/python/helpers/typeshed/stdlib/2and3/_codecs.pyi @@ -68,9 +68,10 @@ def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int if sys.platform == 'win32': def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... - def mbcs_encode(str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... + def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... if sys.version_info >= (3, 0): + def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... + def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... + if sys.version_info >= (3, 6): def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... - def code_page_decode(codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... - def oem_encode(str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... - def code_page_encode(code_page: int, str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... + def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/_dummy_threading.pyi b/python/helpers/typeshed/stdlib/2and3/_dummy_threading.pyi index bd67d850fd86..ae8997251322 100644 --- a/python/helpers/typeshed/stdlib/2and3/_dummy_threading.pyi +++ b/python/helpers/typeshed/stdlib/2and3/_dummy_threading.pyi @@ -1,6 +1,6 @@ from typing import ( - Any, Callable, Iterable, List, Mapping, Optional, Tuple, Type, Union, + Any, Callable, Iterable, List, Mapping, Optional, Text, Tuple, Type, Union, TypeVar, ) from types import FrameType, TracebackType @@ -12,7 +12,6 @@ _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] _PF = Callable[[FrameType, str, Any], None] _T = TypeVar('_T') - __all__: List[str] def active_count() -> int: ... @@ -63,19 +62,20 @@ class Thread: else: def __init__(self, group: None = ..., target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., + name: Optional[Text] = ..., args: Iterable[Any] = ..., - kwargs: Mapping[str, Any] = ...) -> None: ... + kwargs: Mapping[Text, Any] = ...) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... - def setName(self, name: str) -> None: ... + def setName(self, name: Text) -> None: ... if sys.version_info >= (3, 8): @property def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... - def isAlive(self) -> bool: ... + if sys.version_info < (3, 9): + def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... def setDaemon(self, daemonic: bool) -> None: ... @@ -143,19 +143,12 @@ class Semaphore: def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... else: def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - -class BoundedSemaphore: - def __init__(self, value: int = ...) -> None: ... - def __enter__(self) -> bool: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[TracebackType]) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... + if sys.version_info >= (3, 9): + def release(self, n: int = ...) -> None: ... else: - def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... + def release(self) -> None: ... + +class BoundedSemaphore(Semaphore): ... class Event: diff --git a/python/helpers/typeshed/stdlib/2and3/argparse.pyi b/python/helpers/typeshed/stdlib/2and3/argparse.pyi index 769cbb0d3d7e..c782b7aea794 100644 --- a/python/helpers/typeshed/stdlib/2and3/argparse.pyi +++ b/python/helpers/typeshed/stdlib/2and3/argparse.pyi @@ -96,7 +96,22 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): _optionals: _ArgumentGroup _subparsers: Optional[_ArgumentGroup] - if sys.version_info >= (3, 5): + if sys.version_info >= (3, 9): + def __init__(self, + prog: Optional[str] = ..., + usage: Optional[str] = ..., + description: Optional[str] = ..., + epilog: Optional[str] = ..., + parents: Sequence[ArgumentParser] = ..., + formatter_class: _FormatterClass = ..., + prefix_chars: str = ..., + fromfile_prefix_chars: Optional[str] = ..., + argument_default: Optional[str] = ..., + conflict_handler: str = ..., + add_help: bool = ..., + allow_abbrev: bool = ..., + exit_on_error: bool = ...) -> None: ... + elif sys.version_info >= (3, 5): def __init__(self, prog: Optional[str] = ..., usage: Optional[str] = ..., @@ -265,6 +280,8 @@ class Action(_AttributeHolder): def __call__(self, parser: ArgumentParser, namespace: Namespace, values: Union[Text, Sequence[Any], None], option_string: Optional[Text] = ...) -> None: ... + if sys.version_info >= (3, 9): + def format_usage(self) -> str: ... class Namespace(_AttributeHolder): def __init__(self, **kwargs: Any) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/array.pyi b/python/helpers/typeshed/stdlib/2and3/array.pyi index 4f0b8a2cb8ce..5b9c1256e01f 100644 --- a/python/helpers/typeshed/stdlib/2and3/array.pyi +++ b/python/helpers/typeshed/stdlib/2and3/array.pyi @@ -5,6 +5,12 @@ import sys from typing import (Any, BinaryIO, Generic, Iterable, Iterator, List, MutableSequence, overload, Text, Tuple, TypeVar, Union) +from typing_extensions import Literal + +_IntTypeCode = Literal['b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q'] +_FloatTypeCode = Literal['f', 'd'] +_UnicodeTypeCode = Literal['u'] +_TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode] _T = TypeVar('_T', int, float, Text) @@ -12,8 +18,18 @@ if sys.version_info >= (3,): typecodes: str class array(MutableSequence[_T], Generic[_T]): - typecode: str + typecode: _TypeCode itemsize: int + @overload + def __init__(self: array[int], typecode: _IntTypeCode, + __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + @overload + def __init__(self: array[float], typecode: _FloatTypeCode, + __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + @overload + def __init__(self: array[Text], typecode: _UnicodeTypeCode, + __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + @overload def __init__(self, typecode: str, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... def append(self, __v: _T) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/asyncore.pyi b/python/helpers/typeshed/stdlib/2and3/asyncore.pyi index b93bd6c58886..3045e6f192c9 100644 --- a/python/helpers/typeshed/stdlib/2and3/asyncore.pyi +++ b/python/helpers/typeshed/stdlib/2and3/asyncore.pyi @@ -1,18 +1,10 @@ -from typing import Tuple, Union, Optional, Any, Dict, overload +from typing import Tuple, Union, Any, Dict, overload -import os -import select import sys -import time -import warnings from socket import SocketType from typing import Optional from _types import FileDescriptorLike -from errno import (EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, - ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, - EPIPE, EAGAIN, errorcode) - # cyclic dependence with asynchat _maptype = Dict[int, Any] @@ -121,26 +113,25 @@ class dispatcher_with_send(dispatcher): def compact_traceback() -> Tuple[Tuple[str, str, str], type, type, str]: ... def close_all(map: Optional[_maptype] = ..., ignore_all: bool = ...) -> None: ... -# if os.name == 'posix': -# import fcntl -class file_wrapper: - fd: int +if sys.platform != "win32": + class file_wrapper: + fd: int - def __init__(self, fd: int) -> None: ... - def recv(self, bufsize: int, flags: int = ...) -> bytes: ... - def send(self, data: bytes, flags: int = ...) -> int: ... + def __init__(self, fd: int) -> None: ... + def recv(self, bufsize: int, flags: int = ...) -> bytes: ... + def send(self, data: bytes, flags: int = ...) -> int: ... - @overload - def getsockopt(self, level: int, optname: int, buflen: None = ...) -> int: ... - @overload - def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... + @overload + def getsockopt(self, level: int, optname: int, buflen: None = ...) -> int: ... + @overload + def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... - def read(self, bufsize: int, flags: int = ...) -> bytes: ... - def write(self, data: bytes, flags: int = ...) -> int: ... + def read(self, bufsize: int, flags: int = ...) -> bytes: ... + def write(self, data: bytes, flags: int = ...) -> int: ... - def close(self) -> None: ... - def fileno(self) -> int: ... + def close(self) -> None: ... + def fileno(self) -> int: ... -class file_dispatcher(dispatcher): - def __init__(self, fd: FileDescriptorLike, map: Optional[_maptype] = ...) -> None: ... - def set_file(self, fd: int) -> None: ... + class file_dispatcher(dispatcher): + def __init__(self, fd: FileDescriptorLike, map: Optional[_maptype] = ...) -> None: ... + def set_file(self, fd: int) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/bdb.pyi b/python/helpers/typeshed/stdlib/2and3/bdb.pyi index df9d08c21fed..1f7f7f335b16 100644 --- a/python/helpers/typeshed/stdlib/2and3/bdb.pyi +++ b/python/helpers/typeshed/stdlib/2and3/bdb.pyi @@ -23,7 +23,7 @@ class Bdb: returnframe: Optional[FrameType] stoplineno: int - def __init__(self, skip: Iterable[str] = ...) -> None: ... + def __init__(self, skip: Optional[Iterable[str]] = ...) -> None: ... def canonic(self, filename: str) -> str: ... def reset(self) -> None: ... def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ... @@ -64,7 +64,7 @@ class Bdb: ) -> None: ... def runeval(self, expr: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ... def runctx(self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]]) -> None: ... - def runcall(self, func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... + def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... class Breakpoint: diff --git a/python/helpers/typeshed/stdlib/2and3/ctypes/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/ctypes/__init__.pyi index d07efd65e8f8..d313e8463b0c 100644 --- a/python/helpers/typeshed/stdlib/2and3/ctypes/__init__.pyi +++ b/python/helpers/typeshed/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 = ..., @@ -183,7 +183,7 @@ def sizeof(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ... def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ... if sys.platform == 'win32': def WinError(code: Optional[int] = ..., - desc: Optional[str] = ...) -> WindowsError: ... + descr: Optional[str] = ...) -> OSError: ... def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ... class _SimpleCData(Generic[_T], _CData): diff --git a/python/helpers/typeshed/stdlib/2and3/datetime.pyi b/python/helpers/typeshed/stdlib/2and3/datetime.pyi index e80bb83f8172..e0ae3fa16aa2 100644 --- a/python/helpers/typeshed/stdlib/2and3/datetime.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/2and3/decimal.pyi b/python/helpers/typeshed/stdlib/2and3/decimal.pyi index 91271981c4e0..799894fc1c43 100644 --- a/python/helpers/typeshed/stdlib/2and3/decimal.pyi +++ b/python/helpers/typeshed/stdlib/2and3/decimal.pyi @@ -35,7 +35,8 @@ if sys.version_info >= (3,): MIN_ETINY: int class DecimalException(ArithmeticError): - def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... + if sys.version_info < (3,): + def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... class Clamped(DecimalException): ... @@ -64,14 +65,14 @@ class Underflow(Inexact, Rounded, Subnormal): ... if sys.version_info >= (3,): class FloatOperation(DecimalException, TypeError): ... -def setcontext(context: Context) -> None: ... +def setcontext(__context: Context) -> None: ... def getcontext() -> Context: ... def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ... class Decimal(object): def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ... @classmethod - def from_float(cls, f: float) -> Decimal: ... + def from_float(cls, __f: float) -> Decimal: ... if sys.version_info >= (3,): def __bool__(self) -> bool: ... else: @@ -83,7 +84,7 @@ class Decimal(object): def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __hash__(self) -> int: ... def as_tuple(self) -> DecimalTuple: ... - if sys.version_info >= (3,): + if sys.version_info >= (3, 6): def as_integer_ratio(self) -> Tuple[int, int]: ... def to_eng_string(self, context: Optional[Context] = ...) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2and3/difflib.pyi b/python/helpers/typeshed/stdlib/2and3/difflib.pyi index 5b285e070402..110abf7a3bf2 100644 --- a/python/helpers/typeshed/stdlib/2and3/difflib.pyi +++ b/python/helpers/typeshed/stdlib/2and3/difflib.pyi @@ -3,7 +3,7 @@ import sys from typing import ( Any, TypeVar, Callable, Iterable, Iterator, List, NamedTuple, Sequence, Tuple, - Generic, Optional, Text, Union, AnyStr + Generic, Optional, Text, Union, AnyStr, overload ) _T = TypeVar('_T') @@ -28,8 +28,10 @@ class SequenceMatcher(Generic[_T]): def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ... def set_seq1(self, a: Sequence[_T]) -> None: ... def set_seq2(self, b: Sequence[_T]) -> None: ... - def find_longest_match(self, alo: int, ahi: int, blo: int, - bhi: int) -> Match: ... + if sys.version_info >= (3, 9): + def find_longest_match(self, alo: int = ..., ahi: Optional[int] = ..., blo: int = ..., bhi: Optional[int] = ...) -> Match: ... + else: + def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ... def get_matching_blocks(self) -> List[Match]: ... def get_opcodes(self) -> List[Tuple[str, int, int, int, int]]: ... def get_grouped_opcodes(self, n: int = ... @@ -38,6 +40,11 @@ class SequenceMatcher(Generic[_T]): def quick_ratio(self) -> float: ... def real_quick_ratio(self) -> float: ... +# mypy thinks the signatures of the overloads overlap, but the types still work fine +@overload +def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], # type: ignore + n: int = ..., cutoff: float = ...) -> List[AnyStr]: ... +@overload def get_close_matches(word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = ..., cutoff: float = ...) -> List[Sequence[_T]]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/distutils/command/config.pyi b/python/helpers/typeshed/stdlib/2and3/distutils/command/config.pyi index e69de29bb2d1..94e97355ea7c 100644 --- a/python/helpers/typeshed/stdlib/2and3/distutils/command/config.pyi +++ b/python/helpers/typeshed/stdlib/2and3/distutils/command/config.pyi @@ -0,0 +1,87 @@ +from distutils import log as log +from distutils.ccompiler import CCompiler +from distutils.core import Command as Command +from distutils.errors import DistutilsExecError as DistutilsExecError +from distutils.sysconfig import customize_compiler as customize_compiler +from typing import Any, Dict, List, Match, Optional, Pattern, Sequence, Tuple, Union + +LANG_EXT: Dict[str, str] + +class config(Command): + description: str = ... + # Tuple is full name, short name, description + user_options: Sequence[Tuple[str, Optional[str], str]] = ... + compiler: Optional[Union[str, CCompiler]] = ... + cc: Optional[str] = ... + include_dirs: Optional[Sequence[str]] = ... + libraries: Optional[Sequence[str]] = ... + library_dirs: Optional[Sequence[str]] = ... + noisy: int = ... + dump_source: int = ... + temp_files: Sequence[str] = ... + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def try_cpp( + self, + body: Optional[str] = ..., + headers: Optional[Sequence[str]] = ..., + include_dirs: Optional[Sequence[str]] = ..., + lang: str = ..., + ) -> bool: ... + def search_cpp( + self, + pattern: Union[Pattern[str], str], + body: Optional[str] = ..., + headers: Optional[Sequence[str]] = ..., + include_dirs: Optional[Sequence[str]] = ..., + lang: str = ..., + ) -> bool: ... + def try_compile( + self, body: str, headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., lang: str = ... + ) -> bool: ... + def try_link( + self, + body: str, + headers: Optional[Sequence[str]] = ..., + include_dirs: Optional[Sequence[str]] = ..., + libraries: Optional[Sequence[str]] = ..., + library_dirs: Optional[Sequence[str]] = ..., + lang: str = ..., + ) -> bool: ... + def try_run( + self, + body: str, + headers: Optional[Sequence[str]] = ..., + include_dirs: Optional[Sequence[str]] = ..., + libraries: Optional[Sequence[str]] = ..., + library_dirs: Optional[Sequence[str]] = ..., + lang: str = ..., + ) -> bool: ... + def check_func( + self, + func: str, + headers: Optional[Sequence[str]] = ..., + include_dirs: Optional[Sequence[str]] = ..., + libraries: Optional[Sequence[str]] = ..., + library_dirs: Optional[Sequence[str]] = ..., + decl: int = ..., + call: int = ..., + ) -> bool: ... + def check_lib( + self, + library: str, + library_dirs: Optional[Sequence[str]] = ..., + headers: Optional[Sequence[str]] = ..., + include_dirs: Optional[Sequence[str]] = ..., + other_libraries: List[str] = ..., + ) -> bool: ... + def check_header( + self, + header: str, + include_dirs: Optional[Sequence[str]] = ..., + library_dirs: Optional[Sequence[str]] = ..., + lang: str = ..., + ) -> bool: ... + +def dump_file(filename: str, head: Optional[str] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/genericpath.pyi b/python/helpers/typeshed/stdlib/2and3/genericpath.pyi index e0b1c6de208c..267900c90e5d 100644 --- a/python/helpers/typeshed/stdlib/2and3/genericpath.pyi +++ b/python/helpers/typeshed/stdlib/2and3/genericpath.pyi @@ -1,12 +1,15 @@ -from typing import Sequence, AnyStr, Text +from typing import Sequence, AnyStr, Text, Union import sys if sys.version_info >= (3, 0): def commonprefix(m: Sequence[str]) -> str: ... else: def commonprefix(m: Sequence[AnyStr]) -> AnyStr: ... - -def exists(path: Text) -> bool: ... +if sys.version_info >= (3, 6): + from builtins import _PathLike + def exists(path: Union[AnyStr, _PathLike[AnyStr]]) -> bool: ... +else: + def exists(path: Text) -> bool: ... def isfile(path: Text) -> bool: ... def isdir(s: Text) -> bool: ... def getsize(filename: Text) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi index e44e36fd2a69..a38edcc7ed43 100644 --- a/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi @@ -29,6 +29,7 @@ raiseExceptions: bool logThreads: bool logMultiprocessing: bool logProcesses: bool +_srcfile: Optional[str] def currentframe() -> FrameType: ... diff --git a/python/helpers/typeshed/stdlib/2and3/ntpath.pyi b/python/helpers/typeshed/stdlib/2and3/ntpath.pyi index 73c14de7052d..f1496d13a605 100644 --- a/python/helpers/typeshed/stdlib/2and3/ntpath.pyi +++ b/python/helpers/typeshed/stdlib/2and3/ntpath.pyi @@ -5,6 +5,7 @@ import os import sys from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional +from genericpath import exists as exists _T = TypeVar('_T') @@ -100,10 +101,6 @@ elif sys.version_info >= (3, 5): # So, fall back to Any def commonprefix(m: Sequence[_PathType]) -> Any: ... -if sys.version_info >= (3, 3): - def exists(path: Union[_PathType, int]) -> bool: ... -else: - def exists(path: _PathType) -> bool: ... def lexists(path: _PathType) -> bool: ... # These return float if os.stat_float_times() == True, @@ -170,8 +167,8 @@ else: def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -if sys.platform == 'win32': - def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated +if sys.version_info < (3, 7) and sys.platform == 'win32': + def splitunc(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated if sys.version_info < (3,): def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/opcode.pyi b/python/helpers/typeshed/stdlib/2and3/opcode.pyi index 281a6a7264e3..b219670f5dec 100644 --- a/python/helpers/typeshed/stdlib/2and3/opcode.pyi +++ b/python/helpers/typeshed/stdlib/2and3/opcode.pyi @@ -17,9 +17,9 @@ HAVE_ARGUMENT: int EXTENDED_ARG: int if sys.version_info >= (3, 8): - def stack_effect(opcode: int, oparg: Optional[int] = ..., *, jump: Optional[bool] = ...) -> int: ... + def stack_effect(__opcode: int, __oparg: Optional[int] = ..., *, jump: Optional[bool] = ...) -> int: ... elif sys.version_info >= (3, 4): - def stack_effect(opcode: int, oparg: Optional[int] = ...) -> int: ... + def stack_effect(__opcode: int, __oparg: Optional[int] = ...) -> int: ... if sys.version_info >= (3, 6): hasnargs: List[int] diff --git a/python/helpers/typeshed/stdlib/2and3/parser.pyi b/python/helpers/typeshed/stdlib/2and3/parser.pyi index 85c19ecc4846..d6ed07ba8904 100644 --- a/python/helpers/typeshed/stdlib/2and3/parser.pyi +++ b/python/helpers/typeshed/stdlib/2and3/parser.pyi @@ -22,7 +22,7 @@ def issuite(st: STType) -> bool: ... class ParserError(Exception): ... class STType: - def compile(self, filename: _Path) -> CodeType: ... + def compile(self, filename: _Path = ...) -> CodeType: ... def isexpr(self) -> bool: ... def issuite(self) -> bool: ... def tolist(self, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/plistlib.pyi b/python/helpers/typeshed/stdlib/2and3/plistlib.pyi index 62668821bfbd..4db0730a6375 100644 --- a/python/helpers/typeshed/stdlib/2and3/plistlib.pyi +++ b/python/helpers/typeshed/stdlib/2and3/plistlib.pyi @@ -22,29 +22,41 @@ if sys.version_info >= (3,): else: _Path = Union[str, unicode] -if sys.version_info >= (3, 4): +if sys.version_info >= (3, 9): + @overload + def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ...) -> DictT[str, Any]: ... + @overload + def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., dict_type: Type[_D]) -> _D: ... + @overload + def loads(value: bytes, *, fmt: Optional[PlistFormat] = ...) -> DictT[str, Any]: ... + @overload + def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., dict_type: Type[_D]) -> _D: ... +elif sys.version_info >= (3, 4): @overload def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., use_builtin_types: bool = ...) -> DictT[str, Any]: ... @overload def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., - use_builtin_types: bool = ..., dict_type: Type[_D] = ...) -> _D: ... + use_builtin_types: bool = ..., dict_type: Type[_D]) -> _D: ... @overload def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., use_builtin_types: bool = ...) -> DictT[str, Any]: ... @overload def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., - use_builtin_types: bool = ..., dict_type: Type[_D] = ...) -> _D: ... + use_builtin_types: bool = ..., dict_type: Type[_D]) -> _D: ... + +if sys.version_info >= (3, 4): def dump(value: Mapping[str, Any], fp: IO[bytes], *, fmt: PlistFormat = ..., sort_keys: bool = ..., skipkeys: bool = ...) -> None: ... def dumps(value: Mapping[str, Any], *, fmt: PlistFormat = ..., skipkeys: bool = ..., sort_keys: bool = ...) -> bytes: ... -def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> DictT[str, Any]: ... -def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... -def readPlistFromBytes(data: bytes) -> DictT[str, Any]: ... -def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... +if sys.version_info < (3, 9): + def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> DictT[str, Any]: ... + def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... + def readPlistFromBytes(data: bytes) -> DictT[str, Any]: ... + def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... if sys.version_info < (3,): def readPlistFromResource(path: _Path, restype: str = ..., resid: int = ...) -> DictT[str, Any]: ... @@ -60,9 +72,10 @@ if sys.version_info < (3, 7): def __setattr__(self, attr: str, value: Any) -> None: ... def __delattr__(self, attr: str) -> None: ... -class Data: - data: bytes - def __init__(self, data: bytes) -> None: ... +if sys.version_info < (3, 9): + class Data: + data: bytes + def __init__(self, data: bytes) -> None: ... if sys.version_info >= (3, 8): class UID: diff --git a/python/helpers/typeshed/stdlib/2and3/posixpath.pyi b/python/helpers/typeshed/stdlib/2and3/posixpath.pyi index 73c14de7052d..f1496d13a605 100644 --- a/python/helpers/typeshed/stdlib/2and3/posixpath.pyi +++ b/python/helpers/typeshed/stdlib/2and3/posixpath.pyi @@ -5,6 +5,7 @@ import os import sys from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional +from genericpath import exists as exists _T = TypeVar('_T') @@ -100,10 +101,6 @@ elif sys.version_info >= (3, 5): # So, fall back to Any def commonprefix(m: Sequence[_PathType]) -> Any: ... -if sys.version_info >= (3, 3): - def exists(path: Union[_PathType, int]) -> bool: ... -else: - def exists(path: _PathType) -> bool: ... def lexists(path: _PathType) -> bool: ... # These return float if os.stat_float_times() == True, @@ -170,8 +167,8 @@ else: def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -if sys.platform == 'win32': - def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated +if sys.version_info < (3, 7) and sys.platform == 'win32': + def splitunc(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated if sys.version_info < (3,): def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/select.pyi b/python/helpers/typeshed/stdlib/2and3/select.pyi index 47cd117c2559..555816723f17 100644 --- a/python/helpers/typeshed/stdlib/2and3/select.pyi +++ b/python/helpers/typeshed/stdlib/2and3/select.pyi @@ -1,21 +1,22 @@ import sys -from typing import Any, Iterable, List, Optional, Protocol, Tuple, Type, Union +from typing import Any, Iterable, List, Optional, Tuple, Type from types import TracebackType from _types import FileDescriptorLike -PIPE_BUF: int -POLLERR: int -POLLHUP: int -POLLIN: int -POLLMSG: int -POLLNVAL: int -POLLOUT: int -POLLPRI: int -POLLRDBAND: int -POLLRDNORM: int -POLLWRBAND: int -POLLWRNORM: int +if sys.platform != "win32": + PIPE_BUF: int + POLLERR: int + POLLHUP: int + POLLIN: int + POLLMSG: int + POLLNVAL: int + POLLOUT: int + POLLPRI: int + POLLRDBAND: int + POLLRDNORM: int + POLLWRBAND: int + POLLWRNORM: int class poll: def __init__(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/socket.pyi b/python/helpers/typeshed/stdlib/2and3/socket.pyi index 2535cea3843d..89bb7876fdc3 100644 --- a/python/helpers/typeshed/stdlib/2and3/socket.pyi +++ b/python/helpers/typeshed/stdlib/2and3/socket.pyi @@ -322,9 +322,55 @@ if sys.platform == 'linux' and sys.version_info >= (3,): CAN_RAW_FD_FRAMES: int +if sys.platform == 'linux' and sys.version_info >= (3, 8): + CAN_BCM_SETTIMER: int + CAN_BCM_STARTTIMER: int + CAN_BCM_TX_COUNTEVT: int + CAN_BCM_TX_ANNOUNCE: int + CAN_BCM_TX_CP_CAN_ID: int + CAN_BCM_RX_FILTER_ID: int + CAN_BCM_RX_CHECK_DLC: int + CAN_BCM_RX_NO_AUTOTIMER: int + CAN_BCM_RX_ANNOUNCE_RESUME: int + CAN_BCM_TX_RESET_MULTI_IDX: int + CAN_BCM_RX_RTR_FRAME: int + CAN_BCM_CAN_FD_FRAME: int + if sys.platform == 'linux' and sys.version_info >= (3, 7): CAN_ISOTP: int +if sys.platform == 'linux' and sys.version_info >= (3, 9): + CAN_J1939: int + + J1939_MAX_UNICAST_ADDR: int + J1939_IDLE_ADDR: int + J1939_NO_ADDR: int + J1939_NO_NAME: int + J1939_PGN_REQUEST: int + J1939_PGN_ADDRESS_CLAIMED: int + J1939_PGN_ADDRESS_COMMANDED: int + J1939_PGN_PDU1_MAX: int + J1939_PGN_MAX: int + J1939_NO_PGN: int + + SO_J1939_FILTER: int + SO_J1939_PROMISC: int + SO_J1939_SEND_PRIO: int + SO_J1939_ERRQUEUE: int + + SCM_J1939_DEST_ADDR: int + SCM_J1939_DEST_NAME: int + SCM_J1939_PRIO: int + SCM_J1939_ERRQUEUE: int + + J1939_NLA_PAD: int + J1939_NLA_BYTES_ACKED: int + + J1939_EE_INFO_NONE: int + J1939_EE_INFO_TX_ABORT: int + + J1939_FILTER_MAX: int + if sys.platform == 'linux': AF_PACKET: AddressFamily PF_PACKET: int @@ -638,13 +684,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,16 +696,18 @@ 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]: ... - if sys.version_info >= (3, 3): + if sys.version_info >= (3, 3) and sys.platform != "win32": def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ... def recvmsg_into(self, __buffers: Iterable[_WriteBuffer], @@ -675,7 +721,7 @@ class socket: def sendto(self, data: bytes, address: _Address) -> int: ... @overload def sendto(self, data: bytes, flags: int, address: _Address) -> int: ... - if sys.version_info >= (3, 3): + if sys.version_info >= (3, 3) and sys.platform != "win32": def sendmsg(self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., @@ -713,7 +759,7 @@ if sys.version_info >= (3, 7): def create_connection(address: Tuple[Optional[str], int], timeout: Optional[float] = ..., - source_address: Tuple[Union[bytearray, bytes, Text], int] = ...) -> socket: ... + source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ...) -> socket: ... if sys.version_info >= (3, 8): def create_server(address: _Address, @@ -727,7 +773,7 @@ if sys.version_info >= (3, 8): def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... if sys.platform == 'win32' and sys.version_info >= (3, 3): - def fromshare(data: bytes) -> socket: ... + def fromshare(info: bytes) -> socket: ... # the 5th tuple item is an address # TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers @@ -771,7 +817,10 @@ if sys.version_info >= (3, 3): def getdefaulttimeout() -> Optional[float]: ... def setdefaulttimeout(timeout: Optional[float]) -> None: ... if sys.version_info >= (3, 3): - def sethostname(name: str) -> None: ... - def if_nameindex() -> List[Tuple[int, str]]: ... - def if_nametoindex(name: str) -> int: ... - def if_indextoname(index: int) -> str: ... + if sys.platform != "win32": + def sethostname(name: str) -> None: ... + # Windows added these in 3.8, but didn't have them before + if sys.platform != "win32" or sys.version_info >= (3, 8): + def if_nameindex() -> List[Tuple[int, str]]: ... + def if_nametoindex(name: str) -> int: ... + def if_indextoname(index: int) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2and3/ssl.pyi b/python/helpers/typeshed/stdlib/2and3/ssl.pyi index db295f02ea93..b0545d01e4b4 100644 --- a/python/helpers/typeshed/stdlib/2and3/ssl.pyi +++ b/python/helpers/typeshed/stdlib/2and3/ssl.pyi @@ -134,24 +134,38 @@ PROTOCOL_SSLv3: int PROTOCOL_TLSv1: int PROTOCOL_TLSv1_1: int PROTOCOL_TLSv1_2: int -if sys.version_info >= (3, 5): - PROTOCOL_TLS: int +PROTOCOL_TLS: int if sys.version_info >= (3, 6): PROTOCOL_TLS_CLIENT: int PROTOCOL_TLS_SERVER: int -OP_ALL: int -OP_NO_SSLv2: int -OP_NO_SSLv3: int -OP_NO_TLSv1: int -OP_NO_TLSv1_1: int -OP_NO_TLSv1_2: int -OP_CIPHER_SERVER_PREFERENCE: int -OP_SINGLE_DH_USE: int -OP_SINGLE_ECDH_USE: int -OP_NO_COMPRESSION: int if sys.version_info >= (3, 6): - OP_NO_TICKET: int + class Options(enum.IntFlag): + OP_ALL: int + OP_NO_SSLv2: int + OP_NO_SSLv3: int + OP_NO_TLSv1: int + OP_NO_TLSv1_1: int + OP_NO_TLSv1_2: int + OP_CIPHER_SERVER_PREFERENCE: int + OP_SINGLE_DH_USE: int + OP_SINGLE_ECDH_USE: int + OP_NO_COMPRESSION: int + OP_NO_TICKET: int + OP_ENABLE_MIDDLEBOX_COMPAT: int + if sys.version_info >= (3, 7): + OP_NO_RENEGOTIATION: int +else: + OP_ALL: int + OP_NO_SSLv2: int + OP_NO_SSLv3: int + OP_NO_TLSv1: int + OP_NO_TLSv1_1: int + OP_NO_TLSv1_2: int + OP_CIPHER_SERVER_PREFERENCE: int + OP_SINGLE_DH_USE: int + OP_SINGLE_ECDH_USE: int + OP_NO_COMPRESSION: int HAS_ALPN: int HAS_ECDH: bool @@ -249,7 +263,10 @@ if sys.version_info >= (3, 7): class SSLContext: check_hostname: bool - options: int + if sys.version_info >= (3, 6): + options: Options + else: + options: int if sys.version_info >= (3, 8): post_handshake_auth: bool @property diff --git a/python/helpers/typeshed/stdlib/2and3/tarfile.pyi b/python/helpers/typeshed/stdlib/2and3/tarfile.pyi index 98523fc44f64..1a64c59104f1 100644 --- a/python/helpers/typeshed/stdlib/2and3/tarfile.pyi +++ b/python/helpers/typeshed/stdlib/2and3/tarfile.pyi @@ -2,7 +2,7 @@ from typing import ( Callable, IO, Iterable, Iterator, List, Mapping, Optional, Type, - Union, + Union, Tuple, Dict, Set ) import os import sys @@ -15,23 +15,53 @@ elif sys.version_info >= (3,): else: _Path = Union[str, unicode] -ENCODING: str +# tar constants +NUL: bytes +BLOCKSIZE: int +RECORDSIZE: int +GNU_MAGIC: bytes +POSIX_MAGIC: bytes + +LENGTH_NAME: int +LENGTH_LINK: int +LENGTH_PREFIX: int + +REGTYPE: bytes +AREGTYPE: bytes +LNKTYPE: bytes +SYMTYPE: bytes +CONTTYPE: bytes +BLKTYPE: bytes +DIRTYPE: bytes +FIFOTYPE: bytes +CHRTYPE: bytes + +GNUTYPE_LONGNAME: bytes +GNUTYPE_LONGLINK: bytes +GNUTYPE_SPARSE: bytes + +XHDTYPE: bytes +XGLTYPE: bytes +SOLARIS_XHDTYPE: bytes USTAR_FORMAT: int GNU_FORMAT: int PAX_FORMAT: int DEFAULT_FORMAT: int -REGTYPE: bytes -AREGTYPE: bytes -LNKTYPE: bytes -SYMTYPE: bytes -DIRTYPE: bytes -FIFOTYPE: bytes -CONTTYPE: bytes -CHRTYPE: bytes -BLKTYPE: bytes -GNUTYPE_SPARSE: bytes +# tarfile constants + +SUPPORTED_TYPES: Tuple[bytes, ...] +REGULAR_TYPES: Tuple[bytes, ...] +GNU_TYPES: Tuple[bytes, ...] +PAX_FIELDS: Tuple[str, ...] +PAX_NUMBER_FIELDS: Dict[str, type] + +if sys.version_info >= (3,): + PAX_NAME_FIELDS: Set[str] + + +ENCODING: str if sys.version_info < (3,): TAR_PLAIN: int @@ -114,6 +144,18 @@ class TarFile(Iterable[TarInfo]): path: _Path = ...) -> None: ... def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... + def makedir(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented + def makefile(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented + def makeunknown(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented + def makefifo(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented + def makedev(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented + def makelink(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented + if sys.version_info >= (3, 5): + def chown(self, tarinfo: TarInfo, targetpath: _Path, numeric_owner: bool) -> None: ... # undocumented + else: + def chown(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented + def chmod(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented + def utime(self, tarinfo: TarInfo, targetpath: _Path) -> None: ... # undocumented if sys.version_info >= (3, 7): def add(self, name: str, arcname: Optional[str] = ..., recursive: bool = ..., *, @@ -135,7 +177,10 @@ class TarFile(Iterable[TarInfo]): fileobj: Optional[IO[bytes]] = ...) -> TarInfo: ... def close(self) -> None: ... -def is_tarfile(name: str) -> bool: ... +if sys.version_info >= (3, 9): + def is_tarfile(name: Union[_Path, IO[bytes]]) -> bool: ... +else: + def is_tarfile(name: _Path) -> bool: ... if sys.version_info < (3, 8): def filemode(mode: int) -> str: ... # undocumented diff --git a/python/helpers/typeshed/stdlib/2and3/threading.pyi b/python/helpers/typeshed/stdlib/2and3/threading.pyi index bd67d850fd86..ae8997251322 100644 --- a/python/helpers/typeshed/stdlib/2and3/threading.pyi +++ b/python/helpers/typeshed/stdlib/2and3/threading.pyi @@ -1,6 +1,6 @@ from typing import ( - Any, Callable, Iterable, List, Mapping, Optional, Tuple, Type, Union, + Any, Callable, Iterable, List, Mapping, Optional, Text, Tuple, Type, Union, TypeVar, ) from types import FrameType, TracebackType @@ -12,7 +12,6 @@ _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] _PF = Callable[[FrameType, str, Any], None] _T = TypeVar('_T') - __all__: List[str] def active_count() -> int: ... @@ -63,19 +62,20 @@ class Thread: else: def __init__(self, group: None = ..., target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., + name: Optional[Text] = ..., args: Iterable[Any] = ..., - kwargs: Mapping[str, Any] = ...) -> None: ... + kwargs: Mapping[Text, Any] = ...) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... - def setName(self, name: str) -> None: ... + def setName(self, name: Text) -> None: ... if sys.version_info >= (3, 8): @property def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... - def isAlive(self) -> bool: ... + if sys.version_info < (3, 9): + def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... def setDaemon(self, daemonic: bool) -> None: ... @@ -143,19 +143,12 @@ class Semaphore: def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... else: def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - -class BoundedSemaphore: - def __init__(self, value: int = ...) -> None: ... - def __enter__(self) -> bool: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[TracebackType]) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... + if sys.version_info >= (3, 9): + def release(self, n: int = ...) -> None: ... else: - def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... + def release(self) -> None: ... + +class BoundedSemaphore(Semaphore): ... class Event: diff --git a/python/helpers/typeshed/stdlib/2and3/time.pyi b/python/helpers/typeshed/stdlib/2and3/time.pyi index 0c2370ad62a4..9c50beaf74b0 100644 --- a/python/helpers/typeshed/stdlib/2and3/time.pyi +++ b/python/helpers/typeshed/stdlib/2and3/time.pyi @@ -103,8 +103,9 @@ if sys.version_info >= (3, 3): def clock_settime(clk_id: int, time: float) -> None: ... # Unix only if sys.version_info >= (3, 7): - def clock_gettime_ns(clock_id: int) -> int: ... - def clock_settime_ns(clock_id: int, time: int) -> int: ... + if sys.platform != "win32": + def clock_gettime_ns(clock_id: int) -> int: ... + def clock_settime_ns(clock_id: int, time: int) -> int: ... def monotonic_ns() -> int: ... def perf_counter_ns() -> int: ... def process_time_ns() -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/uuid.pyi b/python/helpers/typeshed/stdlib/2and3/uuid.pyi index cfdcc1ebd4dc..09f799bcf10b 100644 --- a/python/helpers/typeshed/stdlib/2and3/uuid.pyi +++ b/python/helpers/typeshed/stdlib/2and3/uuid.pyi @@ -1,7 +1,6 @@ # Stubs for uuid import sys -from enum import Enum from typing import Tuple, Optional, Any, Text # Because UUID has properties called int and bytes we need to rename these temporarily. @@ -10,6 +9,7 @@ _Bytes = bytes _FieldsType = Tuple[int, int, int, int, int, int] if sys.version_info >= (3, 7): + from enum import Enum class SafeUUID(Enum): safe: int unsafe: int @@ -94,7 +94,7 @@ class UUID: def get_version(self) -> Optional[_Int]: ... def __cmp__(self, other: Any) -> _Int: ... -def getnode(*, getters: None = ...) -> int: ... # getters is undocumented (and unused) +def getnode() -> int: ... def uuid1(node: Optional[_Int] = ..., clock_seq: Optional[_Int] = ...) -> UUID: ... def uuid3(namespace: UUID, name: str) -> UUID: ... def uuid4() -> UUID: ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/dom/NodeFilter.pyi b/python/helpers/typeshed/stdlib/2and3/xml/dom/NodeFilter.pyi new file mode 100644 index 000000000000..9bb2c1e530ff --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/xml/dom/NodeFilter.pyi @@ -0,0 +1,20 @@ +class NodeFilter: + FILTER_ACCEPT: int + FILTER_REJECT: int + FILTER_SKIP: int + + SHOW_ALL: int + SHOW_ELEMENT: int + SHOW_ATTRIBUTE: int + SHOW_TEXT: int + SHOW_CDATA_SECTION: int + SHOW_ENTITY_REFERENCE: int + SHOW_ENTITY: int + SHOW_PROCESSING_INSTRUCTION: int + SHOW_COMMENT: int + SHOW_DOCUMENT: int + SHOW_DOCUMENT_TYPE: int + SHOW_DOCUMENT_FRAGMENT: int + SHOW_NOTATION: int + + def acceptNode(self, node) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/dom/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/xml/dom/__init__.pyi new file mode 100644 index 000000000000..91548cd947e8 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/xml/dom/__init__.pyi @@ -0,0 +1,67 @@ +class Node: + ELEMENT_NODE: int + ATTRIBUTE_NODE: int + TEXT_NODE: int + CDATA_SECTION_NODE: int + ENTITY_REFERENCE_NODE: int + ENTITY_NODE: int + PROCESSING_INSTRUCTION_NODE: int + COMMENT_NODE: int + DOCUMENT_NODE: int + DOCUMENT_TYPE_NODE: int + DOCUMENT_FRAGMENT_NODE: int + NOTATION_NODE: int + + +# ExceptionCode +INDEX_SIZE_ERR: int +DOMSTRING_SIZE_ERR: int +HIERARCHY_REQUEST_ERR: int +WRONG_DOCUMENT_ERR: int +INVALID_CHARACTER_ERR: int +NO_DATA_ALLOWED_ERR: int +NO_MODIFICATION_ALLOWED_ERR: int +NOT_FOUND_ERR: int +NOT_SUPPORTED_ERR: int +INUSE_ATTRIBUTE_ERR: int +INVALID_STATE_ERR: int +SYNTAX_ERR: int +INVALID_MODIFICATION_ERR: int +NAMESPACE_ERR: int +INVALID_ACCESS_ERR: int +VALIDATION_ERR: int + + +class DOMException(Exception): + code: int + + def __init__(self, *args, **kw) -> None: ... + def _get_code(self) -> int: ... + +class IndexSizeErr(DOMException): ... +class DomstringSizeErr(DOMException): ... +class HierarchyRequestErr(DOMException): ... +class WrongDocumentErr(DOMException): ... +class NoDataAllowedErr(DOMException): ... +class NoModificationAllowedErr(DOMException): ... +class NotFoundErr(DOMException): ... +class NotSupportedErr(DOMException): ... +class InuseAttributeErr(DOMException): ... +class InvalidStateErr(DOMException): ... +class SyntaxErr(DOMException): ... +class InvalidModificationErr(DOMException): ... +class NamespaceErr(DOMException): ... +class InvalidAccessErr(DOMException): ... +class ValidationErr(DOMException): ... + +class UserDataHandler: + NODE_CLONED: int + NODE_IMPORTED: int + NODE_DELETED: int + NODE_RENAMED: int + +XML_NAMESPACE: str +XMLNS_NAMESPACE: str +XHTML_NAMESPACE: str +EMPTY_NAMESPACE: None +EMPTY_PREFIX: None diff --git a/python/helpers/typeshed/stdlib/2and3/xml/dom/minidom.pyi b/python/helpers/typeshed/stdlib/2and3/xml/dom/minidom.pyi new file mode 100644 index 000000000000..964e6fa3f426 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/xml/dom/minidom.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... # incomplete diff --git a/python/helpers/typeshed/stdlib/2and3/xml/dom/pulldom.pyi b/python/helpers/typeshed/stdlib/2and3/xml/dom/pulldom.pyi new file mode 100644 index 000000000000..964e6fa3f426 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/xml/dom/pulldom.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... # incomplete diff --git a/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementInclude.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementInclude.pyi index e8c3cd5609fc..eabfb54daf39 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementInclude.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementInclude.pyi @@ -1,5 +1,4 @@ -# Stubs for xml.etree.ElementInclude (Python 3.4) - +import sys from typing import Union, Optional, Callable from xml.etree.ElementTree import Element @@ -14,4 +13,7 @@ def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[ # TODO: loader is of type default_loader ie it takes a callable that has the # same signature as default_loader. But default_loader has a keyword argument # Which can't be represented using Callable... -def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... +if sys.version_info >= (3, 9): + def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ..., base_url: Optional[str] = ..., max_depth: Optional[int] = ...) -> None: ... +else: + def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi index 43c72394c017..462491b5fb39 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi @@ -63,7 +63,11 @@ else: # _fixtext function in the source). Client code knows best: _str_result_type = Any -_file_or_filename = Union[str, bytes, int, IO[Any]] +if sys.version_info >= (3, 6): + from os import PathLike + _file_or_filename = Union[str, bytes, PathLike[str], int, IO[Any]] +else: + _file_or_filename = Union[str, bytes, int, IO[Any]] if sys.version_info >= (3, 8): class _Writeable(Protocol): diff --git a/python/helpers/typeshed/stdlib/2and3/xml/sax/saxutils.pyi b/python/helpers/typeshed/stdlib/2and3/xml/sax/saxutils.pyi index 53f074097915..c6317c95acb4 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/sax/saxutils.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/sax/saxutils.pyi @@ -17,7 +17,7 @@ class XMLGenerator(handler.ContentHandler): if sys.version_info >= (3, 0): def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, _Writable]] = ..., encoding: str = ..., short_empty_elements: bool = ...) -> None: ... else: - def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, _Writable]] = ..., encoding: str = ...) -> None: ... + def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, _Writable]] = ..., encoding: Text = ...) -> None: ... def startDocument(self): ... def endDocument(self): ... def startPrefixMapping(self, prefix, uri): ... diff --git a/python/helpers/typeshed/stdlib/2and3/zlib.pyi b/python/helpers/typeshed/stdlib/2and3/zlib.pyi index d6e07bbf899c..871f621bf703 100644 --- a/python/helpers/typeshed/stdlib/2and3/zlib.pyi +++ b/python/helpers/typeshed/stdlib/2and3/zlib.pyi @@ -1,5 +1,7 @@ # Stubs for zlib import sys +from array import array +from typing import Union, Any DEFLATED: int DEF_MEM_LEVEL: int @@ -47,7 +49,7 @@ if sys.version_info >= (3,): else: def compressobj(level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., strategy: int = ...) -> _Compress: ... -def crc32(__data: bytes, __value: int = ...) -> int: ... +def crc32(__data: Union[array[Any], bytes], __value: int = ...) -> int: ... def decompress(__data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... if sys.version_info >= (3,): def decompressobj(wbits: int = ..., zdict: bytes = ...) -> _Decompress: ... diff --git a/python/helpers/typeshed/stdlib/3/ast.pyi b/python/helpers/typeshed/stdlib/3/ast.pyi index c96aad19e916..56d4dc134a88 100644 --- a/python/helpers/typeshed/stdlib/3/ast.pyi +++ b/python/helpers/typeshed/stdlib/3/ast.pyi @@ -16,13 +16,28 @@ if sys.version_info >= (3, 8): else: from typing_extensions import Literal + +if sys.version_info >= (3, 8): + class Num(Constant): ... + class Str(Constant): ... + class Bytes(Constant): ... + class NameConstant(Constant): ... + class Ellipsis(Constant): ... +if sys.version_info >= (3, 9): + class slice(AST): ... + class ExtSlice(slice): ... + class Index(slice): ... + class Suite(mod): ... + class AugLoad(expr_context): ... + class AugStore(expr_context): ... + class Param(expr_context): ... + class NodeVisitor: def visit(self, node: AST) -> Any: ... def generic_visit(self, node: AST) -> Any: ... def visit_Module(self, node: Module) -> Any: ... def visit_Interactive(self, node: Interactive) -> Any: ... def visit_Expression(self, node: Expression) -> Any: ... - def visit_Suite(self, node: Suite) -> Any: ... def visit_FunctionDef(self, node: FunctionDef) -> Any: ... def visit_AsyncFunctionDef(self, node: AsyncFunctionDef) -> Any: ... def visit_ClassDef(self, node: ClassDef) -> Any: ... @@ -50,8 +65,6 @@ class NodeVisitor: def visit_Break(self, node: Break) -> Any: ... def visit_Continue(self, node: Continue) -> Any: ... def visit_Slice(self, node: Slice) -> Any: ... - def visit_ExtSlice(self, node: ExtSlice) -> Any: ... - def visit_Index(self, node: Index) -> Any: ... def visit_BoolOp(self, node: BoolOp) -> Any: ... def visit_BinOp(self, node: BinOp) -> Any: ... def visit_UnaryOp(self, node: UnaryOp) -> Any: ... @@ -71,18 +84,6 @@ class NodeVisitor: if sys.version_info >= (3, 6): def visit_FormattedValue(self, node: FormattedValue) -> Any: ... def visit_JoinedStr(self, node: JoinedStr) -> Any: ... - if sys.version_info < (3, 8): - def visit_Num(self, node: Num) -> Any: ... - def visit_Str(self, node: Str) -> Any: ... - def visit_Bytes(self, node: Bytes) -> Any: ... - def visit_NameConstant(self, node: NameConstant) -> Any: ... - def visit_Ellipsis(self, node: Ellipsis) -> Any: ... - else: - def visit_Num(self, node: Constant) -> Any: ... - def visit_Str(self, node: Constant) -> Any: ... - def visit_Bytes(self, node: Constant) -> Any: ... - def visit_NameConstant(self, node: Constant) -> Any: ... - def visit_Ellipsis(self, node: Constant) -> Any: ... if sys.version_info >= (3, 6): def visit_Constant(self, node: Constant) -> Any: ... if sys.version_info >= (3, 8): @@ -93,11 +94,8 @@ class NodeVisitor: def visit_Name(self, node: Name) -> Any: ... def visit_List(self, node: List) -> Any: ... def visit_Tuple(self, node: Tuple) -> Any: ... - def visit_AugLoad(self, node: AugLoad) -> Any: ... - def visit_AugStore(self, node: AugStore) -> Any: ... def visit_Del(self, node: Del) -> Any: ... def visit_Load(self, node: Load) -> Any: ... - def visit_Param(self, node: Param) -> Any: ... def visit_Store(self, node: Store) -> Any: ... def visit_And(self, node: And) -> Any: ... def visit_Or(self, node: Or) -> Any: ... @@ -135,6 +133,18 @@ class NodeVisitor: def visit_keyword(self, node: keyword) -> Any: ... def visit_alias(self, node: alias) -> Any: ... def visit_withitem(self, node: withitem) -> Any: ... + # visit methods for deprecated nodes + def visit_ExtSlice(self, node: ExtSlice) -> Any: ... + def visit_Index(self, node: Index) -> Any: ... + def visit_Suite(self, node: Suite) -> Any: ... + def visit_AugLoad(self, node: AugLoad) -> Any: ... + def visit_AugStore(self, node: AugStore) -> Any: ... + def visit_Param(self, node: Param) -> Any: ... + def visit_Num(self, node: Num) -> Any: ... + def visit_Str(self, node: Str) -> Any: ... + def visit_Bytes(self, node: Bytes) -> Any: ... + def visit_NameConstant(self, node: NameConstant) -> Any: ... + def visit_Ellipsis(self, node: Ellipsis) -> Any: ... class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> Optional[AST]: ... @@ -174,7 +184,10 @@ if sys.version_info >= (3, 9): def unparse(ast_obj: AST) -> str: ... def copy_location(new_node: _T, old_node: AST) -> _T: ... -def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... +if sys.version_info >= (3, 9): + def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: Union[int, str, None] = ...) -> str: ... +else: + def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: _T) -> _T: ... def get_docstring(node: AST, clean: bool = ...) -> str: ... def increment_lineno(node: _T, n: int = ...) -> _T: ... @@ -184,10 +197,3 @@ def literal_eval(node_or_string: Union[str, AST]) -> Any: ... if sys.version_info >= (3, 8): def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> Optional[str]: ... def walk(node: AST) -> Iterator[AST]: ... - -if sys.version_info >= (3, 8): - class Num(Constant): ... - class Str(Constant): ... - class Bytes(Constant): ... - class NameConstant(Constant): ... - class Ellipsis(Constant): ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/__init__.pyi b/python/helpers/typeshed/stdlib/3/asyncio/__init__.pyi index d52787f25397..147c8b46d4eb 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/__init__.pyi @@ -1,58 +1,12 @@ import sys from typing import Type +from asyncio.base_events import BaseEventLoop as BaseEventLoop from asyncio.coroutines import ( coroutine as coroutine, iscoroutinefunction as iscoroutinefunction, iscoroutine as iscoroutine, ) -from asyncio.protocols import ( - BaseProtocol as BaseProtocol, - Protocol as Protocol, - DatagramProtocol as DatagramProtocol, - SubprocessProtocol as SubprocessProtocol, -) -from asyncio.streams import ( - StreamReader as StreamReader, - StreamWriter as StreamWriter, - StreamReaderProtocol as StreamReaderProtocol, - open_connection as open_connection, - start_server as start_server, -) -from asyncio.subprocess import ( - create_subprocess_exec as create_subprocess_exec, - create_subprocess_shell as create_subprocess_shell, -) -from asyncio.transports import ( - BaseTransport as BaseTransport, - ReadTransport as ReadTransport, - WriteTransport as WriteTransport, - Transport as Transport, - DatagramTransport as DatagramTransport, - SubprocessTransport as SubprocessTransport, -) -from asyncio.futures import ( - Future as Future, - wrap_future as wrap_future, -) -from asyncio.tasks import ( - FIRST_COMPLETED as FIRST_COMPLETED, - FIRST_EXCEPTION as FIRST_EXCEPTION, - ALL_COMPLETED as ALL_COMPLETED, - as_completed as as_completed, - ensure_future as ensure_future, - gather as gather, - run_coroutine_threadsafe as run_coroutine_threadsafe, - shield as shield, - sleep as sleep, - wait as wait, - wait_for as wait_for, - Task as Task, -) -from asyncio.base_events import ( - BaseEventLoop as BaseEventLoop, - Server as Server -) from asyncio.events import ( AbstractEventLoopPolicy as AbstractEventLoopPolicy, AbstractEventLoop as AbstractEventLoop, @@ -66,59 +20,11 @@ from asyncio.events import ( new_event_loop as new_event_loop, get_child_watcher as get_child_watcher, set_child_watcher as set_child_watcher, -) -from asyncio.queues import ( - Queue as Queue, - PriorityQueue as PriorityQueue, - LifoQueue as LifoQueue, - QueueFull as QueueFull, - QueueEmpty as QueueEmpty, -) -from asyncio.locks import ( - Lock as Lock, - Event as Event, - Condition as Condition, - Semaphore as Semaphore, - BoundedSemaphore as BoundedSemaphore, -) - -from asyncio.futures import isfuture as isfuture -from asyncio.events import ( _set_running_loop as _set_running_loop, _get_running_loop as _get_running_loop, ) -if sys.platform == 'win32': - from asyncio.windows_events import * -else: - from asyncio.streams import ( - open_unix_connection as open_unix_connection, - start_unix_server as start_unix_server, - ) - DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy] - if sys.version_info >= (3, 7): - from asyncio.events import ( - get_running_loop as get_running_loop, - ) - from asyncio.tasks import ( - all_tasks as all_tasks, - create_task as create_task, - current_task as current_task, - ) - from asyncio.runners import ( - run as run, - ) - -if sys.platform != 'win32': - from .unix_events import ( - AbstractChildWatcher as AbstractChildWatcher, - BaseChildWatcher as BaseChildWatcher, - SafeChildWatcher as SafeChildWatcher, - SelectorEventLoop as SelectorEventLoop, - ) - if sys.version_info >= (3, 8): - from .unix_events import MultiLoopChildWatcher as MultiLoopChildWatcher, ThreadedChildWatcher as ThreadedChildWatcher - + from asyncio.events import get_running_loop as get_running_loop if sys.version_info >= (3, 8): from asyncio.exceptions import ( CancelledError as CancelledError, @@ -142,3 +48,91 @@ else: IncompleteReadError as IncompleteReadError, LimitOverrunError as LimitOverrunError, ) +from asyncio.futures import ( + Future as Future, + isfuture as isfuture, + wrap_future as wrap_future, +) +from asyncio.locks import ( + Lock as Lock, + Event as Event, + Condition as Condition, + Semaphore as Semaphore, + BoundedSemaphore as BoundedSemaphore, +) +from asyncio.protocols import ( + BaseProtocol as BaseProtocol, + Protocol as Protocol, + DatagramProtocol as DatagramProtocol, + SubprocessProtocol as SubprocessProtocol, +) +if sys.version_info >= (3, 7): + from asyncio.protocols import BufferedProtocol as BufferedProtocol +from asyncio.queues import ( + Queue as Queue, + PriorityQueue as PriorityQueue, + LifoQueue as LifoQueue, + QueueFull as QueueFull, + QueueEmpty as QueueEmpty, +) +if sys.version_info >= (3, 7): + from asyncio.runners import run as run +from asyncio.streams import ( + StreamReader as StreamReader, + StreamWriter as StreamWriter, + StreamReaderProtocol as StreamReaderProtocol, + open_connection as open_connection, + start_server as start_server, +) +from asyncio.subprocess import ( + create_subprocess_exec as create_subprocess_exec, + create_subprocess_shell as create_subprocess_shell, +) +from asyncio.tasks import ( + FIRST_COMPLETED as FIRST_COMPLETED, + FIRST_EXCEPTION as FIRST_EXCEPTION, + ALL_COMPLETED as ALL_COMPLETED, + as_completed as as_completed, + ensure_future as ensure_future, + gather as gather, + run_coroutine_threadsafe as run_coroutine_threadsafe, + shield as shield, + sleep as sleep, + wait as wait, + wait_for as wait_for, + Task as Task, +) +if sys.version_info >= (3, 7): + from asyncio.tasks import ( + all_tasks as all_tasks, + create_task as create_task, + current_task as current_task, + ) +if sys.version_info >= (3, 9): + from asyncio.threads import to_thread as to_thread +from asyncio.transports import ( + BaseTransport as BaseTransport, + ReadTransport as ReadTransport, + WriteTransport as WriteTransport, + Transport as Transport, + DatagramTransport as DatagramTransport, + SubprocessTransport as SubprocessTransport, +) + +DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy] +if sys.platform == 'win32': + from asyncio.windows_events import * + +if sys.platform != 'win32': + from asyncio.streams import ( + open_unix_connection as open_unix_connection, + start_unix_server as start_unix_server, + ) + from .unix_events import ( + AbstractChildWatcher as AbstractChildWatcher, + FastChildWatcher as FastChildWatcher, + SafeChildWatcher as SafeChildWatcher, + SelectorEventLoop as SelectorEventLoop, + ) + if sys.version_info >= (3, 8): + from .unix_events import MultiLoopChildWatcher as MultiLoopChildWatcher, ThreadedChildWatcher as ThreadedChildWatcher diff --git a/python/helpers/typeshed/stdlib/3/asyncio/base_events.pyi b/python/helpers/typeshed/stdlib/3/asyncio/base_events.pyi index 43ea39b62607..3705a1124705 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/base_events.pyi +++ b/python/helpers/typeshed/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 @@ -216,3 +218,5 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): # Debug flag management. def get_debug(self) -> bool: ... def set_debug(self, enabled: bool) -> None: ... + if sys.version_info >= (3, 9): + async def shutdown_default_executor(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/base_futures.pyi b/python/helpers/typeshed/stdlib/3/asyncio/base_futures.pyi new file mode 100644 index 000000000000..f91c886ef305 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/base_futures.pyi @@ -0,0 +1,18 @@ + +import sys +import contextvars +from typing import List, Tuple, Callable, Sequence +from . import futures + +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + +_PENDING: Literal["PENDING"] # undocumented +_CANCELLED: Literal["CANCELLED"] # undocumented +_FINISHED: Literal["FINISHED"] # undocumented + +def isfuture(obj: object) -> bool: ... +def _format_callbacks(cb: Sequence[Tuple[Callable[[futures.Future], None], contextvars.Context]]) -> str: ... # undocumented +def _future_repr_info(future: futures.Future) -> List[str]: ... # undocumented diff --git a/python/helpers/typeshed/stdlib/3/asyncio/base_subprocess.pyi b/python/helpers/typeshed/stdlib/3/asyncio/base_subprocess.pyi new file mode 100644 index 000000000000..31cf24860eff --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/base_subprocess.pyi @@ -0,0 +1,59 @@ + +from typing import Optional, Union, Sequence, IO, Any, List, Deque, Dict, Tuple, Callable +import subprocess + +from . import events +from . import protocols +from . import futures +from . import transports + +_File = Optional[Union[int, IO[Any]]] + +class BaseSubprocessTransport(transports.SubprocessTransport): + + _closed: bool # undocumented + _protocol: protocols.SubprocessProtocol # undocumented + _loop: events.AbstractEventLoop # undocumented + _proc: Optional[subprocess.Popen] # undocumented + _pid: Optional[int] # undocumented + _returncode: Optional[int] # undocumented + _exit_waiters: List[futures.Future] # undocumented + _pending_calls: Deque[Tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented + _pipes: Dict[int, _File] # undocumented + _finished: bool # undocumented + + def __init__(self, loop: events.AbstractEventLoop, protocol: protocols.SubprocessProtocol, args: Union[str, bytes, Sequence[Union[str, bytes]]], + shell: bool, stdin: _File, stdout: _File, stderr: _File, bufsize: int, waiter: Optional[futures.Future] = ..., extra: Optional[Any] = ..., **kwargs: Any) -> None: ... + + def _start(self, args: Union[str, bytes, Sequence[Union[str, bytes]]], shell: bool, stdin: _File, stdout: _File, stderr: _File, bufsize: int, **kwargs: Any): ... # undocumented + def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ... + def get_protocol(self) -> protocols.BaseProtocol: ... + def is_closing(self) -> bool: ... + def close(self) -> None: ... + def get_pid(self) -> Optional[int]: ... # type: ignore + def get_returncode(self) -> Optional[int]: ... + def get_pipe_transport(self, fd: int) -> _File: ... # type: ignore + def _check_proc(self) -> None: ... # undocumented + def send_signal(self, signal: int) -> None: ... # type: ignore + def terminate(self) -> None: ... + def kill(self) -> None: ... + async def _connect_pipes(self, waiter: Optional[futures.Future]) -> None: ... # undocumented + def _call(self, cb: Callable[..., Any], *data: Any) -> None: ... # undocumented + def _pipe_connection_lost(self, fd: int, exc: Optional[BaseException]) -> None: ... # undocumented + def _pipe_data_received(self, fd: int, data: bytes) -> None: ... # undocumented + def _process_exited(self, returncode: int) -> None: ... # undocumented + async def _wait(self) -> int: ... # undocumented + def _try_finish(self) -> None: ... # undocumented + def _call_connection_lost(self, exc: Optional[BaseException]) -> None: ... # undocumented + +class WriteSubprocessPipeProto(protocols.BaseProtocol): # undocumented + + def __init__(self, proc: BaseSubprocessTransport, fd: int) -> None: ... + def connection_made(self, transport: transports.BaseTransport) -> None: ... + def connection_lost(self, exc: Optional[BaseException]) -> None: ... + def pause_writing(self) -> None: ... + def resume_writing(self) -> None: ... + +class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): # undocumented + + def data_received(self, data: bytes) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/base_tasks.pyi b/python/helpers/typeshed/stdlib/3/asyncio/base_tasks.pyi new file mode 100644 index 000000000000..8f8e555487f4 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/base_tasks.pyi @@ -0,0 +1,16 @@ + +import sys + +from typing import List, Optional, Union +from types import FrameType +from . import tasks + +if sys.version_info >= (3, 6): + from builtins import _PathLike + _PathType = Union[bytes, str, _PathLike] +else: + _PathType = Union[bytes, str] + +def _task_repr_info(task: tasks.Task) -> List[str]: ... # undocumented +def _task_get_stack(task: tasks.Task, limit: Optional[int]) -> List[FrameType]: ... # undocumented +def _task_print_stack(task: tasks.Task, limit: Optional[int], file: _PathType): ... # undocumented diff --git a/python/helpers/typeshed/stdlib/3/asyncio/compat.pyi b/python/helpers/typeshed/stdlib/3/asyncio/compat.pyi new file mode 100644 index 000000000000..24d448f49dd5 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/compat.pyi @@ -0,0 +1,10 @@ + +import sys +from typing import List + +if sys.version_info < (3, 7): + PY34: bool + PY35: bool + PY352: bool + + def flatten_list_bytes(list_of_data: List[bytes]) -> bytes: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/constants.pyi b/python/helpers/typeshed/stdlib/3/asyncio/constants.pyi index f15ea4fe2bab..0b28309e9ff7 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/constants.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/asyncio/events.pyi b/python/helpers/typeshed/stdlib/3/asyncio/events.pyi index f90c98cbe249..d3c8119498bb 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/events.pyi +++ b/python/helpers/typeshed/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]] = ..., *, @@ -302,6 +293,9 @@ class AbstractEventLoop(metaclass=ABCMeta): def get_debug(self) -> bool: ... @abstractmethod def set_debug(self, enabled: bool) -> None: ... + if sys.version_info >= (3, 9): + @abstractmethod + async def shutdown_default_executor(self) -> None: ... class AbstractEventLoopPolicy(metaclass=ABCMeta): @abstractmethod @@ -332,7 +326,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/python/helpers/typeshed/stdlib/3/asyncio/format_helpers.pyi b/python/helpers/typeshed/stdlib/3/asyncio/format_helpers.pyi new file mode 100644 index 000000000000..a1b2d09bfad7 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/format_helpers.pyi @@ -0,0 +1,25 @@ + +import sys +import functools +import traceback + +from typing import Optional, Tuple, Union, Iterable, Dict, Any, overload +from types import FunctionType, FrameType + +class _HasWrapper: + __wrapper__: Union[_HasWrapper, FunctionType] + +_FuncType = Union[FunctionType, _HasWrapper, functools.partial, functools.partialmethod] + +if sys.version_info >= (3, 7): + + @overload + def _get_function_source(func: _FuncType) -> Tuple[str, int]: ... + @overload + def _get_function_source(func: object) -> Optional[Tuple[str, int]]: ... + + def _format_callback_source(func: object, args: Iterable[Any]) -> str: ... + def _format_args_and_kwargs(args: Iterable[Any], kwargs: Dict[str, Any]) -> str: ... + def _format_callback(func: object, args: Iterable[Any], kwargs: Dict[str, Any], suffix: str = ...) -> str: ... + + def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> traceback.StackSummary: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/futures.pyi b/python/helpers/typeshed/stdlib/3/asyncio/futures.pyi index f4f97c607d23..a4f8d6710cf6 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/futures.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/futures.pyi @@ -1,7 +1,7 @@ import sys from typing import Any, Union, Callable, TypeVar, Type, List, Iterable, Generator, Awaitable, Optional, Tuple from .events import AbstractEventLoop -from concurrent.futures import ( +from concurrent.futures._base import ( Future as _ConcurrentFuture, Error, ) @@ -46,19 +46,20 @@ class Future(Awaitable[_T], Iterable[_T]): @property 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: ... + if sys.version_info >= (3, 9): + def cancel(self, msg: Optional[str] = ...) -> bool: ... + else: + def cancel(self) -> bool: ... 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/python/helpers/typeshed/stdlib/3/asyncio/locks.pyi b/python/helpers/typeshed/stdlib/3/asyncio/locks.pyi index 19d47276028d..55eabfffc3a9 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/locks.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/asyncio/log.pyi b/python/helpers/typeshed/stdlib/3/asyncio/log.pyi new file mode 100644 index 000000000000..5534ebda5802 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/log.pyi @@ -0,0 +1,4 @@ + +import logging + +logger: logging.Logger diff --git a/python/helpers/typeshed/stdlib/3/asyncio/proactor_events.pyi b/python/helpers/typeshed/stdlib/3/asyncio/proactor_events.pyi index f7bc90db1cc3..0ad5451fd900 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/proactor_events.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/asyncio/protocols.pyi b/python/helpers/typeshed/stdlib/3/asyncio/protocols.pyi index 0fa75a507020..710fad75e193 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/protocols.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/protocols.pyi @@ -1,3 +1,4 @@ +import sys from asyncio import transports from typing import Optional, Tuple, Union @@ -11,9 +12,10 @@ class Protocol(BaseProtocol): def data_received(self, data: bytes) -> None: ... def eof_received(self) -> Optional[bool]: ... -class BufferedProtocol(Protocol): - def get_buffer(self, sizehint: int) -> bytearray: ... - def buffer_updated(self, nbytes: int) -> None: ... +if sys.version_info >= (3, 7): + class BufferedProtocol(BaseProtocol): + def get_buffer(self, sizehint: int) -> bytearray: ... + def buffer_updated(self, nbytes: int) -> None: ... class DatagramProtocol(BaseProtocol): def datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/queues.pyi b/python/helpers/typeshed/stdlib/3/asyncio/queues.pyi index 420c67a9dd68..75340e67e2e7 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/queues.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/asyncio/selector_events.pyi b/python/helpers/typeshed/stdlib/3/asyncio/selector_events.pyi index 5d63cdf8fd47..1af86855b08d 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/selector_events.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/asyncio/sslproto.pyi b/python/helpers/typeshed/stdlib/3/asyncio/sslproto.pyi new file mode 100644 index 000000000000..a86a1b17bb96 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/sslproto.pyi @@ -0,0 +1,135 @@ + +import sys +import ssl + +from typing import ClassVar, Optional, List, Tuple, Callable, Dict, Any, Deque + +from . import transports +from . import constants +from . import events +from . import protocols +from . import futures + +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + +def _create_transport_context(server_side: bool, server_hostname: Optional[str]) -> ssl.SSLContext: ... + +_UNWRAPPED: Literal["UNWRAPPED"] +_DO_HANDSHAKE: Literal["DO_HANDSHAKE"] +_WRAPPED: Literal["WRAPPED"] +_SHUTDOWN: Literal["SHUTDOWN"] + +class _SSLPipe: + + max_size: ClassVar[int] + + _context: ssl.SSLContext + _server_side: bool + _server_hostname: Optional[str] + _state: str + _incoming: ssl.MemoryBIO + _outgoing: ssl.MemoryBIO + _sslobj: Optional[ssl.SSLObject] + _need_ssldata: bool + _handshake_cb: Optional[Callable[[Optional[BaseException]], None]] + _shutdown_cb: Optional[Callable[[], None]] + + def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: Optional[str] = ...) -> None: ... + + @property + def context(self) -> ssl.SSLContext: ... + @property + def ssl_object(self) -> Optional[ssl.SSLObject]: ... + @property + def need_ssldata(self) -> bool: ... + @property + def wrapped(self) -> bool: ... + + def do_handshake(self, callback: Optional[Callable[[Optional[BaseException]], None]] = ...) -> List[bytes]: ... + def shutdown(self, callback: Optional[Callable[[], None]] = ...) -> List[bytes]: ... + def feed_eof(self) -> None: ... + def feed_ssldata(self, data: bytes, only_handshake: bool = ...) -> Tuple[List[bytes], List[bytes]]: ... + def feed_appdata(self, data: bytes, offset: int = ...) -> Tuple[List[bytes], int]: ... + +class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): + + _sendfile_compatible: ClassVar[constants._SendfileMode] + + _loop: events.AbstractEventLoop + _ssl_protocol: SSLProtocol + _closed: bool + + if sys.version_info >= (3, 6): + def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ... + else: + def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol, app_protocol: protocols.BaseProtocol) -> None: ... + + def get_extra_info(self, name: str, default: Optional[Any] = ...) -> Dict[str, Any]: ... + def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ... + def get_protocol(self) -> protocols.BaseProtocol: ... + def is_closing(self) -> bool: ... + def close(self) -> None: ... + if sys.version_info >= (3, 7): + def is_reading(self) -> bool: ... + def pause_reading(self) -> None: ... + def resume_reading(self) -> None: ... + def set_write_buffer_limits(self, high: Optional[int] = ..., low: Optional[int] = ...) -> None: ... + def get_write_buffer_size(self) -> int: ... + if sys.version_info >= (3, 7): + @property + def _protocol_paused(self) -> bool: ... + def write(self, data: bytes) -> None: ... + def can_write_eof(self) -> Literal[False]: ... + def abort(self) -> None: ... + +class SSLProtocol(protocols.Protocol): + + _server_side: bool + _server_hostname: Optional[str] + _sslcontext: ssl.SSLContext + _extra: Dict[str, Any] + _write_backlog: Deque[Tuple[bytes, int]] + _write_buffer_size: int + _waiter: futures.Future + _loop: events.AbstractEventLoop + _app_transport: _SSLProtocolTransport + _sslpipe: Optional[_SSLPipe] + _session_established: bool + _in_handshake: bool + _in_shutdown: bool + _transport: Optional[transports.BaseTransport] + _call_connection_made: bool + _ssl_handshake_timeout: Optional[int] + _app_protocol: protocols.BaseProtocol + _app_protocol_is_buffer: bool + + if sys.version_info >= (3, 7): + def __init__(self, loop: events.AbstractEventLoop, app_protocol: protocols.BaseProtocol, sslcontext: ssl.SSLContext, waiter: futures.Future, + server_side: bool = ..., server_hostname: Optional[str] = ..., call_connection_made: bool = ..., ssl_handshake_timeout: Optional[int] = ...) -> None: ... + else: + def __init__(self, loop: events.AbstractEventLoop, app_protocol: protocols.BaseProtocol, sslcontext: ssl.SSLContext, waiter: futures.Future, + server_side: bool = ..., server_hostname: Optional[str] = ..., call_connection_made: bool = ...) -> None: ... + + if sys.version_info >= (3, 7): + def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ... + def _wakeup_waiter(self, exc: Optional[BaseException] = ...) -> None: ... + def connection_made(self, transport: transports.BaseTransport) -> None: ... + def connection_lost(self, exc: Optional[BaseException]) -> None: ... + def pause_writing(self) -> None: ... + def resume_writing(self) -> None: ... + def data_received(self, data: bytes) -> None: ... + def eof_received(self) -> None: ... + def _get_extra_info(self, name: str, default: Optional[Any] = ...) -> Any: ... + def _start_shutdown(self) -> None: ... + def _write_appdata(self, data: bytes) -> None: ... + def _start_handshake(self) -> None: ... + if sys.version_info >= (3, 7): + def _check_handshake_timeout(self) -> None: ... + def _on_handshake_complete(self, handshake_exc: Optional[BaseException]) -> None: ... + def _process_write_backlog(self) -> None: ... + def _fatal_error(self, exc: BaseException, message: str = ...) -> None: ... + def _finalize(self) -> None: ... + def _abort(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/staggered.pyi b/python/helpers/typeshed/stdlib/3/asyncio/staggered.pyi new file mode 100644 index 000000000000..3ba73b11b089 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/staggered.pyi @@ -0,0 +1,7 @@ + +import sys +from typing import Iterable, Callable, Awaitable, Optional, Tuple, Any, List +from . import events + +if sys.version_info >= (3, 8): + async def staggered_race(coro_fns: Iterable[Callable[[], Awaitable]], delay: Optional[float], *, loop: Optional[events.AbstractEventLoop] = ...) -> Tuple[Any, Optional[int], List[Optional[Exception]]]: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/streams.pyi b/python/helpers/typeshed/stdlib/3/asyncio/streams.pyi index e85170089c8a..b691798ab454 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/streams.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/asyncio/subprocess.pyi b/python/helpers/typeshed/stdlib/3/asyncio/subprocess.pyi index 14137447c9e0..d968a156cec2 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/subprocess.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/asyncio/tasks.pyi b/python/helpers/typeshed/stdlib/3/asyncio/tasks.pyi index 9bb5a5b4e2cc..f7de40db1c4c 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/tasks.pyi +++ b/python/helpers/typeshed/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], @@ -93,7 +93,7 @@ def wait_for(fut: _FutureT[_T], timeout: Optional[float], class Task(Future[_T], Generic[_T]): @classmethod - def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Task[Any]: ... + def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... @classmethod def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... if sys.version_info >= (3, 8): @@ -110,20 +110,22 @@ 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, 9): + def cancel(self, msg: Optional[str] = ...) -> bool: ... + else: + def cancel(self) -> bool: ... 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]]: ... if sys.version_info >= (3, 8): def create_task( coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, name: Optional[str] = ..., - ) -> Task[Any]: ... + ) -> Task[_T]: ... else: - def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[Any]: ... + def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[_T]: ... def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/threads.pyi b/python/helpers/typeshed/stdlib/3/asyncio/threads.pyi new file mode 100644 index 000000000000..52e9a63ac0cc --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/threads.pyi @@ -0,0 +1,7 @@ +import sys +from typing import Any, Callable, TypeVar + +_T = TypeVar('_T') + +if sys.version_info >= (3, 9): + async def to_thread(__func: Callable[..., _T], *args: Any, **kwargs: Any) -> _T: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/transports.pyi b/python/helpers/typeshed/stdlib/3/asyncio/transports.pyi index a0b0fdd8b07a..863da761f20b 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/transports.pyi +++ b/python/helpers/typeshed/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 @@ -20,7 +21,7 @@ class ReadTransport(BaseTransport): class WriteTransport(BaseTransport): def set_write_buffer_limits( - self, high: int = ..., low: int = ... + self, high: Optional[int] = ..., low: Optional[int] = ... ) -> None: ... def get_write_buffer_size(self) -> int: ... def write(self, data: Any) -> None: ... @@ -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/python/helpers/typeshed/stdlib/3/asyncio/trsock.pyi b/python/helpers/typeshed/stdlib/3/asyncio/trsock.pyi new file mode 100644 index 000000000000..9dbefbe8c8c1 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/asyncio/trsock.pyi @@ -0,0 +1,78 @@ + +import sys +import socket +from typing import Union, NoReturn, Tuple, Optional, Iterable, List, Any, BinaryIO, Type, overload +from types import TracebackType + +if sys.version_info >= (3, 8): + # These are based in socket, maybe move them out into _typeshed.pyi or such + _Address = Union[tuple, str] + _RetAddress = Any + _WriteBuffer = Union[bytearray, memoryview] + _CMSG = Tuple[int, int, bytes] + + class TransportSocket: + def __init__(self, sock: socket.socket) -> None: ... + def _na(self, what: str) -> None: ... + @property + def family(self) -> int: ... + @property + def type(self) -> int: ... + @property + def proto(self) -> int: ... + def __getstate__(self) -> NoReturn: ... + def fileno(self) -> int: ... + def dup(self) -> socket.socket: ... + def get_inheritable(self) -> bool: ... + def shutdown(self, how: int) -> None: ... + @overload + def getsockopt(self, level: int, optname: int) -> int: ... + @overload + def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... + @overload + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + @overload + def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ... + def getpeername(self) -> _RetAddress: ... + def getsockname(self) -> _RetAddress: ... + def getsockbyname(self) -> NoReturn: ... # This method doesn't exist on socket, yet is passed through? + def accept(self) -> Tuple[socket.socket, _RetAddress]: ... + def connect(self, address: Union[_Address, bytes]) -> None: ... + def connect_ex(self, address: Union[_Address, bytes]) -> int: ... + def bind(self, address: Union[_Address, bytes]) -> None: ... + if sys.platform == 'win32': + def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ... + else: + def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> NoReturn: ... + def listen(self, __backlog: int = ...) -> None: ... + def makefile(self) -> BinaryIO: ... + def sendfile(self, file, offset: int = ..., count: Optional[int] = ...) -> int: ... + def close(self) -> None: ... + def detach(self) -> int: ... + if sys.platform == "linux": + def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> int: ... + else: + def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> NoReturn: ... + def sendmsg(self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., __flags: int = ..., __address: _Address = ...) -> int: ... + @overload + def sendto(self, data: bytes, address: _Address) -> int: ... + @overload + def sendto(self, data: bytes, flags: int, address: _Address) -> int: ... + def send(self, data: bytes, flags: int = ...) -> int: ... + def sendall(self, data: bytes, flags: int = ...) -> None: ... + def set_inheritable(self, inheritable: bool) -> None: ... + if sys.platform == 'win32': + def share(self, process_id: int) -> bytes: ... + else: + def share(self, process_id: int) -> NoReturn: ... + def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ... + def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> Tuple[int, _RetAddress]: ... + def recvmsg_into(self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ..., __flags: int = ...) -> Tuple[int, List[_CMSG], int, Any]: ... + def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ... + def recvfrom(self, bufsize: int, flags: int = ...) -> Tuple[bytes, _RetAddress]: ... + def recv(self, bufsize: int, flags: int = ...) -> bytes: ... + def settimeout(self, value: Optional[float]) -> None: ... + def gettimeout(self) -> Optional[float]: ... + def setblocking(self, flag: bool) -> None: ... + def __enter__(self) -> socket.socket: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/windows_events.pyi b/python/helpers/typeshed/stdlib/3/asyncio/windows_events.pyi index 537b172a26ff..8b12a9f3539c 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/windows_events.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/windows_events.pyi @@ -1,9 +1,18 @@ import socket import sys -from typing import IO, Any, Callable, ClassVar, List, NoReturn, Optional, Tuple +from typing import IO, Any, Callable, ClassVar, List, NoReturn, Optional, Tuple, Type from . import events, futures, proactor_events, selector_events, streams, windows_utils +__all__ = [ + "SelectorEventLoop", + "ProactorEventLoop", + "IocpProactor", + "DefaultEventLoopPolicy", + "WindowsSelectorEventLoopPolicy", + "WindowsProactorEventLoopPolicy", +] + NULL: int INFINITE: int ERROR_CONNECTION_REFUSED: int @@ -35,31 +44,33 @@ class IocpProactor: def set_loop(self, loop: events.AbstractEventLoop) -> None: ... def select(self, timeout: Optional[int] = ...) -> List[futures.Future[Any]]: ... def recv(self, conn: socket.socket, nbytes: int, flags: int = ...) -> futures.Future[bytes]: ... - def recv_into(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ... + if sys.version_info >= (3, 7): + def recv_into(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ... def send(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ... def accept(self, listener: socket.socket) -> futures.Future[Any]: ... def connect(self, conn: socket.socket, address: bytes) -> futures.Future[Any]: ... - def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ... + if sys.version_info >= (3, 7): + def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ... def accept_pipe(self, pipe: socket.socket) -> futures.Future[Any]: ... async def connect_pipe(self, address: bytes) -> windows_utils.PipeHandle: ... - def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int = ...) -> bool: ... + def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: Optional[int] = ...) -> bool: ... def close(self) -> None: ... SelectorEventLoop = _WindowsSelectorEventLoop if sys.version_info >= (3, 7): class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[events.AbstractEventLoop] + _loop_factory: ClassVar[Type[SelectorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[events.AbstractEventLoop] + _loop_factory: ClassVar[Type[ProactorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy else: class _WindowsDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[events.AbstractEventLoop] + _loop_factory: ClassVar[Type[SelectorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... DefaultEventLoopPolicy = _WindowsDefaultEventLoopPolicy diff --git a/python/helpers/typeshed/stdlib/3/asyncio/windows_utils.pyi b/python/helpers/typeshed/stdlib/3/asyncio/windows_utils.pyi index f29703f09cae..bf7c9380b266 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/windows_utils.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/windows_utils.pyi @@ -1,7 +1,13 @@ -from typing import Tuple, Callable, Optional +import sys +from typing import Tuple, Callable, Optional, Type, Protocol from types import TracebackType + +class _WarnFunction(Protocol): + def __call__(self, message: str, category: Type[Warning], source: PipeHandle): ... + + BUFSIZE: int PIPE: int STDOUT: int @@ -12,7 +18,10 @@ class PipeHandle: def __init__(self, handle: int) -> None: ... def __repr__(self) -> str: ... - def __del__(self) -> None: ... + if sys.version_info >= (3, 8): + def __del__(self, _warn: _WarnFunction = ...) -> None: ... + else: + def __del__(self) -> None: ... def __enter__(self) -> PipeHandle: ... def __exit__(self, t: Optional[type], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... @property diff --git a/python/helpers/typeshed/stdlib/3/builtins.pyi b/python/helpers/typeshed/stdlib/3/builtins.pyi index 811a3da31524..a61b2c029d5b 100644 --- a/python/helpers/typeshed/stdlib/3/builtins.pyi +++ b/python/helpers/typeshed/stdlib/3/builtins.pyi @@ -9,8 +9,12 @@ from typing import ( ItemsView, KeysView, ValuesView, ByteString, Optional, AnyStr, Type, Text, Protocol, ) -from abc import abstractmethod, ABCMeta +from abc import ABCMeta from ast import mod, AST +from io import ( + _OpenBinaryMode, _OpenTextMode, _OpenBinaryModeUpdating, _OpenBinaryModeWriting, _OpenBinaryModeReading, + TextIOWrapper, FileIO, BufferedRandom, BufferedReader, BufferedWriter +) from types import TracebackType, CodeType import sys @@ -291,6 +295,9 @@ _str_base = object +class _FormatMapMapping(Protocol): + def __getitem__(self, __key: str) -> Any: ... + class str(Sequence[str], _str_base): @overload def __init__(self, o: object = ...) -> None: ... @@ -308,7 +315,7 @@ class str(Sequence[str], _str_base): def expandtabs(self, tabsize: int = ...) -> str: ... def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def format(self, *args: object, **kwargs: object) -> str: ... - def format_map(self, map: Mapping[str, Any]) -> str: ... + def format_map(self, map: _FormatMapMapping) -> str: ... def index(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -329,6 +336,9 @@ class str(Sequence[str], _str_base): def lstrip(self, __chars: Optional[str] = ...) -> str: ... def partition(self, __sep: str) -> Tuple[str, str, str]: ... def replace(self, __old: str, __new: str, __count: int = ...) -> str: ... + if sys.version_info >= (3, 9): + def removeprefix(self, __prefix: str) -> str: ... + def removesuffix(self, __suffix: str) -> str: ... def rfind(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rindex(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rjust(self, __width: int, __fillchar: str = ...) -> str: ... @@ -412,6 +422,9 @@ class bytes(ByteString): def lstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... def partition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytes: ... + if sys.version_info >= (3, 9): + def removeprefix(self, __prefix: bytes) -> bytes: ... + def removesuffix(self, __suffix: bytes) -> bytes: ... def rfind(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... def rindex(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytes: ... @@ -498,6 +511,9 @@ class bytearray(MutableSequence[int], ByteString): def lower(self) -> bytearray: ... def lstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def partition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + if sys.version_info >= (3, 9): + def removeprefix(self, __prefix: bytes) -> bytearray: ... + def removesuffix(self, __suffix: bytes) -> bytearray: ... def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... def rfind(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rindex(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... @@ -965,12 +981,99 @@ def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(__number: Union[int, _SupportsIndex]) -> str: ... if sys.version_info >= (3, 6): - def open(file: Union[str, bytes, int, _PathLike[Any]], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., - errors: Optional[str] = ..., newline: Optional[str] = ..., closefd: bool = ..., - opener: Optional[Callable[[str, int], int]] = ...) -> IO[Any]: ... -def open(file: Union[str, bytes, int], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., - errors: Optional[str] = ..., newline: Optional[str] = ..., closefd: bool = ..., - opener: Optional[Callable[[str, int], int]] = ...) -> IO[Any]: ... + # Changed in version 3.6: Support added to accept objects implementing os.PathLike. + _OpenFile = Union[str, bytes, int, _PathLike[Any]] +else: + _OpenFile = Union[str, bytes, int] +_Opener = Callable[[str, int], int] + +# Text mode: always returns a TextIOWrapper +@overload +def open( + file: _OpenFile, + mode: _OpenTextMode = ..., + buffering: int = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., + closefd: bool = ..., + opener: Optional[_Opener] = ..., +) -> TextIOWrapper: ... + +# Unbuffered binary mode: returns a FileIO +@overload +def open( + file: _OpenFile, + mode: _OpenBinaryMode, + buffering: Literal[0], + encoding: None = ..., + errors: None = ..., + newline: None = ..., + closefd: bool = ..., + opener: Optional[_Opener] = ..., +) -> FileIO: ... + +# Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter +@overload +def open( + file: _OpenFile, + mode: _OpenBinaryModeUpdating, + buffering: Literal[-1, 1] = ..., + encoding: None = ..., + errors: None = ..., + newline: None = ..., + closefd: bool = ..., + opener: Optional[_Opener] = ..., +) -> BufferedRandom: ... +@overload +def open( + file: _OpenFile, + mode: _OpenBinaryModeWriting, + buffering: Literal[-1, 1] = ..., + encoding: None = ..., + errors: None = ..., + newline: None = ..., + closefd: bool = ..., + opener: Optional[_Opener] = ..., +) -> BufferedWriter: ... +@overload +def open( + file: _OpenFile, + mode: _OpenBinaryModeReading, + buffering: Literal[-1, 1] = ..., + encoding: None = ..., + errors: None = ..., + newline: None = ..., + closefd: bool = ..., + opener: Optional[_Opener] = ..., +) -> BufferedReader: ... + +# Buffering cannot be determined: fall back to BinaryIO +@overload +def open( + file: _OpenFile, + mode: _OpenBinaryMode, + buffering: int, + encoding: None = ..., + errors: None = ..., + newline: None = ..., + closefd: bool = ..., + opener: Optional[_Opener] = ..., +) -> BinaryIO: ... + +# Fallback if mode is not specified +@overload +def open( + file: _OpenFile, + mode: str, + buffering: int = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., + closefd: bool = ..., + opener: Optional[_Opener] = ..., +) -> IO[Any]: ... + def ord(__c: Union[Text, bytes]) -> int: ... class _Writer(Protocol): @@ -980,6 +1083,12 @@ def print( ) -> None: ... +_E = TypeVar("_E", contravariant=True) +_M = TypeVar("_M", contravariant=True) +class _SupportsPow2(Protocol[_E, _T_co]): + def __pow__(self, __other: _E) -> _T_co: ... +class _SupportsPow3(Protocol[_E, _M, _T_co]): + def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ... if sys.version_info >= (3, 8): @overload def pow(base: int, exp: int, mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative @@ -987,6 +1096,10 @@ if sys.version_info >= (3, 8): def pow(base: int, exp: int, mod: int) -> int: ... @overload def pow(base: float, exp: float, mod: None = ...) -> float: ... + @overload + def pow(base: _SupportsPow2[_E, _T_co], exp: _E) -> _T_co: ... + @overload + def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co: ... else: @overload def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative @@ -994,6 +1107,10 @@ else: def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... + @overload + def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... + @overload + def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M) -> _T_co: ... def quit(code: object = ...) -> NoReturn: ... @overload def reversed(__object: Sequence[_T]) -> Iterator[_T]: ... @@ -1027,6 +1144,16 @@ else: @overload def sum(__iterable: Iterable[_T], __start: _S) -> Union[_T, _S]: ... def vars(__object: Any = ...) -> Dict[str, Any]: ... +# 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 @@ -1104,10 +1231,10 @@ if sys.version_info >= (3, 5): value: Any class SyntaxError(_StandardError): msg: str - lineno: int + lineno: Optional[int] offset: Optional[int] text: Optional[str] - filename: str + filename: Optional[str] class SystemError(_StandardError): ... class TypeError(_StandardError): ... class ValueError(_StandardError): ... diff --git a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi index 0771620daad0..17309d3ca3fd 100644 --- a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi @@ -169,6 +169,9 @@ class UserString(Sequence[str]): @overload def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ... def partition(self, sep: str) -> Tuple[str, str, str]: ... + if sys.version_info >= (3, 9): + def removeprefix(self: _UserStringT, __prefix: Union[str, UserString]) -> _UserStringT: ... + def removesuffix(self: _UserStringT, __suffix: Union[str, UserString]) -> _UserStringT: ... def replace(self: _UserStringT, old: Union[str, UserString], new: Union[str, UserString], maxsplit: int = ...) -> _UserStringT: ... def rfind(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... def rindex(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... diff --git a/python/helpers/typeshed/stdlib/3/concurrent/futures/__init__.pyi b/python/helpers/typeshed/stdlib/3/concurrent/futures/__init__.pyi index 4439dcadb523..9dfe12bac79e 100644 --- a/python/helpers/typeshed/stdlib/3/concurrent/futures/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/concurrent/futures/__init__.pyi @@ -1,3 +1,18 @@ -from ._base import * # noqa: F403 -from .thread import * # noqa: F403 -from .process import * # noqa: F403 +import sys +from ._base import ( + FIRST_COMPLETED as FIRST_COMPLETED, + FIRST_EXCEPTION as FIRST_EXCEPTION, + ALL_COMPLETED as ALL_COMPLETED, + CancelledError as CancelledError, + TimeoutError as TimeoutError, + Future as Future, + Executor as Executor, + wait as wait, + as_completed as as_completed, +) +if sys.version_info >= (3, 8): + from ._base import InvalidStateError as InvalidStateError +if sys.version_info >= (3, 7): + from ._base import BrokenExecutor as BrokenExecutor +from .thread import ThreadPoolExecutor as ThreadPoolExecutor +from .process import ProcessPoolExecutor as ProcessPoolExecutor diff --git a/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi b/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi index 00ff41d76959..27caf7c3ccff 100644 --- a/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi +++ b/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi @@ -17,6 +17,8 @@ LOGGER: Logger class Error(Exception): ... class CancelledError(Error): ... class TimeoutError(Error): ... +if sys.version_info >= (3, 8): + class InvalidStateError(Error): ... if sys.version_info >= (3, 7): class BrokenExecutor(RuntimeError): ... diff --git a/python/helpers/typeshed/stdlib/3/concurrent/futures/process.pyi b/python/helpers/typeshed/stdlib/3/concurrent/futures/process.pyi index ca22879c02fe..960a59f50f0d 100644 --- a/python/helpers/typeshed/stdlib/3/concurrent/futures/process.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/email/errors.pyi b/python/helpers/typeshed/stdlib/3/email/errors.pyi index 77d9902cca20..73e0b800f343 100644 --- a/python/helpers/typeshed/stdlib/3/email/errors.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/email/feedparser.pyi b/python/helpers/typeshed/stdlib/3/email/feedparser.pyi index facfd438c500..8350d135dc86 100644 --- a/python/helpers/typeshed/stdlib/3/email/feedparser.pyi +++ b/python/helpers/typeshed/stdlib/3/email/feedparser.pyi @@ -13,5 +13,5 @@ class FeedParser: class BytesFeedParser: def __init__(self, _factory: Callable[[], Message] = ..., *, policy: Policy = ...) -> None: ... - def feed(self, data: str) -> None: ... + def feed(self, data: bytes) -> None: ... def close(self) -> Message: ... diff --git a/python/helpers/typeshed/stdlib/3/fcntl.pyi b/python/helpers/typeshed/stdlib/3/fcntl.pyi index b9df14753360..735deeaad8c2 100644 --- a/python/helpers/typeshed/stdlib/3/fcntl.pyi +++ b/python/helpers/typeshed/stdlib/3/fcntl.pyi @@ -111,7 +111,7 @@ def ioctl(__fd: FileDescriptorLike, def ioctl(__fd: FileDescriptorLike, __request: int, __arg: _ReadOnlyBuffer, - __mutate_flag: bool) -> bytes: ... + __mutate_flag: bool = ...) -> bytes: ... def flock(__fd: FileDescriptorLike, __operation: int) -> None: ... def lockf(__fd: FileDescriptorLike, __cmd: int, diff --git a/python/helpers/typeshed/stdlib/3/functools.pyi b/python/helpers/typeshed/stdlib/3/functools.pyi index 3b57064dc8df..beccc37a1f50 100644 --- a/python/helpers/typeshed/stdlib/3/functools.pyi +++ b/python/helpers/typeshed/stdlib/3/functools.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Generic, Dict, Iterable, Mapping, Optional, Sequence, Tuple, Type, TypeVar, NamedTuple, Union, overload +from typing import Any, Callable, Generic, Dict, Hashable, Iterable, Mapping, Optional, Sequence, Tuple, Type, TypeVar, NamedTuple, Union, overload _AnyCallable = Callable[..., Any] @@ -21,7 +21,7 @@ class _CacheInfo(NamedTuple): class _lru_cache_wrapper(Generic[_T]): __wrapped__: Callable[..., _T] - def __call__(self, *args: Any, **kwargs: Any) -> _T: ... + def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ... def cache_info(self) -> _CacheInfo: ... def cache_clear(self) -> None: ... @@ -86,6 +86,7 @@ if sys.version_info >= (3, 8): def register(self, cls: Any, method: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... @overload def register(self, cls: Any, method: Callable[..., _T]) -> Callable[..., _T]: ... + def __call__(self, *args: Any, **kwargs: Any) -> _T: ... class cached_property(Generic[_T]): func: Callable[[Any], _T] @@ -96,3 +97,17 @@ if sys.version_info >= (3, 8): @overload def __get__(self, instance: _S, owner: Optional[Type[Any]] = ...) -> _T: ... def __set_name__(self, owner: Type[Any], name: str) -> None: ... + +if sys.version_info >= (3, 9): + class TopologicalSorter(Generic[_T]): + def __init__(self, graph: Optional[Dict[_T, Iterable[_T]]] = ...) -> None: ... + def add(self, node: _T, *predecessors: _T) -> None: ... + def prepare(self) -> None: ... + def is_active(self) -> bool: ... + def done(self, *nodes: _T) -> None: ... + def get_ready(self) -> Tuple[_T, ...]: ... + def static_order(self) -> Iterable[_T]: ... + + class CycleError(ValueError): ... + + def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ... diff --git a/python/helpers/typeshed/stdlib/3/gettext.pyi b/python/helpers/typeshed/stdlib/3/gettext.pyi index ad1ba3c82a53..7c6062c48853 100644 --- a/python/helpers/typeshed/stdlib/3/gettext.pyi +++ b/python/helpers/typeshed/stdlib/3/gettext.pyi @@ -1,21 +1,28 @@ import sys -from typing import overload, Any, Container, IO, Iterable, Optional, Type, TypeVar +from typing import overload, Any, Container, IO, Iterable, Optional, Sequence, 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 __init__(self, fp: Optional[IO[str]] = ...) -> None: ... def _parse(self, fp: IO[str]) -> None: ... def add_fallback(self, fallback: NullTranslations) -> None: ... def gettext(self, message: str) -> str: ... def lgettext(self, message: str) -> str: ... - def ngettext(self, singular: str, plural: str, n: int) -> str: ... - def lngettext(self, singular: str, plural: str, n: int) -> str: ... - def pgettext(self, context: str, message: str) -> str: ... - def npgettext(self, context: str, msgid1: str, msgid2: str, n: int) -> str: ... + def ngettext(self, msgid1: str, msgid2: str, n: int) -> str: ... + def lngettext(self, msgid1: str, msgid2: str, n: int) -> str: ... + if sys.version_info >= (3, 8): + def pgettext(self, context: str, message: str) -> str: ... + def npgettext(self, context: str, msgid1: str, msgid2: str, n: int) -> str: ... def info(self) -> Any: ... def charset(self) -> Any: ... def output_charset(self) -> Any: ... @@ -25,38 +32,41 @@ class NullTranslations: class GNUTranslations(NullTranslations): LE_MAGIC: int BE_MAGIC: int + CONTEXT: str + VERSIONS: Sequence[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: ... -def dngettext(domain: str, singular: str, plural: str, n: int) -> str: ... -def ldngettext(domain: str, singular: str, plural: str, n: int) -> str: ... +def dngettext(domain: str, msgid1: str, msgid2: str, n: int) -> str: ... +def ldngettext(domain: str, msgid1: str, msgid2: str, n: int) -> str: ... def gettext(message: str) -> str: ... def lgettext(message: str) -> str: ... -def ngettext(singular: str, plural: str, n: int) -> str: ... -def lngettext(singular: str, plural: str, n: int) -> str: ... -def pgettext(context: str, message: str) -> str: ... -def dpgettext(domain: str, context: str, message: str) -> str: ... -def npgettext(context: str, msgid1: str, msgid2: str, n: int) -> str: ... -def dnpgettext(domain: str, context: str, msgid1: str, msgid2: str, n: int) -> str: ... +def ngettext(msgid1: str, msgid2: str, n: int) -> str: ... +def lngettext(msgid1: str, msgid2: str, n: int) -> str: ... +if sys.version_info >= (3, 8): + def pgettext(context: str, message: str) -> str: ... + def dpgettext(domain: str, context: str, message: str) -> str: ... + def npgettext(context: str, msgid1: str, msgid2: str, n: int) -> str: ... + def dnpgettext(domain: str, context: str, msgid1: str, msgid2: str, n: int) -> str: ... Catalog = translation diff --git a/python/helpers/typeshed/stdlib/3/hashlib.pyi b/python/helpers/typeshed/stdlib/3/hashlib.pyi index a0bc13cc7bd8..66e18179107e 100644 --- a/python/helpers/typeshed/stdlib/3/hashlib.pyi +++ b/python/helpers/typeshed/stdlib/3/hashlib.pyi @@ -19,9 +19,16 @@ class _Hash(object): def copy(self) -> _Hash: ... def digest(self) -> bytes: ... def hexdigest(self) -> str: ... - def update(self, arg: _DataType) -> None: ... + def update(self, __data: _DataType) -> None: ... -if sys.version_info >= (3, 8): +if sys.version_info >= (3, 9): + def md5(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha1(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha224(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha256(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha384(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha512(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... +elif sys.version_info >= (3, 8): def md5(string: _DataType = ...) -> _Hash: ... def sha1(string: _DataType = ...) -> _Hash: ... def sha224(string: _DataType = ...) -> _Hash: ... @@ -52,9 +59,9 @@ if sys.version_info >= (3, 6): def __init__(self, data: _DataType = ...) -> None: ... def copy(self) -> _VarLenHash: ... - def digest(self, length: int) -> bytes: ... - def hexdigest(self, length: int) -> str: ... - def update(self, arg: _DataType) -> None: ... + def digest(self, __length: int) -> bytes: ... + def hexdigest(self, __length: int) -> str: ... + def update(self, __data: _DataType) -> None: ... sha3_224 = _Hash sha3_256 = _Hash @@ -71,7 +78,10 @@ if sys.version_info >= (3, 6): PERSON_SIZE: int SALT_SIZE: int - def __init__(self, data: _DataType = ..., digest_size: int = ..., key: _DataType = ..., salt: _DataType = ..., person: _DataType = ..., fanout: int = ..., depth: int = ..., leaf_size: int = ..., node_offset: int = ..., node_depth: int = ..., inner_size: int = ..., last_node: bool = ...) -> None: ... + if sys.version_info >= (3, 9): + def __init__(self, __data: _DataType = ..., *, digest_size: int = ..., key: _DataType = ..., salt: _DataType = ..., person: _DataType = ..., fanout: int = ..., depth: int = ..., leaf_size: int = ..., node_offset: int = ..., node_depth: int = ..., inner_size: int = ..., last_node: bool = ..., usedforsecurity: bool = ...) -> None: ... + else: + def __init__(self, __data: _DataType = ..., *, digest_size: int = ..., key: _DataType = ..., salt: _DataType = ..., person: _DataType = ..., fanout: int = ..., depth: int = ..., leaf_size: int = ..., node_offset: int = ..., node_depth: int = ..., inner_size: int = ..., last_node: bool = ...) -> None: ... blake2b = _BlakeHash blake2s = _BlakeHash diff --git a/python/helpers/typeshed/stdlib/3/http/__init__.pyi b/python/helpers/typeshed/stdlib/3/http/__init__.pyi index 3abd978a5cf6..2c61bd9d7902 100644 --- a/python/helpers/typeshed/stdlib/3/http/__init__.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/http/server.pyi b/python/helpers/typeshed/stdlib/3/http/server.pyi index 8682b9c14981..fe9fc238409b 100644 --- a/python/helpers/typeshed/stdlib/3/http/server.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/importlib/machinery.pyi b/python/helpers/typeshed/stdlib/3/importlib/machinery.pyi index 746c5026c759..07521adb2bd3 100644 --- a/python/helpers/typeshed/stdlib/3/importlib/machinery.pyi +++ b/python/helpers/typeshed/stdlib/3/importlib/machinery.pyi @@ -1,10 +1,10 @@ import importlib.abc import types -from typing import Any, Callable, List, Optional, Sequence, Tuple +from typing import Any, Callable, List, Optional, Sequence, Tuple, Union # ModuleSpec is exported from this module, but for circular import # reasons exists in its own stub file (with Loader and ModuleType). -from _importlib_modulespec import ModuleSpec as ModuleSpec # Exported +from _importlib_modulespec import ModuleSpec as ModuleSpec, Loader # Exported class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): @@ -81,7 +81,17 @@ class WindowsRegistryFinder(importlib.abc.MetaPathFinder): target: Optional[types.ModuleType] = ...) -> Optional[ModuleSpec]: ... -class PathFinder(importlib.abc.MetaPathFinder): ... +class PathFinder: + @classmethod + def invalidate_caches(cls) -> None: ... + @classmethod + def find_spec(cls, fullname: str, + path: Optional[Sequence[Union[bytes, str]]] = ..., + target: Optional[types.ModuleType] = ...) -> Optional[ModuleSpec]: ... + @classmethod + def find_module(cls, fullname: str, + path: Optional[Sequence[Union[bytes, str]]] = ...) -> Optional[Loader]: ... + SOURCE_SUFFIXES: List[str] DEBUG_BYTECODE_SUFFIXES: List[str] diff --git a/python/helpers/typeshed/stdlib/3/io.pyi b/python/helpers/typeshed/stdlib/3/io.pyi index efc77b9704a2..41c484e73c98 100644 --- a/python/helpers/typeshed/stdlib/3/io.pyi +++ b/python/helpers/typeshed/stdlib/3/io.pyi @@ -1,12 +1,16 @@ from typing import ( - List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Type, Any, IO, Iterable + List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Type, Any, IO, Iterable, TypeVar ) import builtins import codecs import sys from mmap import mmap from types import TracebackType -from typing import TypeVar + +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal _bytearray_like = Union[bytearray, mmap] @@ -18,6 +22,30 @@ SEEK_END: int _T = TypeVar('_T', bound=IOBase) +_OpenTextMode = Literal[ + 'r', 'r+', '+r', 'rt', 'tr', 'rt+', 'r+t', '+rt', 'tr+', 't+r', '+tr', + 'w', 'w+', '+w', 'wt', 'tw', 'wt+', 'w+t', '+wt', 'tw+', 't+w', '+tw', + 'a', 'a+', '+a', 'at', 'ta', 'at+', 'a+t', '+at', 'ta+', 't+a', '+ta', + 'x', 'x+', '+x', 'xt', 'tx', 'xt+', 'x+t', '+xt', 'tx+', 't+x', '+tx', + 'U', 'rU', 'Ur', 'rtU', 'rUt', 'Urt', 'trU', 'tUr', 'Utr', +] +_OpenBinaryModeUpdating = Literal[ + 'rb+', 'r+b', '+rb', 'br+', 'b+r', '+br', + 'wb+', 'w+b', '+wb', 'bw+', 'b+w', '+bw', + 'ab+', 'a+b', '+ab', 'ba+', 'b+a', '+ba', + 'xb+', 'x+b', '+xb', 'bx+', 'b+x', '+bx', +] +_OpenBinaryModeWriting = Literal[ + 'wb', 'bw', + 'ab', 'ba', + 'xb', 'bx', +] +_OpenBinaryModeReading = Literal[ + 'rb', 'br', + 'rbU', 'rUb', 'Urb', 'brU', 'bUr', 'Ubr', +] +_OpenBinaryMode = Union[_OpenBinaryModeUpdating, _OpenBinaryModeReading, _OpenBinaryModeWriting] + open = builtins.open if sys.version_info >= (3, 8): @@ -44,7 +72,7 @@ class IOBase: def truncate(self, __size: Optional[int] = ...) -> int: ... def writable(self) -> bool: ... def writelines(self, __lines: Iterable[Union[bytes, bytearray]]) -> None: ... - def readline(self, __size: int = ...) -> bytes: ... + def readline(self, __size: Optional[int] = ...) -> bytes: ... def __del__(self) -> None: ... @property def closed(self) -> bool: ... @@ -65,10 +93,10 @@ class BufferedIOBase(IOBase): def read(self, __size: Optional[int] = ...) -> bytes: ... def read1(self, __size: int = ...) -> bytes: ... - -class FileIO(RawIOBase): +class FileIO(RawIOBase, BinaryIO): mode: str - name: Union[int, str] + # Technically this is whatever is passed in as file, either a str, a bytes, or an int. + name: Union[int, str] # type: ignore def __init__( self, file: Union[str, bytes, int], @@ -76,63 +104,46 @@ class FileIO(RawIOBase): closefd: bool = ..., opener: Optional[Callable[[Union[int, str], str], int]] = ... ) -> None: ... + def write(self, __b: bytes) -> int: ... + def read(self, __size: int = ...) -> bytes: ... + def __enter__(self: _T) -> _T: ... -# TODO should extend from BufferedIOBase -class BytesIO(BinaryIO): +class BytesIO(BufferedIOBase, BinaryIO): def __init__(self, initial_bytes: bytes = ...) -> None: ... # BytesIO does not contain a "name" field. This workaround is necessary # to allow BytesIO sub-classes to add this field, as it is defined # as a read-only property on IO[]. name: Any + def __enter__(self: _T) -> _T: ... def getvalue(self) -> bytes: ... def getbuffer(self) -> memoryview: ... - # copied from IOBase - def __iter__(self) -> Iterator[bytes]: ... - def __next__(self) -> bytes: ... - def __enter__(self) -> BytesIO: ... - def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ..., - traceback: Optional[TracebackType] = ...) -> Optional[bool]: ... - def close(self) -> None: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def readable(self) -> bool: ... - def readlines(self, __size: int = ...) -> List[bytes]: ... - def seek(self, __pos: int, __whence: int = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, __size: Optional[int] = ...) -> int: ... - def writable(self) -> bool: ... - # TODO should be the next line instead - # def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ... - def writelines(self, __lines: Any) -> None: ... - def readline(self, __size: Optional[int] = ...) -> bytes: ... - def __del__(self) -> None: ... - closed: bool - # copied from BufferedIOBase - def detach(self) -> RawIOBase: ... - def readinto(self, __buffer: _bytearray_like) -> int: ... - def write(self, __b: Union[bytes, bytearray]) -> int: ... - def readinto1(self, __buffer: _bytearray_like) -> int: ... - def read(self, __size: Optional[int] = ...) -> bytes: ... if sys.version_info >= (3, 7): def read1(self, __size: Optional[int] = ...) -> bytes: ... else: - def read1(self, __size: Optional[int]) -> bytes: ... + def read1(self, __size: Optional[int]) -> bytes: ... # type: ignore -class BufferedReader(BufferedIOBase): +class BufferedReader(BufferedIOBase, BinaryIO): + def __enter__(self: _T) -> _T: ... def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... def peek(self, __size: int = ...) -> bytes: ... + if sys.version_info >= (3, 7): + def read1(self, __size: int = ...) -> bytes: ... + else: + def read1(self, __size: int) -> bytes: ... # type: ignore -class BufferedWriter(BufferedIOBase): +class BufferedWriter(BufferedIOBase, BinaryIO): + def __enter__(self: _T) -> _T: ... def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... - def flush(self) -> None: ... def write(self, __buffer: Union[bytes, bytearray]) -> int: ... class BufferedRandom(BufferedReader, BufferedWriter): + def __enter__(self: _T) -> _T: ... def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... def seek(self, __target: int, __whence: int = ...) -> int: ... - def tell(self) -> int: ... + if sys.version_info >= (3, 7): + def read1(self, __size: int = ...) -> bytes: ... + else: + def read1(self, __size: int) -> bytes: ... # type: ignore class BufferedRWPair(BufferedIOBase): def __init__(self, reader: RawIOBase, writer: RawIOBase, @@ -145,23 +156,16 @@ class TextIOBase(IOBase): newlines: Union[str, Tuple[str, ...], None] def __iter__(self) -> Iterator[str]: ... # type: ignore def __next__(self) -> str: ... # type: ignore - def detach(self) -> IOBase: ... - def write(self, s: str) -> int: ... + def detach(self) -> BinaryIO: ... + def write(self, __s: str) -> int: ... def writelines(self, __lines: List[str]) -> None: ... # type: ignore - def readline(self, size: int = ...) -> str: ... # type: ignore + def readline(self, __size: int = ...) -> str: ... # type: ignore def readlines(self, __hint: int = ...) -> List[str]: ... # type: ignore - def read(self, size: Optional[int] = ...) -> str: ... - def seek(self, offset: int, whence: int = ...) -> int: ... + def read(self, __size: Optional[int] = ...) -> str: ... def tell(self) -> int: ... -# TODO should extend from TextIOBase -class TextIOWrapper(TextIO): +class TextIOWrapper(TextIOBase, TextIO): line_buffering: bool - # TODO uncomment after fixing mypy about using write_through - # def __init__(self, buffer: IO[bytes], encoding: str = ..., - # errors: Optional[str] = ..., newline: Optional[str] = ..., - # line_buffering: bool = ..., write_through: bool = ...) \ - # -> None: ... def __init__( self, buffer: IO[bytes], @@ -171,46 +175,36 @@ class TextIOWrapper(TextIO): line_buffering: bool = ..., write_through: bool = ... ) -> None: ... - # copied from IOBase - def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ..., - traceback: Optional[TracebackType] = ...) -> Optional[bool]: ... - def close(self) -> None: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def readable(self) -> bool: ... - def readlines(self, __hint: int = ...) -> List[str]: ... - def seekable(self) -> bool: ... - def truncate(self, __size: Optional[int] = ...) -> int: ... - def writable(self) -> bool: ... - # TODO should be the next line instead - # def writelines(self, lines: List[str]) -> None: ... - def writelines(self, __lines: Any) -> None: ... - def __del__(self) -> None: ... + @property + def buffer(self) -> BinaryIO: ... + if sys.version_info >= (3, 7): + def reconfigure( + self, + *, + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., + line_buffering: Optional[bool] = ..., + write_through: Optional[bool] = ... + ) -> None: ... closed: bool - # copied from TextIOBase - encoding: str - errors: Optional[str] - newlines: Union[str, Tuple[str, ...], None] - def __iter__(self) -> Iterator[str]: ... - def __next__(self) -> str: ... - def __enter__(self) -> TextIO: ... - def detach(self) -> IOBase: ... - def write(self, __text: str) -> int: ... - def readline(self, __size: int = ...) -> str: ... - def read(self, __size: Optional[int] = ...) -> str: ... + # These are inherited from TextIOBase, but must exist in the stub to satisfy mypy. + def __enter__(self: _T) -> _T: ... + def __iter__(self) -> Iterator[str]: ... # type: ignore + def __next__(self) -> str: ... # type: ignore + def writelines(self, __lines: List[str]) -> None: ... # type: ignore + def readline(self, __size: int = ...) -> str: ... # type: ignore + def readlines(self, __hint: int = ...) -> List[str]: ... # type: ignore def seek(self, __cookie: int, __whence: int = ...) -> int: ... - 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 # as a read-only property on IO[]. name: Any def getvalue(self) -> str: ... - def __enter__(self) -> StringIO: ... class IncrementalNewlineDecoder(codecs.IncrementalDecoder): def __init__(self, decoder: Optional[codecs.IncrementalDecoder], diff --git a/python/helpers/typeshed/stdlib/3/ipaddress.pyi b/python/helpers/typeshed/stdlib/3/ipaddress.pyi index daeb8e96f9e2..5c7d9a2db225 100644 --- a/python/helpers/typeshed/stdlib/3/ipaddress.pyi +++ b/python/helpers/typeshed/stdlib/3/ipaddress.pyi @@ -86,7 +86,7 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): def max_prefixlen(self) -> int: ... @property def num_addresses(self) -> int: ... - def overlaps(self: _T, other: _T) -> bool: ... + def overlaps(self, other: _BaseNetwork) -> bool: ... @property def prefixlen(self) -> int: ... if sys.version_info >= (3, 7): diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/connection.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/connection.pyi index cd03b7cb96f0..0fb97b107a9f 100644 --- a/python/helpers/typeshed/stdlib/3/multiprocessing/connection.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/os/__init__.pyi b/python/helpers/typeshed/stdlib/3/os/__init__.pyi index 7e8eab6dcbd7..dfc542567826 100644 --- a/python/helpers/typeshed/stdlib/3/os/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/os/__init__.pyi @@ -73,13 +73,14 @@ if sys.platform != 'win32': SCHED_RR: int # some flavors of Unix SCHED_RESET_ON_FORK: int # some flavors of Unix -RTLD_LAZY: int -RTLD_NOW: int -RTLD_GLOBAL: int -RTLD_LOCAL: int -RTLD_NODELETE: int -RTLD_NOLOAD: int -RTLD_DEEPBIND: int +if sys.platform != "win32": + RTLD_LAZY: int + RTLD_NOW: int + RTLD_GLOBAL: int + RTLD_LOCAL: int + RTLD_NODELETE: int + RTLD_NOLOAD: int + RTLD_DEEPBIND: int SEEK_SET: int SEEK_CUR: int @@ -151,7 +152,8 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): def __len__(self) -> int: ... environ: _Environ[str] -environb: _Environ[bytes] +if sys.platform != "win32": + environb: _Environ[bytes] if sys.platform != 'win32': confstr_names: Dict[str, int] @@ -214,6 +216,8 @@ class stat_result: st_ctime_ns: int # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) in nanoseconds if sys.version_info >= (3, 8) and sys.platform == "win32": st_reparse_tag: int + if sys.version_info >= (3, 5) and sys.platform == "win32": + st_file_attributes: int def __getitem__(self, i: int) -> int: ... @@ -365,12 +369,15 @@ if sys.platform != 'win32': def getenv(key: Text) -> Optional[str]: ... @overload def getenv(key: Text, default: _T) -> Union[str, _T]: ... -@overload -def getenvb(key: bytes) -> Optional[bytes]: ... -@overload -def getenvb(key: bytes, default: _T = ...) -> Union[bytes, _T]: ... + +if sys.platform != "win32": + @overload + def getenvb(key: bytes) -> Optional[bytes]: ... + @overload + def getenvb(key: bytes, default: _T = ...) -> Union[bytes, _T]: ... def putenv(__name: Union[bytes, Text], __value: Union[bytes, Text]) -> None: ... -def unsetenv(__name: Union[bytes, Text]) -> None: ... +if sys.platform != "win32": + def unsetenv(__name: Union[bytes, Text]) -> None: ... # Return IO or TextIO def fdopen(fd: int, mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., @@ -441,7 +448,9 @@ def access( follow_symlinks: bool = ..., ) -> bool: ... def chdir(path: _FdOrPathType) -> None: ... -def fchdir(fd: int) -> None: ... + +if sys.platform != "win32": + def fchdir(fd: int) -> None: ... def getcwd() -> str: ... def getcwdb() -> bytes: ... def chmod(path: _FdOrPathType, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... @@ -468,11 +477,11 @@ def mkdir(path: _PathType, mode: int = ..., *, dir_fd: Optional[int] = ...) -> N if sys.platform != 'win32': def mkfifo(path: _PathType, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only def makedirs(name: _PathType, mode: int = ..., exist_ok: bool = ...) -> None: ... -def mknod(path: _PathType, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... -def major(__device: int) -> int: ... -def minor(__device: int) -> int: ... -def makedev(__major: int, __minor: int) -> int: ... -if sys.platform != 'win32': +if sys.platform != "win32": + def mknod(path: _PathType, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... + def major(__device: int) -> int: ... + def minor(__device: int) -> int: ... + def makedev(__major: int, __minor: int) -> int: ... def pathconf(path: _FdOrPathType, name: Union[str, int]) -> int: ... # Unix only if sys.version_info >= (3, 6): def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ... @@ -607,9 +616,14 @@ def popen(cmd: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ... def spawnl(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnle(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig -def spawnv(mode: int, file: _PathType, args: List[Union[bytes, Text]]) -> int: ... -def spawnve(mode: int, file: _PathType, args: List[Union[bytes, Text]], - env: _ExecEnv) -> int: ... +if sys.platform != "win32": + def spawnv(mode: int, file: _PathType, args: List[Union[bytes, Text]]) -> int: ... + def spawnve(mode: int, file: _PathType, args: List[Union[bytes, Text]], + env: _ExecEnv) -> int: ... +else: + def spawnv(__mode: int, __path: _PathType, __argv: List[Union[bytes, Text]]) -> int: ... + def spawnve(__mode: int, __path: _PathType, __argv: List[Union[bytes, Text]], + __env: _ExecEnv) -> int: ... def system(command: _PathType) -> int: ... def times() -> times_result: ... def waitpid(__pid: int, __options: int) -> Tuple[int, int]: ... @@ -660,7 +674,7 @@ if sys.version_info >= (3, 6): def getrandom(size: int, flags: int = ...) -> bytes: ... def urandom(__size: int) -> bytes: ... -if sys.version_info >= (3, 7): +if sys.version_info >= (3, 7) and sys.platform != "win32": def register_at_fork( *, before: Optional[Callable[..., Any]] = ..., diff --git a/python/helpers/typeshed/stdlib/3/os/path.pyi b/python/helpers/typeshed/stdlib/3/os/path.pyi index 73c14de7052d..f1496d13a605 100644 --- a/python/helpers/typeshed/stdlib/3/os/path.pyi +++ b/python/helpers/typeshed/stdlib/3/os/path.pyi @@ -5,6 +5,7 @@ import os import sys from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional +from genericpath import exists as exists _T = TypeVar('_T') @@ -100,10 +101,6 @@ elif sys.version_info >= (3, 5): # So, fall back to Any def commonprefix(m: Sequence[_PathType]) -> Any: ... -if sys.version_info >= (3, 3): - def exists(path: Union[_PathType, int]) -> bool: ... -else: - def exists(path: _PathType) -> bool: ... def lexists(path: _PathType) -> bool: ... # These return float if os.stat_float_times() == True, @@ -170,8 +167,8 @@ else: def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -if sys.platform == 'win32': - def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated +if sys.version_info < (3, 7) and sys.platform == 'win32': + def splitunc(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated if sys.version_info < (3,): def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/pathlib.pyi b/python/helpers/typeshed/stdlib/3/pathlib.pyi index b470d1f0dfc0..b76f2ec5b938 100644 --- a/python/helpers/typeshed/stdlib/3/pathlib.pyi +++ b/python/helpers/typeshed/stdlib/3/pathlib.pyi @@ -1,4 +1,6 @@ -from typing import Any, Generator, IO, Optional, Sequence, Tuple, Type, TypeVar, Union, List +from io import _OpenBinaryMode, _OpenTextMode +from typing import (Any, BinaryIO, Generator, IO, List, Optional, Sequence, + TextIO, Tuple, Type, TypeVar, Union, overload) from types import TracebackType import os import sys @@ -43,12 +45,16 @@ class PurePath(_PurePathBase): def as_uri(self) -> str: ... def is_absolute(self) -> bool: ... def is_reserved(self) -> bool: ... + if sys.version_info >= (3, 9): + def is_relative_to(self, *other: Union[str, os.PathLike[str]]) -> bool: ... def match(self, path_pattern: str) -> bool: ... if sys.version_info < (3, 6): def relative_to(self: _P, *other: Union[str, PurePath]) -> _P: ... else: def relative_to(self: _P, *other: Union[str, os.PathLike[str]]) -> _P: ... def with_name(self: _P, name: str) -> _P: ... + if sys.version_info >= (3, 9): + def with_stem(self: _P, stem: str) -> _P: ... def with_suffix(self: _P, suffix: str) -> _P: ... if sys.version_info < (3, 6): def joinpath(self: _P, *other: Union[str, PurePath]) -> _P: ... @@ -93,15 +99,24 @@ class Path(PurePath): else: def mkdir(self, mode: int = ..., parents: bool = ..., exist_ok: bool = ...) -> None: ... - def open(self, mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., errors: Optional[str] = ..., + @overload + def open(self, mode: _OpenTextMode = ..., buffering: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., + newline: Optional[str] = ...) -> TextIO: ... + @overload + def open(self, mode: _OpenBinaryMode, buffering: int = ..., encoding: None = ..., errors: None = ..., + newline: None = ...) -> BinaryIO: ... + @overload + def open(self, mode: str, buffering: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ...) -> IO[Any]: ... def owner(self) -> str: ... + if sys.version_info >= (3, 9): + def readlink(self: _P) -> _P: ... 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/python/helpers/typeshed/stdlib/3/queue.pyi b/python/helpers/typeshed/stdlib/3/queue.pyi index 9647faf4c0d3..ba995e743dee 100644 --- a/python/helpers/typeshed/stdlib/3/queue.pyi +++ b/python/helpers/typeshed/stdlib/3/queue.pyi @@ -3,7 +3,7 @@ # NOTE: These are incomplete! from threading import Condition, Lock -from typing import Any, Deque, TypeVar, Generic, Optional +from typing import Any, TypeVar, Generic, Optional import sys _T = TypeVar('_T') @@ -19,8 +19,8 @@ class Queue(Generic[_T]): not_full: Condition # undocumented all_tasks_done: Condition # undocumented unfinished_tasks: int # undocumented + queue: Any # undocumented - queue: Deque[Any] # undocumented def __init__(self, maxsize: int = ...) -> None: ... def _init(self, maxsize: int) -> None: ... def empty(self) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/3/selectors.pyi b/python/helpers/typeshed/stdlib/3/selectors.pyi index 777874d78ef1..765f4716358a 100644 --- a/python/helpers/typeshed/stdlib/3/selectors.pyi +++ b/python/helpers/typeshed/stdlib/3/selectors.pyi @@ -1,8 +1,9 @@ # Stubs for selector # See https://docs.python.org/3/library/selectors.html +import sys from abc import ABCMeta, abstractmethod -from typing import Any, List, Mapping, NamedTuple, Optional, Protocol, Tuple, Union +from typing import Any, List, Mapping, NamedTuple, Optional, Tuple from _types import FileDescriptor, FileDescriptorLike _EventMask = int @@ -45,18 +46,20 @@ class SelectSelector(BaseSelector): def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... -class PollSelector(BaseSelector): - def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... - def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... - def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... +if sys.platform != "win32": -class EpollSelector(BaseSelector): - def fileno(self) -> int: ... - def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... - def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... - def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... + class PollSelector(BaseSelector): + def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... + def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... + def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... + + class EpollSelector(BaseSelector): + def fileno(self) -> int: ... + def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... + def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... + def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class DevpollSelector(BaseSelector): def fileno(self) -> int: ... diff --git a/python/helpers/typeshed/stdlib/3/signal.pyi b/python/helpers/typeshed/stdlib/3/signal.pyi index 3180bd5e175e..26fa36f5b23b 100644 --- a/python/helpers/typeshed/stdlib/3/signal.pyi +++ b/python/helpers/typeshed/stdlib/3/signal.pyi @@ -5,53 +5,66 @@ from enum import IntEnum from typing import Any, Callable, Tuple, Union, Optional, Iterable, Set from types import FrameType -class ItimerError(IOError): ... +if sys.platform != "win32": + class ItimerError(IOError): ... -ITIMER_PROF: int -ITIMER_REAL: int -ITIMER_VIRTUAL: int + ITIMER_PROF: int + ITIMER_REAL: int + ITIMER_VIRTUAL: int NSIG: int class Signals(IntEnum): SIGABRT: int - SIGALRM: int - SIGBREAK: int # Windows - SIGBUS: int - SIGCHLD: int - SIGCLD: int - SIGCONT: int + if sys.platform != "win32": + SIGALRM: int + if sys.platform == "win32": + SIGBREAK: int + if sys.platform != "win32": + SIGBUS: int + SIGCHLD: int + if sys.platform != "darwin" and sys.platform != "win32": + SIGCLD: int + if sys.platform != "win32": + SIGCONT: int SIGEMT: int SIGFPE: int - SIGHUP: int + if sys.platform != "win32": + SIGHUP: int SIGILL: int SIGINFO: int SIGINT: int - SIGIO: int - SIGIOT: int - SIGKILL: int - SIGPIPE: int - SIGPOLL: int - SIGPROF: int - SIGPWR: int - SIGQUIT: int - SIGRTMAX: int - SIGRTMIN: int + if sys.platform != "win32": + SIGIO: int + SIGIOT: int + SIGKILL: int + SIGPIPE: int + if sys.platform != "darwin" and sys.platform != "win32": + SIGPOLL: int + SIGPWR: int + if sys.platform != "win32": + SIGPROF: int + SIGQUIT: int + if sys.platform != "darwin" and sys.platform != "win32": + SIGRTMAX: int + SIGRTMIN: int SIGSEGV: int - SIGSTOP: int - SIGSYS: int + if sys.platform != "win32": + SIGSTOP: int + SIGSYS: int SIGTERM: int - SIGTRAP: int - SIGTSTP: int - SIGTTIN: int - SIGTTOU: int - SIGURG: int - SIGUSR1: int - SIGUSR2: int - SIGVTALRM: int - SIGWINCH: int - SIGXCPU: int - SIGXFSZ: int + if sys.platform != "win32": + SIGTRAP: int + SIGTSTP: int + SIGTTIN: int + SIGTTOU: int + SIGURG: int + SIGUSR1: int + SIGUSR2: int + SIGVTALRM: int + SIGWINCH: int + SIGXCPU: int + SIGXFSZ: int class Handlers(IntEnum): SIG_DFL: int @@ -60,94 +73,113 @@ class Handlers(IntEnum): SIG_DFL = Handlers.SIG_DFL SIG_IGN = Handlers.SIG_IGN -class Sigmasks(IntEnum): - SIG_BLOCK: int - SIG_UNBLOCK: int - SIG_SETMASK: int +if sys.platform != "win32": + class Sigmasks(IntEnum): + SIG_BLOCK: int + SIG_UNBLOCK: int + SIG_SETMASK: int -SIG_BLOCK = Sigmasks.SIG_BLOCK -SIG_UNBLOCK = Sigmasks.SIG_UNBLOCK -SIG_SETMASK = Sigmasks.SIG_SETMASK + SIG_BLOCK = Sigmasks.SIG_BLOCK + SIG_UNBLOCK = Sigmasks.SIG_UNBLOCK + SIG_SETMASK = Sigmasks.SIG_SETMASK _SIGNUM = Union[int, Signals] _HANDLER = Union[Callable[[Signals, FrameType], None], int, Handlers, None] SIGABRT: Signals -SIGALRM: Signals -SIGBREAK: Signals # Windows -SIGBUS: Signals -SIGCHLD: Signals -SIGCLD: Signals -SIGCONT: Signals +if sys.platform != "win32": + SIGALRM: Signals +if sys.platform == "win32": + SIGBREAK: Signals +if sys.platform != "win32": + SIGBUS: Signals + SIGCHLD: Signals +if sys.platform != "darwin" and sys.platform != "win32": + SIGCLD: Signals +if sys.platform != "win32": + SIGCONT: Signals SIGEMT: Signals SIGFPE: Signals -SIGHUP: Signals +if sys.platform != "win32": + SIGHUP: Signals SIGILL: Signals SIGINFO: Signals SIGINT: Signals -SIGIO: Signals -SIGIOT: Signals -SIGKILL: Signals -SIGPIPE: Signals -SIGPOLL: Signals -SIGPROF: Signals -SIGPWR: Signals -SIGQUIT: Signals -SIGRTMAX: Signals -SIGRTMIN: Signals +if sys.platform != "win32": + SIGIO: Signals + SIGIOT: Signals + SIGKILL: Signals + SIGPIPE: Signals +if sys.platform != "darwin" and sys.platform != "win32": + SIGPOLL: Signals + SIGPWR: Signals +if sys.platform != "win32": + SIGPROF: Signals + SIGQUIT: Signals +if sys.platform != "darwin" and sys.platform != "win32": + SIGRTMAX: Signals + SIGRTMIN: Signals SIGSEGV: Signals -SIGSTOP: Signals -SIGSYS: Signals +if sys.platform != "win32": + SIGSTOP: Signals + SIGSYS: Signals SIGTERM: Signals -SIGTRAP: Signals -SIGTSTP: Signals -SIGTTIN: Signals -SIGTTOU: Signals -SIGURG: Signals -SIGUSR1: Signals -SIGUSR2: Signals -SIGVTALRM: Signals -SIGWINCH: Signals -SIGXCPU: Signals -SIGXFSZ: Signals +if sys.platform != "win32": + SIGTRAP: Signals + SIGTSTP: Signals + SIGTTIN: Signals + SIGTTOU: Signals + SIGURG: Signals + SIGUSR1: Signals + SIGUSR2: Signals + SIGVTALRM: Signals + SIGWINCH: Signals + SIGXCPU: Signals + SIGXFSZ: Signals -# Windows -CTRL_C_EVENT: int -CTRL_BREAK_EVENT: int +if sys.platform == "win32": + CTRL_C_EVENT: int + CTRL_BREAK_EVENT: int -class struct_siginfo(Tuple[int, int, int, int, int, int, int]): - def __init__(self, sequence: Iterable[int]) -> None: ... - @property - def si_signo(self) -> int: ... - @property - def si_code(self) -> int: ... - @property - def si_errno(self) -> int: ... - @property - def si_pid(self) -> int: ... - @property - def si_uid(self) -> int: ... - @property - def si_status(self) -> int: ... - @property - def si_band(self) -> int: ... +if sys.platform != "win32": + class struct_siginfo(Tuple[int, int, int, int, int, int, int]): + def __init__(self, sequence: Iterable[int]) -> None: ... + @property + def si_signo(self) -> int: ... + @property + def si_code(self) -> int: ... + @property + def si_errno(self) -> int: ... + @property + def si_pid(self) -> int: ... + @property + def si_uid(self) -> int: ... + @property + def si_status(self) -> int: ... + @property + def si_band(self) -> int: ... -def alarm(__seconds: int) -> int: ... +if sys.platform != "win32": + def alarm(__seconds: int) -> int: ... def default_int_handler(signum: int, frame: FrameType) -> None: ... -def getitimer(__which: int) -> Tuple[float, float]: ... +if sys.platform != "win32": + def getitimer(__which: int) -> Tuple[float, float]: ... def getsignal(__signalnum: _SIGNUM) -> _HANDLER: ... if sys.version_info >= (3, 8): def strsignal(__signalnum: _SIGNUM) -> Optional[str]: ... def valid_signals() -> Set[Signals]: ... def raise_signal(__signalnum: _SIGNUM) -> None: ... -def pause() -> None: ... -def pthread_kill(__thread_id: int, __signalnum: int) -> None: ... -def pthread_sigmask(__how: int, __mask: Iterable[int]) -> Set[_SIGNUM]: ... +if sys.platform != "win32": + def pause() -> None: ... + def pthread_kill(__thread_id: int, __signalnum: int) -> None: ... + def pthread_sigmask(__how: int, __mask: Iterable[int]) -> Set[_SIGNUM]: ... def set_wakeup_fd(fd: int) -> int: ... -def setitimer(__which: int, __seconds: float, __interval: float = ...) -> Tuple[float, float]: ... -def siginterrupt(__signalnum: int, __flag: bool) -> None: ... +if sys.platform != "win32": + def setitimer(__which: int, __seconds: float, __interval: float = ...) -> Tuple[float, float]: ... + def siginterrupt(__signalnum: int, __flag: bool) -> None: ... def signal(__signalnum: _SIGNUM, __handler: _HANDLER) -> _HANDLER: ... -def sigpending() -> Any: ... -def sigtimedwait(sigset: Iterable[int], timeout: float) -> Optional[struct_siginfo]: ... -def sigwait(__sigset: Iterable[int]) -> _SIGNUM: ... -def sigwaitinfo(sigset: Iterable[int]) -> struct_siginfo: ... +if sys.platform != "win32": + def sigpending() -> Any: ... + def sigtimedwait(sigset: Iterable[int], timeout: float) -> Optional[struct_siginfo]: ... + def sigwait(__sigset: Iterable[int]) -> _SIGNUM: ... + def sigwaitinfo(sigset: Iterable[int]) -> struct_siginfo: ... diff --git a/python/helpers/typeshed/stdlib/3/socketserver.pyi b/python/helpers/typeshed/stdlib/3/socketserver.pyi index 001e3fad915b..3f57efbe9766 100644 --- a/python/helpers/typeshed/stdlib/3/socketserver.pyi +++ b/python/helpers/typeshed/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 @@ -63,23 +63,24 @@ if sys.platform != 'win32': RequestHandlerClass: Callable[..., BaseRequestHandler], bind_and_activate: bool = ...) -> None: ... -class ForkingMixIn: - timeout: Optional[float] # undocumented - active_children: Optional[List[int]] # undocumented - max_children: int # undocumented - if sys.version_info >= (3, 7): - block_on_close: bool - if sys.version_info >= (3, 6): - def collect_children(self, *, blocking: bool = ...) -> None: ... # undocumented - else: - def collect_children(self) -> None: ... # undocumented - def handle_timeout(self) -> None: ... # undocumented - if sys.version_info >= (3, 3): - def service_actions(self) -> None: ... # undocumented - def process_request(self, request: bytes, - client_address: Tuple[str, int]) -> None: ... - if sys.version_info >= (3, 6): - def server_close(self) -> None: ... +if sys.platform != "win32": + class ForkingMixIn: + timeout: Optional[float] # undocumented + active_children: Optional[List[int]] # undocumented + max_children: int # undocumented + if sys.version_info >= (3, 7): + block_on_close: bool + if sys.version_info >= (3, 6): + def collect_children(self, *, blocking: bool = ...) -> None: ... # undocumented + else: + def collect_children(self) -> None: ... # undocumented + def handle_timeout(self) -> None: ... # undocumented + if sys.version_info >= (3, 3): + def service_actions(self) -> None: ... # undocumented + def process_request(self, request: bytes, + client_address: Tuple[str, int]) -> None: ... + if sys.version_info >= (3, 6): + def server_close(self) -> None: ... class ThreadingMixIn: daemon_threads: bool @@ -92,8 +93,9 @@ class ThreadingMixIn: if sys.version_info >= (3, 6): def server_close(self) -> None: ... -class ForkingTCPServer(ForkingMixIn, TCPServer): ... -class ForkingUDPServer(ForkingMixIn, UDPServer): ... +if sys.platform != "win32": + class ForkingTCPServer(ForkingMixIn, TCPServer): ... + class ForkingUDPServer(ForkingMixIn, UDPServer): ... class ThreadingTCPServer(ThreadingMixIn, TCPServer): ... class ThreadingUDPServer(ThreadingMixIn, UDPServer): ... if sys.platform != 'win32': @@ -118,9 +120,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/python/helpers/typeshed/stdlib/3/statistics.pyi b/python/helpers/typeshed/stdlib/3/statistics.pyi index 5041933c4985..f2165f0ce9c0 100644 --- a/python/helpers/typeshed/stdlib/3/statistics.pyi +++ b/python/helpers/typeshed/stdlib/3/statistics.pyi @@ -3,12 +3,20 @@ 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, Hashable _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) + +# Used in mode, multimode +_HashableT = TypeVar("_HashableT", bound=Hashable) + class StatisticsError(ValueError): ... if sys.version_info >= (3, 8): @@ -18,12 +26,12 @@ 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: ... +def mode(data: Iterable[_HashableT]) -> _HashableT: ... if sys.version_info >= (3, 8): - def multimode(data: Iterable[_T]) -> List[_T]: ... + def multimode(data: Iterable[_HashableT]) -> List[_HashableT]: ... def pstdev(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ... def pvariance(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ... if sys.version_info >= (3, 8): @@ -52,6 +60,8 @@ if sys.version_info >= (3, 8): def inv_cdf(self, p: float) -> float: ... def overlap(self, other: NormalDist) -> float: ... def quantiles(self, n: int = ...) -> List[float]: ... + if sys.version_info >= (3, 9): + def zscore(self, x: float) -> float: ... def __add__(self, x2: Union[float, NormalDist]) -> NormalDist: ... def __sub__(self, x2: Union[float, NormalDist]) -> NormalDist: ... def __mul__(self, x2: float) -> NormalDist: ... diff --git a/python/helpers/typeshed/stdlib/3/subprocess.pyi b/python/helpers/typeshed/stdlib/3/subprocess.pyi index 12ef94d3dfa1..edd74d76a9f4 100644 --- a/python/helpers/typeshed/stdlib/3/subprocess.pyi +++ b/python/helpers/typeshed/stdlib/3/subprocess.pyi @@ -448,6 +448,7 @@ def call(args: _CMD, restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., + *, timeout: Optional[float] = ...) -> int: ... # Same args as Popen.__init__ @@ -751,9 +752,9 @@ else: restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., - timeout: Optional[float] = ..., input: _TXT = ..., *, + timeout: Optional[float] = ..., universal_newlines: Literal[True], ) -> str: ... @overload @@ -773,8 +774,9 @@ else: restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., - timeout: Optional[float] = ..., input: _TXT = ..., + *, + timeout: Optional[float] = ..., ) -> bytes: ... @overload def check_output(args: _CMD, @@ -793,8 +795,9 @@ else: restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., - timeout: Optional[float] = ..., input: _TXT = ..., + *, + timeout: Optional[float] = ..., ) -> Any: ... # morally: -> _TXT @@ -837,6 +840,7 @@ class Popen(Generic[AnyStr]): stderr: Optional[IO[AnyStr]] pid: int returncode: int + universal_newlines: bool # Technically it is wrong that Popen provides __new__ instead of __init__ # but this shouldn't come up hopefully? @@ -1155,7 +1159,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: @@ -1166,7 +1170,7 @@ class Popen(Generic[AnyStr]): timeout: Optional[float] = ..., # morally this should be optional ) -> Tuple[AnyStr, AnyStr]: ... - def send_signal(self, signal: int) -> None: ... + def send_signal(self, sig: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ... def __enter__(self: _S) -> _S: ... diff --git a/python/helpers/typeshed/stdlib/3/sys.pyi b/python/helpers/typeshed/stdlib/3/sys.pyi index 68f2383002d3..9a8ce9d782f8 100644 --- a/python/helpers/typeshed/stdlib/3/sys.pyi +++ b/python/helpers/typeshed/stdlib/3/sys.pyi @@ -19,14 +19,16 @@ _ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType] _OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]] # ----- sys variables ----- -abiflags: str +if sys.platform != "win32": + abiflags: str argv: List[str] base_exec_prefix: str base_prefix: str byteorder: str builtin_module_names: Sequence[str] # actually a tuple of strings copyright: str -# dllhandle = 0 # Windows only +if sys.platform == "win32": + dllhandle: int dont_write_bytecode: bool displayhook: Callable[[object], Any] excepthook: Callable[[Type[BaseException], BaseException, TracebackType], Any] @@ -45,6 +47,8 @@ path: List[str] path_hooks: List[Any] # TODO precise type; function, path to finder path_importer_cache: Dict[str, Any] # TODO precise type platform: str +if sys.version_info >= (3, 9): + platlibdir: str prefix: str if sys.version_info >= (3, 8): pycache_prefix: Optional[str] @@ -62,7 +66,8 @@ api_version: int warnoptions: Any # Each entry is a tuple of the form (action, message, category, module, # lineno) -# winver = '' # Windows only +if sys.platform == "win32": + winver: str _xoptions: Dict[Any, Any] @@ -137,10 +142,8 @@ def __excepthook__(type_: Type[BaseException], value: BaseException, def exc_info() -> _OptExcInfo: ... # sys.exit() accepts an optional argument of anything printable def exit(__status: object = ...) -> NoReturn: ... -def getcheckinterval() -> int: ... # deprecated def getdefaultencoding() -> str: ... if sys.platform != 'win32': - # Unix only def getdlopenflags() -> int: ... def getfilesystemencoding() -> str: ... def getrefcount(__object: Any) -> int: ... @@ -178,8 +181,8 @@ class _WinVersion(Tuple[int, int, int, int, product_type: int platform_version: Tuple[int, int, int] - -def getwindowsversion() -> _WinVersion: ... # Windows only +if sys.platform == "win32": + def getwindowsversion() -> _WinVersion: ... def intern(__string: str) -> str: ... @@ -189,13 +192,17 @@ if sys.version_info >= (3, 7): __breakpointhook__: Any # contains the original value of breakpointhook def breakpointhook(*args: Any, **kwargs: Any) -> Any: ... -def setcheckinterval(__n: int) -> None: ... # deprecated -def setdlopenflags(__flags: int) -> None: ... # Linux only +if sys.platform != "win32": + def setdlopenflags(__flags: int) -> None: ... def setrecursionlimit(__limit: int) -> None: ... def setswitchinterval(__interval: float) -> None: ... def gettotalrefcount() -> int: ... # Debug builds only +if sys.version_info < (3, 9): + def getcheckinterval() -> int: ... # deprecated + def setcheckinterval(__n: int) -> None: ... # deprecated + if sys.version_info >= (3, 8): # not exported by sys class UnraisableHookArgs: diff --git a/python/helpers/typeshed/stdlib/3/tempfile.pyi b/python/helpers/typeshed/stdlib/3/tempfile.pyi index 4df4ac58ad4f..a50da29619fd 100644 --- a/python/helpers/typeshed/stdlib/3/tempfile.pyi +++ b/python/helpers/typeshed/stdlib/3/tempfile.pyi @@ -27,7 +27,7 @@ else: if sys.version_info >= (3, 8): @overload - def TemporaryFile( + def NamedTemporaryFile( mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], buffering: int = ..., encoding: Optional[str] = ..., @@ -35,11 +35,12 @@ if sys.version_info >= (3, 8): suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., + delete: bool = ..., *, errors: Optional[str] = ... ) -> IO[str]: ... @overload - def TemporaryFile( + def NamedTemporaryFile( mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., buffering: int = ..., encoding: Optional[str] = ..., @@ -47,11 +48,12 @@ if sys.version_info >= (3, 8): suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., + delete: bool = ..., *, errors: Optional[str] = ... ) -> IO[bytes]: ... @overload - def TemporaryFile( + def NamedTemporaryFile( mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., @@ -59,12 +61,13 @@ if sys.version_info >= (3, 8): suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., + delete: bool = ..., *, errors: Optional[str] = ... ) -> IO[Any]: ... else: @overload - def TemporaryFile( + def NamedTemporaryFile( mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], buffering: int = ..., encoding: Optional[str] = ..., @@ -72,9 +75,10 @@ else: suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., + delete: bool = ..., ) -> IO[str]: ... @overload - def TemporaryFile( + def NamedTemporaryFile( mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., buffering: int = ..., encoding: Optional[str] = ..., @@ -82,9 +86,10 @@ else: suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., + delete: bool = ..., ) -> IO[bytes]: ... @overload - def TemporaryFile( + def NamedTemporaryFile( mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., @@ -92,82 +97,80 @@ else: suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., + delete: bool = ..., ) -> IO[Any]: ... -if sys.version_info >= (3, 8): - @overload - def NamedTemporaryFile( - mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], - buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., - delete: bool = ..., - *, - errors: Optional[str] = ... - ) -> IO[str]: ... - @overload - def NamedTemporaryFile( - mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., - buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., - delete: bool = ..., - *, - errors: Optional[str] = ... - ) -> IO[bytes]: ... - @overload - def NamedTemporaryFile( - mode: str = ..., - buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., - delete: bool = ..., - *, - errors: Optional[str] = ... - ) -> IO[Any]: ... +if sys.platform == "win32": + TemporaryFile = NamedTemporaryFile else: - @overload - def NamedTemporaryFile( - mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], - buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., - delete: bool = ..., - ) -> IO[str]: ... - @overload - def NamedTemporaryFile( - mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., - buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., - delete: bool = ..., - ) -> IO[bytes]: ... - @overload - def NamedTemporaryFile( - mode: str = ..., - buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., - delete: bool = ..., - ) -> IO[Any]: ... + if sys.version_info >= (3, 8): + @overload + def TemporaryFile( + mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], + buffering: int = ..., + encoding: Optional[str] = ..., + newline: Optional[str] = ..., + suffix: Optional[AnyStr] = ..., + prefix: Optional[AnyStr] = ..., + dir: Optional[_DirT[AnyStr]] = ..., + *, + errors: Optional[str] = ... + ) -> IO[str]: ... + @overload + def TemporaryFile( + mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., + buffering: int = ..., + encoding: Optional[str] = ..., + newline: Optional[str] = ..., + suffix: Optional[AnyStr] = ..., + prefix: Optional[AnyStr] = ..., + dir: Optional[_DirT[AnyStr]] = ..., + *, + errors: Optional[str] = ... + ) -> IO[bytes]: ... + @overload + def TemporaryFile( + mode: str = ..., + buffering: int = ..., + encoding: Optional[str] = ..., + newline: Optional[str] = ..., + suffix: Optional[AnyStr] = ..., + prefix: Optional[AnyStr] = ..., + dir: Optional[_DirT[AnyStr]] = ..., + *, + errors: Optional[str] = ... + ) -> IO[Any]: ... + else: + @overload + def TemporaryFile( + mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], + buffering: int = ..., + encoding: Optional[str] = ..., + newline: Optional[str] = ..., + suffix: Optional[AnyStr] = ..., + prefix: Optional[AnyStr] = ..., + dir: Optional[_DirT[AnyStr]] = ..., + ) -> IO[str]: ... + @overload + def TemporaryFile( + mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., + buffering: int = ..., + encoding: Optional[str] = ..., + newline: Optional[str] = ..., + suffix: Optional[AnyStr] = ..., + prefix: Optional[AnyStr] = ..., + dir: Optional[_DirT[AnyStr]] = ..., + ) -> IO[bytes]: ... + @overload + def TemporaryFile( + mode: str = ..., + buffering: int = ..., + encoding: Optional[str] = ..., + newline: Optional[str] = ..., + suffix: Optional[AnyStr] = ..., + prefix: Optional[AnyStr] = ..., + dir: Optional[_DirT[AnyStr]] = ..., + ) -> IO[Any]: ... # It does not actually derive from IO[AnyStr], but it does implement the # protocol. diff --git a/python/helpers/typeshed/stdlib/3/tokenize.pyi b/python/helpers/typeshed/stdlib/3/tokenize.pyi index 25263f31b529..d9b91fa77540 100644 --- a/python/helpers/typeshed/stdlib/3/tokenize.pyi +++ b/python/helpers/typeshed/stdlib/3/tokenize.pyi @@ -3,6 +3,11 @@ from builtins import open as _builtin_open import sys from token import * # noqa: F403 +if sys.version_info < (3, 7): + COMMENT: int + NL: int + ENCODING: int + cookie_re: Pattern[str] blank_re: Pattern[bytes] diff --git a/python/helpers/typeshed/stdlib/3/typing.pyi b/python/helpers/typeshed/stdlib/3/typing.pyi index 11e7ed76a3f8..7fe15b9ff841 100644 --- a/python/helpers/typeshed/stdlib/3/typing.pyi +++ b/python/helpers/typeshed/stdlib/3/typing.pyi @@ -10,14 +10,25 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986 overload = object() Any = object() -TypeVar = object() + +class TypeVar: + __name__: str + __bound__: Optional[Type[Any]] + __constraints__: Tuple[Type[Any], ...] + __covariant__: bool + __contravariant__: bool + def __init__(self, name: str, *constraints: Type[Any], bound: Optional[Type[Any]] = ..., covariant: bool = ..., contravariant: bool = ...) -> None: ... + _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 +41,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 +67,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 +625,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/python/helpers/typeshed/stdlib/3/unittest/mock.pyi b/python/helpers/typeshed/stdlib/3/unittest/mock.pyi index d8ed01ea0fd9..0d2cd387b93c 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/mock.pyi +++ b/python/helpers/typeshed/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: ... @@ -104,7 +123,7 @@ class CallableMixin(Base): def __init__(self, spec: Optional[Any] = ..., side_effect: Optional[Any] = ..., return_value: Any = ..., wraps: Optional[Any] = ..., name: Optional[Any] = ..., spec_set: Optional[Any] = ..., parent: Optional[Any] = ..., _spec_state: Optional[Any] = ..., _new_name: Any = ..., _new_parent: Optional[Any] = ..., **kwargs: Any) -> None: ... def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ... -Mock = Any +class Mock(CallableMixin, NonCallableMock): ... class _patch: attribute_name: Any @@ -158,8 +177,12 @@ patch: _patcher class MagicMixin: def __init__(self, *args: Any, **kw: Any) -> None: ... -NonCallableMagicMock = Any -MagicMock = Any +class NonCallableMagicMock(MagicMixin, NonCallableMock): + def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ... + +class MagicMock(MagicMixin, Mock): + def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ... + if sys.version_info >= (3, 8): AsyncMock = Any diff --git a/python/helpers/typeshed/stdlib/3/unittest/runner.pyi b/python/helpers/typeshed/stdlib/3/unittest/runner.pyi index 95199b2cd518..ffe4e323ac6e 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/runner.pyi +++ b/python/helpers/typeshed/stdlib/3/unittest/runner.pyi @@ -8,8 +8,12 @@ _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] class TextTestResult(unittest.result.TestResult): + descriptions: bool # undocumented + dots: bool # undocumented separator1: str separator2: str + showall: bool # undocumented + stream: TextIO # undocumented def __init__(self, stream: TextIO, descriptions: bool, verbosity: int) -> None: ... def getDescription(self, test: unittest.case.TestCase) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/urllib/request.pyi b/python/helpers/typeshed/stdlib/3/urllib/request.pyi index 6bc9a2327082..143b6a8508df 100644 --- a/python/helpers/typeshed/stdlib/3/urllib/request.pyi +++ b/python/helpers/typeshed/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/python/helpers/typeshed/stdlib/3/urllib/response.pyi b/python/helpers/typeshed/stdlib/3/urllib/response.pyi index dca0efacc474..970fd743770c 100644 --- a/python/helpers/typeshed/stdlib/3/urllib/response.pyi +++ b/python/helpers/typeshed/stdlib/3/urllib/response.pyi @@ -1,12 +1,14 @@ # private module, we only expose what's needed -from typing import BinaryIO, Iterable, List, Mapping, Optional, Type, TypeVar +from typing import Any, BinaryIO, Callable, IO, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar from email.message import Message from types import TracebackType _AIUT = TypeVar("_AIUT", bound=addbase) class addbase(BinaryIO): + fp: IO[bytes] + def __init__(self, fp: IO[bytes]) -> None: ... def __enter__(self: _AIUT) -> _AIUT: ... def __exit__(self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> None: ... def __iter__(self: _AIUT) -> _AIUT: ... @@ -31,12 +33,19 @@ class addbase(BinaryIO): def write(self, s: bytes) -> int: ... def writelines(self, lines: Iterable[bytes]) -> None: ... +class addclosehook(addbase): + closehook: Callable[..., object] + hookargs: Tuple[Any, ...] + def __init__(self, fp: IO[bytes], closehook: Callable[..., object], *hookargs: Any) -> None: ... + class addinfo(addbase): headers: Message + def __init__(self, fp: IO[bytes], headers: Message) -> None: ... def info(self) -> Message: ... class addinfourl(addinfo): url: str code: int + def __init__(self, fp: IO[bytes], headers: Message, url: str, code: Optional[int] = ...) -> None: ... def geturl(self) -> str: ... def getcode(self) -> int: ... diff --git a/python/helpers/typeshed/stdlib/3/venv/__init__.pyi b/python/helpers/typeshed/stdlib/3/venv/__init__.pyi index 63c4e58f43ac..1163f84cfc9b 100644 --- a/python/helpers/typeshed/stdlib/3/venv/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/venv/__init__.pyi @@ -18,7 +18,9 @@ class EnvBuilder: if sys.version_info >= (3, 6): prompt: Optional[str] - if sys.version_info >= (3, 6): + if sys.version_info >= (3, 9): + def __init__(self, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., upgrade: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ..., upgrade_deps: bool = ...) -> None: ... + elif sys.version_info >= (3, 6): def __init__(self, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., upgrade: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ...) -> None: ... else: def __init__(self, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., upgrade: bool = ..., with_pip: bool = ...) -> None: ... @@ -33,9 +35,14 @@ class EnvBuilder: def post_setup(self, context: SimpleNamespace) -> None: ... def replace_variables(self, text: str, context: SimpleNamespace) -> str: ... # undocumented def install_scripts(self, context: SimpleNamespace, path: str) -> None: ... + if sys.version_info >= (3, 9): + def upgrade_dependencies(self, context: SimpleNamespace) -> None: ... -if sys.version_info >= (3, 6): +if sys.version_info >= (3, 9): + def create(env_dir: _Path, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ..., upgrade_deps: bool = ...) -> None: ... +elif sys.version_info >= (3, 6): def create(env_dir: _Path, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ...) -> None: ... else: def create(env_dir: _Path, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ...) -> None: ... + def main(args: Optional[Sequence[Text]] = ...) -> None: ... diff --git a/python/helpers/typeshed/tests/check_consistent.py b/python/helpers/typeshed/tests/check_consistent.py index 2320e813f9f5..141d205deb21 100644 --- a/python/helpers/typeshed/tests/check_consistent.py +++ b/python/helpers/typeshed/tests/check_consistent.py @@ -28,9 +28,11 @@ consistent_files = [ {'stdlib/3.7/contextvars.pyi', 'third_party/3/contextvars.pyi'}, {'stdlib/3/ipaddress.pyi', 'third_party/2/ipaddress.pyi'}, {'stdlib/2/copy_reg.pyi', 'stdlib/3/copyreg.pyi'}, - {'stdlib/2and3/threading.pyi', 'stdlib/2and3/_dummy_threading.pyi'} + {'stdlib/2and3/threading.pyi', 'stdlib/2and3/_dummy_threading.pyi'}, + {'stdlib/3/winreg.pyi', 'stdlib/2/_winreg.pyi'} ] + def main(): files = [os.path.join(root, file) for root, dir, files in os.walk('.') for file in files] no_symlink = 'You cannot use symlinks in typeshed, please copy {} to its link.' @@ -43,7 +45,11 @@ def main(): for file2 in others: f2 = os.path.join(os.getcwd(), file2) if not filecmp.cmp(f1, f2): - raise ValueError('File {f1} does not match file {f2}. Please copy it to {f2}'.format(f1=file1, f2=file2)) + raise ValueError( + "File {f1} does not match file {f2}. Please copy it to {f2}\n" + "Run either:\ncp {f1} {f2}\nOr:\ncp {f2} {f1}".format(f1=file1, f2=file2) + ) + if __name__ == '__main__': main() diff --git a/python/helpers/typeshed/tests/mypy_test.py b/python/helpers/typeshed/tests/mypy_test.py index 4fae05b3bc18..5b36c2f5402f 100644 --- a/python/helpers/typeshed/tests/mypy_test.py +++ b/python/helpers/typeshed/tests/mypy_test.py @@ -90,7 +90,7 @@ def main(): print("Cannot import mypy. Did you install it?") sys.exit(1) - versions = [(3, 8), (3, 7), (3, 6), (3, 5), (2, 7)] + versions = [(3, 9), (3, 8), (3, 7), (3, 6), (3, 5), (2, 7)] if args.python_version: versions = [v for v in versions if any(('%d.%d' % v).startswith(av) for av in args.python_version)] diff --git a/python/helpers/typeshed/tests/stubtest_test.py b/python/helpers/typeshed/tests/stubtest_test.py index 99b08771924b..fba0634febc9 100644 --- a/python/helpers/typeshed/tests/stubtest_test.py +++ b/python/helpers/typeshed/tests/stubtest_test.py @@ -3,7 +3,7 @@ stubtest is a script in the mypy project that compares stubs to the actual objects at runtime. Note that therefore the output of stubtest depends on which Python version it is run with. -In typeshed CI, we run stubtest with each Python minor version from 3.5 through 3.8 inclusive. +In typeshed CI, we run stubtest with each Python minor version from 3.5 through 3.9 inclusive. We pin the version of mypy / stubtest we use in .travis.yml so changes to those don't break typeshed CI. @@ -18,6 +18,8 @@ import sys def run_stubtest(typeshed_dir: Path) -> int: whitelist_dir = typeshed_dir / "tests" / "stubtest_whitelists" version_whitelist = "py{}{}.txt".format(sys.version_info.major, sys.version_info.minor) + platform_whitelist = "{}.txt".format(sys.platform) + combined_whitelist = "{}-py{}{}.txt".format(sys.platform, sys.version_info.major, sys.version_info.minor) cmd = [ sys.executable, @@ -35,7 +37,17 @@ def run_stubtest(typeshed_dir: Path) -> int: "--whitelist", str(whitelist_dir / version_whitelist), ] - if sys.version_info < (3, 8): + if (whitelist_dir / platform_whitelist).exists(): + cmd += [ + "--whitelist", + str(whitelist_dir / platform_whitelist), + ] + if (whitelist_dir / combined_whitelist).exists(): + cmd += [ + "--whitelist", + str(whitelist_dir / combined_whitelist), + ] + if sys.version_info < (3, 9): # As discussed in https://github.com/python/typeshed/issues/3693, we only aim for # positional-only arg accuracy for the latest Python version. cmd += ["--ignore-positional-only"] @@ -46,7 +58,7 @@ def run_stubtest(typeshed_dir: Path) -> int: print( "\nNB: stubtest output depends on the Python version (and system) it is run with. " "See README.md for more details.\n" - "NB: We only check positional-only arg accuracy for Python 3.8.\n" + "NB: We only check positional-only arg accuracy for Python 3.9.\n" "If stubtest is complaining about 'unused whitelist entry' after your fix, please " "remove the entry from the whitelist file. Note you may have to do this for other " "version-specific whitelists as well. Thanks for helping burn the backlog of errors!\n" diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/linux-py35.txt b/python/helpers/typeshed/tests/stubtest_whitelists/linux-py35.txt new file mode 100644 index 000000000000..748671f605b1 --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/linux-py35.txt @@ -0,0 +1,8 @@ +asyncio.unix_events._UnixSelectorEventLoop.create_unix_server +pwd.getpwnam +socket.NETLINK_CRYPTO +site.getsitepackages +site.getuserbase +site.getusersitepackages +ssl.PROTOCOL_SSLv3 +ssl.RAND_egd diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/linux-py36.txt b/python/helpers/typeshed/tests/stubtest_whitelists/linux-py36.txt new file mode 100644 index 000000000000..a880480fc591 --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/linux-py36.txt @@ -0,0 +1,7 @@ +asyncio.unix_events._UnixSelectorEventLoop.create_unix_server +pwd.getpwnam +site.getsitepackages +site.getuserbase +site.getusersitepackages +ssl.PROTOCOL_SSLv3 +ssl.RAND_egd diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/linux-py37.txt b/python/helpers/typeshed/tests/stubtest_whitelists/linux-py37.txt new file mode 100644 index 000000000000..4b1772e9e811 --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/linux-py37.txt @@ -0,0 +1,7 @@ +pwd.getpwnam +site.getsitepackages +site.getuserbase +site.getusersitepackages +time.CLOCK_PROF +time.CLOCK_UPTIME +typing.IO.closed # Incorrect definition in CPython, fixed in bpo-39493 \ No newline at end of file diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/linux-py38.txt b/python/helpers/typeshed/tests/stubtest_whitelists/linux-py38.txt new file mode 100644 index 000000000000..4e0d114e9e3a --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/linux-py38.txt @@ -0,0 +1,8 @@ +os.MFD_HUGE_32MB +os.MFD_HUGE_512MB +site.getsitepackages +site.getuserbase +site.getusersitepackages +time.CLOCK_PROF +time.CLOCK_UPTIME +typing.IO.closed # Incorrect definition in CPython, fixed in bpo-39493 \ No newline at end of file diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/linux.txt b/python/helpers/typeshed/tests/stubtest_whitelists/linux.txt new file mode 100644 index 000000000000..a0b10df46a38 --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/linux.txt @@ -0,0 +1,53 @@ + +_posixsubprocess.cloexec_pipe +builtins.WindowsError +curses.COLORS +curses.COLOR_PAIRS +curses.COLS +curses.LINES +distutils.command.bdist_msi +grp.getgrgid +grp.struct_group._asdict +grp.struct_group._make +grp.struct_group._replace +ntpath.realpath +os.EX_NOTFOUND +os.SF_MNOWAIT +os.SF_NODISKIO +os.SF_SYNC +os.chflags +os.lchflags +os.lchmod +os.listxattr +os.plock +posix.EX_NOTFOUND +select.EPOLL_RDHUP +socket.socketpair +spwd.getspnam +spwd.struct_spwd._asdict +spwd.struct_spwd._make +spwd.struct_spwd._replace +time.CLOCK_HIGHRES +urllib.request.proxy_bypass + +# ========== +# Whitelist entries that cannot or should not be fixed +# ========== + +# Modules that do not exist on Linux systems +_msi +_winapi +asyncio.windows_events +asyncio.windows_utils +ctypes.wintypes +msilib(.[a-z]+)? +msvcrt +winreg +winsound + +# NamedTuple like, but not actually NamedTuples +posix.[a-z]+_(param|result)._(asdict|make|replace) + +# Platform differences that cannot be captured by the type system +fcntl.[A-Z0-9_]+ +os.SCHED_[A-Z_]+ diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/py35.txt b/python/helpers/typeshed/tests/stubtest_whitelists/py35.txt index 069fd79cc898..726102dbafe5 100644 --- a/python/helpers/typeshed/tests/stubtest_whitelists/py35.txt +++ b/python/helpers/typeshed/tests/stubtest_whitelists/py35.txt @@ -3,36 +3,33 @@ asyncio.Future._exception asyncio.Future._loop asyncio.Future._tb_logger asyncio.Task.__init__ -asyncio.constants.DEBUG_STACK_DEPTH -asyncio.constants.SENDFILE_FALLBACK_READBUFFER_SIZE -asyncio.constants.SSL_HANDSHAKE_TIMEOUT -asyncio.exceptions +asyncio.Task._wakeup +asyncio.base_futures # Added in Python 3.6 +asyncio.base_tasks # Added in Python 3.6 +asyncio.exceptions # Added in Python 3.8 +asyncio.format_helpers # Added in Python 3.7 asyncio.futures.Future._callbacks asyncio.futures.Future._exception asyncio.futures.Future._loop asyncio.futures.Future._tb_logger asyncio.futures._TracebackLogger.__init__ -asyncio.protocols.BufferedProtocol asyncio.runners +asyncio.staggered # Added in Python 3.8 asyncio.tasks.Task.__init__ +asyncio.tasks.Task._wakeup +asyncio.threads # Added in Python 3.9 +asyncio.trsock # Added in Python 3.8 bdb.GENERATOR_AND_COROUTINE_FLAGS builtins.str.maketrans cmath.log codecs.StreamRecoder.seek collections.Reversible collections.UserString.maketrans +contextlib._GeneratorContextManager.__init__ ctypes.CDLL.__init__ -decimal.Decimal.as_integer_ratio -gettext.NullTranslations.npgettext -gettext.NullTranslations.pgettext -gettext.dnpgettext -gettext.dpgettext -gettext.npgettext -gettext.pgettext +fractions.Fraction.__new__ # private _normalize param was made keyword-only in Python 3.6 importlib.metadata importlib.resources -io.BufferedRandom.read1 -io.BufferedReader.read1 io.StringIO.readline ipaddress._BaseNetwork.__init__ json.dump @@ -42,24 +39,27 @@ json.loads mmap.ACCESS_DEFAULT multiprocessing.context.BaseContext.reducer multiprocessing.shared_memory +nntplib._NNTPBase.starttls os.DirEntry os.utime +plistlib.Dict.__init__ pyexpat.XMLParserType.ExternalEntityParserCreate smtpd.SMTPChannel.__init__ smtpd.SMTPServer.__init__ -socket.NETLINK_CRYPTO sre_compile.dis -subprocess.check_output -tracemalloc.Filter.__init__ +ssl.SSLSocket.__init__ typing.AbstractSet.isdisjoint typing.Coroutine.cr_await typing.Coroutine.cr_code typing.Coroutine.cr_frame typing.Coroutine.cr_running +typing.Generator.__new__ typing.Generator.gi_code typing.Generator.gi_frame typing.Generator.gi_running typing.Generator.gi_yieldfrom +typing.GenericMeta.__new__ +typing.IO.closed # Incorrect definition in CPython, fixed in bpo-39493 typing.Mapping.get typing.MutableMapping.pop typing.MutableMapping.setdefault @@ -70,14 +70,20 @@ typing.MutableSequence.remove typing.MutableSet.add typing.MutableSet.discard typing.MutableSet.remove -typing.Protocol +typing.NamedTuple.__new__ +typing.NamedTuple._asdict +typing.NamedTuple._make +typing.NamedTuple._replace typing.Sequence.count typing.Sequence.index -typing.Type typing.runtime_checkable unittest.async_case +unittest.case._AssertLogsContext.__init__ uuid.UUID.int -uuid.getnode +xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 +xml.etree.cElementTree.Element.__bool__ +xml.etree.cElementTree.Element.copy +xml.etree.cElementTree.TreeBuilder.start # bpo-39495 xml.etree.cElementTree.XMLPullParser xml.parsers.expat.XMLParserType.ExternalEntityParserCreate zipfile.ZipFile.open diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/py36.txt b/python/helpers/typeshed/tests/stubtest_whitelists/py36.txt index 778563040edb..54dc70ae7896 100644 --- a/python/helpers/typeshed/tests/stubtest_whitelists/py36.txt +++ b/python/helpers/typeshed/tests/stubtest_whitelists/py36.txt @@ -1,17 +1,12 @@ -ast.NodeVisitor.visit_AnnAssign -ast.NodeVisitor.visit_Constant -ast.NodeVisitor.visit_FormattedValue -ast.NodeVisitor.visit_JoinedStr asyncio.Future.__init__ -asyncio.Task._wakeup -asyncio.constants.SENDFILE_FALLBACK_READBUFFER_SIZE -asyncio.constants.SSL_HANDSHAKE_TIMEOUT -asyncio.exceptions +asyncio.exceptions # Added in Python 3.8 +asyncio.format_helpers # Added in Python 3.7 asyncio.futures.Future.__init__ asyncio.futures._TracebackLogger.__init__ -asyncio.protocols.BufferedProtocol asyncio.runners -asyncio.tasks.Task._wakeup +asyncio.staggered # Added in Python 3.8 +asyncio.threads # Added in Python 3.9 +asyncio.trsock # Added in Python 3.8 builtins.str.maketrans cmath.log codecs.StreamRecoder.seek @@ -24,31 +19,27 @@ collections.abc.AsyncGenerator.ag_await collections.abc.AsyncGenerator.ag_code collections.abc.AsyncGenerator.ag_frame collections.abc.AsyncGenerator.ag_running +contextlib._GeneratorContextManager.__init__ copy.PyStringMap ctypes.CDLL.__init__ email.message.MIMEPart.as_string enum.Enum._generate_next_value_ -gettext.NullTranslations.npgettext -gettext.NullTranslations.pgettext -gettext.dnpgettext -gettext.dpgettext -gettext.npgettext -gettext.pgettext importlib.metadata importlib.resources -io.BufferedRandom.read1 -io.BufferedReader.read1 io.StringIO.readline ipaddress._BaseNetwork.__init__ json.loads logging.handlers.MemoryHandler.__init__ mmap.ACCESS_DEFAULT multiprocessing.shared_memory +nntplib._NNTPBase.starttls os.utime +plistlib.Dict.__init__ pyexpat.XMLParserType.ExternalEntityParserCreate secrets.SystemRandom.getstate smtplib.SMTP.sendmail sre_compile.dis +ssl.SSLSocket.__init__ tkinter.Menu.tk_bindForTraversal tkinter.Misc.tk_menuBar typing.AbstractSet.isdisjoint @@ -60,10 +51,13 @@ typing.Coroutine.cr_await typing.Coroutine.cr_code typing.Coroutine.cr_frame typing.Coroutine.cr_running +typing.Generator.__new__ typing.Generator.gi_code typing.Generator.gi_frame typing.Generator.gi_running typing.Generator.gi_yieldfrom +typing.GenericMeta.__new__ +typing.IO.closed # Incorrect definition in CPython, fixed in bpo-39493 typing.Mapping.get typing.MutableMapping.pop typing.MutableMapping.setdefault @@ -74,15 +68,21 @@ typing.MutableSequence.remove typing.MutableSet.add typing.MutableSet.discard typing.MutableSet.remove -typing.Protocol +typing.NamedTuple.__new__ +typing.NamedTuple._asdict +typing.NamedTuple._make +typing.NamedTuple._replace typing.Sequence.count typing.Sequence.index -typing.Type typing.runtime_checkable unittest.async_case +unittest.case._AssertLogsContext.__init__ urllib.parse.parse_qs urllib.parse.parse_qsl uuid.UUID.int -uuid.getnode webbrowser.Opera.raise_opts +xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 +xml.etree.cElementTree.Element.__bool__ +xml.etree.cElementTree.Element.copy +xml.etree.cElementTree.TreeBuilder.start # bpo-39495 xml.parsers.expat.XMLParserType.ExternalEntityParserCreate diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/py37.txt b/python/helpers/typeshed/tests/stubtest_whitelists/py37.txt index 4e5636538683..9bbc39d91222 100644 --- a/python/helpers/typeshed/tests/stubtest_whitelists/py37.txt +++ b/python/helpers/typeshed/tests/stubtest_whitelists/py37.txt @@ -1,28 +1,18 @@ -_bisect.bisect -_bisect.insort -_tracemalloc._get_object_traceback -_tracemalloc.start -ast.NodeVisitor.visit_AnnAssign -ast.NodeVisitor.visit_Constant -ast.NodeVisitor.visit_FormattedValue -ast.NodeVisitor.visit_JoinedStr -asyncio.AbstractEventLoop.create_unix_server asyncio.AbstractEventLoop.sock_sendfile +asyncio.compat # Removed in 3.7 asyncio.Future.__init__ asyncio.Future._callbacks -asyncio.Future._schedule_callbacks asyncio.Handle.__init__ asyncio.TimerHandle.__init__ -asyncio.events.AbstractEventLoop.create_unix_server asyncio.events.AbstractEventLoop.sock_sendfile asyncio.events.Handle.__init__ asyncio.events.TimerHandle.__init__ -asyncio.exceptions +asyncio.exceptions # Added in Python 3.8 asyncio.futures.Future.__init__ asyncio.futures.Future._callbacks -asyncio.futures.Future._schedule_callbacks -asyncio.proactor_events.BaseProactorEventLoop.create_unix_server -asyncio.selector_events.BaseSelectorEventLoop.create_unix_server +asyncio.staggered # Added in Python 3.8 +asyncio.threads # Added in Python 3.9 +asyncio.trsock # Added in Python 3.8 builtins.dict.get builtins.reversed builtins.str.maketrans @@ -36,81 +26,53 @@ collections.abc.AsyncGenerator.ag_await collections.abc.AsyncGenerator.ag_code collections.abc.AsyncGenerator.ag_frame collections.abc.AsyncGenerator.ag_running -concurrent.futures.BrokenThreadPool +concurrent.futures.ProcessPoolExecutor.map contextvars.Context.__init__ contextvars.Context.get copy.PyStringMap ctypes.CDLL.__init__ -dataclasses.dataclass +dataclasses.Field.__init__ dataclasses.field -dataclasses.make_dataclass email.message.MIMEPart.as_string enum.Enum._generate_next_value_ -gettext.NullTranslations.npgettext -gettext.NullTranslations.pgettext -gettext.dnpgettext -gettext.dpgettext -gettext.npgettext -gettext.pgettext http.client.HTTPSConnection.__init__ http.server.SimpleHTTPRequestHandler.__init__ importlib.metadata ipaddress._BaseNetwork.__init__ json.loads logging.handlers.MemoryHandler.__init__ -macurl2path +macurl2path # removed in 3.7 multiprocessing.shared_memory +nntplib._NNTPBase.starttls os.utime -pyclbr.Class.__init__ -pyclbr.Function.__init__ pyexpat.XMLParserType.ExternalEntityParserCreate queue.SimpleQueue.__init__ secrets.SystemRandom.getstate smtplib.SMTP.sendmail sre_constants.RANGE_IGNORE -time.CLOCK_PROF -time.CLOCK_UPTIME +ssl.PROTOCOL_SSLv3 +ssl.RAND_egd tkinter.Menu.tk_bindForTraversal tkinter.Misc.tk_menuBar -tracemalloc.Traceback.format types.ClassMethodDescriptorType.__get__ types.MethodDescriptorType.__get__ types.WrapperDescriptorType.__get__ -typing.AbstractSet -typing.AsyncContextManager -typing.AsyncGenerator -typing.AsyncIterable -typing.AsyncIterator -typing.Awaitable -typing.ByteString -typing.Collection -typing.Container -typing.ContextManager -typing.Coroutine -typing.Generator -typing.GenericMeta -typing.Hashable -typing.ItemsView -typing.Iterable -typing.Iterator -typing.KeysView -typing.Mapping -typing.MappingView -typing.MutableMapping -typing.MutableSequence -typing.MutableSet -typing.Optional -typing.Protocol -typing.Reversible -typing.Sequence -typing.Sized -typing.Union -typing.ValuesView +typing.NamedTuple._asdict +typing.NamedTuple._make +typing.NamedTuple._replace +typing._SpecialForm.__init__ +typing._SpecialForm.__new__ typing.runtime_checkable unittest.async_case +unittest.case._AssertLogsContext.__init__ urllib.parse.parse_qs urllib.parse.parse_qsl uuid.UUID.int uuid.UUID.is_safe +uuid.getnode # undocumented, unused parameter getters that was later removed webbrowser.Opera.raise_opts +xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 +xml.etree.cElementTree.Element.__bool__ +xml.etree.cElementTree.Element.copy +xml.etree.cElementTree.TreeBuilder.start # bpo-39495 xml.parsers.expat.XMLParserType.ExternalEntityParserCreate diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/py38.txt b/python/helpers/typeshed/tests/stubtest_whitelists/py38.txt index a1bc6b042394..c1c85db297ce 100644 --- a/python/helpers/typeshed/tests/stubtest_whitelists/py38.txt +++ b/python/helpers/typeshed/tests/stubtest_whitelists/py38.txt @@ -1,109 +1,54 @@ -_bisect.bisect -_bisect.insort _thread.ExceptHookArgs _thread._ExceptHookArgs -_tracemalloc._get_object_traceback -_tracemalloc.start -_weakref.getweakrefcount -ast.NodeVisitor.visit_AnnAssign -ast.NodeVisitor.visit_FormattedValue -ast.NodeVisitor.visit_JoinedStr -ast.NodeVisitor.visit_NamedExpr -asyncio.AbstractEventLoop.create_unix_server +ast.Bytes.__new__ +ast.Ellipsis.__new__ +ast.NameConstant.__new__ +ast.Num.__new__ +ast.Str.__new__ asyncio.AbstractEventLoop.sock_sendfile +asyncio.compat # removed in 3.7 asyncio.Future.__init__ asyncio.Future._callbacks -asyncio.Future._schedule_callbacks -asyncio.Future.remove_done_callback -asyncio.Future.set_exception -asyncio.Future.set_result asyncio.Handle.__init__ -asyncio.Task.remove_done_callback -asyncio.Task.set_exception -asyncio.Task.set_name -asyncio.Task.set_result asyncio.TimerHandle.__init__ -asyncio._set_running_loop -asyncio.events.AbstractEventLoop.create_unix_server asyncio.events.AbstractEventLoop.sock_sendfile asyncio.events.Handle.__init__ asyncio.events.TimerHandle.__init__ -asyncio.events._set_running_loop asyncio.futures.Future.__init__ asyncio.futures.Future._callbacks -asyncio.futures.Future._schedule_callbacks -asyncio.futures.Future.remove_done_callback -asyncio.futures.Future.set_exception -asyncio.futures.Future.set_result -asyncio.proactor_events.BaseProactorEventLoop.create_unix_server asyncio.proactor_events._ProactorBasePipeTransport.__del__ -asyncio.selector_events.BaseSelectorEventLoop.create_unix_server -asyncio.tasks.Task.remove_done_callback -asyncio.tasks.Task.set_exception -asyncio.tasks.Task.set_name -asyncio.tasks.Task.set_result -bdb.Bdb.runcall -builtins.bytearray.extend -builtins.bytearray.pop +asyncio.threads # Added in Python 3.9 builtins.compile builtins.dict.get builtins.reversed -bz2.BZ2Compressor.compress -bz2.BZ2File.read -bz2.BZ2File.read1 -bz2.BZ2File.readline -bz2.BZ2File.seek -cProfile.Profile.runcall -codecs.lookup -codecs.lookup_error -codecs.register collections.AsyncGenerator.ag_await collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame collections.AsyncGenerator.ag_running -collections.Container.__contains__ collections.ItemsView.__reversed__ collections.KeysView.__reversed__ -collections.OrderedDict.fromkeys -collections.OrderedDict.setdefault collections.ValuesView.__reversed__ collections.abc.AsyncGenerator.ag_await collections.abc.AsyncGenerator.ag_code collections.abc.AsyncGenerator.ag_frame collections.abc.AsyncGenerator.ag_running -collections.abc.Container.__contains__ collections.abc.ItemsView.__reversed__ collections.abc.KeysView.__reversed__ collections.abc.ValuesView.__reversed__ -concurrent.futures.BrokenThreadPool -concurrent.futures.Executor.submit -concurrent.futures.ProcessPoolExecutor.submit -concurrent.futures.ThreadPoolExecutor.submit -concurrent.futures._base.Executor.submit -concurrent.futures.process.ProcessPoolExecutor.submit -concurrent.futures.thread.ThreadPoolExecutor.submit -contextlib.AbstractContextManager.__exit__ -contextlib.AsyncExitStack.callback -contextlib.AsyncExitStack.push_async_callback -contextlib.ExitStack.callback +concurrent.futures.ProcessPoolExecutor.map contextvars.Context.__init__ contextvars.Context.get -contextvars.ContextVar.reset -contextvars.ContextVar.set copy.PyStringMap -dataclasses.dataclass +dataclasses.Field.__init__ +dataclasses.InitVar.__init__ dataclasses.field -dataclasses.make_dataclass -dataclasses.replace -decimal.Decimal.from_float -decimal.setcontext -dis.stack_effect email.message.MIMEPart.as_string enum.Enum._generate_next_value_ functools.partialmethod.__get__ +functools.singledispatchmethod.__call__ # A lie to reflect that the descriptor get returns a callable gettext.install gettext.translation -hmac.compare_digest +hmac.new # Stub is a white lie; see comments in the stub http.client.HTTPSConnection.__init__ http.cookiejar.DefaultCookiePolicy.__init__ http.server.SimpleHTTPRequestHandler.__init__ @@ -111,111 +56,59 @@ importlib.metadata.EntryPointBase inspect.isasyncgenfunction inspect.iscoroutinefunction inspect.isgeneratorfunction -io.IncrementalNewlineDecoder.setstate ipaddress.IPv4Interface.hostmask ipaddress.IPv6Interface.hostmask ipaddress._BaseNetwork.broadcast_address ipaddress._BaseNetwork.hostmask -itertools.tee logging.handlers.MemoryHandler.__init__ -lzma.LZMACompressor.compress -lzma.is_check_supported macpath -macurl2path -mmap.MADV_AUTOSYNC -mmap.MADV_CORE -mmap.MADV_NOCORE -mmap.MADV_NOSYNC -mmap.MADV_PROTECT -mmap.MADV_SOFT_OFFLINE +macurl2path # removed in 3.7 +mmap.MADV_[A-Z_]+ +multiprocessing.managers.SharedMemoryServer.__init__ multiprocessing.pool.CLOSE multiprocessing.pool.RUN multiprocessing.pool.TERMINATE multiprocessing.spawn._main -opcode.stack_effect -os.MFD_HUGE_32MB -os.MFD_HUGE_512MB -os.pipe2 -os.posix_fadvise -os.posix_fallocate -os.sched_getaffinity -os.sched_getparam -os.sched_getscheduler -os.sched_rr_get_interval -os.sched_setaffinity -os.sched_setparam -os.sched_setscheduler -os.setresgid -os.setresuid -os.waitid -pickle.Pickler.dump +nntplib._NNTPBase.starttls pickle.Pickler.reducer_override platform.DEV_NULL -profile.Profile.runcall -pwd.getpwuid -pyclbr.Class.__init__ -pyclbr.Function.__init__ queue.SimpleQueue.__init__ -random.Random.getrandbits -random.getrandbits secrets.SystemRandom.getstate -secrets.compare_digest -signal.sigtimedwait -signal.sigwaitinfo smtplib.SMTP.sendmail sre_constants.RANGE_IGNORE +ssl.PROTOCOL_SSLv3 +ssl.RAND_egd sys.UnraisableHookArgs threading.ExceptHookArgs -time.CLOCK_PROF -time.CLOCK_UPTIME tkinter.Menu.tk_bindForTraversal tkinter.Misc.tk_menuBar -trace.Trace.runfunc -tracemalloc.Traceback.format -tracemalloc.start types.ClassMethodDescriptorType.__get__ types.CodeType.replace types.MethodDescriptorType.__get__ types.WrapperDescriptorType.__get__ -typing.AbstractSet -typing.AsyncContextManager -typing.AsyncGenerator -typing.AsyncIterable -typing.AsyncIterator -typing.Awaitable -typing.ByteString -typing.Collection -typing.Container -typing.ContextManager -typing.Coroutine -typing.Generator -typing.GenericMeta -typing.Hashable -typing.ItemsView -typing.Iterable -typing.Iterator -typing.KeysView -typing.Mapping -typing.MappingView -typing.MutableMapping -typing.MutableSequence -typing.MutableSet -typing.Optional -typing.Reversible -typing.Sequence -typing.Sized -typing.Union -typing.ValuesView -unittest.TestCase.addCleanup -unittest.case.TestCase.addCleanup +typing.NamedTuple.__new__ +typing.NamedTuple._asdict +typing.NamedTuple._make +typing.NamedTuple._replace +typing.SupportsAbs.__init__ +typing.SupportsBytes.__init__ +typing.SupportsComplex.__init__ +typing.SupportsFloat.__init__ +typing.SupportsIndex.__init__ +typing.SupportsInt.__init__ +typing.SupportsRound.__init__ +typing._SpecialForm.__init__ +typing._SpecialForm.__new__ +unittest.case._AssertLogsContext.__init__ unittest.doModuleCleanups -unittest.mock.MagicProxy.__call__ -unittest.mock._MockIter.__iter__ +uuid.getnode # undocumented, unused parameter getters that was later removed weakref.WeakValueDictionary.__init__ weakref.WeakValueDictionary.update -weakref.getweakrefcount webbrowser.Opera.raise_opts +xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 xml.etree.ElementTree.XMLParser.__init__ +xml.etree.cElementTree.Element.__bool__ +xml.etree.cElementTree.Element.copy +xml.etree.cElementTree.TreeBuilder.start # bpo-39495 xml.etree.cElementTree.XMLParser.__init__ zipfile.Path.open -zipfile.ZipExtFile.seek diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/py39.txt b/python/helpers/typeshed/tests/stubtest_whitelists/py39.txt new file mode 100644 index 000000000000..2a867afbed86 --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/py39.txt @@ -0,0 +1,221 @@ +_ast.ImportFrom.level +_dummy_thread +_thread.ExceptHookArgs +_thread._ExceptHookArgs +_weakref.getweakrefcount +array.array.fromstring +array.array.tostring +ast.Bytes.__new__ +ast.Ellipsis.__new__ +ast.ExtSlice.__new__ +ast.ImportFrom.level +ast.Index.__new__ +ast.NameConstant.__new__ +ast.Num.__new__ +ast.Str.__new__ +asyncio.AbstractEventLoop.sock_sendfile +asyncio.compat # removed in 3.7 +asyncio.Future.__init__ +asyncio.Future._callbacks +asyncio.Handle.__init__ +asyncio.TimerHandle.__init__ +asyncio.events.AbstractEventLoop.sock_sendfile +asyncio.events.Handle.__init__ +asyncio.events.TimerHandle.__init__ +asyncio.futures.Future.__init__ +asyncio.futures.Future._callbacks +asyncio.proactor_events._ProactorBasePipeTransport.__del__ +builtins.bytearray.extend +builtins.bytearray.pop +builtins.compile +builtins.dict.get +builtins.reversed +bz2.BZ2Compressor.compress +bz2.BZ2File.read +bz2.BZ2File.read1 +bz2.BZ2File.readline +bz2.BZ2File.seek +cProfile.Profile.runcall +codecs.lookup +codecs.lookup_error +codecs.register +collections.AsyncGenerator.ag_await +collections.AsyncGenerator.ag_code +collections.AsyncGenerator.ag_frame +collections.AsyncGenerator.ag_running +collections.Container.__contains__ +collections.ItemsView.__reversed__ +collections.KeysView.__reversed__ +collections.OrderedDict.fromkeys +collections.OrderedDict.setdefault +collections.ValuesView.__reversed__ +collections.abc.AsyncGenerator.ag_await +collections.abc.AsyncGenerator.ag_code +collections.abc.AsyncGenerator.ag_frame +collections.abc.AsyncGenerator.ag_running +collections.abc.Container.__contains__ +collections.abc.ItemsView.__reversed__ +collections.abc.KeysView.__reversed__ +collections.abc.ValuesView.__reversed__ +compileall.compile_dir +compileall.compile_file +concurrent.futures.Executor.submit +concurrent.futures.ProcessPoolExecutor.map +concurrent.futures.ProcessPoolExecutor.shutdown +concurrent.futures.ProcessPoolExecutor.submit +concurrent.futures.ThreadPoolExecutor.shutdown +concurrent.futures.ThreadPoolExecutor.submit +concurrent.futures._base.Executor.submit +concurrent.futures.process.ProcessPoolExecutor.shutdown +concurrent.futures.process.ProcessPoolExecutor.submit +concurrent.futures.thread.ThreadPoolExecutor.shutdown +concurrent.futures.thread.ThreadPoolExecutor.submit +contextlib.AbstractContextManager.__exit__ +contextlib.AsyncExitStack.callback +contextlib.AsyncExitStack.push_async_callback +contextlib.ExitStack.callback +contextvars.Context.__init__ +contextvars.Context.get +contextvars.ContextVar.reset +contextvars.ContextVar.set +copy.PyStringMap +dataclasses.Field.__init__ +dataclasses.InitVar.__init__ +dataclasses.dataclass +dataclasses.field +dataclasses.replace +dummy_threading +email.message.MIMEPart.as_string +enum.Enum._generate_next_value_ +ftplib.FTP.__init__ +ftplib.FTP_TLS.__init__ +functools.partialmethod.__get__ +functools.singledispatchmethod.__call__ +gettext.install +gettext.translation +hmac.compare_digest +hmac.new # Stub is a white lie; see comments in the stub +http.client.HTTPSConnection.__init__ +http.cookiejar.DefaultCookiePolicy.__init__ +http.server.SimpleHTTPRequestHandler.__init__ +imaplib.IMAP4.__init__ +imaplib.IMAP4.open +imaplib.IMAP4_SSL.__init__ +imaplib.IMAP4_SSL.open +importlib.metadata.DistributionFinder.Context.pattern +importlib.metadata.EntryPointBase +inspect.isasyncgenfunction +inspect.iscoroutinefunction +inspect.isgeneratorfunction +io.IncrementalNewlineDecoder.setstate +ipaddress.IPv4Interface.hostmask +ipaddress.IPv6Interface.hostmask +ipaddress._BaseNetwork.broadcast_address +ipaddress._BaseNetwork.hostmask +itertools.tee +logging.FileHandler.__init__ +logging.handlers.BaseRotatingHandler.__init__ +logging.handlers.MemoryHandler.__init__ +logging.handlers.RotatingFileHandler.__init__ +logging.handlers.TimedRotatingFileHandler.__init__ +logging.handlers.WatchedFileHandler.__init__ +lzma.LZMACompressor.compress +lzma.is_check_supported +macpath +macurl2path # removed in 3.7 +mmap.MADV_AUTOSYNC +mmap.MADV_CORE +mmap.MADV_NOCORE +mmap.MADV_NOSYNC +mmap.MADV_PROTECT +mmap.MADV_SOFT_OFFLINE +multiprocessing.managers.SharedMemoryServer.__init__ +multiprocessing.pool.CLOSE +multiprocessing.pool.RUN +multiprocessing.pool.TERMINATE +multiprocessing.spawn._main +nntplib.NNTP.starttls +os.MFD_HUGE_32MB +os.MFD_HUGE_512MB +os.getgrouplist +os.initgroups +os.pipe2 +os.posix_fadvise +os.posix_fallocate +os.sched_getaffinity +os.sched_getparam +os.sched_getscheduler +os.sched_rr_get_interval +os.sched_setaffinity +os.sched_setparam +os.sched_setscheduler +os.sendfile +os.setresgid +os.setresuid +os.waitid +pickle.Pickler.dump +pickle.Pickler.reducer_override +pickle.loads +platform.DEV_NULL +platform.uname_result.__new__ +platform.uname_result._fields +platform.uname_result.processor +profile.Profile.runcall +pwd.getpwnam +pwd.getpwuid +queue.SimpleQueue.__init__ +random.SystemRandom.getrandbits +secrets.SystemRandom.getstate +secrets.SystemRandom.getrandbits +secrets.compare_digest +signal.sigtimedwait +signal.sigwaitinfo +smtplib.LMTP.__init__ +smtplib.SMTP.sendmail +sre_constants.RANGE_IGNORE +ssl.AF_INET +ssl.PROTOCOL_SSLv3 +ssl.RAND_egd +symtable.SymbolTable.has_exec +sys.UnraisableHookArgs +threading.ExceptHookArgs +time.CLOCK_PROF +time.CLOCK_UPTIME +tkinter.Menu.tk_bindForTraversal +tkinter.Misc.tk_menuBar +trace.Trace.runfunc +types.ClassMethodDescriptorType.__get__ +types.CodeType.replace +types.MethodDescriptorType.__get__ +types.WrapperDescriptorType.__get__ +typing.Annotated +typing.NamedTuple +typing.SupportsAbs.__init__ +typing.SupportsBytes.__init__ +typing.SupportsComplex.__init__ +typing.SupportsFloat.__init__ +typing.SupportsIndex.__init__ +typing.SupportsInt.__init__ +typing.SupportsRound.__init__ +typing._SpecialForm.__init__ +typing._TypedDict.__delitem__ +typing._TypedDict.copy +typing._TypedDict.items +typing._TypedDict.keys +typing._TypedDict.pop +typing._TypedDict.setdefault +typing._TypedDict.update +typing._TypedDict.values +unittest.TestCase.addCleanup +unittest.case.TestCase.addCleanup +unittest.doModuleCleanups +weakref.WeakValueDictionary.__init__ +weakref.WeakValueDictionary.update +weakref.getweakrefcount +webbrowser.Opera.raise_opts +xml.etree.ElementTree.Element.getchildren +xml.etree.ElementTree.Element.getiterator +xml.etree.ElementTree.ElementTree.getiterator +xml.etree.ElementTree.XMLParser.__init__ +xml.etree.cElementTree +zipfile.ZipExtFile.seek diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/py3_common.txt b/python/helpers/typeshed/tests/stubtest_whitelists/py3_common.txt index 33521f5c9401..e011cbf5b28a 100644 --- a/python/helpers/typeshed/tests/stubtest_whitelists/py3_common.txt +++ b/python/helpers/typeshed/tests/stubtest_whitelists/py3_common.txt @@ -1,178 +1,35 @@ +__future__._Feature.__init__ _csv.Dialect.__init__ _dummy_threading _importlib_modulespec _operator.methodcaller -_posixsubprocess.cloexec_pipe -_subprocess +_threading_local.local.__new__ _types _weakref.CallableProxyType.__getattr__ _weakref.ProxyType.__getattr__ _weakref.ReferenceType.__call__ -_winapi +abc.ABCMeta.__new__ abc.abstractclassmethod abc.abstractmethod abc.abstractstaticmethod -aifc.open -aifc.openfp +argparse.ArgumentError.__init__ argparse.Namespace.__getattr__ -ast.NodeVisitor.visit_Add -ast.NodeVisitor.visit_And -ast.NodeVisitor.visit_Assert -ast.NodeVisitor.visit_Assign -ast.NodeVisitor.visit_AsyncFor -ast.NodeVisitor.visit_AsyncFunctionDef -ast.NodeVisitor.visit_AsyncWith -ast.NodeVisitor.visit_Attribute -ast.NodeVisitor.visit_AugAssign -ast.NodeVisitor.visit_AugLoad -ast.NodeVisitor.visit_AugStore -ast.NodeVisitor.visit_Await -ast.NodeVisitor.visit_BinOp -ast.NodeVisitor.visit_BitAnd -ast.NodeVisitor.visit_BitOr -ast.NodeVisitor.visit_BitXor -ast.NodeVisitor.visit_BoolOp -ast.NodeVisitor.visit_Break -ast.NodeVisitor.visit_Bytes -ast.NodeVisitor.visit_Call -ast.NodeVisitor.visit_ClassDef -ast.NodeVisitor.visit_Compare -ast.NodeVisitor.visit_Continue -ast.NodeVisitor.visit_Del -ast.NodeVisitor.visit_Delete -ast.NodeVisitor.visit_Dict -ast.NodeVisitor.visit_DictComp -ast.NodeVisitor.visit_Div -ast.NodeVisitor.visit_Ellipsis -ast.NodeVisitor.visit_Eq -ast.NodeVisitor.visit_ExceptHandler -ast.NodeVisitor.visit_Expr -ast.NodeVisitor.visit_Expression -ast.NodeVisitor.visit_ExtSlice -ast.NodeVisitor.visit_FloorDiv -ast.NodeVisitor.visit_For -ast.NodeVisitor.visit_FunctionDef -ast.NodeVisitor.visit_GeneratorExp -ast.NodeVisitor.visit_Global -ast.NodeVisitor.visit_Gt -ast.NodeVisitor.visit_GtE -ast.NodeVisitor.visit_If -ast.NodeVisitor.visit_IfExp -ast.NodeVisitor.visit_Import -ast.NodeVisitor.visit_ImportFrom -ast.NodeVisitor.visit_In -ast.NodeVisitor.visit_Index -ast.NodeVisitor.visit_Interactive -ast.NodeVisitor.visit_Invert -ast.NodeVisitor.visit_Is -ast.NodeVisitor.visit_IsNot -ast.NodeVisitor.visit_LShift -ast.NodeVisitor.visit_Lambda -ast.NodeVisitor.visit_List -ast.NodeVisitor.visit_ListComp -ast.NodeVisitor.visit_Load -ast.NodeVisitor.visit_Lt -ast.NodeVisitor.visit_LtE -ast.NodeVisitor.visit_MatMult -ast.NodeVisitor.visit_Mod -ast.NodeVisitor.visit_Module -ast.NodeVisitor.visit_Mult -ast.NodeVisitor.visit_Name -ast.NodeVisitor.visit_NameConstant -ast.NodeVisitor.visit_Nonlocal -ast.NodeVisitor.visit_Not -ast.NodeVisitor.visit_NotEq -ast.NodeVisitor.visit_NotIn -ast.NodeVisitor.visit_Num -ast.NodeVisitor.visit_Or -ast.NodeVisitor.visit_Param -ast.NodeVisitor.visit_Pass -ast.NodeVisitor.visit_Pow -ast.NodeVisitor.visit_RShift -ast.NodeVisitor.visit_Raise -ast.NodeVisitor.visit_Return -ast.NodeVisitor.visit_Set -ast.NodeVisitor.visit_SetComp -ast.NodeVisitor.visit_Slice -ast.NodeVisitor.visit_Starred -ast.NodeVisitor.visit_Store -ast.NodeVisitor.visit_Str -ast.NodeVisitor.visit_Sub -ast.NodeVisitor.visit_Subscript -ast.NodeVisitor.visit_Suite -ast.NodeVisitor.visit_Try -ast.NodeVisitor.visit_Tuple -ast.NodeVisitor.visit_UAdd -ast.NodeVisitor.visit_USub -ast.NodeVisitor.visit_UnaryOp -ast.NodeVisitor.visit_While -ast.NodeVisitor.visit_With -ast.NodeVisitor.visit_Yield -ast.NodeVisitor.visit_YieldFrom -ast.NodeVisitor.visit_alias -ast.NodeVisitor.visit_arg -ast.NodeVisitor.visit_arguments -ast.NodeVisitor.visit_comprehension -ast.NodeVisitor.visit_keyword -ast.NodeVisitor.visit_withitem -asyncio.AbstractEventLoop.connect_accepted_socket -asyncio.AbstractEventLoop.create_unix_connection -asyncio.BaseChildWatcher asyncio.BaseEventLoop.subprocess_exec asyncio.Condition.acquire asyncio.Condition.locked asyncio.Condition.release -asyncio.Future._copy_state -asyncio.Queue._consume_done_getters -asyncio.Queue._consume_done_putters -asyncio.Server -asyncio.StreamReaderProtocol.__init__ -asyncio.Task._step asyncio.Task.get_stack asyncio.Task.print_stack -asyncio.WriteTransport.set_write_buffer_limits asyncio.base_events.BaseEventLoop.subprocess_exec -asyncio.create_subprocess_exec -asyncio.create_subprocess_shell -asyncio.events.AbstractEventLoop.connect_accepted_socket -asyncio.events.AbstractEventLoop.create_unix_connection -asyncio.futures.Future._copy_state -asyncio.futures.wrap_future +asyncio.base_events.Server.__init__ asyncio.locks.Condition.acquire asyncio.locks.Condition.locked asyncio.locks.Condition.release -asyncio.open_connection -asyncio.open_unix_connection -asyncio.proactor_events.BaseProactorEventLoop.create_unix_connection asyncio.proactor_events.BaseProactorEventLoop.sock_recv -asyncio.queues.Queue._consume_done_getters -asyncio.queues.Queue._consume_done_putters -asyncio.selector_events.BaseSelectorEventLoop.create_unix_connection asyncio.selector_events.BaseSelectorEventLoop.sock_recv -asyncio.sleep -asyncio.start_unix_server -asyncio.streams.StreamReaderProtocol.__init__ -asyncio.streams.open_connection -asyncio.streams.open_unix_connection -asyncio.streams.start_unix_server -asyncio.subprocess.create_subprocess_exec -asyncio.subprocess.create_subprocess_shell -asyncio.tasks.Task._step +asyncio.streams.FlowControlMixin.__init__ asyncio.tasks.Task.get_stack asyncio.tasks.Task.print_stack -asyncio.tasks.sleep -asyncio.transports.WriteTransport.set_write_buffer_limits -asyncio.transports._FlowControlMixin.set_write_buffer_limits -asyncio.unix_events._UnixSelectorEventLoop.create_unix_connection -asyncio.unix_events._UnixSelectorEventLoop.create_unix_server -asyncio.windows_events -asyncio.windows_utils -asyncio.wrap_future -base64.b32decode -base64.b64decode -base64.b64encode -bdb.Bdb.__init__ -builtins.WindowsError builtins.bytearray.__float__ builtins.bytearray.__int__ builtins.bytearray.append @@ -183,13 +40,8 @@ builtins.bytes.__int__ builtins.bytes.maketrans builtins.classmethod.__get__ builtins.complex.__complex__ -builtins.copyright -builtins.credits builtins.ellipsis -builtins.exit builtins.function -builtins.help -builtins.license builtins.memoryview.__contains__ builtins.memoryview.__iter__ builtins.memoryview.cast @@ -198,15 +50,14 @@ builtins.property.__get__ builtins.property.fdel builtins.property.fget builtins.property.fset -builtins.quit -builtins.reveal_locals -builtins.reveal_type builtins.staticmethod.__get__ +bz2.BZ2Decompressor.__init__ bz2.BZ2File.readinto bz2.BZ2File.readlines bz2.BZ2File.write bz2.BZ2File.writelines codecs.BufferedIncrementalDecoder.decode +codecs.CodecInfo.__new__ codecs.CodecInfo.decode codecs.CodecInfo.encode codecs.CodecInfo.incrementaldecoder @@ -219,26 +70,6 @@ codecs.IncrementalEncoder.encode codecs.StreamReader.__getattr__ codecs.StreamReader.readline codecs.StreamReader.readlines -codecs.StreamReaderWriter.__getattr__ -codecs.StreamReaderWriter.close -codecs.StreamReaderWriter.fileno -codecs.StreamReaderWriter.flush -codecs.StreamReaderWriter.isatty -codecs.StreamReaderWriter.readable -codecs.StreamReaderWriter.seekable -codecs.StreamReaderWriter.tell -codecs.StreamReaderWriter.truncate -codecs.StreamReaderWriter.writable -codecs.StreamRecoder.__getattr__ -codecs.StreamRecoder.close -codecs.StreamRecoder.fileno -codecs.StreamRecoder.flush -codecs.StreamRecoder.isatty -codecs.StreamRecoder.readable -codecs.StreamRecoder.seekable -codecs.StreamRecoder.tell -codecs.StreamRecoder.truncate -codecs.StreamRecoder.writable codecs.StreamWriter.__getattr__ codecs.StreamWriter.write codecs.open @@ -295,20 +126,21 @@ collections.abc.Sequence.count collections.abc.Sequence.index collections.abc.Set.isdisjoint collections.deque.__hash__ -concurrent.futures.BrokenProcessPool -concurrent.futures.CANCELLED -concurrent.futures.CANCELLED_AND_NOTIFIED -concurrent.futures.EXTRA_QUEUED_CALLS -concurrent.futures.Error concurrent.futures.Executor.map -concurrent.futures.FINISHED -concurrent.futures.LOGGER -concurrent.futures.PENDING -concurrent.futures.ProcessPoolExecutor.map -concurrent.futures.RUNNING concurrent.futures._base.Executor.map +concurrent.futures.ProcessPoolExecutor.map concurrent.futures.process.ProcessPoolExecutor.map +configparser.DuplicateOptionError.__init__ +configparser.DuplicateSectionError.__init__ +configparser.Error.__init__ +configparser.InterpolationDepthError.__init__ +configparser.InterpolationError.__init__ +configparser.InterpolationMissingOptionError.__init__ configparser.LegacyInterpolation.before_get +configparser.MissingSectionHeaderError.__init__ +configparser.NoOptionError.__init__ +configparser.NoSectionError.__init__ +configparser.ParsingError.__init__ configparser.SectionProxy.__getattr__ configparser.SectionProxy.getboolean configparser.SectionProxy.getfloat @@ -328,28 +160,23 @@ ctypes.memmove ctypes.memset ctypes.pointer ctypes.string_at -ctypes.wintypes ctypes.wstring_at -curses.COLORS -curses.COLOR_PAIRS -curses.COLS -curses.LINES dbm.error dbm.ndbm -decimal.DecimalException.handle difflib.SequenceMatcher.__init__ -dis.dis distutils.archive_util.make_archive distutils.archive_util.make_tarball -distutils.command.bdist_msi distutils.command.bdist_packager distutils.core.Extension.__init__ distutils.debug.DEBUG distutils.extension.Extension.__init__ +distutils.fancy_getopt.OptionDummy.__init__ +distutils.filelist.FileList.__init__ distutils.sysconfig.set_python_build distutils.text_file.TextFile.warn distutils.version.Version._cmp distutils.version.Version.parse +email.errors.MessageDefect.__init__ email.feedparser.BytesFeedParser.__init__ email.feedparser.FeedParser.__init__ email.generator.BytesGenerator.__init__ @@ -364,6 +191,7 @@ email.headerregistry.HeaderRegistry.__init__ email.headerregistry.MIMEVersionHeader.parse email.headerregistry.ParameterizedMIMEHeader.parse email.headerregistry.UnstructuredHeader.parse +email.message.MIMEPart.__init__ email.message.Message.get_payload email.message.Message.set_param email.parser.HeaderParser.__init__ @@ -378,31 +206,24 @@ encodings.utf_8.IncrementalDecoder._buffer_decode encodings.utf_8.StreamReader.decode encodings.utf_8.StreamWriter.encode encodings.utf_8.encode -errno.EDEADLCK -fcntl.F_FULLFSYNC -fcntl.F_NOCACHE -gettext.GNUTranslations.lngettext -gettext.GNUTranslations.ngettext -gettext.NullTranslations.__init__ -gettext.NullTranslations.lngettext -gettext.NullTranslations.ngettext -gettext.dngettext -gettext.ldngettext -gettext.lngettext -gettext.ngettext -grp.getgrgid -grp.struct_group._asdict -grp.struct_group._make -grp.struct_group._replace +enum.EnumMeta.__call__ +enum.EnumMeta.__new__ +getopt.GetoptError.__init__ +hmac.HMAC.__init__ html.parser.HTMLParser.feed http.HTTPStatus.description http.HTTPStatus.phrase +http.client.BadStatusLine.__init__ http.client.HTTPResponse.read1 http.client.HTTPResponse.readinto http.client.HTTPResponse.readline +http.client.IncompleteRead.__init__ +http.client.LineTooLong.__init__ +http.client.UnknownProtocol.__init__ http.cookiejar.Cookie.is_expired http.cookiejar.CookieJar.clear http.cookiejar.FileCookieJar.__init__ +http.cookies.Morsel.__init__ http.cookies.Morsel.setdefault http.cookies.Morsel.update http.server.HTTPServer.__init__ @@ -414,21 +235,18 @@ importlib.abc.MetaPathFinder.find_spec importlib.abc.PathEntryFinder.find_spec importlib.machinery.BuiltinImporter.find_module importlib.machinery.BuiltinImporter.find_spec +importlib.machinery.ExtensionFileLoader.__init__ importlib.machinery.ExtensionFileLoader.get_filename importlib.machinery.FrozenImporter.find_module importlib.machinery.FrozenImporter.find_spec importlib.machinery.FrozenImporter.module_repr -importlib.machinery.PathFinder.find_module -importlib.machinery.PathFinder.find_spec -importlib.machinery.PathFinder.invalidate_caches importlib.machinery.SourceFileLoader.set_data importlib.machinery.WindowsRegistryFinder.find_module importlib.machinery.WindowsRegistryFinder.find_spec importlib.util.spec_from_file_location importlib.util.spec_from_loader -inspect.Parameter.__init__ +inspect.BoundArguments.__init__ inspect.Parameter.replace -inspect.Signature.__init__ inspect.Signature.replace inspect.getabsfile inspect.getmodule @@ -438,6 +256,7 @@ io.BufferedReader.truncate io.BufferedWriter.seek io.BufferedWriter.truncate io.BytesIO.readlines +io.BytesIO.seek # Parameter name for a positional-only param differs from its name in the inherited method io.FileIO.seek io.StringIO.seek io.StringIO.truncate @@ -466,8 +285,10 @@ itertools.takewhile itertools.zip_longest lib2to3.pygram.pattern_symbols lib2to3.pygram.python_symbols +lib2to3.pytree.Base.__new__ lib2to3.pytree.Base.children lib2to3.pytree.Base.type +lib2to3.pytree.BasePattern.__new__ lib2to3.pytree.BasePattern.type lib2to3.pytree.NegatedPattern.match lib2to3.pytree.NegatedPattern.match_seq @@ -478,6 +299,7 @@ logging.Logger.addFilter logging.Logger.removeFilter logging.LoggerAdapter.isEnabledFor logging.LoggerAdapter.setLevel +logging.RootLogger.__init__ logging.addLevelName logging.disable logging.getLevelName @@ -497,7 +319,6 @@ mailbox._mboxMMDF.get_string mailbox.mbox.__init__ mimetypes.read_mime_types mmap.mmap.__iter__ -msvcrt multiprocessing.Array multiprocessing.Event multiprocessing.JoinableQueue @@ -506,16 +327,21 @@ multiprocessing.SimpleQueue multiprocessing.Value multiprocessing.context.BaseContext.Event multiprocessing.managers.BaseManager.shutdown +multiprocessing.managers.Server.__init__ multiprocessing.managers.SyncManager.Event multiprocessing.managers.SyncManager.Lock multiprocessing.managers.SyncManager.Namespace multiprocessing.managers.SyncManager.RLock +multiprocessing.pool.ApplyResult.__init__ +multiprocessing.pool.IMapIterator.__init__ +multiprocessing.pool.MapResult.__init__ multiprocessing.pool.Pool.imap multiprocessing.pool.Pool.imap_unordered multiprocessing.pool.Pool.map multiprocessing.pool.Pool.map_async multiprocessing.pool.Pool.starmap multiprocessing.pool.Pool.starmap_async +multiprocessing.queues.JoinableQueue.__init__ multiprocessing.queues.Queue.__init__ multiprocessing.queues.Queue.put_nowait multiprocessing.queues.SimpleQueue.__init__ @@ -525,12 +351,12 @@ multiprocessing.synchronize.Barrier.__init__ multiprocessing.synchronize.Condition.acquire multiprocessing.synchronize.Condition.release multiprocessing.synchronize.Event.__init__ +multiprocessing.synchronize.SemLock.__init__ multiprocessing.synchronize.SemLock.acquire multiprocessing.synchronize.SemLock.release +netrc.NetrcParseError.__init__ netrc.netrc.__init__ -nntplib._NNTPBase.starttls ntpath.join -ntpath.realpath numbers.Number.__hash__ operator.methodcaller optparse.HelpFormatter._format__Text @@ -538,61 +364,15 @@ optparse.OptionParser.__init__ optparse.Values.__getattr__ optparse.Values.read_file optparse.Values.read_module -os.EX_NOTFOUND -os.O_BINARY -os.O_EXLOCK -os.O_NOINHERIT -os.O_RANDOM -os.O_SEQUENTIAL -os.O_SHLOCK -os.O_SHORT_LIVED -os.O_TEMPORARY -os.O_TEXT -os.SCHED_SPORADIC -os.SF_MNOWAIT -os.SF_NODISKIO -os.SF_SYNC +os._Environ.__init__ os._Environ.setdefault -os.chflags -os.lchflags -os.lchmod -os.listxattr -os.plock -os.sched_param._asdict -os.sched_param._make -os.sched_param._replace -os.statvfs_result._asdict -os.statvfs_result._make -os.statvfs_result._replace -os.times_result._asdict -os.times_result._make -os.times_result._replace -os.uname_result._asdict -os.uname_result._make -os.uname_result._replace -os.waitid_result._asdict -os.waitid_result._make -os.waitid_result._replace +os._wrap_close.__init__ pickle.Pickler.persistent_id pickle.Unpickler.find_class pickle.Unpickler.persistent_load pipes.Template.copy pkgutil.ImpImporter.__init__ poplib.POP3_SSL.stls -posix.EX_NOTFOUND -posix.sched_param._asdict -posix.sched_param._make -posix.sched_param._replace -posix.times_result._asdict -posix.times_result._make -posix.times_result._replace -posix.uname_result._asdict -posix.uname_result._make -posix.uname_result._replace -posix.waitid_result._asdict -posix.waitid_result._make -posix.waitid_result._replace -pwd.getpwnam pydoc.HTMLDoc.docdata pydoc.HTMLDoc.docproperty pydoc.HTMLDoc.docroutine @@ -602,13 +382,11 @@ pydoc.TextDoc.docother pydoc.TextDoc.docproperty pydoc.TextDoc.docroutine random.Random.randrange -random.Random.triangular random.SystemRandom.getstate random.randrange -random.triangular +re.error.__init__ runpy.run_path sched.Event.__doc__ -select.EPOLL_RDHUP select.poll selectors.DevpollSelector selectors.KqueueSelector @@ -616,103 +394,14 @@ shlex.shlex.__init__ shlex.shlex.error_leader shlex.shlex.sourcehook shutil.register_unpack_format -signal.CTRL_BREAK_EVENT -signal.CTRL_C_EVENT -signal.SIGBREAK signal.SIGEMT signal.SIGINFO -site.getsitepackages -site.getuserbase -site.getusersitepackages smtpd.MailmanProxy.process_message smtpd.PureProxy.process_message smtplib.SMTP.send_message -socket.AF_AAL5 -socket.AF_BLUETOOTH -socket.AF_DECnet -socket.AF_LINK -socket.AF_SYSTEM -socket.AI_DEFAULT -socket.AI_MASK -socket.AI_V4MAPPED_CFG -socket.BDADDR_ANY -socket.BDADDR_LOCAL -socket.BTPROTO_HCI -socket.BTPROTO_L2CAP -socket.BTPROTO_RFCOMM -socket.BTPROTO_SCO -socket.EAIEAI_ADDRFAMILY -socket.EAI_BADHINTS -socket.EAI_MAX -socket.EAI_PROTOCOL -socket.EINTR -socket.HCI_DATA_DIR -socket.HCI_FILTER -socket.HCI_TIME_STAMP -socket.IPPROTO_BIP -socket.IPPROTO_EON -socket.IPPROTO_GGP -socket.IPPROTO_HELLO -socket.IPPROTO_IPCOMP -socket.IPPROTO_IPV4 -socket.IPPROTO_MAX -socket.IPPROTO_MOBILE -socket.IPPROTO_ND -socket.IPPROTO_VRRP -socket.IPPROTO_XTP -socket.IPV6_USE_MIN_MTU -socket.IPX_TYPE -socket.IP_RECVDSTADDR -socket.LOCAL_PEERCRED -socket.MSG_BCAST -socket.MSG_BTAG -socket.MSG_EOF -socket.MSG_ETAG -socket.MSG_MCAST -socket.MSG_NOTIFICATION -socket.NETLINK_ARPD -socket.NETLINK_ROUTE6 -socket.NETLINK_SKIP -socket.NETLINK_TAPBASE -socket.NETLINK_TCPDIAG -socket.NETLINK_W1 -socket.RDS_CANCEL_SENT_TO -socket.RDS_CMSG_RDMA_ARGS -socket.RDS_CMSG_RDMA_DEST -socket.RDS_CMSG_RDMA_MAP -socket.RDS_CMSG_RDMA_STATUS -socket.RDS_CMSG_RDMA_UPDATE -socket.RDS_CONG_MONITOR -socket.RDS_FREE_MR -socket.RDS_GET_MR -socket.RDS_GET_MR_FOR_DEST -socket.RDS_RDMA_DONTWAIT -socket.RDS_RDMA_FENCE -socket.RDS_RDMA_INVALIDATE -socket.RDS_RDMA_NOTIFY_ME -socket.RDS_RDMA_READWRITE -socket.RDS_RDMA_SILENT -socket.RDS_RDMA_USE_ONCE -socket.RDS_RECVERR -socket.SCM_CREDS -socket.SOL_ATALK -socket.SOL_AX25 -socket.SOL_HCI -socket.SOL_IPX -socket.SOL_NETROM -socket.SOL_ROSE -socket.SO_EXCLUSIVEADDRUSE -socket.SO_SETFIB -socket.SO_USELOOPBACK -socket.create_connection -socket.socketpair socketserver.BaseServer.fileno socketserver.BaseServer.get_request socketserver.BaseServer.server_bind -spwd.getspnam -spwd.struct_spwd._asdict -spwd.struct_spwd._make -spwd.struct_spwd._replace sqlite3.Row.__len__ sqlite3.dbapi2.Row.__len__ sqlite3.dbapi2.register_adapters_and_converters @@ -721,8 +410,9 @@ sqlite3.register_adapters_and_converters sqlite3.version_info sre_constants.error.__init__ ssl.PROTOCOL_SSLv2 -ssl.PROTOCOL_SSLv3 -ssl.RAND_egd +ssl.Purpose.__new__ +ssl.SSLContext.__new__ +ssl.SSLObject.__init__ ssl.SSLSocket.connect ssl.SSLSocket.connect_ex ssl.SSLSocket.recv @@ -731,21 +421,15 @@ ssl.SSLSocket.recvfrom ssl.SSLSocket.recvfrom_into ssl.SSLSocket.sendto ssl._ASN1Object.__new__ -subprocess.Popen.send_signal -subprocess.call +subprocess.Popen.__init__ sunau.Au_write.getmark sunau.Au_write.getmarkers sunau.Au_write.setcomptype sunau.Au_write.setmark +symtable.Symbol.__init__ +symtable.SymbolTable.__init__ sys.gettotalrefcount -sys.getwindowsversion sys.implementation -sys.last_traceback -sys.last_type -sys.last_value -sys.ps1 -sys.ps2 -sys.tracebacklimit sysconfig.is_python_build sysconfig.parse_config_h tarfile.TarFile.__init__ @@ -755,20 +439,17 @@ tempfile.SpooledTemporaryFile.__next__ tempfile.SpooledTemporaryFile.readable tempfile.SpooledTemporaryFile.seekable tempfile.SpooledTemporaryFile.writable -threading.BoundedSemaphore.__enter__ -threading.BoundedSemaphore.acquire threading.Condition.acquire threading.Condition.release threading.Lock threading.Semaphore.__enter__ threading.Semaphore.acquire threading.Thread.__init__ -time.CLOCK_HIGHRES timeit.main +trace.CoverageResults.__init__ traceback.FrameSummary.__init__ traceback.TracebackException.__init__ traceback.TracebackException.from_exception -tracemalloc.Snapshot.load types.GetSetDescriptorType.__get__ types.GetSetDescriptorType.__set__ types.MemberDescriptorType.__get__ @@ -778,23 +459,16 @@ types.coroutine types.new_class types.prepare_class typing.AwaitableGenerator -typing.Generic typing.IO.__iter__ typing.IO.__next__ -typing.IO.closed -typing.Match -typing.NamedTuple._asdict -typing.NamedTuple._make -typing.NamedTuple._replace -typing.Pattern -typing.TypeAlias -typing.cast typing.type_check_only unittest.TestCase.assertAlmostEqual unittest.TestCase.assertDictContainsSubset unittest.TestCase.assertNotAlmostEqual unittest.TestCase.assertSequenceEqual unittest.TestLoader.loadTestsFromModule +unittest.TestProgram.__init__ +unittest.TestResult.__init__ unittest.TestResult.addSubTest unittest.TestRunner unittest.TestSuite.run @@ -806,30 +480,23 @@ unittest.case.expectedFailure unittest.expectedFailure unittest.loader.TestLoader.loadTestsFromModule unittest.main +unittest.mock.NonCallableMock.__init__ +unittest.mock.NonCallableMock.__new__ unittest.removeHandler +unittest.result.TestResult.__init__ unittest.result.TestResult.addSubTest unittest.runner.TestRunner unittest.signals.removeHandler unittest.suite.TestSuite.run +urllib.error.ContentTooShortError.__init__ +urllib.error.URLError.__init__ +urllib.parse._DefragResultBase.__new__ urllib.request.BaseHandler.http_error_nnn -urllib.request.proxy_bypass -urllib.response.addbase.__next__ -urllib.response.addbase.fileno -urllib.response.addbase.flush -urllib.response.addbase.isatty -urllib.response.addbase.read -urllib.response.addbase.readable -urllib.response.addbase.readline -urllib.response.addbase.readlines -urllib.response.addbase.seek -urllib.response.addbase.seekable -urllib.response.addbase.tell -urllib.response.addbase.truncate -urllib.response.addbase.writable -urllib.response.addbase.write -urllib.response.addbase.writelines +urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ urllib.robotparser.RobotFileParser.can_fetch +warnings.catch_warnings.__init__ weakref.CallableProxyType.__getattr__ +weakref.KeyedRef.__new__ weakref.ProxyType.__getattr__ weakref.ReferenceType.__call__ weakref.WeakKeyDictionary.__init__ @@ -845,18 +512,54 @@ webbrowser.UnixBrowser.raise_opts webbrowser.UnixBrowser.remote_action webbrowser.UnixBrowser.remote_action_newtab webbrowser.UnixBrowser.remote_action_newwin -winsound -wsgiref.types -wsgiref.util.FileWrapper.__init__ -wsgiref.util.FileWrapper.close +wsgiref.types # Doesn't exist, see comments in file xml.etree.ElementPath._SelectorContext.parent_map xml.etree.ElementTree.Element.__bool__ xml.etree.ElementTree.Element.copy -xml.etree.ElementTree.TreeBuilder.start -xml.etree.cElementTree.Element.__bool__ -xml.etree.cElementTree.Element.copy -xml.etree.cElementTree.TreeBuilder.start xml.sax.xmlreader.AttributesImpl.has_key zipfile.ZipExtFile.read zipfile.ZipExtFile.readline zlib.compressobj + +# ========== +# Whitelist entries that cannot or should not be fixed +# ========== +_pydecimal.* # See comments in file +ast.NodeVisitor.visit_\w+ # Methods are discovered dynamically, see #3796 +# Weird special builtins that are typed as functions, but aren't functions +builtins.copyright +builtins.credits +builtins.exit +builtins.help +builtins.license +builtins.quit +# Builtins that mypy pretends exist +builtins.reveal_locals +builtins.reveal_type +# Various classes in typing aren't types at runtime. In addition, mypy thinks some special forms are tautologically defined. +typing.[A-Z]\w+ +# We can't distinguish not having a default value from having a default value of inspect.Parameter.empty +inspect.Parameter.__init__ +inspect.Signature.__init__ +os.[a-z]+_(param|result)._(asdict|make|replace) # NamedTuple like, but not actually NamedTuples +# sys attributes that are not always defined +sys.last_traceback +sys.last_type +sys.last_value +sys.ps1 +sys.ps2 +sys.tracebacklimit +# See comments in file. List out methods that are delegated by __getattr__ at runtime. +# Used to make the relevant class satisfy BinaryIO interface. +codecs.StreamReaderWriter.\w+ +codecs.StreamRecoder.\w+ +urllib.response.addbase.\w+ + +# Platform differences that cannot be captured by the type system +errno.[A-Z0-9]+ +os.O_[A-Z_]+ +(posix.O_[A-Z_]+)? +(posix.ST_[A-Z]+)? +socket.AF_DECnet +socket.[A-Z0-9_]+ +(termios.[A-Z0-9_]+)? diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/win32-py35.txt b/python/helpers/typeshed/tests/stubtest_whitelists/win32-py35.txt new file mode 100644 index 000000000000..e3f4bd9f8294 --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/win32-py35.txt @@ -0,0 +1 @@ +posixpath.splitunc # This doesn't exist, but our hands are tied by check_consistent diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/win32-py36.txt b/python/helpers/typeshed/tests/stubtest_whitelists/win32-py36.txt new file mode 100644 index 000000000000..4d948912a9ec --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/win32-py36.txt @@ -0,0 +1,3 @@ +hashlib.scrypt +os.startfile +posixpath.splitunc # This doesn't exist, but our hands are tied by check_consistent diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/win32-py37.txt b/python/helpers/typeshed/tests/stubtest_whitelists/win32-py37.txt new file mode 100644 index 000000000000..902e132e9003 --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/win32-py37.txt @@ -0,0 +1 @@ +os.startfile \ No newline at end of file diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/win32-py38.txt b/python/helpers/typeshed/tests/stubtest_whitelists/win32-py38.txt new file mode 100644 index 000000000000..6927638e495f --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/win32-py38.txt @@ -0,0 +1,2 @@ +os._AddedDllDirectory.__init__ # Parameters mismatch +importlib.metadata.DistributionFinder.Context.pattern \ No newline at end of file diff --git a/python/helpers/typeshed/tests/stubtest_whitelists/win32.txt b/python/helpers/typeshed/tests/stubtest_whitelists/win32.txt new file mode 100644 index 000000000000..cc0e88fb2870 --- /dev/null +++ b/python/helpers/typeshed/tests/stubtest_whitelists/win32.txt @@ -0,0 +1,39 @@ +ctypes.GetLastError # Is actually a pointer +locale.[A-Z0-9_]+ # Constants that should be moved to _locale and re-exported conditionally +locale.nl_langinfo # Function that should be moved to _locale and re-exported conditionally +os.path.join # Parameter name mismatch +posixpath.altsep # Type mismatch +posixpath.realpath # Parameter name mismatch +urllib.request.pathname2url # Parameter name mismatch +urllib.request.url2pathname # Same + +# ========== +# Whitelist entries that cannot or should not be fixed +# ========== + +# Modules that do not exist on Windows systems +_curses +_posixsubprocess +asyncio.unix_events +crypt +dbm.gnu +fcntl +grp +nis +posix +pwd +readline +resource +spwd +syslog +termios + +# Modules that rely on _curses +curses +curses.ascii +curses.panel +curses.textpad + +# Modules that rely on termios +pty +tty diff --git a/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi b/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi index 4439dcadb523..9dfe12bac79e 100644 --- a/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi @@ -1,3 +1,18 @@ -from ._base import * # noqa: F403 -from .thread import * # noqa: F403 -from .process import * # noqa: F403 +import sys +from ._base import ( + FIRST_COMPLETED as FIRST_COMPLETED, + FIRST_EXCEPTION as FIRST_EXCEPTION, + ALL_COMPLETED as ALL_COMPLETED, + CancelledError as CancelledError, + TimeoutError as TimeoutError, + Future as Future, + Executor as Executor, + wait as wait, + as_completed as as_completed, +) +if sys.version_info >= (3, 8): + from ._base import InvalidStateError as InvalidStateError +if sys.version_info >= (3, 7): + from ._base import BrokenExecutor as BrokenExecutor +from .thread import ThreadPoolExecutor as ThreadPoolExecutor +from .process import ProcessPoolExecutor as ProcessPoolExecutor diff --git a/python/helpers/typeshed/third_party/2/concurrent/futures/_base.pyi b/python/helpers/typeshed/third_party/2/concurrent/futures/_base.pyi index 00ff41d76959..27caf7c3ccff 100644 --- a/python/helpers/typeshed/third_party/2/concurrent/futures/_base.pyi +++ b/python/helpers/typeshed/third_party/2/concurrent/futures/_base.pyi @@ -17,6 +17,8 @@ LOGGER: Logger class Error(Exception): ... class CancelledError(Error): ... class TimeoutError(Error): ... +if sys.version_info >= (3, 8): + class InvalidStateError(Error): ... if sys.version_info >= (3, 7): class BrokenExecutor(RuntimeError): ... diff --git a/python/helpers/typeshed/third_party/2/concurrent/futures/process.pyi b/python/helpers/typeshed/third_party/2/concurrent/futures/process.pyi index ca22879c02fe..960a59f50f0d 100644 --- a/python/helpers/typeshed/third_party/2/concurrent/futures/process.pyi +++ b/python/helpers/typeshed/third_party/2/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/python/helpers/typeshed/third_party/2/ipaddress.pyi b/python/helpers/typeshed/third_party/2/ipaddress.pyi index daeb8e96f9e2..5c7d9a2db225 100644 --- a/python/helpers/typeshed/third_party/2/ipaddress.pyi +++ b/python/helpers/typeshed/third_party/2/ipaddress.pyi @@ -86,7 +86,7 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): def max_prefixlen(self) -> int: ... @property def num_addresses(self) -> int: ... - def overlaps(self: _T, other: _T) -> bool: ... + def overlaps(self, other: _BaseNetwork) -> bool: ... @property def prefixlen(self) -> int: ... if sys.version_info >= (3, 7): diff --git a/python/helpers/typeshed/third_party/2/pathlib2.pyi b/python/helpers/typeshed/third_party/2/pathlib2.pyi index b470d1f0dfc0..b76f2ec5b938 100644 --- a/python/helpers/typeshed/third_party/2/pathlib2.pyi +++ b/python/helpers/typeshed/third_party/2/pathlib2.pyi @@ -1,4 +1,6 @@ -from typing import Any, Generator, IO, Optional, Sequence, Tuple, Type, TypeVar, Union, List +from io import _OpenBinaryMode, _OpenTextMode +from typing import (Any, BinaryIO, Generator, IO, List, Optional, Sequence, + TextIO, Tuple, Type, TypeVar, Union, overload) from types import TracebackType import os import sys @@ -43,12 +45,16 @@ class PurePath(_PurePathBase): def as_uri(self) -> str: ... def is_absolute(self) -> bool: ... def is_reserved(self) -> bool: ... + if sys.version_info >= (3, 9): + def is_relative_to(self, *other: Union[str, os.PathLike[str]]) -> bool: ... def match(self, path_pattern: str) -> bool: ... if sys.version_info < (3, 6): def relative_to(self: _P, *other: Union[str, PurePath]) -> _P: ... else: def relative_to(self: _P, *other: Union[str, os.PathLike[str]]) -> _P: ... def with_name(self: _P, name: str) -> _P: ... + if sys.version_info >= (3, 9): + def with_stem(self: _P, stem: str) -> _P: ... def with_suffix(self: _P, suffix: str) -> _P: ... if sys.version_info < (3, 6): def joinpath(self: _P, *other: Union[str, PurePath]) -> _P: ... @@ -93,15 +99,24 @@ class Path(PurePath): else: def mkdir(self, mode: int = ..., parents: bool = ..., exist_ok: bool = ...) -> None: ... - def open(self, mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., errors: Optional[str] = ..., + @overload + def open(self, mode: _OpenTextMode = ..., buffering: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., + newline: Optional[str] = ...) -> TextIO: ... + @overload + def open(self, mode: _OpenBinaryMode, buffering: int = ..., encoding: None = ..., errors: None = ..., + newline: None = ...) -> BinaryIO: ... + @overload + def open(self, mode: str, buffering: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ...) -> IO[Any]: ... def owner(self) -> str: ... + if sys.version_info >= (3, 9): + def readlink(self: _P) -> _P: ... 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/python/helpers/typeshed/third_party/2and3/attr/__init__.pyi b/python/helpers/typeshed/third_party/2and3/attr/__init__.pyi index fcb93b18e36f..38f16f06ba0c 100644 --- a/python/helpers/typeshed/third_party/2and3/attr/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/attr/__init__.pyi @@ -20,12 +20,27 @@ from . import filters as filters from . import converters as converters from . import validators as validators +from ._version_info import VersionInfo + +__version__: str +__version_info__: VersionInfo +__title__: str +__description__: str +__url__: str +__uri__: str +__author__: str +__email__: str +__license__: str +__copyright__: str + _T = TypeVar("_T") _C = TypeVar("_C", bound=type) _ValidatorType = Callable[[Any, Attribute[_T], _T], Any] _ConverterType = Callable[[Any], _T] _FilterType = Callable[[Attribute[_T], _T], bool] +_ReprType = Callable[[Any], str] +_ReprArgType = Union[bool, _ReprType] # FIXME: in reality, if multiple validators are passed they must be in a list or tuple, # but those are invariant and so would prevent subtypes of _ValidatorType from working # when passed in a list or tuple. @@ -49,18 +64,16 @@ class Attribute(Generic[_T]): name: str default: Optional[_T] validator: Optional[_ValidatorType[_T]] - repr: bool + repr: _ReprArgType cmp: bool + eq: bool + order: bool hash: Optional[bool] init: bool converter: Optional[_ConverterType[_T]] metadata: Dict[Any, Any] type: Optional[Type[_T]] kw_only: bool - def __lt__(self, x: Attribute[_T]) -> bool: ... - def __le__(self, x: Attribute[_T]) -> bool: ... - def __gt__(self, x: Attribute[_T]) -> bool: ... - def __ge__(self, x: Attribute[_T]) -> bool: ... # NOTE: We had several choices for the annotation to use for type arg: # 1) Type[_T] @@ -89,16 +102,17 @@ class Attribute(Generic[_T]): def attrib( default: None = ..., validator: None = ..., - repr: bool = ..., - cmp: bool = ..., + repr: _ReprArgType = ..., + cmp: Optional[bool] = ..., hash: Optional[bool] = ..., init: bool = ..., - convert: None = ..., metadata: Optional[Mapping[Any, Any]] = ..., type: None = ..., converter: None = ..., factory: None = ..., kw_only: bool = ..., + eq: Optional[bool] = ..., + order: Optional[bool] = ..., ) -> Any: ... # This form catches an explicit None or no default and infers the type from the other arguments. @@ -106,16 +120,17 @@ def attrib( def attrib( default: None = ..., validator: Optional[_ValidatorArgType[_T]] = ..., - repr: bool = ..., - cmp: bool = ..., + repr: _ReprArgType = ..., + cmp: Optional[bool] = ..., hash: Optional[bool] = ..., init: bool = ..., - convert: Optional[_ConverterType[_T]] = ..., metadata: Optional[Mapping[Any, Any]] = ..., type: Optional[Type[_T]] = ..., converter: Optional[_ConverterType[_T]] = ..., factory: Optional[Callable[[], _T]] = ..., kw_only: bool = ..., + eq: Optional[bool] = ..., + order: Optional[bool] = ..., ) -> _T: ... # This form catches an explicit default argument. @@ -123,16 +138,17 @@ def attrib( def attrib( default: _T, validator: Optional[_ValidatorArgType[_T]] = ..., - repr: bool = ..., - cmp: bool = ..., + repr: _ReprArgType = ..., + cmp: Optional[bool] = ..., hash: Optional[bool] = ..., init: bool = ..., - convert: Optional[_ConverterType[_T]] = ..., metadata: Optional[Mapping[Any, Any]] = ..., type: Optional[Type[_T]] = ..., converter: Optional[_ConverterType[_T]] = ..., factory: Optional[Callable[[], _T]] = ..., kw_only: bool = ..., + eq: Optional[bool] = ..., + order: Optional[bool] = ..., ) -> _T: ... # This form covers type=non-Type: e.g. forward references (str), Any @@ -140,16 +156,17 @@ def attrib( def attrib( default: Optional[_T] = ..., validator: Optional[_ValidatorArgType[_T]] = ..., - repr: bool = ..., - cmp: bool = ..., + repr: _ReprArgType = ..., + cmp: Optional[bool] = ..., hash: Optional[bool] = ..., init: bool = ..., - convert: Optional[_ConverterType[_T]] = ..., metadata: Optional[Mapping[Any, Any]] = ..., type: object = ..., converter: Optional[_ConverterType[_T]] = ..., factory: Optional[Callable[[], _T]] = ..., kw_only: bool = ..., + eq: Optional[bool] = ..., + order: Optional[bool] = ..., ) -> Any: ... @overload def attrs( @@ -157,7 +174,7 @@ def attrs( these: Optional[Dict[str, Any]] = ..., repr_ns: Optional[str] = ..., repr: bool = ..., - cmp: bool = ..., + cmp: Optional[bool] = ..., hash: Optional[bool] = ..., init: bool = ..., slots: bool = ..., @@ -168,6 +185,8 @@ def attrs( kw_only: bool = ..., cache_hash: bool = ..., auto_exc: bool = ..., + eq: Optional[bool] = ..., + order: Optional[bool] = ..., ) -> _C: ... @overload def attrs( @@ -175,7 +194,7 @@ def attrs( these: Optional[Dict[str, Any]] = ..., repr_ns: Optional[str] = ..., repr: bool = ..., - cmp: bool = ..., + cmp: Optional[bool] = ..., hash: Optional[bool] = ..., init: bool = ..., slots: bool = ..., @@ -186,6 +205,8 @@ def attrs( kw_only: bool = ..., cache_hash: bool = ..., auto_exc: bool = ..., + eq: Optional[bool] = ..., + order: Optional[bool] = ..., ) -> Callable[[_C], _C]: ... # TODO: add support for returning NamedTuple from the mypy plugin @@ -204,7 +225,7 @@ def make_class( bases: Tuple[type, ...] = ..., repr_ns: Optional[str] = ..., repr: bool = ..., - cmp: bool = ..., + cmp: Optional[bool] = ..., hash: Optional[bool] = ..., init: bool = ..., slots: bool = ..., @@ -215,6 +236,8 @@ def make_class( kw_only: bool = ..., cache_hash: bool = ..., auto_exc: bool = ..., + eq: Optional[bool] = ..., + order: Optional[bool] = ..., ) -> type: ... # _funcs -- diff --git a/python/helpers/typeshed/third_party/2and3/attr/_version_info.pyi b/python/helpers/typeshed/third_party/2and3/attr/_version_info.pyi new file mode 100644 index 000000000000..45ced0863377 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/attr/_version_info.pyi @@ -0,0 +1,9 @@ +class VersionInfo: + @property + def year(self) -> int: ... + @property + def minor(self) -> int: ... + @property + def micro(self) -> int: ... + @property + def releaselevel(self) -> str: ... diff --git a/python/helpers/typeshed/third_party/2and3/attr/exceptions.pyi b/python/helpers/typeshed/third_party/2and3/attr/exceptions.pyi index 48fffcc1e2df..736fde2e1d20 100644 --- a/python/helpers/typeshed/third_party/2and3/attr/exceptions.pyi +++ b/python/helpers/typeshed/third_party/2and3/attr/exceptions.pyi @@ -1,3 +1,5 @@ +from typing import Any + class FrozenInstanceError(AttributeError): msg: str = ... @@ -5,3 +7,9 @@ class AttrsAttributeNotFoundError(ValueError): ... class NotAnAttrsClassError(ValueError): ... class DefaultAlreadySetError(RuntimeError): ... class UnannotatedAttributeError(RuntimeError): ... +class PythonTooOldError(RuntimeError): ... + +class NotCallableError(TypeError): + msg: str = ... + value: Any = ... + def __init__(self, msg: str, value: Any) -> None: ... diff --git a/python/helpers/typeshed/third_party/2and3/attr/validators.pyi b/python/helpers/typeshed/third_party/2and3/attr/validators.pyi index 01af06845ec3..9a22abb197d7 100644 --- a/python/helpers/typeshed/third_party/2and3/attr/validators.pyi +++ b/python/helpers/typeshed/third_party/2and3/attr/validators.pyi @@ -1,24 +1,66 @@ -from typing import Container, List, Union, TypeVar, Type, Any, Optional, Tuple +from typing import ( + Container, + List, + Union, + TypeVar, + Type, + Any, + Optional, + Tuple, + Iterable, + Mapping, + Callable, + Match, + AnyStr, + overload, +) from . import _ValidatorType _T = TypeVar("_T") +_T1 = TypeVar("_T1") +_T2 = TypeVar("_T2") +_T3 = TypeVar("_T3") +_I = TypeVar("_I", bound=Iterable) +_K = TypeVar("_K") +_V = TypeVar("_V") +_M = TypeVar("_M", bound=Mapping) +# To be more precise on instance_of use some overloads. +# If there are more than 3 items in the tuple then we fall back to Any +@overload +def instance_of(type: Type[_T]) -> _ValidatorType[_T]: ... +@overload +def instance_of(type: Tuple[Type[_T]]) -> _ValidatorType[_T]: ... +@overload def instance_of( - type: Union[Tuple[Type[_T], ...], Type[_T]] -) -> _ValidatorType[_T]: ... + type: Tuple[Type[_T1], Type[_T2]] +) -> _ValidatorType[Union[_T1, _T2]]: ... +@overload +def instance_of( + type: Tuple[Type[_T1], Type[_T2], Type[_T3]] +) -> _ValidatorType[Union[_T1, _T2, _T3]]: ... +@overload +def instance_of(type: Tuple[type, ...]) -> _ValidatorType[Any]: ... def provides(interface: Any) -> _ValidatorType[Any]: ... def optional( validator: Union[_ValidatorType[_T], List[_ValidatorType[_T]]] ) -> _ValidatorType[Optional[_T]]: ... def in_(options: Container[_T]) -> _ValidatorType[_T]: ... def and_(*validators: _ValidatorType[_T]) -> _ValidatorType[_T]: ... +def matches_re( + regex: AnyStr, + flags: int = ..., + func: Optional[ + Callable[[AnyStr, AnyStr, int], Optional[Match[AnyStr]]] + ] = ..., +) -> _ValidatorType[AnyStr]: ... def deep_iterable( member_validator: _ValidatorType[_T], - iterable_validator: Optional[_ValidatorType[_T]], -) -> _ValidatorType[_T]: ... + iterable_validator: Optional[_ValidatorType[_I]] = ..., +) -> _ValidatorType[_I]: ... def deep_mapping( - key_validator: _ValidatorType[_T], - value_validator: _ValidatorType[_T], - mapping_validator: Optional[_ValidatorType[_T]], -) -> _ValidatorType[_T]: ... + key_validator: _ValidatorType[_K], + value_validator: _ValidatorType[_V], + mapping_validator: Optional[_ValidatorType[_M]] = ..., +) -> _ValidatorType[_M]: ... def is_callable() -> _ValidatorType[_T]: ... diff --git a/python/helpers/typeshed/third_party/2and3/cryptography/fernet.pyi b/python/helpers/typeshed/third_party/2and3/cryptography/fernet.pyi index 8ce2d7937588..058cd15ce228 100644 --- a/python/helpers/typeshed/third_party/2and3/cryptography/fernet.pyi +++ b/python/helpers/typeshed/third_party/2and3/cryptography/fernet.pyi @@ -1,9 +1,9 @@ -from typing import List, Optional +from typing import List, Optional, Union, Text class InvalidToken(Exception): ... class Fernet(object): - def __init__(self, key: bytes) -> None: ... + def __init__(self, key: Union[bytes, Text]) -> None: ... def decrypt(self, token: bytes, ttl: Optional[int] = ...) -> bytes: ... def encrypt(self, data: bytes) -> bytes: ... def extract_timestamp(self, token: bytes) -> int: ... diff --git a/python/helpers/typeshed/third_party/2and3/cryptography/hazmat/primitives/asymmetric/ec.pyi b/python/helpers/typeshed/third_party/2and3/cryptography/hazmat/primitives/asymmetric/ec.pyi index f8b7e1638f8b..137f7138bc5c 100644 --- a/python/helpers/typeshed/third_party/2and3/cryptography/hazmat/primitives/asymmetric/ec.pyi +++ b/python/helpers/typeshed/third_party/2and3/cryptography/hazmat/primitives/asymmetric/ec.pyi @@ -183,7 +183,7 @@ class EllipticCurveSignatureAlgorithm(metaclass=ABCMeta): class ECDH(object): ... class ECDSA(EllipticCurveSignatureAlgorithm): - def __init__(self, algorithm: HashAlgorithm): ... + def __init__(self, algorithm: Union[HashAlgorithm, Prehashed]): ... @property def algorithm(self) -> Union[HashAlgorithm, Prehashed]: ... diff --git a/python/helpers/typeshed/third_party/2and3/cryptography/hazmat/primitives/asymmetric/utils.pyi b/python/helpers/typeshed/third_party/2and3/cryptography/hazmat/primitives/asymmetric/utils.pyi index 136d270db420..610a517f2639 100644 --- a/python/helpers/typeshed/third_party/2and3/cryptography/hazmat/primitives/asymmetric/utils.pyi +++ b/python/helpers/typeshed/third_party/2and3/cryptography/hazmat/primitives/asymmetric/utils.pyi @@ -1,6 +1,16 @@ -from typing import Tuple +from typing import Optional, Tuple +from cryptography.hazmat.primitives.hashes import HashAlgorithm + def decode_dss_signature(signature: bytes) -> Tuple[int, int]: ... + + def encode_dss_signature(r: int, s: int) -> bytes: ... -class Prehashed(object): ... + +class Prehashed(object): + _algorithm: HashAlgorithm # undocumented + _digest_size: int # undocumented + def __init__(self, algorithm: HashAlgorithm) -> None: ... + + digest_size: int diff --git a/python/helpers/typeshed/third_party/2and3/mock.pyi b/python/helpers/typeshed/third_party/2and3/mock.pyi index d8ed01ea0fd9..0d2cd387b93c 100644 --- a/python/helpers/typeshed/third_party/2and3/mock.pyi +++ b/python/helpers/typeshed/third_party/2and3/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: ... @@ -104,7 +123,7 @@ class CallableMixin(Base): def __init__(self, spec: Optional[Any] = ..., side_effect: Optional[Any] = ..., return_value: Any = ..., wraps: Optional[Any] = ..., name: Optional[Any] = ..., spec_set: Optional[Any] = ..., parent: Optional[Any] = ..., _spec_state: Optional[Any] = ..., _new_name: Any = ..., _new_parent: Optional[Any] = ..., **kwargs: Any) -> None: ... def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ... -Mock = Any +class Mock(CallableMixin, NonCallableMock): ... class _patch: attribute_name: Any @@ -158,8 +177,12 @@ patch: _patcher class MagicMixin: def __init__(self, *args: Any, **kw: Any) -> None: ... -NonCallableMagicMock = Any -MagicMock = Any +class NonCallableMagicMock(MagicMixin, NonCallableMock): + def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ... + +class MagicMock(MagicMixin, Mock): + def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ... + if sys.version_info >= (3, 8): AsyncMock = Any diff --git a/python/helpers/typeshed/third_party/2and3/requests/__init__.pyi b/python/helpers/typeshed/third_party/2and3/requests/__init__.pyi index 7705d78b484b..07d0efbacdb1 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/__init__.pyi @@ -9,32 +9,36 @@ from . import exceptions from . import packages import logging +from .models import Request as Request +from .models import Response as Response +from .models import PreparedRequest as PreparedRequest + +from .api import request as request +from .api import get as get +from .api import head as head +from .api import post as post +from .api import patch as patch +from .api import put as put +from .api import delete as delete +from .api import options as options + +from .sessions import session as session +from .sessions import Session as Session + +from .status_codes import codes as codes + +from .exceptions import RequestException as RequestException +from .exceptions import Timeout as Timeout +from .exceptions import URLRequired as URLRequired +from .exceptions import TooManyRedirects as TooManyRedirects +from .exceptions import HTTPError as HTTPError +from .exceptions import ConnectionError as ConnectionError + __title__: Any __build__: Any __license__: Any __copyright__: Any __version__: Any -Request = models.Request -Response = models.Response -PreparedRequest = models.PreparedRequest -request = api.request -get = api.get -head = api.head -post = api.post -patch = api.patch -put = api.put -delete = api.delete -options = api.options -session = sessions.session -Session = sessions.Session -codes = status_codes.codes -RequestException = exceptions.RequestException -Timeout = exceptions.Timeout -URLRequired = exceptions.URLRequired -TooManyRedirects = exceptions.TooManyRedirects -HTTPError = exceptions.HTTPError -ConnectionError = exceptions.ConnectionError - class NullHandler(logging.Handler): def emit(self, record): ... diff --git a/python/helpers/typeshed/third_party/2and3/werkzeug/exceptions.pyi b/python/helpers/typeshed/third_party/2and3/werkzeug/exceptions.pyi index 36b14ee82b08..41f8012b50a0 100644 --- a/python/helpers/typeshed/third_party/2and3/werkzeug/exceptions.pyi +++ b/python/helpers/typeshed/third_party/2and3/werkzeug/exceptions.pyi @@ -1,3 +1,4 @@ +import datetime from typing import Any, Dict, Tuple, List, Text, NoReturn, Optional, Protocol, Type, Union, Iterable from wsgiref.types import WSGIEnvironment, StartResponse @@ -124,7 +125,16 @@ class PreconditionRequired(HTTPException): code: int description: Text -class TooManyRequests(HTTPException): +class _RetryAfter(HTTPException): + retry_after: Union[None, int, datetime.datetime] + def __init__( + self, + description: Optional[Text] = ..., + response: Optional[Response] = ..., + retry_after: Union[None, int, datetime.datetime] = ..., + ) -> None: ... + +class TooManyRequests(_RetryAfter): code: int description: Text @@ -148,7 +158,7 @@ class BadGateway(HTTPException): code: int description: Text -class ServiceUnavailable(HTTPException): +class ServiceUnavailable(_RetryAfter): code: int description: Text diff --git a/python/helpers/typeshed/third_party/2and3/werkzeug/serving.pyi b/python/helpers/typeshed/third_party/2and3/werkzeug/serving.pyi index 54bce9784bb6..5b5305014c8d 100644 --- a/python/helpers/typeshed/third_party/2and3/werkzeug/serving.pyi +++ b/python/helpers/typeshed/third_party/2and3/werkzeug/serving.pyi @@ -2,12 +2,20 @@ import sys from typing import Any, Optional if sys.version_info < (3,): - from SocketServer import ThreadingMixIn, ForkingMixIn + from SocketServer import ThreadingMixIn from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler else: - from socketserver import ThreadingMixIn, ForkingMixIn + from socketserver import ThreadingMixIn from http.server import HTTPServer, BaseHTTPRequestHandler +if sys.platform == "win32": + class ForkingMixIn(object): ... +else: + if sys.version_info < (3,): + from SocketServer import ForkingMixIn as ForkingMixIn + else: + from socketserver import ForkingMixIn as ForkingMixIn + class _SslDummy: def __getattr__(self, name): ... diff --git a/python/helpers/typeshed/third_party/2and3/werkzeug/wrappers.pyi b/python/helpers/typeshed/third_party/2and3/werkzeug/wrappers.pyi index 45a2f009b60a..2b8b34ffeac1 100644 --- a/python/helpers/typeshed/third_party/2and3/werkzeug/wrappers.pyi +++ b/python/helpers/typeshed/third_party/2and3/werkzeug/wrappers.pyi @@ -87,11 +87,6 @@ class BaseRequest: is_multiprocess: bool is_run_once: bool - # These are not preset at runtime but we add them since monkeypatching this - # class is quite common. - def __setattr__(self, name: str, value: Any): ... - def __getattr__(self, name: str): ... - _OnCloseT = TypeVar('_OnCloseT', bound=Callable[[], Any]) _SelfT = TypeVar('_SelfT', bound=BaseResponse) diff --git a/python/helpers/typeshed/third_party/3/orjson.pyi b/python/helpers/typeshed/third_party/3/orjson.pyi index 37584705568c..cd35c5f0a532 100644 --- a/python/helpers/typeshed/third_party/3/orjson.pyi +++ b/python/helpers/typeshed/third_party/3/orjson.pyi @@ -12,7 +12,9 @@ def loads(__obj: Union[bytes, bytearray, str]) -> Any: ... class JSONDecodeError(ValueError): ... class JSONEncodeError(TypeError): ... +OPT_INDENT_2: int OPT_NAIVE_UTC: int +OPT_NON_STR_KEYS: int OPT_OMIT_MICROSECONDS: int OPT_SERIALIZE_DATACLASS: int OPT_SERIALIZE_NUMPY: int diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java index f949aca46ef4..b3f049436e76 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java @@ -30,7 +30,6 @@ import com.jetbrains.python.codeInsight.functionTypeComments.psi.PyParameterType import com.jetbrains.python.psi.*; import com.jetbrains.python.psi.impl.PyBuiltinCache; import com.jetbrains.python.psi.impl.PyCallExpressionHelper; -import com.jetbrains.python.psi.impl.PyCallExpressionNavigator; import com.jetbrains.python.psi.impl.PyPsiUtils; import com.jetbrains.python.psi.impl.stubs.PyClassElementType; import com.jetbrains.python.psi.impl.stubs.PyTypingAliasStubType; @@ -188,7 +187,7 @@ public class PyTypingTypeProvider extends PyTypeProviderBase { } } - return getTypeVarTypeForCallee(referenceExpression, context); + return null; } @Override @@ -311,33 +310,6 @@ public class PyTypingTypeProvider extends PyTypeProviderBase { return new PyCustomType(CALLABLE, null, false, true, PyBuiltinCache.getInstance(anchor).getObjectType()); } - @Nullable - private static PyType getTypeVarTypeForCallee(@NotNull PyReferenceExpression referenceExpression, @NotNull TypeEvalContext context) { - if (PyCallExpressionNavigator.getPyCallExpressionByCallee(referenceExpression) == null) return null; - - if (resolveToQualifiedNames(referenceExpression, context).contains(TYPE_VAR)) { - final List parameters = new ArrayList<>(); - - final PyBuiltinCache builtinCache = PyBuiltinCache.getInstance(referenceExpression); - final LanguageLevel languageLevel = LanguageLevel.forElement(referenceExpression); - final PyElementGenerator generator = PyElementGenerator.getInstance(referenceExpression.getProject()); - - parameters.add(PyCallableParameterImpl.nonPsi("name", builtinCache.getStringType(languageLevel))); - final PyType typeOrForwardReference = PyUnionType.union(builtinCache.getTypeType(), builtinCache.getStrType()); - parameters.add(PyCallableParameterImpl.positionalNonPsi("constraints", typeOrForwardReference)); - parameters.add(PyCallableParameterImpl.nonPsi("bound", typeOrForwardReference, generator.createEllipsis())); - - final PyClassType boolType = builtinCache.getBoolType(); - final PyExpression falseValue = generator.createExpressionFromText(languageLevel, "False"); - parameters.add(PyCallableParameterImpl.nonPsi("covariant", boolType, falseValue)); - parameters.add(PyCallableParameterImpl.nonPsi("contravariant", boolType, falseValue)); - - return new PyCallableTypeImpl(parameters, null); - } - - return null; - } - private static boolean omitFirstParamInTypeComment(@NotNull PyFunction func, @NotNull PyFunctionTypeAnnotation annotation) { return func.getContainingClass() != null && func.getModifier() != PyFunction.Modifier.STATICMETHOD && annotation.getParameterTypeList().getParameterTypes().size() < func.getParameterList().getParameters().length; @@ -410,6 +382,13 @@ public class PyTypingTypeProvider extends PyTypeProviderBase { } } + final PyClass initializedClass = PyUtil.turnConstructorIntoClass(function); + if (initializedClass != null && TYPE_VAR.equals(initializedClass.getQualifiedName())) { + // `typing.TypeVar` call should be assigned to a target and hence should be processed by [getReferenceType] + // but the corresponding type is also returned here to suppress type checker on `T = TypeVar("T")` assignment. + return Ref.create(getGenericTypeFromTypeVar(callSite, new Context(context))); + } + return null; } diff --git a/python/testData/inspections/PyTypeCheckerInspection/InitializingTypeVar.py b/python/testData/inspections/PyTypeCheckerInspection/InitializingTypeVar.py index e6f2ca65ea61..47777ef71ff6 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/InitializingTypeVar.py +++ b/python/testData/inspections/PyTypeCheckerInspection/InitializingTypeVar.py @@ -1,7 +1,7 @@ from typing import TypeVar TypeVar("T", int, str, bound=int, covariant=True, contravariant=True) -TypeVar("T", int, str, bound='int', covariant=True, contravariant=True) -TypeVar("T", int, 'str', bound=int, covariant=True, contravariant=True) -TypeVar("T", 'int', 'str', bound=int, covariant=True, contravariant=True) -TypeVar("T", 0, 1, bound=2, covariant=3, contravariant=4) \ No newline at end of file +TypeVar("T", int, str, bound='int', covariant=True, contravariant=True) +TypeVar("T", int, 'str', bound=int, covariant=True, contravariant=True) +TypeVar("T", 'int', 'str', bound=int, covariant=True, contravariant=True) +TypeVar("T", 0, 1, bound=2, covariant=3, contravariant=4) \ No newline at end of file diff --git a/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions.py b/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions.py index e121e37effa1..2b72850dd872 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions.py +++ b/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions.py @@ -28,7 +28,7 @@ class B: b = B() -open(b) +open(b) os.fspath(b) os.fsencode(b) diff --git a/python/testSrc/com/jetbrains/python/PyLineBreakpointTypeTest.kt b/python/testSrc/com/jetbrains/python/PyLineBreakpointTypeTest.kt index e2b56660db62..6abfbdba474f 100644 --- a/python/testSrc/com/jetbrains/python/PyLineBreakpointTypeTest.kt +++ b/python/testSrc/com/jetbrains/python/PyLineBreakpointTypeTest.kt @@ -39,7 +39,7 @@ class PyLineBreakpointTypeTest : PyTestCase() { // PY-16932 fun testPutAtPythonStub() { val pythonFile = PyTypeShed.directory!!.findFileByRelativePath("stdlib/2/__builtin__.pyi") - val line = 19 + val line = 23 val document = FileDocumentManager.getInstance().getDocument(pythonFile!!) val range = TextRange.create(document!!.getLineStartOffset(line), document.getLineEndOffset(line)) diff --git a/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java b/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java index 8b52f07fb2fe..d023f4499f26 100644 --- a/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java +++ b/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java @@ -1033,14 +1033,14 @@ public class PyParameterInfoTest extends LightMarkedTestCase { // PY-28127 PY-31424 public void testInitializingTypeVar() { runWithLanguageLevel( - LanguageLevel.PYTHON34, + LanguageLevel.getLatest(), () -> { final int offset = loadTest(1).get("").getTextOffset(); - feignCtrlP(offset).check("name: str, *constraints: Union[type, str], bound: Union[type, str] = ..., " + - "covariant: bool = False, contravariant: bool = False", + feignCtrlP(offset).check("self: TypeVar, name: str, *constraints: type, bound: Optional[type] = ..., " + + "covariant: bool = ..., contravariant: bool = ...", new String[]{"name: str, "}, - ArrayUtilRt.EMPTY_STRING_ARRAY); + new String[]{"self: TypeVar, "}); } ); }