diff --git a/.github/workflows/stubtest-unused-whitelist.yml b/.github/workflows/stubtest-unused-whitelist.yml index 7a1282c76..d2f53b55d 100644 --- a/.github/workflows/stubtest-unused-whitelist.yml +++ b/.github/workflows/stubtest-unused-whitelist.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest", "windows-latest"] - python-version: [3.5, 3.6, 3.7, 3.8, 3.9] + python-version: [3.6, 3.7, 3.8, 3.9] fail-fast: false steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0c16d232f..8ce9b4c0a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -89,7 +89,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest", "windows-latest"] - python-version: [3.5, 3.6, 3.7, 3.8, 3.9] + python-version: [3.6, 3.7, 3.8, 3.9] fail-fast: false steps: diff --git a/README.md b/README.md index c7e80dac5..d16f25331 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ contributors can be found in [CONTRIBUTING.md](CONTRIBUTING.md). **Please read it before submitting pull requests; do not report issues with annotations to the project the stubs are for, but instead report them here to typeshed.** -Typeshed supports Python versions 2.7 and 3.5 and up. +Typeshed supports Python versions 2.7 and 3.6 and up. ## Using @@ -124,7 +124,7 @@ typed-ast, flake8 (and plugins), pytype, black and isort. ### mypy_test.py -This test requires Python 3.5 or higher; Python 3.6.1 or higher is recommended. +This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended. Run using:`(.venv3)$ python3 tests/mypy_test.py` This test is shallow — it verifies that all stubs can be @@ -138,10 +138,10 @@ the mypy tests that avoids installing mypy: ```bash $ PYTHONPATH=../.. python3 tests/mypy_test.py ``` -You can restrict mypy tests to a single version by passing `-p2` or `-p3.5`: +You can restrict mypy tests to a single version by passing `-p2` or `-p3.9`: ```bash -$ PYTHONPATH=../.. python3 tests/mypy_test.py -p3.5 -running mypy --python-version 3.5 --strict-optional # with 342 files +$ PYTHONPATH=../.. python3 tests/mypy_test.py -p3.9 +running mypy --python-version 3.9 --strict-optional # with 342 files ``` ### pytype_test.py @@ -155,7 +155,7 @@ This test works similarly to `mypy_test.py`, except it uses `pytype`. ### mypy_selftest.py -This test requires Python 3.5 or higher; Python 3.6.1 or higher is recommended. +This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended. Run using: `(.venv3)$ python3 tests/mypy_selftest.py` This test checks mypy's code base using mypy and typeshed code in this repo. @@ -175,7 +175,7 @@ Run using: `python3 tests/check_consistent.py` ### stubtest_test.py -This test requires Python 3.5 or higher. +This test requires Python 3.6 or higher. Run using `(.venv3)$ python3 tests/stubtest_test.py` This test compares the stdlib stubs against the objects at runtime. Because of diff --git a/scripts/migrate_script.py b/scripts/migrate_script.py index 45ecaef39..3315da683 100644 --- a/scripts/migrate_script.py +++ b/scripts/migrate_script.py @@ -14,7 +14,7 @@ from typing import List, Optional, Set, Tuple STDLIB_NAMESPACE = "stdlib" THIRD_PARTY_NAMESPACE = "stubs" DEFAULT_VERSION = "0.1" -DEFAULT_PY3_VERSION = "3.5" +DEFAULT_PY3_VERSION = "3.6" PY2_NAMESPACE = "python2" OUTPUT_DIR = "out" @@ -113,7 +113,7 @@ def collect_stdlib_packages() -> Tuple[List[StdLibPackage], List[StdLibPackage]] add_stdlib_packages_from("stdlib/2and3", stdlib, "2.7") # Use oldest currently supported version for Python 3 packages/modules. add_stdlib_packages_from("stdlib/3", stdlib, DEFAULT_PY3_VERSION) - for version in ("3.6", "3.7", "3.8", "3.9"): + for version in ("3.7", "3.8", "3.9"): subdir = os.path.join("stdlib", version) if os.path.isdir(subdir): add_stdlib_packages_from(subdir, stdlib, version) diff --git a/stdlib/3/_ast.pyi b/stdlib/3/_ast.pyi index 6a5f7d1f3..a8da42ad7 100644 --- a/stdlib/3/_ast.pyi +++ b/stdlib/3/_ast.pyi @@ -87,12 +87,11 @@ class AugAssign(stmt): op: operator value: expr -if sys.version_info >= (3, 6): - class AnnAssign(stmt): - target: expr - annotation: expr - value: Optional[expr] - simple: int +class AnnAssign(stmt): + target: expr + annotation: expr + value: Optional[expr] + simple: int class For(stmt): target: expr @@ -225,13 +224,13 @@ class Call(expr): args: typing.List[expr] keywords: typing.List[keyword] -if sys.version_info >= (3, 6): - class FormattedValue(expr): - value: expr - conversion: Optional[int] - format_spec: Optional[expr] - class JoinedStr(expr): - values: typing.List[expr] +class FormattedValue(expr): + value: expr + conversion: Optional[int] + format_spec: Optional[expr] + +class JoinedStr(expr): + values: typing.List[expr] if sys.version_info < (3, 8): class Num(expr): # Deprecated in 3.8; use Constant @@ -244,13 +243,12 @@ if sys.version_info < (3, 8): value: Any class Ellipsis(expr): ... # Deprecated in 3.8; use Constant -if sys.version_info >= (3, 6): - class Constant(expr): - value: Any # None, str, bytes, bool, int, float, complex, Ellipsis - kind: Optional[str] - # Aliases for value, for backwards compatibility - s: Any - n: complex +class Constant(expr): + value: Any # None, str, bytes, bool, int, float, complex, Ellipsis + kind: Optional[str] + # Aliases for value, for backwards compatibility + s: Any + n: complex if sys.version_info >= (3, 8): class NamedExpr(expr): @@ -350,8 +348,7 @@ class comprehension(AST): target: expr iter: expr ifs: typing.List[expr] - if sys.version_info >= (3, 6): - is_async: int + is_async: int class excepthandler(AST): ... diff --git a/stdlib/3/_compat_pickle.pyi b/stdlib/3/_compat_pickle.pyi index 349cb9b79..5be4c9b9d 100644 --- a/stdlib/3/_compat_pickle.pyi +++ b/stdlib/3/_compat_pickle.pyi @@ -1,4 +1,3 @@ -import sys from typing import Dict, Tuple IMPORT_MAPPING: Dict[str, str] @@ -8,6 +7,4 @@ MULTIPROCESSING_EXCEPTIONS: Tuple[str, ...] REVERSE_IMPORT_MAPPING: Dict[str, str] REVERSE_NAME_MAPPING: Dict[Tuple[str, str], Tuple[str, str]] PYTHON3_OSERROR_EXCEPTIONS: Tuple[str, ...] - -if sys.version_info >= (3, 6): - PYTHON3_IMPORTERROR_EXCEPTIONS: Tuple[str, ...] +PYTHON3_IMPORTERROR_EXCEPTIONS: Tuple[str, ...] diff --git a/stdlib/3/ast.pyi b/stdlib/3/ast.pyi index e01d3d0df..ff1cd00c7 100644 --- a/stdlib/3/ast.pyi +++ b/stdlib/3/ast.pyi @@ -49,8 +49,7 @@ class NodeVisitor: def visit_Delete(self, node: Delete) -> Any: ... def visit_Assign(self, node: Assign) -> Any: ... def visit_AugAssign(self, node: AugAssign) -> Any: ... - if sys.version_info >= (3, 6): - def visit_AnnAssign(self, node: AnnAssign) -> Any: ... + def visit_AnnAssign(self, node: AnnAssign) -> Any: ... def visit_For(self, node: For) -> Any: ... def visit_AsyncFor(self, node: AsyncFor) -> Any: ... def visit_While(self, node: While) -> Any: ... @@ -85,11 +84,9 @@ class NodeVisitor: def visit_YieldFrom(self, node: YieldFrom) -> Any: ... def visit_Compare(self, node: Compare) -> Any: ... def visit_Call(self, node: Call) -> Any: ... - if sys.version_info >= (3, 6): - def visit_FormattedValue(self, node: FormattedValue) -> Any: ... - def visit_JoinedStr(self, node: JoinedStr) -> Any: ... - if sys.version_info >= (3, 6): - def visit_Constant(self, node: Constant) -> Any: ... + def visit_FormattedValue(self, node: FormattedValue) -> Any: ... + def visit_JoinedStr(self, node: JoinedStr) -> Any: ... + def visit_Constant(self, node: Constant) -> Any: ... if sys.version_info >= (3, 8): def visit_NamedExpr(self, node: NamedExpr) -> Any: ... def visit_Attribute(self, node: Attribute) -> Any: ... diff --git a/stdlib/3/asyncio/base_events.pyi b/stdlib/3/asyncio/base_events.pyi index 46e7b149e..33c0f87d8 100644 --- a/stdlib/3/asyncio/base_events.pyi +++ b/stdlib/3/asyncio/base_events.pyi @@ -34,8 +34,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def is_running(self) -> bool: ... def is_closed(self) -> bool: ... def close(self) -> None: ... - if sys.version_info >= (3, 6): - async def shutdown_asyncgens(self) -> None: ... + async def shutdown_asyncgens(self) -> None: ... # Methods scheduling callbacks. All these return Handles. if sys.version_info >= (3, 7): def call_soon(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ... diff --git a/stdlib/3/asyncio/constants.pyi b/stdlib/3/asyncio/constants.pyi index 8a2c848ac..14681f330 100644 --- a/stdlib/3/asyncio/constants.pyi +++ b/stdlib/3/asyncio/constants.pyi @@ -3,8 +3,7 @@ import sys LOG_THRESHOLD_FOR_CONNLOST_WRITES: int ACCEPT_RETRY_DELAY: int -if sys.version_info >= (3, 6): - DEBUG_STACK_DEPTH: int +DEBUG_STACK_DEPTH: int if sys.version_info >= (3, 7): SSL_HANDSHAKE_TIMEOUT: float SENDFILE_FALLBACK_READBUFFER_SIZE: int diff --git a/stdlib/3/asyncio/futures.pyi b/stdlib/3/asyncio/futures.pyi index eccda8903..46911ae6c 100644 --- a/stdlib/3/asyncio/futures.pyi +++ b/stdlib/3/asyncio/futures.pyi @@ -33,8 +33,6 @@ class Future(Awaitable[_T], Iterable[_T]): _exception: BaseException _blocking = False _log_traceback = False - if sys.version_info < (3, 6): - _tb_logger: Type[_TracebackLogger] def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ... def __repr__(self) -> str: ... def __del__(self) -> None: ... diff --git a/stdlib/3/asyncio/sslproto.pyi b/stdlib/3/asyncio/sslproto.pyi index c797f89ce..8d1c44aee 100644 --- a/stdlib/3/asyncio/sslproto.pyi +++ b/stdlib/3/asyncio/sslproto.pyi @@ -48,13 +48,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): _loop: events.AbstractEventLoop _ssl_protocol: SSLProtocol _closed: bool - - if sys.version_info >= (3, 6): - def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ... - else: - def __init__( - self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol, app_protocol: protocols.BaseProtocol - ) -> None: ... + def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ... def get_extra_info(self, name: str, default: Optional[Any] = ...) -> Dict[str, Any]: ... def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ... def get_protocol(self) -> protocols.BaseProtocol: ... diff --git a/stdlib/3/asyncio/transports.pyi b/stdlib/3/asyncio/transports.pyi index 4ac392b1b..636ac3630 100644 --- a/stdlib/3/asyncio/transports.pyi +++ b/stdlib/3/asyncio/transports.pyi @@ -9,9 +9,8 @@ class BaseTransport: def get_extra_info(self, name: Any, default: Any = ...) -> Any: ... def is_closing(self) -> bool: ... def close(self) -> None: ... - if sys.version_info >= (3, 5): - def set_protocol(self, protocol: BaseProtocol) -> None: ... - def get_protocol(self) -> BaseProtocol: ... + def set_protocol(self, protocol: BaseProtocol) -> None: ... + def get_protocol(self) -> BaseProtocol: ... class ReadTransport(BaseTransport): if sys.version_info >= (3, 7): diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 13ce51131..72270ac2f 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -85,8 +85,7 @@ class object: __dict__: Dict[str, Any] __slots__: Union[str, Iterable[str]] __module__: str - if sys.version_info >= (3, 6): - __annotations__: Dict[str, Any] + __annotations__: Dict[str, Any] @property def __class__(self: _T) -> Type[_T]: ... @__class__.setter @@ -106,8 +105,7 @@ class object: def __reduce__(self) -> Union[str, Tuple[Any, ...]]: ... def __reduce_ex__(self, protocol: int) -> Union[str, Tuple[Any, ...]]: ... def __dir__(self) -> Iterable[str]: ... - if sys.version_info >= (3, 6): - def __init_subclass__(cls) -> None: ... + def __init_subclass__(cls) -> None: ... class staticmethod(object): # Special, only valid as a decorator. __func__: Callable[..., Any] @@ -422,7 +420,7 @@ class bytes(ByteString): def find(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... if sys.version_info >= (3, 8): def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ... - elif sys.version_info >= (3, 5): + else: def hex(self) -> str: ... def index(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... def isalnum(self) -> bool: ... @@ -478,8 +476,7 @@ class bytes(ByteString): def __add__(self, s: bytes) -> bytes: ... def __mul__(self, n: int) -> bytes: ... def __rmul__(self, n: int) -> bytes: ... - if sys.version_info >= (3, 5): - def __mod__(self, value: Any) -> bytes: ... + def __mod__(self, value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... diff --git a/stdlib/3/collections/__init__.pyi b/stdlib/3/collections/__init__.pyi index c3183de27..39bed2d99 100644 --- a/stdlib/3/collections/__init__.pyi +++ b/stdlib/3/collections/__init__.pyi @@ -3,11 +3,13 @@ import typing from typing import ( AbstractSet, Any, + AsyncGenerator as AsyncGenerator, AsyncIterable as AsyncIterable, AsyncIterator as AsyncIterator, Awaitable as Awaitable, ByteString as ByteString, Callable as Callable, + Collection as Collection, Container as Container, Coroutine as Coroutine, Dict, @@ -38,9 +40,6 @@ from typing import ( Set = AbstractSet -if sys.version_info >= (3, 6): - from typing import AsyncGenerator as AsyncGenerator, Collection as Collection - _S = TypeVar("_S") _T = TypeVar("_T") _KT = TypeVar("_KT") @@ -57,7 +56,7 @@ if sys.version_info >= (3, 7): defaults: Optional[Iterable[Any]] = ..., ) -> Type[Tuple[Any, ...]]: ... -elif sys.version_info >= (3, 6): +else: def namedtuple( typename: str, field_names: Union[str, Iterable[str]], @@ -67,11 +66,6 @@ elif sys.version_info >= (3, 6): module: Optional[str] = ..., ) -> Type[Tuple[Any, ...]]: ... -else: - def namedtuple( - typename: str, field_names: Union[str, Iterable[str]], verbose: bool = ..., rename: bool = ... - ) -> Type[Tuple[Any, ...]]: ... - class UserDict(MutableMapping[_KT, _VT]): data: Dict[_KT, _VT] def __init__(self, __dict: Optional[Mapping[_KT, _VT]] = ..., **kwargs: _VT) -> None: ... @@ -194,9 +188,6 @@ class UserString(Sequence[str]): def upper(self: _UserStringT) -> _UserStringT: ... def zfill(self: _UserStringT, width: int) -> _UserStringT: ... -# Technically, deque only derives from MutableSequence in 3.5 (before then, the insert and index -# methods did not exist). -# But in practice it's not worth losing sleep over. class deque(MutableSequence[_T], Generic[_T]): @property def maxlen(self) -> Optional[int]: ... diff --git a/stdlib/3/collections/abc.pyi b/stdlib/3/collections/abc.pyi index f1df1961c..c9d69978a 100644 --- a/stdlib/3/collections/abc.pyi +++ b/stdlib/3/collections/abc.pyi @@ -1,11 +1,11 @@ -import sys - from . import ( + AsyncGenerator as AsyncGenerator, AsyncIterable as AsyncIterable, AsyncIterator as AsyncIterator, Awaitable as Awaitable, ByteString as ByteString, Callable as Callable, + Collection as Collection, Container as Container, Coroutine as Coroutine, Generator as Generator, @@ -19,11 +19,9 @@ from . import ( MutableMapping as MutableMapping, MutableSequence as MutableSequence, MutableSet as MutableSet, + Reversible as Reversible, Sequence as Sequence, Set as Set, Sized as Sized, ValuesView as ValuesView, ) - -if sys.version_info >= (3, 6): - from . import AsyncGenerator as AsyncGenerator, Collection as Collection, Reversible as Reversible diff --git a/stdlib/3/compileall.pyi b/stdlib/3/compileall.pyi index 4d6fda9fa..bcc2a8e82 100644 --- a/stdlib/3/compileall.pyi +++ b/stdlib/3/compileall.pyi @@ -2,11 +2,6 @@ import sys from _typeshed import AnyPath from typing import Any, Optional, Pattern -if sys.version_info < (3, 6): - _SuccessType = bool -else: - _SuccessType = int - if sys.version_info >= (3, 7): from py_compile import PycInvalidationMode @@ -27,7 +22,7 @@ if sys.version_info >= (3, 9): prependdir: Optional[AnyPath] = ..., limit_sl_dest: Optional[AnyPath] = ..., hardlink_dupes: bool = ..., - ) -> _SuccessType: ... + ) -> int: ... def compile_file( fullname: AnyPath, ddir: Optional[AnyPath] = ..., @@ -42,7 +37,7 @@ if sys.version_info >= (3, 9): prependdir: Optional[AnyPath] = ..., limit_sl_dest: Optional[AnyPath] = ..., hardlink_dupes: bool = ..., - ) -> _SuccessType: ... + ) -> int: ... elif sys.version_info >= (3, 7): def compile_dir( @@ -56,7 +51,7 @@ elif sys.version_info >= (3, 7): optimize: int = ..., workers: int = ..., invalidation_mode: Optional[PycInvalidationMode] = ..., - ) -> _SuccessType: ... + ) -> int: ... def compile_file( fullname: AnyPath, ddir: Optional[AnyPath] = ..., @@ -66,7 +61,7 @@ elif sys.version_info >= (3, 7): legacy: bool = ..., optimize: int = ..., invalidation_mode: Optional[PycInvalidationMode] = ..., - ) -> _SuccessType: ... + ) -> int: ... else: # rx can be any object with a 'search' method; once we have Protocols we can change the type @@ -80,7 +75,7 @@ else: legacy: bool = ..., optimize: int = ..., workers: int = ..., - ) -> _SuccessType: ... + ) -> int: ... def compile_file( fullname: AnyPath, ddir: Optional[AnyPath] = ..., @@ -89,7 +84,7 @@ else: quiet: int = ..., legacy: bool = ..., optimize: int = ..., - ) -> _SuccessType: ... + ) -> int: ... if sys.version_info >= (3, 7): def compile_path( @@ -100,7 +95,7 @@ if sys.version_info >= (3, 7): legacy: bool = ..., optimize: int = ..., invalidation_mode: Optional[PycInvalidationMode] = ..., - ) -> _SuccessType: ... + ) -> int: ... else: def compile_path( @@ -110,4 +105,4 @@ else: quiet: int = ..., legacy: bool = ..., optimize: int = ..., - ) -> _SuccessType: ... + ) -> int: ... diff --git a/stdlib/3/email/mime/application.pyi b/stdlib/3/email/mime/application.pyi index 4df7b6e00..d1b2f1dad 100644 --- a/stdlib/3/email/mime/application.pyi +++ b/stdlib/3/email/mime/application.pyi @@ -1,4 +1,3 @@ -import sys from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy from typing import Callable, Optional, Tuple, Union @@ -6,21 +5,12 @@ from typing import Callable, Optional, Tuple, Union _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEApplication(MIMENonMultipart): - if sys.version_info >= (3, 6): - def __init__( - self, - _data: Union[str, bytes], - _subtype: str = ..., - _encoder: Callable[[MIMEApplication], None] = ..., - *, - policy: Optional[Policy] = ..., - **_params: _ParamsType, - ) -> None: ... - else: - def __init__( - self, - _data: Union[str, bytes], - _subtype: str = ..., - _encoder: Callable[[MIMEApplication], None] = ..., - **_params: _ParamsType, - ) -> None: ... + def __init__( + self, + _data: Union[str, bytes], + _subtype: str = ..., + _encoder: Callable[[MIMEApplication], None] = ..., + *, + policy: Optional[Policy] = ..., + **_params: _ParamsType, + ) -> None: ... diff --git a/stdlib/3/email/mime/audio.pyi b/stdlib/3/email/mime/audio.pyi index 39287cebb..9bd5b5ca5 100644 --- a/stdlib/3/email/mime/audio.pyi +++ b/stdlib/3/email/mime/audio.pyi @@ -1,4 +1,3 @@ -import sys from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy from typing import Callable, Optional, Tuple, Union @@ -6,21 +5,12 @@ from typing import Callable, Optional, Tuple, Union _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEAudio(MIMENonMultipart): - if sys.version_info >= (3, 6): - def __init__( - self, - _audiodata: Union[str, bytes], - _subtype: Optional[str] = ..., - _encoder: Callable[[MIMEAudio], None] = ..., - *, - policy: Optional[Policy] = ..., - **_params: _ParamsType, - ) -> None: ... - else: - def __init__( - self, - _audiodata: Union[str, bytes], - _subtype: Optional[str] = ..., - _encoder: Callable[[MIMEAudio], None] = ..., - **_params: _ParamsType, - ) -> None: ... + def __init__( + self, + _audiodata: Union[str, bytes], + _subtype: Optional[str] = ..., + _encoder: Callable[[MIMEAudio], None] = ..., + *, + policy: Optional[Policy] = ..., + **_params: _ParamsType, + ) -> None: ... diff --git a/stdlib/3/email/mime/base.pyi b/stdlib/3/email/mime/base.pyi index 922bb170c..1e3223315 100644 --- a/stdlib/3/email/mime/base.pyi +++ b/stdlib/3/email/mime/base.pyi @@ -1,12 +1,8 @@ import email.message -import sys from email.policy import Policy from typing import Optional, Tuple, Union _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEBase(email.message.Message): - if sys.version_info >= (3, 6): - def __init__(self, _maintype: str, _subtype: str, *, policy: Optional[Policy] = ..., **_params: _ParamsType) -> None: ... - else: - def __init__(self, _maintype: str, _subtype: str, **_params: _ParamsType) -> None: ... + def __init__(self, _maintype: str, _subtype: str, *, policy: Optional[Policy] = ..., **_params: _ParamsType) -> None: ... diff --git a/stdlib/3/email/mime/image.pyi b/stdlib/3/email/mime/image.pyi index a2a25885a..f192494ec 100644 --- a/stdlib/3/email/mime/image.pyi +++ b/stdlib/3/email/mime/image.pyi @@ -1,4 +1,3 @@ -import sys from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy from typing import Callable, Optional, Tuple, Union @@ -6,21 +5,12 @@ from typing import Callable, Optional, Tuple, Union _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEImage(MIMENonMultipart): - if sys.version_info >= (3, 6): - def __init__( - self, - _imagedata: Union[str, bytes], - _subtype: Optional[str] = ..., - _encoder: Callable[[MIMEImage], None] = ..., - *, - policy: Optional[Policy] = ..., - **_params: _ParamsType, - ) -> None: ... - else: - def __init__( - self, - _imagedata: Union[str, bytes], - _subtype: Optional[str] = ..., - _encoder: Callable[[MIMEImage], None] = ..., - **_params: _ParamsType, - ) -> None: ... + def __init__( + self, + _imagedata: Union[str, bytes], + _subtype: Optional[str] = ..., + _encoder: Callable[[MIMEImage], None] = ..., + *, + policy: Optional[Policy] = ..., + **_params: _ParamsType, + ) -> None: ... diff --git a/stdlib/3/email/mime/message.pyi b/stdlib/3/email/mime/message.pyi index 78b33aa58..d2ce81818 100644 --- a/stdlib/3/email/mime/message.pyi +++ b/stdlib/3/email/mime/message.pyi @@ -1,11 +1,7 @@ -import sys from email.message import Message from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy from typing import Optional class MIMEMessage(MIMENonMultipart): - if sys.version_info >= (3, 6): - def __init__(self, _msg: Message, _subtype: str = ..., *, policy: Optional[Policy] = ...) -> None: ... - else: - def __init__(self, _msg: Message, _subtype: str = ...) -> None: ... + def __init__(self, _msg: Message, _subtype: str = ..., *, policy: Optional[Policy] = ...) -> None: ... diff --git a/stdlib/3/email/mime/multipart.pyi b/stdlib/3/email/mime/multipart.pyi index 5f572bd53..eb5f662de 100644 --- a/stdlib/3/email/mime/multipart.pyi +++ b/stdlib/3/email/mime/multipart.pyi @@ -1,4 +1,3 @@ -import sys from email.message import Message from email.mime.base import MIMEBase from email.policy import Policy @@ -7,21 +6,12 @@ from typing import Optional, Sequence, Tuple, Union _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEMultipart(MIMEBase): - if sys.version_info >= (3, 6): - def __init__( - self, - _subtype: str = ..., - boundary: Optional[str] = ..., - _subparts: Optional[Sequence[Message]] = ..., - *, - policy: Optional[Policy] = ..., - **_params: _ParamsType, - ) -> None: ... - else: - def __init__( - self, - _subtype: str = ..., - boundary: Optional[str] = ..., - _subparts: Optional[Sequence[Message]] = ..., - **_params: _ParamsType, - ) -> None: ... + def __init__( + self, + _subtype: str = ..., + boundary: Optional[str] = ..., + _subparts: Optional[Sequence[Message]] = ..., + *, + policy: Optional[Policy] = ..., + **_params: _ParamsType, + ) -> None: ... diff --git a/stdlib/3/email/mime/text.pyi b/stdlib/3/email/mime/text.pyi index e088bffc7..aa5590ebb 100644 --- a/stdlib/3/email/mime/text.pyi +++ b/stdlib/3/email/mime/text.pyi @@ -1,12 +1,8 @@ -import sys from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy from typing import Optional class MIMEText(MIMENonMultipart): - if sys.version_info >= (3, 6): - def __init__( - self, _text: str, _subtype: str = ..., _charset: Optional[str] = ..., *, policy: Optional[Policy] = ... - ) -> None: ... - else: - def __init__(self, _text: str, _subtype: str = ..., _charset: Optional[str] = ...) -> None: ... + def __init__( + self, _text: str, _subtype: str = ..., _charset: Optional[str] = ..., *, policy: Optional[Policy] = ... + ) -> None: ... diff --git a/stdlib/3/enum.pyi b/stdlib/3/enum.pyi index 860836f0b..1a1dcf005 100644 --- a/stdlib/3/enum.pyi +++ b/stdlib/3/enum.pyi @@ -29,13 +29,12 @@ class Enum(metaclass=EnumMeta): _value2member_map_: Dict[int, Enum] # undocumented if sys.version_info >= (3, 7): _ignore_: Union[str, List[str]] - if sys.version_info >= (3, 6): - _order_: str - __order__: str - @classmethod - def _missing_(cls, value: object) -> Any: ... - @staticmethod - def _generate_next_value_(name: str, start: int, count: int, last_values: List[Any]) -> Any: ... + _order_: str + __order__: str + @classmethod + def _missing_(cls, value: object) -> Any: ... + @staticmethod + def _generate_next_value_(name: str, start: int, count: int, last_values: List[Any]) -> Any: ... def __new__(cls: Type[_T], value: object) -> _T: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... @@ -49,25 +48,26 @@ class IntEnum(int, Enum): def unique(enumeration: _S) -> _S: ... -if sys.version_info >= (3, 6): - _auto_null: Any +_auto_null: Any - # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() - class auto(IntFlag): - value: Any - class Flag(Enum): - def __contains__(self: _T, other: _T) -> bool: ... - def __repr__(self) -> str: ... - def __str__(self) -> str: ... - def __bool__(self) -> bool: ... - def __or__(self: _T, other: _T) -> _T: ... - def __and__(self: _T, other: _T) -> _T: ... - def __xor__(self: _T, other: _T) -> _T: ... - def __invert__(self: _T) -> _T: ... - class IntFlag(int, Flag): - def __or__(self: _T, other: Union[int, _T]) -> _T: ... - def __and__(self: _T, other: Union[int, _T]) -> _T: ... - def __xor__(self: _T, other: Union[int, _T]) -> _T: ... - __ror__ = __or__ - __rand__ = __and__ - __rxor__ = __xor__ +# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() +class auto(IntFlag): + value: Any + +class Flag(Enum): + def __contains__(self: _T, other: _T) -> bool: ... + def __repr__(self) -> str: ... + def __str__(self) -> str: ... + def __bool__(self) -> bool: ... + def __or__(self: _T, other: _T) -> _T: ... + def __and__(self: _T, other: _T) -> _T: ... + def __xor__(self: _T, other: _T) -> _T: ... + def __invert__(self: _T) -> _T: ... + +class IntFlag(int, Flag): + def __or__(self: _T, other: Union[int, _T]) -> _T: ... + def __and__(self: _T, other: Union[int, _T]) -> _T: ... + def __xor__(self: _T, other: Union[int, _T]) -> _T: ... + __ror__ = __or__ + __rand__ = __and__ + __rxor__ = __xor__ diff --git a/stdlib/3/glob.pyi b/stdlib/3/glob.pyi index 5244d0c8c..3029b2581 100644 --- a/stdlib/3/glob.pyi +++ b/stdlib/3/glob.pyi @@ -1,12 +1,6 @@ -import sys from typing import AnyStr, Iterator, List, Union -if sys.version_info >= (3, 6): - def glob0(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... - -else: - def glob0(dirname: AnyStr, basename: AnyStr) -> List[AnyStr]: ... - +def glob0(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... def glob1(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... def glob(pathname: AnyStr, *, recursive: bool = ...) -> List[AnyStr]: ... def iglob(pathname: AnyStr, *, recursive: bool = ...) -> Iterator[AnyStr]: ... diff --git a/stdlib/3/hashlib.pyi b/stdlib/3/hashlib.pyi index 6c4b783da..70b120d08 100644 --- a/stdlib/3/hashlib.pyi +++ b/stdlib/3/hashlib.pyi @@ -49,72 +49,75 @@ def pbkdf2_hmac( hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: Optional[int] = ... ) -> bytes: ... -if sys.version_info >= (3, 6): - class _VarLenHash(object): - digest_size: int - block_size: int - name: str - def __init__(self, data: ReadableBuffer = ...) -> None: ... - def copy(self) -> _VarLenHash: ... - def digest(self, __length: int) -> bytes: ... - def hexdigest(self, __length: int) -> str: ... - def update(self, __data: ReadableBuffer) -> None: ... - sha3_224 = _Hash - sha3_256 = _Hash - sha3_384 = _Hash - sha3_512 = _Hash - shake_128 = _VarLenHash - shake_256 = _VarLenHash - def scrypt( - password: ReadableBuffer, - *, - salt: Optional[ReadableBuffer] = ..., - n: Optional[int] = ..., - r: Optional[int] = ..., - p: Optional[int] = ..., - maxmem: int = ..., - dklen: int = ..., - ) -> bytes: ... - class _BlakeHash(_Hash): - MAX_DIGEST_SIZE: int - MAX_KEY_SIZE: int - PERSON_SIZE: int - SALT_SIZE: int +class _VarLenHash(object): + digest_size: int + block_size: int + name: str + def __init__(self, data: ReadableBuffer = ...) -> None: ... + def copy(self) -> _VarLenHash: ... + def digest(self, __length: int) -> bytes: ... + def hexdigest(self, __length: int) -> str: ... + def update(self, __data: ReadableBuffer) -> None: ... - if sys.version_info >= (3, 9): - def __init__( - self, - __data: ReadableBuffer = ..., - *, - digest_size: int = ..., - key: ReadableBuffer = ..., - salt: ReadableBuffer = ..., - person: ReadableBuffer = ..., - fanout: int = ..., - depth: int = ..., - leaf_size: int = ..., - node_offset: int = ..., - node_depth: int = ..., - inner_size: int = ..., - last_node: bool = ..., - usedforsecurity: bool = ..., - ) -> None: ... - else: - def __init__( - self, - __data: ReadableBuffer = ..., - *, - digest_size: int = ..., - key: ReadableBuffer = ..., - salt: ReadableBuffer = ..., - person: ReadableBuffer = ..., - fanout: int = ..., - depth: int = ..., - leaf_size: int = ..., - node_offset: int = ..., - node_depth: int = ..., - inner_size: int = ..., - last_node: bool = ..., - ) -> None: ... - blake2b = _BlakeHash - blake2s = _BlakeHash +sha3_224 = _Hash +sha3_256 = _Hash +sha3_384 = _Hash +sha3_512 = _Hash +shake_128 = _VarLenHash +shake_256 = _VarLenHash + +def scrypt( + password: ReadableBuffer, + *, + salt: Optional[ReadableBuffer] = ..., + n: Optional[int] = ..., + r: Optional[int] = ..., + p: Optional[int] = ..., + maxmem: int = ..., + dklen: int = ..., +) -> bytes: ... + +class _BlakeHash(_Hash): + MAX_DIGEST_SIZE: int + MAX_KEY_SIZE: int + PERSON_SIZE: int + SALT_SIZE: int + + if sys.version_info >= (3, 9): + def __init__( + self, + __data: ReadableBuffer = ..., + *, + digest_size: int = ..., + key: ReadableBuffer = ..., + salt: ReadableBuffer = ..., + person: ReadableBuffer = ..., + fanout: int = ..., + depth: int = ..., + leaf_size: int = ..., + node_offset: int = ..., + node_depth: int = ..., + inner_size: int = ..., + last_node: bool = ..., + usedforsecurity: bool = ..., + ) -> None: ... + else: + def __init__( + self, + __data: ReadableBuffer = ..., + *, + digest_size: int = ..., + key: ReadableBuffer = ..., + salt: ReadableBuffer = ..., + person: ReadableBuffer = ..., + fanout: int = ..., + depth: int = ..., + leaf_size: int = ..., + node_offset: int = ..., + node_depth: int = ..., + inner_size: int = ..., + last_node: bool = ..., + ) -> None: ... + +blake2b = _BlakeHash +blake2s = _BlakeHash diff --git a/stdlib/3/http/client.pyi b/stdlib/3/http/client.pyi index 19c0c4f1c..79170ce2c 100644 --- a/stdlib/3/http/client.pyi +++ b/stdlib/3/http/client.pyi @@ -156,18 +156,15 @@ class HTTPConnection: timeout: Optional[float] = ..., source_address: Optional[Tuple[str, int]] = ..., ) -> None: ... - if sys.version_info >= (3, 6): - def request( - self, - method: str, - url: str, - body: Optional[_DataType] = ..., - headers: Mapping[str, str] = ..., - *, - encode_chunked: bool = ..., - ) -> None: ... - else: - def request(self, method: str, url: str, body: Optional[_DataType] = ..., headers: Mapping[str, str] = ...) -> None: ... + def request( + self, + method: str, + url: str, + body: Optional[_DataType] = ..., + headers: Mapping[str, str] = ..., + *, + encode_chunked: bool = ..., + ) -> None: ... def getresponse(self) -> HTTPResponse: ... def set_debuglevel(self, level: int) -> None: ... def set_tunnel(self, host: str, port: Optional[int] = ..., headers: Optional[Mapping[str, str]] = ...) -> None: ... @@ -175,10 +172,7 @@ class HTTPConnection: def close(self) -> None: ... def putrequest(self, method: str, url: str, skip_host: bool = ..., skip_accept_encoding: bool = ...) -> None: ... def putheader(self, header: str, *argument: str) -> None: ... - if sys.version_info >= (3, 6): - def endheaders(self, message_body: Optional[_DataType] = ..., *, encode_chunked: bool = ...) -> None: ... - else: - def endheaders(self, message_body: Optional[_DataType] = ...) -> None: ... + def endheaders(self, message_body: Optional[_DataType] = ..., *, encode_chunked: bool = ...) -> None: ... def send(self, data: _DataType) -> None: ... class HTTPSConnection(HTTPConnection): diff --git a/stdlib/3/http/cookiejar.pyi b/stdlib/3/http/cookiejar.pyi index 49ea66e14..7ff7544ad 100644 --- a/stdlib/3/http/cookiejar.pyi +++ b/stdlib/3/http/cookiejar.pyi @@ -1,11 +1,9 @@ import sys from http.client import HTTPResponse +from os import PathLike from typing import Dict, Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union, overload from urllib.request import Request -if sys.version_info >= (3, 6): - from os import PathLike - _T = TypeVar("_T") class LoadError(OSError): ... diff --git a/stdlib/3/imp.pyi b/stdlib/3/imp.pyi index 029030712..adcf6e097 100644 --- a/stdlib/3/imp.pyi +++ b/stdlib/3/imp.pyi @@ -1,5 +1,4 @@ import os -import sys import types from _typeshed import StrPath from typing import IO, Any, List, Optional, Protocol, Tuple, TypeVar, Union @@ -57,14 +56,9 @@ def load_package(name: str, path: StrPath) -> types.ModuleType: ... def load_module(name: str, file: Optional[_FileLike], filename: str, details: Tuple[str, str, int]) -> types.ModuleType: ... # IO[Any] is a TextIOWrapper if name is a .py file, and a FileIO otherwise. -if sys.version_info >= (3, 6): - def find_module( - name: str, path: Union[None, List[str], List[os.PathLike[str]], List[StrPath]] = ... - ) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ... - -else: - def find_module(name: str, path: Optional[List[str]] = ...) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ... - +def find_module( + name: str, path: Union[None, List[str], List[os.PathLike[str]], List[StrPath]] = ... +) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ... def reload(module: types.ModuleType) -> types.ModuleType: ... def init_builtin(name: str) -> Optional[types.ModuleType]: ... def load_dynamic(name: str, path: str, file: Any = ...) -> types.ModuleType: ... # file argument is ignored diff --git a/stdlib/3/importlib/util.pyi b/stdlib/3/importlib/util.pyi index e38633ea5..028d78bfe 100644 --- a/stdlib/3/importlib/util.pyi +++ b/stdlib/3/importlib/util.pyi @@ -1,6 +1,6 @@ import importlib.abc import importlib.machinery -import sys +import os import types from typing import Any, Callable, List, Optional, Union @@ -23,17 +23,9 @@ def spec_from_loader( loader_state: Optional[Any] = ..., is_package: Optional[bool] = ..., ) -> importlib.machinery.ModuleSpec: ... - -if sys.version_info >= (3, 6): - import os - - _Path = Union[str, bytes, os.PathLike] -else: - _Path = str - def spec_from_file_location( name: str, - location: _Path, + location: Union[str, bytes, os.PathLike], *, loader: Optional[importlib.abc.Loader] = ..., submodule_search_locations: Optional[List[str]] = ..., diff --git a/stdlib/3/inspect.pyi b/stdlib/3/inspect.pyi index 861902948..7eeac785b 100644 --- a/stdlib/3/inspect.pyi +++ b/stdlib/3/inspect.pyi @@ -44,18 +44,9 @@ CO_GENERATOR: int CO_NOFREE: int CO_COROUTINE: int CO_ITERABLE_COROUTINE: int -if sys.version_info >= (3, 6): - CO_ASYNC_GENERATOR: int +CO_ASYNC_GENERATOR: int TPFLAGS_IS_ABSTRACT: int -if sys.version_info < (3, 6): - class ModuleInfo(NamedTuple): - name: str - suffix: str - mode: str - module_type: int - def getmoduleinfo(path: str) -> Optional[ModuleInfo]: ... - def getmembers(object: object, predicate: Optional[Callable[[Any], bool]] = ...) -> List[Tuple[str, Any]]: ... def getmodulename(path: str) -> Optional[str]: ... def ismodule(object: object) -> bool: ... @@ -75,13 +66,13 @@ def isgenerator(object: object) -> bool: ... def iscoroutine(object: object) -> bool: ... def isawaitable(object: object) -> bool: ... -if sys.version_info >= (3, 6): - if sys.version_info >= (3, 8): - def isasyncgenfunction(obj: object) -> bool: ... - else: - def isasyncgenfunction(object: object) -> bool: ... - def isasyncgen(object: object) -> bool: ... +if sys.version_info >= (3, 8): + def isasyncgenfunction(obj: object) -> bool: ... +else: + def isasyncgenfunction(object: object) -> bool: ... + +def isasyncgen(object: object) -> bool: ... def istraceback(object: object) -> bool: ... def isframe(object: object) -> bool: ... def iscode(object: object) -> bool: ... diff --git a/stdlib/3/json/__init__.pyi b/stdlib/3/json/__init__.pyi index 9abde5ddf..69c82a9c6 100644 --- a/stdlib/3/json/__init__.pyi +++ b/stdlib/3/json/__init__.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import SupportsRead from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type, Union @@ -34,14 +33,8 @@ def dump( sort_keys: bool = ..., **kwds: Any, ) -> None: ... - -if sys.version_info >= (3, 6): - _LoadsString = Union[str, bytes] -else: - _LoadsString = str - def loads( - s: _LoadsString, + s: Union[str, bytes], *, cls: Optional[Type[JSONDecoder]] = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., @@ -52,7 +45,7 @@ def loads( **kwds: Any, ) -> Any: ... def load( - fp: SupportsRead[_LoadsString], + fp: SupportsRead[Union[str, bytes]], *, cls: Optional[Type[JSONDecoder]] = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., diff --git a/stdlib/3/json/decoder.pyi b/stdlib/3/json/decoder.pyi index 6551d42b7..19d7b4eb2 100644 --- a/stdlib/3/json/decoder.pyi +++ b/stdlib/3/json/decoder.pyi @@ -1,4 +1,3 @@ -import sys from typing import Any, Callable, Dict, List, Optional, Tuple class JSONDecodeError(ValueError): @@ -16,27 +15,15 @@ class JSONDecoder: parse_constant: Callable[[str], Any] = ... strict: bool object_pairs_hook: Callable[[List[Tuple[str, Any]]], Any] - - if sys.version_info >= (3, 6): - def __init__( - self, - *, - object_hook: Optional[Callable[[Dict[str, Any]], Any]] = ..., - parse_float: Optional[Callable[[str], Any]] = ..., - parse_int: Optional[Callable[[str], Any]] = ..., - parse_constant: Optional[Callable[[str], Any]] = ..., - strict: bool = ..., - object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ..., - ) -> None: ... - else: - def __init__( - self, - object_hook: Optional[Callable[[Dict[str, Any]], Any]] = ..., - parse_float: Optional[Callable[[str], Any]] = ..., - parse_int: Optional[Callable[[str], Any]] = ..., - parse_constant: Optional[Callable[[str], Any]] = ..., - strict: bool = ..., - object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ..., - ) -> None: ... + def __init__( + self, + *, + object_hook: Optional[Callable[[Dict[str, Any]], Any]] = ..., + parse_float: Optional[Callable[[str], Any]] = ..., + parse_int: Optional[Callable[[str], Any]] = ..., + parse_constant: Optional[Callable[[str], Any]] = ..., + strict: bool = ..., + object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ..., + ) -> None: ... def decode(self, s: str, _w: Callable[..., Any] = ...) -> Any: ... # _w is undocumented def raw_decode(self, s: str, idx: int = ...) -> Tuple[Any, int]: ... diff --git a/stdlib/3/json/encoder.pyi b/stdlib/3/json/encoder.pyi index b865dd144..7d520149b 100644 --- a/stdlib/3/json/encoder.pyi +++ b/stdlib/3/json/encoder.pyi @@ -1,4 +1,3 @@ -import sys from typing import Any, Callable, Iterator, Optional, Tuple class JSONEncoder: @@ -11,32 +10,18 @@ class JSONEncoder: allow_nan: bool sort_keys: bool indent: int - - if sys.version_info >= (3, 6): - def __init__( - self, - *, - skipkeys: bool = ..., - ensure_ascii: bool = ..., - check_circular: bool = ..., - allow_nan: bool = ..., - sort_keys: bool = ..., - indent: Optional[int] = ..., - separators: Optional[Tuple[str, str]] = ..., - default: Optional[Callable[..., Any]] = ..., - ) -> None: ... - else: - def __init__( - self, - skipkeys: bool = ..., - ensure_ascii: bool = ..., - check_circular: bool = ..., - allow_nan: bool = ..., - sort_keys: bool = ..., - indent: Optional[int] = ..., - separators: Optional[Tuple[str, str]] = ..., - default: Optional[Callable[..., Any]] = ..., - ) -> None: ... + def __init__( + self, + *, + skipkeys: bool = ..., + ensure_ascii: bool = ..., + check_circular: bool = ..., + allow_nan: bool = ..., + sort_keys: bool = ..., + indent: Optional[int] = ..., + separators: Optional[Tuple[str, str]] = ..., + default: Optional[Callable[..., Any]] = ..., + ) -> None: ... def default(self, o: Any) -> Any: ... def encode(self, o: Any) -> str: ... def iterencode(self, o: Any, _one_shot: bool = ...) -> Iterator[str]: ... diff --git a/stdlib/3/multiprocessing/managers.pyi b/stdlib/3/multiprocessing/managers.pyi index 8bacf9ab3..92d467311 100644 --- a/stdlib/3/multiprocessing/managers.pyi +++ b/stdlib/3/multiprocessing/managers.pyi @@ -1,5 +1,3 @@ -# Stubs for multiprocessing.managers - # NOTE: These are incomplete! import queue @@ -62,27 +60,16 @@ class Token(object): class BaseProxy(object): _address_to_local: Dict[Any, Any] _mutex: Any - if sys.version_info >= (3, 6): - def __init__( - self, - token: Any, - serializer: str, - manager: Any = ..., - authkey: Optional[AnyStr] = ..., - exposed: Any = ..., - incref: bool = ..., - manager_owned: bool = ..., - ) -> None: ... - else: - def __init__( - self, - token: Any, - serializer: str, - manager: Any = ..., - authkey: Optional[AnyStr] = ..., - exposed: Any = ..., - incref: bool = ..., - ) -> None: ... + def __init__( + self, + token: Any, + serializer: str, + manager: Any = ..., + authkey: Optional[AnyStr] = ..., + exposed: Any = ..., + incref: bool = ..., + manager_owned: bool = ..., + ) -> None: ... def __deepcopy__(self, memo: Optional[Any]) -> Any: ... def _callmethod(self, methodname: str, args: Tuple[Any, ...] = ..., kwds: Dict[Any, Any] = ...) -> None: ... def _getvalue(self) -> Any: ... diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index 85d2e8aa8..a311b174c 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -8,7 +8,7 @@ from _typeshed import ( OpenBinaryModeWriting, OpenTextMode, ) -from builtins import OSError +from builtins import OSError, _PathLike from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper as _TextIOWrapper from posix import listdir as listdir, times_result from typing import ( @@ -249,7 +249,7 @@ class stat_result: st_ctime_ns: int # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) in nanoseconds if sys.version_info >= (3, 8) and sys.platform == "win32": st_reparse_tag: int - if sys.version_info >= (3, 5) and sys.platform == "win32": + if sys.platform == "win32": st_file_attributes: int def __getitem__(self, i: int) -> int: ... # not documented @@ -271,41 +271,24 @@ class stat_result: st_creator: int st_type: int -if sys.version_info >= (3, 6): - from builtins import _PathLike - - PathLike = _PathLike # See comment in builtins +PathLike = _PathLike # See comment in builtins _FdOrAnyPath = Union[int, AnyPath] -if sys.version_info >= (3, 6): - class DirEntry(Generic[AnyStr]): - # This is what the scandir interator yields - # The constructor is hidden +class DirEntry(Generic[AnyStr]): + # This is what the scandir interator yields + # The constructor is hidden - name: AnyStr - path: AnyStr - def inode(self) -> int: ... - def is_dir(self, *, follow_symlinks: bool = ...) -> bool: ... - def is_file(self, *, follow_symlinks: bool = ...) -> bool: ... - def is_symlink(self) -> bool: ... - def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ... - def __fspath__(self) -> AnyStr: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - -else: - class DirEntry(Generic[AnyStr]): - # This is what the scandir interator yields - # The constructor is hidden - - name: AnyStr - path: AnyStr - def inode(self) -> int: ... - def is_dir(self, *, follow_symlinks: bool = ...) -> bool: ... - def is_file(self, *, follow_symlinks: bool = ...) -> bool: ... - def is_symlink(self) -> bool: ... - def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ... + name: AnyStr + path: AnyStr + def inode(self) -> int: ... + def is_dir(self, *, follow_symlinks: bool = ...) -> bool: ... + def is_file(self, *, follow_symlinks: bool = ...) -> bool: ... + def is_symlink(self) -> bool: ... + def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ... + def __fspath__(self) -> AnyStr: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... if sys.platform != "win32": _Tuple10Int = Tuple[int, int, int, int, int, int, int, int, int, int] @@ -347,26 +330,14 @@ if sys.platform != "win32": f_namemax: int # ----- os function stubs ----- -if sys.version_info >= (3, 6): - def fsencode(filename: Union[str, bytes, PathLike[Any]]) -> bytes: ... - -else: - def fsencode(filename: Union[str, bytes]) -> bytes: ... - -if sys.version_info >= (3, 6): - def fsdecode(filename: Union[str, bytes, PathLike[Any]]) -> str: ... - -else: - def fsdecode(filename: Union[str, bytes]) -> str: ... - -if sys.version_info >= (3, 6): - @overload - def fspath(path: str) -> str: ... - @overload - def fspath(path: bytes) -> bytes: ... - @overload - def fspath(path: PathLike[AnyStr]) -> AnyStr: ... - +def fsencode(filename: Union[str, bytes, PathLike[Any]]) -> bytes: ... +def fsdecode(filename: Union[str, bytes, PathLike[Any]]) -> str: ... +@overload +def fspath(path: str) -> str: ... +@overload +def fspath(path: bytes) -> bytes: ... +@overload +def fspath(path: PathLike[AnyStr]) -> AnyStr: ... def get_exec_path(env: Optional[Mapping[str, str]] = ...) -> List[str]: ... # NOTE: get_exec_path(): returns List[bytes] when env not None @@ -615,12 +586,7 @@ if sys.platform != "win32": def makedev(__major: int, __minor: int) -> int: ... def pathconf(path: _FdOrAnyPath, 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: ... - -else: - def readlink(path: AnyStr, *, dir_fd: Optional[int] = ...) -> AnyStr: ... - +def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ... def remove(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ... def removedirs(name: AnyPath) -> None: ... def rename(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... @@ -628,10 +594,11 @@ def renames(old: AnyPath, new: AnyPath) -> None: ... def replace(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... def rmdir(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ... +class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): + def __next__(self) -> DirEntry[AnyStr]: ... + def close(self) -> None: ... + if sys.version_info >= (3, 7): - class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): - def __next__(self) -> DirEntry[AnyStr]: ... - def close(self) -> None: ... @overload def scandir(path: None = ...) -> _ScandirIterator[str]: ... @overload @@ -639,21 +606,12 @@ if sys.version_info >= (3, 7): @overload def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ... -elif sys.version_info >= (3, 6): - class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): - def __next__(self) -> DirEntry[AnyStr]: ... - def close(self) -> None: ... +else: @overload def scandir(path: None = ...) -> _ScandirIterator[str]: ... @overload def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ... -else: - @overload - def scandir(path: None = ...) -> Iterator[DirEntry[str]]: ... - @overload - def scandir(path: AnyStr) -> Iterator[DirEntry[AnyStr]]: ... - def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ... if sys.version_info < (3, 7): @@ -683,15 +641,9 @@ def utime( _OnError = Callable[[OSError], Any] -if sys.version_info >= (3, 6): - def walk( - top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., onerror: Optional[_OnError] = ..., followlinks: bool = ... - ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... - -else: - def walk( - top: AnyStr, topdown: bool = ..., onerror: Optional[_OnError] = ..., followlinks: bool = ... - ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... +def walk( + top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., onerror: Optional[_OnError] = ..., followlinks: bool = ... +) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... if sys.platform != "win32": if sys.version_info >= (3, 7): @@ -713,18 +665,9 @@ if sys.platform != "win32": follow_symlinks: bool = ..., dir_fd: Optional[int] = ..., ) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ... - elif sys.version_info >= (3, 6): - def fwalk( - top: Union[str, PathLike[str]] = ..., - topdown: bool = ..., - onerror: Optional[_OnError] = ..., - *, - follow_symlinks: bool = ..., - dir_fd: Optional[int] = ..., - ) -> Iterator[Tuple[str, List[str], List[str], int]]: ... else: def fwalk( - top: str = ..., + top: Union[str, PathLike[str]] = ..., topdown: bool = ..., onerror: Optional[_OnError] = ..., *, @@ -751,23 +694,19 @@ def execlpe(file: AnyPath, __arg0: AnyPath, *args: Any) -> NoReturn: ... # The docs say `args: tuple or list of strings` # The implementation enforces tuple or list so we can't use Sequence. -if sys.version_info >= (3, 6): - # Not separating out PathLike[str] and PathLike[bytes] here because it doesn't make much difference - # in practice, and doing so would explode the number of combinations in this already long union. - # All these combinations are necessary due to List being invariant. - _ExecVArgs = Union[ - Tuple[AnyPath, ...], - List[bytes], - List[str], - List[PathLike[Any]], - List[Union[bytes, str]], - List[Union[bytes, PathLike[Any]]], - List[Union[str, PathLike[Any]]], - List[Union[bytes, str, PathLike[Any]]], - ] -else: - _ExecVArgs = Union[Tuple[AnyPath, ...], List[bytes], List[str], List[Union[bytes, str]]] - +# Not separating out PathLike[str] and PathLike[bytes] here because it doesn't make much difference +# in practice, and doing so would explode the number of combinations in this already long union. +# All these combinations are necessary due to List being invariant. +_ExecVArgs = Union[ + Tuple[AnyPath, ...], + List[bytes], + List[str], + List[PathLike[Any]], + List[Union[bytes, str]], + List[Union[bytes, PathLike[Any]]], + List[Union[str, PathLike[Any]]], + List[Union[bytes, str, PathLike[Any]]], +] _ExecEnv = Union[Mapping[bytes, Union[bytes, str]], Mapping[str, Union[bytes, str]]] def execv(__path: AnyPath, __argv: _ExecVArgs) -> NoReturn: ... @@ -849,9 +788,8 @@ if sys.platform != "win32": def getloadavg() -> Tuple[float, float, float]: ... def sysconf(__name: Union[str, int]) -> int: ... -if sys.version_info >= (3, 6): - if sys.platform == "linux": - def getrandom(size: int, flags: int = ...) -> bytes: ... +if sys.platform == "linux": + def getrandom(size: int, flags: int = ...) -> bytes: ... def urandom(__size: int) -> bytes: ... diff --git a/stdlib/3/pathlib.pyi b/stdlib/3/pathlib.pyi index 47aab851a..7145f4152 100644 --- a/stdlib/3/pathlib.pyi +++ b/stdlib/3/pathlib.pyi @@ -153,10 +153,7 @@ class Path(PurePath): else: def rename(self, target: Union[str, PurePath]) -> None: ... def replace(self, target: Union[str, PurePath]) -> None: ... - if sys.version_info < (3, 6): - def resolve(self: _P) -> _P: ... - else: - def resolve(self: _P, strict: bool = ...) -> _P: ... + def resolve(self: _P, strict: bool = ...) -> _P: ... def rglob(self, pattern: str) -> Generator[Path, None, None]: ... def rmdir(self) -> None: ... def symlink_to(self, target: Union[str, Path], target_is_directory: bool = ...) -> None: ... diff --git a/stdlib/3/posix.pyi b/stdlib/3/posix.pyi index e57fb0c52..9080d5b90 100644 --- a/stdlib/3/posix.pyi +++ b/stdlib/3/posix.pyi @@ -1,10 +1,8 @@ import sys +from builtins import _PathLike # See comment in builtins from os import stat_result as stat_result from typing import Dict, List, NamedTuple, Optional, overload -if sys.version_info >= (3, 6): - from builtins import _PathLike # See comment in builtins - class uname_result(NamedTuple): sysname: str nodename: str @@ -62,9 +60,8 @@ F_TEST: int F_TLOCK: int F_ULOCK: int -if sys.version_info >= (3, 6): - GRND_NONBLOCK: int - GRND_RANDOM: int +GRND_NONBLOCK: int +GRND_RANDOM: int NGROUPS_MAX: int O_APPEND: int @@ -153,24 +150,14 @@ WUNTRACED: int XATTR_CREATE: int XATTR_REPLACE: int XATTR_SIZE_MAX: int - -if sys.version_info >= (3, 6): - @overload - def listdir(path: Optional[str] = ...) -> List[str]: ... - @overload - def listdir(path: bytes) -> List[bytes]: ... - @overload - def listdir(path: int) -> List[str]: ... - @overload - def listdir(path: _PathLike[str]) -> List[str]: ... - -else: - @overload - def listdir(path: Optional[str] = ...) -> List[str]: ... - @overload - def listdir(path: bytes) -> List[bytes]: ... - @overload - def listdir(path: int) -> List[str]: ... +@overload +def listdir(path: Optional[str] = ...) -> List[str]: ... +@overload +def listdir(path: bytes) -> List[bytes]: ... +@overload +def listdir(path: int) -> List[str]: ... +@overload +def listdir(path: _PathLike[str]) -> List[str]: ... if sys.platform == "win32": environ: Dict[str, str] diff --git a/stdlib/3/random.pyi b/stdlib/3/random.pyi index a0c36984d..9a28024c2 100644 --- a/stdlib/3/random.pyi +++ b/stdlib/3/random.pyi @@ -15,15 +15,14 @@ class Random(_random.Random): if sys.version_info >= (3, 9): def randbytes(self, n: int) -> bytes: ... def choice(self, seq: Sequence[_T]) -> _T: ... - if sys.version_info >= (3, 6): - def choices( - self, - population: Sequence[_T], - weights: Optional[Sequence[float]] = ..., - *, - cum_weights: Optional[Sequence[float]] = ..., - k: int = ..., - ) -> List[_T]: ... + def choices( + self, + population: Sequence[_T], + weights: Optional[Sequence[float]] = ..., + *, + cum_weights: Optional[Sequence[float]] = ..., + k: int = ..., + ) -> List[_T]: ... def shuffle(self, x: MutableSequence[Any], random: Optional[Callable[[], float]] = ...) -> None: ... if sys.version_info >= (3, 9): def sample( @@ -59,16 +58,13 @@ if sys.version_info >= (3, 9): def randbytes(n: int) -> bytes: ... def choice(seq: Sequence[_T]) -> _T: ... - -if sys.version_info >= (3, 6): - def choices( - population: Sequence[_T], - weights: Optional[Sequence[float]] = ..., - *, - cum_weights: Optional[Sequence[float]] = ..., - k: int = ..., - ) -> List[_T]: ... - +def choices( + population: Sequence[_T], + weights: Optional[Sequence[float]] = ..., + *, + cum_weights: Optional[Sequence[float]] = ..., + k: int = ..., +) -> List[_T]: ... def shuffle(x: MutableSequence[Any], random: Optional[Callable[[], float]] = ...) -> None: ... if sys.version_info >= (3, 9): diff --git a/stdlib/3/re.pyi b/stdlib/3/re.pyi index a0b815d90..264174440 100644 --- a/stdlib/3/re.pyi +++ b/stdlib/3/re.pyi @@ -1,3 +1,4 @@ +import enum import sys from typing import Any, AnyStr, Callable, Iterator, List, Optional, Tuple, Union, overload @@ -7,45 +8,7 @@ if sys.version_info >= (3, 7): else: from typing import Match, Pattern -if sys.version_info >= (3, 6): - import enum - class RegexFlag(enum.IntFlag): - A: int - ASCII: int - DEBUG: int - I: int - IGNORECASE: int - L: int - LOCALE: int - M: int - MULTILINE: int - S: int - DOTALL: int - X: int - VERBOSE: int - U: int - UNICODE: int - T: int - TEMPLATE: int - A = RegexFlag.A - ASCII = RegexFlag.ASCII - DEBUG = RegexFlag.DEBUG - I = RegexFlag.I - IGNORECASE = RegexFlag.IGNORECASE - L = RegexFlag.L - LOCALE = RegexFlag.LOCALE - M = RegexFlag.M - MULTILINE = RegexFlag.MULTILINE - S = RegexFlag.S - DOTALL = RegexFlag.DOTALL - X = RegexFlag.X - VERBOSE = RegexFlag.VERBOSE - U = RegexFlag.U - UNICODE = RegexFlag.UNICODE - T = RegexFlag.T - TEMPLATE = RegexFlag.TEMPLATE - _FlagsType = Union[int, RegexFlag] -else: +class RegexFlag(enum.IntFlag): A: int ASCII: int DEBUG: int @@ -63,7 +26,25 @@ else: UNICODE: int T: int TEMPLATE: int - _FlagsType = int + +A = RegexFlag.A +ASCII = RegexFlag.ASCII +DEBUG = RegexFlag.DEBUG +I = RegexFlag.I +IGNORECASE = RegexFlag.IGNORECASE +L = RegexFlag.L +LOCALE = RegexFlag.LOCALE +M = RegexFlag.M +MULTILINE = RegexFlag.MULTILINE +S = RegexFlag.S +DOTALL = RegexFlag.DOTALL +X = RegexFlag.X +VERBOSE = RegexFlag.VERBOSE +U = RegexFlag.U +UNICODE = RegexFlag.UNICODE +T = RegexFlag.T +TEMPLATE = RegexFlag.TEMPLATE +_FlagsType = Union[int, RegexFlag] if sys.version_info < (3, 7): # undocumented diff --git a/stdlib/3.6/secrets.pyi b/stdlib/3/secrets.pyi similarity index 100% rename from stdlib/3.6/secrets.pyi rename to stdlib/3/secrets.pyi diff --git a/stdlib/3/shlex.pyi b/stdlib/3/shlex.pyi index bcf7ed0c2..0eb89d33c 100644 --- a/stdlib/3/shlex.pyi +++ b/stdlib/3/shlex.pyi @@ -25,19 +25,14 @@ class shlex(Iterable[str]): lineno: int token: str eof: str - if sys.version_info >= (3, 6): - punctuation_chars: str - - if sys.version_info >= (3, 6): - def __init__( - self, - instream: Union[str, TextIO] = ..., - infile: Optional[str] = ..., - posix: bool = ..., - punctuation_chars: Union[bool, str] = ..., - ) -> None: ... - else: - def __init__(self, instream: Union[str, TextIO] = ..., infile: Optional[str] = ..., posix: bool = ...) -> None: ... + punctuation_chars: str + def __init__( + self, + instream: Union[str, TextIO] = ..., + infile: Optional[str] = ..., + posix: bool = ..., + punctuation_chars: Union[bool, str] = ..., + ) -> None: ... def get_token(self) -> str: ... def push_token(self, tok: str) -> None: ... def read_token(self) -> str: ... diff --git a/stdlib/3/sre_parse.pyi b/stdlib/3/sre_parse.pyi index f200fe9c9..4c7b6157d 100644 --- a/stdlib/3/sre_parse.pyi +++ b/stdlib/3/sre_parse.pyi @@ -12,9 +12,9 @@ WHITESPACE: FrozenSet[str] ESCAPES: Dict[str, Tuple[_NIC, int]] CATEGORIES: Dict[str, Union[Tuple[_NIC, _NIC], Tuple[_NIC, List[Tuple[_NIC, _NIC]]]]] FLAGS: Dict[str, int] -if sys.version_info >= (3, 6): - GLOBAL_FLAGS: int - class Verbose(Exception): ... +GLOBAL_FLAGS: int + +class Verbose(Exception): ... class _State: flags: int @@ -74,9 +74,8 @@ class Tokenizer: def getuntil(self, terminator: str, name: str) -> str: ... else: def getuntil(self, terminator: str) -> str: ... - if sys.version_info >= (3, 6): - @property - def pos(self) -> int: ... + @property + def pos(self) -> int: ... def tell(self) -> int: ... def seek(self, index: int) -> None: ... def error(self, msg: str, offset: int = ...) -> _Error: ... diff --git a/stdlib/3/statistics.pyi b/stdlib/3/statistics.pyi index f963802eb..9786a0484 100644 --- a/stdlib/3/statistics.pyi +++ b/stdlib/3/statistics.pyi @@ -18,10 +18,7 @@ if sys.version_info >= (3, 8): def geometric_mean(data: Iterable[SupportsFloat]) -> float: ... def mean(data: Iterable[_Number]) -> _Number: ... - -if sys.version_info >= (3, 6): - def harmonic_mean(data: Iterable[_Number]) -> _Number: ... - +def harmonic_mean(data: Iterable[_Number]) -> _Number: ... def median(data: Iterable[_Number]) -> _Number: ... def median_low(data: Iterable[SupportsLessThanT]) -> SupportsLessThanT: ... def median_high(data: Iterable[SupportsLessThanT]) -> SupportsLessThanT: ... diff --git a/stdlib/3/subprocess.pyi b/stdlib/3/subprocess.pyi index 159a8e18b..0bc65cff8 100644 --- a/stdlib/3/subprocess.pyi +++ b/stdlib/3/subprocess.pyi @@ -216,7 +216,7 @@ if sys.version_info >= (3, 7): timeout: Optional[float] = ..., ) -> CompletedProcess[Any]: ... -elif sys.version_info >= (3, 6): +else: # Nearly same args as Popen.__init__ except for timeout, input, and check @overload def run( @@ -350,82 +350,6 @@ elif sys.version_info >= (3, 6): 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: AnyPath = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - 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: AnyPath = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - 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: AnyPath = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - 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, @@ -625,8 +549,7 @@ if sys.version_info >= (3, 7): text: Optional[bool] = ..., ) -> Any: ... # morally: -> _TXT -elif sys.version_info >= (3, 6): - # 3.6 added encoding and errors +else: @overload def check_output( args: _CMD, @@ -748,74 +671,6 @@ elif sys.version_info >= (3, 6): errors: Optional[str] = ..., ) -> Any: ... # morally: -> _TXT -else: - @overload - def check_output( - args: _CMD, - bufsize: int = ..., - executable: AnyPath = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - env: Optional[_ENV] = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - input: _TXT = ..., - *, - timeout: Optional[float] = ..., - universal_newlines: Literal[True], - ) -> str: ... - @overload - def check_output( - args: _CMD, - bufsize: int = ..., - executable: AnyPath = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - env: Optional[_ENV] = ..., - universal_newlines: Literal[False] = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - input: _TXT = ..., - *, - timeout: Optional[float] = ..., - ) -> bytes: ... - @overload - def check_output( - args: _CMD, - bufsize: int = ..., - executable: AnyPath = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - input: _TXT = ..., - *, - timeout: Optional[float] = ..., - ) -> Any: ... # morally: -> _TXT - PIPE: int STDOUT: int DEVNULL: int @@ -1009,7 +864,7 @@ class Popen(Generic[AnyStr]): encoding: Optional[str] = ..., errors: Optional[str] = ..., ) -> Popen[Any]: ... - elif sys.version_info >= (3, 6): + else: @overload def __new__( cls, @@ -1131,72 +986,6 @@ class Popen(Generic[AnyStr]): encoding: Optional[str] = ..., errors: Optional[str] = ..., ) -> Popen[Any]: ... - else: - @overload - def __new__( - cls, - args: _CMD, - bufsize: int = ..., - executable: Optional[AnyPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - env: Optional[_ENV] = ..., - *, - universal_newlines: Literal[True], - startupinfo: Optional[Any] = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - ) -> Popen[str]: ... - @overload - def __new__( - cls, - args: _CMD, - bufsize: int = ..., - executable: Optional[AnyPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - env: Optional[_ENV] = ..., - *, - universal_newlines: Literal[False] = ..., - startupinfo: Optional[Any] = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - ) -> Popen[bytes]: ... - @overload - def __new__( - cls, - args: _CMD, - bufsize: int = ..., - executable: Optional[AnyPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[AnyPath] = ..., - env: Optional[_ENV] = ..., - universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - ) -> Popen[Any]: ... def poll(self) -> Optional[int]: ... if sys.version_info >= (3, 7): def wait(self, timeout: Optional[float] = ...) -> int: ... diff --git a/stdlib/3/symbol.pyi b/stdlib/3/symbol.pyi index 8f764f294..6fbe306fa 100644 --- a/stdlib/3/symbol.pyi +++ b/stdlib/3/symbol.pyi @@ -1,4 +1,3 @@ -import sys from typing import Dict single_input: int @@ -18,8 +17,7 @@ stmt: int simple_stmt: int small_stmt: int expr_stmt: int -if sys.version_info >= (3, 6): - annassign: int +annassign: int testlist_star_expr: int augassign: int del_stmt: int diff --git a/stdlib/3/sys.pyi b/stdlib/3/sys.pyi index 7c0e15ddc..d7c9176d6 100644 --- a/stdlib/3/sys.pyi +++ b/stdlib/3/sys.pyi @@ -2,7 +2,22 @@ import sys from builtins import object as _object from importlib.abc import MetaPathFinder, PathEntryFinder from types import FrameType, ModuleType, TracebackType -from typing import Any, Callable, Dict, List, NoReturn, Optional, Sequence, TextIO, Tuple, Type, TypeVar, Union, overload +from typing import ( + Any, + AsyncGenerator, + Callable, + Dict, + List, + NoReturn, + Optional, + Sequence, + TextIO, + Tuple, + Type, + TypeVar, + Union, + overload, +) _T = TypeVar("_T") @@ -209,12 +224,11 @@ if sys.version_info >= (3, 8): def addaudithook(hook: Callable[[str, Tuple[Any, ...]], Any]) -> None: ... def audit(__event: str, *args: Any) -> None: ... -if sys.version_info >= (3, 6): - from typing import AsyncGenerator +_AsyncgenHook = Optional[Callable[[AsyncGenerator[Any, Any]], None]] - _AsyncgenHook = Optional[Callable[[AsyncGenerator[Any, Any]], None]] - class _asyncgen_hooks(Tuple[_AsyncgenHook, _AsyncgenHook]): - firstiter: _AsyncgenHook - finalizer: _AsyncgenHook - def get_asyncgen_hooks() -> _asyncgen_hooks: ... - def set_asyncgen_hooks(firstiter: _AsyncgenHook = ..., finalizer: _AsyncgenHook = ...) -> None: ... +class _asyncgen_hooks(Tuple[_AsyncgenHook, _AsyncgenHook]): + firstiter: _AsyncgenHook + finalizer: _AsyncgenHook + +def get_asyncgen_hooks() -> _asyncgen_hooks: ... +def set_asyncgen_hooks(firstiter: _AsyncgenHook = ..., finalizer: _AsyncgenHook = ...) -> None: ... diff --git a/stdlib/3/tempfile.pyi b/stdlib/3/tempfile.pyi index acfe24a4c..7b87fd46e 100644 --- a/stdlib/3/tempfile.pyi +++ b/stdlib/3/tempfile.pyi @@ -14,10 +14,7 @@ template: str _S = TypeVar("_S") _T = TypeVar("_T") # for pytype, define typevar in same file as alias -if sys.version_info >= (3, 6): - _DirT = Union[_T, os.PathLike[_T]] -else: - _DirT = Union[_T] +_DirT = Union[_T, os.PathLike[_T]] if sys.version_info >= (3, 8): @overload diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index 9ead49895..a4b96ec97 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -108,45 +108,44 @@ _ScreenUnits = Union[str, float] # manual page: Tk_GetPixels _XYScrollCommand = Union[str, Callable[[float, float], Any]] # -xscrollcommand and -yscrollcommand in 'options' manual page _TakeFocusValue = Union[bool, Literal[""], Callable[[str], Optional[bool]]] # -takefocus in manual page named 'options' -if sys.version_info >= (3, 6): - class EventType(str, Enum): - Activate: str = ... - ButtonPress: str = ... - ButtonRelease: str = ... - Circulate: str = ... - CirculateRequest: str = ... - ClientMessage: str = ... - Colormap: str = ... - Configure: str = ... - ConfigureRequest: str = ... - Create: str = ... - Deactivate: str = ... - Destroy: str = ... - Enter: str = ... - Expose: str = ... - FocusIn: str = ... - FocusOut: str = ... - GraphicsExpose: str = ... - Gravity: str = ... - KeyPress: str = ... - KeyRelease: str = ... - Keymap: str = ... - Leave: str = ... - Map: str = ... - MapRequest: str = ... - Mapping: str = ... - Motion: str = ... - MouseWheel: str = ... - NoExpose: str = ... - Property: str = ... - Reparent: str = ... - ResizeRequest: str = ... - Selection: str = ... - SelectionClear: str = ... - SelectionRequest: str = ... - Unmap: str = ... - VirtualEvent: str = ... - Visibility: str = ... +class EventType(str, Enum): + Activate: str = ... + ButtonPress: str = ... + ButtonRelease: str = ... + Circulate: str = ... + CirculateRequest: str = ... + ClientMessage: str = ... + Colormap: str = ... + Configure: str = ... + ConfigureRequest: str = ... + Create: str = ... + Deactivate: str = ... + Destroy: str = ... + Enter: str = ... + Expose: str = ... + FocusIn: str = ... + FocusOut: str = ... + GraphicsExpose: str = ... + Gravity: str = ... + KeyPress: str = ... + KeyRelease: str = ... + Keymap: str = ... + Leave: str = ... + Map: str = ... + MapRequest: str = ... + Mapping: str = ... + Motion: str = ... + MouseWheel: str = ... + NoExpose: str = ... + Property: str = ... + Reparent: str = ... + ResizeRequest: str = ... + Selection: str = ... + SelectionClear: str = ... + SelectionRequest: str = ... + Unmap: str = ... + VirtualEvent: str = ... + Visibility: str = ... # Events considered covariant because you should never assign to event.widget. _W = TypeVar("_W", covariant=True, bound="Misc") @@ -168,10 +167,7 @@ class Event(Generic[_W]): send_event: bool keysym: str keysym_num: int - if sys.version_info >= (3, 6): - type: EventType - else: - type: str + type: EventType widget: _W delta: int @@ -184,10 +180,9 @@ class Variable: def set(self, value: Any) -> None: ... initialize = set def get(self) -> Any: ... - if sys.version_info >= (3, 6): - def trace_add(self, mode: _TraceMode, callback: Callable[[str, str, str], Any]) -> str: ... - def trace_remove(self, mode: _TraceMode, cbname: str) -> None: ... - def trace_info(self) -> List[Tuple[Tuple[_TraceMode, ...], str]]: ... + def trace_add(self, mode: _TraceMode, callback: Callable[[str, str, str], Any]) -> str: ... + def trace_remove(self, mode: _TraceMode, cbname: str) -> None: ... + def trace_info(self) -> List[Tuple[Tuple[_TraceMode, ...], str]]: ... def trace_variable(self, mode, callback): ... # deprecated def trace_vdelete(self, mode, cbname): ... # deprecated def trace_vinfo(self): ... # deprecated @@ -232,8 +227,6 @@ class Misc: def tk_strictMotif(self, boolean: Optional[Any] = ...): ... def tk_bisque(self): ... def tk_setPalette(self, *args, **kw): ... - if sys.version_info < (3, 6): - def tk_menuBar(self, *args): ... def wait_variable(self, name: Union[str, Variable] = ...): ... waitvar: Any def wait_window(self, window: Optional[Any] = ...): ... @@ -1878,8 +1871,6 @@ class Menu(Widget): config = configure def cget(self, key: _MenuOptionName) -> Any: ... def tk_popup(self, x, y, entry: str = ...): ... - if sys.version_info < (3, 6): - def tk_bindForTraversal(self): ... def activate(self, index): ... def add(self, itemType, cnf=..., **kw): ... def add_cascade(self, cnf=..., **kw): ... diff --git a/stdlib/3/tokenize.pyi b/stdlib/3/tokenize.pyi index e6cd8997f..23babea28 100644 --- a/stdlib/3/tokenize.pyi +++ b/stdlib/3/tokenize.pyi @@ -1,5 +1,6 @@ import sys from builtins import open as _builtin_open +from os import PathLike from token import * # noqa: F403 from typing import ( Any, @@ -61,14 +62,7 @@ def untokenize(iterable: Iterable[_Token]) -> Any: ... def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ... def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... # undocumented - -if sys.version_info >= (3, 6): - from os import PathLike - def open(filename: Union[str, bytes, int, PathLike[Any]]) -> TextIO: ... - -elif sys.version_info >= (3, 2): - def open(filename: Union[str, bytes, int]) -> TextIO: ... - +def open(filename: Union[str, bytes, int, PathLike[Any]]) -> TextIO: ... def group(*choices: str) -> str: ... # undocumented def any(*choices: str) -> str: ... # undocumented def maybe(*choices: str) -> str: ... # undocumented @@ -116,11 +110,7 @@ PseudoExtras: str # undocumented PseudoToken: str # undocumented endpats: Dict[str, str] # undocumented -if sys.version_info < (3, 6): - single_quoted: Dict[str, str] # undocumented - triple_quoted: Dict[str, str] # undocumented -else: - single_quoted: Set[str] # undocumented - triple_quoted: Set[str] # undocumented +single_quoted: Set[str] # undocumented +triple_quoted: Set[str] # undocumented tabsize: int # undocumented diff --git a/stdlib/3/tracemalloc.pyi b/stdlib/3/tracemalloc.pyi index 95c81d0e3..593c4edae 100644 --- a/stdlib/3/tracemalloc.pyi +++ b/stdlib/3/tracemalloc.pyi @@ -6,32 +6,25 @@ from _tracemalloc import * def get_object_traceback(obj: object) -> Optional[Traceback]: ... def take_snapshot() -> Snapshot: ... -if sys.version_info >= (3, 6): - class DomainFilter: - inclusive: bool - domain: int - def __init__(self, inclusive: bool, domain: int) -> None: ... +class DomainFilter: + inclusive: bool + domain: int + def __init__(self, inclusive: bool, domain: int) -> None: ... class Filter: - if sys.version_info >= (3, 6): - domain: Optional[int] + domain: Optional[int] inclusive: bool lineno: Optional[int] filename_pattern: str all_frames: bool - if sys.version_info >= (3, 6): - def __init__( - self, - inclusive: bool, - filename_pattern: str, - lineno: Optional[int] = ..., - all_frames: bool = ..., - domain: Optional[int] = ..., - ) -> None: ... - else: - def __init__( - self, inclusive: bool, filename_pattern: str, lineno: Optional[int] = ..., all_frames: bool = ... - ) -> None: ... + def __init__( + self, + inclusive: bool, + filename_pattern: str, + lineno: Optional[int] = ..., + all_frames: bool = ..., + domain: Optional[int] = ..., + ) -> None: ... class Statistic: count: int @@ -85,10 +78,7 @@ class Snapshot: def __init__(self, traces: Sequence[_TraceTupleT], traceback_limit: int) -> None: ... def compare_to(self, old_snapshot: Snapshot, key_type: str, cumulative: bool = ...) -> List[StatisticDiff]: ... def dump(self, filename: str) -> None: ... - if sys.version_info >= (3, 6): - def filter_traces(self, filters: Sequence[Union[DomainFilter, Filter]]) -> Snapshot: ... - else: - def filter_traces(self, filters: Sequence[Filter]) -> Snapshot: ... + def filter_traces(self, filters: Sequence[Union[DomainFilter, Filter]]) -> Snapshot: ... @staticmethod def load(filename: str) -> Snapshot: ... def statistics(self, key_type: str, cumulative: bool = ...) -> List[Statistic]: ... diff --git a/stdlib/3/types.pyi b/stdlib/3/types.pyi index 7bf4ee47b..764dc5bd1 100644 --- a/stdlib/3/types.pyi +++ b/stdlib/3/types.pyi @@ -164,22 +164,21 @@ class GeneratorType: @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Any: ... -if sys.version_info >= (3, 6): - class AsyncGeneratorType(Generic[_T_co, _T_contra]): - ag_await: Optional[Awaitable[Any]] - ag_frame: FrameType - ag_running: bool - ag_code: CodeType - def __aiter__(self) -> Awaitable[AsyncGeneratorType[_T_co, _T_contra]]: ... - def __anext__(self) -> Awaitable[_T_co]: ... - def asend(self, __val: _T_contra) -> Awaitable[_T_co]: ... - @overload - def athrow( - self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... - ) -> Awaitable[_T_co]: ... - @overload - def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ... - def aclose(self) -> Awaitable[None]: ... +class AsyncGeneratorType(Generic[_T_co, _T_contra]): + ag_await: Optional[Awaitable[Any]] + ag_frame: FrameType + ag_running: bool + ag_code: CodeType + def __aiter__(self) -> Awaitable[AsyncGeneratorType[_T_co, _T_contra]]: ... + def __anext__(self) -> Awaitable[_T_co]: ... + def asend(self, __val: _T_contra) -> Awaitable[_T_co]: ... + @overload + def athrow( + self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + ) -> Awaitable[_T_co]: ... + @overload + def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ... + def aclose(self) -> Awaitable[None]: ... class CoroutineType: cr_await: Optional[Any] diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index b99ca7882..df3ab2cb4 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -252,32 +252,31 @@ class AsyncIterator(AsyncIterable[_T_co], Protocol[_T_co]): def __anext__(self) -> Awaitable[_T_co]: ... def __aiter__(self) -> AsyncIterator[_T_co]: ... -if sys.version_info >= (3, 6): - class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]): - @abstractmethod - def __anext__(self) -> Awaitable[_T_co]: ... - @abstractmethod - def asend(self, __value: _T_contra) -> Awaitable[_T_co]: ... - @overload - @abstractmethod - def athrow( - self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... - ) -> Awaitable[_T_co]: ... - @overload - @abstractmethod - def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ... - @abstractmethod - def aclose(self) -> Awaitable[None]: ... - @abstractmethod - def __aiter__(self) -> AsyncGenerator[_T_co, _T_contra]: ... - @property - def ag_await(self) -> Any: ... - @property - def ag_code(self) -> CodeType: ... - @property - def ag_frame(self) -> FrameType: ... - @property - def ag_running(self) -> bool: ... +class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]): + @abstractmethod + def __anext__(self) -> Awaitable[_T_co]: ... + @abstractmethod + def asend(self, __value: _T_contra) -> Awaitable[_T_co]: ... + @overload + @abstractmethod + def athrow( + self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + ) -> Awaitable[_T_co]: ... + @overload + @abstractmethod + def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ... + @abstractmethod + def aclose(self) -> Awaitable[None]: ... + @abstractmethod + def __aiter__(self) -> AsyncGenerator[_T_co, _T_contra]: ... + @property + def ag_await(self) -> Any: ... + @property + def ag_code(self) -> CodeType: ... + @property + def ag_frame(self) -> FrameType: ... + @property + def ag_running(self) -> bool: ... @runtime_checkable class Container(Protocol[_T_co]): @@ -286,19 +285,13 @@ class Container(Protocol[_T_co]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -if sys.version_info >= (3, 6): - @runtime_checkable - class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]): - # Implement Sized (but don't have it as a base class). - @abstractmethod - def __len__(self) -> int: ... - _Collection = Collection[_T_co] -else: - @runtime_checkable - class _Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]): - # Implement Sized (but don't have it as a base class). - @abstractmethod - def __len__(self) -> int: ... +@runtime_checkable +class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]): + # Implement Sized (but don't have it as a base class). + @abstractmethod + def __len__(self) -> int: ... + +_Collection = Collection[_T_co] class Sequence(_Collection[_T_co], Reversible[_T_co], Generic[_T_co]): @overload @@ -573,8 +566,7 @@ class Match(Generic[AnyStr]): def span(self, __group: Union[int, str] = ...) -> Tuple[int, int]: ... @property def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented - if sys.version_info >= (3, 6): - def __getitem__(self, g: Union[int, str]) -> AnyStr: ... + def __getitem__(self, g: Union[int, str]) -> AnyStr: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/3/urllib/request.pyi b/stdlib/3/urllib/request.pyi index 22932d890..0affc55f4 100644 --- a/stdlib/3/urllib/request.pyi +++ b/stdlib/3/urllib/request.pyi @@ -1,6 +1,5 @@ import os import ssl -import sys from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar @@ -250,22 +249,12 @@ class HTTPErrorProcessor(BaseHandler): def http_response(self, request: Request, response: HTTPResponse) -> _UrlopenRet: ... def https_response(self, request: Request, response: HTTPResponse) -> _UrlopenRet: ... -if sys.version_info >= (3, 6): - def urlretrieve( - url: str, - filename: Optional[Union[str, os.PathLike[Any]]] = ..., - reporthook: Optional[Callable[[int, int, int], None]] = ..., - data: Optional[bytes] = ..., - ) -> Tuple[str, HTTPMessage]: ... - -else: - def urlretrieve( - url: str, - filename: Optional[str] = ..., - reporthook: Optional[Callable[[int, int, int], None]] = ..., - data: Optional[bytes] = ..., - ) -> Tuple[str, HTTPMessage]: ... - +def urlretrieve( + url: str, + filename: Optional[Union[str, os.PathLike[Any]]] = ..., + reporthook: Optional[Callable[[int, int, int], None]] = ..., + data: Optional[bytes] = ..., +) -> Tuple[str, HTTPMessage]: ... def urlcleanup() -> None: ... class URLopener: diff --git a/stdlib/3/urllib/robotparser.pyi b/stdlib/3/urllib/robotparser.pyi index 5e99b285c..ad96ca12b 100644 --- a/stdlib/3/urllib/robotparser.pyi +++ b/stdlib/3/urllib/robotparser.pyi @@ -13,8 +13,7 @@ class RobotFileParser: def can_fetch(self, user_agent: str, url: str) -> bool: ... def mtime(self) -> int: ... def modified(self) -> None: ... - if sys.version_info >= (3, 6): - def crawl_delay(self, useragent: str) -> Optional[str]: ... - def request_rate(self, useragent: str) -> Optional[_RequestRate]: ... + def crawl_delay(self, useragent: str) -> Optional[str]: ... + def request_rate(self, useragent: str) -> Optional[_RequestRate]: ... if sys.version_info >= (3, 8): def site_maps(self) -> Optional[List[str]]: ... diff --git a/stdlib/3/xmlrpc/client.pyi b/stdlib/3/xmlrpc/client.pyi index 4f596987c..7bea294bb 100644 --- a/stdlib/3/xmlrpc/client.pyi +++ b/stdlib/3/xmlrpc/client.pyi @@ -143,8 +143,7 @@ class Unmarshaller: def end_boolean(self, data: str) -> None: ... def end_int(self, data: str) -> None: ... def end_double(self, data: str) -> None: ... - if sys.version_info >= (3, 6): - def end_bigdecimal(self, data: str) -> None: ... + def end_bigdecimal(self, data: str) -> None: ... def end_string(self, data: str) -> None: ... def end_array(self, data: str) -> None: ... def end_struct(self, data: str) -> None: ... diff --git a/tests/stubtest_test.py b/tests/stubtest_test.py index 54a4fdaa8..18d6c5e09 100755 --- a/tests/stubtest_test.py +++ b/tests/stubtest_test.py @@ -3,7 +3,7 @@ stubtest is a script in the mypy project that compares stubs to the actual objects at runtime. Note that therefore the output of stubtest depends on which Python version it is run with. -In typeshed CI, we run stubtest with each Python minor version from 3.5 through 3.9 inclusive. +In typeshed CI, we run stubtest with each currently supported Python minor version, except 2.7. We pin the version of mypy / stubtest we use in .travis.yml so changes to those don't break typeshed CI. diff --git a/tests/stubtest_whitelists/linux-py35.txt b/tests/stubtest_whitelists/linux-py35.txt deleted file mode 100644 index 67dbd1f16..000000000 --- a/tests/stubtest_whitelists/linux-py35.txt +++ /dev/null @@ -1,5 +0,0 @@ -asyncio.unix_events._UnixSelectorEventLoop.create_unix_server -pwd.getpwnam -socket.NETLINK_CRYPTO -ssl.PROTOCOL_SSLv3 -ssl.RAND_egd diff --git a/tests/stubtest_whitelists/py35.txt b/tests/stubtest_whitelists/py35.txt deleted file mode 100644 index 403a52e50..000000000 --- a/tests/stubtest_whitelists/py35.txt +++ /dev/null @@ -1,81 +0,0 @@ -asyncio.Future._callbacks -asyncio.Future._exception -asyncio.Future._loop -asyncio.Future._tb_logger -asyncio.Task.__init__ -asyncio.Task._wakeup -asyncio.base_futures # Added in Python 3.6 -asyncio.base_tasks # Added in Python 3.6 -asyncio.exceptions # Added in Python 3.8 -asyncio.format_helpers # Added in Python 3.7 -asyncio.futures.Future._callbacks -asyncio.futures.Future._exception -asyncio.futures.Future._loop -asyncio.futures.Future._tb_logger -asyncio.futures._TracebackLogger.__init__ -asyncio.runners -asyncio.staggered # Added in Python 3.8 -asyncio.tasks.Task.__init__ -asyncio.tasks.Task._wakeup -asyncio.threads # Added in Python 3.9 -asyncio.trsock # Added in Python 3.8 -bdb.GENERATOR_AND_COROUTINE_FLAGS -builtins.ModuleNotFoundError -builtins.str.maketrans -cmath.log -codecs.StreamRecoder.seek -collections.Reversible -collections.UserString.maketrans -contextlib._GeneratorContextManager.__init__ -ctypes.CDLL.__init__ -fractions.Fraction.__new__ # private _normalize param was made keyword-only in Python 3.6 -hmac.HMAC.__init__ -importlib.metadata -importlib.resources -io.StringIO.readline -ipaddress._BaseNetwork.__init__ -json.dump -json.dumps -json.load -json.loads -mmap.ACCESS_DEFAULT -multiprocessing.context.BaseContext.reducer -multiprocessing.shared_memory -nntplib._NNTPBase.starttls -os.DirEntry -os.utime -plistlib.Dict.__init__ -pyexpat.XMLParserType.ExternalEntityParserCreate -random.Random.randrange # missing undocumented arg _int -random.randrange # missing undocumented arg _int -smtpd.SMTPChannel.__init__ -smtpd.SMTPServer.__init__ -sre_compile.dis -ssl.SSLSocket.__init__ -tarfile.TarFile.__init__ # undocumented arg copybufsize doesn't exist -typing.Coroutine.cr_await -typing.Coroutine.cr_code -typing.Coroutine.cr_frame -typing.Coroutine.cr_running -typing.Generator.__new__ -typing.Generator.gi_code -typing.Generator.gi_frame -typing.Generator.gi_running -typing.Generator.gi_yieldfrom -typing.GenericMeta.__new__ -typing.IO.closed # Incorrect definition in CPython, fixed in bpo-39493 -typing.Mapping.get -typing.NamedTuple.__new__ -typing.NamedTuple._asdict -typing.NamedTuple._make -typing.NamedTuple._replace -typing.Sequence.index -typing.runtime_checkable -unittest.async_case # Added in Python 3.8 -uuid.UUID.int -xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 -xml.etree.cElementTree.TreeBuilder.start # bpo-39495 -xml.etree.cElementTree.XMLPullParser -xml.parsers.expat.XMLParserType.ExternalEntityParserCreate -zipfile.ZipFile.open -zlib.compress diff --git a/tests/stubtest_whitelists/win32-py35.txt b/tests/stubtest_whitelists/win32-py35.txt deleted file mode 100644 index e3f4bd9f8..000000000 --- a/tests/stubtest_whitelists/win32-py35.txt +++ /dev/null @@ -1 +0,0 @@ -posixpath.splitunc # This doesn't exist, but our hands are tied by check_consistent diff --git a/third_party/2/enum.pyi b/third_party/2/enum.pyi index 860836f0b..1a1dcf005 100644 --- a/third_party/2/enum.pyi +++ b/third_party/2/enum.pyi @@ -29,13 +29,12 @@ class Enum(metaclass=EnumMeta): _value2member_map_: Dict[int, Enum] # undocumented if sys.version_info >= (3, 7): _ignore_: Union[str, List[str]] - if sys.version_info >= (3, 6): - _order_: str - __order__: str - @classmethod - def _missing_(cls, value: object) -> Any: ... - @staticmethod - def _generate_next_value_(name: str, start: int, count: int, last_values: List[Any]) -> Any: ... + _order_: str + __order__: str + @classmethod + def _missing_(cls, value: object) -> Any: ... + @staticmethod + def _generate_next_value_(name: str, start: int, count: int, last_values: List[Any]) -> Any: ... def __new__(cls: Type[_T], value: object) -> _T: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... @@ -49,25 +48,26 @@ class IntEnum(int, Enum): def unique(enumeration: _S) -> _S: ... -if sys.version_info >= (3, 6): - _auto_null: Any +_auto_null: Any - # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() - class auto(IntFlag): - value: Any - class Flag(Enum): - def __contains__(self: _T, other: _T) -> bool: ... - def __repr__(self) -> str: ... - def __str__(self) -> str: ... - def __bool__(self) -> bool: ... - def __or__(self: _T, other: _T) -> _T: ... - def __and__(self: _T, other: _T) -> _T: ... - def __xor__(self: _T, other: _T) -> _T: ... - def __invert__(self: _T) -> _T: ... - class IntFlag(int, Flag): - def __or__(self: _T, other: Union[int, _T]) -> _T: ... - def __and__(self: _T, other: Union[int, _T]) -> _T: ... - def __xor__(self: _T, other: Union[int, _T]) -> _T: ... - __ror__ = __or__ - __rand__ = __and__ - __rxor__ = __xor__ +# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() +class auto(IntFlag): + value: Any + +class Flag(Enum): + def __contains__(self: _T, other: _T) -> bool: ... + def __repr__(self) -> str: ... + def __str__(self) -> str: ... + def __bool__(self) -> bool: ... + def __or__(self: _T, other: _T) -> _T: ... + def __and__(self: _T, other: _T) -> _T: ... + def __xor__(self: _T, other: _T) -> _T: ... + def __invert__(self: _T) -> _T: ... + +class IntFlag(int, Flag): + def __or__(self: _T, other: Union[int, _T]) -> _T: ... + def __and__(self: _T, other: Union[int, _T]) -> _T: ... + def __xor__(self: _T, other: Union[int, _T]) -> _T: ... + __ror__ = __or__ + __rand__ = __and__ + __rxor__ = __xor__ diff --git a/third_party/2/tornado/web.pyi b/third_party/2/tornado/web.pyi index 1097e4788..0c594bae9 100644 --- a/third_party/2/tornado/web.pyi +++ b/third_party/2/tornado/web.pyi @@ -8,7 +8,7 @@ MAX_SUPPORTED_SIGNED_VALUE_VERSION: Any DEFAULT_SIGNED_VALUE_VERSION: Any DEFAULT_SIGNED_VALUE_MIN_VERSION: Any -if sys.version_info[:2] >= (3, 5): +if sys.version_info >= (3, 5): from typing import Awaitable _MethodType = Callable[..., Optional[Awaitable[None]]] diff --git a/third_party/2and3/jinja2/_compat.pyi b/third_party/2and3/jinja2/_compat.pyi index 17c061f81..4edf9286b 100644 --- a/third_party/2and3/jinja2/_compat.pyi +++ b/third_party/2and3/jinja2/_compat.pyi @@ -1,7 +1,7 @@ import sys from typing import Any, Optional -if sys.version_info[0] >= 3: +if sys.version_info >= (3,): from urllib.parse import quote_from_bytes url_quote = quote_from_bytes diff --git a/third_party/3/jwt/algorithms.pyi b/third_party/3/jwt/algorithms.pyi index d7900e3f6..fe83e56b6 100644 --- a/third_party/3/jwt/algorithms.pyi +++ b/third_party/3/jwt/algorithms.pyi @@ -44,11 +44,6 @@ class NoneAlgorithm(Algorithm[None]): class _HashAlg: def __call__(self, arg: Union[bytes, bytearray, memoryview] = ...) -> _Hash: ... -if sys.version_info >= (3, 6): - _LoadsString = Union[str, bytes, bytearray] -else: - _LoadsString = str - class HMACAlgorithm(Algorithm[bytes]): SHA256: ClassVar[_HashAlg] SHA384: ClassVar[_HashAlg] @@ -59,7 +54,7 @@ class HMACAlgorithm(Algorithm[bytes]): @staticmethod def to_jwk(key_obj: Union[str, bytes]) -> str: ... @staticmethod - def from_jwk(jwk: _LoadsString) -> bytes: ... + def from_jwk(jwk: Union[str, bytes]) -> bytes: ... # Only defined if cryptography is installed. class RSAAlgorithm(Algorithm[Any]): @@ -70,7 +65,7 @@ class RSAAlgorithm(Algorithm[Any]): def __init__(self, hash_alg: Union[HashAlgorithm, Prehashed]) -> None: ... def prepare_key(self, key: Union[bytes, str, RSAPrivateKey, RSAPublicKey]) -> Union[RSAPrivateKey, RSAPublicKey]: ... @staticmethod - def from_jwk(jwk: Union[_LoadsString, Dict[str, Any]]) -> Union[RSAPrivateKey, RSAPublicKey]: ... + def from_jwk(jwk: Union[str, bytes, Dict[str, Any]]) -> Union[RSAPrivateKey, RSAPublicKey]: ... def sign(self, msg: bytes, key: RSAPrivateKey) -> bytes: ... def verify(self, msg: bytes, key: RSAPublicKey, sig: bytes) -> bool: ... @@ -87,7 +82,7 @@ class ECAlgorithm(Algorithm[Any]): @staticmethod def to_jwk(key_obj: Union[EllipticCurvePrivateKeyWithSerialization, EllipticCurvePublicKeyWithSerialization]) -> str: ... @staticmethod - def from_jwk(jwk: _LoadsString) -> Union[EllipticCurvePrivateKey, EllipticCurvePublicKey]: ... + def from_jwk(jwk: Union[str, bytes]) -> Union[EllipticCurvePrivateKey, EllipticCurvePublicKey]: ... def sign(self, msg: bytes, key: EllipticCurvePrivateKey) -> bytes: ... def verify(self, msg: bytes, key: EllipticCurvePublicKey, sig: bytes) -> bool: ...