From 9ccf9356bf35082d298604f3604fecbdb9c06443 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sat, 27 Jul 2019 10:58:21 +0200 Subject: [PATCH] Remove Python 3.4 support (#3147) Closes #3123 --- CONTRIBUTING.md | 18 +- README.md | 2 +- stdlib/2and3/binascii.pyi | 11 +- stdlib/2and3/smtpd.pyi | 16 +- stdlib/2and3/ssl.pyi | 150 ++-- stdlib/2and3/tarfile.pyi | 3 - stdlib/2and3/webbrowser.pyi | 13 +- stdlib/3/_imp.pyi | 7 +- stdlib/3/_operator.pyi | 4 +- stdlib/3/asyncio/__init__.pyi | 13 +- stdlib/3/asyncio/base_events.pyi | 6 +- stdlib/3/asyncio/events.pyi | 10 +- stdlib/3/asyncio/futures.pyi | 3 +- stdlib/3/asyncio/queues.pyi | 6 - stdlib/3/collections/__init__.pyi | 46 +- stdlib/3/collections/abc.pyi | 16 +- stdlib/3/compileall.pyi | 5 +- stdlib/3/email/message.pyi | 3 +- stdlib/3/email/policy.pyi | 3 +- stdlib/3/faulthandler.pyi | 8 +- stdlib/3/glob.pyi | 8 +- stdlib/3/heapq.pyi | 6 +- stdlib/3/html/parser.pyi | 9 +- stdlib/3/http/__init__.pyi | 124 ++-- stdlib/3/http/client.pyi | 86 +-- stdlib/3/imp.pyi | 3 +- stdlib/3/importlib/abc.pyi | 9 +- stdlib/3/importlib/util.pyi | 21 +- stdlib/3/inspect.pyi | 41 +- stdlib/3/io.pyi | 6 +- stdlib/3/ipaddress.pyi | 6 +- stdlib/3/json/__init__.pyi | 3 +- stdlib/3/json/decoder.pyi | 15 +- stdlib/3/lzma.pyi | 5 +- stdlib/3/os/__init__.pyi | 364 ++++------ stdlib/3/posix.pyi | 3 +- stdlib/3/signal.pyi | 120 ++-- stdlib/3/smtplib.pyi | 24 +- stdlib/3/subprocess.pyi | 761 +++++++++++---------- stdlib/3/symbol.pyi | 9 +- stdlib/3/sys.pyi | 3 +- stdlib/3/tempfile.pyi | 164 ++--- stdlib/3/typing.pyi | 25 +- stdlib/3/unittest/loader.pyi | 10 +- stdlib/3/unittest/runner.pyi | 26 +- stdlib/3/urllib/parse.pyi | 21 +- stdlib/3/urllib/request.pyi | 19 +- stdlib/{3.5 => 3}/zipapp.pyi | 0 tests/check_consistent.py | 3 +- tests/mypy_test.py | 2 +- third_party/2and3/boto/utils.pyi | 2 +- third_party/2and3/markupsafe/__init__.pyi | 2 +- third_party/2and3/markupsafe/_compat.pyi | 2 +- third_party/{3.5 => 3}/contextvars.pyi | 0 third_party/3/pkg_resources/py31compat.pyi | 9 +- 55 files changed, 988 insertions(+), 1266 deletions(-) rename stdlib/{3.5 => 3}/zipapp.pyi (100%) rename third_party/{3.5 => 3}/contextvars.pyi (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 045d07f65..d5f09b179 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -307,8 +307,8 @@ and optionally the lowest minor version, with the exception of the `2and3` directory which applies to both Python 2 and 3. For example, stubs in the `3` directory will be applied to all versions of -Python 3, though stubs in the `3.6` directory will only be applied to versions -3.6 and above. However, stubs in the `2` directory will not be applied to +Python 3, though stubs in the `3.7` directory will only be applied to versions +3.7 and above. However, stubs in the `2` directory will not be applied to Python 3. It is preferred to use a single stub in the more generic directory that @@ -318,7 +318,7 @@ if the given library works on both Python 2 and Python 3, prefer to put your stubs in the `2and3` directory, unless the types are so different that the stubs become unreadable that way. -You can use checks like `if sys.version_info >= (3, 4):` to denote new +You can use checks like `if sys.version_info >= (3, 8):` to denote new functionality introduced in a given Python version or solve type differences. When doing so, only use one-tuples or two-tuples. This is because: @@ -331,17 +331,17 @@ because: regardless of the micro version used. Because of this, if a given functionality was introduced in, say, Python -3.4.4, your check: +3.7.4, your check: -* should be expressed as `if sys.version_info >= (3, 4):` -* should NOT be expressed as `if sys.version_info >= (3, 4, 4):` -* should NOT be expressed as `if sys.version_info >= (3, 5):` +* should be expressed as `if sys.version_info >= (3, 7):` +* should NOT be expressed as `if sys.version_info >= (3, 7, 4):` +* should NOT be expressed as `if sys.version_info >= (3, 8):` This makes the type checker assume the functionality was also available -in 3.4.0 - 3.4.3, which while *technically* incorrect is relatively +in 3.7.0 - 3.7.3, which while *technically* incorrect is relatively harmless. This is a strictly better compromise than using the latter two forms, which would generate false positive errors for correct use -under Python 3.4.4. +under Python 3.7.4. Note: in its current implementation, typeshed cannot contain stubs for multiple versions of the same third-party library. Prefer to generate diff --git a/README.md b/README.md index 14f32ea72..76f3ed924 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ For information on how to use `typeshed`, read below. Information for contributors can be found in [CONTRIBUTING.md](CONTRIBUTING.md). **Please read it before submitting pull requests.** -Typeshed supports Python versions 2.7 and 3.4 and up. +Typeshed supports Python versions 2.7 and 3.5 and up. ## Using diff --git a/stdlib/2and3/binascii.pyi b/stdlib/2and3/binascii.pyi index 9689b712b..d268a1b6a 100644 --- a/stdlib/2and3/binascii.pyi +++ b/stdlib/2and3/binascii.pyi @@ -5,20 +5,15 @@ import sys from typing import Union, Text - if sys.version_info < (3,): # Python 2 accepts unicode ascii pretty much everywhere. - _Bytes = Union[bytes, Text] - _Ascii = Union[bytes, Text] -elif sys.version_info < (3, 3): - # Python 3.2 and below only accepts bytes. - _Bytes = bytes - _Ascii = bytes + _Bytes = Text + _Ascii = Text else: # But since Python 3.3 ASCII-only unicode strings are accepted by the # a2b_* functions. _Bytes = bytes - _Ascii = Union[bytes, Text] + _Ascii = Union[bytes, str] def a2b_uu(string: _Ascii) -> bytes: ... if sys.version_info >= (3, 7): diff --git a/stdlib/2and3/smtpd.pyi b/stdlib/2and3/smtpd.pyi index 923b8bc65..67599d7de 100644 --- a/stdlib/2and3/smtpd.pyi +++ b/stdlib/2and3/smtpd.pyi @@ -13,10 +13,8 @@ class SMTPChannel(asynchat.async_chat): COMMAND: int DATA: int - if sys.version_info >= (3, 3): - command_size_limits: DefaultDict[str, int] - if sys.version_info >= (3,): + command_size_limits: DefaultDict[str, int] smtp_server: SMTPServer conn: socket.socket addr: Any @@ -32,19 +30,14 @@ class SMTPChannel(asynchat.async_chat): command_size_limit: int data_size_limit: int - if sys.version_info >= (3, 5): enable_SMTPUTF8: bool - if sys.version_info >= (3, 3): @property def max_command_size_limit(self) -> int: ... - if sys.version_info >= (3, 5): + if sys.version_info >= (3,): def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ..., map: Optional[asyncore._maptype] = ..., enable_SMTPUTF8: bool = ..., decode_data: bool = ...) -> None: ... - elif sys.version_info >= (3, 4): - def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ..., - map: Optional[asyncore._maptype] = ...) -> None: ... else: def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... def push(self, msg: bytes) -> None: ... @@ -69,13 +62,10 @@ class SMTPServer(asyncore.dispatcher): data_size_limit: int enable_SMTPUTF8: bool - if sys.version_info >= (3, 5): + if sys.version_info >= (3,): def __init__(self, localaddr: _Address, remoteaddr: _Address, data_size_limit: int = ..., map: Optional[asyncore._maptype] = ..., enable_SMTPUTF8: bool = ..., decode_data: bool = ...) -> None: ... - elif sys.version_info >= (3, 4): - def __init__(self, localaddr: _Address, remoteaddr: _Address, - data_size_limit: int = ..., map: Optional[asyncore._maptype] = ...) -> None: ... else: def __init__(self, localaddr: _Address, remoteaddr: _Address, data_size_limit: int = ...) -> None: ... diff --git a/stdlib/2and3/ssl.pyi b/stdlib/2and3/ssl.pyi index c0990d967..717c0edac 100644 --- a/stdlib/2and3/ssl.pyi +++ b/stdlib/2and3/ssl.pyi @@ -48,11 +48,13 @@ def wrap_socket(sock: socket.socket, keyfile: Optional[str] = ..., ciphers: Optional[str] = ...) -> SSLSocket: ... -if sys.version_info < (3,) or sys.version_info >= (3, 4): - def create_default_context(purpose: Any = ..., *, - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[str, bytes, None] = ...) -> SSLContext: ... +def create_default_context( + purpose: Any = ..., + *, + cafile: Optional[str] = ..., + capath: Optional[str] = ..., + cadata: Union[str, bytes, None] = ..., +) -> SSLContext: ... if sys.version_info >= (3, 4): def _create_unverified_context(protocol: int = ..., *, @@ -80,39 +82,35 @@ def get_server_certificate(addr: Tuple[str, int], ssl_version: int = ..., ca_certs: Optional[str] = ...) -> str: ... def DER_cert_to_PEM_cert(der_cert_bytes: bytes) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... -if sys.version_info < (3,) or sys.version_info >= (3, 4): - DefaultVerifyPaths = NamedTuple('DefaultVerifyPaths', - [('cafile', str), ('capath', str), - ('openssl_cafile_env', str), - ('openssl_cafile', str), - ('openssl_capath_env', str), - ('openssl_capath', str)]) - def get_default_verify_paths() -> DefaultVerifyPaths: ... +DefaultVerifyPaths = NamedTuple('DefaultVerifyPaths', + [('cafile', str), ('capath', str), + ('openssl_cafile_env', str), + ('openssl_cafile', str), + ('openssl_capath_env', str), + ('openssl_capath', str)]) +def get_default_verify_paths() -> DefaultVerifyPaths: ... if sys.platform == 'win32': - if sys.version_info < (3,) or sys.version_info >= (3, 4): - def enum_certificates(store_name: str) -> _EnumRetType: ... - def enum_crls(store_name: str) -> _EnumRetType: ... + def enum_certificates(store_name: str) -> _EnumRetType: ... + def enum_crls(store_name: str) -> _EnumRetType: ... CERT_NONE: int CERT_OPTIONAL: int CERT_REQUIRED: int -if sys.version_info < (3,) or sys.version_info >= (3, 4): - VERIFY_DEFAULT: int - VERIFY_CRL_CHECK_LEAF: int - VERIFY_CRL_CHECK_CHAIN: int - VERIFY_X509_STRICT: int - VERIFY_X509_TRUSTED_FIRST: int +VERIFY_DEFAULT: int +VERIFY_CRL_CHECK_LEAF: int +VERIFY_CRL_CHECK_CHAIN: int +VERIFY_X509_STRICT: int +VERIFY_X509_TRUSTED_FIRST: int PROTOCOL_SSLv23: int PROTOCOL_SSLv2: int PROTOCOL_SSLv3: int PROTOCOL_TLSv1: int -if sys.version_info < (3,) or sys.version_info >= (3, 4): - PROTOCOL_TLSv1_1: int - PROTOCOL_TLSv1_2: int +PROTOCOL_TLSv1_1: int +PROTOCOL_TLSv1_2: int if sys.version_info >= (3, 5): PROTOCOL_TLS: int if sys.version_info >= (3, 6): @@ -123,9 +121,8 @@ OP_ALL: int OP_NO_SSLv2: int OP_NO_SSLv3: int OP_NO_TLSv1: int -if sys.version_info < (3,) or sys.version_info >= (3, 4): - OP_NO_TLSv1_1: int - OP_NO_TLSv1_2: 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 @@ -133,8 +130,7 @@ OP_NO_COMPRESSION: int if sys.version_info >= (3, 6): OP_NO_TICKET: int -if sys.version_info < (3,) or sys.version_info >= (3, 5): - HAS_ALPN: int +HAS_ALPN: int HAS_ECDH: bool HAS_SNI: bool HAS_NPN: bool @@ -144,41 +140,40 @@ OPENSSL_VERSION: str OPENSSL_VERSION_INFO: Tuple[int, int, int, int, int] OPENSSL_VERSION_NUMBER: int -if sys.version_info < (3,) or sys.version_info >= (3, 4): - ALERT_DESCRIPTION_HANDSHAKE_FAILURE: int - ALERT_DESCRIPTION_INTERNAL_ERROR: int - ALERT_DESCRIPTION_ACCESS_DENIED: int - ALERT_DESCRIPTION_BAD_CERTIFICATE: int - ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: int - ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: int - ALERT_DESCRIPTION_BAD_RECORD_MAC: int - ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: int - ALERT_DESCRIPTION_CERTIFICATE_REVOKED: int - ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: int - ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: int - ALERT_DESCRIPTION_CLOSE_NOTIFY: int - ALERT_DESCRIPTION_DECODE_ERROR: int - ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: int - ALERT_DESCRIPTION_DECRYPT_ERROR: int - ALERT_DESCRIPTION_ILLEGAL_PARAMETER: int - ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: int - ALERT_DESCRIPTION_NO_RENEGOTIATION: int - ALERT_DESCRIPTION_PROTOCOL_VERSION: int - ALERT_DESCRIPTION_RECORD_OVERFLOW: int - ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: int - ALERT_DESCRIPTION_UNKNOWN_CA: int - ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: int - ALERT_DESCRIPTION_UNRECOGNIZED_NAME: int - ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: int - ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: int - ALERT_DESCRIPTION_USER_CANCELLED: int +ALERT_DESCRIPTION_HANDSHAKE_FAILURE: int +ALERT_DESCRIPTION_INTERNAL_ERROR: int +ALERT_DESCRIPTION_ACCESS_DENIED: int +ALERT_DESCRIPTION_BAD_CERTIFICATE: int +ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: int +ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: int +ALERT_DESCRIPTION_BAD_RECORD_MAC: int +ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: int +ALERT_DESCRIPTION_CERTIFICATE_REVOKED: int +ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: int +ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: int +ALERT_DESCRIPTION_CLOSE_NOTIFY: int +ALERT_DESCRIPTION_DECODE_ERROR: int +ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: int +ALERT_DESCRIPTION_DECRYPT_ERROR: int +ALERT_DESCRIPTION_ILLEGAL_PARAMETER: int +ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: int +ALERT_DESCRIPTION_NO_RENEGOTIATION: int +ALERT_DESCRIPTION_PROTOCOL_VERSION: int +ALERT_DESCRIPTION_RECORD_OVERFLOW: int +ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: int +ALERT_DESCRIPTION_UNKNOWN_CA: int +ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: int +ALERT_DESCRIPTION_UNRECOGNIZED_NAME: int +ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: int +ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: int +ALERT_DESCRIPTION_USER_CANCELLED: int if sys.version_info < (3,): class _ASN1Object(NamedTuple('_ASN1Object', [('nid', int), ('shortname', str), ('longname', str), ('oid', str)])): ... class Purpose(_ASN1Object): SERVER_AUTH: ClassVar[Purpose] CLIENT_AUTH: ClassVar[Purpose] -if sys.version_info >= (3, 4): +else: class _ASN1Object(NamedTuple('_ASN1Object', [('nid', int), ('shortname', str), ('longname', str), ('oid', str)])): ... class Purpose(_ASN1Object, enum.Enum): SERVER_AUTH = ... @@ -202,12 +197,10 @@ class SSLSocket(socket.socket): def shared_cipher(self) -> Optional[List[Tuple[str, int, int]]]: ... def compression(self) -> Optional[str]: ... def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... - if sys.version_info < (3,) or sys.version_info >= (3, 5): - def selected_alpn_protocol(self) -> Optional[str]: ... + def selected_alpn_protocol(self) -> Optional[str]: ... def selected_npn_protocol(self) -> Optional[str]: ... def unwrap(self) -> socket.socket: ... - if sys.version_info < (3,) or sys.version_info >= (3, 5): - def version(self) -> Optional[str]: ... + def version(self) -> Optional[str]: ... def pending(self) -> int: ... @@ -223,37 +216,30 @@ if sys.version_info >= (3, 7): class SSLContext: - if sys.version_info < (3,) or sys.version_info >= (3, 4): - check_hostname: bool + check_hostname: bool options: int @property def protocol(self) -> int: ... - if sys.version_info < (3,) or sys.version_info >= (3, 4): - verify_flags: int + verify_flags: int verify_mode: int if sys.version_info >= (3, 5): def __init__(self, protocol: int = ...) -> None: ... else: def __init__(self, protocol: int) -> None: ... - if sys.version_info < (3,) or sys.version_info >= (3, 4): - def cert_store_stats(self) -> Dict[str, int]: ... + def cert_store_stats(self) -> Dict[str, int]: ... def load_cert_chain(self, certfile: str, keyfile: Optional[str] = ..., password: _PasswordType = ...) -> None: ... - if sys.version_info < (3,) or sys.version_info >= (3, 4): - def load_default_certs(self, purpose: Purpose = ...) -> None: ... - def load_verify_locations(self, cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[str, bytes, None] = ...) -> None: ... - def get_ca_certs(self, - binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ... - else: - def load_verify_locations(self, - cafile: Optional[str] = ..., - capath: Optional[str] = ...) -> None: ... + def load_default_certs(self, purpose: Purpose = ...) -> None: ... + def load_verify_locations( + self, + cafile: Optional[str] = ..., + capath: Optional[str] = ..., + cadata: Union[str, bytes, None] = ..., + ) -> None: ... + def get_ca_certs(self, binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ... def set_default_verify_paths(self) -> None: ... def set_ciphers(self, ciphers: str) -> None: ... - if sys.version_info < (3,) or sys.version_info >= (3, 5): - def set_alpn_protocols(self, protocols: List[str]) -> None: ... + def set_alpn_protocols(self, protocols: List[str]) -> None: ... def set_npn_protocols(self, protocols: List[str]) -> None: ... def set_servername_callback(self, server_name_callback: Optional[_SrvnmeCbType]) -> None: ... diff --git a/stdlib/2and3/tarfile.pyi b/stdlib/2and3/tarfile.pyi index f5984949d..07f78aeeb 100644 --- a/stdlib/2and3/tarfile.pyi +++ b/stdlib/2and3/tarfile.pyi @@ -109,9 +109,6 @@ class TarFile(Iterable[TarInfo]): def extract(self, member: Union[str, TarInfo], path: _Path = ..., set_attrs: bool = ..., *, numeric_owner: bool = ...) -> None: ... - elif sys.version_info >= (3,): - def extract(self, member: Union[str, TarInfo], path: _Path = ..., - set_attrs: bool = ...) -> None: ... else: def extract(self, member: Union[str, TarInfo], path: _Path = ...) -> None: ... diff --git a/stdlib/2and3/webbrowser.pyi b/stdlib/2and3/webbrowser.pyi index 7d1b4cb68..111037571 100644 --- a/stdlib/2and3/webbrowser.pyi +++ b/stdlib/2and3/webbrowser.pyi @@ -56,13 +56,12 @@ class Galeon(UnixBrowser): remote_action_newwin: str background: bool -if sys.version_info[:2] == (2, 7) or sys.version_info >= (3, 3): - class Chrome(UnixBrowser): - remote_args: List[str] - remote_action: str - remote_action_newwin: str - remote_action_newtab: str - background: bool +class Chrome(UnixBrowser): + remote_args: List[str] + remote_action: str + remote_action_newwin: str + remote_action_newtab: str + background: bool class Opera(UnixBrowser): raise_opts: List[str] diff --git a/stdlib/3/_imp.pyi b/stdlib/3/_imp.pyi index 7015b3b0c..1992e3bda 100644 --- a/stdlib/3/_imp.pyi +++ b/stdlib/3/_imp.pyi @@ -4,10 +4,9 @@ import sys import types from typing import Any, List -if sys.version_info >= (3, 5): - from importlib.machinery import ModuleSpec - def create_builtin(spec: ModuleSpec) -> types.ModuleType: ... - def create_dynamic(spec: ModuleSpec, file: Any = ...) -> None: ... +from importlib.machinery import ModuleSpec +def create_builtin(spec: ModuleSpec) -> types.ModuleType: ... +def create_dynamic(spec: ModuleSpec, file: Any = ...) -> None: ... def acquire_lock() -> None: ... def exec_builtin(mod: types.ModuleType) -> int: ... diff --git a/stdlib/3/_operator.pyi b/stdlib/3/_operator.pyi index 6d08cd7ef..bd162ab9f 100644 --- a/stdlib/3/_operator.pyi +++ b/stdlib/3/_operator.pyi @@ -57,8 +57,8 @@ from operator import ( itemgetter as itemgetter, attrgetter as attrgetter, methodcaller as methodcaller, + matmul as matmul, + imatmul as imatmul, ) -if sys.version_info >= (3, 5): - from operator import matmul as matmul, imatmul as imatmul def _compare_digest(a: AnyStr, b: AnyStr) -> bool: ... diff --git a/stdlib/3/asyncio/__init__.pyi b/stdlib/3/asyncio/__init__.pyi index b98c2d1c8..c89d5f77b 100644 --- a/stdlib/3/asyncio/__init__.pyi +++ b/stdlib/3/asyncio/__init__.pyi @@ -84,14 +84,11 @@ from asyncio.locks import ( BoundedSemaphore as BoundedSemaphore, ) -if sys.version_info < (3, 5): - from asyncio.queues import JoinableQueue as JoinableQueue -else: - 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, - ) +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.streams import ( open_unix_connection as open_unix_connection, diff --git a/stdlib/3/asyncio/base_events.pyi b/stdlib/3/asyncio/base_events.pyi index 31023abf1..4f84e4be9 100644 --- a/stdlib/3/asyncio/base_events.pyi +++ b/stdlib/3/asyncio/base_events.pyi @@ -39,8 +39,7 @@ class BaseEventLoop(AbstractEventLoop): def call_at(self, when: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... def time(self) -> float: ... # Future methods - if sys.version_info >= (3, 5): - def create_future(self) -> Future[Any]: ... + def create_future(self) -> Future[Any]: ... # Tasks methods def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ... @@ -131,8 +130,7 @@ class BaseEventLoop(AbstractEventLoop): def remove_signal_handler(self, sig: int) -> None: ... # Error handlers. def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ... - if sys.version_info >= (3, 5): - def get_exception_handler(self) -> Optional[_ExceptionHandler]: ... + def get_exception_handler(self) -> Optional[_ExceptionHandler]: ... def default_exception_handler(self, context: _Context) -> None: ... def call_exception_handler(self, context: _Context) -> None: ... # Debug flag management. diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index 3dbd60944..5cab0044a 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -73,9 +73,8 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod def time(self) -> float: ... # Future methods - if sys.version_info >= (3, 5): - @abstractmethod - def create_future(self) -> Future[Any]: ... + @abstractmethod + def create_future(self) -> Future[Any]: ... # Tasks methods @abstractmethod def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... @@ -197,9 +196,8 @@ class AbstractEventLoop(metaclass=ABCMeta): # Error handlers. @abstractmethod def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ... - if sys.version_info >= (3, 5): - @abstractmethod - def get_exception_handler(self) -> Optional[_ExceptionHandler]: ... + @abstractmethod + def get_exception_handler(self) -> Optional[_ExceptionHandler]: ... @abstractmethod def default_exception_handler(self, context: _Context) -> None: ... @abstractmethod diff --git a/stdlib/3/asyncio/futures.pyi b/stdlib/3/asyncio/futures.pyi index ed2e4a0c9..b4323c018 100644 --- a/stdlib/3/asyncio/futures.pyi +++ b/stdlib/3/asyncio/futures.pyi @@ -26,8 +26,7 @@ class _TracebackLogger: def clear(self) -> None: ... def __del__(self) -> None: ... -if sys.version_info >= (3, 5): - def isfuture(obj: object) -> bool: ... +def isfuture(obj: object) -> bool: ... class Future(Awaitable[_T], Iterable[_T]): _state: str diff --git a/stdlib/3/asyncio/queues.pyi b/stdlib/3/asyncio/queues.pyi index dc4e9efa1..243a74d54 100644 --- a/stdlib/3/asyncio/queues.pyi +++ b/stdlib/3/asyncio/queues.pyi @@ -42,9 +42,3 @@ class PriorityQueue(Queue[_T]): ... class LifoQueue(Queue[_T]): ... - -if sys.version_info < (3, 5): - class JoinableQueue(Queue[_T]): - def task_done(self) -> None: ... - @coroutine - def join(self) -> Generator[Any, None, bool]: ... diff --git a/stdlib/3/collections/__init__.pyi b/stdlib/3/collections/__init__.pyi index 524ff6f8f..a6cecdfc7 100644 --- a/stdlib/3/collections/__init__.pyi +++ b/stdlib/3/collections/__init__.pyi @@ -9,8 +9,12 @@ from typing import ( from . import abc from typing import ( + AsyncIterable as AsyncIterable, + AsyncIterator as AsyncIterator, + Awaitable as Awaitable, Callable as Callable, Container as Container, + Coroutine as Coroutine, Hashable as Hashable, Iterable as Iterable, Iterator as Iterator, @@ -34,13 +38,6 @@ if sys.version_info >= (3, 6): Collection as Collection, AsyncGenerator as AsyncGenerator, ) -if sys.version_info >= (3, 5): - from typing import ( - Awaitable as Awaitable, - Coroutine as Coroutine, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - ) _S = TypeVar('_S') _T = TypeVar('_T') @@ -118,8 +115,7 @@ class UserString(Sequence[str]): def __int__(self) -> int: ... def __float__(self) -> float: ... def __complex__(self) -> complex: ... - if sys.version_info >= (3, 5): - def __getnewargs__(self) -> Tuple[str]: ... + def __getnewargs__(self) -> Tuple[str]: ... def __lt__(self, string: Union[str, UserString]) -> bool: ... def __le__(self, string: Union[str, UserString]) -> bool: ... def __gt__(self, string: Union[str, UserString]) -> bool: ... @@ -132,8 +128,7 @@ class UserString(Sequence[str]): def __mul__(self: _UserStringT, n: int) -> _UserStringT: ... def __mod__(self: _UserStringT, args: Any) -> _UserStringT: ... def capitalize(self: _UserStringT) -> _UserStringT: ... - if sys.version_info >= (3, 5): - def casefold(self: _UserStringT) -> _UserStringT: ... + def casefold(self: _UserStringT) -> _UserStringT: ... def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... def count(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UserStringT: ... @@ -141,8 +136,7 @@ class UserString(Sequence[str]): def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ... def find(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... def format(self, *args: Any, **kwds: Any) -> str: ... - if sys.version_info >= (3, 5): - def format_map(self, mapping: Mapping[str, Any]) -> str: ... + def format_map(self, mapping: Mapping[str, Any]) -> str: ... def index(self, sub: str, start: int = ..., end: int = ...) -> int: ... def isalpha(self) -> bool: ... def isalnum(self) -> bool: ... @@ -151,8 +145,7 @@ class UserString(Sequence[str]): def isidentifier(self) -> bool: ... def islower(self) -> bool: ... def isnumeric(self) -> bool: ... - if sys.version_info >= (3, 5): - def isprintable(self) -> bool: ... + def isprintable(self) -> bool: ... def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... @@ -160,13 +153,12 @@ class UserString(Sequence[str]): def ljust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... def lower(self: _UserStringT) -> _UserStringT: ... def lstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... - if sys.version_info >= (3, 5): - @staticmethod - @overload - def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... - @staticmethod - @overload - def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ... + @staticmethod + @overload + def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... + @staticmethod + @overload + def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ... def partition(self, sep: str) -> Tuple[str, str, str]: ... 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: ... @@ -197,8 +189,7 @@ class deque(MutableSequence[_T], Generic[_T]): def append(self, x: _T) -> None: ... def appendleft(self, x: _T) -> None: ... def clear(self) -> None: ... - if sys.version_info >= (3, 5): - def copy(self) -> deque[_T]: ... + def copy(self) -> deque[_T]: ... def count(self, x: _T) -> int: ... def extend(self, iterable: Iterable[_T]) -> None: ... def extendleft(self, iterable: Iterable[_T]) -> None: ... @@ -238,10 +229,9 @@ class deque(MutableSequence[_T], Generic[_T]): def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ... - if sys.version_info >= (3, 5): - def __add__(self, other: deque[_T]) -> deque[_T]: ... - def __mul__(self, other: int) -> deque[_T]: ... - def __imul__(self, other: int) -> None: ... + def __add__(self, other: deque[_T]) -> deque[_T]: ... + def __mul__(self, other: int) -> deque[_T]: ... + def __imul__(self, other: int) -> None: ... _CounterT = TypeVar('_CounterT', bound=Counter) diff --git a/stdlib/3/collections/abc.pyi b/stdlib/3/collections/abc.pyi index a9577285c..117184388 100644 --- a/stdlib/3/collections/abc.pyi +++ b/stdlib/3/collections/abc.pyi @@ -4,7 +4,13 @@ import sys from . import ( + AsyncIterable as AsyncIterable, + AsyncIterator as AsyncIterator, + Awaitable as Awaitable, + ByteString as ByteString, Container as Container, + Coroutine as Coroutine, + Generator as Generator, Hashable as Hashable, Iterable as Iterable, Iterator as Iterator, @@ -22,16 +28,6 @@ from . import ( ValuesView as ValuesView, ) -if sys.version_info >= (3, 5): - from . import ( - Generator as Generator, - ByteString as ByteString, - Awaitable as Awaitable, - Coroutine as Coroutine, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - ) - if sys.version_info >= (3, 6): from . import ( Collection as Collection, diff --git a/stdlib/3/compileall.pyi b/stdlib/3/compileall.pyi index 8d2731c05..0e0b11748 100644 --- a/stdlib/3/compileall.pyi +++ b/stdlib/3/compileall.pyi @@ -12,9 +12,6 @@ else: _SuccessType = int # rx can be any object with a 'search' method; once we have Protocols we can change the type -if sys.version_info < (3, 5): - def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ... -else: - def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., workers: int = ...) -> _SuccessType: ... +def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., workers: int = ...) -> _SuccessType: ... def compile_file(fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ... def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ... diff --git a/stdlib/3/email/message.pyi b/stdlib/3/email/message.pyi index 09fbdda7a..88aef3efe 100644 --- a/stdlib/3/email/message.pyi +++ b/stdlib/3/email/message.pyi @@ -63,8 +63,7 @@ class Message: def get_content_charset(self, failobj: _T = ...) -> Union[_T, str]: ... def get_charsets(self, failobj: _T = ...) -> Union[_T, List[str]]: ... def walk(self) -> Generator[Message, None, None]: ... - if sys.version_info >= (3, 5): - def get_content_disposition(self) -> Optional[str]: ... + def get_content_disposition(self) -> Optional[str]: ... def as_string(self, unixfrom: bool = ..., maxheaderlen: int = ..., policy: Optional[Policy] = ...) -> str: ... def as_bytes(self, unixfrom: bool = ..., diff --git a/stdlib/3/email/policy.pyi b/stdlib/3/email/policy.pyi index e47e643f9..581cf5891 100644 --- a/stdlib/3/email/policy.pyi +++ b/stdlib/3/email/policy.pyi @@ -13,8 +13,7 @@ class Policy: linesep: str cte_type: str raise_on_defect: bool - if sys.version_info >= (3, 5): - mange_from: bool + mange_from: bool def __init__(self, **kw: Any) -> None: ... def clone(self, **kw: Any) -> Policy: ... def handle_defect(self, obj: Message, diff --git a/stdlib/3/faulthandler.pyi b/stdlib/3/faulthandler.pyi index 2dfce7714..736a4539c 100644 --- a/stdlib/3/faulthandler.pyi +++ b/stdlib/3/faulthandler.pyi @@ -1,16 +1,10 @@ import sys from typing import Union, Protocol - class _HasFileno(Protocol): def fileno(self) -> int: ... - -if sys.version_info >= (3, 5): - _File = Union[_HasFileno, int] -else: - _File = _HasFileno - +_File = Union[_HasFileno, int] def cancel_dump_traceback_later() -> None: ... def disable() -> None: ... diff --git a/stdlib/3/glob.pyi b/stdlib/3/glob.pyi index 22ee20569..5e73a7971 100644 --- a/stdlib/3/glob.pyi +++ b/stdlib/3/glob.pyi @@ -11,12 +11,8 @@ else: def glob1(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... -if sys.version_info >= (3, 5): - def glob(pathname: AnyStr, *, recursive: bool = ...) -> List[AnyStr]: ... - def iglob(pathname: AnyStr, *, recursive: bool = ...) -> Iterator[AnyStr]: ... -else: - def glob(pathname: AnyStr) -> List[AnyStr]: ... - def iglob(pathname: AnyStr) -> Iterator[AnyStr]: ... +def glob(pathname: AnyStr, *, recursive: bool = ...) -> List[AnyStr]: ... +def iglob(pathname: AnyStr, *, recursive: bool = ...) -> Iterator[AnyStr]: ... def escape(pathname: AnyStr) -> AnyStr: ... diff --git a/stdlib/3/heapq.pyi b/stdlib/3/heapq.pyi index 5c49dfac1..0764da518 100644 --- a/stdlib/3/heapq.pyi +++ b/stdlib/3/heapq.pyi @@ -12,11 +12,7 @@ def heappop(heap: List[_T]) -> _T: ... def heappushpop(heap: List[_T], item: _T) -> _T: ... def heapify(x: List[_T]) -> None: ... def heapreplace(heap: List[_T], item: _T) -> _T: ... -if sys.version_info >= (3, 5): - def merge(*iterables: Iterable[_T], key: Callable[[_T], Any] = ..., - reverse: bool = ...) -> Iterable[_T]: ... -else: - def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... +def merge(*iterables: Iterable[_T], key: Callable[[_T], Any] = ..., reverse: bool = ...) -> Iterable[_T]: ... def nlargest(n: int, iterable: Iterable[_T], key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... def nsmallest(n: int, iterable: Iterable[_T], diff --git a/stdlib/3/html/parser.pyi b/stdlib/3/html/parser.pyi index d4cfb5102..55b99ea34 100644 --- a/stdlib/3/html/parser.pyi +++ b/stdlib/3/html/parser.pyi @@ -3,11 +3,7 @@ from _markupbase import ParserBase import sys class HTMLParser(ParserBase): - if sys.version_info >= (3, 5): - def __init__(self, *, convert_charrefs: bool = ...) -> None: ... - else: - def __init__(self, strict: bool = ..., *, - convert_charrefs: bool = ...) -> None: ... + def __init__(self, *, convert_charrefs: bool = ...) -> None: ... def feed(self, feed: str) -> None: ... def close(self) -> None: ... def reset(self) -> None: ... @@ -26,6 +22,3 @@ class HTMLParser(ParserBase): def handle_decl(self, decl: str) -> None: ... def handle_pi(self, data: str) -> None: ... def unknown_decl(self, data: str) -> None: ... - -if sys.version_info < (3, 5): - class HTMLParseError(Exception): ... diff --git a/stdlib/3/http/__init__.pyi b/stdlib/3/http/__init__.pyi index 580250b3c..adc6940aa 100644 --- a/stdlib/3/http/__init__.pyi +++ b/stdlib/3/http/__init__.pyi @@ -2,68 +2,66 @@ import sys from enum import IntEnum -if sys.version_info >= (3, 5): - class HTTPStatus(IntEnum): +class HTTPStatus(IntEnum): + def __init__(self, *a) -> None: ... - def __init__(self, *a) -> None: ... + phrase: str + description: str - phrase: str - description: str - - CONTINUE = ... - SWITCHING_PROTOCOLS = ... - PROCESSING = ... - OK = ... - CREATED = ... - ACCEPTED = ... - NON_AUTHORITATIVE_INFORMATION = ... - NO_CONTENT = ... - RESET_CONTENT = ... - PARTIAL_CONTENT = ... - MULTI_STATUS = ... - ALREADY_REPORTED = ... - IM_USED = ... - MULTIPLE_CHOICES = ... - MOVED_PERMANENTLY = ... - FOUND = ... - SEE_OTHER = ... - NOT_MODIFIED = ... - USE_PROXY = ... - TEMPORARY_REDIRECT = ... - PERMANENT_REDIRECT = ... - BAD_REQUEST = ... - UNAUTHORIZED = ... - PAYMENT_REQUIRED = ... - FORBIDDEN = ... - NOT_FOUND = ... - METHOD_NOT_ALLOWED = ... - NOT_ACCEPTABLE = ... - PROXY_AUTHENTICATION_REQUIRED = ... - REQUEST_TIMEOUT = ... - CONFLICT = ... - GONE = ... - LENGTH_REQUIRED = ... - PRECONDITION_FAILED = ... - REQUEST_ENTITY_TOO_LARGE = ... - REQUEST_URI_TOO_LONG = ... - UNSUPPORTED_MEDIA_TYPE = ... - REQUESTED_RANGE_NOT_SATISFIABLE = ... - EXPECTATION_FAILED = ... - UNPROCESSABLE_ENTITY = ... - LOCKED = ... - FAILED_DEPENDENCY = ... - UPGRADE_REQUIRED = ... - PRECONDITION_REQUIRED = ... - TOO_MANY_REQUESTS = ... - REQUEST_HEADER_FIELDS_TOO_LARGE = ... - INTERNAL_SERVER_ERROR = ... - NOT_IMPLEMENTED = ... - BAD_GATEWAY = ... - SERVICE_UNAVAILABLE = ... - GATEWAY_TIMEOUT = ... - HTTP_VERSION_NOT_SUPPORTED = ... - VARIANT_ALSO_NEGOTIATES = ... - INSUFFICIENT_STORAGE = ... - LOOP_DETECTED = ... - NOT_EXTENDED = ... - NETWORK_AUTHENTICATION_REQUIRED = ... + CONTINUE = ... + SWITCHING_PROTOCOLS = ... + PROCESSING = ... + OK = ... + CREATED = ... + ACCEPTED = ... + NON_AUTHORITATIVE_INFORMATION = ... + NO_CONTENT = ... + RESET_CONTENT = ... + PARTIAL_CONTENT = ... + MULTI_STATUS = ... + ALREADY_REPORTED = ... + IM_USED = ... + MULTIPLE_CHOICES = ... + MOVED_PERMANENTLY = ... + FOUND = ... + SEE_OTHER = ... + NOT_MODIFIED = ... + USE_PROXY = ... + TEMPORARY_REDIRECT = ... + PERMANENT_REDIRECT = ... + BAD_REQUEST = ... + UNAUTHORIZED = ... + PAYMENT_REQUIRED = ... + FORBIDDEN = ... + NOT_FOUND = ... + METHOD_NOT_ALLOWED = ... + NOT_ACCEPTABLE = ... + PROXY_AUTHENTICATION_REQUIRED = ... + REQUEST_TIMEOUT = ... + CONFLICT = ... + GONE = ... + LENGTH_REQUIRED = ... + PRECONDITION_FAILED = ... + REQUEST_ENTITY_TOO_LARGE = ... + REQUEST_URI_TOO_LONG = ... + UNSUPPORTED_MEDIA_TYPE = ... + REQUESTED_RANGE_NOT_SATISFIABLE = ... + EXPECTATION_FAILED = ... + UNPROCESSABLE_ENTITY = ... + LOCKED = ... + FAILED_DEPENDENCY = ... + UPGRADE_REQUIRED = ... + PRECONDITION_REQUIRED = ... + TOO_MANY_REQUESTS = ... + REQUEST_HEADER_FIELDS_TOO_LARGE = ... + INTERNAL_SERVER_ERROR = ... + NOT_IMPLEMENTED = ... + BAD_GATEWAY = ... + SERVICE_UNAVAILABLE = ... + GATEWAY_TIMEOUT = ... + HTTP_VERSION_NOT_SUPPORTED = ... + VARIANT_ALSO_NEGOTIATES = ... + INSUFFICIENT_STORAGE = ... + LOOP_DETECTED = ... + NOT_EXTENDED = ... + NETWORK_AUTHENTICATION_REQUIRED = ... diff --git a/stdlib/3/http/client.pyi b/stdlib/3/http/client.pyi index 2b173993e..f4b5189d9 100644 --- a/stdlib/3/http/client.pyi +++ b/stdlib/3/http/client.pyi @@ -80,61 +80,34 @@ responses: Dict[int, str] class HTTPMessage(email.message.Message): ... -if sys.version_info >= (3, 5): - # Ignore errors to work around python/mypy#5027 - class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore - msg: HTTPMessage - headers: HTTPMessage - version: int - debuglevel: int - closed: bool - status: int - reason: str - def __init__(self, sock: socket, debuglevel: int = ..., - method: Optional[str] = ..., url: Optional[str] = ...) -> None: ... - def read(self, amt: Optional[int] = ...) -> bytes: ... - @overload - def getheader(self, name: str) -> Optional[str]: ... - @overload - def getheader(self, name: str, default: _T) -> Union[str, _T]: ... - def getheaders(self) -> List[Tuple[str, str]]: ... - def fileno(self) -> int: ... - def isclosed(self) -> bool: ... - def __iter__(self) -> Iterator[bytes]: ... - def __enter__(self) -> HTTPResponse: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[types.TracebackType]) -> bool: ... - def info(self) -> email.message.Message: ... - def geturl(self) -> str: ... - def getcode(self) -> int: ... - def begin(self) -> None: ... -else: - class HTTPResponse(io.RawIOBase, BinaryIO): # type: ignore - msg: HTTPMessage - headers: HTTPMessage - version: int - debuglevel: int - closed: bool - status: int - reason: str - def read(self, amt: Optional[int] = ...) -> bytes: ... - def readinto(self, b: bytearray) -> int: ... - @overload - def getheader(self, name: str) -> Optional[str]: ... - @overload - def getheader(self, name: str, default: _T) -> Union[str, _T]: ... - def getheaders(self) -> List[Tuple[str, str]]: ... - def fileno(self) -> int: ... - def __iter__(self) -> Iterator[bytes]: ... - def __enter__(self) -> HTTPResponse: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[types.TracebackType]) -> bool: ... - def info(self) -> email.message.Message: ... - def geturl(self) -> str: ... - def getcode(self) -> int: ... - def begin(self) -> None: ... +# Ignore errors to work around python/mypy#5027 +class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore + msg: HTTPMessage + headers: HTTPMessage + version: int + debuglevel: int + closed: bool + status: int + reason: str + def __init__(self, sock: socket, debuglevel: int = ..., + method: Optional[str] = ..., url: Optional[str] = ...) -> None: ... + def read(self, amt: Optional[int] = ...) -> bytes: ... + @overload + def getheader(self, name: str) -> Optional[str]: ... + @overload + def getheader(self, name: str, default: _T) -> Union[str, _T]: ... + def getheaders(self) -> List[Tuple[str, str]]: ... + def fileno(self) -> int: ... + def isclosed(self) -> bool: ... + def __iter__(self) -> Iterator[bytes]: ... + def __enter__(self) -> HTTPResponse: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], + exc_tb: Optional[types.TracebackType]) -> bool: ... + def info(self) -> email.message.Message: ... + def geturl(self) -> str: ... + def getcode(self) -> int: ... + def begin(self) -> None: ... # This is an API stub only for the class below, not a class itself. # urllib.request uses it for a parameter. @@ -220,5 +193,4 @@ class ResponseNotReady(ImproperConnectionState): ... class BadStatusLine(HTTPException): ... class LineTooLong(HTTPException): ... -if sys.version_info >= (3, 5): - class RemoteDisconnected(ConnectionResetError, BadStatusLine): ... +class RemoteDisconnected(ConnectionResetError, BadStatusLine): ... diff --git a/stdlib/3/imp.pyi b/stdlib/3/imp.pyi index 33440910a..9ba615021 100644 --- a/stdlib/3/imp.pyi +++ b/stdlib/3/imp.pyi @@ -9,8 +9,7 @@ from _imp import (lock_held as lock_held, acquire_lock as acquire_lock, release_ get_frozen_object as get_frozen_object, is_frozen_package as is_frozen_package, init_frozen as init_frozen, is_builtin as is_builtin, is_frozen as is_frozen) -if sys.version_info >= (3, 5): - from _imp import create_dynamic as create_dynamic +from _imp import create_dynamic as create_dynamic _T = TypeVar('_T') diff --git a/stdlib/3/importlib/abc.pyi b/stdlib/3/importlib/abc.pyi index a86e194dd..709ba44f7 100644 --- a/stdlib/3/importlib/abc.pyi +++ b/stdlib/3/importlib/abc.pyi @@ -32,13 +32,8 @@ class InspectLoader(Loader): @abstractmethod def get_source(self, fullname: str) -> Optional[str]: ... def exec_module(self, module: types.ModuleType) -> None: ... - if sys.version_info < (3, 5): - def source_to_code(self, data: Union[bytes, str], - path: str = ...) -> types.CodeType: ... - else: - @staticmethod - def source_to_code(data: Union[bytes, str], - path: str = ...) -> types.CodeType: ... + @staticmethod + def source_to_code(data: Union[bytes, str], path: str = ...) -> types.CodeType: ... class ExecutionLoader(InspectLoader): @abstractmethod diff --git a/stdlib/3/importlib/util.pyi b/stdlib/3/importlib/util.pyi index 32d97cf27..878d0652e 100644 --- a/stdlib/3/importlib/util.pyi +++ b/stdlib/3/importlib/util.pyi @@ -43,18 +43,11 @@ def spec_from_file_location( submodule_search_locations: Optional[List[str]] = ... ) -> importlib.machinery.ModuleSpec: ... -if sys.version_info >= (3, 5): - def module_from_spec( - spec: importlib.machinery.ModuleSpec - ) -> types.ModuleType: ... +def module_from_spec(spec: importlib.machinery.ModuleSpec) -> types.ModuleType: ... - class LazyLoader(importlib.abc.Loader): - def __init__(self, loader: importlib.abc.Loader) -> None: ... - @classmethod - def factory( - cls, loader: importlib.abc.Loader - ) -> Callable[..., LazyLoader]: ... - def create_module( - self, spec: importlib.machinery.ModuleSpec - ) -> Optional[types.ModuleType]: ... - def exec_module(self, module: types.ModuleType) -> None: ... +class LazyLoader(importlib.abc.Loader): + def __init__(self, loader: importlib.abc.Loader) -> None: ... + @classmethod + def factory(cls, loader: importlib.abc.Loader) -> Callable[..., LazyLoader]: ... + def create_module(self, spec: importlib.machinery.ModuleSpec) -> Optional[types.ModuleType]: ... + def exec_module(self, module: types.ModuleType) -> None: ... diff --git a/stdlib/3/inspect.pyi b/stdlib/3/inspect.pyi index 320200c44..91126028c 100644 --- a/stdlib/3/inspect.pyi +++ b/stdlib/3/inspect.pyi @@ -28,9 +28,8 @@ CO_VARKEYWORDS: int CO_NESTED: int CO_GENERATOR: int CO_NOFREE: int -if sys.version_info >= (3, 5): - CO_COROUTINE: int - CO_ITERABLE_COROUTINE: int +CO_COROUTINE: int +CO_ITERABLE_COROUTINE: int if sys.version_info >= (3, 6): CO_ASYNC_GENERATOR: int TPFLAGS_IS_ABSTRACT: int @@ -55,10 +54,9 @@ def isfunction(object: object) -> bool: ... def isgeneratorfunction(object: object) -> bool: ... def isgenerator(object: object) -> bool: ... -if sys.version_info >= (3, 5): - def iscoroutinefunction(object: object) -> bool: ... - def iscoroutine(object: object) -> bool: ... - def isawaitable(object: object) -> bool: ... +def iscoroutinefunction(object: object) -> bool: ... +def iscoroutine(object: object) -> bool: ... +def isawaitable(object: object) -> bool: ... if sys.version_info >= (3, 6): def isasyncgenfunction(object: object) -> bool: ... def isasyncgen(object: object) -> bool: ... @@ -122,12 +120,8 @@ class Signature: parameters: Optional[Sequence[Parameter]] = ..., return_annotation: Any = ...) -> Signature: ... - if sys.version_info >= (3, 5): - @classmethod - def from_callable(cls, - obj: Callable[..., Any], - *, - follow_wrapped: bool = ...) -> Signature: ... + @classmethod + def from_callable(cls, obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Signature: ... # The name is the same as the enum's name in CPython class _ParameterKind: ... @@ -164,8 +158,7 @@ class BoundArguments: kwargs: Dict[str, Any] signature: Signature - if sys.version_info >= (3, 5): - def apply_defaults(self) -> None: ... + def apply_defaults(self) -> None: ... # @@ -306,19 +299,17 @@ GEN_SUSPENDED: str GEN_CLOSED: str def getgeneratorstate(generator: Generator[Any, Any, Any]) -> str: ... -if sys.version_info >= (3, 5): - CORO_CREATED: str - CORO_RUNNING: str - CORO_SUSPENDED: str - CORO_CLOSED: str - # TODO can we be more specific than "object"? - def getcoroutinestate(coroutine: object) -> str: ... +CORO_CREATED: str +CORO_RUNNING: str +CORO_SUSPENDED: str +CORO_CLOSED: str +# TODO can we be more specific than "object"? +def getcoroutinestate(coroutine: object) -> str: ... def getgeneratorlocals(generator: Generator[Any, Any, Any]) -> Dict[str, Any]: ... -if sys.version_info >= (3, 5): - # TODO can we be more specific than "object"? - def getcoroutinelocals(coroutine: object) -> Dict[str, Any]: ... +# TODO can we be more specific than "object"? +def getcoroutinelocals(coroutine: object) -> Dict[str, Any]: ... Attribute = NamedTuple('Attribute', [('name', str), ('kind', str), diff --git a/stdlib/3/io.pyi b/stdlib/3/io.pyi index e64890281..5afbbcbf3 100644 --- a/stdlib/3/io.pyi +++ b/stdlib/3/io.pyi @@ -56,8 +56,7 @@ class BufferedIOBase(IOBase): def detach(self) -> RawIOBase: ... def readinto(self, b: _bytearray_like) -> int: ... def write(self, b: Union[bytes, bytearray]) -> int: ... - if sys.version_info >= (3, 5): - def readinto1(self, b: _bytearray_like) -> int: ... + def readinto1(self, b: _bytearray_like) -> int: ... def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... @@ -109,8 +108,7 @@ class BytesIO(BinaryIO): def detach(self) -> RawIOBase: ... def readinto(self, b: _bytearray_like) -> int: ... def write(self, b: Union[bytes, bytearray]) -> int: ... - if sys.version_info >= (3, 5): - def readinto1(self, b: _bytearray_like) -> int: ... + def readinto1(self, b: _bytearray_like) -> int: ... def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... diff --git a/stdlib/3/ipaddress.pyi b/stdlib/3/ipaddress.pyi index f706330b6..c6855fe26 100644 --- a/stdlib/3/ipaddress.pyi +++ b/stdlib/3/ipaddress.pyi @@ -1,4 +1,3 @@ -import sys from typing import (Any, Container, Generic, Iterable, Iterator, Optional, overload, SupportsInt, Tuple, TypeVar) @@ -25,9 +24,8 @@ class _IPAddressBase: def compressed(self) -> str: ... @property def exploded(self) -> str: ... - if sys.version_info >= (3, 5): - @property - def reverse_pointer(self) -> str: ... + @property + def reverse_pointer(self) -> str: ... @property def version(self) -> int: ... diff --git a/stdlib/3/json/__init__.pyi b/stdlib/3/json/__init__.pyi index cf42c36c7..e60c4727d 100644 --- a/stdlib/3/json/__init__.pyi +++ b/stdlib/3/json/__init__.pyi @@ -3,8 +3,7 @@ from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Protoc from .decoder import JSONDecoder as JSONDecoder from .encoder import JSONEncoder as JSONEncoder -if sys.version_info >= (3, 5): - from .decoder import JSONDecodeError as JSONDecodeError +from .decoder import JSONDecodeError as JSONDecodeError def dumps(obj: Any, skipkeys: bool = ..., diff --git a/stdlib/3/json/decoder.pyi b/stdlib/3/json/decoder.pyi index 8e30c1e73..1acb84af8 100644 --- a/stdlib/3/json/decoder.pyi +++ b/stdlib/3/json/decoder.pyi @@ -1,14 +1,13 @@ import sys from typing import Any, Callable, Dict, List, Optional, Tuple -if sys.version_info >= (3, 5): - class JSONDecodeError(ValueError): - msg: str - doc: str - pos: int - lineno: int - colno: int - def __init__(self, msg: str, doc: str, pos: int) -> None: ... +class JSONDecodeError(ValueError): + msg: str + doc: str + pos: int + lineno: int + colno: int + def __init__(self, msg: str, doc: str, pos: int) -> None: ... class JSONDecoder: object_hook: Callable[[Dict[str, Any]], Any] diff --git a/stdlib/3/lzma.pyi b/stdlib/3/lzma.pyi index cd0a088b4..37009c813 100644 --- a/stdlib/3/lzma.pyi +++ b/stdlib/3/lzma.pyi @@ -49,9 +49,8 @@ class LZMADecompressor(object): def eof(self) -> bool: ... @property def unused_data(self) -> bytes: ... - if sys.version_info >= (3, 5): - @property - def needs_input(self) -> bool: ... + @property + def needs_input(self) -> bool: ... # from _lzma.c class LZMACompressor(object): diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index b71792687..2a9656a3d 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -2,6 +2,7 @@ # Ron Murawski from io import TextIOWrapper as _TextIOWrapper +from posix import times_result import sys from typing import ( Mapping, MutableMapping, Dict, List, Any, Tuple, IO, Iterable, Iterator, NoReturn, overload, Union, AnyStr, @@ -16,75 +17,72 @@ _T = TypeVar('_T') # ----- os variables ----- -if sys.version_info >= (3, 2): - supports_bytes_environ: bool +supports_bytes_environ: bool -if sys.version_info >= (3, 3): - supports_dir_fd: Set[Callable[..., Any]] - supports_fd: Set[Callable[..., Any]] - supports_effective_ids: Set[Callable[..., Any]] - supports_follow_symlinks: Set[Callable[..., Any]] +supports_dir_fd: Set[Callable[..., Any]] +supports_fd: Set[Callable[..., Any]] +supports_effective_ids: Set[Callable[..., Any]] +supports_follow_symlinks: Set[Callable[..., Any]] - if sys.platform != 'win32': - # Unix only - PRIO_PROCESS: int - PRIO_PGRP: int - PRIO_USER: int +if sys.platform != 'win32': + # Unix only + PRIO_PROCESS: int + PRIO_PGRP: int + PRIO_USER: int - F_LOCK: int - F_TLOCK: int - F_ULOCK: int - F_TEST: int + F_LOCK: int + F_TLOCK: int + F_ULOCK: int + F_TEST: int - POSIX_FADV_NORMAL: int - POSIX_FADV_SEQUENTIAL: int - POSIX_FADV_RANDOM: int - POSIX_FADV_NOREUSE: int - POSIX_FADV_WILLNEED: int - POSIX_FADV_DONTNEED: int + POSIX_FADV_NORMAL: int + POSIX_FADV_SEQUENTIAL: int + POSIX_FADV_RANDOM: int + POSIX_FADV_NOREUSE: int + POSIX_FADV_WILLNEED: int + POSIX_FADV_DONTNEED: int - SF_NODISKIO: int - SF_MNOWAIT: int - SF_SYNC: int + SF_NODISKIO: int + SF_MNOWAIT: int + SF_SYNC: int - XATTR_SIZE_MAX: int # Linux only - XATTR_CREATE: int # Linux only - XATTR_REPLACE: int # Linux only + XATTR_SIZE_MAX: int # Linux only + XATTR_CREATE: int # Linux only + XATTR_REPLACE: int # Linux only - P_PID: int - P_PGID: int - P_ALL: int + P_PID: int + P_PGID: int + P_ALL: int - WEXITED: int - WSTOPPED: int - WNOWAIT: int + WEXITED: int + WSTOPPED: int + WNOWAIT: int - CLD_EXITED: int - CLD_DUMPED: int - CLD_TRAPPED: int - CLD_CONTINUED: int + CLD_EXITED: int + CLD_DUMPED: int + CLD_TRAPPED: int + CLD_CONTINUED: int - SCHED_OTHER: int # some flavors of Unix - SCHED_BATCH: int # some flavors of Unix - SCHED_IDLE: int # some flavors of Unix - SCHED_SPORADIC: int # some flavors of Unix - SCHED_FIFO: int # some flavors of Unix - 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 + SCHED_OTHER: int # some flavors of Unix + SCHED_BATCH: int # some flavors of Unix + SCHED_IDLE: int # some flavors of Unix + SCHED_SPORADIC: int # some flavors of Unix + SCHED_FIFO: int # some flavors of Unix + 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 SEEK_SET: int SEEK_CUR: int SEEK_END: int -if sys.version_info >= (3, 3) and sys.platform != 'win32': +if sys.platform != 'win32': SEEK_DATA: int # some flavors of Unix SEEK_HOLE: int # some flavors of Unix @@ -104,8 +102,7 @@ O_SYNC: int # Unix only O_NDELAY: int # Unix only O_NONBLOCK: int # Unix only O_NOCTTY: int # Unix only -if sys.version_info >= (3, 3): - O_CLOEXEC: int # Unix only +O_CLOEXEC: int # Unix only O_SHLOCK: int # Unix only O_EXLOCK: int # Unix only O_BINARY: int # Windows only @@ -120,9 +117,8 @@ O_DIRECT: int # Gnu extension if in C library O_DIRECTORY: int # Gnu extension if in C library O_NOFOLLOW: int # Gnu extension if in C library O_NOATIME: int # Gnu extension if in C library -if sys.version_info >= (3, 4): - O_PATH: int # Gnu extension if in C library - O_TMPFILE: int # Gnu extension if in C library +O_PATH: int # Gnu extension if in C library +O_TMPFILE: int # Gnu extension if in C library O_LARGEFILE: int # Gnu extension if in C library curdir: str @@ -153,8 +149,7 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): def __len__(self) -> int: ... environ: _Environ[str] -if sys.version_info >= (3, 2): - environb: _Environ[bytes] +environb: _Environ[bytes] if sys.platform != 'win32': confstr_names: Dict[str, int] @@ -242,10 +237,7 @@ if sys.version_info >= (3, 6): from builtins import _PathLike as PathLike # See comment in builtins _PathType = path._PathType -if sys.version_info >= (3, 3): - _FdOrPathType = Union[int, _PathType] -else: - _FdOrPathType = _PathType +_FdOrPathType = Union[int, _PathType] if sys.version_info >= (3, 6): class DirEntry(PathLike[AnyStr]): @@ -261,7 +253,7 @@ if sys.version_info >= (3, 6): def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ... def __fspath__(self) -> AnyStr: ... -elif sys.version_info >= (3, 5): +else: class DirEntry(Generic[AnyStr]): # This is what the scandir interator yields # The constructor is hidden @@ -321,15 +313,13 @@ if sys.platform != 'win32': def getegid() -> int: ... def geteuid() -> int: ... def getgid() -> int: ... - if sys.version_info >= (3, 3): - def getgrouplist(user: str, gid: int) -> List[int]: ... + def getgrouplist(user: str, gid: int) -> List[int]: ... def getgroups() -> List[int]: ... # Unix only, behaves differently on Mac def initgroups(username: str, gid: int) -> None: ... def getpgid(pid: int) -> int: ... def getpgrp() -> int: ... - if sys.version_info >= (3, 3): - def getpriority(which: int, who: int) -> int: ... - def setpriority(which: int, who: int, priority: int) -> None: ... + def getpriority(which: int, who: int) -> int: ... + def setpriority(which: int, who: int, priority: int) -> None: ... def getresuid() -> Tuple[int, int, int]: ... def getresgid() -> Tuple[int, int, int]: ... def getuid() -> int: ... @@ -346,11 +336,8 @@ if sys.platform != 'win32': def getsid(pid: int) -> int: ... def setsid() -> None: ... def setuid(uid: int) -> None: ... - if sys.version_info >= (3, 3): - from posix import uname_result - def uname() -> uname_result: ... - else: - def uname() -> Tuple[str, str, str, str, str]: ... + from posix import uname_result + def uname() -> uname_result: ... @overload def getenv(key: Text) -> Optional[str]: ... @@ -369,17 +356,12 @@ def device_encoding(fd: int) -> Optional[str]: ... def dup(fd: int) -> int: ... if sys.version_info >= (3, 7): def dup2(fd: int, fd2: int, inheritable: bool = ...) -> int: ... -elif sys.version_info >= (3, 4): - def dup2(fd: int, fd2: int, inheritable: bool = ...) -> None: ... else: - def dup2(fd: int, fd2: int) -> None: ... + def dup2(fd: int, fd2: int, inheritable: bool = ...) -> None: ... def fstat(fd: int) -> stat_result: ... def fsync(fd: int) -> None: ... def lseek(fd: int, pos: int, how: int) -> int: ... -if sys.version_info >= (3, 3): - def open(file: _PathType, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ... -else: - def open(file: _PathType, flags: int, mode: int = ...) -> int: ... +def open(file: _PathType, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ... def pipe() -> Tuple[int, int]: ... def read(fd: int, n: int) -> bytes: ... @@ -391,33 +373,29 @@ if sys.platform != 'win32': def fpathconf(fd: int, name: Union[str, int]) -> int: ... def fstatvfs(fd: int) -> statvfs_result: ... def ftruncate(fd: int, length: int) -> None: ... - if sys.version_info >= (3, 5): - def get_blocking(fd: int) -> bool: ... - def set_blocking(fd: int, blocking: bool) -> None: ... + def get_blocking(fd: int) -> bool: ... + def set_blocking(fd: int, blocking: bool) -> None: ... def isatty(fd: int) -> bool: ... - if sys.version_info >= (3, 3): - def lockf(__fd: int, __cmd: int, __length: int) -> None: ... + def lockf(__fd: int, __cmd: int, __length: int) -> None: ... def openpty() -> Tuple[int, int]: ... # some flavors of Unix - if sys.version_info >= (3, 3): - def pipe2(flags: int) -> Tuple[int, int]: ... # some flavors of Unix - def posix_fallocate(fd: int, offset: int, length: int) -> None: ... - def posix_fadvise(fd: int, offset: int, length: int, advice: int) -> None: ... - def pread(fd: int, buffersize: int, offset: int) -> bytes: ... - def pwrite(fd: int, string: bytes, offset: int) -> int: ... - @overload - def sendfile(__out_fd: int, __in_fd: int, offset: Optional[int], count: int) -> int: ... - @overload - def sendfile(__out_fd: int, __in_fd: int, offset: int, count: int, - headers: Sequence[bytes] = ..., trailers: Sequence[bytes] = ..., flags: int = ...) -> int: ... # FreeBSD and Mac OS X only - def readv(fd: int, buffers: Sequence[bytearray]) -> int: ... - def writev(fd: int, buffers: Sequence[bytes]) -> int: ... + def pipe2(flags: int) -> Tuple[int, int]: ... # some flavors of Unix + def posix_fallocate(fd: int, offset: int, length: int) -> None: ... + def posix_fadvise(fd: int, offset: int, length: int, advice: int) -> None: ... + def pread(fd: int, buffersize: int, offset: int) -> bytes: ... + def pwrite(fd: int, string: bytes, offset: int) -> int: ... + @overload + def sendfile(__out_fd: int, __in_fd: int, offset: Optional[int], count: int) -> int: ... + @overload + def sendfile(__out_fd: int, __in_fd: int, offset: int, count: int, + headers: Sequence[bytes] = ..., trailers: Sequence[bytes] = ..., flags: int = ...) -> int: ... # FreeBSD and Mac OS X only + def readv(fd: int, buffers: Sequence[bytearray]) -> int: ... + def writev(fd: int, buffers: Sequence[bytes]) -> int: ... terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)]) def get_terminal_size(fd: int = ...) -> terminal_size: ... -if sys.version_info >= (3, 4): - def get_inheritable(fd: int) -> bool: ... - def set_inheritable(fd: int, inheritable: bool) -> None: ... +def get_inheritable(fd: int) -> bool: ... +def set_inheritable(fd: int, inheritable: bool) -> None: ... if sys.platform != 'win32': # Unix only @@ -425,36 +403,36 @@ if sys.platform != 'win32': def tcsetpgrp(fd: int, pg: int) -> None: ... def ttyname(fd: int) -> str: ... def write(fd: int, string: bytes) -> int: ... -if sys.version_info >= (3, 3): - def access(path: _FdOrPathType, mode: int, *, dir_fd: Optional[int] = ..., - effective_ids: bool = ..., follow_symlinks: bool = ...) -> bool: ... -else: - def access(path: _PathType, mode: int) -> bool: ... +def access( + path: _FdOrPathType, + mode: int, + *, + dir_fd: Optional[int] = ..., + effective_ids: bool = ..., + follow_symlinks: bool = ..., +) -> bool: ... def chdir(path: _FdOrPathType) -> None: ... def fchdir(fd: int) -> None: ... def getcwd() -> str: ... def getcwdb() -> bytes: ... -if sys.version_info >= (3, 3): - def chmod(path: _FdOrPathType, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... - if sys.platform != 'win32': - def chflags(path: _PathType, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix - def chown(path: _FdOrPathType, uid: int, gid: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... # Unix only -else: - def chmod(path: _PathType, mode: int) -> None: ... - if sys.platform != 'win32': - def chflags(path: _PathType, flags: int) -> None: ... # Some flavors of Unix - def chown(path: _PathType, uid: int, gid: int) -> None: ... # Unix only +def chmod(path: _FdOrPathType, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... +if sys.platform != 'win32': + def chflags(path: _PathType, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix + def chown(path: _FdOrPathType, uid: int, gid: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... # Unix only if sys.platform != 'win32': # Unix only def chroot(path: _PathType) -> None: ... def lchflags(path: _PathType, flags: int) -> None: ... def lchmod(path: _PathType, mode: int) -> None: ... def lchown(path: _PathType, uid: int, gid: int) -> None: ... -if sys.version_info >= (3, 3): - def link(src: _PathType, link_name: _PathType, *, src_dir_fd: Optional[int] = ..., - dst_dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... -else: - def link(src: _PathType, link_name: _PathType) -> None: ... +def link( + src: _PathType, + link_name: _PathType, + *, + src_dir_fd: Optional[int] = ..., + dst_dir_fd: Optional[int] = ..., + follow_symlinks: bool = ..., +) -> None: ... if sys.version_info >= (3, 6): @overload @@ -465,41 +443,20 @@ if sys.version_info >= (3, 6): def listdir(path: int) -> List[str]: ... @overload def listdir(path: PathLike[str]) -> List[str]: ... -elif sys.version_info >= (3, 3): +else: @overload def listdir(path: Optional[str] = ...) -> List[str]: ... @overload def listdir(path: bytes) -> List[bytes]: ... @overload def listdir(path: int) -> List[str]: ... -else: - @overload - def listdir(path: Optional[str] = ...) -> List[str]: ... - @overload - def listdir(path: bytes) -> List[bytes]: ... -if sys.version_info >= (3, 3): - def lstat(path: _PathType, *, dir_fd: Optional[int] = ...) -> stat_result: ... - def mkdir(path: _PathType, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... - if sys.platform != 'win32': - def mkfifo(path: _PathType, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only -else: - def lstat(path: _PathType) -> stat_result: ... - def mkdir(path: _PathType, mode: int = ...) -> None: ... - if sys.platform != 'win32': - def mkfifo(path: _PathType, mode: int = ...) -> None: ... # Unix only -if sys.version_info >= (3, 4): - def makedirs(name: _PathType, mode: int = ..., exist_ok: bool = ...) -> None: ... -else: - def makedirs(path: _PathType, mode: int = ..., exist_ok: bool = ...) -> None: ... -if sys.version_info >= (3, 4): - def mknod(path: _PathType, mode: int = ..., device: int = ..., - *, dir_fd: Optional[int] = ...) -> None: ... -elif sys.version_info >= (3, 3): - def mknod(filename: _PathType, mode: int = ..., device: int = ..., - *, dir_fd: Optional[int] = ...) -> None: ... -else: - def mknod(filename: _PathType, mode: int = ..., device: int = ...) -> None: ... +def lstat(path: _PathType, *, dir_fd: Optional[int] = ...) -> stat_result: ... +def mkdir(path: _PathType, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... +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: ... @@ -507,30 +464,14 @@ if sys.platform != 'win32': 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: ... -elif sys.version_info >= (3, 3): +else: def readlink(path: AnyStr, *, dir_fd: Optional[int] = ...) -> AnyStr: ... -else: - def readlink(path: AnyStr) -> AnyStr: ... -if sys.version_info >= (3, 3): - def remove(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ... -else: - def remove(path: _PathType) -> None: ... -if sys.version_info >= (3, 4): - def removedirs(name: _PathType) -> None: ... -else: - def removedirs(path: _PathType) -> None: ... -if sys.version_info >= (3, 3): - def rename(src: _PathType, dst: _PathType, *, - src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... -else: - def rename(src: _PathType, dst: _PathType) -> None: ... +def remove(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ... +def removedirs(name: _PathType) -> None: ... +def rename(src: _PathType, dst: _PathType, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... def renames(old: _PathType, new: _PathType) -> None: ... -if sys.version_info >= (3, 3): - def replace(src: _PathType, dst: _PathType, *, - src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... - def rmdir(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ... -else: - def rmdir(path: _PathType) -> None: ... +def replace(src: _PathType, dst: _PathType, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... +def rmdir(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ... if sys.version_info >= (3, 7): class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... @@ -549,16 +490,12 @@ elif sys.version_info >= (3, 6): def scandir() -> _ScandirIterator[str]: ... @overload def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ... -elif sys.version_info >= (3, 5): +else: @overload def scandir() -> Iterator[DirEntry[str]]: ... @overload def scandir(path: AnyStr) -> Iterator[DirEntry[AnyStr]]: ... -if sys.version_info >= (3, 3): - def stat(path: _FdOrPathType, *, dir_fd: Optional[int] = ..., - follow_symlinks: bool = ...) -> stat_result: ... -else: - def stat(path: _PathType) -> stat_result: ... +def stat(path: _FdOrPathType, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ... if sys.version_info < (3, 7): @overload def stat_float_times() -> bool: ... @@ -566,22 +503,25 @@ if sys.version_info < (3, 7): def stat_float_times(__newvalue: bool) -> None: ... if sys.platform != 'win32': def statvfs(path: _FdOrPathType) -> statvfs_result: ... # Unix only -if sys.version_info >= (3, 3): - def symlink(source: _PathType, link_name: _PathType, - target_is_directory: bool = ..., *, dir_fd: Optional[int] = ...) -> None: ... - if sys.platform != 'win32': - def sync() -> None: ... # Unix only - def truncate(path: _FdOrPathType, length: int) -> None: ... # Unix only up to version 3.4 - def unlink(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ... - def utime(path: _FdOrPathType, times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ..., *, - ns: Tuple[int, int] = ..., dir_fd: Optional[int] = ..., - follow_symlinks: bool = ...) -> None: ... -else: - def symlink(source: _PathType, link_name: _PathType, - target_is_directory: bool = ...) -> None: - ... # final argument in Windows only - def unlink(path: _PathType) -> None: ... - def utime(path: _PathType, times: Optional[Tuple[float, float]]) -> None: ... +def symlink( + source: _PathType, + link_name: _PathType, + target_is_directory: bool = ..., + *, + dir_fd: Optional[int] = ..., +) -> None: ... +if sys.platform != 'win32': + def sync() -> None: ... # Unix only +def truncate(path: _FdOrPathType, length: int) -> None: ... # Unix only up to version 3.4 +def unlink(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ... +def utime( + path: _FdOrPathType, + times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ..., + *, + ns: Tuple[int, int] = ..., + dir_fd: Optional[int] = ..., + follow_symlinks: bool = ..., +) -> None: ... if sys.version_info >= (3, 6): def walk(top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., @@ -592,7 +532,7 @@ else: def walk(top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... -if sys.platform != 'win32' and sys.version_info >= (3, 3): +if sys.platform != 'win32': if sys.version_info >= (3, 7): @overload def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ..., @@ -643,17 +583,9 @@ if sys.platform != 'win32': def nice(increment: int) -> int: ... def plock(op: int) -> None: ... # ???op is int? -if sys.version_info >= (3, 0): - class _wrap_close(_TextIOWrapper): - def close(self) -> Optional[int]: ... # type: ignore - def popen(command: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ... -else: - class _wrap_close(IO[Text]): - def close(self) -> Optional[int]: ... - def popen(__cmd: Text, __mode: Text = ..., __bufsize: int = ...) -> _wrap_close: ... - def popen2(__cmd: Text, __mode: Text = ..., __bufsize: int = ...) -> Tuple[IO[Text], IO[Text]]: ... - def popen3(__cmd: Text, __mode: Text = ..., __bufsize: int = ...) -> Tuple[IO[Text], IO[Text], IO[Text]]: ... - def popen4(__cmd: Text, __mode: Text = ..., __bufsize: int = ...) -> Tuple[IO[Text], IO[Text]]: ... +class _wrap_close(_TextIOWrapper): + def close(self) -> Optional[int]: ... # type: ignore +def popen(command: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ... def spawnl(mode: int, path: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnle(mode: int, path: _PathType, arg0: Union[bytes, Text], @@ -662,11 +594,7 @@ def spawnv(mode: int, path: _PathType, args: List[Union[bytes, Text]]) -> int: . def spawnve(mode: int, path: _PathType, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... def system(command: _PathType) -> int: ... -if sys.version_info >= (3, 3): - from posix import times_result - def times() -> times_result: ... -else: - def times() -> Tuple[float, float, float, float, float]: ... +def times() -> times_result: ... def waitpid(pid: int, options: int) -> Tuple[int, int]: ... if sys.platform == 'win32': @@ -678,9 +606,8 @@ else: def spawnvp(mode: int, file: _PathType, args: List[Union[bytes, Text]]) -> int: ... def spawnvpe(mode: int, file: _PathType, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... def wait() -> Tuple[int, int]: ... # Unix only - if sys.version_info >= (3, 3): - from posix import waitid_result - def waitid(idtype: int, ident: int, options: int) -> waitid_result: ... + from posix import waitid_result + def waitid(idtype: int, ident: int, options: int) -> waitid_result: ... def wait3(options: int) -> Tuple[int, int, Any]: ... def wait4(pid: int, options: int) -> Tuple[int, int, Any]: ... def WCOREDUMP(status: int) -> bool: ... @@ -692,7 +619,7 @@ else: def WSTOPSIG(status: int) -> int: ... def WTERMSIG(status: int) -> int: ... -if sys.platform != 'win32' and sys.version_info >= (3, 3): +if sys.platform != 'win32': from posix import sched_param def sched_get_priority_min(policy: int) -> int: ... # some flavors of Unix def sched_get_priority_max(policy: int) -> int: ... # some flavors of Unix @@ -705,8 +632,7 @@ if sys.platform != 'win32' and sys.version_info >= (3, 3): def sched_setaffinity(pid: int, mask: Iterable[int]) -> None: ... # some flavors of Unix def sched_getaffinity(pid: int) -> Set[int]: ... # some flavors of Unix -if sys.version_info >= (3, 4): - def cpu_count() -> Optional[int]: ... +def cpu_count() -> Optional[int]: ... if sys.platform != 'win32': # Unix only def confstr(name: Union[str, int]) -> Optional[str]: ... diff --git a/stdlib/3/posix.pyi b/stdlib/3/posix.pyi index 6902e5f23..a24001d7f 100644 --- a/stdlib/3/posix.pyi +++ b/stdlib/3/posix.pyi @@ -65,8 +65,7 @@ if sys.version_info >= (3, 6): NGROUPS_MAX: int O_APPEND: int -if sys.version_info >= (3, 4): - O_ACCMODE: int +O_ACCMODE: int O_ASYNC: int O_CREAT: int O_DIRECT: int diff --git a/stdlib/3/signal.pyi b/stdlib/3/signal.pyi index 34a8cdd07..c520b9a64 100644 --- a/stdlib/3/signal.pyi +++ b/stdlib/3/signal.pyi @@ -13,77 +13,65 @@ ITIMER_VIRTUAL: int = ... NSIG: int = ... -if sys.version_info >= (3, 5): - class Signals(IntEnum): - SIGABRT = ... - SIGALRM = ... - SIGBREAK = ... # Windows - SIGBUS = ... - SIGCHLD = ... - SIGCLD = ... - SIGCONT = ... - SIGEMT = ... - SIGFPE = ... - SIGHUP = ... - SIGILL = ... - SIGINFO = ... - SIGINT = ... - SIGIO = ... - SIGIOT = ... - SIGKILL = ... - SIGPIPE = ... - SIGPOLL = ... - SIGPROF = ... - SIGPWR = ... - SIGQUIT = ... - SIGRTMAX = ... - SIGRTMIN = ... - SIGSEGV = ... - SIGSTOP = ... - SIGSYS = ... - SIGTERM = ... - SIGTRAP = ... - SIGTSTP = ... - SIGTTIN = ... - SIGTTOU = ... - SIGURG = ... - SIGUSR1 = ... - SIGUSR2 = ... - SIGVTALRM = ... - SIGWINCH = ... - SIGXCPU = ... - SIGXFSZ = ... +class Signals(IntEnum): + SIGABRT = ... + SIGALRM = ... + SIGBREAK = ... # Windows + SIGBUS = ... + SIGCHLD = ... + SIGCLD = ... + SIGCONT = ... + SIGEMT = ... + SIGFPE = ... + SIGHUP = ... + SIGILL = ... + SIGINFO = ... + SIGINT = ... + SIGIO = ... + SIGIOT = ... + SIGKILL = ... + SIGPIPE = ... + SIGPOLL = ... + SIGPROF = ... + SIGPWR = ... + SIGQUIT = ... + SIGRTMAX = ... + SIGRTMIN = ... + SIGSEGV = ... + SIGSTOP = ... + SIGSYS = ... + SIGTERM = ... + SIGTRAP = ... + SIGTSTP = ... + SIGTTIN = ... + SIGTTOU = ... + SIGURG = ... + SIGUSR1 = ... + SIGUSR2 = ... + SIGVTALRM = ... + SIGWINCH = ... + SIGXCPU = ... + SIGXFSZ = ... - class Handlers(IntEnum): - SIG_DFL = ... - SIG_IGN = ... +class Handlers(IntEnum): + SIG_DFL = ... + SIG_IGN = ... - SIG_DFL = Handlers.SIG_DFL - SIG_IGN = Handlers.SIG_IGN +SIG_DFL = Handlers.SIG_DFL +SIG_IGN = Handlers.SIG_IGN - class Sigmasks(IntEnum): - SIG_BLOCK = ... - SIG_UNBLOCK = ... - SIG_SETMASK = ... +class Sigmasks(IntEnum): + SIG_BLOCK = ... + SIG_UNBLOCK = ... + SIG_SETMASK = ... - 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 - _SIG = Signals - _SIGNUM = Union[int, Signals] - _HANDLER = Union[Callable[[Signals, FrameType], None], int, Handlers, None] -else: - SIG_DFL: int = ... - SIG_IGN: int = ... - - SIG_BLOCK: int = ... - SIG_UNBLOCK: int = ... - SIG_SETMASK: int = ... - - _SIG = int - _SIGNUM = int - _HANDLER = Union[Callable[[int, FrameType], None], int, None] +_SIG = Signals +_SIGNUM = Union[int, Signals] +_HANDLER = Union[Callable[[Signals, FrameType], None], int, Handlers, None] SIGABRT: _SIG = ... SIGALRM: _SIG = ... diff --git a/stdlib/3/smtplib.pyi b/stdlib/3/smtplib.pyi index ec8e27f09..d13439b38 100644 --- a/stdlib/3/smtplib.pyi +++ b/stdlib/3/smtplib.pyi @@ -96,20 +96,16 @@ class SMTP: vrfy = verify def expn(self, address: str) -> _Reply: ... def ehlo_or_helo_if_needed(self) -> None: ... - if sys.version_info >= (3, 5): - user: str - password: str - def auth(self, mechanism: str, authobject: _AuthObject, *, initial_response_ok: bool = ...) -> _Reply: ... - @overload - def auth_cram_md5(self, challenge: None = ...) -> None: ... - @overload - def auth_cram_md5(self, challenge: bytes) -> str: ... - def auth_plain(self, challenge: Optional[bytes] = ...) -> str: ... - def auth_login(self, challenge: Optional[bytes] = ...) -> str: ... - def login(self, user: str, password: str, *, - initial_response_ok: bool = ...) -> _Reply: ... - else: - def login(self, user: str, password: str) -> _Reply: ... + user: str + password: str + def auth(self, mechanism: str, authobject: _AuthObject, *, initial_response_ok: bool = ...) -> _Reply: ... + @overload + def auth_cram_md5(self, challenge: None = ...) -> None: ... + @overload + def auth_cram_md5(self, challenge: bytes) -> str: ... + def auth_plain(self, challenge: Optional[bytes] = ...) -> str: ... + def auth_login(self, challenge: Optional[bytes] = ...) -> str: ... + def login(self, user: str, password: str, *, initial_response_ok: bool = ...) -> _Reply: ... def starttls(self, keyfile: Optional[str] = ..., certfile: Optional[str] = ..., context: Optional[SSLContext] = ...) -> _Reply: ... def sendmail(self, from_addr: str, to_addrs: Union[str, Sequence[str]], diff --git a/stdlib/3/subprocess.pyi b/stdlib/3/subprocess.pyi index fa7d10236..57bff805e 100644 --- a/stdlib/3/subprocess.pyi +++ b/stdlib/3/subprocess.pyi @@ -38,372 +38,396 @@ _ENV = Union[Mapping[bytes, _TXT], Mapping[Text, _TXT]] _T = TypeVar('_T') -if sys.version_info >= (3, 5): - class CompletedProcess(Generic[_T]): - # morally: _CMD - args: Any - returncode: int - # These are really both Optional, but requiring checks would be tedious - # and writing all the overloads would be horrific. - stdout: _T - stderr: _T - def __init__(self, args: _CMD, - returncode: int, - stdout: Optional[_T] = ..., - stderr: Optional[_T] = ...) -> None: ... - def check_returncode(self) -> None: ... +class CompletedProcess(Generic[_T]): + # morally: _CMD + args: Any + returncode: int + # These are really both Optional, but requiring checks would be tedious + # and writing all the overloads would be horrific. + stdout: _T + stderr: _T + def __init__(self, args: _CMD, returncode: int, stdout: Optional[_T] = ..., stderr: Optional[_T] = ...) -> None: ... + def check_returncode(self) -> None: ... - if sys.version_info >= (3, 7): - # Nearly the same args as for 3.6, except for capture_output and text - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - capture_output: bool = ..., - check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[str] = ..., - text: Literal[True], - timeout: Optional[float] = ...) -> CompletedProcess[str]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - capture_output: bool = ..., - check: bool = ..., - encoding: str, - errors: Optional[str] = ..., - input: Optional[str] = ..., - text: Optional[bool] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[str]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - capture_output: bool = ..., - check: bool = ..., - encoding: Optional[str] = ..., - errors: str, - input: Optional[str] = ..., - text: Optional[bool] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[str]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - *, - universal_newlines: Literal[True], - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - # where the *real* keyword only args start - capture_output: bool = ..., - check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[str] = ..., - text: Optional[bool] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[str]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: Literal[False] = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - capture_output: bool = ..., - check: bool = ..., - encoding: None = ..., - errors: None = ..., - input: Optional[bytes] = ..., - text: Literal[None, False] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[bytes]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - capture_output: bool = ..., - check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[_TXT] = ..., - text: Optional[bool] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[Any]: ... - elif sys.version_info >= (3, 6): - # Nearly same args as Popen.__init__ except for timeout, input, and check - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - encoding: str, - errors: Optional[str] = ..., - input: Optional[str] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[str]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - encoding: Optional[str] = ..., - errors: str, - input: Optional[str] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[str]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - *, - universal_newlines: Literal[True], - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - # where the *real* keyword only args start - check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[str] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[str]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: Literal[False] = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - encoding: None = ..., - errors: None = ..., - input: Optional[bytes] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[bytes]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[_TXT] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[Any]: ... - else: - # Nearly same args as Popen.__init__ except for timeout, input, and check - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - *, - universal_newlines: Literal[True], - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - # where the *real* keyword only args start - check: bool = ..., - input: Optional[str] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[str]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: Literal[False] = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - input: Optional[bytes] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[bytes]: ... - @overload - def run(args: _CMD, - bufsize: int = ..., - executable: _PATH = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[_PATH] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - input: Optional[_TXT] = ..., - timeout: Optional[float] = ...) -> CompletedProcess[Any]: ... +if sys.version_info >= (3, 7): + # Nearly the same args as for 3.6, except for capture_output and text + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: bool = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + capture_output: bool = ..., + check: bool = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + input: Optional[str] = ..., + text: Literal[True], + timeout: Optional[float] = ..., + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: bool = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + capture_output: bool = ..., + check: bool = ..., + encoding: str, + errors: Optional[str] = ..., + input: Optional[str] = ..., + text: Optional[bool] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: bool = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + capture_output: bool = ..., + check: bool = ..., + encoding: Optional[str] = ..., + errors: str, + input: Optional[str] = ..., + text: Optional[bool] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + *, + universal_newlines: Literal[True], + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + # where the *real* keyword only args start + capture_output: bool = ..., + check: bool = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + input: Optional[str] = ..., + text: Optional[bool] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: Literal[False] = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + capture_output: bool = ..., + check: bool = ..., + encoding: None = ..., + errors: None = ..., + input: Optional[bytes] = ..., + text: Literal[None, False] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[bytes]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: bool = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + capture_output: bool = ..., + check: bool = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + input: Optional[_TXT] = ..., + text: Optional[bool] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[Any]: ... +elif sys.version_info >= (3, 6): + # Nearly same args as Popen.__init__ except for timeout, input, and check + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: bool = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + check: bool = ..., + encoding: str, + errors: Optional[str] = ..., + input: Optional[str] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: bool = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + check: bool = ..., + encoding: Optional[str] = ..., + errors: str, + input: Optional[str] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + *, + universal_newlines: Literal[True], + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + # where the *real* keyword only args start + check: bool = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + input: Optional[str] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: Literal[False] = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + check: bool = ..., + encoding: None = ..., + errors: None = ..., + input: Optional[bytes] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[bytes]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: bool = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + check: bool = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + input: Optional[_TXT] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[Any]: ... +else: + # Nearly same args as Popen.__init__ except for timeout, input, and check + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + *, + universal_newlines: Literal[True], + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + # where the *real* keyword only args start + check: bool = ..., + input: Optional[str] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: Literal[False] = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + check: bool = ..., + input: Optional[bytes] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[bytes]: ... + @overload + def run( + args: _CMD, + bufsize: int = ..., + executable: _PATH = ..., + stdin: _FILE = ..., + stdout: _FILE = ..., + stderr: _FILE = ..., + preexec_fn: Callable[[], Any] = ..., + close_fds: bool = ..., + shell: bool = ..., + cwd: Optional[_PATH] = ..., + env: Optional[_ENV] = ..., + universal_newlines: bool = ..., + startupinfo: Any = ..., + creationflags: int = ..., + restore_signals: bool = ..., + start_new_session: bool = ..., + pass_fds: Any = ..., + *, + check: bool = ..., + input: Optional[_TXT] = ..., + timeout: Optional[float] = ..., + ) -> CompletedProcess[Any]: ... # Same args as Popen.__init__ def call(args: _CMD, @@ -795,10 +819,9 @@ class CalledProcessError(Exception): # morally: Optional[_TXT] output: Any - if sys.version_info >= (3, 5): - # morally: Optional[_TXT] - stdout: Any - stderr: Any + # morally: Optional[_TXT] + stdout: Any + stderr: Any def __init__(self, returncode: int, diff --git a/stdlib/3/symbol.pyi b/stdlib/3/symbol.pyi index 0cf5f1cdf..59be57765 100644 --- a/stdlib/3/symbol.pyi +++ b/stdlib/3/symbol.pyi @@ -9,8 +9,7 @@ eval_input: int decorator: int decorators: int decorated: int -if sys.version_info >= (3, 5): - async_funcdef: int +async_funcdef: int funcdef: int parameters: int typedargslist: int @@ -45,8 +44,7 @@ global_stmt: int nonlocal_stmt: int assert_stmt: int compound_stmt: int -if sys.version_info >= (3, 5): - async_stmt: int +async_stmt: int if_stmt: int while_stmt: int for_stmt: int @@ -73,8 +71,7 @@ arith_expr: int term: int factor: int power: int -if sys.version_info >= (3, 5): - atom_expr: int +atom_expr: int atom: int testlist_comp: int trailer: int diff --git a/stdlib/3/sys.pyi b/stdlib/3/sys.pyi index 911ff4fe9..fa99bbb13 100644 --- a/stdlib/3/sys.pyi +++ b/stdlib/3/sys.pyi @@ -185,8 +185,7 @@ def getwindowsversion() -> _WinVersion: ... # Windows only def intern(string: str) -> str: ... -if sys.version_info >= (3, 5): - def is_finalizing() -> bool: ... +def is_finalizing() -> bool: ... if sys.version_info >= (3, 7): __breakpointhook__: Any # contains the original value of breakpointhook diff --git a/stdlib/3/tempfile.pyi b/stdlib/3/tempfile.pyi index e041b44e7..e4aad54b4 100644 --- a/stdlib/3/tempfile.pyi +++ b/stdlib/3/tempfile.pyi @@ -13,111 +13,75 @@ tempdir: Optional[str] template: str -if sys.version_info >= (3, 5): - def TemporaryFile( - mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., - newline: Optional[str] = ..., suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., - dir: Optional[AnyStr] = ... - ) -> IO[Any]: - ... - def NamedTemporaryFile( - mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., - newline: Optional[str] = ..., suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., - dir: Optional[AnyStr] = ..., delete: bool = ... - ) -> IO[Any]: - ... +def TemporaryFile( + mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., + newline: Optional[str] = ..., suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., + dir: Optional[AnyStr] = ... +) -> IO[Any]: + ... +def NamedTemporaryFile( + mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., + newline: Optional[str] = ..., suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., + dir: Optional[AnyStr] = ..., delete: bool = ... +) -> IO[Any]: + ... - # It does not actually derive from IO[AnyStr], but it does implement the - # protocol. - class SpooledTemporaryFile(IO[AnyStr]): - def __init__(self, max_size: int = ..., mode: str = ..., - buffering: int = ..., encoding: Optional[str] = ..., - newline: Optional[str] = ..., suffix: Optional[str] = ..., - prefix: Optional[str] = ..., dir: Optional[str] = ... - ) -> None: ... - def rollover(self) -> None: ... - def __enter__(self) -> SpooledTemporaryFile: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[TracebackType]) -> bool: ... +# It does not actually derive from IO[AnyStr], but it does implement the +# protocol. +class SpooledTemporaryFile(IO[AnyStr]): + def __init__(self, max_size: int = ..., mode: str = ..., + buffering: int = ..., encoding: Optional[str] = ..., + newline: Optional[str] = ..., suffix: Optional[str] = ..., + prefix: Optional[str] = ..., dir: Optional[str] = ... + ) -> None: ... + def rollover(self) -> None: ... + def __enter__(self) -> SpooledTemporaryFile: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], + exc_tb: Optional[TracebackType]) -> bool: ... - # These methods are copied from the abstract methods of IO, because - # SpooledTemporaryFile implements IO. - # See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918. - def close(self) -> None: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, n: int = ...) -> AnyStr: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> AnyStr: ... - def readlines(self, hint: int = ...) -> List[AnyStr]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: Optional[int] = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, s: AnyStr) -> int: ... - def writelines(self, lines: Iterable[AnyStr]) -> None: ... - def __next__(self) -> AnyStr: ... - def __iter__(self) -> Iterator[AnyStr]: ... + # These methods are copied from the abstract methods of IO, because + # SpooledTemporaryFile implements IO. + # See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918. + def close(self) -> None: ... + def fileno(self) -> int: ... + def flush(self) -> None: ... + def isatty(self) -> bool: ... + def read(self, n: int = ...) -> AnyStr: ... + def readable(self) -> bool: ... + def readline(self, limit: int = ...) -> AnyStr: ... + def readlines(self, hint: int = ...) -> List[AnyStr]: ... + def seek(self, offset: int, whence: int = ...) -> int: ... + def seekable(self) -> bool: ... + def tell(self) -> int: ... + def truncate(self, size: Optional[int] = ...) -> int: ... + def writable(self) -> bool: ... + def write(self, s: AnyStr) -> int: ... + def writelines(self, lines: Iterable[AnyStr]) -> None: ... + def __next__(self) -> AnyStr: ... + def __iter__(self) -> Iterator[AnyStr]: ... - class TemporaryDirectory(Generic[AnyStr]): - name: str - def __init__(self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., - dir: Optional[AnyStr] = ...) -> None: ... - def cleanup(self) -> None: ... - def __enter__(self) -> AnyStr: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[TracebackType]) -> bool: ... +class TemporaryDirectory(Generic[AnyStr]): + name: str + def __init__(self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., + dir: Optional[AnyStr] = ...) -> None: ... + def cleanup(self) -> None: ... + def __enter__(self) -> AnyStr: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], + exc_tb: Optional[TracebackType]) -> bool: ... - def mkstemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[AnyStr] = ..., - text: bool = ...) -> Tuple[int, AnyStr]: ... - @overload - def mkdtemp() -> str: ... - @overload - def mkdtemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., - dir: Optional[AnyStr] = ...) -> AnyStr: ... - def mktemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[AnyStr] = ...) -> AnyStr: ... +def mkstemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[AnyStr] = ..., + text: bool = ...) -> Tuple[int, AnyStr]: ... +@overload +def mkdtemp() -> str: ... +@overload +def mkdtemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., + dir: Optional[AnyStr] = ...) -> AnyStr: ... +def mktemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[AnyStr] = ...) -> AnyStr: ... - def gettempdirb() -> bytes: ... - def gettempprefixb() -> bytes: ... -else: - def TemporaryFile( - mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., - newline: Optional[str] = ..., suffix: str = ..., prefix: str = ..., - dir: Optional[str] = ... - ) -> IO[Any]: - ... - def NamedTemporaryFile( - mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., - newline: Optional[str] = ..., suffix: str = ..., prefix: str = ..., - dir: Optional[str] = ..., delete: bool = ... - ) -> IO[Any]: - ... - def SpooledTemporaryFile( - max_size: int = ..., mode: str = ..., buffering: int = ..., - encoding: str = ..., newline: str = ..., suffix: str = ..., - prefix: str = ..., dir: Optional[str] = ... - ) -> IO[Any]: - ... - - class TemporaryDirectory: - name: str - def __init__(self, suffix: str = ..., prefix: str = ..., - dir: Optional[str] = ...) -> None: ... - def cleanup(self) -> None: ... - def __enter__(self) -> str: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[TracebackType]) -> bool: ... - - def mkstemp(suffix: str = ..., prefix: str = ..., dir: Optional[str] = ..., - text: bool = ...) -> Tuple[int, str]: ... - def mkdtemp(suffix: str = ..., prefix: str = ..., - dir: Optional[str] = ...) -> str: ... - def mktemp(suffix: str = ..., prefix: str = ..., dir: Optional[str] = ...) -> str: ... +def gettempdirb() -> bytes: ... +def gettempprefixb() -> bytes: ... def gettempdir() -> str: ... def gettempprefix() -> str: ... diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 042f86487..1fefd23a2 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -168,10 +168,6 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): @property def gi_yieldfrom(self) -> Optional[Generator]: ... -# TODO: Several types should only be defined if sys.python_version >= (3, 5): -# Awaitable, AsyncIterator, AsyncIterable, Coroutine, Collection. -# See https: //github.com/python/typeshed/issues/655 for why this is not easy. - @runtime_checkable class Awaitable(Protocol[_T_co]): @abstractmethod @@ -271,10 +267,7 @@ class Sequence(_Collection[_T_co], Reversible[_T_co], Generic[_T_co]): @abstractmethod def __getitem__(self, s: slice) -> Sequence[_T_co]: ... # Mixin methods - if sys.version_info >= (3, 5): - def index(self, x: Any, start: int = ..., end: int = ...) -> int: ... - else: - def index(self, x: Any) -> int: ... + def index(self, x: Any, start: int = ..., end: int = ...) -> int: ... def count(self, x: Any) -> int: ... def __contains__(self, x: object) -> bool: ... def __iter__(self) -> Iterator[_T_co]: ... @@ -376,13 +369,15 @@ class ContextManager(Protocol[_T_co]): __exc_value: Optional[BaseException], __traceback: Optional[TracebackType]) -> Optional[bool]: ... -if sys.version_info >= (3, 5): - @runtime_checkable - class AsyncContextManager(Protocol[_T_co]): - def __aenter__(self) -> Awaitable[_T_co]: ... - def __aexit__(self, exc_type: Optional[Type[BaseException]], - exc_value: Optional[BaseException], - traceback: Optional[TracebackType]) -> Awaitable[Optional[bool]]: ... +@runtime_checkable +class AsyncContextManager(Protocol[_T_co]): + def __aenter__(self) -> Awaitable[_T_co]: ... + def __aexit__( + self, + exc_type: Optional[Type[BaseException]], + exc_value: Optional[BaseException], + traceback: Optional[TracebackType], + ) -> Awaitable[Optional[bool]]: ... class Mapping(_Collection[_KT], Generic[_KT, _VT_co]): # TODO: We wish the key type could also be covariant, but that doesn't work, diff --git a/stdlib/3/unittest/loader.pyi b/stdlib/3/unittest/loader.pyi index 53b81ad72..d32c7132b 100644 --- a/stdlib/3/unittest/loader.pyi +++ b/stdlib/3/unittest/loader.pyi @@ -7,19 +7,13 @@ from typing import Any, Callable, List, Optional, Sequence, Type class TestLoader: - if sys.version_info >= (3, 5): - errors: List[Type[BaseException]] + errors: List[Type[BaseException]] testMethodPrefix: str sortTestMethodsUsing: Callable[[str, str], bool] suiteClass: Callable[[List[unittest.case.TestCase]], unittest.suite.TestSuite] def loadTestsFromTestCase(self, testCaseClass: Type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ... - if sys.version_info >= (3, 5): - def loadTestsFromModule(self, module: ModuleType, - *, pattern: Any = ...) -> unittest.suite.TestSuite: ... - else: - def loadTestsFromModule(self, - module: ModuleType) -> unittest.suite.TestSuite: ... + def loadTestsFromModule(self, module: ModuleType, *, pattern: Any = ...) -> unittest.suite.TestSuite: ... def loadTestsFromName(self, name: str, module: Optional[ModuleType] = ...) -> unittest.suite.TestSuite: ... def loadTestsFromNames(self, names: Sequence[str], diff --git a/stdlib/3/unittest/runner.pyi b/stdlib/3/unittest/runner.pyi index 786bc191e..4c84d8b06 100644 --- a/stdlib/3/unittest/runner.pyi +++ b/stdlib/3/unittest/runner.pyi @@ -23,18 +23,16 @@ class TestRunner: class TextTestRunner(TestRunner): - if sys.version_info >= (3, 5): - def __init__(self, stream: Optional[TextIO] = ..., - descriptions: bool = ..., verbosity: int = ..., - failfast: bool = ..., buffer: bool = ..., - resultclass: Optional[_ResultClassType] = ..., - warnings: Optional[Type[Warning]] = ..., - *, tb_locals: bool = ...) -> None: ... - else: - def __init__(self, - stream: Optional[TextIO] = ..., - descriptions: bool = ..., verbosity: int = ..., - failfast: bool = ..., buffer: bool = ..., - resultclass: Optional[_ResultClassType] = ..., - warnings: Optional[Type[Warning]] = ...) -> None: ... + def __init__( + self, + stream: Optional[TextIO] = ..., + descriptions: bool = ..., + verbosity: int = ..., + failfast: bool = ..., + buffer: bool = ..., + resultclass: Optional[_ResultClassType] = ..., + warnings: Optional[Type[Warning]] = ..., + *, + tb_locals: bool = ..., + ) -> None: ... def _makeResult(self) -> unittest.result.TestResult: ... diff --git a/stdlib/3/urllib/parse.pyi b/stdlib/3/urllib/parse.pyi index 8d7cc4a0d..b835119ec 100644 --- a/stdlib/3/urllib/parse.pyi +++ b/stdlib/3/urllib/parse.pyi @@ -109,19 +109,14 @@ def urldefrag(url: str) -> DefragResult: ... @overload def urldefrag(url: bytes) -> DefragResultBytes: ... -if sys.version_info >= (3, 5): - def urlencode(query: Union[Mapping[Any, Any], - Mapping[Any, Sequence[Any]], - Sequence[Tuple[Any, Any]], - Sequence[Tuple[Any, Sequence[Any]]]], - doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., errors: str = ..., - quote_via: Callable[[str, AnyStr, str, str], str] = ...) -> str: ... -else: - def urlencode(query: Union[Mapping[Any, Any], - Mapping[Any, Sequence[Any]], - Sequence[Tuple[Any, Any]], - Sequence[Tuple[Any, Sequence[Any]]]], - doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ... +def urlencode( + query: Union[Mapping[Any, Any], Mapping[Any, Sequence[Any]], Sequence[Tuple[Any, Any]], Sequence[Tuple[Any, Sequence[Any]]]], + doseq: bool = ..., + safe: AnyStr = ..., + encoding: str = ..., + errors: str = ..., + quote_via: Callable[[str, AnyStr, str, str], str] = ..., +) -> str: ... def urljoin(base: AnyStr, url: Optional[AnyStr], allow_fragments: bool = ...) -> AnyStr: ... diff --git a/stdlib/3/urllib/request.pyi b/stdlib/3/urllib/request.pyi index cac03ae1a..b043a115e 100644 --- a/stdlib/3/urllib/request.pyi +++ b/stdlib/3/urllib/request.pyi @@ -115,14 +115,17 @@ class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): user: str, passwd: str) -> None: ... def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ... -if sys.version_info >= (3, 5): - class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm): - def add_password(self, realm: str, uri: Union[str, Sequence[str]], - user: str, passwd: str, - is_authenticated: bool = ...) -> None: ... - def update_authenticated(self, uri: Union[str, Sequence[str]], - is_authenticated: bool = ...) -> None: ... - def is_authenticated(self, authuri: str) -> bool: ... +class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm): + def add_password( + self, + realm: str, + uri: Union[str, Sequence[str]], + user: str, + passwd: str, + is_authenticated: bool = ..., + ) -> None: ... + def update_authenticated(self, uri: Union[str, Sequence[str]], is_authenticated: bool = ...) -> None: ... + def is_authenticated(self, authuri: str) -> bool: ... class AbstractBasicAuthHandler: def __init__(self, diff --git a/stdlib/3.5/zipapp.pyi b/stdlib/3/zipapp.pyi similarity index 100% rename from stdlib/3.5/zipapp.pyi rename to stdlib/3/zipapp.pyi diff --git a/tests/check_consistent.py b/tests/check_consistent.py index 0566b4967..47e455830 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -13,7 +13,6 @@ consistent_files = [ 'stdlib/2and3/ntpath.pyi', 'stdlib/2and3/macpath.pyi', 'stdlib/2/os/path.pyi', 'stdlib/3/os/path.pyi'}, {'stdlib/3/enum.pyi', 'third_party/2/enum.pyi'}, - {'stdlib/2/os/path.pyi', 'stdlib/3/os/path.pyi'}, {'stdlib/3/unittest/mock.pyi', 'third_party/2and3/mock.pyi'}, {'stdlib/3/concurrent/__init__.pyi', 'third_party/2/concurrent/__init__.pyi'}, {'stdlib/3/concurrent/futures/__init__.pyi', 'third_party/2/concurrent/futures/__init__.pyi'}, @@ -22,7 +21,7 @@ consistent_files = [ {'stdlib/3/concurrent/futures/process.pyi', 'third_party/2/concurrent/futures/process.pyi'}, {'stdlib/3.7/dataclasses.pyi', 'third_party/3/dataclasses.pyi'}, {'stdlib/3/pathlib.pyi', 'third_party/2/pathlib2.pyi'}, - {'stdlib/3.7/contextvars.pyi', 'third_party/3.5/contextvars.pyi'}, + {'stdlib/3.7/contextvars.pyi', 'third_party/3/contextvars.pyi'}, ] def main(): diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 2d9119109..568f072b1 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -88,7 +88,7 @@ def main(): print("Cannot import mypy. Did you install it?") sys.exit(1) - versions = [(3, 8), (3, 7), (3, 6), (3, 5), (3, 4), (2, 7)] + versions = [(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/third_party/2and3/boto/utils.pyi b/third_party/2and3/boto/utils.pyi index 6552b0af1..2132eb374 100644 --- a/third_party/2and3/boto/utils.pyi +++ b/third_party/2and3/boto/utils.pyi @@ -25,7 +25,7 @@ from typing import ( _KT = TypeVar('_KT') _VT = TypeVar('_VT') -if sys.version_info[0] >= 3: +if sys.version_info >= (3,): # TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO import io _StringIO = io.StringIO diff --git a/third_party/2and3/markupsafe/__init__.pyi b/third_party/2and3/markupsafe/__init__.pyi index 44d15da3a..6bedd2476 100644 --- a/third_party/2and3/markupsafe/__init__.pyi +++ b/third_party/2and3/markupsafe/__init__.pyi @@ -49,5 +49,5 @@ class EscapeFormatter(string.Formatter): def __init__(self, escape: Callable[[text_type], Markup]) -> None: ... def format_field(self, value: text_type, format_spec: text_type) -> Markup: ... -if sys.version_info[0] >= 3: +if sys.version_info >= (3,): soft_str = soft_unicode diff --git a/third_party/2and3/markupsafe/_compat.pyi b/third_party/2and3/markupsafe/_compat.pyi index 7257425cf..9ca940101 100644 --- a/third_party/2and3/markupsafe/_compat.pyi +++ b/third_party/2and3/markupsafe/_compat.pyi @@ -7,7 +7,7 @@ _V = TypeVar('_V') PY2: bool def iteritems(d: Mapping[_K, _V]) -> Iterator[Tuple[_K, _V]]: ... -if sys.version_info[0] >= 3: +if sys.version_info >= (3,): text_type = str string_types = str, unichr = chr diff --git a/third_party/3.5/contextvars.pyi b/third_party/3/contextvars.pyi similarity index 100% rename from third_party/3.5/contextvars.pyi rename to third_party/3/contextvars.pyi diff --git a/third_party/3/pkg_resources/py31compat.pyi b/third_party/3/pkg_resources/py31compat.pyi index e7b17a3c4..aefe11301 100644 --- a/third_party/3/pkg_resources/py31compat.pyi +++ b/third_party/3/pkg_resources/py31compat.pyi @@ -4,11 +4,4 @@ import sys needs_makedirs: bool -def _makedirs_31(path: Text, exist_ok: bool = ...) -> None: ... - -# _makedirs_31 has special behavior to handle an edge case that was removed in -# 3.4.1. No one should be using 3.4 instead of 3.4.1, so this should be fine. -if sys.version_info >= (3,): - makedirs = os.makedirs -else: - makedirs = _makedirs_31 +makedirs = os.makedirs