diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index a44a8a1a7c2a..470722a293a3 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -1,13 +1,13 @@ import codecs import sys -from typing import Any, Callable, Dict, Tuple, Union +from typing import Any, Callable, Union # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap: def size(self) -> int: ... -_MapT = Union[Dict[int, int], _EncodingMap] -_Handler = Callable[[Exception], Tuple[str, int]] +_MapT = Union[dict[int, int], _EncodingMap] +_Handler = Callable[[Exception], tuple[str, int]] def register(__search_function: Callable[[str], Any]) -> None: ... def register_error(__errors: str, __handler: _Handler) -> None: ... diff --git a/stdlib/_compression.pyi b/stdlib/_compression.pyi index 8f81847ff492..31940e3eb15b 100644 --- a/stdlib/_compression.pyi +++ b/stdlib/_compression.pyi @@ -1,6 +1,6 @@ from _typeshed import WriteableBuffer from io import BufferedIOBase, RawIOBase -from typing import Any, Callable, Protocol, Tuple, Type +from typing import Any, Callable, Protocol, Type BUFFER_SIZE: Any @@ -16,7 +16,7 @@ class DecompressReader(RawIOBase): self, fp: _Reader, decomp_factory: Callable[..., object], - trailing_error: Type[Exception] | Tuple[Type[Exception], ...] = ..., + trailing_error: Type[Exception] | tuple[Type[Exception], ...] = ..., **decomp_args: Any, ) -> None: ... def readable(self) -> bool: ... diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index 65f0ca27f0ec..54e9099bbdcd 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, List, Protocol, Type, Union +from typing import Any, Iterable, Iterator, Protocol, Type, Union QUOTE_ALL: int QUOTE_MINIMAL: int @@ -20,7 +20,7 @@ class Dialect: _DialectLike = Union[str, Dialect, Type[Dialect]] -class _reader(Iterator[List[str]]): +class _reader(Iterator[list[str]]): dialect: Dialect line_num: int def __next__(self) -> list[str]: ... diff --git a/stdlib/_dummy_thread.pyi b/stdlib/_dummy_thread.pyi index 886d9d739780..8935c1d71e0b 100644 --- a/stdlib/_dummy_thread.pyi +++ b/stdlib/_dummy_thread.pyi @@ -1,9 +1,9 @@ -from typing import Any, Callable, NoReturn, Tuple +from typing import Any, Callable, NoReturn TIMEOUT_MAX: int error = RuntimeError -def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... +def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... def exit() -> NoReturn: ... def get_ident() -> int: ... def allocate_lock() -> LockType: ... diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index 251e53810adc..77a88d4fa141 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -13,7 +13,6 @@ from typing import ( Protocol, Sequence, SupportsAbs, - Tuple, TypeVar, overload, ) @@ -99,7 +98,7 @@ class attrgetter(Generic[_T_co]): @overload def __new__(cls, attr: str, __attr2: str, __attr3: str, __attr4: str) -> attrgetter[tuple[Any, Any, Any, Any]]: ... @overload - def __new__(cls, attr: str, *attrs: str) -> attrgetter[Tuple[Any, ...]]: ... + def __new__(cls, attr: str, *attrs: str) -> attrgetter[tuple[Any, ...]]: ... def __call__(self, obj: Any) -> _T_co: ... @final @@ -113,7 +112,7 @@ class itemgetter(Generic[_T_co]): @overload def __new__(cls, item: Any, __item2: Any, __item3: Any, __item4: Any) -> itemgetter[tuple[Any, Any, Any, Any]]: ... @overload - def __new__(cls, item: Any, *items: Any) -> itemgetter[Tuple[Any, ...]]: ... + def __new__(cls, item: Any, *items: Any) -> itemgetter[tuple[Any, ...]]: ... def __call__(self, obj: Any) -> _T_co: ... @final diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index 49ebf93c31b7..ffb25d5a2c0e 100644 --- a/stdlib/_osx_support.pyi +++ b/stdlib/_osx_support.pyi @@ -1,5 +1,5 @@ import sys -from typing import Iterable, Sequence, Tuple, TypeVar +from typing import Iterable, Sequence, TypeVar _T = TypeVar("_T") _K = TypeVar("_K") @@ -7,8 +7,8 @@ _V = TypeVar("_V") __all__: list[str] -_UNIVERSAL_CONFIG_VARS: Tuple[str, ...] # undocumented -_COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented +_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented +_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented _INITPRE: str # undocumented def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented diff --git a/stdlib/_py_abc.pyi b/stdlib/_py_abc.pyi index 8d7938918271..697a7f17111a 100644 --- a/stdlib/_py_abc.pyi +++ b/stdlib/_py_abc.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple, Type, TypeVar +from typing import Any, Type, TypeVar _T = TypeVar("_T") @@ -6,5 +6,5 @@ _T = TypeVar("_T") def get_cache_token() -> object: ... class ABCMeta(type): - def __new__(__mcls, __name: str, __bases: Tuple[Type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ... + def __new__(__mcls, __name: str, __bases: tuple[Type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ... def register(cls, subclass: Type[_T]) -> Type[_T]: ... diff --git a/stdlib/_random.pyi b/stdlib/_random.pyi index fa80c6d98144..654277ec421a 100644 --- a/stdlib/_random.pyi +++ b/stdlib/_random.pyi @@ -1,7 +1,5 @@ -from typing import Tuple - # Actually Tuple[(int,) * 625] -_State = Tuple[int, ...] +_State = tuple[int, ...] class Random(object): def __init__(self, seed: object = ...) -> None: ... diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 82898177286b..d7d7f73ea37d 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Iterable -from typing import Any, SupportsInt, Tuple, Union, overload +from typing import Any, SupportsInt, Union, overload if sys.version_info >= (3, 8): from typing import SupportsIndex @@ -10,12 +10,12 @@ if sys.version_info >= (3, 8): else: _FD = SupportsInt -_CMSG = Tuple[int, int, bytes] -_CMSGArg = Tuple[int, int, ReadableBuffer] +_CMSG = tuple[int, int, bytes] +_CMSGArg = tuple[int, int, ReadableBuffer] # Addresses can be either tuples of varying lengths (AF_INET, AF_INET6, # AF_NETLINK, AF_TIPC) or strings (AF_UNIX). -_Address = Union[Tuple[Any, ...], str] +_Address = Union[tuple[Any, ...], str] _RetAddress = Any # TODO Most methods allow bytes as address objects diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 55ca3e80c7de..03318a0b2d41 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import structseq from threading import Thread from types import TracebackType -from typing import Any, Callable, NoReturn, Optional, Tuple, Type +from typing import Any, Callable, NoReturn, Optional, Type from typing_extensions import final error = RuntimeError @@ -21,7 +21,7 @@ class LockType: self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... -def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ... +def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ... def interrupt_main() -> None: ... def exit() -> NoReturn: ... def allocate_lock() -> LockType: ... @@ -34,7 +34,7 @@ if sys.version_info >= (3, 8): def get_native_id() -> int: ... # only available on some platforms @final class _ExceptHookArgs( - structseq[Any], Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]] + structseq[Any], tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]] ): @property def exc_type(self) -> Type[BaseException]: ... diff --git a/stdlib/_threading_local.pyi b/stdlib/_threading_local.pyi index bab69a7c2e7d..9e1e3f48d286 100644 --- a/stdlib/_threading_local.pyi +++ b/stdlib/_threading_local.pyi @@ -1,7 +1,7 @@ -from typing import Any, Dict +from typing import Any from weakref import ReferenceType -localdict = Dict[Any, Any] +localdict = dict[Any, Any] class _localimpl: key: str diff --git a/stdlib/_typeshed/wsgi.pyi b/stdlib/_typeshed/wsgi.pyi index 658b0fed2c6c..031d1472b6c5 100644 --- a/stdlib/_typeshed/wsgi.pyi +++ b/stdlib/_typeshed/wsgi.pyi @@ -3,7 +3,7 @@ # See the README.md file in this directory for more information. from sys import _OptExcInfo -from typing import Any, Callable, Dict, Iterable, Protocol +from typing import Any, Callable, Iterable, Protocol # stable class StartResponse(Protocol): @@ -11,7 +11,7 @@ class StartResponse(Protocol): self, status: str, headers: list[tuple[str, str]], exc_info: _OptExcInfo | None = ... ) -> Callable[[bytes], Any]: ... -WSGIEnvironment = Dict[str, Any] # stable +WSGIEnvironment = dict[str, Any] # stable WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] # stable # WSGI input streams per PEP 3333, stable diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index c9dbda103ef3..3c53692e1b36 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import SupportsWrite -from typing import Any, Callable, Tuple, Type, TypeVar +from typing import Any, Callable, Type, TypeVar _T = TypeVar("_T") _FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) @@ -8,7 +8,7 @@ _FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) # These definitions have special processing in mypy class ABCMeta(type): __abstractmethods__: frozenset[str] - def __init__(self, name: str, bases: Tuple[type, ...], namespace: dict[str, Any]) -> None: ... + def __init__(self, name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> None: ... def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ... diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index 79f470a366bb..e19bf2478bf3 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self from types import TracebackType -from typing import IO, Any, NamedTuple, Tuple, Type, Union, overload +from typing import IO, Any, NamedTuple, Type, Union, overload from typing_extensions import Literal class Error(Exception): ... @@ -15,7 +15,7 @@ class _aifc_params(NamedTuple): compname: bytes _File = Union[str, IO[bytes]] -_Marker = Tuple[int, int, bytes] +_Marker = tuple[int, int, bytes] class Aifc_read: def __init__(self, f: _File) -> None: ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 8e252ddc75c6..51933dc66668 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -1,20 +1,5 @@ import sys -from typing import ( - IO, - Any, - Callable, - Generator, - Generic, - Iterable, - NoReturn, - Pattern, - Protocol, - Sequence, - Tuple, - Type, - TypeVar, - overload, -) +from typing import IO, Any, Callable, Generator, Generic, Iterable, NoReturn, Pattern, Protocol, Sequence, Type, TypeVar, overload _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) @@ -70,7 +55,7 @@ class _ActionsContainer: choices: Iterable[_T] | None = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., dest: str | None = ..., version: str = ..., **kwargs: Any, @@ -274,7 +259,7 @@ class HelpFormatter: def _format_text(self, text: str) -> str: ... def _format_action(self, action: Action) -> str: ... def _format_action_invocation(self, action: Action) -> str: ... - def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], Tuple[str, ...]]: ... + def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], tuple[str, ...]]: ... def _format_args(self, action: Action, default_metavar: str) -> str: ... def _expand_help(self, action: Action) -> str: ... def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ... @@ -299,7 +284,7 @@ class Action(_AttributeHolder): choices: Iterable[Any] | None required: bool help: str | None - metavar: str | Tuple[str, ...] | None + metavar: str | tuple[str, ...] | None def __init__( self, option_strings: Sequence[str], @@ -311,7 +296,7 @@ class Action(_AttributeHolder): choices: Iterable[_T] | None = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... def __call__( self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = ... @@ -330,7 +315,7 @@ if sys.version_info >= (3, 9): choices: Iterable[_T] | None = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... class Namespace(_AttributeHolder): @@ -375,7 +360,7 @@ class _StoreConstAction(Action): default: Any = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... # undocumented @@ -403,7 +388,7 @@ class _AppendConstAction(Action): default: Any = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... # undocumented @@ -440,7 +425,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): dest: str = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... else: def __init__( @@ -450,7 +435,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): parser_class: Type[_ArgumentParserT], dest: str = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: str, **kwargs: Any) -> _ArgumentParserT: ... diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index e804c2f5d3bd..674baf49ba05 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -9,18 +9,18 @@ from asyncio.tasks import Task from asyncio.transports import BaseTransport from collections.abc import Iterable from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Awaitable, Callable, Dict, Generator, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Awaitable, Callable, Generator, Sequence, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 7): from contextvars import Context _T = TypeVar("_T") -_Context = Dict[str, Any] +_Context = dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] _ProtocolFactory = Callable[[], BaseProtocol] _SSLContext = Union[bool, None, ssl.SSLContext] -_TransProtPair = Tuple[BaseTransport, BaseProtocol] +_TransProtPair = tuple[BaseTransport, BaseProtocol] class Server(AbstractServer): if sys.version_info >= (3, 7): @@ -37,7 +37,7 @@ class Server(AbstractServer): def __init__(self, loop: AbstractEventLoop, sockets: list[socket]) -> None: ... if sys.version_info >= (3, 8): @property - def sockets(self) -> Tuple[socket, ...]: ... + def sockets(self) -> tuple[socket, ...]: ... elif sys.version_info >= (3, 7): @property def sockets(self) -> list[socket]: ... diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index 096bce60f7e3..94c7c01dd1bc 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -1,6 +1,6 @@ import subprocess from collections import deque -from typing import IO, Any, Callable, Optional, Sequence, Tuple, Union +from typing import IO, Any, Callable, Optional, Sequence, Union from . import events, futures, protocols, transports @@ -15,7 +15,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): _pid: int | None # undocumented _returncode: int | None # undocumented _exit_waiters: list[futures.Future[Any]] # undocumented - _pending_calls: deque[tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented + _pending_calls: deque[tuple[Callable[..., Any], tuple[Any, ...]]] # undocumented _pipes: dict[int, _File] # undocumented _finished: bool # undocumented def __init__( diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 6ef9117b6491..81b30b7e0065 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -3,7 +3,7 @@ import sys from _typeshed import FileDescriptorLike, Self from abc import ABCMeta, abstractmethod from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Awaitable, Callable, Dict, Generator, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Awaitable, Callable, Generator, Sequence, TypeVar, Union, overload from typing_extensions import Literal from .base_events import Server @@ -17,11 +17,11 @@ if sys.version_info >= (3, 7): from contextvars import Context _T = TypeVar("_T") -_Context = Dict[str, Any] +_Context = dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] _ProtocolFactory = Callable[[], BaseProtocol] _SSLContext = Union[bool, None, ssl.SSLContext] -_TransProtPair = Tuple[BaseTransport, BaseProtocol] +_TransProtPair = tuple[BaseTransport, BaseProtocol] class Handle: _cancelled = False diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 33ec5d67aaf9..55147f4fddd5 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -1,14 +1,14 @@ import socket import sys from types import TracebackType -from typing import Any, BinaryIO, Iterable, NoReturn, Tuple, Type, Union, overload +from typing import Any, BinaryIO, Iterable, NoReturn, Type, Union, overload if sys.version_info >= (3, 8): # These are based in socket, maybe move them out into _typeshed.pyi or such - _Address = Union[Tuple[Any, ...], str] + _Address = Union[tuple[Any, ...], str] _RetAddress = Any _WriteBuffer = Union[bytearray, memoryview] - _CMSG = Tuple[int, int, bytes] + _CMSG = tuple[int, int, bytes] class TransportSocket: def __init__(self, sock: socket.socket) -> None: ... def _na(self, what: str) -> None: ... diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index e135221134a5..123da2677a7e 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -1,10 +1,10 @@ import sys from _typeshed import FileDescriptorLike from socket import socket -from typing import Any, Dict, Tuple, overload +from typing import Any, overload # cyclic dependence with asynchat -_maptype = Dict[int, Any] +_maptype = dict[int, Any] _socket = socket socket_map: _maptype # undocumented @@ -41,8 +41,8 @@ class dispatcher: def readable(self) -> bool: ... def writable(self) -> bool: ... def listen(self, num: int) -> None: ... - def bind(self, addr: Tuple[Any, ...] | str) -> None: ... - def connect(self, address: Tuple[Any, ...] | str) -> None: ... + def bind(self, addr: tuple[Any, ...] | str) -> None: ... + def connect(self, address: tuple[Any, ...] | str) -> None: ... def accept(self) -> tuple[_socket, Any] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index 321bfe55c4b0..b08731b85b0b 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,7 +1,5 @@ -from typing import Tuple - -AdpcmState = Tuple[int, int] -RatecvState = Tuple[int, Tuple[Tuple[int, int], ...]] +AdpcmState = tuple[int, int] +RatecvState = tuple[int, tuple[tuple[int, int], ...]] class error(Exception): ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index 1d03ddf19a0e..3f6b6d3d8b7b 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -1,9 +1,9 @@ from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, Tuple, Type, TypeVar +from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, Type, TypeVar _T = TypeVar("_T") _TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type -_ExcInfo = Tuple[Type[BaseException], BaseException, FrameType] +_ExcInfo = tuple[Type[BaseException], BaseException, FrameType] GENERATOR_AND_COROUTINE_FLAGS: int diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index 02d094faf923..4e295b8ed903 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Tuple, Union +from typing import IO, Any, Union class Error(Exception): ... @@ -12,7 +12,7 @@ class FInfo: Creator: str Flags: int -_FileInfoTuple = Tuple[str, FInfo, int, int] +_FileInfoTuple = tuple[str, FInfo, int, int] _FileHandleUnion = Union[str, IO[bytes]] def getfileinfo(name: str) -> _FileInfoTuple: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 0daf9d154227..cf5799238b76 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -49,7 +49,6 @@ from typing import ( SupportsFloat, SupportsInt, SupportsRound, - Tuple, Type, TypeVar, Union, @@ -108,11 +107,11 @@ class object: def __sizeof__(self) -> int: ... # return type of pickle methods is rather hard to express in the current type system # see #6661 and https://docs.python.org/3/library/pickle.html#object.__reduce__ - def __reduce__(self) -> str | Tuple[Any, ...]: ... + def __reduce__(self) -> str | tuple[Any, ...]: ... if sys.version_info >= (3, 8): - def __reduce_ex__(self, __protocol: SupportsIndex) -> str | Tuple[Any, ...]: ... + def __reduce_ex__(self, __protocol: SupportsIndex) -> str | tuple[Any, ...]: ... else: - def __reduce_ex__(self, __protocol: int) -> str | Tuple[Any, ...]: ... + def __reduce_ex__(self, __protocol: int) -> str | tuple[Any, ...]: ... def __dir__(self) -> Iterable[str]: ... def __init_subclass__(cls) -> None: ... @@ -141,14 +140,14 @@ class classmethod(Generic[_R]): # Special, only valid as a decorator. class type(object): __base__: type - __bases__: Tuple[type, ...] + __bases__: tuple[type, ...] __basicsize__: int __dict__: dict[str, Any] __dictoffset__: int __flags__: int __itemsize__: int __module__: str - __mro__: Tuple[type, ...] + __mro__: tuple[type, ...] __name__: str __qualname__: str __text_signature__: str | None @@ -156,11 +155,11 @@ class type(object): @overload def __init__(self, __o: object) -> None: ... @overload - def __init__(self, __name: str, __bases: Tuple[type, ...], __dict: dict[str, Any], **kwds: Any) -> None: ... + def __init__(self, __name: str, __bases: tuple[type, ...], __dict: dict[str, Any], **kwds: Any) -> None: ... @overload def __new__(cls, __o: object) -> type: ... @overload - def __new__(cls: Type[_TT], __name: str, __bases: Tuple[type, ...], __namespace: dict[str, Any], **kwds: Any) -> _TT: ... + def __new__(cls: Type[_TT], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwds: Any) -> _TT: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... def __subclasses__(self: _TT) -> list[_TT]: ... # Note: the documentation doesn't specify what the return type is, the standard @@ -169,7 +168,7 @@ class type(object): def __instancecheck__(self, __instance: Any) -> bool: ... def __subclasscheck__(self, __subclass: type) -> bool: ... @classmethod - def __prepare__(metacls, __name: str, __bases: Tuple[type, ...], **kwds: Any) -> Mapping[str, object]: ... + def __prepare__(metacls, __name: str, __bases: tuple[type, ...], **kwds: Any) -> Mapping[str, object]: ... if sys.version_info >= (3, 10): def __or__(self, __t: Any) -> types.UnionType: ... def __ror__(self, __t: Any) -> types.UnionType: ... @@ -370,7 +369,7 @@ class str(Sequence[str]): def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ... def endswith( - self, __suffix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... @@ -411,7 +410,7 @@ class str(Sequence[str]): def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... def splitlines(self, keepends: bool = ...) -> list[str]: ... def startswith( - self, __prefix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... def strip(self, __chars: str | None = ...) -> str: ... def swapcase(self) -> str: ... @@ -463,7 +462,7 @@ class bytes(ByteString): ) -> int: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( - self, __suffix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __suffix: bytes | tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ... @@ -510,7 +509,7 @@ class bytes(ByteString): def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytes]: ... def splitlines(self, keepends: bool = ...) -> list[bytes]: ... def startswith( - self, __prefix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __prefix: bytes | tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... def strip(self, __bytes: bytes | None = ...) -> bytes: ... def swapcase(self) -> bytes: ... @@ -565,7 +564,7 @@ class bytearray(MutableSequence[int], ByteString): def copy(self) -> bytearray: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( - self, __suffix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __suffix: bytes | tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ... @@ -614,7 +613,7 @@ class bytearray(MutableSequence[int], ByteString): def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytearray]: ... def splitlines(self, keepends: bool = ...) -> list[bytearray]: ... def startswith( - self, __prefix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __prefix: bytes | tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... def strip(self, __bytes: bytes | None = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... @@ -659,9 +658,9 @@ class bytearray(MutableSequence[int], ByteString): class memoryview(Sized, Sequence[int]): format: str itemsize: int - shape: Tuple[int, ...] | None - strides: Tuple[int, ...] | None - suboffsets: Tuple[int, ...] | None + shape: tuple[int, ...] | None + strides: tuple[int, ...] | None + suboffsets: tuple[int, ...] | None readonly: bool ndim: int @@ -675,7 +674,7 @@ class memoryview(Sized, Sequence[int]): def __exit__( self, __exc_type: Type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None ) -> None: ... - def cast(self, format: str, shape: list[int] | Tuple[int, ...] = ...) -> memoryview: ... + def cast(self, format: str, shape: list[int] | tuple[int, ...] = ...) -> memoryview: ... @overload def __getitem__(self, __i: SupportsIndex) -> int: ... @overload @@ -748,18 +747,18 @@ class tuple(Sequence[_T_co], Generic[_T_co]): @overload def __getitem__(self, __x: SupportsIndex) -> _T_co: ... @overload - def __getitem__(self, __x: slice) -> Tuple[_T_co, ...]: ... + def __getitem__(self, __x: slice) -> tuple[_T_co, ...]: ... def __iter__(self) -> Iterator[_T_co]: ... - def __lt__(self, __x: Tuple[_T_co, ...]) -> bool: ... - def __le__(self, __x: Tuple[_T_co, ...]) -> bool: ... - def __gt__(self, __x: Tuple[_T_co, ...]) -> bool: ... - def __ge__(self, __x: Tuple[_T_co, ...]) -> bool: ... + def __lt__(self, __x: tuple[_T_co, ...]) -> bool: ... + def __le__(self, __x: tuple[_T_co, ...]) -> bool: ... + def __gt__(self, __x: tuple[_T_co, ...]) -> bool: ... + def __ge__(self, __x: tuple[_T_co, ...]) -> bool: ... @overload - def __add__(self, __x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... + def __add__(self, __x: tuple[_T_co, ...]) -> tuple[_T_co, ...]: ... @overload - def __add__(self, __x: Tuple[_T, ...]) -> Tuple[_T_co | _T, ...]: ... - def __mul__(self, __n: SupportsIndex) -> Tuple[_T_co, ...]: ... - def __rmul__(self, __n: SupportsIndex) -> Tuple[_T_co, ...]: ... + def __add__(self, __x: tuple[_T, ...]) -> tuple[_T_co | _T, ...]: ... + def __mul__(self, __n: SupportsIndex) -> tuple[_T_co, ...]: ... + def __rmul__(self, __n: SupportsIndex) -> tuple[_T_co, ...]: ... def count(self, __value: Any) -> int: ... def index(self, __value: Any, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ... if sys.version_info >= (3, 9): @@ -924,7 +923,7 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]): if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... -class enumerate(Iterator[Tuple[int, _T]], Generic[_T]): +class enumerate(Iterator[tuple[int, _T]], Generic[_T]): def __init__(self, iterable: Iterable[_T], start: int = ...) -> None: ... def __iter__(self) -> Iterator[tuple[int, _T]]: ... def __next__(self) -> tuple[int, _T]: ... @@ -1090,15 +1089,15 @@ def iter(__function: Callable[[], _T], __sentinel: object) -> Iterator[_T]: ... # We need recursive types to express the type of the second argument to `isinstance` properly, hence the use of `Any` if sys.version_info >= (3, 10): def isinstance( - __obj: object, __class_or_tuple: type | types.UnionType | Tuple[type | types.UnionType | Tuple[Any, ...], ...] + __obj: object, __class_or_tuple: type | types.UnionType | tuple[type | types.UnionType | tuple[Any, ...], ...] ) -> bool: ... def issubclass( - __cls: type, __class_or_tuple: type | types.UnionType | Tuple[type | types.UnionType | Tuple[Any, ...], ...] + __cls: type, __class_or_tuple: type | types.UnionType | tuple[type | types.UnionType | tuple[Any, ...], ...] ) -> bool: ... else: - def isinstance(__obj: object, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... - def issubclass(__cls: type, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... + def isinstance(__obj: object, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... + def issubclass(__cls: type, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... def len(__obj: Sized) -> int: ... def license() -> None: ... @@ -1449,7 +1448,7 @@ class zip(Iterator[_T_co], Generic[_T_co]): __iter6: Iterable[Any], *iterables: Iterable[Any], strict: bool = ..., - ) -> zip[Tuple[Any, ...]]: ... + ) -> zip[tuple[Any, ...]]: ... else: @overload def __new__(cls, __iter1: Iterable[_T1]) -> zip[tuple[_T1]]: ... @@ -1480,7 +1479,7 @@ class zip(Iterator[_T_co], Generic[_T_co]): __iter5: Iterable[Any], __iter6: Iterable[Any], *iterables: Iterable[Any], - ) -> zip[Tuple[Any, ...]]: ... + ) -> zip[tuple[Any, ...]]: ... def __iter__(self) -> Iterator[_T_co]: ... def __next__(self) -> _T_co: ... @@ -1502,7 +1501,7 @@ class ellipsis: ... Ellipsis: ellipsis class BaseException(object): - args: Tuple[Any, ...] + args: tuple[Any, ...] __cause__: BaseException | None __context__: BaseException | None __suppress_context__: bool diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index f4a7ab50cc11..e79524aa793e 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from types import CodeType -from typing import Any, Callable, Tuple, TypeVar +from typing import Any, Callable, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( @@ -9,7 +9,7 @@ def runctx( ) -> None: ... _T = TypeVar("_T") -_Label = Tuple[str, int, str] +_Label = tuple[str, int, str] class Profile: stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 26073fb7281b..aa37928b87b1 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -1,9 +1,9 @@ import datetime import sys from time import struct_time -from typing import Any, Iterable, Optional, Sequence, Tuple +from typing import Any, Iterable, Optional, Sequence -_LocaleType = Tuple[Optional[str], Optional[str]] +_LocaleType = tuple[Optional[str], Optional[str]] class IllegalMonthError(ValueError): def __init__(self, month: int) -> None: ... @@ -97,7 +97,7 @@ c: TextCalendar def setfirstweekday(firstweekday: int) -> None: ... def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... -def timegm(tuple: Tuple[int, ...] | struct_time) -> int: ... +def timegm(tuple: tuple[int, ...] | struct_time) -> int: ... # Data attributes day_name: Sequence[str] diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index 7576740fc1c0..a8f3912aa04c 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -1,8 +1,8 @@ from _typeshed import StrOrBytesPath from types import FrameType, TracebackType -from typing import IO, Any, Callable, Optional, Tuple, Type +from typing import IO, Any, Callable, Optional, Type -_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_ExcInfo = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] def reset() -> str: ... # undocumented def small(text: str) -> str: ... # undocumented diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 63de22d99188..e08672e51428 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -2,7 +2,7 @@ import sys import types from _typeshed import Self from abc import abstractmethod -from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, Tuple, Type, TypeVar, overload +from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, Type, TypeVar, overload from typing_extensions import Literal BOM32_BE: bytes @@ -71,7 +71,7 @@ def lookup(__encoding: str) -> CodecInfo: ... def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> tuple[str, int]: ... # undocumented def utf_16_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... # undocumented -class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): +class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): @property def encode(self) -> _Encoder: ... @property diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index d4808d326efe..adcdf29fa690 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,7 +1,7 @@ import sys from _collections_abc import dict_items, dict_keys, dict_values from _typeshed import Self, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT -from typing import Any, Dict, Generic, NoReturn, Tuple, Type, TypeVar, overload +from typing import Any, Generic, NoReturn, Type, TypeVar, overload from typing_extensions import SupportsIndex, final if sys.version_info >= (3, 9): @@ -28,12 +28,12 @@ if sys.version_info >= (3, 7): rename: bool = ..., module: str | None = ..., defaults: Iterable[Any] | None = ..., - ) -> Type[Tuple[Any, ...]]: ... + ) -> Type[tuple[Any, ...]]: ... else: def namedtuple( typename: str, field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., module: str | None = ... - ) -> Type[Tuple[Any, ...]]: ... + ) -> Type[tuple[Any, ...]]: ... class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): data: dict[_KT, _VT] @@ -132,7 +132,7 @@ class UserString(Sequence[str]): def encode(self: UserString, encoding: str | None = ..., errors: str | None = ...) -> bytes: ... else: def encode(self: _UserStringT, encoding: str | None = ..., errors: str | None = ...) -> _UserStringT: ... - def endswith(self, suffix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... + def endswith(self, suffix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ... def find(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def format(self, *args: Any, **kwds: Any) -> str: ... @@ -174,7 +174,7 @@ class UserString(Sequence[str]): def split(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... def splitlines(self, keepends: bool = ...) -> list[str]: ... - def startswith(self, prefix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... + def startswith(self, prefix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... def strip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ... def swapcase(self: _UserStringT) -> _UserStringT: ... def title(self: _UserStringT) -> _UserStringT: ... @@ -214,7 +214,7 @@ class deque(MutableSequence[_T], Generic[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... -class Counter(Dict[_T, int], Generic[_T]): +class Counter(dict[_T, int], Generic[_T]): @overload def __init__(self, __iterable: None = ..., **kwargs: int) -> None: ... @overload @@ -261,14 +261,14 @@ class _OrderedDictKeysView(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # ty def __reversed__(self) -> Iterator[_KT_co]: ... @final -class _OrderedDictItemsView(dict_items[_KT_co, _VT_co], Reversible[Tuple[_KT_co, _VT_co]]): # type: ignore[misc] +class _OrderedDictItemsView(dict_items[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]): # type: ignore[misc] def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... @final class _OrderedDictValuesView(dict_values[_KT_co, _VT_co], Reversible[_VT_co], Generic[_KT_co, _VT_co]): # type: ignore[misc] def __reversed__(self) -> Iterator[_VT_co]: ... -class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): +class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def popitem(self, last: bool = ...) -> tuple[_KT, _VT]: ... def move_to_end(self, key: _KT, last: bool = ...) -> None: ... def copy(self: Self) -> Self: ... @@ -286,7 +286,7 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): @overload def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> OrderedDict[_T, _S]: ... -class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): +class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]): default_factory: Callable[[], _VT] | None @overload def __init__(self, **kwargs: _VT) -> None: ... diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index c1a44c997381..ebc64159e54f 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -4,7 +4,7 @@ from _typeshed import Self from abc import abstractmethod from collections.abc import Container, Iterable, Iterator, Sequence from logging import Logger -from typing import Any, Callable, Generic, Protocol, Set, TypeVar, overload +from typing import Any, Callable, Generic, Protocol, TypeVar, overload from typing_extensions import SupportsIndex if sys.version_info >= (3, 9): @@ -76,7 +76,7 @@ class Executor: def as_completed(fs: Iterable[Future[_T]], timeout: float | None = ...) -> Iterator[Future[_T]]: ... # Ideally this would be a namedtuple, but mypy doesn't support generic tuple types. See #1976 -class DoneAndNotDoneFutures(Sequence[Set[Future[_T]]]): +class DoneAndNotDoneFutures(Sequence[set[Future[_T]]]): done: set[Future[_T]] not_done: set[Future[_T]] def __new__(_cls, done: set[Future[_T]], not_done: set[Future[_T]]) -> DoneAndNotDoneFutures[_T]: ... diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index cc48f48f0023..6435901a8f13 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -5,7 +5,7 @@ from multiprocessing.context import BaseContext, Process from multiprocessing.queues import Queue, SimpleQueue from threading import Lock, Semaphore, Thread from types import TracebackType -from typing import Any, Callable, Generic, Tuple, TypeVar +from typing import Any, Callable, Generic, TypeVar from weakref import ref from ._base import Executor, Future @@ -37,7 +37,7 @@ class _ExceptionWithTraceback: exc: BaseException tb: TracebackType def __init__(self, exc: BaseException, tb: TracebackType) -> None: ... - def __reduce__(self) -> str | Tuple[Any, ...]: ... + def __reduce__(self) -> str | tuple[Any, ...]: ... def _rebuild_exc(exc: Exception, tb: str) -> Exception: ... @@ -84,7 +84,7 @@ if sys.version_info >= (3, 7): ) -> None: ... def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ... -def _get_chunks(*iterables: Any, chunksize: int) -> Generator[Tuple[Any, ...], None, None]: ... +def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...], None, None]: ... def _process_chunk(fn: Callable[..., Any], chunk: tuple[Any, None, None]) -> Generator[Any, None, None]: ... def _sendback_result( result_queue: SimpleQueue[_WorkItem[Any]], work_id: int, result: Any | None = ..., exception: Exception | None = ... @@ -95,7 +95,7 @@ if sys.version_info >= (3, 7): call_queue: Queue[_CallItem], result_queue: SimpleQueue[_ResultItem], initializer: Callable[..., None] | None, - initargs: Tuple[Any, ...], + initargs: tuple[Any, ...], ) -> None: ... else: @@ -139,7 +139,7 @@ else: class ProcessPoolExecutor(Executor): _mp_context: BaseContext | None = ... _initializer: Callable[..., None] | None = ... - _initargs: Tuple[Any, ...] = ... + _initargs: tuple[Any, ...] = ... _executor_manager_thread: _ThreadWakeup _processes: MutableMapping[int, Process] _shutdown_thread: bool @@ -158,7 +158,7 @@ class ProcessPoolExecutor(Executor): max_workers: int | None = ..., mp_context: BaseContext | None = ..., initializer: Callable[..., None] | None = ..., - initargs: Tuple[Any, ...] = ..., + initargs: tuple[Any, ...] = ..., ) -> None: ... else: def __init__(self, max_workers: int | None = ...) -> None: ... diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index b3f7ac82c464..f27c43c3403c 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -2,7 +2,7 @@ import queue import sys from collections.abc import Iterable, Mapping, Set as AbstractSet from threading import Lock, Semaphore, Thread -from typing import Any, Callable, Generic, Tuple, TypeVar +from typing import Any, Callable, Generic, TypeVar from weakref import ref from ._base import Executor, Future @@ -33,7 +33,7 @@ if sys.version_info >= (3, 7): executor_reference: ref[Any], work_queue: queue.SimpleQueue[Any], initializer: Callable[..., None], - initargs: Tuple[Any, ...], + initargs: tuple[Any, ...], ) -> None: ... else: @@ -52,7 +52,7 @@ class ThreadPoolExecutor(Executor): _shutdown_lock: Lock _thread_name_prefix: str | None = ... _initializer: Callable[..., None] | None = ... - _initargs: Tuple[Any, ...] = ... + _initargs: tuple[Any, ...] = ... if sys.version_info >= (3, 7): _work_queue: queue.SimpleQueue[_WorkItem[Any]] else: @@ -63,7 +63,7 @@ class ThreadPoolExecutor(Executor): max_workers: int | None = ..., thread_name_prefix: str = ..., initializer: Callable[..., None] | None = ..., - initargs: Tuple[Any, ...] = ..., + initargs: tuple[Any, ...] = ..., ) -> None: ... else: def __init__(self, max_workers: int | None = ..., thread_name_prefix: str = ...) -> None: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 83d9d969080a..dc81cb78577a 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -1,14 +1,14 @@ import sys from _typeshed import StrOrBytesPath, StrPath, SupportsWrite from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence -from typing import Any, ClassVar, Dict, Optional, Pattern, Type, TypeVar, overload +from typing import Any, ClassVar, Optional, Pattern, Type, TypeVar, overload from typing_extensions import Literal # Internal type aliases _section = Mapping[str, str] _parser = MutableMapping[str, _section] _converter = Callable[[str], Any] -_converters = Dict[str, _converter] +_converters = dict[str, _converter] _T = TypeVar("_T") if sys.version_info >= (3, 7): diff --git a/stdlib/copyreg.pyi b/stdlib/copyreg.pyi index 320097b3a204..6097670833c0 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -1,7 +1,7 @@ -from typing import Any, Callable, Hashable, Optional, SupportsInt, Tuple, TypeVar, Union +from typing import Any, Callable, Hashable, Optional, SupportsInt, TypeVar, Union _TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] +_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Optional[Any]]] __all__: list[str] diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 0b69cb2272d3..3211e688a309 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -21,7 +21,7 @@ from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence from typing import Any, Generic, Type, TypeVar, overload if sys.version_info >= (3, 8): - from typing import Dict as _DictReadMapping + from builtins import dict as _DictReadMapping else: from collections import OrderedDict as _DictReadMapping diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 5cf8ce289148..179e1cae54c3 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -11,7 +11,6 @@ from typing import ( Mapping, Optional, Sequence, - Tuple, Type, TypeVar, Union as _UnionT, @@ -98,8 +97,8 @@ class _CData(metaclass=_CDataMeta): class _CanCastTo(_CData): ... class _PointerLike(_CanCastTo): ... -_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, Tuple[_CData, ...]], _CData] -_PF = _UnionT[Tuple[int], Tuple[int, str], Tuple[int, str, Any]] +_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, tuple[_CData, ...]], _CData] +_PF = _UnionT[tuple[int], tuple[int, str], tuple[int, str, Any]] class _FuncPointer(_PointerLike, _CData): restype: Type[_CData] | Callable[[int], Any] | None @@ -110,9 +109,9 @@ class _FuncPointer(_PointerLike, _CData): @overload def __init__(self, callable: Callable[..., Any]) -> None: ... @overload - def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: Tuple[_PF, ...] = ...) -> None: ... + def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] = ...) -> None: ... @overload - def __init__(self, vtlb_index: int, name: str, paramflags: Tuple[_PF, ...] = ..., iid: pointer[c_int] = ...) -> None: ... + def __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: pointer[c_int] = ...) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class _NamedFuncPointer(_FuncPointer): diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 6dfe83c2d4a8..885facb9c0db 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -1,6 +1,6 @@ import sys import types -from typing import Any, Callable, Generic, Iterable, Mapping, Protocol, Tuple, Type, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Mapping, Protocol, Type, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -20,7 +20,7 @@ def asdict(obj: Any) -> dict[str, Any]: ... @overload def asdict(obj: Any, *, dict_factory: Callable[[list[tuple[str, Any]]], _T]) -> _T: ... @overload -def astuple(obj: Any) -> Tuple[Any, ...]: ... +def astuple(obj: Any) -> tuple[Any, ...]: ... @overload def astuple(obj: Any, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ... @@ -172,7 +172,7 @@ else: metadata: Mapping[Any, Any] | None = ..., ) -> Any: ... -def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... +def fields(class_or_instance: Any) -> tuple[Field[Any], ...]: ... def is_dataclass(obj: Any) -> bool: ... class FrozenInstanceError(AttributeError): ... @@ -191,7 +191,7 @@ if sys.version_info >= (3, 10): cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., @@ -209,7 +209,7 @@ else: cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 959af69675c9..ac04557c6f39 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -1,16 +1,16 @@ import numbers import sys from types import TracebackType -from typing import Any, Container, NamedTuple, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Container, NamedTuple, Sequence, Type, TypeVar, Union, overload _Decimal = Union[Decimal, int] -_DecimalNew = Union[Decimal, float, str, Tuple[int, Sequence[int], int]] +_DecimalNew = Union[Decimal, float, str, tuple[int, Sequence[int], int]] _ComparableNum = Union[Decimal, float, numbers.Rational] _DecimalT = TypeVar("_DecimalT", bound=Decimal) class DecimalTuple(NamedTuple): sign: int - digits: Tuple[int, ...] + digits: tuple[int, ...] exponent: int ROUND_DOWN: str @@ -184,7 +184,7 @@ class Context(object): # __setattr__() only allows to set a specific set of attributes, # already defined above. def __delattr__(self, __name: str) -> None: ... - def __reduce__(self) -> tuple[Type[Context], Tuple[Any, ...]]: ... + def __reduce__(self) -> tuple[Type[Context], tuple[Any, ...]]: ... def clear_flags(self) -> None: ... def clear_traps(self) -> None: ... def copy(self) -> Context: ... diff --git a/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index d21de4691503..7c7023ed0b65 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,6 +1,6 @@ -from typing import Any, Callable, Optional, Tuple, Union +from typing import Any, Callable, Optional, Union -_Macro = Union[Tuple[str], Tuple[str, Optional[str]]] +_Macro = Union[tuple[str], tuple[str, Optional[str]]] def gen_lib_options( compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str] @@ -141,7 +141,7 @@ class CCompiler: def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... def object_filenames(self, source_filenames: list[str], strip_dir: int = ..., output_dir: str = ...) -> list[str]: ... def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... + def execute(self, func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... def spawn(self, cmd: list[str]) -> None: ... def mkpath(self, name: str, mode: int = ...) -> None: ... def move_file(self, src: str, dst: str) -> str: ... diff --git a/stdlib/distutils/command/install.pyi b/stdlib/distutils/command/install.pyi index 47fa8b08d1b2..661d256e6f07 100644 --- a/stdlib/distutils/command/install.pyi +++ b/stdlib/distutils/command/install.pyi @@ -1,9 +1,9 @@ -from typing import Any, Tuple +from typing import Any from ..cmd import Command HAS_USER_SITE: bool -SCHEME_KEYS: Tuple[str, ...] +SCHEME_KEYS: tuple[str, ...] INSTALL_SCHEMES: dict[str, dict[Any, Any]] class install(Command): diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index 06a0847e4687..dce8394b6289 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,7 +1,7 @@ -from typing import Any, Iterable, List, Mapping, Optional, Tuple, overload +from typing import Any, Iterable, Mapping, Optional, overload -_Option = Tuple[str, Optional[str], str] -_GR = Tuple[List[str], OptionDummy] +_Option = tuple[str, Optional[str], str] +_GR = tuple[list[str], OptionDummy] def fancy_getopt( options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index 9b0915570ece..03ee0185cac4 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -1,6 +1,6 @@ from _typeshed import StrPath from collections.abc import Callable, Container, Iterable, Mapping -from typing import Any, Tuple +from typing import Any def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... @@ -9,7 +9,7 @@ def check_environ() -> None: ... def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... def split_quoted(s: str) -> list[str]: ... def execute( - func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... + func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... def strtobool(val: str) -> bool: ... def byte_compile( diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 9921dde39af6..1908cdeda97a 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Pattern, Tuple, TypeVar +from typing import Pattern, TypeVar _T = TypeVar("_T", bound=Version) @@ -31,7 +31,7 @@ class StrictVersion(Version): class LooseVersion(Version): component_re: Pattern[str] vstring: str - version: Tuple[str | int, ...] + version: tuple[str | int, ...] def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 9a9f83b0d8fe..611137740ac4 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -1,6 +1,6 @@ import types import unittest -from typing import Any, Callable, NamedTuple, Tuple, Type +from typing import Any, Callable, NamedTuple, Type class TestResults(NamedTuple): failed: int @@ -86,7 +86,7 @@ class DocTestFinder: ) -> list[DocTest]: ... _Out = Callable[[str], Any] -_ExcInfo = Tuple[Type[BaseException], BaseException, types.TracebackType] +_ExcInfo = tuple[Type[BaseException], BaseException, types.TracebackType] class DocTestRunner: DIVIDER: str diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index a14f5a2d2238..ddb9d9e45913 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -1,7 +1,7 @@ import sys from email.errors import HeaderParseError, MessageDefect from email.policy import Policy -from typing import Any, Iterable, Iterator, List, Pattern, Type, TypeVar, Union +from typing import Any, Iterable, Iterator, Pattern, Type, TypeVar, Union from typing_extensions import Final _T = TypeVar("_T") @@ -23,7 +23,7 @@ def quote_string(value: Any) -> str: ... if sys.version_info >= (3, 7): rfc2047_matcher: Pattern[str] -class TokenList(List[Union[TokenList, Terminal]]): +class TokenList(list[Union[TokenList, Terminal]]): token_type: str | None syntactic_break: bool ew_combine_allowed: bool diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index 6a3d6ca5b2a7..abf10ed4a4fd 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -13,7 +13,7 @@ from email._header_value_parser import ( ) from email.errors import MessageDefect from email.policy import Policy -from typing import Any, ClassVar, Tuple, Type +from typing import Any, ClassVar, Type from typing_extensions import Literal class BaseHeader(str): @@ -22,7 +22,7 @@ class BaseHeader(str): @property def name(self) -> str: ... @property - def defects(self) -> Tuple[MessageDefect, ...]: ... + def defects(self) -> tuple[MessageDefect, ...]: ... def __new__(cls, name: str, value: Any) -> BaseHeader: ... def init(self, name: str, *, parse_tree: TokenList, defects: Iterable[MessageDefect]) -> None: ... def fold(self, *, policy: Policy) -> str: ... @@ -54,9 +54,9 @@ class AddressHeader: max_count: ClassVar[Literal[1] | None] def init(self, name: str, *, parse_tree: TokenList, defects: Iterable[MessageDefect], groups: Iterable[Group]) -> None: ... @property - def groups(self) -> Tuple[Group, ...]: ... + def groups(self) -> tuple[Group, ...]: ... @property - def addresses(self) -> Tuple[Address, ...]: ... + def addresses(self) -> tuple[Address, ...]: ... @staticmethod def value_parser(value: str) -> AddressList: ... @classmethod @@ -165,6 +165,6 @@ class Group: @property def display_name(self) -> str | None: ... @property - def addresses(self) -> Tuple[Address, ...]: ... + def addresses(self) -> tuple[Address, ...]: ... def __init__(self, display_name: str | None = ..., addresses: Iterable[Address] | None = ...) -> None: ... def __str__(self) -> str: ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index a1749a4cfc2e..a860f12de9dc 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -2,14 +2,14 @@ from email.charset import Charset from email.contentmanager import ContentManager from email.errors import MessageDefect from email.policy import Policy -from typing import Any, Generator, Iterator, List, Optional, Sequence, Tuple, TypeVar, Union +from typing import Any, Generator, Iterator, Optional, Sequence, TypeVar, Union _T = TypeVar("_T") -_PayloadType = Union[List[Message], str, bytes] +_PayloadType = Union[list[Message], str, bytes] _CharsetType = Union[Charset, str, None] -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] -_ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] +_ParamType = Union[str, tuple[Optional[str], Optional[str], str]] _HeaderType = Any class Message: diff --git a/stdlib/email/mime/application.pyi b/stdlib/email/mime/application.pyi index 11fc470e9dd1..d176cd613e27 100644 --- a/stdlib/email/mime/application.pyi +++ b/stdlib/email/mime/application.pyi @@ -1,8 +1,8 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEApplication(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/audio.pyi b/stdlib/email/mime/audio.pyi index ee6de410bf53..38657c932e2f 100644 --- a/stdlib/email/mime/audio.pyi +++ b/stdlib/email/mime/audio.pyi @@ -1,8 +1,8 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEAudio(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/base.pyi b/stdlib/email/mime/base.pyi index b88dfd492554..cb655607b032 100644 --- a/stdlib/email/mime/base.pyi +++ b/stdlib/email/mime/base.pyi @@ -1,8 +1,8 @@ import email.message from email.policy import Policy -from typing import Optional, Tuple, Union +from typing import Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEBase(email.message.Message): def __init__(self, _maintype: str, _subtype: str, *, policy: Policy | None = ..., **_params: _ParamsType) -> None: ... diff --git a/stdlib/email/mime/image.pyi b/stdlib/email/mime/image.pyi index 886aa74d5fe5..0325d9e594da 100644 --- a/stdlib/email/mime/image.pyi +++ b/stdlib/email/mime/image.pyi @@ -1,8 +1,8 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEImage(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/multipart.pyi b/stdlib/email/mime/multipart.pyi index 6259ddf5ab8f..6c316c055329 100644 --- a/stdlib/email/mime/multipart.pyi +++ b/stdlib/email/mime/multipart.pyi @@ -1,9 +1,9 @@ from email.message import Message from email.mime.base import MIMEBase from email.policy import Policy -from typing import Optional, Sequence, Tuple, Union +from typing import Optional, Sequence, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEMultipart(MIMEBase): def __init__( diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index 3c07e98079fc..728a5a53f230 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -1,10 +1,10 @@ import datetime import sys from email.charset import Charset -from typing import Optional, Tuple, Union, overload +from typing import Optional, Union, overload -_ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] -_PDTZ = Tuple[int, int, int, int, int, int, int, int, int, Optional[int]] +_ParamType = Union[str, tuple[Optional[str], Optional[str], str]] +_PDTZ = tuple[int, int, int, int, int, int, int, int, int, Optional[int]] def quote(str: str) -> str: ... def unquote(str: str) -> str: ... diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index e8846ba5293e..a80a022ad6f5 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -3,7 +3,7 @@ import types from abc import ABCMeta from builtins import property as _builtins_property from collections.abc import Iterable, Iterator, Mapping -from typing import Any, Dict, Tuple, Type, TypeVar, Union, overload +from typing import Any, Type, TypeVar, Union, overload _T = TypeVar("_T") _S = TypeVar("_S", bound=Type[Enum]) @@ -21,7 +21,7 @@ _S = TypeVar("_S", bound=Type[Enum]) # _EnumNames = Union[str, Iterable[str], Iterable[Iterable[Union[str, Any]]], Mapping[str, Any]] -class _EnumDict(Dict[str, Any]): +class _EnumDict(dict[str, Any]): def __init__(self) -> None: ... # Note: EnumMeta actually subclasses type directly, not ABCMeta. @@ -34,7 +34,7 @@ class EnumMeta(ABCMeta): def __new__( metacls: Type[_T], cls: str, - bases: Tuple[type, ...], + bases: tuple[type, ...], classdict: _EnumDict, *, boundary: FlagBoundary | None = ..., @@ -42,9 +42,9 @@ class EnumMeta(ABCMeta): **kwds: Any, ) -> _T: ... elif sys.version_info >= (3, 9): - def __new__(metacls: Type[_T], cls: str, bases: Tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> _T: ... # type: ignore + def __new__(metacls: Type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> _T: ... # type: ignore else: - def __new__(metacls: Type[_T], cls: str, bases: Tuple[type, ...], classdict: _EnumDict) -> _T: ... # type: ignore + def __new__(metacls: Type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> _T: ... # type: ignore def __iter__(self: Type[_T]) -> Iterator[_T]: ... def __reversed__(self: Type[_T]) -> Iterator[_T]: ... def __contains__(self: Type[Any], member: object) -> bool: ... diff --git a/stdlib/formatter.pyi b/stdlib/formatter.pyi index 7c3b97688dbd..f5d8348d08a1 100644 --- a/stdlib/formatter.pyi +++ b/stdlib/formatter.pyi @@ -1,8 +1,8 @@ -from typing import IO, Any, Iterable, Tuple +from typing import IO, Any, Iterable AS_IS: None -_FontType = Tuple[str, bool, bool, bool] -_StylesType = Tuple[Any, ...] +_FontType = tuple[str, bool, bool, bool] +_StylesType = tuple[Any, ...] class NullFormatter: writer: NullWriter | None @@ -68,7 +68,7 @@ class NullWriter: def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... def new_spacing(self, spacing: str | None) -> None: ... - def new_styles(self, styles: Tuple[Any, ...]) -> None: ... + def new_styles(self, styles: tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... @@ -81,7 +81,7 @@ class AbstractWriter(NullWriter): def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... def new_spacing(self, spacing: str | None) -> None: ... - def new_styles(self, styles: Tuple[Any, ...]) -> None: ... + def new_styles(self, styles: tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index 745669ce0f18..f84199c168e9 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -3,7 +3,7 @@ from _typeshed import Self, SupportsRead, SupportsReadline from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Callable, Iterable, Iterator, TextIO, Tuple, Type +from typing import Any, Callable, Iterable, Iterator, TextIO, Type from typing_extensions import Literal MSG_OOB: int @@ -18,7 +18,7 @@ class error_temp(Error): ... class error_perm(Error): ... class error_proto(Error): ... -all_errors: Tuple[Type[Exception], ...] +all_errors: tuple[Type[Exception], ...] class FTP: debugging: int diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 78ed5992a468..3d1041d06f05 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -1,7 +1,7 @@ import sys import types from _typeshed import SupportsAllComparisons, SupportsItems -from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, Tuple, Type, TypeVar, overload +from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, Type, TypeVar, overload from typing_extensions import final if sys.version_info >= (3, 9): @@ -49,7 +49,7 @@ def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], SupportsAllComp class partial(Generic[_T]): func: Callable[..., _T] - args: Tuple[Any, ...] + args: tuple[Any, ...] keywords: dict[str, Any] def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> _T: ... @@ -61,7 +61,7 @@ _Descriptor = Any class partialmethod(Generic[_T]): func: Callable[..., _T] | _Descriptor - args: Tuple[Any, ...] + args: tuple[Any, ...] keywords: dict[str, Any] @overload def __init__(self, __func: Callable[..., _T], *args: Any, **keywords: Any) -> None: ... @@ -120,10 +120,10 @@ if sys.version_info >= (3, 9): def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ... def _make_key( - args: Tuple[Hashable, ...], + args: tuple[Hashable, ...], kwds: SupportsItems[Any, Any], typed: bool, - kwd_mark: Tuple[object, ...] = ..., + kwd_mark: tuple[object, ...] = ..., fasttypes: set[type] = ..., tuple: type = ..., type: Any = ..., diff --git a/stdlib/genericpath.pyi b/stdlib/genericpath.pyi index c9829ae350f1..f9518750d3f1 100644 --- a/stdlib/genericpath.pyi +++ b/stdlib/genericpath.pyi @@ -1,6 +1,6 @@ import os from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRichComparisonT -from typing import Sequence, Tuple, overload +from typing import Sequence, overload from typing_extensions import Literal # All overloads can return empty string. Ideally, Literal[""] would be a valid @@ -13,7 +13,7 @@ def commonprefix(m: Sequence[BytesPath]) -> bytes | Literal[""]: ... @overload def commonprefix(m: Sequence[list[SupportsRichComparisonT]]) -> Sequence[SupportsRichComparisonT]: ... @overload -def commonprefix(m: Sequence[Tuple[SupportsRichComparisonT, ...]]) -> Sequence[SupportsRichComparisonT]: ... +def commonprefix(m: Sequence[tuple[SupportsRichComparisonT, ...]]) -> Sequence[SupportsRichComparisonT]: ... def exists(path: StrOrBytesPath | int) -> bool: ... def getsize(filename: StrOrBytesPath | int) -> int: ... def isfile(path: StrOrBytesPath | int) -> bool: ... diff --git a/stdlib/graphlib.pyi b/stdlib/graphlib.pyi index 0872af4a54a4..96d64cbce18c 100644 --- a/stdlib/graphlib.pyi +++ b/stdlib/graphlib.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsItems -from typing import Generic, Iterable, Tuple, TypeVar +from typing import Generic, Iterable, TypeVar _T = TypeVar("_T") @@ -10,7 +10,7 @@ class TopologicalSorter(Generic[_T]): def is_active(self) -> bool: ... def __bool__(self) -> bool: ... def done(self, *nodes: _T) -> None: ... - def get_ready(self) -> Tuple[_T, ...]: ... + def get_ready(self) -> tuple[_T, ...]: ... def static_order(self) -> Iterable[_T]: ... class CycleError(ValueError): ... diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 33f2a9774be8..52be219f354f 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -1,9 +1,9 @@ from _typeshed import structseq -from typing import Any, List, Optional, Tuple +from typing import Any, Optional from typing_extensions import final @final -class struct_group(structseq[Any], Tuple[str, Optional[str], int, List[str]]): +class struct_group(structseq[Any], tuple[str, Optional[str], int, list[str]]): @property def gr_name(self) -> str: ... @property diff --git a/stdlib/html/parser.pyi b/stdlib/html/parser.pyi index 66515cad03ba..60e0de51d3b8 100644 --- a/stdlib/html/parser.pyi +++ b/stdlib/html/parser.pyi @@ -1,5 +1,5 @@ from _markupbase import ParserBase -from typing import Pattern, Tuple +from typing import Pattern class HTMLParser(ParserBase): def __init__(self, *, convert_charrefs: bool = ...) -> None: ... @@ -18,7 +18,7 @@ class HTMLParser(ParserBase): def handle_decl(self, decl: str) -> None: ... def handle_pi(self, data: str) -> None: ... def unknown_decl(self, data: str) -> None: ... - CDATA_CONTENT_ELEMENTS: Tuple[str, ...] + CDATA_CONTENT_ELEMENTS: tuple[str, ...] def check_for_whole_start_tag(self, i: int) -> int: ... # undocumented def clear_cdata_mode(self) -> None: ... # undocumented def goahead(self, end: bool) -> None: ... # undocumented diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index f37fb19cebe9..6bfa7f385e69 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrPath from http.client import HTTPResponse -from typing import ClassVar, Iterable, Iterator, Pattern, Sequence, Tuple, TypeVar, overload +from typing import ClassVar, Iterable, Iterator, Pattern, Sequence, TypeVar, overload from urllib.request import Request _T = TypeVar("_T") @@ -102,10 +102,10 @@ class DefaultCookiePolicy(CookiePolicy): strict_ns_set_initial_dollar: bool = ..., strict_ns_set_path: bool = ..., ) -> None: ... - def blocked_domains(self) -> Tuple[str, ...]: ... + def blocked_domains(self) -> tuple[str, ...]: ... def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ... def is_blocked(self, domain: str) -> bool: ... - def allowed_domains(self) -> Tuple[str, ...] | None: ... + def allowed_domains(self) -> tuple[str, ...] | None: ... def set_allowed_domains(self, allowed_domains: Sequence[str] | None) -> None: ... def is_not_allowed(self, domain: str) -> bool: ... def set_ok_version(self, cookie: Cookie, request: Request) -> bool: ... # undocumented diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 4244c0c6aa0d..211fd37662d4 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, Generic, Iterable, Mapping, TypeVar, Union, overload +from typing import Any, Generic, Iterable, Mapping, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -18,7 +18,7 @@ def _unquote(str: str) -> str: ... class CookieError(Exception): ... -class Morsel(Dict[str, Any], Generic[_T]): +class Morsel(dict[str, Any], Generic[_T]): value: str coded_value: _T key: str @@ -40,7 +40,7 @@ class Morsel(Dict[str, Any], Generic[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]): +class BaseCookie(dict[str, Morsel[_T]], Generic[_T]): def __init__(self, input: _DataType | None = ...) -> None: ... def value_decode(self, val: str) -> _T: ... def value_encode(self, val: _T) -> str: ... diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index a9f19048c9ae..1b2774d8fde0 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -5,14 +5,14 @@ from _typeshed import Self from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Callable, List, Pattern, Tuple, Type, Union +from typing import IO, Any, Callable, Pattern, Type, Union from typing_extensions import Literal # TODO: Commands should use their actual return types, not this type alias. # E.g. Tuple[Literal["OK"], List[bytes]] -_CommandResults = Tuple[str, List[Any]] +_CommandResults = tuple[str, list[Any]] -_AnyResponseData = Union[List[None], List[Union[bytes, Tuple[bytes, bytes]]]] +_AnyResponseData = Union[list[None], list[Union[bytes, tuple[bytes, bytes]]]] _list = list # conflicts with a method named "list" diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index c5d9efba9ad6..a9e223149b52 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -7,7 +7,7 @@ from email.message import Message from importlib.abc import MetaPathFinder from os import PathLike from pathlib import Path -from typing import Any, ClassVar, Iterable, NamedTuple, Pattern, Tuple, overload +from typing import Any, ClassVar, Iterable, NamedTuple, Pattern, overload if sys.version_info >= (3, 10): from importlib.metadata._meta import PackageMetadata as PackageMetadata @@ -101,6 +101,6 @@ if sys.version_info >= (3, 8): ) -> Iterable[Distribution]: ... def metadata(distribution_name: str) -> Message: ... def version(distribution_name: str) -> str: ... - def entry_points() -> dict[str, Tuple[EntryPoint, ...]]: ... + def entry_points() -> dict[str, tuple[EntryPoint, ...]]: ... def files(distribution_name: str) -> list[PackagePath] | None: ... def requires(distribution_name: str) -> list[str] | None: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 35c9149c01f0..d4c81f474db4 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -23,7 +23,7 @@ from types import ( if sys.version_info >= (3, 7): from types import ClassMethodDescriptorType, WrapperDescriptorType, MemberDescriptorType, MethodDescriptorType -from typing import Any, ClassVar, NamedTuple, Protocol, Tuple, Type, TypeVar, Union +from typing import Any, ClassVar, NamedTuple, Protocol, Type, TypeVar, Union from typing_extensions import Literal, TypeGuard # @@ -234,7 +234,7 @@ class Parameter: class BoundArguments: arguments: OrderedDict[str, Any] - args: Tuple[Any, ...] + args: tuple[Any, ...] kwargs: dict[str, Any] signature: Signature def __init__(self, signature: Signature, arguments: OrderedDict[str, Any]) -> None: ... @@ -262,14 +262,14 @@ if sys.version_info < (3, 11): args: list[str] varargs: str | None keywords: str | None - defaults: Tuple[Any, ...] + defaults: tuple[Any, ...] def getargspec(func: object) -> ArgSpec: ... class FullArgSpec(NamedTuple): args: list[str] varargs: str | None varkw: str | None - defaults: Tuple[Any, ...] | None + defaults: tuple[Any, ...] | None kwonlyargs: list[str] kwonlydefaults: dict[str, Any] | None annotations: dict[str, Any] @@ -291,7 +291,7 @@ if sys.version_info < (3, 11): args: list[str], varargs: str | None = ..., varkw: str | None = ..., - defaults: Tuple[Any, ...] | None = ..., + defaults: tuple[Any, ...] | None = ..., kwonlyargs: Sequence[str] | None = ..., kwonlydefaults: dict[str, Any] | None = ..., annotations: dict[str, Any] = ..., @@ -313,7 +313,7 @@ def formatargvalues( formatvarkw: Callable[[str], str] | None = ..., formatvalue: Callable[[Any], str] | None = ..., ) -> str: ... -def getmro(cls: type) -> Tuple[type, ...]: ... +def getmro(cls: type) -> tuple[type, ...]: ... def getcallargs(__func: Callable[..., Any], *args: Any, **kwds: Any) -> dict[str, Any]: ... class ClosureVars(NamedTuple): diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 29c42ed9da71..50452917c6f3 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -4,7 +4,7 @@ import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer from os import _Opener from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, TextIO, Tuple, Type +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, TextIO, Type DEFAULT_BUFFER_SIZE: int @@ -119,7 +119,7 @@ class BufferedRWPair(BufferedIOBase): class TextIOBase(IOBase): encoding: str errors: str | None - newlines: str | Tuple[str, ...] | None + newlines: str | tuple[str, ...] | None def __iter__(self) -> Iterator[str]: ... # type: ignore[override] def __next__(self) -> str: ... # type: ignore[override] def detach(self) -> BinaryIO: ... @@ -179,4 +179,4 @@ class IncrementalNewlineDecoder(codecs.IncrementalDecoder): def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ... def decode(self, input: bytes | str, final: bool = ...) -> str: ... @property - def newlines(self) -> str | Tuple[str, ...] | None: ... + def newlines(self) -> str | tuple[str, ...] | None: ... diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 1ff7ffc181ed..a5a7f4f1b62f 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -9,7 +9,6 @@ from typing import ( SupportsComplex, SupportsFloat, SupportsInt, - Tuple, Type, TypeVar, Union, @@ -91,7 +90,7 @@ class filterfalse(Iterator[_T], Generic[_T]): _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") -class groupby(Iterator[Tuple[_T, Iterator[_S]]], Generic[_T, _S]): +class groupby(Iterator[tuple[_T, Iterator[_S]]], Generic[_T, _S]): @overload def __new__(cls, iterable: Iterable[_T1], key: None = ...) -> groupby[_T1, _T1]: ... @overload @@ -117,7 +116,7 @@ class takewhile(Iterator[_T], Generic[_T]): def __iter__(self) -> Iterator[_T]: ... def __next__(self) -> _T: ... -def tee(__iterable: Iterable[_T], __n: int = ...) -> Tuple[Iterator[_T], ...]: ... +def tee(__iterable: Iterable[_T], __n: int = ...) -> tuple[Iterator[_T], ...]: ... class zip_longest(Iterator[Any]): def __init__(self, *p: Iterable[Any], fillvalue: Any = ...) -> None: ... @@ -170,18 +169,18 @@ class product(Iterator[_T_co], Generic[_T_co]): __iter6: Iterable[Any], __iter7: Iterable[Any], *iterables: Iterable[Any], - ) -> product[Tuple[Any, ...]]: ... + ) -> product[tuple[Any, ...]]: ... @overload - def __new__(cls, *iterables: Iterable[_T1], repeat: int) -> product[Tuple[_T1, ...]]: ... + def __new__(cls, *iterables: Iterable[_T1], repeat: int) -> product[tuple[_T1, ...]]: ... @overload - def __new__(cls, *iterables: Iterable[Any], repeat: int = ...) -> product[Tuple[Any, ...]]: ... + def __new__(cls, *iterables: Iterable[Any], repeat: int = ...) -> product[tuple[Any, ...]]: ... def __iter__(self) -> Iterator[_T_co]: ... def __next__(self) -> _T_co: ... -class permutations(Iterator[Tuple[_T, ...]], Generic[_T]): +class permutations(Iterator[tuple[_T, ...]], Generic[_T]): def __init__(self, iterable: Iterable[_T], r: int | None = ...) -> None: ... - def __iter__(self) -> Iterator[Tuple[_T, ...]]: ... - def __next__(self) -> Tuple[_T, ...]: ... + def __iter__(self) -> Iterator[tuple[_T, ...]]: ... + def __next__(self) -> tuple[_T, ...]: ... class combinations(Iterator[_T_co], Generic[_T_co]): @overload @@ -193,14 +192,14 @@ class combinations(Iterator[_T_co], Generic[_T_co]): @overload def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> combinations[tuple[_T, _T, _T, _T, _T]]: ... @overload - def __new__(cls, iterable: Iterable[_T], r: int) -> combinations[Tuple[_T, ...]]: ... + def __new__(cls, iterable: Iterable[_T], r: int) -> combinations[tuple[_T, ...]]: ... def __iter__(self) -> Iterator[_T_co]: ... def __next__(self) -> _T_co: ... -class combinations_with_replacement(Iterator[Tuple[_T, ...]], Generic[_T]): +class combinations_with_replacement(Iterator[tuple[_T, ...]], Generic[_T]): def __init__(self, iterable: Iterable[_T], r: int) -> None: ... - def __iter__(self) -> Iterator[Tuple[_T, ...]]: ... - def __next__(self) -> Tuple[_T, ...]: ... + def __iter__(self) -> Iterator[tuple[_T, ...]]: ... + def __next__(self) -> tuple[_T, ...]: ... if sys.version_info >= (3, 10): class pairwise(Iterator[_T_co], Generic[_T_co]): diff --git a/stdlib/lib2to3/pgen2/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index 48cb4eae916c..77cc6aec3d67 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -1,10 +1,10 @@ from _typeshed import StrPath -from typing import Dict, List, Optional, Tuple, TypeVar +from typing import Optional, TypeVar _P = TypeVar("_P") -_Label = Tuple[int, Optional[str]] -_DFA = List[List[Tuple[int, int]]] -_DFAS = Tuple[_DFA, Dict[int, int]] +_Label = tuple[int, Optional[str]] +_DFA = list[list[tuple[int, int]]] +_DFAS = tuple[_DFA, dict[int, int]] class Grammar: symbol2number: dict[str, int] diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index e96a0d8c8eb3..3679caee9314 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,9 +1,9 @@ from lib2to3.pgen2.token import * # noqa -from typing import Callable, Iterable, Iterator, Tuple +from typing import Callable, Iterable, Iterator -_Coord = Tuple[int, int] +_Coord = tuple[int, int] _TokenEater = Callable[[int, str, _Coord, _Coord, str], None] -_TokenInfo = Tuple[int, str, _Coord, _Coord, str] +_TokenInfo = tuple[int, str, _Coord, _Coord, str] class TokenError(Exception): ... class StopTokenizing(Exception): ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index eab82cbc200d..2ed9a2788d84 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,11 +1,11 @@ from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Iterator, Optional, TypeVar, Union _P = TypeVar("_P") _NL = Union[Node, Leaf] -_Context = Tuple[str, int, int] -_Results = Dict[str, _NL] -_RawNode = Tuple[int, str, _Context, Optional[List[_NL]]] +_Context = tuple[str, int, int] +_Results = dict[str, _NL] +_RawNode = tuple[int, str, _Context, Optional[list[_NL]]] _Convert = Callable[[Grammar, _RawNode], Any] HUGE: int diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index a66614bf6b37..e53d3efea5b2 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,7 +1,7 @@ -from typing import Any, Dict, List, Protocol, Tuple +from typing import Any, Protocol -_ModuleGlobals = Dict[str, Any] -_ModuleMetadata = Tuple[int, float, List[str], str] +_ModuleGlobals = dict[str, Any] +_ModuleMetadata = tuple[int, float, list[str], str] class _SourceLoader(Protocol): def __call__(self) -> str | None: ... diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index c6289f27da2c..f3942102716a 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -4,7 +4,7 @@ import sys # as a type annotation or type alias. from builtins import str as _str from decimal import Decimal -from typing import Any, Callable, Iterable, Mapping, Sequence, Tuple +from typing import Any, Callable, Iterable, Mapping, Sequence CODESET: int D_T_FMT: int @@ -82,7 +82,7 @@ class Error(Exception): ... def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... def localeconv() -> Mapping[_str, int | _str | list[int]]: ... def nl_langinfo(__key: int) -> _str: ... -def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> tuple[_str | None, _str | None]: ... +def getdefaultlocale(envvars: tuple[_str, ...] = ...) -> tuple[_str | None, _str | None]: ... def getlocale(category: int = ...) -> Sequence[_str]: ... def getpreferredencoding(do_setlocale: bool = ...) -> _str: ... def normalize(localename: _str) -> _str: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 7d4fa279155c..d580c668181b 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -6,12 +6,12 @@ from io import TextIOWrapper from string import Template from time import struct_time from types import FrameType, TracebackType -from typing import Any, ClassVar, Generic, Optional, Pattern, TextIO, Tuple, Type, TypeVar, Union, overload +from typing import Any, ClassVar, Generic, Optional, Pattern, TextIO, Type, TypeVar, Union, overload from typing_extensions import Literal -_SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, Optional[TracebackType]], Tuple[None, None, None]] +_SysExcInfoType = Union[tuple[Type[BaseException], BaseException, Optional[TracebackType]], tuple[None, None, None]] _ExcInfoType = Union[None, bool, _SysExcInfoType, BaseException] -_ArgsType = Union[Tuple[object, ...], Mapping[str, object]] +_ArgsType = Union[tuple[object, ...], Mapping[str, object]] _FilterType = Union[Filter, Callable[[LogRecord], int]] _Level = Union[int, str] _FormatStyle = Literal["%", "{", "$"] diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index 9eaa771ed3d3..56218d1370fe 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -1,6 +1,6 @@ -from typing import Dict, Mapping, Sequence, Union +from typing import Mapping, Sequence, Union -_Cap = Dict[str, Union[str, int]] +_Cap = dict[str, Union[str, int]] def findmatch( caps: Mapping[str, list[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index 90c87d2cf385..eefd5439ee28 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import IO, Sequence, Tuple +from typing import IO, Sequence if sys.version_info >= (3, 8): def guess_type(url: StrPath, strict: bool = ...) -> tuple[str | None, str | None]: ... @@ -26,7 +26,7 @@ class MimeTypes: encodings_map: dict[str, str] types_map: tuple[dict[str, str], dict[str, str]] types_map_inv: tuple[dict[str, str], dict[str, str]] - def __init__(self, filenames: Tuple[str, ...] = ..., strict: bool = ...) -> None: ... + def __init__(self, filenames: tuple[str, ...] = ..., strict: bool = ...) -> None: ... def guess_extension(self, type: str, strict: bool = ...) -> str | None: ... def guess_type(self, url: str, strict: bool = ...) -> tuple[str | None, str | None]: ... def guess_all_extensions(self, type: str, strict: bool = ...) -> list[str]: ... diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index e77a108e9525..3e7694ccffc9 100644 --- a/stdlib/modulefinder.pyi +++ b/stdlib/modulefinder.pyi @@ -1,6 +1,6 @@ import sys from types import CodeType -from typing import IO, Any, Container, Iterable, Iterator, Sequence, Tuple +from typing import IO, Any, Container, Iterable, Iterator, Sequence LOAD_CONST: int # undocumented IMPORT_NAME: int # undocumented @@ -62,7 +62,7 @@ class ModuleFinder: def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented def import_module(self, partname: str, fqname: str, parent: Module) -> Module | None: ... # undocumented def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: tuple[str, str, str]) -> Module: ... # undocumented - def scan_opcodes(self, co: CodeType) -> Iterator[tuple[str, Tuple[Any, ...]]]: ... # undocumented + def scan_opcodes(self, co: CodeType) -> Iterator[tuple[str, tuple[Any, ...]]]: ... # undocumented def scan_code(self, co: CodeType, m: Module) -> None: ... # undocumented def load_package(self, fqname: str, pathname: str) -> Module: ... # undocumented def add_module(self, fqname: str) -> Module: ... # undocumented diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 4e1a7e6a7c02..b5866492a097 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -1,6 +1,6 @@ import sys from types import ModuleType -from typing import Any, Container, Iterable, Sequence, Tuple, Type +from typing import Any, Container, Iterable, Sequence, Type from typing_extensions import Literal if sys.platform == "win32": @@ -37,7 +37,7 @@ if sys.platform == "win32": seqno: int | Type[_Unspecified] = ..., cond: str | Type[_Unspecified] = ..., ) -> None: ... - def add_data(db: _Database, table: str, values: Iterable[Tuple[Any, ...]]) -> None: ... + def add_data(db: _Database, table: str, values: Iterable[tuple[Any, ...]]) -> None: ... def add_stream(db: _Database, name: str, path: str) -> None: ... def init_database( name: str, schema: ModuleType, ProductName: str, ProductCode: str, ProductVersion: str, Manufacturer: str diff --git a/stdlib/msilib/sequence.pyi b/stdlib/msilib/sequence.pyi index 123d232886f7..87dff754009d 100644 --- a/stdlib/msilib/sequence.pyi +++ b/stdlib/msilib/sequence.pyi @@ -1,9 +1,9 @@ import sys -from typing import List, Optional, Tuple +from typing import Optional if sys.platform == "win32": - _SequenceType = List[Tuple[str, Optional[str], int]] + _SequenceType = list[tuple[str, Optional[str], int]] AdminExecuteSequence: _SequenceType AdminUISequence: _SequenceType diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index 56ea5c7c0b0b..56db4594edc0 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -2,13 +2,13 @@ import socket import sys import types from _typeshed import Self -from typing import Any, Iterable, Tuple, Type, Union +from typing import Any, Iterable, Type, Union if sys.version_info >= (3, 8): from typing import SupportsIndex # https://docs.python.org/3/library/multiprocessing.html#address-formats -_Address = Union[str, Tuple[str, int]] +_Address = Union[str, tuple[str, int]] class _ConnectionBase: if sys.version_info >= (3, 8): diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index 4ef3d095911f..0f7a20693a85 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -1,11 +1,11 @@ from _typeshed import Self from queue import Queue from types import TracebackType -from typing import Any, Tuple, Type, Union +from typing import Any, Type, Union families: list[None] -_Address = Union[str, Tuple[str, int]] +_Address = Union[str, tuple[str, int]] class Connection(object): _in: Any diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 6d406bc4e4da..280a0b93e882 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -4,7 +4,7 @@ import queue import sys import threading from contextlib import AbstractContextManager -from typing import Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Tuple, TypeVar +from typing import Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, TypeVar from .connection import Connection from .context import BaseContext @@ -52,7 +52,7 @@ class BaseProxy(object): manager_owned: bool = ..., ) -> None: ... def __deepcopy__(self, memo: Any | None) -> Any: ... - def _callmethod(self, methodname: str, args: Tuple[Any, ...] = ..., kwds: dict[Any, Any] = ...) -> None: ... + def _callmethod(self, methodname: str, args: tuple[Any, ...] = ..., kwds: dict[Any, Any] = ...) -> None: ... def _getvalue(self) -> Any: ... def __reduce__(self) -> tuple[Any, tuple[Any, Any, str, dict[Any, Any]]]: ... diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index 40fb8ef170ab..2e52981a56b7 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self from contextlib import AbstractContextManager -from typing import Any, Callable, Generic, Iterable, Iterator, List, Mapping, TypeVar +from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias @@ -32,7 +32,7 @@ class ApplyResult(Generic[_T]): # alias created during issue #17805 AsyncResult = ApplyResult -class MapResult(ApplyResult[List[_T]]): +class MapResult(ApplyResult[list[_T]]): if sys.version_info >= (3, 8): def __init__( self, diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index 32c22d19f6e5..4746c78b1b4d 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -1,17 +1,17 @@ import sys -from typing import Any, Callable, Mapping, Tuple +from typing import Any, Callable, Mapping class BaseProcess: name: str daemon: bool authkey: bytes - _identity: Tuple[int, ...] # undocumented + _identity: tuple[int, ...] # undocumented def __init__( self, group: None = ..., target: Callable[..., Any] | None = ..., name: str | None = ..., - args: Tuple[Any, ...] = ..., + args: tuple[Any, ...] = ..., kwargs: Mapping[str, Any] = ..., *, daemon: bool | None = ..., diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index 6ffc2542087a..1b51da38bc43 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Generic, Iterable, Tuple, TypeVar +from typing import Any, Generic, Iterable, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias @@ -23,7 +23,7 @@ if sys.version_info >= (3, 8): def __init__(self, sequence: Iterable[_SLT] | None = ..., *, name: str | None = ...) -> None: ... def __getitem__(self, position: int) -> _SLT: ... def __setitem__(self, position: int, value: _SLT) -> None: ... - def __reduce__(self: _S) -> tuple[_S, Tuple[_SLT, ...]]: ... + def __reduce__(self: _S) -> tuple[_S, tuple[_SLT, ...]]: ... def __len__(self) -> int: ... @property def format(self) -> str: ... diff --git a/stdlib/netrc.pyi b/stdlib/netrc.pyi index b8eac307740a..7c1c2068aff6 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import Optional, Tuple +from typing import Optional class NetrcParseError(Exception): filename: str | None @@ -8,7 +8,7 @@ class NetrcParseError(Exception): def __init__(self, msg: str, filename: StrOrBytesPath | None = ..., lineno: int | None = ...) -> None: ... # (login, account, password) tuple -_NetrcTuple = Tuple[str, Optional[str], Optional[str]] +_NetrcTuple = tuple[str, Optional[str], Optional[str]] class netrc: hosts: dict[str, _NetrcTuple] diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 508b5f679bc3..f0a0fb42da5c 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -3,7 +3,7 @@ import socket import ssl import sys from _typeshed import Self -from typing import IO, Any, Iterable, NamedTuple, Tuple, Union +from typing import IO, Any, Iterable, NamedTuple, Union _File = Union[IO[bytes], bytes, str, None] @@ -72,7 +72,7 @@ class _NNTPBase: def xhdr(self, hdr: str, str: Any, *, file: _File = ...) -> tuple[str, _list[str]]: ... def xover(self, start: int, end: int, *, file: _File = ...) -> tuple[str, _list[tuple[int, dict[str, str]]]]: ... def over( - self, message_spec: None | str | _list[Any] | Tuple[Any, ...], *, file: _File = ... + self, message_spec: None | str | _list[Any] | tuple[Any, ...], *, file: _File = ... ) -> tuple[str, _list[tuple[int, dict[str, str]]]]: ... if sys.version_info < (3, 9): def xgtitle(self, group: str, *, file: _File = ...) -> tuple[str, _list[tuple[str, str]]]: ... diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index b8ea9d2fff38..416bc5446cc5 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -1,6 +1,6 @@ -from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, Tuple, Type, overload +from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, Type, overload -NO_DEFAULT: Tuple[str, ...] +NO_DEFAULT: tuple[str, ...] SUPPRESS_HELP: str SUPPRESS_USAGE: str @@ -72,14 +72,14 @@ class TitledHelpFormatter(HelpFormatter): def format_usage(self, usage: str) -> str: ... class Option: - ACTIONS: Tuple[str, ...] - ALWAYS_TYPED_ACTIONS: Tuple[str, ...] + ACTIONS: tuple[str, ...] + ALWAYS_TYPED_ACTIONS: tuple[str, ...] ATTRS: list[str] CHECK_METHODS: list[Callable[..., Any]] | None - CONST_ACTIONS: Tuple[str, ...] - STORE_ACTIONS: Tuple[str, ...] - TYPED_ACTIONS: Tuple[str, ...] - TYPES: Tuple[str, ...] + CONST_ACTIONS: tuple[str, ...] + STORE_ACTIONS: tuple[str, ...] + TYPED_ACTIONS: tuple[str, ...] + TYPES: tuple[str, ...] TYPE_CHECKER: dict[str, Callable[..., Any]] _long_opts: list[str] _short_opts: list[str] @@ -89,7 +89,7 @@ class Option: nargs: int type: Any callback: Callable[..., Any] | None - callback_args: Tuple[Any, ...] | None + callback_args: tuple[Any, ...] | None callback_kwargs: dict[str, Any] | None help: str | None metavar: str | None diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 5d4b6b246662..709902e86d0d 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -24,13 +24,11 @@ from typing import ( Generic, Iterable, Iterator, - List, Mapping, MutableMapping, NoReturn, Protocol, Sequence, - Tuple, TypeVar, Union, overload, @@ -284,7 +282,7 @@ TMP_MAX: int # Undocumented, but used by tempfile # ----- os classes (structures) ----- @final -class stat_result(structseq[float], Tuple[int, int, int, int, int, int, int, float, float, float]): +class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, float, float, float]): # The constructor of this class takes an iterable of variable length (though it must be at least 10). # # However, this class behaves like a tuple of 10 elements, @@ -383,7 +381,7 @@ class DirEntry(Generic[AnyStr]): if sys.version_info >= (3, 7): @final - class statvfs_result(structseq[int], Tuple[int, int, int, int, int, int, int, int, int, int, int]): + class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int, int]): @property def f_bsize(self) -> int: ... @property @@ -409,7 +407,7 @@ if sys.version_info >= (3, 7): else: @final - class statvfs_result(structseq[int], Tuple[int, int, int, int, int, int, int, int, int, int]): + class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int]): @property def f_bsize(self) -> int: ... @property @@ -447,7 +445,7 @@ def getppid() -> int: ... def strerror(__code: int) -> str: ... def umask(__mask: int) -> int: ... @final -class uname_result(structseq[str], Tuple[str, str, str, str, str]): +class uname_result(structseq[str], tuple[str, str, str, str, str]): @property def sysname(self) -> str: ... @property @@ -639,7 +637,7 @@ if sys.platform != "win32": def writev(__fd: int, __buffers: Sequence[bytes]) -> int: ... @final -class terminal_size(structseq[int], Tuple[int, int]): +class terminal_size(structseq[int], tuple[int, int]): @property def columns(self) -> int: ... @property @@ -813,14 +811,14 @@ def execlpe(file: StrOrBytesPath, __arg0: StrOrBytesPath, *args: Any) -> NoRetur # 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[StrOrBytesPath, ...], - 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]]], + tuple[StrOrBytesPath, ...], + 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]]] @@ -858,7 +856,7 @@ else: def system(command: StrOrBytesPath) -> int: ... @final -class times_result(structseq[float], Tuple[float, float, float, float, float]): +class times_result(structseq[float], tuple[float, float, float, float, float]): @property def user(self) -> float: ... @property @@ -884,7 +882,7 @@ else: def wait() -> tuple[int, int]: ... # Unix only if sys.platform != "darwin": @final - class waitid_result(structseq[int], Tuple[int, int, int, int, int]): + class waitid_result(structseq[int], tuple[int, int, int, int, int]): @property def si_pid(self) -> int: ... @property @@ -912,7 +910,7 @@ else: argv: _ExecVArgs, env: _ExecEnv, *, - file_actions: Sequence[Tuple[Any, ...]] | None = ..., + file_actions: Sequence[tuple[Any, ...]] | None = ..., setpgroup: int | None = ..., resetids: bool = ..., setsid: bool = ..., @@ -925,7 +923,7 @@ else: argv: _ExecVArgs, env: _ExecEnv, *, - file_actions: Sequence[Tuple[Any, ...]] | None = ..., + file_actions: Sequence[tuple[Any, ...]] | None = ..., setpgroup: int | None = ..., resetids: bool = ..., setsid: bool = ..., @@ -936,7 +934,7 @@ else: if sys.platform != "win32": @final - class sched_param(structseq[int], Tuple[int]): + class sched_param(structseq[int], tuple[int]): def __new__(cls, sched_priority: int) -> sched_param: ... @property def sched_priority(self) -> int: ... diff --git a/stdlib/parser.pyi b/stdlib/parser.pyi index aecf3244ca8d..ab819a71a15f 100644 --- a/stdlib/parser.pyi +++ b/stdlib/parser.pyi @@ -1,13 +1,13 @@ from _typeshed import StrOrBytesPath from types import CodeType -from typing import Any, Sequence, Tuple +from typing import Any, Sequence def expr(source: str) -> STType: ... def suite(source: str) -> STType: ... def sequence2st(sequence: Sequence[Any]) -> STType: ... def tuple2st(sequence: Sequence[Any]) -> STType: ... def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... -def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any, ...]: ... +def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... def compilest(st: STType, filename: StrOrBytesPath = ...) -> CodeType: ... def isexpr(st: STType) -> bool: ... def issuite(st: STType) -> bool: ... @@ -19,4 +19,4 @@ class STType: def isexpr(self) -> bool: ... def issuite(self) -> bool: ... def tolist(self, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... - def totuple(self, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any, ...]: ... + def totuple(self, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 7d5f7ff2dba8..b541345c06d4 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -11,7 +11,7 @@ from _typeshed import ( from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from os import PathLike, stat_result from types import TracebackType -from typing import IO, Any, BinaryIO, Generator, Sequence, Tuple, Type, TypeVar, overload +from typing import IO, Any, BinaryIO, Generator, Sequence, Type, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -20,7 +20,7 @@ if sys.version_info >= (3, 9): _P = TypeVar("_P", bound=PurePath) class PurePath(PathLike[str]): - parts: Tuple[str, ...] + parts: tuple[str, ...] drive: str root: str anchor: str diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index cef1ffe9eb9b..46c349137459 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -1,11 +1,11 @@ import sys -from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Tuple, Type, Union +from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Type, Union from typing_extensions import final HIGHEST_PROTOCOL: int DEFAULT_PROTOCOL: int -bytes_types: Tuple[Type[Any], ...] # undocumented +bytes_types: tuple[Type[Any], ...] # undocumented class _ReadableFileobj(Protocol): def read(self, __n: int) -> bytes: ... @@ -58,10 +58,10 @@ class UnpicklingError(PickleError): ... _reducedtype = Union[ str, - Tuple[Callable[..., Any], Tuple[Any, ...]], - Tuple[Callable[..., Any], Tuple[Any, ...], Any], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]]], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]], + tuple[Callable[..., Any], tuple[Any, ...]], + tuple[Callable[..., Any], tuple[Any, ...], Any], + tuple[Callable[..., Any], tuple[Any, ...], Any, Optional[Iterator[Any]]], + tuple[Callable[..., Any], tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]], ] class Pickler: diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 9fa51a3848ee..da05ff0aadd3 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -1,7 +1,7 @@ -from typing import IO, Any, Callable, Iterator, MutableMapping, Tuple, Type +from typing import IO, Any, Callable, Iterator, MutableMapping, Type _Reader = Callable[[IO[bytes]], Any] -bytes_types: Tuple[Type[Any], ...] +bytes_types: tuple[Type[Any], ...] UP_TO_NEWLINE: int TAKEN_FROM_ARGUMENT1: int @@ -108,9 +108,9 @@ long4: ArgumentDescriptor class StackObject(object): name: str - obtype: Type[Any] | Tuple[Type[Any], ...] + obtype: Type[Any] | tuple[Type[Any], ...] doc: str - def __init__(self, name: str, obtype: Type[Any] | Tuple[Type[Any], ...], doc: str) -> None: ... + def __init__(self, name: str, obtype: Type[Any] | tuple[Type[Any], ...], doc: str) -> None: ... pyint: StackObject pylong: StackObject diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index aa8cea4dc01a..765a7a5ea5f9 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -4,7 +4,7 @@ if sys.version_info < (3, 8): import os DEV_NULL = os.devnull -from typing import NamedTuple, Tuple +from typing import NamedTuple if sys.version_info >= (3, 8): def libc_ver(executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> tuple[str, str]: ... @@ -17,11 +17,11 @@ if sys.version_info < (3, 8): distname: str = ..., version: str = ..., id: str = ..., - supported_dists: Tuple[str, ...] = ..., + supported_dists: tuple[str, ...] = ..., full_distribution_name: bool = ..., ) -> tuple[str, str, str]: ... def dist( - distname: str = ..., version: str = ..., id: str = ..., supported_dists: Tuple[str, ...] = ... + distname: str = ..., version: str = ..., id: str = ..., supported_dists: tuple[str, ...] = ... ) -> tuple[str, str, str]: ... def win32_ver(release: str = ..., version: str = ..., csd: str = ..., ptype: str = ...) -> tuple[str, str, str, str]: ... diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index 07b6963746be..7abe9dd2942b 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -1,7 +1,7 @@ import sys from datetime import datetime from enum import Enum -from typing import IO, Any, Dict as _Dict, Mapping, MutableMapping, Tuple, Type +from typing import IO, Any, Mapping, MutableMapping, Type class PlistFormat(Enum): FMT_XML: int @@ -31,7 +31,7 @@ else: ) -> Any: ... def dump( - value: Mapping[str, Any] | list[Any] | Tuple[Any, ...] | str | bool | float | bytes | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | datetime, fp: IO[bytes], *, fmt: PlistFormat = ..., @@ -39,7 +39,7 @@ def dump( skipkeys: bool = ..., ) -> None: ... def dumps( - value: Mapping[str, Any] | list[Any] | Tuple[Any, ...] | str | bool | float | bytes | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | datetime, *, fmt: PlistFormat = ..., skipkeys: bool = ..., @@ -53,7 +53,7 @@ if sys.version_info < (3, 9): def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... if sys.version_info < (3, 7): - class Dict(_Dict[str, Any]): + class Dict(dict[str, Any]): def __getattr__(self, attr: str) -> Any: ... def __setattr__(self, attr: str, value: Any) -> None: ... def __delattr__(self, attr: str) -> None: ... diff --git a/stdlib/poplib.pyi b/stdlib/poplib.pyi index 28fba4ce951f..028af412847b 100644 --- a/stdlib/poplib.pyi +++ b/stdlib/poplib.pyi @@ -1,8 +1,8 @@ import socket import ssl -from typing import Any, BinaryIO, List, Pattern, Tuple, overload +from typing import Any, BinaryIO, Pattern, overload -_LongResp = Tuple[bytes, List[bytes], int] +_LongResp = tuple[bytes, list[bytes], int] class error_proto(Exception): ... diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index cb0cbf7c9388..7581c0122c9c 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import Any, Callable, Tuple, TypeVar +from typing import Any, Callable, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( @@ -8,7 +8,7 @@ def runctx( _SelfT = TypeVar("_SelfT", bound=Profile) _T = TypeVar("_T") -_Label = Tuple[str, int, str] +_Label = tuple[str, int, str] class Profile: bias: int diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index e8256f9f98ab..6e008c823ff2 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import StrOrBytesPath from cProfile import Profile as _cProfile from profile import Profile -from typing import IO, Any, Iterable, Tuple, TypeVar, Union, overload +from typing import IO, Any, Iterable, TypeVar, Union, overload _Selector = Union[str, float, int] _T = TypeVar("_T", bound=Stats) @@ -33,7 +33,7 @@ class Stats: def get_top_level_stats(self) -> None: ... def add(self: _T, *arg_list: None | str | Profile | _cProfile | _T) -> _T: ... def dump_stats(self, filename: StrOrBytesPath) -> None: ... - def get_sort_arg_defs(self) -> dict[str, tuple[Tuple[tuple[int, int], ...], str]]: ... + def get_sort_arg_defs(self) -> dict[str, tuple[tuple[tuple[int, int], ...], str]]: ... @overload def sort_stats(self: _T, field: int) -> _T: ... @overload diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index a16175879f67..3ed6111bde31 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -1,9 +1,9 @@ from _typeshed import structseq -from typing import Any, Tuple +from typing import Any from typing_extensions import final @final -class struct_passwd(structseq[Any], Tuple[str, str, int, int, str, str, str]): +class struct_passwd(structseq[Any], tuple[str, str, int, int, str, str, str]): @property def pw_name(self) -> str: ... @property diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index b60ef8f9bcb3..a1d4359d28fc 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -1,10 +1,10 @@ from _typeshed import SupportsWrite from reprlib import Repr from types import MethodType, ModuleType, TracebackType -from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, Optional, Tuple, Type +from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, Optional, Type # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ -_Exc_Info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_Exc_Info = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] __author__: str __date__: str @@ -96,7 +96,7 @@ class HTMLDoc(Doc): methods: Mapping[str, str] = ..., ) -> str: ... def formattree( - self, tree: list[tuple[type, Tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ... + self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ... ) -> str: ... def docmodule(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... def docclass( @@ -143,7 +143,7 @@ class TextDoc(Doc): def indent(self, text: str, prefix: str = ...) -> str: ... def section(self, title: str, contents: str) -> str: ... def formattree( - self, tree: list[tuple[type, Tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ..., prefix: str = ... + self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ..., prefix: str = ... ) -> str: ... def docmodule(self, object: object, name: str | None = ..., mod: Any | None = ...) -> str: ... # type: ignore[override] def docclass(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... @@ -187,7 +187,7 @@ _list = list # "list" conflicts with method name class Helper: keywords: dict[str, str | tuple[str, str]] symbols: dict[str, str] - topics: dict[str, str | Tuple[str, ...]] + topics: dict[str, str | tuple[str, ...]] def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... input: IO[str] output: IO[str] diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 6a3d6cd56791..37424f20c18d 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,7 +1,7 @@ import pyexpat.errors as errors import pyexpat.model as model from _typeshed import SupportsRead -from typing import Any, Callable, Optional, Tuple +from typing import Any, Callable, Optional from typing_extensions import final EXPAT_VERSION: str # undocumented @@ -20,7 +20,7 @@ XML_PARAM_ENTITY_PARSING_NEVER: int XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int XML_PARAM_ENTITY_PARSING_ALWAYS: int -_Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] +_Model = tuple[int, int, Optional[str], tuple[Any, ...]] @final class XMLParserType(object): diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 4834dab6552e..ffa866ef9aa0 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -3,7 +3,7 @@ import sys from _typeshed import SupportsLenAndGetItem from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set as AbstractSet from fractions import Fraction -from typing import Any, ClassVar, NoReturn, Tuple, TypeVar +from typing import Any, ClassVar, NoReturn, TypeVar _T = TypeVar("_T") @@ -11,8 +11,8 @@ class Random(_random.Random): VERSION: ClassVar[int] def __init__(self, x: Any = ...) -> None: ... def seed(self, a: Any = ..., version: int = ...) -> None: ... - def getstate(self) -> Tuple[Any, ...]: ... - def setstate(self, state: Tuple[Any, ...]) -> None: ... + def getstate(self) -> tuple[Any, ...]: ... + def setstate(self, state: tuple[Any, ...]) -> None: ... def getrandbits(self, __k: int) -> int: ... def randrange(self, start: int, stop: int | None = ..., step: int = ...) -> int: ... def randint(self, a: int, b: int) -> int: ... diff --git a/stdlib/reprlib.pyi b/stdlib/reprlib.pyi index 4d400554a4ff..2095c0af6983 100644 --- a/stdlib/reprlib.pyi +++ b/stdlib/reprlib.pyi @@ -1,6 +1,6 @@ from array import array from collections import deque -from typing import Any, Callable, Tuple +from typing import Any, Callable _ReprFunc = Callable[[Any], str] @@ -21,7 +21,7 @@ class Repr: def __init__(self) -> None: ... def repr(self, x: Any) -> str: ... def repr1(self, x: Any, level: int) -> str: ... - def repr_tuple(self, x: Tuple[Any, ...], level: int) -> str: ... + def repr_tuple(self, x: tuple[Any, ...], level: int) -> str: ... def repr_list(self, x: list[Any], level: int) -> str: ... def repr_array(self, x: array[Any], level: int) -> str: ... def repr_set(self, x: set[Any], level: int) -> str: ... diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index ff6f1d79e483..8e01bc717684 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import structseq -from typing import Tuple, overload +from typing import overload from typing_extensions import final RLIMIT_AS: int @@ -26,7 +26,7 @@ if sys.platform == "linux": RUSAGE_THREAD: int @final -class struct_rusage(structseq[float], Tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int]): +class struct_rusage(structseq[float], tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int]): @property def ru_utime(self) -> float: ... @property diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index cb96dc2bbf4a..71aacc5c2610 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,10 +1,10 @@ -from typing import Any, Callable, NamedTuple, Tuple +from typing import Any, Callable, NamedTuple class Event(NamedTuple): time: float priority: Any action: Callable[..., Any] - argument: Tuple[Any, ...] + argument: tuple[Any, ...] kwargs: dict[str, Any] class scheduler: @@ -14,7 +14,7 @@ class scheduler: time: float, priority: Any, action: Callable[..., Any], - argument: Tuple[Any, ...] = ..., + argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ..., ) -> Event: ... def enter( @@ -22,7 +22,7 @@ class scheduler: delay: float, priority: Any, action: Callable[..., Any], - argument: Tuple[Any, ...] = ..., + argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ..., ) -> Event: ... def run(self, blocking: bool = ...) -> float | None: ... diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index 6c93662fb326..777391662aa3 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import structseq from enum import IntEnum from types import FrameType -from typing import Any, Callable, Iterable, Optional, Tuple, Union +from typing import Any, Callable, Iterable, Optional, Union from typing_extensions import final NSIG: int @@ -132,7 +132,7 @@ else: SIGRTMAX: Signals SIGRTMIN: Signals @final - class struct_siginfo(structseq[int], Tuple[int, int, int, int, int, int, int]): + class struct_siginfo(structseq[int], tuple[int, int, int, int, int, int, int]): @property def si_signo(self) -> int: ... @property diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index ef0ada2c72de..e5401552caae 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -2,9 +2,9 @@ import asynchat import asyncore import socket from collections import defaultdict -from typing import Any, Tuple, Type +from typing import Any, Type -_Address = Tuple[str, int] # (host, port) +_Address = tuple[str, int] # (host, port) class SMTPChannel(asynchat.async_chat): COMMAND: int diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index a6f7d07ee7ec..0a57f1f5d2de 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -4,12 +4,12 @@ from email.message import Message as _Message from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Dict, Pattern, Protocol, Sequence, Tuple, Type, Union, overload +from typing import Any, Pattern, Protocol, Sequence, Type, Union, overload -_Reply = Tuple[int, bytes] -_SendErrs = Dict[str, _Reply] +_Reply = tuple[int, bytes] +_SendErrs = dict[str, _Reply] # Should match source_address for socket.create_connection -_SourceAddress = Tuple[Union[bytearray, bytes, str], int] +_SourceAddress = tuple[Union[bytearray, bytes, str], int] SMTP_PORT: int SMTP_SSL_PORT: int diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index c64408cfab07..c663e73bef50 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -2,11 +2,11 @@ import sys import types from _typeshed import Self from socket import socket as _socket -from typing import Any, BinaryIO, Callable, ClassVar, Tuple, Type, TypeVar, Union +from typing import Any, BinaryIO, Callable, ClassVar, Type, TypeVar, Union _T = TypeVar("_T") -_RequestType = Union[_socket, Tuple[bytes, _socket]] -_AddressType = Union[Tuple[str, int], str] +_RequestType = Union[_socket, tuple[bytes, _socket]] +_AddressType = Union[tuple[str, int], str] class BaseServer: address_family: int diff --git a/stdlib/spwd.pyi b/stdlib/spwd.pyi index fc3d8ce90021..10f1ab1fb721 100644 --- a/stdlib/spwd.pyi +++ b/stdlib/spwd.pyi @@ -1,9 +1,9 @@ from _typeshed import structseq -from typing import Any, Tuple +from typing import Any from typing_extensions import final @final -class struct_spwd(structseq[Any], Tuple[str, str, int, int, int, int, int, int, int]): +class struct_spwd(structseq[Any], tuple[str, str, int, int, int, int, int, int, int]): @property def sp_namp(self) -> str: ... @property diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index 598e61d6a8e0..c4de55bcbf7e 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -1,7 +1,7 @@ import sys from sre_constants import * from sre_constants import _NamedIntConstant as _NIC, error as _Error -from typing import Any, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload +from typing import Any, Iterable, Match, Optional, Pattern as _Pattern, Union, overload SPECIAL_CHARS: str REPEAT_CHARS: str @@ -37,12 +37,12 @@ if sys.version_info >= (3, 8): else: Pattern = _State -_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern] -_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern] -_OpInType = List[Tuple[_NIC, int]] -_OpBranchType = Tuple[None, List[SubPattern]] +_OpSubpatternType = tuple[Optional[int], int, int, SubPattern] +_OpGroupRefExistsType = tuple[int, SubPattern, SubPattern] +_OpInType = list[tuple[_NIC, int]] +_OpBranchType = tuple[None, list[SubPattern]] _AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType] -_CodeType = Tuple[_NIC, _AvType] +_CodeType = tuple[_NIC, _AvType] class SubPattern: data: list[_CodeType] @@ -85,8 +85,8 @@ class Tokenizer: def fix_flags(src: str | bytes, flags: int) -> int: ... -_TemplateType = Tuple[List[Tuple[int, int]], List[Optional[str]]] -_TemplateByteType = Tuple[List[Tuple[int, int]], List[Optional[bytes]]] +_TemplateType = tuple[list[tuple[int, int]], list[Optional[str]]] +_TemplateByteType = tuple[list[tuple[int, int]], list[Optional[bytes]]] if sys.version_info >= (3, 8): def parse(str: str, flags: int = ..., state: State | None = ...) -> SubPattern: ... @overload diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 628139634bac..cdb727285647 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -2,14 +2,14 @@ import enum import socket import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer -from typing import Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Optional, Set, Tuple, Type, Union, overload +from typing import Any, Callable, ClassVar, Iterable, NamedTuple, Optional, Type, Union, overload from typing_extensions import Literal, TypedDict -_PCTRTT = Tuple[Tuple[str, str], ...] -_PCTRTTT = Tuple[_PCTRTT, ...] -_PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] +_PCTRTT = tuple[tuple[str, str], ...] +_PCTRTTT = tuple[_PCTRTT, ...] +_PeerCertRetDictType = dict[str, Union[str, _PCTRTTT, _PCTRTT]] _PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] -_EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] +_EnumRetType = list[tuple[bytes, str, Union[set[str], bool]]] _PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes] _SrvnmeCbType = Callable[[Union[SSLSocket, SSLObject], Optional[str], SSLSocket], Optional[int]] diff --git a/stdlib/struct.pyi b/stdlib/struct.pyi index d7c9cbef7dce..47af62973259 100644 --- a/stdlib/struct.pyi +++ b/stdlib/struct.pyi @@ -1,14 +1,14 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer -from typing import Any, Iterator, Tuple +from typing import Any, Iterator class error(Exception): ... def pack(fmt: str | bytes, *v: Any) -> bytes: ... def pack_into(fmt: str | bytes, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... -def unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... -def unpack_from(__format: str | bytes, buffer: ReadableBuffer, offset: int = ...) -> Tuple[Any, ...]: ... -def iter_unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Iterator[Tuple[Any, ...]]: ... +def unpack(__format: str | bytes, __buffer: ReadableBuffer) -> tuple[Any, ...]: ... +def unpack_from(__format: str | bytes, buffer: ReadableBuffer, offset: int = ...) -> tuple[Any, ...]: ... +def iter_unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Iterator[tuple[Any, ...]]: ... def calcsize(__format: str | bytes) -> int: ... class Struct: @@ -20,6 +20,6 @@ class Struct: def __init__(self, format: str | bytes) -> None: ... def pack(self, *v: Any) -> bytes: ... def pack_into(self, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... - def unpack(self, __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... - def unpack_from(self, buffer: ReadableBuffer, offset: int = ...) -> Tuple[Any, ...]: ... - def iter_unpack(self, __buffer: ReadableBuffer) -> Iterator[Tuple[Any, ...]]: ... + def unpack(self, __buffer: ReadableBuffer) -> tuple[Any, ...]: ... + def unpack_from(self, buffer: ReadableBuffer, offset: int = ...) -> tuple[Any, ...]: ... + def iter_unpack(self, __buffer: ReadableBuffer) -> Iterator[tuple[Any, ...]]: ... diff --git a/stdlib/symtable.pyi b/stdlib/symtable.pyi index 2f8961faa5f6..58fb8c8ae69f 100644 --- a/stdlib/symtable.pyi +++ b/stdlib/symtable.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Sequence, Tuple +from typing import Any, Sequence def symtable(code: str, filename: str, compile_type: str) -> SymbolTable: ... @@ -19,15 +19,15 @@ class SymbolTable(object): def get_children(self) -> list[SymbolTable]: ... class Function(SymbolTable): - def get_parameters(self) -> Tuple[str, ...]: ... - def get_locals(self) -> Tuple[str, ...]: ... - def get_globals(self) -> Tuple[str, ...]: ... - def get_frees(self) -> Tuple[str, ...]: ... + def get_parameters(self) -> tuple[str, ...]: ... + def get_locals(self) -> tuple[str, ...]: ... + def get_globals(self) -> tuple[str, ...]: ... + def get_frees(self) -> tuple[str, ...]: ... if sys.version_info >= (3, 8): - def get_nonlocals(self) -> Tuple[str, ...]: ... + def get_nonlocals(self) -> tuple[str, ...]: ... class Class(SymbolTable): - def get_methods(self) -> Tuple[str, ...]: ... + def get_methods(self) -> tuple[str, ...]: ... class Symbol(object): if sys.version_info >= (3, 8): diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index b5829884482a..b4cf9175d911 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -4,28 +4,14 @@ from importlib.abc import PathEntryFinder from importlib.machinery import ModuleSpec from io import TextIOWrapper from types import FrameType, ModuleType, TracebackType -from typing import ( - Any, - AsyncGenerator, - Callable, - NoReturn, - Optional, - Protocol, - Sequence, - TextIO, - Tuple, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, AsyncGenerator, Callable, NoReturn, Optional, Protocol, Sequence, TextIO, Type, TypeVar, Union, overload from typing_extensions import Literal _T = TypeVar("_T") # The following type alias are stub-only and do not exist during runtime -_ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType] -_OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]] +_ExcInfo = tuple[Type[BaseException], BaseException, TracebackType] +_OptExcInfo = Union[_ExcInfo, tuple[None, None, None]] # Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder` class _MetaPathFinder(Protocol): @@ -146,7 +132,7 @@ class _int_info: bits_per_digit: int sizeof_digit: int -class _version_info(Tuple[int, int, int, str, int]): +class _version_info(tuple[int, int, int, str, int]): major: int minor: int micro: int @@ -192,7 +178,7 @@ _TraceFunc = Callable[[FrameType, str, Any], Optional[Callable[[FrameType, str, def gettrace() -> _TraceFunc | None: ... def settrace(tracefunc: _TraceFunc | None) -> None: ... -class _WinVersion(Tuple[int, int, int, int, str, int, int, int, int, Tuple[int, int, int]]): +class _WinVersion(tuple[int, int, int, int, str, int, int, int, int, tuple[int, int, int]]): major: int minor: int build: int @@ -234,12 +220,12 @@ if sys.version_info >= (3, 8): err_msg: str | None object: _object | None unraisablehook: Callable[[UnraisableHookArgs], Any] - def addaudithook(hook: Callable[[str, Tuple[Any, ...]], Any]) -> None: ... + def addaudithook(hook: Callable[[str, tuple[Any, ...]], Any]) -> None: ... def audit(__event: str, *args: Any) -> None: ... _AsyncgenHook = Optional[Callable[[AsyncGenerator[Any, Any]], None]] -class _asyncgen_hooks(Tuple[_AsyncgenHook, _AsyncgenHook]): +class _asyncgen_hooks(tuple[_AsyncgenHook, _AsyncgenHook]): firstiter: _AsyncgenHook finalizer: _AsyncgenHook diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index ff828d519912..17077144f6e9 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -1,12 +1,12 @@ -from typing import IO, Any, Tuple, overload +from typing import IO, Any, overload def get_config_var(name: str) -> str | None: ... @overload def get_config_vars() -> dict[str, Any]: ... @overload def get_config_vars(arg: str, *args: str) -> list[Any]: ... -def get_scheme_names() -> Tuple[str, ...]: ... -def get_path_names() -> Tuple[str, ...]: ... +def get_scheme_names() -> tuple[str, ...]: ... +def get_path_names() -> tuple[str, ...]: ... def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> str: ... def get_paths(scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> dict[str, str]: ... def get_python_version() -> str: ... diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 0134316d8107..4931a6f0e679 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -5,7 +5,7 @@ from _typeshed import Self, StrOrBytesPath, StrPath from collections.abc import Callable, Iterable, Iterator, Mapping from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj from types import TracebackType -from typing import IO, Protocol, Tuple, Type, TypeVar, overload +from typing import IO, Protocol, Type, TypeVar, overload from typing_extensions import Literal _TF = TypeVar("_TF", bound=TarFile) @@ -62,10 +62,10 @@ DEFAULT_FORMAT: int # tarfile constants -SUPPORTED_TYPES: Tuple[bytes, ...] -REGULAR_TYPES: Tuple[bytes, ...] -GNU_TYPES: Tuple[bytes, ...] -PAX_FIELDS: Tuple[str, ...] +SUPPORTED_TYPES: tuple[bytes, ...] +REGULAR_TYPES: tuple[bytes, ...] +GNU_TYPES: tuple[bytes, ...] +PAX_FIELDS: tuple[str, ...] PAX_NUMBER_FIELDS: dict[str, type] PAX_NAME_FIELDS: set[str] diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 119c111bc4e1..4aec26175a48 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -2,7 +2,7 @@ import os import sys from _typeshed import Self from types import TracebackType -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, Tuple, Type, Union, overload +from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, Type, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -206,7 +206,7 @@ class SpooledTemporaryFile(IO[AnyStr]): @property def encoding(self) -> str: ... # undocumented @property - def newlines(self) -> str | Tuple[str, ...] | None: ... # undocumented + def newlines(self) -> str | tuple[str, ...] | None: ... # undocumented # bytes needs to go first, as default mode is to open as bytes if sys.version_info >= (3, 8): @overload diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index ed8522dccc51..c4da38417243 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -1,7 +1,7 @@ from _typeshed import FileDescriptorLike -from typing import Any, List, Union +from typing import Any, Union -_Attr = List[Union[int, List[Union[bytes, int]]]] +_Attr = list[Union[int, list[Union[bytes, int]]]] # TODO constants not really documented B0: int diff --git a/stdlib/time.pyi b/stdlib/time.pyi index fc929b112185..6e23b331d1c8 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -1,10 +1,10 @@ import sys from _typeshed import structseq from types import SimpleNamespace -from typing import Any, Tuple, Union +from typing import Any, Union from typing_extensions import final -_TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] +_TimeTuple = tuple[int, int, int, int, int, int, int, int, int] altzone: int daylight: int diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index a32fe5554157..50de97f48fdc 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -5,7 +5,7 @@ from enum import Enum from tkinter.constants import * from tkinter.font import _FontDescription from types import TracebackType -from typing import Any, Callable, Generic, List, Mapping, Optional, Protocol, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, Mapping, Optional, Protocol, Sequence, Type, TypeVar, Union, overload from typing_extensions import Literal, TypedDict # Using anything from tkinter.font in this file means that 'import tkinter' @@ -42,18 +42,18 @@ _ButtonCommand = Union[str, Callable[[], Any]] # accepts string of tcl code, re _CanvasItemId = int _Color = str # typically '#rrggbb', '#rgb' or color names. _Compound = Literal["top", "left", "center", "right", "bottom", "none"] # -compound in manual page named 'options' -_Cursor = Union[str, Tuple[str], Tuple[str, str], Tuple[str, str, str], Tuple[str, str, str, str]] # manual page: Tk_GetCursor +_Cursor = Union[str, tuple[str], tuple[str, str], tuple[str, str, str], tuple[str, str, str, str]] # manual page: Tk_GetCursor _EntryValidateCommand = Union[ - Callable[[], bool], str, List[str], Tuple[str, ...] + Callable[[], bool], str, list[str], tuple[str, ...] ] # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P'] _GridIndex = Union[int, str, Literal["all"]] _ImageSpec = Union[_Image, str] # str can be from e.g. tkinter.image_names() _Padding = Union[ _ScreenUnits, - Tuple[_ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], ] _Relief = Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] # manual page: Tk_GetRelief _ScreenUnits = Union[str, float] # Often the right type instead of int. Manual page: Tk_GetPixels @@ -137,7 +137,7 @@ class Variable: def get(self) -> Any: ... 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_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 @@ -249,7 +249,7 @@ class Misc: def winfo_geometry(self) -> str: ... def winfo_height(self) -> int: ... def winfo_id(self) -> int: ... - def winfo_interps(self, displayof: Literal[0] | Misc | None = ...) -> Tuple[str, ...]: ... + def winfo_interps(self, displayof: Literal[0] | Misc | None = ...) -> tuple[str, ...]: ... def winfo_ismapped(self) -> bool: ... def winfo_manager(self) -> str: ... def winfo_name(self) -> str: ... @@ -420,9 +420,9 @@ class Misc: x: _ScreenUnits = ..., y: _ScreenUnits = ..., ) -> None: ... - def event_info(self, virtual: str | None = ...) -> Tuple[str, ...]: ... - def image_names(self) -> Tuple[str, ...]: ... - def image_types(self) -> Tuple[str, ...]: ... + def event_info(self, virtual: str | None = ...) -> tuple[str, ...]: ... + def image_names(self) -> tuple[str, ...]: ... + def image_types(self) -> tuple[str, ...]: ... # See #4363 and #4891 def __setitem__(self, key: str, value: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... @@ -468,7 +468,7 @@ class Wm: ) -> tuple[int, int, int, int] | None: ... aspect = wm_aspect @overload - def wm_attributes(self) -> Tuple[Any, ...]: ... + def wm_attributes(self) -> tuple[Any, ...]: ... @overload def wm_attributes(self, __option: str) -> Any: ... @overload @@ -479,7 +479,7 @@ class Wm: @overload def wm_colormapwindows(self) -> list[Misc]: ... @overload - def wm_colormapwindows(self, __wlist: list[Misc] | Tuple[Misc, ...]) -> None: ... + def wm_colormapwindows(self, __wlist: list[Misc] | tuple[Misc, ...]) -> None: ... @overload def wm_colormapwindows(self, __first_wlist_item: Misc, *other_wlist_items: Misc) -> None: ... colormapwindows = wm_colormapwindows @@ -543,7 +543,7 @@ class Wm: @overload def wm_protocol(self, name: str, func: None = ...) -> str: ... @overload - def wm_protocol(self, name: None = ..., func: None = ...) -> Tuple[str, ...]: ... + def wm_protocol(self, name: None = ..., func: None = ...) -> tuple[str, ...]: ... protocol = wm_protocol @overload def wm_resizable(self, width: None = ..., height: None = ...) -> tuple[bool, bool]: ... @@ -1043,17 +1043,17 @@ class Canvas(Widget, XView, YView): def addtag_overlapping(self, newtag: str, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: _ScreenUnits) -> None: ... def addtag_withtag(self, newtag: str, tagOrId: str | _CanvasItemId) -> None: ... def find(self, *args): ... # internal method - def find_above(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... - def find_all(self) -> Tuple[_CanvasItemId, ...]: ... - def find_below(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... + def find_above(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... + def find_all(self) -> tuple[_CanvasItemId, ...]: ... + def find_below(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... def find_closest( self, x: _ScreenUnits, y: _ScreenUnits, halo: _ScreenUnits | None = ..., start: str | _CanvasItemId | None = ... - ) -> Tuple[_CanvasItemId, ...]: ... + ) -> tuple[_CanvasItemId, ...]: ... def find_enclosed( self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: _ScreenUnits - ) -> Tuple[_CanvasItemId, ...]: ... - def find_overlapping(self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: float) -> Tuple[_CanvasItemId, ...]: ... - def find_withtag(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... + ) -> tuple[_CanvasItemId, ...]: ... + def find_overlapping(self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: float) -> tuple[_CanvasItemId, ...]: ... + def find_withtag(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... # Incompatible with Misc.bbox(), tkinter violates LSP def bbox(self, *args: str | _CanvasItemId) -> tuple[int, int, int, int]: ... # type: ignore[override] @overload @@ -1076,7 +1076,7 @@ class Canvas(Widget, XView, YView): @overload def coords(self) -> list[float]: ... @overload - def coords(self, __args: list[int] | list[float] | Tuple[float, ...]) -> None: ... + def coords(self, __args: list[int] | list[float] | tuple[float, ...]) -> None: ... @overload def coords(self, __x1: float, __y1: float, *args: float) -> None: ... # create_foo() methods accept coords as a list, a tuple, or as separate arguments. @@ -1092,16 +1092,16 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., arrow: Literal["first", "last", "both"] = ..., arrowshape: tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledstipple: _Bitmap = ..., disabledwidth: _ScreenUnits = ..., @@ -1112,7 +1112,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1120,16 +1120,16 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., arrow: Literal["first", "last", "both"] = ..., arrowshape: tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledstipple: _Bitmap = ..., disabledwidth: _ScreenUnits = ..., @@ -1140,7 +1140,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1151,15 +1151,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1172,7 +1172,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1180,15 +1180,15 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1201,7 +1201,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1212,15 +1212,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *xy_pairs: float, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1236,23 +1236,23 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload def create_polygon( self, - __coords: Tuple[float, ...] | list[int] | list[float], + __coords: tuple[float, ...] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1268,7 +1268,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1279,15 +1279,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1300,7 +1300,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1308,15 +1308,15 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1329,7 +1329,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1349,7 +1349,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1369,7 +1369,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1382,7 +1382,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1394,7 +1394,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1405,7 +1405,7 @@ class Canvas(Widget, XView, YView): @overload def dtag(self, __id: _CanvasItemId, __tag_to_delete: str) -> None: ... def focus(self, *args): ... - def gettags(self, __tagOrId: str | _CanvasItemId) -> Tuple[str, ...]: ... + def gettags(self, __tagOrId: str | _CanvasItemId) -> tuple[str, ...]: ... def icursor(self, *args): ... def index(self, *args): ... def insert(self, *args): ... @@ -2650,7 +2650,7 @@ class Text(Widget, XView, YView): startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., # Literal inside Tuple doesn't actually work - tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., + tabs: _ScreenUnits | str | tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2701,7 +2701,7 @@ class Text(Widget, XView, YView): spacing3: _ScreenUnits = ..., startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., - tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., + tabs: _ScreenUnits | str | tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2780,20 +2780,20 @@ class Text(Widget, XView, YView): def image_create(self, index, cnf=..., **kw): ... def image_names(self): ... def index(self, index: _TextIndex) -> str: ... - def insert(self, index: _TextIndex, chars: str, *args: str | list[str] | Tuple[str, ...]) -> None: ... + def insert(self, index: _TextIndex, chars: str, *args: str | list[str] | tuple[str, ...]) -> None: ... @overload def mark_gravity(self, markName: str, direction: None = ...) -> Literal["left", "right"]: ... @overload def mark_gravity(self, markName: str, direction: Literal["left", "right"]) -> None: ... # actually returns empty string - def mark_names(self) -> Tuple[str, ...]: ... + def mark_names(self) -> tuple[str, ...]: ... def mark_set(self, markName: str, index: _TextIndex) -> None: ... def mark_unset(self, *markNames: str) -> None: ... def mark_next(self, index: _TextIndex) -> str | None: ... def mark_previous(self, index: _TextIndex) -> str | None: ... # **kw of peer_create is same as the kwargs of Text.__init__ def peer_create(self, newPathName: str | Text, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def peer_names(self) -> Tuple[_tkinter.Tcl_Obj, ...]: ... - def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | list[str] | Tuple[str, ...]) -> None: ... + def peer_names(self) -> tuple[_tkinter.Tcl_Obj, ...]: ... + def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | list[str] | tuple[str, ...]) -> None: ... def scan_mark(self, x: int, y: int) -> None: ... def scan_dragto(self, x: int, y: int) -> None: ... def search( @@ -2865,11 +2865,11 @@ class Text(Widget, XView, YView): tag_config = tag_configure def tag_delete(self, __first_tag_name: str, *tagNames: str) -> None: ... # error if no tag names given def tag_lower(self, tagName: str, belowThis: str | None = ...) -> None: ... - def tag_names(self, index: _TextIndex | None = ...) -> Tuple[str, ...]: ... + def tag_names(self, index: _TextIndex | None = ...) -> tuple[str, ...]: ... def tag_nextrange(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> tuple[str, str] | tuple[()]: ... def tag_prevrange(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> tuple[str, str] | tuple[()]: ... def tag_raise(self, tagName: str, aboveThis: str | None = ...) -> None: ... - def tag_ranges(self, tagName: str) -> Tuple[_tkinter.Tcl_Obj, ...]: ... + def tag_ranges(self, tagName: str) -> tuple[_tkinter.Tcl_Obj, ...]: ... # tag_remove and tag_delete are different def tag_remove(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... # TODO: window_* methods @@ -2959,10 +2959,10 @@ class PhotoImage(Image): str | list[str] | list[list[_Color]] - | list[Tuple[_Color, ...]] - | Tuple[str, ...] - | Tuple[list[_Color], ...] - | Tuple[Tuple[_Color, ...], ...] + | list[tuple[_Color, ...]] + | tuple[str, ...] + | tuple[list[_Color], ...] + | tuple[tuple[_Color, ...], ...] ), to: tuple[int, int] | None = ..., ) -> None: ... @@ -2986,8 +2986,8 @@ class BitmapImage(Image): maskfile: StrOrBytesPath = ..., ) -> None: ... -def image_names() -> Tuple[str, ...]: ... -def image_types() -> Tuple[str, ...]: ... +def image_names() -> tuple[str, ...]: ... +def image_types() -> tuple[str, ...]: ... class Spinbox(Widget, XView): def __init__( @@ -3006,7 +3006,7 @@ class Spinbox(Widget, XView): buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., # percent substitutions don't seem to be supported, it's similar to Entry's validation stuff - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3043,7 +3043,7 @@ class Spinbox(Widget, XView): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., vcmd: _EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., @@ -3063,7 +3063,7 @@ class Spinbox(Widget, XView): buttoncursor: _Cursor = ..., buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3099,7 +3099,7 @@ class Spinbox(Widget, XView): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., vcmd: _EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., @@ -3119,7 +3119,7 @@ class Spinbox(Widget, XView): def scan(self, *args): ... def scan_mark(self, x): ... def scan_dragto(self, x): ... - def selection(self, *args: Any) -> Tuple[int, ...]: ... + def selection(self, *args: Any) -> tuple[int, ...]: ... def selection_adjust(self, index): ... def selection_clear(self): ... def selection_element(self, element: Any | None = ...): ... diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index 0fc7d6e8a3bc..b818d5e8253e 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog -from typing import IO, Any, ClassVar, Iterable, Tuple +from typing import IO, Any, ClassVar, Iterable from typing_extensions import Literal dialogstates: dict[Any, tuple[Any, Any]] @@ -64,7 +64,7 @@ def asksaveasfilename( *, confirmoverwrite: bool | None = ..., defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -74,7 +74,7 @@ def asksaveasfilename( def askopenfilename( *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -84,13 +84,13 @@ def askopenfilename( def askopenfilenames( *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> Literal[""] | Tuple[str, ...]: ... +) -> Literal[""] | tuple[str, ...]: ... def askdirectory( *, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = ..., parent: Misc | None = ..., title: str | None = ... ) -> str: ... # can be empty string @@ -101,7 +101,7 @@ def asksaveasfile( *, confirmoverwrite: bool | None = ..., defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -112,7 +112,7 @@ def askopenfile( mode: str = ..., *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -123,11 +123,11 @@ def askopenfiles( mode: str = ..., *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> Tuple[IO[Any], ...]: ... # can be empty tuple +) -> tuple[IO[Any], ...]: ... # can be empty tuple def test() -> None: ... diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index fccc0fbf1f0a..211e8ec9a0be 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,7 +1,7 @@ import _tkinter import sys import tkinter -from typing import Any, List, Tuple, Union, overload +from typing import Any, Union, overload from typing_extensions import Literal, TypedDict NORMAL: Literal["normal"] @@ -15,8 +15,8 @@ _FontDescription = Union[ # A font object constructed in Python Font, # ("Helvetica", 12, BOLD) - List[Any], - Tuple[Any, ...], + list[Any], + tuple[Any, ...], # A font object constructed in Tcl _tkinter.Tcl_Obj, ] @@ -102,8 +102,8 @@ class Font: def metrics(self, *, displayof: tkinter.Misc | None = ...) -> _MetricsDict: ... def measure(self, text: str, displayof: tkinter.Misc | None = ...) -> int: ... -def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> Tuple[str, ...]: ... -def names(root: tkinter.Misc | None = ...) -> Tuple[str, ...]: ... +def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> tuple[str, ...]: ... +def names(root: tkinter.Misc | None = ...) -> tuple[str, ...]: ... if sys.version_info >= (3, 10): def nametofont(name: str, root: tkinter.Misc | None = ...) -> Font: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 4914234c4eed..6842ab7b1108 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -1,5 +1,5 @@ import tkinter -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal WINDOW: Literal["window"] @@ -194,7 +194,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def indicator_size(self, entry: str) -> int: ... def info_anchor(self) -> str: ... def info_bbox(self, entry: str) -> tuple[int, int, int, int]: ... - def info_children(self, entry: str | None = ...) -> Tuple[str, ...]: ... + def info_children(self, entry: str | None = ...) -> tuple[str, ...]: ... def info_data(self, entry: str) -> Any: ... def info_dragsite(self) -> str: ... def info_dropsite(self) -> str: ... @@ -203,7 +203,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def info_next(self, entry: str) -> str: ... def info_parent(self, entry: str) -> str: ... def info_prev(self, entry: str) -> str: ... - def info_selection(self) -> Tuple[str, ...]: ... + def info_selection(self) -> tuple[str, ...]: ... def item_cget(self, entry: str, col: int, opt: Any) -> Any: ... def item_configure(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> Any | None: ... def item_create(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... @@ -224,7 +224,7 @@ class CheckList(TixWidget): def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... def open(self, entrypath: str) -> None: ... - def getselection(self, mode: str = ...) -> Tuple[str, ...]: ... + def getselection(self, mode: str = ...) -> tuple[str, ...]: ... def getstatus(self, entrypath: str) -> str: ... def setstatus(self, entrypath: str, mode: str = ...) -> None: ... @@ -253,7 +253,7 @@ class TList(TixWidget, tkinter.XView, tkinter.YView): def info_down(self, index: int) -> int: ... def info_left(self, index: int) -> int: ... def info_right(self, index: int) -> int: ... - def info_selection(self) -> Tuple[int, ...]: ... + def info_selection(self) -> tuple[int, ...]: ... def info_size(self) -> int: ... def info_up(self, index: int) -> int: ... def nearest(self, x: int, y: int) -> int: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 3ef348d91ab2..f7319291da6d 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -2,7 +2,7 @@ import _tkinter import sys import tkinter from tkinter.font import _FontDescription -from typing import Any, Callable, Tuple, Union, overload +from typing import Any, Callable, Union, overload from typing_extensions import Literal, TypedDict def tclobjs_to_py(adict): ... @@ -24,7 +24,7 @@ class Style: def element_options(self, elementname): ... def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...): ... def theme_settings(self, themename, settings): ... - def theme_names(self) -> Tuple[str, ...]: ... + def theme_names(self) -> tuple[str, ...]: ... @overload def theme_use(self, themename: str) -> None: ... @overload @@ -234,7 +234,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented validatecommand: tkinter._EntryValidateCommand = ..., # undocumented - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented ) -> None: ... @@ -259,7 +259,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -287,7 +287,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -828,7 +828,7 @@ if sys.version_info >= (3, 7): *, background: tkinter._Color = ..., # undocumented class_: str = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., # undocumented font: _FontDescription = ..., # undocumented @@ -847,7 +847,7 @@ if sys.version_info >= (3, 7): to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., # undocumented wrap: bool = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -858,7 +858,7 @@ if sys.version_info >= (3, 7): cnf: dict[str, Any] | None = ..., *, background: tkinter._Color = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., @@ -876,7 +876,7 @@ if sys.version_info >= (3, 7): to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -922,9 +922,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): master: tkinter.Misc | None = ..., *, class_: str = ..., - columns: str | list[str] | Tuple[str, ...] = ..., + columns: str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ..., + displaycolumns: str | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] | Literal["#all"] = ..., height: int = ..., name: str = ..., padding: tkinter._Padding = ..., @@ -933,7 +933,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): # # 'tree headings' is same as ['tree', 'headings'], and I wouldn't be # surprised if someone is using it. - show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ..., + show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -944,13 +944,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): self, cnf: dict[str, Any] | None = ..., *, - columns: str | list[str] | Tuple[str, ...] = ..., + columns: str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ..., + displaycolumns: str | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] | Literal["#all"] = ..., height: int = ..., padding: tkinter._Padding = ..., selectmode: Literal["extended", "browse", "none"] = ..., - show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ..., + show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -960,7 +960,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, item, column: _TreeviewColumnId | None = ...) -> tuple[int, int, int, int] | Literal[""]: ... # type: ignore[override] - def get_children(self, item: str | None = ...) -> Tuple[str, ...]: ... + def get_children(self, item: str | None = ...) -> tuple[str, ...]: ... def set_children(self, item: str, *newchildren: str) -> None: ... @overload def column(self, column: _TreeviewColumnId, option: Literal["width", "minwidth"]) -> int: ... @@ -1027,20 +1027,20 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): id: str = ..., # same as iid text: str = ..., image: tkinter._ImageSpec = ..., - values: list[Any] | Tuple[Any, ...] = ..., + values: list[Any] | tuple[Any, ...] = ..., open: bool = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., ) -> str: ... @overload def item(self, item: str, option: Literal["text"]) -> str: ... @overload def item(self, item: str, option: Literal["image"]) -> tuple[str] | Literal[""]: ... @overload - def item(self, item: str, option: Literal["values"]) -> Tuple[Any, ...] | Literal[""]: ... + def item(self, item: str, option: Literal["values"]) -> tuple[Any, ...] | Literal[""]: ... @overload def item(self, item: str, option: Literal["open"]) -> bool: ... # actually 0 or 1 @overload - def item(self, item: str, option: Literal["tags"]) -> Tuple[str, ...] | Literal[""]: ... + def item(self, item: str, option: Literal["tags"]) -> tuple[str, ...] | Literal[""]: ... @overload def item(self, item: str, option: str) -> Any: ... @overload @@ -1051,9 +1051,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): *, text: str = ..., image: tkinter._ImageSpec = ..., - values: list[Any] | Tuple[Any, ...] | Literal[""] = ..., + values: list[Any] | tuple[Any, ...] | Literal[""] = ..., open: bool = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., ) -> _TreeviewItemDict | None: ... def move(self, item: str, parent: str, index: int) -> None: ... reattach = move @@ -1062,13 +1062,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def prev(self, item: str) -> str: ... # returning empty string means first item def see(self, item: str) -> None: ... if sys.version_info >= (3, 8): - def selection(self) -> Tuple[str, ...]: ... + def selection(self) -> tuple[str, ...]: ... else: - def selection(self, selop: Any | None = ..., items: Any | None = ...) -> Tuple[str, ...]: ... - def selection_set(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_add(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_remove(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_toggle(self, items: str | list[str] | Tuple[str, ...]) -> None: ... + def selection(self, selop: Any | None = ..., items: Any | None = ...) -> tuple[str, ...]: ... + def selection_set(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_add(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_remove(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_toggle(self, items: str | list[str] | tuple[str, ...]) -> None: ... @overload def set(self, item: str, column: None = ..., value: None = ...) -> dict[str, Any]: ... @overload @@ -1104,7 +1104,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): image: tkinter._ImageSpec = ..., ) -> _TreeviewTagDict | Any: ... # can be None but annoying to check @overload - def tag_has(self, tagname: str, item: None = ...) -> Tuple[str, ...]: ... + def tag_has(self, tagname: str, item: None = ...) -> tuple[str, ...]: ... @overload def tag_has(self, tagname: str, item: str) -> bool: ... diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index a8294adb653f..7614ebfe403e 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import StrOrBytesPath from builtins import open as _builtin_open from token import * # noqa: F403 -from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, TextIO, Tuple, Union +from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, TextIO, Union if sys.version_info < (3, 7): COMMENT: int @@ -12,7 +12,7 @@ if sys.version_info < (3, 7): cookie_re: Pattern[str] blank_re: Pattern[bytes] -_Position = Tuple[int, int] +_Position = tuple[int, int] class _TokenInfo(NamedTuple): type: int diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index 2fe841aa5bd3..ee8dffa67820 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -1,13 +1,13 @@ import sys import types from _typeshed import StrPath -from typing import Any, Callable, Mapping, Optional, Sequence, Tuple, TypeVar +from typing import Any, Callable, Mapping, Optional, Sequence, TypeVar from typing_extensions import ParamSpec _T = TypeVar("_T") _P = ParamSpec("_P") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] -_fileModuleFunction = Tuple[str, Optional[str], str] +_fileModuleFunction = tuple[str, Optional[str], str] class CoverageResults: def __init__( diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index eceba5420e6b..4e36490c24e4 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -1,9 +1,9 @@ import sys from _typeshed import SupportsWrite from types import FrameType, TracebackType -from typing import IO, Any, Generator, Iterable, Iterator, List, Mapping, Optional, Tuple, Type, overload +from typing import IO, Any, Generator, Iterable, Iterator, Mapping, Optional, Type, overload -_PT = Tuple[str, int, str, Optional[str]] +_PT = tuple[str, int, str, Optional[str]] def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | None = ...) -> None: ... @@ -146,7 +146,7 @@ class FrameSummary(Iterable[Any]): def __getitem__(self, i: int) -> Any: ... def __iter__(self) -> Iterator[Any]: ... -class StackSummary(List[FrameSummary]): +class StackSummary(list[FrameSummary]): @classmethod def extract( cls, diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 4666bd1565a0..4d7bbb7994a6 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,6 +1,6 @@ import sys from _tracemalloc import * -from typing import Optional, Sequence, Tuple, Union, overload +from typing import Optional, Sequence, Union, overload from typing_extensions import SupportsIndex def get_object_traceback(obj: object) -> Traceback | None: ... @@ -35,7 +35,7 @@ class StatisticDiff: traceback: Traceback def __init__(self, traceback: Traceback, size: int, size_diff: int, count: int, count_diff: int) -> None: ... -_FrameTupleT = Tuple[str, int] +_FrameTupleT = tuple[str, int] class Frame: filename: str @@ -43,9 +43,9 @@ class Frame: def __init__(self, frame: _FrameTupleT) -> None: ... if sys.version_info >= (3, 9): - _TraceTupleT = Union[Tuple[int, int, Sequence[_FrameTupleT], Optional[int]], Tuple[int, int, Sequence[_FrameTupleT]]] + _TraceTupleT = Union[tuple[int, int, Sequence[_FrameTupleT], Optional[int]], tuple[int, int, Sequence[_FrameTupleT]]] else: - _TraceTupleT = Tuple[int, int, Sequence[_FrameTupleT]] + _TraceTupleT = tuple[int, int, Sequence[_FrameTupleT]] class Trace: domain: int diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 8542fc8bfa24..9d20877927c1 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -1,22 +1,22 @@ from tkinter import Canvas, Frame, PhotoImage -from typing import Any, Callable, ClassVar, Dict, Sequence, Tuple, TypeVar, Union, overload +from typing import Any, Callable, ClassVar, Sequence, TypeVar, Union, overload # Note: '_Color' is the alias we use for arguments and _AnyColor is the # alias we use for return types. Really, these two aliases should be the # same, but as per the "no union returns" typeshed policy, we'll return # Any instead. -_Color = Union[str, Tuple[float, float, float]] +_Color = Union[str, tuple[float, float, float]] _AnyColor = Any # TODO: Replace this with a TypedDict once it becomes standardized. -_PenState = Dict[str, Any] +_PenState = dict[str, Any] _Speed = Union[str, float] -_PolygonCoords = Sequence[Tuple[float, float]] +_PolygonCoords = Sequence[tuple[float, float]] # TODO: Type this more accurately # Vec2D is actually a custom subclass of 'tuple'. -Vec2D = Tuple[float, float] +Vec2D = tuple[float, float] class ScrolledCanvas(Frame): ... @@ -251,7 +251,7 @@ class RawTurtle(TPen, TNavigator): # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp(self) -> Any: ... - def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... + def clearstamp(self, stampid: int | tuple[int, ...]) -> None: ... def clearstamps(self, n: int | None = ...) -> None: ... def filling(self) -> bool: ... def begin_fill(self) -> None: ... @@ -516,7 +516,7 @@ def tilt(angle: float) -> None: ... # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp() -> Any: ... -def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... +def clearstamp(stampid: int | tuple[int, ...]) -> None: ... def clearstamps(n: int | None = ...) -> None: ... def filling() -> bool: ... def begin_fill() -> None: ... diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 41f584f60f32..c0fe8bc3eabc 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -16,7 +16,6 @@ from typing import ( KeysView, Mapping, MutableSequence, - Tuple, Type, TypeVar, ValuesView, @@ -42,9 +41,9 @@ class _Cell: @final class FunctionType: - __closure__: Tuple[_Cell, ...] | None + __closure__: tuple[_Cell, ...] | None __code__: CodeType - __defaults__: Tuple[Any, ...] | None + __defaults__: tuple[Any, ...] | None __dict__: dict[str, Any] __globals__: dict[str, Any] __name__: str @@ -56,8 +55,8 @@ class FunctionType: code: CodeType, globals: dict[str, Any], name: str | None = ..., - argdefs: Tuple[object, ...] | None = ..., - closure: Tuple[_Cell, ...] | None = ..., + argdefs: tuple[object, ...] | None = ..., + closure: tuple[_Cell, ...] | None = ..., ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __get__(self, obj: object | None, type: type | None) -> MethodType: ... @@ -76,15 +75,15 @@ class CodeType: co_stacksize: int co_flags: int co_code: bytes - co_consts: Tuple[Any, ...] - co_names: Tuple[str, ...] - co_varnames: Tuple[str, ...] + co_consts: tuple[Any, ...] + co_names: tuple[str, ...] + co_varnames: tuple[str, ...] co_filename: str co_name: str co_firstlineno: int co_lnotab: bytes - co_freevars: Tuple[str, ...] - co_cellvars: Tuple[str, ...] + co_freevars: tuple[str, ...] + co_cellvars: tuple[str, ...] if sys.version_info >= (3, 8): def __init__( self, @@ -95,15 +94,15 @@ class CodeType: stacksize: int, flags: int, codestring: bytes, - constants: Tuple[Any, ...], - names: Tuple[str, ...], - varnames: Tuple[str, ...], + constants: tuple[Any, ...], + names: tuple[str, ...], + varnames: tuple[str, ...], filename: str, name: str, firstlineno: int, lnotab: bytes, - freevars: Tuple[str, ...] = ..., - cellvars: Tuple[str, ...] = ..., + freevars: tuple[str, ...] = ..., + cellvars: tuple[str, ...] = ..., ) -> None: ... else: def __init__( @@ -114,15 +113,15 @@ class CodeType: stacksize: int, flags: int, codestring: bytes, - constants: Tuple[Any, ...], - names: Tuple[str, ...], - varnames: Tuple[str, ...], + constants: tuple[Any, ...], + names: tuple[str, ...], + varnames: tuple[str, ...], filename: str, name: str, firstlineno: int, lnotab: bytes, - freevars: Tuple[str, ...] = ..., - cellvars: Tuple[str, ...] = ..., + freevars: tuple[str, ...] = ..., + cellvars: tuple[str, ...] = ..., ) -> None: ... if sys.version_info >= (3, 10): def replace( @@ -136,11 +135,11 @@ class CodeType: co_flags: int = ..., co_firstlineno: int = ..., co_code: bytes = ..., - co_consts: Tuple[Any, ...] = ..., - co_names: Tuple[str, ...] = ..., - co_varnames: Tuple[str, ...] = ..., - co_freevars: Tuple[str, ...] = ..., - co_cellvars: Tuple[str, ...] = ..., + co_consts: tuple[Any, ...] = ..., + co_names: tuple[str, ...] = ..., + co_varnames: tuple[str, ...] = ..., + co_freevars: tuple[str, ...] = ..., + co_cellvars: tuple[str, ...] = ..., co_filename: str = ..., co_name: str = ..., co_linetable: object = ..., @@ -159,11 +158,11 @@ class CodeType: co_flags: int = ..., co_firstlineno: int = ..., co_code: bytes = ..., - co_consts: Tuple[Any, ...] = ..., - co_names: Tuple[str, ...] = ..., - co_varnames: Tuple[str, ...] = ..., - co_freevars: Tuple[str, ...] = ..., - co_cellvars: Tuple[str, ...] = ..., + co_consts: tuple[Any, ...] = ..., + co_names: tuple[str, ...] = ..., + co_varnames: tuple[str, ...] = ..., + co_freevars: tuple[str, ...] = ..., + co_cellvars: tuple[str, ...] = ..., co_filename: str = ..., co_name: str = ..., co_lnotab: bytes = ..., @@ -281,8 +280,8 @@ class _StaticFunctionType: @final class MethodType: - __closure__: Tuple[_Cell, ...] | None # inherited from the added function - __defaults__: Tuple[Any, ...] | None # inherited from the added function + __closure__: tuple[_Cell, ...] | None # inherited from the added function + __defaults__: tuple[Any, ...] | None # inherited from the added function __func__: _StaticFunctionType __self__: object __name__: str # inherited from the added function @@ -385,18 +384,18 @@ if sys.version_info >= (3, 7): kwds: dict[str, Any] | None = ..., exec_body: Callable[[dict[str, Any]], None] | None = ..., ) -> type: ... - def resolve_bases(bases: Iterable[object]) -> Tuple[Any, ...]: ... + def resolve_bases(bases: Iterable[object]) -> tuple[Any, ...]: ... else: def new_class( name: str, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., kwds: dict[str, Any] | None = ..., exec_body: Callable[[dict[str, Any]], None] | None = ..., ) -> type: ... def prepare_class( - name: str, bases: Tuple[type, ...] = ..., kwds: dict[str, Any] | None = ... + name: str, bases: tuple[type, ...] = ..., kwds: dict[str, Any] | None = ... ) -> tuple[type, dict[str, Any], dict[str, Any]]: ... # Actually a different type, but `property` is special and we want that too. @@ -419,8 +418,8 @@ if sys.version_info >= (3, 8): if sys.version_info >= (3, 9): class GenericAlias: __origin__: type - __args__: Tuple[Any, ...] - __parameters__: Tuple[Any, ...] + __args__: tuple[Any, ...] + __parameters__: tuple[Any, ...] def __init__(self, origin: type, args: Any) -> None: ... def __getattr__(self, name: str) -> Any: ... # incomplete @@ -434,6 +433,6 @@ if sys.version_info >= (3, 10): NotImplementedType = _NotImplementedType # noqa F811 from builtins @final class UnionType: - __args__: Tuple[Any, ...] + __args__: tuple[Any, ...] def __or__(self, obj: Any) -> UnionType: ... def __ror__(self, obj: Any) -> UnionType: ... diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 3eb41c797f4a..e7f288377b83 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -22,7 +22,6 @@ from typing import ( NewType as NewType, NoReturn as NoReturn, Text as Text, - Tuple, Type as Type, TypeVar, ValuesView, @@ -87,7 +86,7 @@ if sys.version_info >= (3, 7): localns: dict[str, Any] | None = ..., include_extras: bool = ..., ) -> dict[str, Any]: ... - def get_args(tp: Any) -> Tuple[Any, ...]: ... + def get_args(tp: Any) -> tuple[Any, ...]: ... def get_origin(tp: Any) -> Any | None: ... Annotated: _SpecialForm = ... diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 370e35868e42..858bf38e700d 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -19,7 +19,6 @@ from typing import ( NoReturn, Pattern, Sequence, - Tuple, Type, TypeVar, overload, @@ -102,8 +101,8 @@ class TestCase: def assertIsNotNone(self, obj: Any, msg: Any = ...) -> None: ... def assertIn(self, member: Any, container: Iterable[Any] | Container[Any], msg: Any = ...) -> None: ... def assertNotIn(self, member: Any, container: Iterable[Any] | Container[Any], msg: Any = ...) -> None: ... - def assertIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: Any = ...) -> None: ... - def assertNotIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: Any = ...) -> None: ... + def assertIsInstance(self, obj: Any, cls: type | tuple[type, ...], msg: Any = ...) -> None: ... + def assertNotIsInstance(self, obj: Any, cls: type | tuple[type, ...], msg: Any = ...) -> None: ... def assertGreater(self, a: Any, b: Any, msg: Any = ...) -> None: ... def assertGreaterEqual(self, a: Any, b: Any, msg: Any = ...) -> None: ... def assertLess(self, a: Any, b: Any, msg: Any = ...) -> None: ... @@ -111,17 +110,17 @@ class TestCase: @overload def assertRaises( # type: ignore[misc] self, - expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...], + expected_exception: Type[BaseException] | tuple[Type[BaseException], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any, ) -> None: ... @overload - def assertRaises(self, expected_exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... + def assertRaises(self, expected_exception: Type[_E] | tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... @overload def assertRaisesRegex( # type: ignore[misc] self, - expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...], + expected_exception: Type[BaseException] | tuple[Type[BaseException], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -130,20 +129,20 @@ class TestCase: @overload def assertRaisesRegex( self, - expected_exception: Type[_E] | Tuple[Type[_E], ...], + expected_exception: Type[_E] | tuple[Type[_E], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertRaisesContext[_E]: ... @overload def assertWarns( # type: ignore[misc] - self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any + self, expected_warning: Type[Warning] | tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any ) -> None: ... @overload - def assertWarns(self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ... + def assertWarns(self, expected_warning: Type[Warning] | tuple[Type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ... @overload def assertWarnsRegex( # type: ignore[misc] self, - expected_warning: Type[Warning] | Tuple[Type[Warning], ...], + expected_warning: Type[Warning] | tuple[Type[Warning], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -152,7 +151,7 @@ class TestCase: @overload def assertWarnsRegex( self, - expected_warning: Type[Warning] | Tuple[Type[Warning], ...], + expected_warning: Type[Warning] | tuple[Type[Warning], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertWarnsContext: ... @@ -200,7 +199,7 @@ class TestCase: self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: Type[Sequence[Any]] | None = ... ) -> None: ... def assertListEqual(self, list1: list[Any], list2: list[Any], msg: Any = ...) -> None: ... - def assertTupleEqual(self, tuple1: Tuple[Any, ...], tuple2: Tuple[Any, ...], msg: Any = ...) -> None: ... + def assertTupleEqual(self, tuple1: tuple[Any, ...], tuple2: tuple[Any, ...], msg: Any = ...) -> None: ... def assertSetEqual(self, set1: AbstractSet[object], set2: AbstractSet[object], msg: Any = ...) -> None: ... def assertDictEqual(self, d1: Mapping[Any, object], d2: Mapping[Any, object], msg: Any = ...) -> None: ... def fail(self, msg: Any = ...) -> NoReturn: ... @@ -231,13 +230,13 @@ class TestCase: @overload def failUnlessRaises( # type: ignore[misc] self, - exception: Type[BaseException] | Tuple[Type[BaseException], ...], + exception: Type[BaseException] | tuple[Type[BaseException], ...], callable: Callable[..., Any] = ..., *args: Any, **kwargs: Any, ) -> None: ... @overload - def failUnlessRaises(self, exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... + def failUnlessRaises(self, exception: Type[_E] | tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... def failUnlessAlmostEqual(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... def assertAlmostEquals( self, first: float, second: float, places: int = ..., msg: Any = ..., delta: float = ... @@ -251,7 +250,7 @@ class TestCase: @overload def assertRaisesRegexp( # type: ignore[misc] self, - exception: Type[BaseException] | Tuple[Type[BaseException], ...], + exception: Type[BaseException] | tuple[Type[BaseException], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -260,7 +259,7 @@ class TestCase: @overload def assertRaisesRegexp( self, - exception: Type[_E] | Tuple[Type[_E], ...], + exception: Type[_E] | tuple[Type[_E], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertRaisesContext[_E]: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 394e9c9166eb..aca7e4f9554f 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -3,10 +3,10 @@ import unittest.case import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Callable, List, Pattern, Sequence, Type +from typing import Any, Callable, Pattern, Sequence, Type _SortComparisonMethod = Callable[[str, str], int] -_SuiteClass = Callable[[List[unittest.case.TestCase]], unittest.suite.TestSuite] +_SuiteClass = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite] VALID_MODULE_NAME: Pattern[str] diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index a84ab67b49f8..72d0bab95c2e 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Awaitable, Callable, Generic, Iterable, List, Mapping, Sequence, Tuple, Type, TypeVar, overload +from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, Type, TypeVar, overload _T = TypeVar("_T") _TT = TypeVar("_TT", bound=Type[Any]) @@ -96,7 +96,7 @@ class _Call(tuple[Any, ...]): call: _Call -class _CallList(List[_Call]): +class _CallList(list[_Call]): def __contains__(self, value: Any) -> bool: ... class Base: @@ -155,7 +155,7 @@ class NonCallableMock(Base, Any): call_args_list: _CallList mock_calls: _CallList def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ... - def _call_matcher(self, _call: Tuple[_Call, ...]) -> _Call: ... + def _call_matcher(self, _call: tuple[_Call, ...]) -> _Call: ... def _get_child_mock(self, **kw: Any) -> NonCallableMock: ... class CallableMixin(Base): diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 0ec4e9170388..9a19aef77d21 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -1,8 +1,8 @@ import unittest.case from types import TracebackType -from typing import Any, Callable, TextIO, Tuple, Type, TypeVar, Union +from typing import Any, Callable, TextIO, Type, TypeVar, Union -_SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, TracebackType], Tuple[None, None, None]] +_SysExcInfoType = Union[tuple[Type[BaseException], BaseException, TracebackType], tuple[None, None, None]] _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/stdlib/unittest/util.pyi b/stdlib/unittest/util.pyi index ab6ed053a6ff..680ca24b7c33 100644 --- a/stdlib/unittest/util.pyi +++ b/stdlib/unittest/util.pyi @@ -1,7 +1,7 @@ -from typing import Any, Sequence, Tuple, TypeVar +from typing import Any, Sequence, TypeVar _T = TypeVar("_T") -_Mismatch = Tuple[_T, _T, int] +_Mismatch = tuple[_T, _T, int] _MAX_LENGTH: int _PLACEHOLDER_LEN: int diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index a5afbdc26bf2..7404b5382014 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, AnyStr, Callable, Generic, Mapping, NamedTuple, Sequence, Tuple, Union, overload +from typing import Any, AnyStr, Callable, Generic, Mapping, NamedTuple, Sequence, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -35,7 +35,7 @@ class _NetlocResultMixinBase(Generic[AnyStr]): class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ... class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ... -class _DefragResultBase(Tuple[Any, ...], Generic[AnyStr]): +class _DefragResultBase(tuple[Any, ...], Generic[AnyStr]): url: AnyStr fragment: AnyStr diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 3c8a6facde6f..3749d7a390ea 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -4,7 +4,7 @@ from _typeshed import StrOrBytesPath from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar -from typing import IO, Any, Callable, ClassVar, Mapping, NoReturn, Pattern, Sequence, Tuple, TypeVar, overload +from typing import IO, Any, Callable, ClassVar, Mapping, NoReturn, Pattern, Sequence, TypeVar, overload from urllib.error import HTTPError from urllib.response import addclosehook, addinfourl @@ -196,9 +196,9 @@ class HTTPSHandler(AbstractHTTPHandler): def https_request(self, request: Request) -> Request: ... # undocumented class FileHandler(BaseHandler): - names: ClassVar[Tuple[str, ...] | None] # undocumented + names: ClassVar[tuple[str, ...] | None] # undocumented def file_open(self, req: Request) -> addinfourl: ... - def get_names(self) -> Tuple[str, ...]: ... # undocumented + def get_names(self) -> tuple[str, ...]: ... # undocumented def open_local_file(self, req: Request) -> addinfourl: ... # undocumented class DataHandler(BaseHandler): diff --git a/stdlib/urllib/response.pyi b/stdlib/urllib/response.pyi index 647ebf874432..18b498b40744 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import Self from email.message import Message from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Tuple, Type, TypeVar +from typing import IO, Any, BinaryIO, Callable, Iterable, Type, TypeVar _AIUT = TypeVar("_AIUT", bound=addbase) @@ -37,7 +37,7 @@ class addbase(BinaryIO): class addclosehook(addbase): closehook: Callable[..., object] - hookargs: Tuple[Any, ...] + hookargs: tuple[Any, ...] def __init__(self, fp: IO[bytes], closehook: Callable[..., object], *hookargs: Any) -> None: ... class addinfo(addbase): diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index da13d819fbdf..782c0491ffb2 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -1,10 +1,10 @@ import sys -from typing import Any, Tuple +from typing import Any # Because UUID has properties called int and bytes we need to rename these temporarily. _Int = int _Bytes = bytes -_FieldsType = Tuple[int, int, int, int, int, int] +_FieldsType = tuple[int, int, int, int, int, int] if sys.version_info >= (3, 7): from enum import Enum diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 16ebba39ef17..fd1cad7fe840 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -1,5 +1,5 @@ from _weakrefset import WeakSet as WeakSet -from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, Tuple, Type, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, Type, TypeVar, overload from _weakref import ( CallableProxyType as CallableProxyType, @@ -17,7 +17,7 @@ _KT = TypeVar("_KT") _VT = TypeVar("_VT") _CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) -ProxyTypes: Tuple[Type[Any], ...] +ProxyTypes: tuple[Type[Any], ...] class WeakMethod(ref[_CallableT], Generic[_CallableT]): def __new__(cls, meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> WeakMethod[_CallableT]: ... @@ -81,7 +81,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): class finalize: def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... def __call__(self, _: Any = ...) -> Any | None: ... - def detach(self) -> tuple[Any, Any, Tuple[Any, ...], dict[str, Any]] | None: ... - def peek(self) -> tuple[Any, Any, Tuple[Any, ...], dict[str, Any]] | None: ... + def detach(self) -> tuple[Any, Any, tuple[Any, ...], dict[str, Any]] | None: ... + def peek(self) -> tuple[Any, Any, tuple[Any, ...], dict[str, Any]] | None: ... alive: bool atexit: bool diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index ac1e56b7664e..eccc0d164767 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -1,12 +1,12 @@ from abc import abstractmethod from types import TracebackType -from typing import IO, Callable, MutableMapping, Optional, Tuple, Type +from typing import IO, Callable, MutableMapping, Optional, Type from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment from .util import FileWrapper -_exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_exc_info = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] def format_date_time(timestamp: float | None) -> str: ... # undocumented def read_environ() -> dict[str, str]: ... diff --git a/stdlib/wsgiref/headers.pyi b/stdlib/wsgiref/headers.pyi index 531a521d3824..b62124a2a936 100644 --- a/stdlib/wsgiref/headers.pyi +++ b/stdlib/wsgiref/headers.pyi @@ -1,6 +1,6 @@ -from typing import List, Pattern, Tuple, overload +from typing import Pattern, overload -_HeaderList = List[Tuple[str, str]] +_HeaderList = list[tuple[str, str]] tspecials: Pattern[str] # undocumented diff --git a/stdlib/xml/dom/minicompat.pyi b/stdlib/xml/dom/minicompat.pyi index 46d55c666cb0..38e6d05e4743 100644 --- a/stdlib/xml/dom/minicompat.pyi +++ b/stdlib/xml/dom/minicompat.pyi @@ -1,14 +1,14 @@ -from typing import Any, Iterable, List, Tuple, Type, TypeVar +from typing import Any, Iterable, Type, TypeVar _T = TypeVar("_T") StringTypes: tuple[Type[str]] -class NodeList(List[_T]): +class NodeList(list[_T]): length: int def item(self, index: int) -> _T | None: ... -class EmptyNodeList(Tuple[Any, ...]): +class EmptyNodeList(tuple[Any, ...]): length: int def item(self, index: int) -> None: ... def __add__(self, other: Iterable[_T]) -> NodeList[_T]: ... # type: ignore[override] diff --git a/stdlib/xml/dom/pulldom.pyi b/stdlib/xml/dom/pulldom.pyi index 530c1988e743..c2b7aa0772fa 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, Sequence, Tuple, Union +from typing import IO, Any, Sequence, Union from typing_extensions import Literal from xml.dom.minidom import Document, DOMImplementation, Element, Text from xml.sax.handler import ContentHandler @@ -17,7 +17,7 @@ CHARACTERS: Literal["CHARACTERS"] _DocumentFactory = Union[DOMImplementation, None] _Node = Union[Document, Element, Text] -_Event = Tuple[ +_Event = tuple[ Literal[ Literal["START_ELEMENT"], Literal["END_ELEMENT"], diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index db4bd6a4e958..5a2dd69c1bee 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -1,11 +1,11 @@ -from typing import Callable, Generator, List, Pattern, Tuple, TypeVar +from typing import Callable, Generator, Pattern, TypeVar from xml.etree.ElementTree import Element xpath_tokenizer_re: Pattern[str] -_token = Tuple[str, str] +_token = tuple[str, str] _next = Callable[[], _token] -_callback = Callable[[_SelectorContext, List[Element]], Generator[Element, None, None]] +_callback = Callable[[_SelectorContext, list[Element]], Generator[Element, None, None]] def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = ...) -> Generator[_token, None, None]: ... def get_parent_map(context: _SelectorContext) -> dict[Element, Element]: ... diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 6ee578b9aa81..c4236cf292bb 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -4,7 +4,6 @@ from typing import ( IO, Any, Callable, - Dict, Generator, ItemsView, Iterable, @@ -257,7 +256,7 @@ def fromstringlist(sequence: Sequence[str | bytes], parser: XMLParser | None = . # TreeBuilder is called by client code (they could pass strs, bytes or whatever); # but we don't want to use a too-broad type, or it would be too hard to write # elementfactories. -_ElementFactory = Callable[[Any, Dict[Any, Any]], Element] +_ElementFactory = Callable[[Any, dict[Any, Any]], Element] class TreeBuilder: if sys.version_info >= (3, 8): diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index b715e8b2928a..e9f9e03ae56d 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -6,16 +6,16 @@ from _typeshed import Self, SupportsRead, SupportsWrite from datetime import datetime from io import BytesIO from types import TracebackType -from typing import Any, Callable, Dict, Iterable, List, Mapping, Protocol, Tuple, Type, Union, overload +from typing import Any, Callable, Iterable, Mapping, Protocol, Type, Union, overload from typing_extensions import Literal class _SupportsTimeTuple(Protocol): def timetuple(self) -> time.struct_time: ... _DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple] -_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime, DateTime, Binary] -_XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time] -_HostType = Union[Tuple[str, Dict[str, str]], str] +_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime, DateTime, Binary] +_XMLDate = Union[int, datetime, tuple[int, ...], time.struct_time] +_HostType = Union[tuple[str, dict[str, str]], str] def escape(s: str) -> str: ... # undocumented @@ -63,7 +63,7 @@ def _strftime(value: _XMLDate) -> str: ... # undocumented class DateTime: value: str # undocumented - def __init__(self, value: int | str | datetime | time.struct_time | Tuple[int, ...] = ...) -> None: ... + def __init__(self, value: int | str | datetime | time.struct_time | tuple[int, ...] = ...) -> None: ... def __lt__(self, other: _DateTimeComparable) -> bool: ... def __le__(self, other: _DateTimeComparable) -> bool: ... def __gt__(self, other: _DateTimeComparable) -> bool: ... @@ -135,7 +135,7 @@ class Unmarshaller: _use_datetime: bool _use_builtin_types: bool def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ... - def close(self) -> Tuple[_Marshallable, ...]: ... + def close(self) -> tuple[_Marshallable, ...]: ... def getmethodname(self) -> str | None: ... def xml(self, encoding: str, standalone: Any) -> None: ... # Standalone is ignored def start(self, tag: str, attrs: dict[str, str]) -> None: ... @@ -159,7 +159,7 @@ class Unmarshaller: class _MultiCallMethod: # undocumented - __call_list: list[tuple[str, Tuple[_Marshallable, ...]]] + __call_list: list[tuple[str, tuple[_Marshallable, ...]]] __name: str def __init__(self, call_list: list[tuple[str, _Marshallable]], name: str) -> None: ... def __getattr__(self, name: str) -> _MultiCallMethod: ... @@ -174,7 +174,7 @@ class MultiCallIterator: # undocumented class MultiCall: __server: ServerProxy - __call_list: list[tuple[str, Tuple[_Marshallable, ...]]] + __call_list: list[tuple[str, tuple[_Marshallable, ...]]] def __init__(self, server: ServerProxy) -> None: ... def __getattr__(self, item: str) -> _MultiCallMethod: ... def __call__(self) -> MultiCallIterator: ... @@ -186,13 +186,13 @@ FastUnmarshaller: Unmarshaller | None def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[ExpatParser, Unmarshaller]: ... def dumps( - params: Fault | Tuple[_Marshallable, ...], + params: Fault | tuple[_Marshallable, ...], methodname: str | None = ..., methodresponse: bool | None = ..., encoding: str | None = ..., allow_none: bool = ..., ) -> str: ... -def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[Tuple[_Marshallable, ...], str | None]: ... +def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[tuple[_Marshallable, ...], str | None]: ... def gzip_encode(data: bytes) -> bytes: ... # undocumented def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ... # undocumented @@ -204,9 +204,9 @@ class GzipDecodedResponse(gzip.GzipFile): # undocumented class _Method: # undocumented - __send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable] + __send: Callable[[str, tuple[_Marshallable, ...]], _Marshallable] __name: str - def __init__(self, send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ... + def __init__(self, send: Callable[[str, tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ... def __getattr__(self, name: str) -> _Method: ... def __call__(self, *args: _Marshallable) -> _Marshallable: ... @@ -228,10 +228,10 @@ class Transport: ) -> None: ... else: def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ... - def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> Tuple[_Marshallable, ...]: ... + def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> tuple[_Marshallable, ...]: ... def single_request( self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ... - ) -> Tuple[_Marshallable, ...]: ... + ) -> tuple[_Marshallable, ...]: ... def getparser(self) -> tuple[ExpatParser, Unmarshaller]: ... def get_host_info(self, host: _HostType) -> tuple[str, list[tuple[str, str]], dict[str, str]]: ... def make_connection(self, host: _HostType) -> http.client.HTTPConnection: ... @@ -239,7 +239,7 @@ class Transport: def send_request(self, host: _HostType, handler: str, request_body: bytes, debug: bool) -> http.client.HTTPConnection: ... def send_headers(self, connection: http.client.HTTPConnection, headers: list[tuple[str, str]]) -> None: ... def send_content(self, connection: http.client.HTTPConnection, request_body: bytes) -> None: ... - def parse_response(self, response: http.client.HTTPResponse) -> Tuple[_Marshallable, ...]: ... + def parse_response(self, response: http.client.HTTPResponse) -> tuple[_Marshallable, ...]: ... class SafeTransport(Transport): @@ -304,6 +304,6 @@ class ServerProxy: self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __close(self) -> None: ... # undocumented - def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ... # undocumented + def __request(self, methodname: str, params: tuple[_Marshallable, ...]) -> tuple[_Marshallable, ...]: ... # undocumented Server = ServerProxy diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index f84253cef568..48105d1461f0 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -3,11 +3,11 @@ import pydoc import socketserver import sys from datetime import datetime -from typing import Any, Callable, Dict, Iterable, List, Mapping, Pattern, Protocol, Tuple, Type, Union +from typing import Any, Callable, Iterable, Mapping, Pattern, Protocol, Type, Union from xmlrpc.client import Fault # TODO: Recursive type on tuple, list, dict -_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime] +_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime] # The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy class _DispatchArity0(Protocol): @@ -53,7 +53,7 @@ class SimpleXMLRPCDispatcher: # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ..., + dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = ..., path: Any | None = ..., ) -> str: ... # undocumented def system_listMethods(self) -> list[str]: ... # undocumented @@ -109,7 +109,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ..., + dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = ..., path: Any | None = ..., ) -> str: ... diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 710b9b237b4c..c64690ba8ca9 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -3,10 +3,10 @@ import sys from _typeshed import Self, StrPath from os import PathLike from types import TracebackType -from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, Tuple, Type, overload +from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, Type, overload from typing_extensions import Literal -_DateTuple = Tuple[int, int, int, int, int, int] +_DateTuple = tuple[int, int, int, int, int, int] _ReadWriteMode = Literal["r", "w"] _ReadWriteBinaryMode = Literal["r", "w", "rb", "wb"] _ZipFileMode = Literal["r", "w", "x", "a"] diff --git a/stubs/Markdown/markdown/blockparser.pyi b/stubs/Markdown/markdown/blockparser.pyi index a747902f718e..e51db23729a2 100644 --- a/stubs/Markdown/markdown/blockparser.pyi +++ b/stubs/Markdown/markdown/blockparser.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, TypeVar +from typing import Any, Iterable, TypeVar from xml.etree.ElementTree import Element, ElementTree from . import Markdown @@ -6,7 +6,7 @@ from .util import Registry _T = TypeVar("_T") -class State(List[_T]): +class State(list[_T]): def set(self, state: _T) -> None: ... def reset(self) -> None: ... def isstate(self, state: _T) -> bool: ... diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 4d7113496b60..ca3fb6ff0cc5 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsRead, SupportsWrite from collections.abc import Iterable, Iterator, MutableMapping from pathlib import Path -from typing import Any, Callable, Dict, Protocol, Sequence, SupportsBytes, Tuple, Union +from typing import Any, Callable, Protocol, Sequence, SupportsBytes, Union from typing_extensions import Literal from ._imaging import ( @@ -16,13 +16,13 @@ from .ImagePalette import ImagePalette _Mode = Literal["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"] _Resample = Literal[0, 1, 2, 3, 4, 5] -_Size = Tuple[int, int] -_Box = Tuple[int, int, int, int] +_Size = tuple[int, int] +_Box = tuple[int, int, int, int] _ConversionMatrix = Union[ - Tuple[float, float, float, float], Tuple[float, float, float, float, float, float, float, float, float, float, float, float], + tuple[float, float, float, float], tuple[float, float, float, float, float, float, float, float, float, float, float, float], ] -_Color = Union[float, Tuple[float, ...]] +_Color = Union[float, tuple[float, ...]] class _Writeable(SupportsWrite[bytes], Protocol): def seek(self, __offset: int) -> Any: ... @@ -88,7 +88,7 @@ MODES: list[_Mode] def getmodebase(mode: _Mode) -> Literal["L", "RGB"]: ... def getmodetype(mode: _Mode) -> Literal["L", "I", "F"]: ... -def getmodebandnames(mode: _Mode) -> Tuple[str, ...]: ... +def getmodebandnames(mode: _Mode) -> tuple[str, ...]: ... def getmodebands(mode: _Mode) -> int: ... def preinit() -> None: ... def init() -> None: ... @@ -99,7 +99,7 @@ class _E: def __add__(self, other) -> _E: ... def __mul__(self, other) -> _E: ... -_ImageState = Tuple[Dict[str, Any], str, Tuple[int, int], Any, bytes] +_ImageState = tuple[dict[str, Any], str, tuple[int, int], Any, bytes] class Image: format: Any @@ -149,7 +149,7 @@ class Image: def crop(self, box: _Box | None = ...) -> Image: ... def draft(self, mode: str, size: _Size) -> None: ... def filter(self, filter: Filter | Callable[[], Filter]) -> Image: ... - def getbands(self) -> Tuple[str, ...]: ... + def getbands(self) -> tuple[str, ...]: ... def getbbox(self) -> tuple[int, int, int, int] | None: ... def getcolors(self, maxcolors: int = ...) -> list[tuple[int, int]]: ... def getdata(self, band: int | None = ...): ... @@ -197,7 +197,7 @@ class Image: ) -> None: ... def seek(self, frame: int) -> None: ... def show(self, title: str | None = ..., command: str | None = ...) -> None: ... - def split(self) -> Tuple[Image, ...]: ... + def split(self) -> tuple[Image, ...]: ... def getchannel(self, channel: int | str) -> Image: ... def tell(self) -> int: ... def thumbnail(self, size: tuple[int, int], resample: _Resample = ..., reducing_gap: float = ...) -> None: ... @@ -218,7 +218,7 @@ class Image: class ImagePointHandler: ... class ImageTransformHandler: ... -def new(mode: _Mode, size: tuple[int, int], color: float | Tuple[float, ...] | str = ...) -> Image: ... +def new(mode: _Mode, size: tuple[int, int], color: float | tuple[float, ...] | str = ...) -> Image: ... def frombytes(mode: _Mode, size: tuple[int, int], data, decoder_name: str = ..., *args) -> Image: ... def frombuffer(mode: _Mode, size: tuple[int, int], data, decoder_name: str = ..., *args) -> Image: ... def fromarray(obj, mode: _Mode | None = ...) -> Image: ... diff --git a/stubs/Pillow/PIL/ImageColor.pyi b/stubs/Pillow/PIL/ImageColor.pyi index 8e0db5292296..79aaba0ba7c1 100644 --- a/stubs/Pillow/PIL/ImageColor.pyi +++ b/stubs/Pillow/PIL/ImageColor.pyi @@ -1,8 +1,8 @@ -from typing import Tuple, Union +from typing import Union -_RGB = Union[Tuple[int, int, int], Tuple[int, int, int, int]] +_RGB = Union[tuple[int, int, int], tuple[int, int, int, int]] _Ink = Union[str, int, _RGB] -_GreyScale = Tuple[int, int] +_GreyScale = tuple[int, int] def getrgb(color: _Ink) -> _RGB: ... def getcolor(color: _Ink, mode: str) -> _RGB | _GreyScale: ... diff --git a/stubs/Pillow/PIL/ImageDraw.pyi b/stubs/Pillow/PIL/ImageDraw.pyi index 5ca32e3b3c8f..15c71b99abfb 100644 --- a/stubs/Pillow/PIL/ImageDraw.pyi +++ b/stubs/Pillow/PIL/ImageDraw.pyi @@ -1,12 +1,12 @@ from collections.abc import Container -from typing import Any, Sequence, Tuple, Union, overload +from typing import Any, Sequence, Union, overload from typing_extensions import Literal from .Image import Image from .ImageColor import _Ink from .ImageFont import _Font -_XY = Sequence[Union[float, Tuple[float, float]]] +_XY = Sequence[Union[float, tuple[float, float]]] _Outline = Any class ImageDraw: diff --git a/stubs/Pillow/PIL/ImageFilter.pyi b/stubs/Pillow/PIL/ImageFilter.pyi index af03bce671dd..e7991452317b 100644 --- a/stubs/Pillow/PIL/ImageFilter.pyi +++ b/stubs/Pillow/PIL/ImageFilter.pyi @@ -1,10 +1,10 @@ from _typeshed import Self -from typing import Any, Callable, Iterable, Sequence, Tuple, Type +from typing import Any, Callable, Iterable, Sequence, Type from typing_extensions import Literal from .Image import Image -_FilterArgs = Tuple[Sequence[int], int, int, Sequence[int]] +_FilterArgs = tuple[Sequence[int], int, int, Sequence[int]] # filter image parameters below are the C images, i.e. Image().im. diff --git a/stubs/Pillow/PIL/PdfParser.pyi b/stubs/Pillow/PIL/PdfParser.pyi index 4e484ae2a817..6cf70bc63668 100644 --- a/stubs/Pillow/PIL/PdfParser.pyi +++ b/stubs/Pillow/PIL/PdfParser.pyi @@ -1,5 +1,5 @@ import collections -from typing import Any, List +from typing import Any def encode_text(s: str) -> bytes: ... @@ -44,7 +44,7 @@ class PdfName: allowed_chars: Any def __bytes__(self): ... -class PdfArray(List[Any]): +class PdfArray(list[Any]): def __bytes__(self): ... class PdfDict(collections.UserDict): diff --git a/stubs/Pillow/PIL/TiffTags.pyi b/stubs/Pillow/PIL/TiffTags.pyi index 5559e169bd5c..64ede121bfb6 100644 --- a/stubs/Pillow/PIL/TiffTags.pyi +++ b/stubs/Pillow/PIL/TiffTags.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, NamedTuple, Tuple, Union +from typing import Any, NamedTuple, Union from typing_extensions import Literal class _TagInfo(NamedTuple): @@ -36,7 +36,7 @@ DOUBLE: Literal[12] IFD: Literal[13] _TagType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] -_TagTuple = Union[Tuple[str, _TagType, int], Tuple[str, _TagInfo, int, Dict[str, int]]] +_TagTuple = Union[tuple[str, _TagType, int], tuple[str, _TagInfo, int, dict[str, int]]] TAGS_V2: dict[int, _TagTuple] TAGS_V2_GROUPS: dict[int, dict[int, _TagTuple]] diff --git a/stubs/PyMySQL/pymysql/__init__.pyi b/stubs/PyMySQL/pymysql/__init__.pyi index 6babdc3fb4e5..c501ab39a9a6 100644 --- a/stubs/PyMySQL/pymysql/__init__.pyi +++ b/stubs/PyMySQL/pymysql/__init__.pyi @@ -1,5 +1,4 @@ import sys -from typing import FrozenSet from .connections import Connection as Connection from .constants import FIELD_TYPE as FIELD_TYPE @@ -30,7 +29,7 @@ threadsafety: int apilevel: str paramstyle: str -class DBAPISet(FrozenSet[int]): +class DBAPISet(frozenset[int]): def __ne__(self, other) -> bool: ... def __eq__(self, other) -> bool: ... def __hash__(self) -> int: ... diff --git a/stubs/PyMySQL/pymysql/connections.pyi b/stubs/PyMySQL/pymysql/connections.pyi index f30e0366167a..f357eb8b3db6 100644 --- a/stubs/PyMySQL/pymysql/connections.pyi +++ b/stubs/PyMySQL/pymysql/connections.pyi @@ -1,5 +1,5 @@ from socket import socket as _socket -from typing import Any, AnyStr, Generic, Mapping, Tuple, Type, TypeVar, overload +from typing import Any, AnyStr, Generic, Mapping, Type, TypeVar, overload from .charset import charset_by_id as charset_by_id, charset_by_name as charset_by_name from .constants import CLIENT as CLIENT, COMMAND as COMMAND, FIELD_TYPE as FIELD_TYPE, SERVER_STATUS as SERVER_STATUS @@ -35,7 +35,7 @@ class MysqlPacket: def read_uint64(self) -> Any: ... def read_length_encoded_integer(self) -> int: ... def read_length_coded_string(self) -> bytes: ... - def read_struct(self, fmt: str) -> Tuple[Any, ...]: ... + def read_struct(self, fmt: str) -> tuple[Any, ...]: ... def is_ok_packet(self) -> bool: ... def is_eof_packet(self) -> bool: ... def is_auth_switch_request(self) -> bool: ... diff --git a/stubs/PyMySQL/pymysql/cursors.pyi b/stubs/PyMySQL/pymysql/cursors.pyi index 45942196111e..be38c5494027 100644 --- a/stubs/PyMySQL/pymysql/cursors.pyi +++ b/stubs/PyMySQL/pymysql/cursors.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, Text, Tuple, TypeVar +from typing import Any, Iterable, Iterator, Text, TypeVar from .connections import Connection @@ -6,7 +6,7 @@ _SelfT = TypeVar("_SelfT") class Cursor: connection: Connection[Any] - description: Tuple[Text, ...] + description: tuple[Text, ...] rownumber: int rowcount: int arraysize: int @@ -27,21 +27,21 @@ class Cursor: def __enter__(self: _SelfT) -> _SelfT: ... def __exit__(self, *exc_info: Any) -> None: ... # Methods returning result tuples are below. - def fetchone(self) -> Tuple[Any, ...] | None: ... - def fetchmany(self, size: int | None = ...) -> Tuple[Tuple[Any, ...], ...]: ... - def fetchall(self) -> Tuple[Tuple[Any, ...], ...]: ... - def __iter__(self) -> Iterator[Tuple[Any, ...]]: ... + def fetchone(self) -> tuple[Any, ...] | None: ... + def fetchmany(self, size: int | None = ...) -> tuple[tuple[Any, ...], ...]: ... + def fetchall(self) -> tuple[tuple[Any, ...], ...]: ... + def __iter__(self) -> Iterator[tuple[Any, ...]]: ... class DictCursorMixin: dict_type: Any # TODO: add support if someone needs this def fetchone(self) -> dict[Text, Any] | None: ... - def fetchmany(self, size: int | None = ...) -> Tuple[dict[Text, Any], ...]: ... - def fetchall(self) -> Tuple[dict[Text, Any], ...]: ... + def fetchmany(self, size: int | None = ...) -> tuple[dict[Text, Any], ...]: ... + def fetchall(self) -> tuple[dict[Text, Any], ...]: ... def __iter__(self) -> Iterator[dict[Text, Any]]: ... class SSCursor(Cursor): - def fetchall(self) -> list[Tuple[Any, ...]]: ... # type: ignore[override] - def fetchall_unbuffered(self) -> Iterator[Tuple[Any, ...]]: ... + def fetchall(self) -> list[tuple[Any, ...]]: ... # type: ignore[override] + def fetchall_unbuffered(self) -> Iterator[tuple[Any, ...]]: ... def scroll(self, value: int, mode: Text = ...) -> None: ... class DictCursor(DictCursorMixin, Cursor): ... # type: ignore[misc] diff --git a/stubs/Pygments/pygments/lexer.pyi b/stubs/Pygments/pygments/lexer.pyi index 6ede8438bc04..379ba530816e 100644 --- a/stubs/Pygments/pygments/lexer.pyi +++ b/stubs/Pygments/pygments/lexer.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Iterator, Sequence -from typing import Any, Tuple +from typing import Any from pygments.token import _TokenType from pygments.util import Future @@ -40,7 +40,7 @@ class _inherit: ... inherit: Any -class combined(Tuple[Any]): +class combined(tuple[Any]): def __new__(cls, *args): ... def __init__(self, *args) -> None: ... diff --git a/stubs/Pygments/pygments/lexers/__init__.pyi b/stubs/Pygments/pygments/lexers/__init__.pyi index 23a2966c3890..14ca6673bd27 100644 --- a/stubs/Pygments/pygments/lexers/__init__.pyi +++ b/stubs/Pygments/pygments/lexers/__init__.pyi @@ -1,13 +1,13 @@ from _typeshed import StrOrBytesPath, StrPath from collections.abc import Iterator -from typing import Any, Tuple, Union +from typing import Any, Union from pygments.lexer import Lexer, LexerMeta _OpenFile = Union[StrOrBytesPath, int] # copy/pasted from builtins.pyi # TODO: use lower-case tuple once mypy updated -def get_all_lexers() -> Iterator[tuple[str, Tuple[str, ...], Tuple[str, ...], Tuple[str, ...]]]: ... +def get_all_lexers() -> Iterator[tuple[str, tuple[str, ...], tuple[str, ...], tuple[str, ...]]]: ... def find_lexer_class(name: str) -> LexerMeta | None: ... def find_lexer_class_by_name(_alias: str) -> LexerMeta: ... def get_lexer_by_name(_alias: str, **options: Any) -> Lexer: ... diff --git a/stubs/Pygments/pygments/token.pyi b/stubs/Pygments/pygments/token.pyi index 74a918f52dfb..e3790965a651 100644 --- a/stubs/Pygments/pygments/token.pyi +++ b/stubs/Pygments/pygments/token.pyi @@ -1,7 +1,6 @@ from collections.abc import Mapping -from typing import Tuple -class _TokenType(Tuple[str]): # TODO: change to lower-case tuple once new mypy released +class _TokenType(tuple[str]): # TODO: change to lower-case tuple once new mypy released parent: _TokenType | None def split(self) -> list[_TokenType]: ... subtypes: set[_TokenType] diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index fd2a90122e2a..8711bddb4d4e 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import BinaryIO, Iterable, Tuple +from typing import BinaryIO, Iterable from ..base import AsyncBase @@ -31,7 +31,7 @@ class AsyncTextIOWrapper(AsyncBase[str]): @property def line_buffering(self) -> bool: ... @property - def newlines(self) -> str | Tuple[str, ...] | None: ... + def newlines(self) -> str | tuple[str, ...] | None: ... @property def name(self) -> StrOrBytesPath | int: ... @property diff --git a/stubs/babel/babel/messages/plurals.pyi b/stubs/babel/babel/messages/plurals.pyi index 0f9ac943b0f5..5f75160f3d7f 100644 --- a/stubs/babel/babel/messages/plurals.pyi +++ b/stubs/babel/babel/messages/plurals.pyi @@ -1,10 +1,10 @@ -from typing import Any, Tuple +from typing import Any LC_CTYPE: Any PLURALS: Any DEFAULT_PLURAL: Any -class _PluralTuple(Tuple[int, str]): +class _PluralTuple(tuple[int, str]): num_plurals: Any plural_expr: Any plural_forms: Any diff --git a/stubs/beautifulsoup4/bs4/dammit.pyi b/stubs/beautifulsoup4/bs4/dammit.pyi index 97df5bfda88c..9dd69f4b4c46 100644 --- a/stubs/beautifulsoup4/bs4/dammit.pyi +++ b/stubs/beautifulsoup4/bs4/dammit.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable, Iterator from logging import Logger -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal chardet_type: Any @@ -77,7 +77,7 @@ class UnicodeDammit: @property def declared_html_encoding(self) -> str | None: ... def find_codec(self, charset: str) -> str | None: ... - MS_CHARS: dict[bytes, str | Tuple[str, ...]] + MS_CHARS: dict[bytes, str | tuple[str, ...]] MS_CHARS_TO_ASCII: dict[bytes, str] WINDOWS_1252_TO_UTF8: dict[int, bytes] MULTIBYTE_MARKERS_AND_SIZES: list[tuple[int, int, int]] diff --git a/stubs/beautifulsoup4/bs4/element.pyi b/stubs/beautifulsoup4/bs4/element.pyi index 9e7b2d1c2a35..576e3e6b4241 100644 --- a/stubs/beautifulsoup4/bs4/element.pyi +++ b/stubs/beautifulsoup4/bs4/element.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from collections.abc import Iterator -from typing import Any, Callable, Generic, Iterable, List, Mapping, Pattern, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, Iterable, Mapping, Pattern, Type, TypeVar, Union, overload from . import BeautifulSoup from .builder import TreeBuilder @@ -53,7 +53,7 @@ class PageElement: previousSibling: PageElement | None @property def stripped_strings(self) -> Iterator[str]: ... - def get_text(self, separator: str = ..., strip: bool = ..., types: Tuple[Type[NavigableString], ...] = ...) -> str: ... + def get_text(self, separator: str = ..., strip: bool = ..., types: tuple[Type[NavigableString], ...] = ...) -> str: ... getText = get_text @property def text(self) -> str: ... @@ -256,7 +256,7 @@ class Tag(PageElement): can_be_empty_element: bool | None = ..., cdata_list_attributes: list[str] | None = ..., preserve_whitespace_tags: list[str] | None = ..., - interesting_string_types: Type[NavigableString] | Tuple[Type[NavigableString], ...] | None = ..., + interesting_string_types: Type[NavigableString] | tuple[Type[NavigableString], ...] | None = ..., ) -> None: ... parserClass: Type[BeautifulSoup] | None def __copy__(self: Self) -> Self: ... @@ -267,7 +267,7 @@ class Tag(PageElement): def string(self) -> str | None: ... @string.setter def string(self, string: str) -> None: ... - DEFAULT_INTERESTING_STRING_TYPES: Tuple[Type[NavigableString], ...] + DEFAULT_INTERESTING_STRING_TYPES: tuple[Type[NavigableString], ...] @property def strings(self) -> Iterable[str]: ... def decompose(self) -> None: ... @@ -348,6 +348,6 @@ class SoupStrainer: searchTag = search_tag def search(self, markup: PageElement | Iterable[PageElement]): ... -class ResultSet(List[_PageElementT], Generic[_PageElementT]): +class ResultSet(list[_PageElementT], Generic[_PageElementT]): source: SoupStrainer def __init__(self, source: SoupStrainer, result: Iterable[_PageElementT] = ...) -> None: ... diff --git a/stubs/bleach/bleach/sanitizer.pyi b/stubs/bleach/bleach/sanitizer.pyi index 0966af2096d6..4adf96e47194 100644 --- a/stubs/bleach/bleach/sanitizer.pyi +++ b/stubs/bleach/bleach/sanitizer.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Container, Iterable -from typing import Any, Dict, List, Pattern, Union +from typing import Any, Pattern, Union from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter @@ -39,8 +39,8 @@ class Cleaner(object): def clean(self, text: str) -> str: ... _AttributeFilter = Callable[[str, str, str], bool] -_AttributeDict = Union[Dict[str, Union[List[str], _AttributeFilter]], Dict[str, List[str]], Dict[str, _AttributeFilter]] -_Attributes = Union[_AttributeFilter, _AttributeDict, List[str]] +_AttributeDict = Union[dict[str, Union[list[str], _AttributeFilter]], dict[str, list[str]], dict[str, _AttributeFilter]] +_Attributes = Union[_AttributeFilter, _AttributeDict, list[str]] def attribute_filter_factory(attributes: _Attributes) -> _AttributeFilter: ... diff --git a/stubs/boto/boto/s3/cors.pyi b/stubs/boto/boto/s3/cors.pyi index f31e612f748d..125587f9ba0e 100644 --- a/stubs/boto/boto/s3/cors.pyi +++ b/stubs/boto/boto/s3/cors.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class CORSRule: allowed_method: Any @@ -20,7 +20,7 @@ class CORSRule: def endElement(self, name, value, connection): ... def to_xml(self) -> str: ... -class CORSConfiguration(List[CORSRule]): +class CORSConfiguration(list[CORSRule]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self) -> str: ... diff --git a/stubs/boto/boto/s3/lifecycle.pyi b/stubs/boto/boto/s3/lifecycle.pyi index bf750bb2e50f..7919bad712df 100644 --- a/stubs/boto/boto/s3/lifecycle.pyi +++ b/stubs/boto/boto/s3/lifecycle.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class Rule: id: Any @@ -33,7 +33,7 @@ class Transition: def __init__(self, days: Any | None = ..., date: Any | None = ..., storage_class: Any | None = ...) -> None: ... def to_xml(self): ... -class Transitions(List[Transition]): +class Transitions(list[Transition]): transition_properties: int current_transition_property: int temp_days: Any @@ -51,7 +51,7 @@ class Transitions(List[Transition]): @property def storage_class(self): ... -class Lifecycle(List[Rule]): +class Lifecycle(list[Rule]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... diff --git a/stubs/boto/boto/s3/tagging.pyi b/stubs/boto/boto/s3/tagging.pyi index ad1bcf8039f4..98a954d5fd8e 100644 --- a/stubs/boto/boto/s3/tagging.pyi +++ b/stubs/boto/boto/s3/tagging.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class Tag: key: Any @@ -9,13 +9,13 @@ class Tag: def to_xml(self): ... def __eq__(self, other): ... -class TagSet(List[Tag]): +class TagSet(list[Tag]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def add_tag(self, key, value): ... def to_xml(self): ... -class Tags(List[TagSet]): +class Tags(list[TagSet]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... diff --git a/stubs/boto/boto/s3/website.pyi b/stubs/boto/boto/s3/website.pyi index 186afdf1fdd1..e913f6dde791 100644 --- a/stubs/boto/boto/s3/website.pyi +++ b/stubs/boto/boto/s3/website.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any def tag(key, value): ... @@ -33,7 +33,7 @@ class RedirectLocation(_XMLKeyValue): def __init__(self, hostname: Any | None = ..., protocol: Any | None = ...) -> None: ... def to_xml(self): ... -class RoutingRules(List[RoutingRule]): +class RoutingRules(list[RoutingRule]): def add_rule(self, rule: RoutingRule) -> RoutingRules: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 3e650b1fea31..91d2942f6132 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -3,7 +3,7 @@ import logging.handlers import subprocess import sys import time -from typing import IO, Any, Callable, ContextManager, Dict, Iterable, Mapping, Sequence, Type, TypeVar +from typing import IO, Any, Callable, ContextManager, Iterable, Mapping, Sequence, Type, TypeVar import boto.connection @@ -50,7 +50,7 @@ def merge_meta( def get_aws_metadata(headers: Mapping[str, str], provider: _Provider | None = ...) -> Mapping[str, str]: ... def retry_url(url: str, retry_on_404: bool = ..., num_retries: int = ..., timeout: int | None = ...) -> str: ... -class LazyLoadMetadata(Dict[_KT, _VT]): +class LazyLoadMetadata(dict[_KT, _VT]): def __init__(self, url: str, num_retries: int, timeout: int | None = ...) -> None: ... def get_instance_metadata( @@ -101,7 +101,7 @@ class AuthSMTPHandler(logging.handlers.SMTPHandler): self, mailhost: str, username: str, password: str, fromaddr: str, toaddrs: Sequence[str], subject: str ) -> None: ... -class LRUCache(Dict[_KT, _VT]): +class LRUCache(dict[_KT, _VT]): class _Item: previous: LRUCache._Item | None next: LRUCache._Item | None diff --git a/stubs/cachetools/cachetools/keys.pyi b/stubs/cachetools/cachetools/keys.pyi index 9effbe6e171f..ef3e1120f4f9 100644 --- a/stubs/cachetools/cachetools/keys.pyi +++ b/stubs/cachetools/cachetools/keys.pyi @@ -1,4 +1,4 @@ -from typing import Hashable, Tuple +from typing import Hashable -def hashkey(*args: Hashable, **kwargs: Hashable) -> Tuple[Hashable, ...]: ... -def typedkey(*args: Hashable, **kwargs: Hashable) -> Tuple[Hashable, ...]: ... +def hashkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... +def typedkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... diff --git a/stubs/chardet/chardet/__init__.pyi b/stubs/chardet/chardet/__init__.pyi index 54e48f5c7233..7f883dabaf7b 100644 --- a/stubs/chardet/chardet/__init__.pyi +++ b/stubs/chardet/chardet/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Tuple +from typing import Any from .universaldetector import UniversalDetector as UniversalDetector @@ -11,16 +11,16 @@ else: from typing_extensions import TypedDict class _LangModelType(TypedDict): - char_to_order_map: Tuple[int, ...] - precedence_matrix: Tuple[int, ...] + char_to_order_map: tuple[int, ...] + precedence_matrix: tuple[int, ...] typical_positive_ratio: float keep_english_letter: bool charset_name: str language: str class _SMModelType(TypedDict): - class_table: Tuple[int, ...] + class_table: tuple[int, ...] class_factor: int - state_table: Tuple[int, ...] - char_len_table: Tuple[int, ...] + state_table: tuple[int, ...] + char_len_table: tuple[int, ...] name: str diff --git a/stubs/chardet/chardet/langbulgarianmodel.pyi b/stubs/chardet/chardet/langbulgarianmodel.pyi index de07cfa7b1b4..07344de5c895 100644 --- a/stubs/chardet/chardet/langbulgarianmodel.pyi +++ b/stubs/chardet/chardet/langbulgarianmodel.pyi @@ -1,9 +1,7 @@ -from typing import Tuple - from . import _LangModelType -Latin5_BulgarianCharToOrderMap: Tuple[int, ...] -win1251BulgarianCharToOrderMap: Tuple[int, ...] -BulgarianLangModel: Tuple[int, ...] +Latin5_BulgarianCharToOrderMap: tuple[int, ...] +win1251BulgarianCharToOrderMap: tuple[int, ...] +BulgarianLangModel: tuple[int, ...] Latin5BulgarianModel: _LangModelType Win1251BulgarianModel: _LangModelType diff --git a/stubs/chardet/chardet/langcyrillicmodel.pyi b/stubs/chardet/chardet/langcyrillicmodel.pyi index 40a7044b1398..22e7c52dc20a 100644 --- a/stubs/chardet/chardet/langcyrillicmodel.pyi +++ b/stubs/chardet/chardet/langcyrillicmodel.pyi @@ -1,14 +1,12 @@ -from typing import Tuple - from . import _LangModelType -KOI8R_char_to_order_map: Tuple[int, ...] -win1251_char_to_order_map: Tuple[int, ...] -latin5_char_to_order_map: Tuple[int, ...] -macCyrillic_char_to_order_map: Tuple[int, ...] -IBM855_char_to_order_map: Tuple[int, ...] -IBM866_char_to_order_map: Tuple[int, ...] -RussianLangModel: Tuple[int, ...] +KOI8R_char_to_order_map: tuple[int, ...] +win1251_char_to_order_map: tuple[int, ...] +latin5_char_to_order_map: tuple[int, ...] +macCyrillic_char_to_order_map: tuple[int, ...] +IBM855_char_to_order_map: tuple[int, ...] +IBM866_char_to_order_map: tuple[int, ...] +RussianLangModel: tuple[int, ...] Koi8rModel: _LangModelType Win1251CyrillicModel: _LangModelType Latin5CyrillicModel: _LangModelType diff --git a/stubs/chardet/chardet/langgreekmodel.pyi b/stubs/chardet/chardet/langgreekmodel.pyi index f0fa3e8c21d3..ceee125a2341 100644 --- a/stubs/chardet/chardet/langgreekmodel.pyi +++ b/stubs/chardet/chardet/langgreekmodel.pyi @@ -1,9 +1,7 @@ -from typing import Tuple - from . import _LangModelType -Latin7_char_to_order_map: Tuple[int, ...] -win1253_char_to_order_map: Tuple[int, ...] -GreekLangModel: Tuple[int, ...] +Latin7_char_to_order_map: tuple[int, ...] +win1253_char_to_order_map: tuple[int, ...] +GreekLangModel: tuple[int, ...] Latin7GreekModel: _LangModelType Win1253GreekModel: _LangModelType diff --git a/stubs/chardet/chardet/langhebrewmodel.pyi b/stubs/chardet/chardet/langhebrewmodel.pyi index 08bfbc91bf26..a17e10de3023 100644 --- a/stubs/chardet/chardet/langhebrewmodel.pyi +++ b/stubs/chardet/chardet/langhebrewmodel.pyi @@ -1,7 +1,5 @@ -from typing import Tuple - from . import _LangModelType -WIN1255_CHAR_TO_ORDER_MAP: Tuple[int, ...] -HEBREW_LANG_MODEL: Tuple[int, ...] +WIN1255_CHAR_TO_ORDER_MAP: tuple[int, ...] +HEBREW_LANG_MODEL: tuple[int, ...] Win1255HebrewModel: _LangModelType diff --git a/stubs/chardet/chardet/langhungarianmodel.pyi b/stubs/chardet/chardet/langhungarianmodel.pyi index 01e4a44380c2..498c7da58a9d 100644 --- a/stubs/chardet/chardet/langhungarianmodel.pyi +++ b/stubs/chardet/chardet/langhungarianmodel.pyi @@ -1,9 +1,7 @@ -from typing import Tuple - from . import _LangModelType -Latin2_HungarianCharToOrderMap: Tuple[int, ...] -win1250HungarianCharToOrderMap: Tuple[int, ...] -HungarianLangModel: Tuple[int, ...] +Latin2_HungarianCharToOrderMap: tuple[int, ...] +win1250HungarianCharToOrderMap: tuple[int, ...] +HungarianLangModel: tuple[int, ...] Latin2HungarianModel: _LangModelType Win1250HungarianModel: _LangModelType diff --git a/stubs/chardet/chardet/langthaimodel.pyi b/stubs/chardet/chardet/langthaimodel.pyi index 93149e72b16c..eee2356e8ead 100644 --- a/stubs/chardet/chardet/langthaimodel.pyi +++ b/stubs/chardet/chardet/langthaimodel.pyi @@ -1,7 +1,5 @@ -from typing import Tuple - from . import _LangModelType -TIS620CharToOrderMap: Tuple[int, ...] -ThaiLangModel: Tuple[int, ...] +TIS620CharToOrderMap: tuple[int, ...] +ThaiLangModel: tuple[int, ...] TIS620ThaiModel: _LangModelType diff --git a/stubs/chardet/chardet/langturkishmodel.pyi b/stubs/chardet/chardet/langturkishmodel.pyi index 65b1bdcbbe2d..6686f262d619 100644 --- a/stubs/chardet/chardet/langturkishmodel.pyi +++ b/stubs/chardet/chardet/langturkishmodel.pyi @@ -1,7 +1,5 @@ -from typing import Tuple - from . import _LangModelType -Latin5_TurkishCharToOrderMap: Tuple[int, ...] -TurkishLangModel: Tuple[int, ...] +Latin5_TurkishCharToOrderMap: tuple[int, ...] +TurkishLangModel: tuple[int, ...] Latin5TurkishModel: _LangModelType diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index 117fe8f6265c..9cf3008e86b2 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import SupportsWrite -from typing import Any, Callable, Dict, Optional, Pattern, Sequence, TextIO, Tuple, Union +from typing import Any, Callable, Optional, Pattern, Sequence, TextIO, Union if sys.platform == "win32": from .winterm import WinTerm @@ -20,7 +20,7 @@ class StreamWrapper: def closed(self) -> bool: ... _WinTermCall = Callable[[Optional[int], bool, bool], None] -_WinTermCallDict = Dict[int, Union[Tuple[_WinTermCall], Tuple[_WinTermCall, int], Tuple[_WinTermCall, int, bool]]] +_WinTermCallDict = dict[int, Union[tuple[_WinTermCall], tuple[_WinTermCall, int], tuple[_WinTermCall, int, bool]]] class AnsiToWin32: ANSI_CSI_RE: Pattern[str] = ... @@ -40,6 +40,6 @@ class AnsiToWin32: def write_and_convert(self, text: str) -> None: ... def write_plain_text(self, text: str, start: int, end: int) -> None: ... def convert_ansi(self, paramstring: str, command: str) -> None: ... - def extract_params(self, command: str, paramstring: str) -> Tuple[int, ...]: ... + def extract_params(self, command: str, paramstring: str) -> tuple[int, ...]: ... def call_win32(self, command: str, params: Sequence[int]) -> None: ... def convert_osc(self, text: str) -> str: ... diff --git a/stubs/croniter/croniter.pyi b/stubs/croniter/croniter.pyi index 820e0ee50a42..1c864f5cc769 100644 --- a/stubs/croniter/croniter.pyi +++ b/stubs/croniter/croniter.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Any, Iterator, Text, Tuple, Type, TypeVar, Union +from typing import Any, Iterator, Text, Type, TypeVar, Union from typing_extensions import Literal _RetType = Union[Type[float], Type[datetime.datetime]] @@ -12,7 +12,7 @@ class CroniterNotAlphaError(CroniterError): ... class croniter(Iterator[Any]): MONTHS_IN_YEAR: Literal[12] - RANGES: Tuple[tuple[int, int], ...] + RANGES: tuple[tuple[int, int], ...] DAYS: tuple[ Literal[31], Literal[28], @@ -27,9 +27,9 @@ class croniter(Iterator[Any]): Literal[30], Literal[31], ] - ALPHACONV: Tuple[dict[str, Any], ...] - LOWMAP: Tuple[dict[int, Any], ...] - LEN_MEANS_ALL: Tuple[int, ...] + ALPHACONV: tuple[dict[str, Any], ...] + LOWMAP: tuple[dict[int, Any], ...] + LEN_MEANS_ALL: tuple[int, ...] bad_length: str tzinfo: datetime.tzinfo | None cur: float diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index a76db82bd6ac..922b26c186b1 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Generic, Iterable, Mapping, Tuple, Type, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Mapping, Type, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -15,7 +15,7 @@ def asdict(obj: Any) -> dict[str, Any]: ... @overload def asdict(obj: Any, *, dict_factory: Callable[[list[tuple[str, Any]]], _T]) -> _T: ... @overload -def astuple(obj: Any) -> Tuple[Any, ...]: ... +def astuple(obj: Any) -> tuple[Any, ...]: ... @overload def astuple(obj: Any, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ... @overload @@ -66,7 +66,7 @@ def field( def field( *, init: bool = ..., repr: bool = ..., hash: bool | None = ..., compare: bool = ..., metadata: Mapping[str, Any] | None = ... ) -> Any: ... -def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... +def fields(class_or_instance: Any) -> tuple[Field[Any], ...]: ... def is_dataclass(obj: Any) -> bool: ... class FrozenInstanceError(AttributeError): ... @@ -79,7 +79,7 @@ def make_dataclass( cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., diff --git a/stubs/dateparser/dateparser/search/__init__.pyi b/stubs/dateparser/dateparser/search/__init__.pyi index 2fbbdcbb0933..7116034fc157 100644 --- a/stubs/dateparser/dateparser/search/__init__.pyi +++ b/stubs/dateparser/dateparser/search/__init__.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Mapping, Set as AbstractSet from datetime import datetime -from typing import Any, Tuple, overload +from typing import Any, overload if sys.version_info >= (3, 8): from typing import Literal @@ -11,14 +11,14 @@ else: @overload def search_dates( text: str, - languages: list[str] | Tuple[str, ...] | AbstractSet[str] | None, + languages: list[str] | tuple[str, ...] | AbstractSet[str] | None, settings: Mapping[Any, Any] | None, add_detected_language: Literal[True], ) -> list[tuple[str, datetime, str]]: ... @overload def search_dates( text: str, - languages: list[str] | Tuple[str, ...] | AbstractSet[str] | None = ..., + languages: list[str] | tuple[str, ...] | AbstractSet[str] | None = ..., settings: Mapping[Any, Any] | None = ..., add_detected_language: Literal[False] = ..., ) -> list[tuple[str, datetime]]: ... diff --git a/stubs/decorator/decorator.pyi b/stubs/decorator/decorator.pyi index 0d50a5412a1d..622726106b25 100644 --- a/stubs/decorator/decorator.pyi +++ b/stubs/decorator/decorator.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Iterator, NamedTuple, Pattern, Text, Tuple, TypeVar +from typing import Any, Callable, Iterator, NamedTuple, Pattern, Text, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) _Func = TypeVar("_Func", bound=Callable[..., Any]) @@ -14,7 +14,7 @@ else: args: list[str] varargs: str | None varkw: str | None - defaults: Tuple[Any, ...] + defaults: tuple[Any, ...] kwonlyargs: list[str] kwonlydefaults: dict[str, Any] annotations: dict[str, Any] @@ -34,7 +34,7 @@ class FunctionMaker(object): args: list[Text] varargs: Text | None varkw: Text | None - defaults: Tuple[Any, ...] + defaults: tuple[Any, ...] kwonlyargs: list[Text] kwonlydefaults: Text | None shortsignature: Text | None @@ -49,7 +49,7 @@ class FunctionMaker(object): func: Callable[..., Any] | None = ..., name: Text | None = ..., signature: Text | None = ..., - defaults: Tuple[Any, ...] | None = ..., + defaults: tuple[Any, ...] | None = ..., doc: Text | None = ..., module: Text | None = ..., funcdict: _dict[Text, Any] | None = ..., @@ -64,7 +64,7 @@ class FunctionMaker(object): obj: Any, body: Text, evaldict: _dict[Text, Any], - defaults: Tuple[Any, ...] | None = ..., + defaults: tuple[Any, ...] | None = ..., doc: Text | None = ..., module: Text | None = ..., addsource: bool = ..., diff --git a/stubs/docutils/docutils/__init__.pyi b/stubs/docutils/docutils/__init__.pyi index d4477b9624b0..4a113c725fa4 100644 --- a/stubs/docutils/docutils/__init__.pyi +++ b/stubs/docutils/docutils/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, NamedTuple, Tuple +from typing import Any, ClassVar, NamedTuple __docformat__: str __version__: str @@ -23,19 +23,19 @@ class ApplicationError(Exception): ... class DataError(ApplicationError): ... class SettingsSpec: - settings_spec: ClassVar[Tuple[Any, ...]] + settings_spec: ClassVar[tuple[Any, ...]] settings_defaults: ClassVar[dict[Any, Any] | None] settings_default_overrides: ClassVar[dict[Any, Any] | None] - relative_path_settings: ClassVar[Tuple[Any, ...]] + relative_path_settings: ClassVar[tuple[Any, ...]] config_section: ClassVar[str | None] - config_section_dependencies: ClassVar[Tuple[str, ...] | None] + config_section_dependencies: ClassVar[tuple[str, ...] | None] class TransformSpec: def get_transforms(self) -> list[Any]: ... - default_transforms: ClassVar[Tuple[Any, ...]] + default_transforms: ClassVar[tuple[Any, ...]] unknown_reference_resolvers: ClassVar[list[Any]] class Component(SettingsSpec, TransformSpec): component_type: ClassVar[str | None] - supported: ClassVar[Tuple[str, ...]] + supported: ClassVar[tuple[str, ...]] def supports(self, format: str) -> bool: ... diff --git a/stubs/docutils/docutils/frontend.pyi b/stubs/docutils/docutils/frontend.pyi index c32dc44ffb5e..0ec65862916f 100644 --- a/stubs/docutils/docutils/frontend.pyi +++ b/stubs/docutils/docutils/frontend.pyi @@ -1,7 +1,7 @@ import optparse from collections.abc import Iterable, Mapping from configparser import RawConfigParser -from typing import Any, ClassVar, Tuple, Type +from typing import Any, ClassVar, Type from docutils import SettingsSpec from docutils.parsers import Parser @@ -45,7 +45,7 @@ def validate_smartquotes_locales( ) -> list[tuple[str, str]]: ... def make_paths_absolute(pathdict, keys, base_path: Any | None = ...) -> None: ... def make_one_path_absolute(base_path, path) -> str: ... -def filter_settings_spec(settings_spec, *exclude, **replace) -> Tuple[Any, ...]: ... +def filter_settings_spec(settings_spec, *exclude, **replace) -> tuple[Any, ...]: ... class Values(optparse.Values): def update(self, other_dict, option_parser) -> None: ... diff --git a/stubs/docutils/docutils/parsers/null.pyi b/stubs/docutils/docutils/parsers/null.pyi index 1d3629109243..edc977325a1d 100644 --- a/stubs/docutils/docutils/parsers/null.pyi +++ b/stubs/docutils/docutils/parsers/null.pyi @@ -1,6 +1,6 @@ -from typing import ClassVar, Tuple +from typing import ClassVar from docutils import parsers class Parser(parsers.Parser): - config_section_dependencies: ClassVar[Tuple[str, ...]] + config_section_dependencies: ClassVar[tuple[str, ...]] diff --git a/stubs/docutils/docutils/parsers/rst/__init__.pyi b/stubs/docutils/docutils/parsers/rst/__init__.pyi index f605176c4173..b9cc02940ce0 100644 --- a/stubs/docutils/docutils/parsers/rst/__init__.pyi +++ b/stubs/docutils/docutils/parsers/rst/__init__.pyi @@ -1,11 +1,11 @@ -from typing import Any, ClassVar, Tuple +from typing import Any, ClassVar from typing_extensions import Literal from docutils import parsers from docutils.parsers.rst import states class Parser(parsers.Parser): - config_section_dependencies: ClassVar[Tuple[str, ...]] + config_section_dependencies: ClassVar[tuple[str, ...]] initial_state: Literal["Body", "RFC2822Body"] state_classes: Any inliner: Any diff --git a/stubs/docutils/docutils/parsers/rst/roles.pyi b/stubs/docutils/docutils/parsers/rst/roles.pyi index 2c3d65b68c94..4a319e6bbf64 100644 --- a/stubs/docutils/docutils/parsers/rst/roles.pyi +++ b/stubs/docutils/docutils/parsers/rst/roles.pyi @@ -1,11 +1,11 @@ -from typing import Any, Callable, Dict, List, Tuple +from typing import Any, Callable import docutils.nodes import docutils.parsers.rst.states _RoleFn = Callable[ - [str, str, str, int, docutils.parsers.rst.states.Inliner, Dict[str, Any], List[str]], - Tuple[List[docutils.nodes.reference], List[docutils.nodes.reference]], + [str, str, str, int, docutils.parsers.rst.states.Inliner, dict[str, Any], list[str]], + tuple[list[docutils.nodes.reference], list[docutils.nodes.reference]], ] def register_local_role(name: str, role_fn: _RoleFn) -> None: ... diff --git a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi index 066a43e538c5..11f052fdb2ac 100644 --- a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi +++ b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi @@ -1,8 +1,8 @@ import argparse import ast -from typing import Any, Generic, Iterable, Iterator, Tuple, Type, TypeVar +from typing import Any, Generic, Iterable, Iterator, Type, TypeVar -FLAKE8_ERROR = Tuple[int, int, str, Type[Any]] +FLAKE8_ERROR = tuple[int, int, str, Type[Any]] TConfig = TypeVar("TConfig") # noqa: Y001 class Error: diff --git a/stubs/fpdf2/fpdf/image_parsing.pyi b/stubs/fpdf2/fpdf/image_parsing.pyi index 6355b3adf3c2..14c4f4bcd261 100644 --- a/stubs/fpdf2/fpdf/image_parsing.pyi +++ b/stubs/fpdf2/fpdf/image_parsing.pyi @@ -1,9 +1,9 @@ -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal _ImageFilter = Literal["AUTO", "FlateDecode", "DCTDecode", "JPXDecode"] -SUPPORTED_IMAGE_FILTERS: Tuple[_ImageFilter, ...] +SUPPORTED_IMAGE_FILTERS: tuple[_ImageFilter, ...] def load_image(filename): ... diff --git a/stubs/fpdf2/fpdf/syntax.pyi b/stubs/fpdf2/fpdf/syntax.pyi index 54788032540a..838880de0794 100644 --- a/stubs/fpdf2/fpdf/syntax.pyi +++ b/stubs/fpdf2/fpdf/syntax.pyi @@ -1,5 +1,5 @@ from abc import ABC -from typing import Any, List +from typing import Any def clear_empty_fields(d): ... def create_dictionary_string( @@ -29,7 +29,7 @@ def camel_case(property_name): ... class PDFString(str): def serialize(self): ... -class PDFArray(List[Any]): +class PDFArray(list[Any]): def serialize(self): ... class Destination(ABC): diff --git a/stubs/fpdf2/fpdf/util.pyi b/stubs/fpdf2/fpdf/util.pyi index 0455c3f2a6b8..21b00796ab70 100644 --- a/stubs/fpdf2/fpdf/util.pyi +++ b/stubs/fpdf2/fpdf/util.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal _Unit = Literal["pt", "mm", "cm", "in"] @@ -14,5 +14,5 @@ def convert_unit( to_convert: float | Iterable[float | Iterable[Any]], old_unit: str | float, new_unit: str | float, -) -> float | Tuple[float, ...]: ... +) -> float | tuple[float, ...]: ... def dochecks() -> None: ... diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 7ab8c8be9f23..61618b9dad47 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -1,14 +1,14 @@ import decimal from _typeshed import ReadableBuffer from datetime import date, datetime, time -from typing import Any, Sequence, Tuple, Type, overload +from typing import Any, Sequence, Type, overload from typing_extensions import Literal from .resultrow import ResultRow apilevel: str threadsafety: int -paramstyle: Tuple[str, ...] +paramstyle: tuple[str, ...] connect = Connection class Connection: @@ -44,19 +44,19 @@ class LOB: def read(self, size: int = ..., position: int = ...) -> str | bytes: ... def write(self, object: str | bytes) -> int: ... -_Parameters = Sequence[Tuple[Any, ...]] +_Parameters = Sequence[tuple[Any, ...]] class Cursor: - description: Tuple[Tuple[Any, ...], ...] + description: tuple[tuple[Any, ...], ...] rowcount: int statementhash: str | None connection: Connection arraysize: int def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def callproc(self, procname: str, parameters: Tuple[Any, ...] = ..., overview: bool = ...) -> Tuple[Any, ...]: ... + def callproc(self, procname: str, parameters: tuple[Any, ...] = ..., overview: bool = ...) -> tuple[Any, ...]: ... def close(self) -> None: ... - def description_ext(self) -> Sequence[Tuple[Any, ...]]: ... - def execute(self, operation: str, parameters: Tuple[Any, ...]) -> bool: ... + def description_ext(self) -> Sequence[tuple[Any, ...]]: ... + def execute(self, operation: str, parameters: tuple[Any, ...]) -> bool: ... def executemany(self, operation: str, parameters: _Parameters) -> Any: ... def executemanyprepared(self, parameters: _Parameters) -> Any: ... def executeprepared(self, parameters: _Parameters = ...) -> Any: ... @@ -67,7 +67,7 @@ class Cursor: def getwarning(self) -> Warning | None: ... def haswarning(self) -> bool: ... def nextset(self) -> None: ... - def parameter_description(self) -> Tuple[str, ...]: ... + def parameter_description(self) -> tuple[str, ...]: ... @overload def prepare(self, operation: str, newcursor: Literal[True]) -> Cursor: ... @overload diff --git a/stubs/hdbcli/hdbcli/resultrow.pyi b/stubs/hdbcli/hdbcli/resultrow.pyi index 02a02eca91d4..cf0ee12ecd88 100644 --- a/stubs/hdbcli/hdbcli/resultrow.pyi +++ b/stubs/hdbcli/hdbcli/resultrow.pyi @@ -1,6 +1,6 @@ -from typing import Any, Tuple +from typing import Any class ResultRow: def __init__(self, *args: Any, **kwargs: Any) -> None: ... - column_names: Tuple[str, ...] - column_values: Tuple[Any, ...] + column_names: tuple[str, ...] + column_values: tuple[Any, ...] diff --git a/stubs/html5lib/html5lib/_tokenizer.pyi b/stubs/html5lib/html5lib/_tokenizer.pyi index cf62e2ca65d9..fd9f6dac7caf 100644 --- a/stubs/html5lib/html5lib/_tokenizer.pyi +++ b/stubs/html5lib/html5lib/_tokenizer.pyi @@ -1,10 +1,10 @@ import sys from collections import OrderedDict -from typing import Any, Dict +from typing import Any entitiesTrie: Any if sys.version_info >= (3, 7): - attributeMap = Dict[Any, Any] + attributeMap = dict[Any, Any] else: attributeMap = OrderedDict[Any, Any] diff --git a/stubs/html5lib/html5lib/_utils.pyi b/stubs/html5lib/html5lib/_utils.pyi index c6f85f5a622f..1ea974392438 100644 --- a/stubs/html5lib/html5lib/_utils.pyi +++ b/stubs/html5lib/html5lib/_utils.pyi @@ -1,9 +1,9 @@ from collections.abc import Mapping -from typing import Any, Dict +from typing import Any supports_lone_surrogates: bool -class MethodDispatcher(Dict[Any, Any]): +class MethodDispatcher(dict[Any, Any]): default: Any def __init__(self, items=...) -> None: ... def __getitem__(self, key): ... diff --git a/stubs/html5lib/html5lib/treebuilders/base.pyi b/stubs/html5lib/html5lib/treebuilders/base.pyi index 12e89bb296d4..8c73d5257666 100644 --- a/stubs/html5lib/html5lib/treebuilders/base.pyi +++ b/stubs/html5lib/html5lib/treebuilders/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any Marker: Any listElementsMap: Any @@ -18,7 +18,7 @@ class Node: def cloneNode(self) -> None: ... def hasContent(self) -> None: ... -class ActiveFormattingElements(List[Any]): +class ActiveFormattingElements(list[Any]): def append(self, node) -> None: ... def nodesEqual(self, node1, node2): ... diff --git a/stubs/httplib2/httplib2/__init__.pyi b/stubs/httplib2/httplib2/__init__.pyi index 14bf1dba7af8..f1da1887fee3 100644 --- a/stubs/httplib2/httplib2/__init__.pyi +++ b/stubs/httplib2/httplib2/__init__.pyi @@ -1,6 +1,6 @@ import http.client from collections.abc import Generator -from typing import Any, Dict, TypeVar +from typing import Any, TypeVar from .error import * @@ -175,7 +175,7 @@ class Http: connection_type: Any | None = ..., ): ... -class Response(Dict[str, Any]): +class Response(dict[str, Any]): fromcache: bool version: int status: int diff --git a/stubs/ldap3/ldap3/__init__.pyi b/stubs/ldap3/ldap3/__init__.pyi index 4f72194fa2bd..2336956e8e71 100644 --- a/stubs/ldap3/ldap3/__init__.pyi +++ b/stubs/ldap3/ldap3/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple, Type +from typing import Any, Type from typing_extensions import Literal from .abstract.attrDef import AttrDef as AttrDef @@ -98,7 +98,7 @@ HASHED_SALTED_SHA384: Literal["SALTED_SHA384"] HASHED_SALTED_SHA512: Literal["SALTED_SHA512"] HASHED_SALTED_MD5: Literal["SALTED_MD5"] -NUMERIC_TYPES: Tuple[Type[Any], ...] -INTEGER_TYPES: Tuple[Type[Any], ...] -STRING_TYPES: Tuple[Type[Any], ...] -SEQUENCE_TYPES: Tuple[Type[Any], ...] +NUMERIC_TYPES: tuple[Type[Any], ...] +INTEGER_TYPES: tuple[Type[Any], ...] +STRING_TYPES: tuple[Type[Any], ...] +SEQUENCE_TYPES: tuple[Type[Any], ...] diff --git a/stubs/mysqlclient/MySQLdb/__init__.pyi b/stubs/mysqlclient/MySQLdb/__init__.pyi index 88d6eb25bd2c..7e8070b3e09f 100644 --- a/stubs/mysqlclient/MySQLdb/__init__.pyi +++ b/stubs/mysqlclient/MySQLdb/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, FrozenSet +from typing import Any from MySQLdb import connections as connections, constants as constants, converters as converters, cursors as cursors from MySQLdb._mysql import ( @@ -35,7 +35,7 @@ threadsafety: int apilevel: str paramstyle: str -class DBAPISet(FrozenSet[Any]): +class DBAPISet(frozenset[Any]): def __eq__(self, other): ... STRING: Any diff --git a/stubs/mysqlclient/MySQLdb/_mysql.pyi b/stubs/mysqlclient/MySQLdb/_mysql.pyi index 690e3469893f..3e79317aafff 100644 --- a/stubs/mysqlclient/MySQLdb/_mysql.pyi +++ b/stubs/mysqlclient/MySQLdb/_mysql.pyi @@ -1,9 +1,9 @@ import builtins -from typing import Any, Tuple +from typing import Any import MySQLdb._exceptions -version_info: Tuple[Any, ...] +version_info: tuple[Any, ...] class DataError(MySQLdb._exceptions.DatabaseError): ... class DatabaseError(MySQLdb._exceptions.Error): ... diff --git a/stubs/oauthlib/oauthlib/common.pyi b/stubs/oauthlib/oauthlib/common.pyi index bdd765525fe8..622e9e3ea8da 100644 --- a/stubs/oauthlib/oauthlib/common.pyi +++ b/stubs/oauthlib/oauthlib/common.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any UNICODE_ASCII_CHARACTER_SET: str CLIENT_ID_CHARACTER_SET: str @@ -28,7 +28,7 @@ def add_params_to_uri(uri, params, fragment: bool = ...): ... def safe_string_equals(a, b): ... def to_unicode(data, encoding: str = ...): ... -class CaseInsensitiveDict(Dict[Any, Any]): +class CaseInsensitiveDict(dict[Any, Any]): proxy: Any def __init__(self, data) -> None: ... def __contains__(self, k): ... diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi index c11b07b2d41d..d4901f5aa653 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi @@ -1,6 +1,6 @@ -from typing import Any, Dict +from typing import Any -class OAuth2Token(Dict[Any, Any]): +class OAuth2Token(dict[Any, Any]): def __init__(self, params, old_scope: Any | None = ...) -> None: ... @property def scope_changed(self): ... diff --git a/stubs/paramiko/paramiko/agent.pyi b/stubs/paramiko/paramiko/agent.pyi index bad43a1bc15f..24926ac1eb5c 100644 --- a/stubs/paramiko/paramiko/agent.pyi +++ b/stubs/paramiko/paramiko/agent.pyi @@ -1,6 +1,6 @@ from socket import _RetAddress, socket from threading import Thread -from typing import Protocol, Tuple +from typing import Protocol from paramiko.channel import Channel from paramiko.message import Message @@ -18,7 +18,7 @@ SSH2_AGENT_SIGN_RESPONSE: int class AgentSSH: def __init__(self) -> None: ... - def get_keys(self) -> Tuple[AgentKey, ...]: ... + def get_keys(self) -> tuple[AgentKey, ...]: ... class AgentProxyThread(Thread): def __init__(self, agent: _AgentProxy) -> None: ... diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index 6c412620ef19..11721bd2217d 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -1,11 +1,11 @@ from threading import Event -from typing import Callable, List, Tuple +from typing import Callable from paramiko.pkey import PKey from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.transport import Transport -_InteractiveCallback = Callable[[str, str, List[Tuple[str, bool]]], List[str]] +_InteractiveCallback = Callable[[str, str, list[tuple[str, bool]]], list[str]] class AuthHandler: transport: Transport diff --git a/stubs/paramiko/paramiko/config.pyi b/stubs/paramiko/paramiko/config.pyi index 65bb71f450a8..8a7b74f8b8c0 100644 --- a/stubs/paramiko/paramiko/config.pyi +++ b/stubs/paramiko/paramiko/config.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Dict, Iterable, Pattern +from typing import IO, Any, Iterable, Pattern from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize @@ -25,7 +25,7 @@ class LazyFqdn: host: str | None def __init__(self, config: SSHConfigDict, host: str | None = ...) -> None: ... -class SSHConfigDict(Dict[str, str]): +class SSHConfigDict(dict[str, str]): def __init__(self, *args: Any, **kwargs: Any) -> None: ... def as_bool(self, key: str) -> bool: ... def as_int(self, key: str) -> int: ... diff --git a/stubs/paramiko/paramiko/file.pyi b/stubs/paramiko/paramiko/file.pyi index dbf35fc39c93..45c4acab12b6 100644 --- a/stubs/paramiko/paramiko/file.pyi +++ b/stubs/paramiko/paramiko/file.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Generic, Iterable, Tuple +from typing import Any, AnyStr, Generic, Iterable from paramiko.util import ClosingContextManager @@ -15,7 +15,7 @@ class BufferedFile(ClosingContextManager, Generic[AnyStr]): FLAG_LINE_BUFFERED: int FLAG_UNIVERSAL_NEWLINE: int - newlines: None | AnyStr | Tuple[AnyStr, ...] + newlines: None | AnyStr | tuple[AnyStr, ...] def __init__(self) -> None: ... def __del__(self) -> None: ... def __iter__(self) -> BufferedFile[Any]: ... diff --git a/stubs/paramiko/paramiko/server.pyi b/stubs/paramiko/paramiko/server.pyi index 22647fd22f69..5bc25c3d60b8 100644 --- a/stubs/paramiko/paramiko/server.pyi +++ b/stubs/paramiko/paramiko/server.pyi @@ -1,5 +1,4 @@ import threading -from typing import Tuple from paramiko.channel import Channel from paramiko.message import Message @@ -19,7 +18,7 @@ class ServerInterface: def enable_auth_gssapi(self) -> bool: ... def check_port_forward_request(self, address: str, port: int) -> int: ... def cancel_port_forward_request(self, address: str, port: int) -> None: ... - def check_global_request(self, kind: str, msg: Message) -> bool | Tuple[bool | int | str, ...]: ... + def check_global_request(self, kind: str, msg: Message) -> bool | tuple[bool | int | str, ...]: ... def check_channel_pty_request( self, channel: Channel, term: bytes, width: int, height: int, pixelwidth: int, pixelheight: int, modes: bytes ) -> bool: ... diff --git a/stubs/paramiko/paramiko/ssh_gss.pyi b/stubs/paramiko/paramiko/ssh_gss.pyi index aed5ae7672fe..7f750a4236ba 100644 --- a/stubs/paramiko/paramiko/ssh_gss.pyi +++ b/stubs/paramiko/paramiko/ssh_gss.pyi @@ -1,7 +1,7 @@ -from typing import Any, Tuple, Type +from typing import Any, Type GSS_AUTH_AVAILABLE: bool -GSS_EXCEPTIONS: Tuple[Type[Exception], ...] +GSS_EXCEPTIONS: tuple[Type[Exception], ...] def GSSAuth(auth_method: str, gss_deleg_creds: bool = ...) -> _SSH_GSSAuth: ... diff --git a/stubs/paramiko/paramiko/transport.pyi b/stubs/paramiko/paramiko/transport.pyi index f294c9ad591c..7ebb5b97eff6 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -2,7 +2,7 @@ from logging import Logger from socket import socket from threading import Condition, Event, Lock, Thread from types import ModuleType -from typing import Any, Callable, Iterable, Protocol, Sequence, Tuple, Type +from typing import Any, Callable, Iterable, Protocol, Sequence, Type from paramiko.auth_handler import AuthHandler, _InteractiveCallback from paramiko.channel import Channel @@ -14,7 +14,7 @@ from paramiko.sftp_client import SFTPClient from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.util import ClosingContextManager -_Addr = Tuple[str, int] +_Addr = tuple[str, int] class _KexEngine(Protocol): def start_kex(self) -> None: ... @@ -67,7 +67,7 @@ class Transport(Thread, ClosingContextManager): server_key_dict: dict[str, PKey] server_accepts: list[Channel] server_accept_cv: Condition - subsystem_table: dict[str, tuple[Type[SubsystemHandler], Tuple[Any, ...], dict[str, Any]]] + subsystem_table: dict[str, tuple[Type[SubsystemHandler], tuple[Any, ...], dict[str, Any]]] sys: ModuleType def __init__( self, diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index c4c361f1836c..695927ae5417 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -1,5 +1,5 @@ import textwrap -from typing import IO, Any, Callable, Generic, List, Text, Type, TypeVar, overload +from typing import IO, Any, Callable, Generic, Text, Type, TypeVar, overload from typing_extensions import SupportsIndex _TB = TypeVar("_TB", bound="_BaseEntry") @@ -23,7 +23,7 @@ def detect_encoding(file: bytes | Text, binary_mode: bool = ...) -> str: ... def escape(st: Text) -> Text: ... def unescape(st: Text) -> Text: ... -class _BaseFile(List[_TB]): +class _BaseFile(list[_TB]): fpath: Text wrapwidth: int encoding: Text diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 1eed72c28165..e5a63e88a438 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -1,6 +1,6 @@ import sys from contextlib import AbstractContextManager -from typing import Any, Callable, Iterable, Iterator, Tuple, TypeVar +from typing import Any, Callable, Iterable, Iterator, TypeVar from ._common import ( AIX as AIX, @@ -125,7 +125,7 @@ class Process: def pid(self) -> int: ... def oneshot(self) -> AbstractContextManager[None]: ... def as_dict( - self, attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... + self, attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... ) -> dict[str, Any]: ... def parent(self) -> Process: ... def parents(self) -> list[Process]: ... @@ -188,7 +188,7 @@ class Popen(Process): def pids() -> list[int]: ... def pid_exists(pid: int) -> bool: ... def process_iter( - attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... + attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... ) -> Iterator[Process]: ... def wait_procs( procs: Iterable[Process], timeout: float | None = ..., callback: Callable[[Process], Any] | None = ... diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi index 149a29f52276..0362445ce1af 100644 --- a/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Tuple, TypeVar, overload +from typing import Any, Callable, TypeVar, overload import psycopg2 import psycopg2.extensions @@ -360,9 +360,9 @@ class cursor: def copy_to(self, file, table, sep=..., null=..., columns=...): ... def execute(self, query, vars=...): ... def executemany(self, query, vars_list): ... - def fetchall(self) -> list[Tuple[Any, ...]]: ... - def fetchmany(self, size=...) -> list[Tuple[Any, ...]]: ... - def fetchone(self) -> Tuple[Any, ...] | Any: ... + def fetchall(self) -> list[tuple[Any, ...]]: ... + def fetchmany(self, size=...) -> list[tuple[Any, ...]]: ... + def fetchone(self) -> tuple[Any, ...] | Any: ... def mogrify(self, *args, **kwargs): ... def nextset(self): ... def scroll(self, value, mode=...): ... diff --git a/stubs/psycopg2/psycopg2/extras.pyi b/stubs/psycopg2/psycopg2/extras.pyi index 364de1a2f85a..fdd7cf429b34 100644 --- a/stubs/psycopg2/psycopg2/extras.pyi +++ b/stubs/psycopg2/psycopg2/extras.pyi @@ -1,5 +1,5 @@ from collections import OrderedDict -from typing import Any, List +from typing import Any from psycopg2._ipaddress import register_ipaddress as register_ipaddress from psycopg2._json import ( @@ -45,7 +45,7 @@ class DictCursor(DictCursorBase): def execute(self, query, vars: Any | None = ...): ... def callproc(self, procname, vars: Any | None = ...): ... -class DictRow(List[Any]): +class DictRow(list[Any]): def __init__(self, cursor) -> None: ... def __getitem__(self, x): ... def __setitem__(self, x, v) -> None: ... diff --git a/stubs/pyOpenSSL/OpenSSL/crypto.pyi b/stubs/pyOpenSSL/OpenSSL/crypto.pyi index abfb1e3ab85d..01e5577853ce 100644 --- a/stubs/pyOpenSSL/OpenSSL/crypto.pyi +++ b/stubs/pyOpenSSL/OpenSSL/crypto.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Callable, Iterable, Sequence, Text, Tuple, Union +from typing import Any, Callable, Iterable, Sequence, Text, Union from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey @@ -118,7 +118,7 @@ class CRL: @classmethod def from_cryptography(cls, crypto_crl: CertificateRevocationList) -> CRL: ... def get_issuer(self) -> X509Name: ... - def get_revoked(self) -> Tuple[Revoked, ...]: ... + def get_revoked(self) -> tuple[Revoked, ...]: ... def set_lastUpdate(self, when: bytes) -> None: ... def set_nextUpdate(self, when: bytes) -> None: ... def set_version(self, version: int) -> None: ... @@ -166,7 +166,7 @@ class PKCS7: class PKCS12: def __init__(self) -> None: ... def export(self, passphrase: bytes | None = ..., iter: int = ..., maciter: int = ...) -> bytes: ... - def get_ca_certificates(self) -> Tuple[X509, ...]: ... + def get_ca_certificates(self) -> tuple[X509, ...]: ... def get_certificate(self) -> X509: ... def get_friendlyname(self) -> bytes | None: ... def get_privatekey(self) -> PKey: ... diff --git a/stubs/pyaudio/pyaudio.pyi b/stubs/pyaudio/pyaudio.pyi index 6849056b1d47..a724d45ffdc2 100644 --- a/stubs/pyaudio/pyaudio.pyi +++ b/stubs/pyaudio/pyaudio.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Mapping, Optional, Sequence, Tuple, Union +from typing import Callable, Mapping, Optional, Sequence, Union from typing_extensions import Final paFloat32: Final[int] = ... @@ -70,7 +70,7 @@ paMacCoreStreamInfo: PaMacCoreStreamInfo _ChannelMap = Sequence[int] _PaHostApiInfo = Mapping[str, Union[str, int]] _PaDeviceInfo = Mapping[str, Union[str, int, float]] -_StreamCallback = Callable[[Optional[bytes], int, Mapping[str, float], int], Tuple[Optional[bytes], int]] +_StreamCallback = Callable[[Optional[bytes], int, Mapping[str, float], int], tuple[Optional[bytes], int]] def get_format_from_width(width: int, unsigned: bool = ...) -> int: ... def get_portaudio_version() -> int: ... diff --git a/stubs/pycurl/pycurl.pyi b/stubs/pycurl/pycurl.pyi index f69b2b6c0060..c3517e112676 100644 --- a/stubs/pycurl/pycurl.pyi +++ b/stubs/pycurl/pycurl.pyi @@ -1,6 +1,6 @@ # TODO(MichalPokorny): more precise types -from typing import Any, Text, Tuple +from typing import Any, Text GLOBAL_ACK_EINTR: int GLOBAL_ALL: int @@ -14,7 +14,7 @@ def global_cleanup() -> None: ... version: str -def version_info() -> tuple[int, str, int, str, int, str, int, str, Tuple[str, ...], Any, int, Any]: ... +def version_info() -> tuple[int, str, int, str, int, str, int, str, tuple[str, ...], Any, int, Any]: ... class error(Exception): ... diff --git a/stubs/python-nmap/nmap/nmap.pyi b/stubs/python-nmap/nmap/nmap.pyi index a07d4b5e13ba..70be8d261d59 100644 --- a/stubs/python-nmap/nmap/nmap.pyi +++ b/stubs/python-nmap/nmap/nmap.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, Text, TypeVar +from typing import Any, Callable, Iterable, Iterator, Text, TypeVar from typing_extensions import TypedDict _T = TypeVar("_T") @@ -101,7 +101,7 @@ class PortScannerYield(PortScannerAsync): def wait(self, timeout: int | None = ...) -> None: ... def still_scanning(self) -> None: ... # type: ignore[override] -class PortScannerHostDict(Dict[str, Any]): +class PortScannerHostDict(dict[str, Any]): def hostnames(self) -> list[_ResultHostNames]: ... def hostname(self) -> str: ... def state(self) -> str: ... diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 187a24d99898..21988ccd270b 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -5,7 +5,6 @@ from typing import ( Any, Callable, ClassVar, - Dict, Generic, Iterable, Iterator, @@ -39,7 +38,7 @@ SYM_EMPTY: bytes EMPTY_RESPONSE: str NEVER_DECODE: str -class CaseInsensitiveDict(Dict[_StrType, _VT]): +class CaseInsensitiveDict(dict[_StrType, _VT]): def __init__(self, data: SupportsItems[_StrType, _VT]) -> None: ... def update(self, data: SupportsItems[_StrType, _VT]) -> None: ... # type: ignore[override] @overload diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index 89ba100c02af..645b5df8a330 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsItems -from typing import IO, Any, Callable, Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, TypeVar, Union +from typing import IO, Any, Callable, Iterable, Mapping, MutableMapping, Optional, Text, TypeVar, Union from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, structures, utils from .models import Response @@ -43,18 +43,18 @@ class SessionRedirectMixin: def rebuild_proxies(self, prepared_request, proxies): ... def should_strip_auth(self, old_url, new_url): ... -_Data = Union[None, Text, bytes, Mapping[str, Any], Mapping[Text, Any], Iterable[Tuple[Text, Optional[Text]]], IO[Any]] +_Data = Union[None, Text, bytes, Mapping[str, Any], Mapping[Text, Any], Iterable[tuple[Text, Optional[Text]]], IO[Any]] _Hook = Callable[[Response], Any] -_Hooks = MutableMapping[Text, List[_Hook]] +_Hooks = MutableMapping[Text, list[_Hook]] _HooksInput = MutableMapping[Text, Union[Iterable[_Hook], _Hook]] _ParamsMappingKeyType = Union[Text, bytes, int, float] _ParamsMappingValueType = Union[Text, bytes, int, float, Iterable[Union[Text, bytes, int, float]], None] _Params = Union[ SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType], - Tuple[_ParamsMappingKeyType, _ParamsMappingValueType], - Iterable[Tuple[_ParamsMappingKeyType, _ParamsMappingValueType]], + tuple[_ParamsMappingKeyType, _ParamsMappingValueType], + Iterable[tuple[_ParamsMappingKeyType, _ParamsMappingValueType]], Union[Text, bytes], ] _TextMapping = MutableMapping[Text, Text] diff --git a/stubs/requests/requests/structures.pyi b/stubs/requests/requests/structures.pyi index ed7d9a2f225c..ee342d7d4b4f 100644 --- a/stubs/requests/requests/structures.pyi +++ b/stubs/requests/requests/structures.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, Iterable, Iterator, Mapping, MutableMapping, TypeVar +from typing import Any, Generic, Iterable, Iterator, Mapping, MutableMapping, TypeVar _VT = TypeVar("_VT") @@ -12,7 +12,7 @@ class CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]): def __len__(self) -> int: ... def copy(self) -> CaseInsensitiveDict[_VT]: ... -class LookupDict(Dict[str, _VT]): +class LookupDict(dict[str, _VT]): name: Any def __init__(self, name: Any = ...) -> None: ... def __getitem__(self, key: str) -> _VT | None: ... # type: ignore[override] diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index a0b68c1a6d79..ee8ce36ce5cd 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -1,6 +1,6 @@ from _typeshed import IdentityFunction from logging import Logger -from typing import Any, Callable, Sequence, Tuple, Type, TypeVar +from typing import Any, Callable, Sequence, Type, TypeVar _R = TypeVar("_R") @@ -8,7 +8,7 @@ def retry_call( f: Callable[..., _R], fargs: Sequence[Any] | None = ..., fkwargs: dict[str, Any] | None = ..., - exceptions: Type[Exception] | Tuple[Type[Exception], ...] = ..., + exceptions: Type[Exception] | tuple[Type[Exception], ...] = ..., tries: int = ..., delay: float = ..., max_delay: float | None = ..., @@ -17,7 +17,7 @@ def retry_call( logger: Logger | None = ..., ) -> _R: ... def retry( - exceptions: Type[Exception] | Tuple[Type[Exception], ...] = ..., + exceptions: Type[Exception] | tuple[Type[Exception], ...] = ..., tries: int = ..., delay: float = ..., max_delay: float | None = ..., diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index 9f121f3340fc..a7dba8debab0 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -2,7 +2,7 @@ import importlib.abc import types import zipimport from abc import ABCMeta -from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, TypeVar, Union, overload LegacyVersion = Any # from packaging.version Version = Any # from packaging.version @@ -70,14 +70,14 @@ class Requirement: unsafe_name: str project_name: str key: str - extras: Tuple[str, ...] + extras: tuple[str, ...] specs: list[tuple[str, str]] # TODO: change this to packaging.markers.Marker | None once we can import # packaging.markers marker: Any | None @staticmethod def parse(s: str | Iterable[str]) -> Requirement: ... - def __contains__(self, item: Distribution | str | Tuple[str, ...]) -> bool: ... + def __contains__(self, item: Distribution | str | tuple[str, ...]) -> bool: ... def __eq__(self, other_requirement: Any) -> bool: ... def load_entry_point(dist: _EPDistType, group: str, name: str) -> Any: ... @@ -90,15 +90,15 @@ def get_entry_map(dist: _EPDistType, group: str) -> dict[str, EntryPoint]: ... class EntryPoint: name: str module_name: str - attrs: Tuple[str, ...] - extras: Tuple[str, ...] + attrs: tuple[str, ...] + extras: tuple[str, ...] dist: Distribution | None def __init__( self, name: str, module_name: str, - attrs: Tuple[str, ...] = ..., - extras: Tuple[str, ...] = ..., + attrs: tuple[str, ...] = ..., + extras: tuple[str, ...] = ..., dist: Distribution | None = ..., ) -> None: ... @classmethod @@ -123,7 +123,7 @@ class Distribution(IResourceProvider, IMetadataProvider): key: str extras: list[str] version: str - parsed_version: Tuple[str, ...] + parsed_version: tuple[str, ...] py_version: str platform: str | None precedence: int @@ -145,7 +145,7 @@ class Distribution(IResourceProvider, IMetadataProvider): def from_filename(cls, filename: str, metadata: _MetadataType = ..., **kw: str | None | int) -> Distribution: ... def activate(self, path: list[str] | None = ...) -> None: ... def as_requirement(self) -> Requirement: ... - def requires(self, extras: Tuple[str, ...] = ...) -> list[Requirement]: ... + def requires(self, extras: tuple[str, ...] = ...) -> list[Requirement]: ... def clone(self, **kw: str | int | None) -> Requirement: ... def egg_name(self) -> str: ... def __cmp__(self, other: Any) -> bool: ... diff --git a/stubs/setuptools/setuptools/command/easy_install.pyi b/stubs/setuptools/setuptools/command/easy_install.pyi index 11f8224e69ad..6d7bc390a8da 100644 --- a/stubs/setuptools/setuptools/command/easy_install.pyi +++ b/stubs/setuptools/setuptools/command/easy_install.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from pkg_resources import Environment from setuptools import Command, SetuptoolsDeprecationWarning @@ -106,7 +106,7 @@ class RewritePthDistributions(PthDistributions): prelude: Any postlude: Any -class CommandSpec(List[str]): +class CommandSpec(list[str]): options: Any split_args: Any @classmethod diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 88590adaebad..4b1037bed51e 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -8,7 +8,7 @@ from collections.abc import Callable, ItemsView, Iterable, Iterator as _Iterator from functools import wraps as wraps from importlib.util import spec_from_loader as spec_from_loader from io import BytesIO as BytesIO, StringIO as StringIO -from typing import Any, AnyStr, NoReturn, Pattern, Tuple, Type, TypeVar, overload +from typing import Any, AnyStr, NoReturn, Pattern, Type, TypeVar, overload from typing_extensions import Literal from . import moves as moves @@ -44,9 +44,9 @@ Iterator = object def get_method_function(meth: types.MethodType) -> types.FunctionType: ... def get_method_self(meth: types.MethodType) -> object | None: ... -def get_function_closure(fun: types.FunctionType) -> Tuple[types._Cell, ...] | None: ... +def get_function_closure(fun: types.FunctionType) -> tuple[types._Cell, ...] | None: ... def get_function_code(fun: types.FunctionType) -> types.CodeType: ... -def get_function_defaults(fun: types.FunctionType) -> Tuple[Any, ...] | None: ... +def get_function_defaults(fun: types.FunctionType) -> tuple[Any, ...] | None: ... def get_function_globals(fun: types.FunctionType) -> dict[str, Any]: ... def iterkeys(d: Mapping[_K, Any]) -> _Iterator[_K]: ... def itervalues(d: Mapping[Any, _V]) -> _Iterator[_V]: ... diff --git a/stubs/stripe/stripe/stripe_object.pyi b/stubs/stripe/stripe/stripe_object.pyi index 25ed72a9de70..5b496bfb631a 100644 --- a/stubs/stripe/stripe/stripe_object.pyi +++ b/stubs/stripe/stripe/stripe_object.pyi @@ -1,9 +1,9 @@ import json -from typing import Any, Dict +from typing import Any from stripe import api_requestor as api_requestor -class StripeObject(Dict[Any, Any]): +class StripeObject(dict[Any, Any]): class ReprJSONEncoder(json.JSONEncoder): def default(self, obj): ... def __init__( diff --git a/stubs/tabulate/tabulate.pyi b/stubs/tabulate/tabulate.pyi index 8b5efde5bf08..1d0daa981c6c 100644 --- a/stubs/tabulate/tabulate.pyi +++ b/stubs/tabulate/tabulate.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Container, Iterable, List, Mapping, NamedTuple, Sequence, Union +from typing import Any, Callable, Container, Iterable, Mapping, NamedTuple, Sequence, Union LATEX_ESCAPE_RULES: dict[str, str] MIN_PADDING: int @@ -18,8 +18,8 @@ class DataRow(NamedTuple): sep: str end: str -_TableFormatLine = Union[None, Line, Callable[[List[int], List[str]], str]] -_TableFormatRow = Union[None, DataRow, Callable[[List[Any], List[int], List[str]], str]] +_TableFormatLine = Union[None, Line, Callable[[list[int], list[str]], str]] +_TableFormatRow = Union[None, DataRow, Callable[[list[Any], list[int], list[str]], str]] class TableFormat(NamedTuple): lineabove: _TableFormatLine diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index 93dbae12ee4d..f7758e881506 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -1,4 +1,3 @@ -import typing from typing import Any, Iterator class NodeVisitor: @@ -15,7 +14,7 @@ def fix_missing_locations(node: AST) -> AST: ... def get_docstring(node: AST, clean: bool = ...) -> bytes | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... -def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... +def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ... def literal_eval(node_or_string: str | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... @@ -26,8 +25,8 @@ PyCF_ONLY_AST: int identifier = str class AST: - _attributes: typing.Tuple[str, ...] - _fields: typing.Tuple[str, ...] + _attributes: tuple[str, ...] + _fields: tuple[str, ...] def __init__(self, *args: Any, **kwargs: Any) -> None: ... class mod(AST): ... diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 8d0a830541a9..996b07904e50 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -1,4 +1,3 @@ -import typing from typing import Any, Iterator class NodeVisitor: @@ -15,7 +14,7 @@ def fix_missing_locations(node: AST) -> AST: ... def get_docstring(node: AST, clean: bool = ...) -> str | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... -def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... +def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ... def literal_eval(node_or_string: str | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... @@ -26,8 +25,8 @@ PyCF_ONLY_AST: int identifier = str class AST: - _attributes: typing.Tuple[str, ...] - _fields: typing.Tuple[str, ...] + _attributes: tuple[str, ...] + _fields: tuple[str, ...] def __init__(self, *args: Any, **kwargs: Any) -> None: ... class mod(AST): ... diff --git a/stubs/vobject/vobject/icalendar.pyi b/stubs/vobject/vobject/icalendar.pyi index bbd568502c94..6a9728e0ae9c 100644 --- a/stubs/vobject/vobject/icalendar.pyi +++ b/stubs/vobject/vobject/icalendar.pyi @@ -1,15 +1,15 @@ from datetime import timedelta -from typing import Any, Tuple +from typing import Any from .base import Component from .behavior import Behavior -DATENAMES: Tuple[str, ...] -RULENAMES: Tuple[str, ...] -DATESANDRULES: Tuple[str, ...] +DATENAMES: tuple[str, ...] +RULENAMES: tuple[str, ...] +DATESANDRULES: tuple[str, ...] PRODID: str -WEEKDAYS: Tuple[str, ...] -FREQUENCIES: Tuple[str, ...] +WEEKDAYS: tuple[str, ...] +FREQUENCIES: tuple[str, ...] zeroDelta: timedelta twoHours: timedelta diff --git a/stubs/waitress/waitress/__init__.pyi b/stubs/waitress/waitress/__init__.pyi index 2abd726d3e38..f3aef6fbab97 100644 --- a/stubs/waitress/waitress/__init__.pyi +++ b/stubs/waitress/waitress/__init__.pyi @@ -1,7 +1,7 @@ -from typing import Any, Tuple +from typing import Any from waitress.server import create_server as create_server def serve(app: Any, **kw: Any) -> None: ... def serve_paste(app: Any, global_conf: Any, **kw: Any) -> int: ... -def profile(cmd: Any, globals: Any, locals: Any, sort_order: Tuple[str, ...], callers: bool) -> None: ... +def profile(cmd: Any, globals: Any, locals: Any, sort_order: tuple[str, ...], callers: bool) -> None: ... diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index 6c1358068f6d..71f7b837a6ee 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -10,7 +10,8 @@ ) CONTEXT_MANAGER_ALIASES = {"ContextManager": "AbstractContextManager", "AsyncContextManager": "AbstractAsyncContextManager"} -CONTEXTLIB_ALIAS_ALLOWLIST = frozenset({Path("stdlib/contextlib.pyi"), Path("stdlib/typing_extensions.pyi")}) +CONTEXTLIB_ALIAS_ALLOWLIST = frozenset({Path("stdlib/contextlib.pyi")}) +FORBIDDEN_BUILTIN_TYPING_IMPORTS = frozenset({"List", "FrozenSet", "Set", "Dict", "Tuple"}) IMPORTED_FROM_TYPING_NOT_TYPING_EXTENSIONS = frozenset( {"ClassVar", "Type", "NewType", "overload", "Text", "Protocol", "runtime_checkable", "NoReturn"} @@ -21,7 +22,7 @@ ) # The values in the mapping are what these are called in `collections` -IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS = { +IMPORTED_FROM_COLLECTIONS_NOT_TYPING = { "Counter": "Counter", "Deque": "deque", "DefaultDict": "defaultdict", @@ -34,21 +35,21 @@ def check_new_syntax(tree: ast.AST, path: Path) -> list[str]: errors = [] python_2_support_required = any(directory in path.parents for directory in STUBS_SUPPORTING_PYTHON_2) - def unparse_without_tuple_parens(node: ast.AST) -> str: - if isinstance(node, ast.Tuple) and node.elts: - return ast.unparse(node)[1:-1] - return ast.unparse(node) - - def is_dotdotdot(node: ast.AST) -> bool: - return isinstance(node, ast.Constant) and node.s is Ellipsis - - def add_contextlib_alias_error(node: ast.ImportFrom | ast.Attribute, alias: str) -> None: - errors.append(f"{path}:{node.lineno}: Use `contextlib.{CONTEXT_MANAGER_ALIASES[alias]}` instead of `typing.{alias}`") - - class OldSyntaxFinder(ast.NodeVisitor): - def __init__(self, *, set_from_collections_abc: bool) -> None: - self.set_from_collections_abc = set_from_collections_abc - + def check_object_from_typing(node: ast.ImportFrom | ast.Attribute, object_name: str): + if object_name in FORBIDDEN_BUILTIN_TYPING_IMPORTS: + errors.append(f"{path}:{node.lineno}: Use `builtins.{object_name.lower()}` instead of `typing.{object_name}`") + elif object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING: + errors.append( + f"{path}:{node.lineno}: " + f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING[object_name]}` instead of `typing.{object_name}`" + ) + elif not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST and object_name in CONTEXT_MANAGER_ALIASES: + errors.append( + f"{path}:{node.lineno}: Use `contextlib.{CONTEXT_MANAGER_ALIASES[object_name]}` instead of `typing.{object_name}`" + ) + # We can't yet check for collections.abc imports due to pytype errors + + class UnionFinder(ast.NodeVisitor): def visit_Subscript(self, node: ast.Subscript) -> None: if isinstance(node.value, ast.Name): if node.value.id == "Union" and isinstance(node.slice, ast.Tuple): @@ -57,45 +58,10 @@ def visit_Subscript(self, node: ast.Subscript) -> None: if node.value.id == "Optional": new_syntax = f"{ast.unparse(node.slice)} | None" errors.append(f"{path}:{node.lineno}: Use PEP 604 syntax for Optional, e.g. `{new_syntax}`") - if node.value.id in {"List", "FrozenSet"}: - new_syntax = f"{node.value.id.lower()}[{ast.unparse(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use built-in generics, e.g. `{new_syntax}`") - if not self.set_from_collections_abc and node.value.id == "Set": - new_syntax = f"set[{ast.unparse(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use built-in generics, e.g. `{new_syntax}`") - if node.value.id == "Deque": - new_syntax = f"collections.deque[{ast.unparse(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use `collections.deque` instead of `typing.Deque`, e.g. `{new_syntax}`") - if node.value.id == "Dict": - new_syntax = f"dict[{unparse_without_tuple_parens(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use built-in generics, e.g. `{new_syntax}`") - if node.value.id == "DefaultDict": - new_syntax = f"collections.defaultdict[{unparse_without_tuple_parens(node.slice)}]" - errors.append( - f"{path}:{node.lineno}: Use `collections.defaultdict` instead of `typing.DefaultDict`, " - f"e.g. `{new_syntax}`" - ) - # Tuple[Foo, ...] must be allowed because of mypy bugs - if node.value.id == "Tuple" and not ( - isinstance(node.slice, ast.Tuple) and len(node.slice.elts) == 2 and is_dotdotdot(node.slice.elts[1]) - ): - new_syntax = f"tuple[{unparse_without_tuple_parens(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use built-in generics, e.g. `{new_syntax}`") self.generic_visit(node) - # This doesn't check type aliases (or type var bounds, etc), since those are not - # currently supported - # - # TODO: can use built-in generics in type aliases - class AnnotationFinder(ast.NodeVisitor): - def __init__(self) -> None: - self.set_from_collections_abc = False - - def old_syntax_finder(self) -> OldSyntaxFinder: - """Convenience method to create an `OldSyntaxFinder` instance with the correct state""" - return OldSyntaxFinder(set_from_collections_abc=self.set_from_collections_abc) - + class OldSyntaxFinder(ast.NodeVisitor): def visit_ImportFrom(self, node: ast.ImportFrom) -> None: if node.module == "collections.abc": imported_classes = node.names @@ -104,8 +70,6 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: f"{path}:{node.lineno}: " f"Use `from collections.abc import Set as AbstractSet` to avoid confusion with `builtins.set`" ) - self.set_from_collections_abc = True - elif node.module == "typing_extensions": for imported_object in node.names: imported_object_name = imported_object.name @@ -120,11 +84,11 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: f"Use `collections.abc.{imported_object_name}` or `typing.{imported_object_name}` " f"instead of `typing_extensions.{imported_object_name}`" ) - elif imported_object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS: + elif imported_object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING: errors.append( f"{path}:{node.lineno}: " - f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS[imported_object_name]}` " - f"or `typing.{imported_object_name}` instead of `typing_extensions.{imported_object_name}`" + f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING[imported_object_name]}` " + f"instead of `typing_extensions.{imported_object_name}`" ) elif imported_object_name in CONTEXT_MANAGER_ALIASES: if python_2_support_required: @@ -138,36 +102,30 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: f"instead of `typing_extensions.{imported_object_name}`" ) - elif not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST and node.module == "typing": - for imported_class in node.names: - imported_class_name = imported_class.name - if imported_class_name in CONTEXT_MANAGER_ALIASES: - add_contextlib_alias_error(node, imported_class_name) + elif node.module == "typing": + for imported_object in node.names: + check_object_from_typing(node, imported_object.name) + def visit_Attribute(self, node: ast.Attribute) -> None: + if isinstance(node.value, ast.Name) and node.value.id == "typing": + check_object_from_typing(node, node.attr) self.generic_visit(node) - if not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST: - - def visit_Attribute(self, node: ast.Attribute) -> None: - if isinstance(node.value, ast.Name) and node.value.id == "typing" and node.attr in CONTEXT_MANAGER_ALIASES: - add_contextlib_alias_error(node, node.attr) - self.generic_visit(node) - def visit_AnnAssign(self, node: ast.AnnAssign) -> None: - self.old_syntax_finder().visit(node.annotation) + UnionFinder().visit(node.annotation) def visit_arg(self, node: ast.arg) -> None: if node.annotation is not None: - self.old_syntax_finder().visit(node.annotation) + UnionFinder().visit(node.annotation) def visit_FunctionDef(self, node: ast.FunctionDef) -> None: if node.returns is not None: - self.old_syntax_finder().visit(node.returns) + UnionFinder().visit(node.returns) self.generic_visit(node) def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None: if node.returns is not None: - self.old_syntax_finder().visit(node.returns) + UnionFinder().visit(node.returns) self.generic_visit(node) class IfFinder(ast.NodeVisitor): @@ -180,7 +138,9 @@ def visit_If(self, node: ast.If) -> None: ) self.generic_visit(node) - AnnotationFinder().visit(tree) + if path != Path("stdlib/typing_extensions.pyi"): + OldSyntaxFinder().visit(tree) + IfFinder().visit(tree) return errors