From 08e54fec546651309cdfc04d6c10dab60edf48f2 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sat, 30 Oct 2021 22:59:28 -0700 Subject: [PATCH] Sync typeshed Source commit: https://github.com/python/typeshed/commit/151f256051445f251d9966120f35d4819e433c7a --- mypy/typeshed/stdlib/@python2/__builtin__.pyi | 2 +- mypy/typeshed/stdlib/@python2/builtins.pyi | 2 +- .../stdlib/@python2/sqlite3/dbapi2.pyi | 2 +- mypy/typeshed/stdlib/_codecs.pyi | 78 ++--- mypy/typeshed/stdlib/_compat_pickle.pyi | 4 +- mypy/typeshed/stdlib/_curses.pyi | 22 +- mypy/typeshed/stdlib/_json.pyi | 6 +- mypy/typeshed/stdlib/_markupbase.pyi | 4 +- mypy/typeshed/stdlib/_osx_support.pyi | 2 +- mypy/typeshed/stdlib/_posixsubprocess.pyi | 4 +- mypy/typeshed/stdlib/_socket.pyi | 1 + mypy/typeshed/stdlib/_threading_local.pyi | 4 +- mypy/typeshed/stdlib/_tracemalloc.pyi | 4 +- mypy/typeshed/stdlib/_typeshed/__init__.pyi | 4 +- mypy/typeshed/stdlib/_typeshed/wsgi.pyi | 4 +- mypy/typeshed/stdlib/_warnings.pyi | 6 +- mypy/typeshed/stdlib/_winapi.pyi | 22 +- mypy/typeshed/stdlib/aifc.pyi | 2 +- mypy/typeshed/stdlib/argparse.pyi | 87 ++++-- mypy/typeshed/stdlib/array.pyi | 4 +- mypy/typeshed/stdlib/asyncio/base_events.pyi | 18 +- mypy/typeshed/stdlib/asyncio/base_futures.pyi | 4 +- .../stdlib/asyncio/base_subprocess.pyi | 2 +- mypy/typeshed/stdlib/asyncio/coroutines.pyi | 13 +- mypy/typeshed/stdlib/asyncio/events.pyi | 20 +- .../stdlib/asyncio/format_helpers.pyi | 6 +- mypy/typeshed/stdlib/asyncio/futures.pyi | 4 +- mypy/typeshed/stdlib/asyncio/protocols.pyi | 3 +- mypy/typeshed/stdlib/asyncio/sslproto.pyi | 8 +- mypy/typeshed/stdlib/asyncio/staggered.pyi | 4 +- mypy/typeshed/stdlib/asyncio/streams.pyi | 6 +- mypy/typeshed/stdlib/asyncio/subprocess.pyi | 4 +- mypy/typeshed/stdlib/asyncio/tasks.pyi | 50 +-- mypy/typeshed/stdlib/asyncio/transports.pyi | 4 +- mypy/typeshed/stdlib/asyncio/trsock.pyi | 14 +- .../stdlib/asyncio/windows_events.pyi | 4 +- .../typeshed/stdlib/asyncio/windows_utils.pyi | 4 +- mypy/typeshed/stdlib/asyncore.pyi | 4 +- mypy/typeshed/stdlib/audioop.pyi | 10 +- mypy/typeshed/stdlib/bdb.pyi | 6 +- mypy/typeshed/stdlib/builtins.pyi | 70 ++--- mypy/typeshed/stdlib/calendar.pyi | 12 +- mypy/typeshed/stdlib/cgitb.pyi | 4 +- mypy/typeshed/stdlib/cmath.pyi | 4 +- mypy/typeshed/stdlib/cmd.pyi | 4 +- mypy/typeshed/stdlib/codecs.pyi | 32 +- mypy/typeshed/stdlib/collections/__init__.pyi | 18 +- mypy/typeshed/stdlib/colorsys.pyi | 14 +- .../stdlib/concurrent/futures/process.pyi | 2 +- mypy/typeshed/stdlib/configparser.pyi | 4 +- mypy/typeshed/stdlib/ctypes/__init__.pyi | 4 +- mypy/typeshed/stdlib/dataclasses.pyi | 6 +- mypy/typeshed/stdlib/datetime.pyi | 8 +- mypy/typeshed/stdlib/decimal.pyi | 12 +- mypy/typeshed/stdlib/difflib.pyi | 6 +- mypy/typeshed/stdlib/dis.pyi | 4 +- mypy/typeshed/stdlib/distutils/cmd.pyi | 10 +- mypy/typeshed/stdlib/distutils/core.pyi | 6 +- mypy/typeshed/stdlib/distutils/dep_util.pyi | 4 +- mypy/typeshed/stdlib/distutils/dist.pyi | 4 +- mypy/typeshed/stdlib/distutils/extension.pyi | 4 +- .../stdlib/distutils/fancy_getopt.pyi | 2 +- mypy/typeshed/stdlib/distutils/file_util.pyi | 4 +- mypy/typeshed/stdlib/distutils/text_file.pyi | 4 +- mypy/typeshed/stdlib/distutils/version.pyi | 4 +- .../stdlib/email/_header_value_parser.pyi | 94 +++--- mypy/typeshed/stdlib/email/header.pyi | 6 +- mypy/typeshed/stdlib/email/message.pyi | 4 +- mypy/typeshed/stdlib/email/policy.pyi | 14 +- mypy/typeshed/stdlib/email/utils.pyi | 12 +- mypy/typeshed/stdlib/encodings/utf_8.pyi | 11 +- mypy/typeshed/stdlib/filecmp.pyi | 4 +- mypy/typeshed/stdlib/fractions.pyi | 12 +- mypy/typeshed/stdlib/ftplib.pyi | 90 ++++-- mypy/typeshed/stdlib/gc.pyi | 6 +- mypy/typeshed/stdlib/genericpath.pyi | 16 +- mypy/typeshed/stdlib/html/parser.pyi | 6 +- mypy/typeshed/stdlib/http/client.pyi | 20 +- mypy/typeshed/stdlib/http/cookies.pyi | 4 +- mypy/typeshed/stdlib/http/server.pyi | 12 +- mypy/typeshed/stdlib/imaplib.pyi | 26 +- mypy/typeshed/stdlib/imp.pyi | 8 +- mypy/typeshed/stdlib/importlib/abc.pyi | 4 +- mypy/typeshed/stdlib/importlib/machinery.pyi | 9 +- mypy/typeshed/stdlib/inspect.pyi | 10 +- mypy/typeshed/stdlib/ipaddress.pyi | 10 +- mypy/typeshed/stdlib/itertools.pyi | 26 +- mypy/typeshed/stdlib/json/__init__.pyi | 10 +- mypy/typeshed/stdlib/json/decoder.pyi | 8 +- mypy/typeshed/stdlib/json/encoder.pyi | 4 +- mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi | 4 +- mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi | 14 +- .../stdlib/lib2to3/pgen2/tokenize.pyi | 2 +- mypy/typeshed/stdlib/lib2to3/pytree.pyi | 4 +- mypy/typeshed/stdlib/locale.pyi | 2 +- mypy/typeshed/stdlib/logging/config.pyi | 32 +- mypy/typeshed/stdlib/macpath.pyi | 6 +- mypy/typeshed/stdlib/mailbox.pyi | 15 +- mypy/typeshed/stdlib/mailcap.pyi | 4 +- mypy/typeshed/stdlib/math.pyi | 125 ++++---- mypy/typeshed/stdlib/mimetypes.pyi | 10 +- mypy/typeshed/stdlib/modulefinder.pyi | 18 +- mypy/typeshed/stdlib/msilib/__init__.pyi | 8 +- mypy/typeshed/stdlib/msilib/schema.pyi | 3 +- mypy/typeshed/stdlib/msilib/text.pyi | 5 +- .../stdlib/multiprocessing/connection.pyi | 2 +- .../multiprocessing/dummy/connection.pyi | 2 +- .../stdlib/multiprocessing/managers.pyi | 12 +- mypy/typeshed/stdlib/multiprocessing/pool.pyi | 12 +- .../stdlib/multiprocessing/shared_memory.pyi | 2 +- mypy/typeshed/stdlib/nntplib.pyi | 38 +-- mypy/typeshed/stdlib/ntpath.pyi | 4 +- mypy/typeshed/stdlib/operator.pyi | 12 +- mypy/typeshed/stdlib/optparse.pyi | 4 +- mypy/typeshed/stdlib/os/__init__.pyi | 34 +-- mypy/typeshed/stdlib/pdb.pyi | 12 +- mypy/typeshed/stdlib/pickletools.pyi | 2 +- mypy/typeshed/stdlib/pkgutil.pyi | 4 +- mypy/typeshed/stdlib/platform.pyi | 26 +- mypy/typeshed/stdlib/plistlib.pyi | 6 +- mypy/typeshed/stdlib/poplib.pyi | 6 +- mypy/typeshed/stdlib/posix.pyi | 4 +- mypy/typeshed/stdlib/posixpath.pyi | 20 +- mypy/typeshed/stdlib/pprint.pyi | 4 +- mypy/typeshed/stdlib/pstats.pyi | 8 +- mypy/typeshed/stdlib/pty.pyi | 8 +- mypy/typeshed/stdlib/pydoc.pyi | 16 +- mypy/typeshed/stdlib/pyexpat/__init__.pyi | 4 +- mypy/typeshed/stdlib/re.pyi | 10 +- mypy/typeshed/stdlib/resource.pyi | 8 +- mypy/typeshed/stdlib/select.pyi | 10 +- mypy/typeshed/stdlib/selectors.pyi | 16 +- mypy/typeshed/stdlib/shlex.pyi | 4 +- mypy/typeshed/stdlib/shutil.pyi | 16 +- mypy/typeshed/stdlib/signal.pyi | 4 +- mypy/typeshed/stdlib/site.pyi | 17 +- mypy/typeshed/stdlib/smtplib.pyi | 6 +- mypy/typeshed/stdlib/socket.pyi | 1 + mypy/typeshed/stdlib/sqlite3/dbapi2.pyi | 8 +- mypy/typeshed/stdlib/sre_parse.pyi | 4 +- mypy/typeshed/stdlib/ssl.pyi | 16 +- mypy/typeshed/stdlib/string.pyi | 4 +- mypy/typeshed/stdlib/subprocess.pyi | 13 +- mypy/typeshed/stdlib/sys.pyi | 6 +- mypy/typeshed/stdlib/tabnanny.pyi | 4 +- mypy/typeshed/stdlib/telnetlib.pyi | 4 +- mypy/typeshed/stdlib/tempfile.pyi | 4 +- mypy/typeshed/stdlib/time.pyi | 14 +- mypy/typeshed/stdlib/timeit.pyi | 4 +- mypy/typeshed/stdlib/tkinter/__init__.pyi | 289 +++++++++--------- mypy/typeshed/stdlib/tkinter/colorchooser.pyi | 4 +- mypy/typeshed/stdlib/tkinter/filedialog.pyi | 16 +- mypy/typeshed/stdlib/tkinter/font.pyi | 5 +- mypy/typeshed/stdlib/tkinter/tix.pyi | 4 +- mypy/typeshed/stdlib/tkinter/ttk.pyi | 160 +++++----- mypy/typeshed/stdlib/tokenize.pyi | 2 +- mypy/typeshed/stdlib/trace.pyi | 6 +- mypy/typeshed/stdlib/traceback.pyi | 6 +- mypy/typeshed/stdlib/turtle.pyi | 36 +-- mypy/typeshed/stdlib/types.pyi | 19 +- mypy/typeshed/stdlib/typing.pyi | 40 ++- mypy/typeshed/stdlib/unittest/mock.pyi | 2 +- mypy/typeshed/stdlib/unittest/result.pyi | 8 +- mypy/typeshed/stdlib/unittest/runner.pyi | 4 +- mypy/typeshed/stdlib/unittest/util.pyi | 6 +- mypy/typeshed/stdlib/urllib/error.pyi | 6 +- mypy/typeshed/stdlib/urllib/parse.pyi | 8 +- mypy/typeshed/stdlib/urllib/request.pyi | 22 +- mypy/typeshed/stdlib/warnings.pyi | 11 +- mypy/typeshed/stdlib/weakref.pyi | 20 +- mypy/typeshed/stdlib/winreg.pyi | 8 +- mypy/typeshed/stdlib/wsgiref/handlers.pyi | 6 +- mypy/typeshed/stdlib/xml/dom/domreg.pyi | 4 +- mypy/typeshed/stdlib/xml/dom/minicompat.pyi | 2 +- .../typeshed/stdlib/xml/etree/ElementTree.pyi | 9 +- mypy/typeshed/stdlib/xml/sax/xmlreader.pyi | 4 +- mypy/typeshed/stdlib/xmlrpc/client.pyi | 32 +- mypy/typeshed/stdlib/xmlrpc/server.pyi | 8 +- mypy/typeshed/stdlib/zipimport.pyi | 4 +- .../stubs/mypy-extensions/METADATA.toml | 2 +- 180 files changed, 1350 insertions(+), 1194 deletions(-) diff --git a/mypy/typeshed/stdlib/@python2/__builtin__.pyi b/mypy/typeshed/stdlib/@python2/__builtin__.pyi index ebe9cdd95038..453a95871463 100644 --- a/mypy/typeshed/stdlib/@python2/__builtin__.pyi +++ b/mypy/typeshed/stdlib/@python2/__builtin__.pyi @@ -952,7 +952,7 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... @overload def next(__i: Iterator[_T]) -> _T: ... @overload -def next(__i: Iterator[_T], default: _VT) -> _T | _VT: ... +def next(__i: Iterator[_T], __default: _VT) -> _T | _VT: ... def oct(__number: int | _SupportsIndex) -> str: ... def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... def ord(__c: Text | bytes) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/builtins.pyi b/mypy/typeshed/stdlib/@python2/builtins.pyi index ebe9cdd95038..453a95871463 100644 --- a/mypy/typeshed/stdlib/@python2/builtins.pyi +++ b/mypy/typeshed/stdlib/@python2/builtins.pyi @@ -952,7 +952,7 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... @overload def next(__i: Iterator[_T]) -> _T: ... @overload -def next(__i: Iterator[_T], default: _VT) -> _T | _VT: ... +def next(__i: Iterator[_T], __default: _VT) -> _T | _VT: ... def oct(__number: int | _SupportsIndex) -> str: ... def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... def ord(__c: Text | bytes) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/sqlite3/dbapi2.pyi b/mypy/typeshed/stdlib/@python2/sqlite3/dbapi2.pyi index fadfcc8f5884..023a0506f4aa 100644 --- a/mypy/typeshed/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/mypy/typeshed/stdlib/@python2/sqlite3/dbapi2.pyi @@ -135,7 +135,7 @@ class Cursor(Iterator[Any]): description: Any lastrowid: Any row_factory: Any - rowcount: Any + rowcount: int # TODO: Cursor class accepts exactly 1 argument # required type is sqlite3.Connection (which is imported as _Connection) # however, the name of the __init__ variable is unknown diff --git a/mypy/typeshed/stdlib/_codecs.pyi b/mypy/typeshed/stdlib/_codecs.pyi index aa30309cb53c..5e4a9ad6da3d 100644 --- a/mypy/typeshed/stdlib/_codecs.pyi +++ b/mypy/typeshed/stdlib/_codecs.pyi @@ -16,51 +16,51 @@ def lookup_error(__name: str) -> _Handler: ... def decode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ... def encode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ... def charmap_build(__map: str) -> _MapT: ... -def ascii_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ... -def ascii_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def charmap_decode(__data: bytes, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[str, int]: ... -def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[bytes, int]: ... -def escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ... -def escape_encode(__data: bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def latin_1_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ... -def latin_1_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def raw_unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ... -def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def readbuffer_encode(__data: str | bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ... -def unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def ascii_decode(__data: bytes, __errors: str | None = ...) -> tuple[str, int]: ... +def ascii_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def charmap_decode(__data: bytes, __errors: str | None = ..., __mapping: _MapT | None = ...) -> tuple[str, int]: ... +def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _MapT | None = ...) -> tuple[bytes, int]: ... +def escape_decode(__data: str | bytes, __errors: str | None = ...) -> tuple[str, int]: ... +def escape_encode(__data: bytes, __errors: str | None = ...) -> tuple[bytes, int]: ... +def latin_1_decode(__data: bytes, __errors: str | None = ...) -> tuple[str, int]: ... +def latin_1_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def raw_unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> tuple[str, int]: ... +def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def readbuffer_encode(__data: str | bytes, __errors: str | None = ...) -> tuple[bytes, int]: ... +def unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> tuple[str, int]: ... +def unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... if sys.version_info < (3, 8): - def unicode_internal_decode(__obj: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ... - def unicode_internal_encode(__obj: str | bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ... + def unicode_internal_decode(__obj: str | bytes, __errors: str | None = ...) -> tuple[str, int]: ... + def unicode_internal_encode(__obj: str | bytes, __errors: str | None = ...) -> tuple[bytes, int]: ... -def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_16_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def utf_16_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_16_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ... +def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... +def utf_16_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def utf_16_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... +def utf_16_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ... def utf_16_ex_decode( __data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ... -) -> Tuple[str, int, int]: ... -def utf_16_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_16_le_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def utf_32_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_32_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def utf_32_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ... +) -> tuple[str, int, int]: ... +def utf_16_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... +def utf_16_le_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def utf_32_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... +def utf_32_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def utf_32_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... +def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ... def utf_32_ex_decode( __data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ... -) -> Tuple[str, int, int]: ... -def utf_32_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_32_le_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def utf_7_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_7_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def utf_8_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_8_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +) -> tuple[str, int, int]: ... +def utf_32_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... +def utf_32_le_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def utf_7_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... +def utf_7_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def utf_8_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... +def utf_8_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... if sys.platform == "win32": - def mbcs_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... - def mbcs_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... - def code_page_decode(__codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... - def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... - def oem_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... - def oem_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... + def mbcs_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... + def mbcs_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... + def code_page_decode(__codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... + def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... + def oem_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ... + def oem_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... diff --git a/mypy/typeshed/stdlib/_compat_pickle.pyi b/mypy/typeshed/stdlib/_compat_pickle.pyi index ba6c88a03035..76aba3020321 100644 --- a/mypy/typeshed/stdlib/_compat_pickle.pyi +++ b/mypy/typeshed/stdlib/_compat_pickle.pyi @@ -1,10 +1,10 @@ from typing import Tuple IMPORT_MAPPING: dict[str, str] -NAME_MAPPING: dict[Tuple[str, str], Tuple[str, str]] +NAME_MAPPING: dict[tuple[str, str], tuple[str, str]] PYTHON2_EXCEPTIONS: Tuple[str, ...] MULTIPROCESSING_EXCEPTIONS: Tuple[str, ...] REVERSE_IMPORT_MAPPING: dict[str, str] -REVERSE_NAME_MAPPING: dict[Tuple[str, str], Tuple[str, str]] +REVERSE_NAME_MAPPING: dict[tuple[str, str], tuple[str, str]] PYTHON3_OSERROR_EXCEPTIONS: Tuple[str, ...] PYTHON3_IMPORTERROR_EXCEPTIONS: Tuple[str, ...] diff --git a/mypy/typeshed/stdlib/_curses.pyi b/mypy/typeshed/stdlib/_curses.pyi index e4fc2a8f68f0..e0f978c5cae1 100644 --- a/mypy/typeshed/stdlib/_curses.pyi +++ b/mypy/typeshed/stdlib/_curses.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, BinaryIO, NamedTuple, Tuple, Union, overload +from typing import IO, Any, BinaryIO, NamedTuple, Union, overload _chtype = Union[str, bytes, int] @@ -273,7 +273,7 @@ def baudrate() -> int: ... def beep() -> None: ... def can_change_color() -> bool: ... def cbreak(__flag: bool = ...) -> None: ... -def color_content(__color_number: int) -> Tuple[int, int, int]: ... +def color_content(__color_number: int) -> tuple[int, int, int]: ... # Changed in Python 3.8.8 and 3.9.2 if sys.version_info >= (3, 8): @@ -293,8 +293,8 @@ def erasechar() -> bytes: ... def filter() -> None: ... def flash() -> None: ... def flushinp() -> None: ... -def getmouse() -> Tuple[int, int, int, int, int]: ... -def getsyx() -> Tuple[int, int]: ... +def getmouse() -> tuple[int, int, int, int, int]: ... +def getsyx() -> tuple[int, int]: ... def getwin(__file: BinaryIO) -> _CursesWindow: ... def halfdelay(__tenths: int) -> None: ... def has_colors() -> bool: ... @@ -316,7 +316,7 @@ def killchar() -> bytes: ... def longname() -> bytes: ... def meta(__yes: bool) -> None: ... def mouseinterval(__interval: int) -> None: ... -def mousemask(__newmask: int) -> Tuple[int, int]: ... +def mousemask(__newmask: int) -> tuple[int, int]: ... def napms(__ms: int) -> int: ... def newpad(__nlines: int, __ncols: int) -> _CursesWindow: ... def newwin(__nlines: int, __ncols: int, __begin_y: int = ..., __begin_x: int = ...) -> _CursesWindow: ... @@ -326,7 +326,7 @@ def noecho() -> None: ... def nonl() -> None: ... def noqiflush() -> None: ... def noraw() -> None: ... -def pair_content(__pair_number: int) -> Tuple[int, int]: ... +def pair_content(__pair_number: int) -> tuple[int, int]: ... def pair_number(__attr: int) -> int: ... def putp(__string: bytes) -> None: ... def qiflush(__flag: bool = ...) -> None: ... @@ -427,8 +427,8 @@ class _CursesWindow: def echochar(self, __ch: _chtype, __attr: int = ...) -> None: ... def enclose(self, __y: int, __x: int) -> bool: ... def erase(self) -> None: ... - def getbegyx(self) -> Tuple[int, int]: ... - def getbkgd(self) -> Tuple[int, int]: ... + def getbegyx(self) -> tuple[int, int]: ... + def getbkgd(self) -> tuple[int, int]: ... @overload def getch(self) -> int: ... @overload @@ -441,8 +441,8 @@ class _CursesWindow: def getkey(self) -> str: ... @overload def getkey(self, y: int, x: int) -> str: ... - def getmaxyx(self) -> Tuple[int, int]: ... - def getparyx(self) -> Tuple[int, int]: ... + def getmaxyx(self) -> tuple[int, int]: ... + def getparyx(self) -> tuple[int, int]: ... @overload def getstr(self) -> _chtype: ... @overload @@ -451,7 +451,7 @@ class _CursesWindow: def getstr(self, y: int, x: int) -> _chtype: ... @overload def getstr(self, y: int, x: int, n: int) -> _chtype: ... - def getyx(self) -> Tuple[int, int]: ... + def getyx(self) -> tuple[int, int]: ... @overload def hline(self, ch: _chtype, n: int) -> None: ... @overload diff --git a/mypy/typeshed/stdlib/_json.pyi b/mypy/typeshed/stdlib/_json.pyi index f807a85b93f4..7395288afdbc 100644 --- a/mypy/typeshed/stdlib/_json.pyi +++ b/mypy/typeshed/stdlib/_json.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Tuple +from typing import Any, Callable class make_encoder: sort_keys: Any @@ -32,7 +32,7 @@ class make_scanner: strict: bool # TODO: 'context' needs the attrs above (ducktype), but not __call__. def __init__(self, context: make_scanner) -> None: ... - def __call__(self, string: str, index: int) -> Tuple[Any, int]: ... + def __call__(self, string: str, index: int) -> tuple[Any, int]: ... def encode_basestring_ascii(s: str) -> str: ... -def scanstring(string: str, end: int, strict: bool = ...) -> Tuple[str, int]: ... +def scanstring(string: str, end: int, strict: bool = ...) -> tuple[str, int]: ... diff --git a/mypy/typeshed/stdlib/_markupbase.pyi b/mypy/typeshed/stdlib/_markupbase.pyi index d8bc79f34e8c..368d32bd5b4c 100644 --- a/mypy/typeshed/stdlib/_markupbase.pyi +++ b/mypy/typeshed/stdlib/_markupbase.pyi @@ -1,8 +1,6 @@ -from typing import Tuple - class ParserBase: def __init__(self) -> None: ... def error(self, message: str) -> None: ... def reset(self) -> None: ... - def getpos(self) -> Tuple[int, int]: ... + def getpos(self) -> tuple[int, int]: ... def unknown_decl(self, data: str) -> None: ... diff --git a/mypy/typeshed/stdlib/_osx_support.pyi b/mypy/typeshed/stdlib/_osx_support.pyi index f03c37d1011a..ce1fffc00e8c 100644 --- a/mypy/typeshed/stdlib/_osx_support.pyi +++ b/mypy/typeshed/stdlib/_osx_support.pyi @@ -30,4 +30,4 @@ def customize_config_vars(_config_vars: dict[str, str]) -> dict[str, str]: ... def customize_compiler(_config_vars: dict[str, str]) -> dict[str, str]: ... def get_platform_osx( _config_vars: dict[str, str], osname: _T, release: _K, machine: _V -) -> Tuple[str | _T, str | _K, str | _V]: ... +) -> tuple[str | _T, str | _K, str | _V]: ... diff --git a/mypy/typeshed/stdlib/_posixsubprocess.pyi b/mypy/typeshed/stdlib/_posixsubprocess.pyi index 05209ba05b9b..0eae723e7a67 100644 --- a/mypy/typeshed/stdlib/_posixsubprocess.pyi +++ b/mypy/typeshed/stdlib/_posixsubprocess.pyi @@ -1,8 +1,8 @@ # NOTE: These are incomplete! -from typing import Callable, Sequence, Tuple +from typing import Callable, Sequence -def cloexec_pipe() -> Tuple[int, int]: ... +def cloexec_pipe() -> tuple[int, int]: ... def fork_exec( args: Sequence[str], executable_list: Sequence[bytes], diff --git a/mypy/typeshed/stdlib/_socket.pyi b/mypy/typeshed/stdlib/_socket.pyi index 7945c662e820..846f64d5a433 100644 --- a/mypy/typeshed/stdlib/_socket.pyi +++ b/mypy/typeshed/stdlib/_socket.pyi @@ -325,6 +325,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 7): if sys.platform == "linux" and sys.version_info >= (3, 9): CAN_J1939: int + CAN_RAW_JOIN_FILTERS: int J1939_MAX_UNICAST_ADDR: int J1939_IDLE_ADDR: int diff --git a/mypy/typeshed/stdlib/_threading_local.pyi b/mypy/typeshed/stdlib/_threading_local.pyi index 461459d694dd..bab69a7c2e7d 100644 --- a/mypy/typeshed/stdlib/_threading_local.pyi +++ b/mypy/typeshed/stdlib/_threading_local.pyi @@ -1,11 +1,11 @@ -from typing import Any, Dict, Tuple +from typing import Any, Dict from weakref import ReferenceType localdict = Dict[Any, Any] class _localimpl: key: str - dicts: dict[int, Tuple[ReferenceType[Any], localdict]] + dicts: dict[int, tuple[ReferenceType[Any], localdict]] def __init__(self) -> None: ... def get_dict(self) -> localdict: ... def create_dict(self) -> localdict: ... diff --git a/mypy/typeshed/stdlib/_tracemalloc.pyi b/mypy/typeshed/stdlib/_tracemalloc.pyi index 27637637f6c5..fd159dc586cb 100644 --- a/mypy/typeshed/stdlib/_tracemalloc.pyi +++ b/mypy/typeshed/stdlib/_tracemalloc.pyi @@ -1,12 +1,12 @@ import sys from tracemalloc import _FrameTupleT, _TraceTupleT -from typing import Sequence, Tuple +from typing import Sequence def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ... def _get_traces() -> Sequence[_TraceTupleT]: ... def clear_traces() -> None: ... def get_traceback_limit() -> int: ... -def get_traced_memory() -> Tuple[int, int]: ... +def get_traced_memory() -> tuple[int, int]: ... def get_tracemalloc_memory() -> int: ... def is_tracing() -> bool: ... diff --git a/mypy/typeshed/stdlib/_typeshed/__init__.pyi b/mypy/typeshed/stdlib/_typeshed/__init__.pyi index 9e60fd07e017..6dd0b38c2e65 100644 --- a/mypy/typeshed/stdlib/_typeshed/__init__.pyi +++ b/mypy/typeshed/stdlib/_typeshed/__init__.pyi @@ -7,7 +7,7 @@ import ctypes import mmap import sys from os import PathLike -from typing import AbstractSet, Any, Awaitable, Container, Iterable, Protocol, Tuple, TypeVar, Union +from typing import AbstractSet, Any, Awaitable, Container, Iterable, Protocol, TypeVar, Union from typing_extensions import Literal, final _KT = TypeVar("_KT") @@ -57,7 +57,7 @@ class SupportsTrunc(Protocol): # stable class SupportsItems(Protocol[_KT_co, _VT_co]): - def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: ... + def items(self) -> AbstractSet[tuple[_KT_co, _VT_co]]: ... # stable class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]): diff --git a/mypy/typeshed/stdlib/_typeshed/wsgi.pyi b/mypy/typeshed/stdlib/_typeshed/wsgi.pyi index ddb32b78332a..658b0fed2c6c 100644 --- a/mypy/typeshed/stdlib/_typeshed/wsgi.pyi +++ b/mypy/typeshed/stdlib/_typeshed/wsgi.pyi @@ -3,12 +3,12 @@ # See the README.md file in this directory for more information. from sys import _OptExcInfo -from typing import Any, Callable, Dict, Iterable, Protocol, Tuple +from typing import Any, Callable, Dict, Iterable, Protocol # stable class StartResponse(Protocol): def __call__( - self, status: str, headers: list[Tuple[str, str]], exc_info: _OptExcInfo | None = ... + self, status: str, headers: list[tuple[str, str]], exc_info: _OptExcInfo | None = ... ) -> Callable[[bytes], Any]: ... WSGIEnvironment = Dict[str, Any] # stable diff --git a/mypy/typeshed/stdlib/_warnings.pyi b/mypy/typeshed/stdlib/_warnings.pyi index fef73e69c626..e5b180b14fea 100644 --- a/mypy/typeshed/stdlib/_warnings.pyi +++ b/mypy/typeshed/stdlib/_warnings.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple, Type, overload +from typing import Any, Type, overload _defaultaction: str _onceregistry: dict[Any, Any] @@ -15,7 +15,7 @@ def warn_explicit( filename: str, lineno: int, module: str | None = ..., - registry: dict[str | Tuple[str, Type[Warning], int], int] | None = ..., + registry: dict[str | tuple[str, Type[Warning], int], int] | None = ..., module_globals: dict[str, Any] | None = ..., source: Any | None = ..., ) -> None: ... @@ -26,7 +26,7 @@ def warn_explicit( filename: str, lineno: int, module: str | None = ..., - registry: dict[str | Tuple[str, Type[Warning], int], int] | None = ..., + registry: dict[str | tuple[str, Type[Warning], int], int] | None = ..., module_globals: dict[str, Any] | None = ..., source: Any | None = ..., ) -> None: ... diff --git a/mypy/typeshed/stdlib/_winapi.pyi b/mypy/typeshed/stdlib/_winapi.pyi index eabbad312abc..f1a12be18677 100644 --- a/mypy/typeshed/stdlib/_winapi.pyi +++ b/mypy/typeshed/stdlib/_winapi.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, NoReturn, Sequence, Tuple, overload +from typing import Any, NoReturn, Sequence, overload from typing_extensions import Literal CREATE_NEW_CONSOLE: int @@ -73,7 +73,7 @@ def CreateNamedPipe( __default_timeout: int, __security_attributes: int, ) -> int: ... -def CreatePipe(__pipe_attrs: Any, __size: int) -> Tuple[int, int]: ... +def CreatePipe(__pipe_attrs: Any, __size: int) -> tuple[int, int]: ... def CreateProcess( __application_name: str | None, __command_line: str | None, @@ -84,7 +84,7 @@ def CreateProcess( __env_mapping: dict[str, str], __current_directory: str | None, __startup_info: Any, -) -> Tuple[int, int, int, int]: ... +) -> tuple[int, int, int, int]: ... def DuplicateHandle( __source_process_handle: int, __source_handle: int, @@ -106,13 +106,13 @@ def GetModuleFileName(__module_handle: int) -> str: ... def GetStdHandle(__std_handle: int) -> int: ... def GetVersion() -> int: ... def OpenProcess(__desired_access: int, __inherit_handle: bool, __process_id: int) -> int: ... -def PeekNamedPipe(__handle: int, __size: int = ...) -> Tuple[int, int] | Tuple[bytes, int, int]: ... +def PeekNamedPipe(__handle: int, __size: int = ...) -> tuple[int, int] | tuple[bytes, int, int]: ... @overload -def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> Tuple[Overlapped, int]: ... +def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> tuple[Overlapped, int]: ... @overload -def ReadFile(handle: int, size: int, overlapped: Literal[False] = ...) -> Tuple[bytes, int]: ... +def ReadFile(handle: int, size: int, overlapped: Literal[False] = ...) -> tuple[bytes, int]: ... @overload -def ReadFile(handle: int, size: int, overlapped: int | bool) -> Tuple[Any, int]: ... +def ReadFile(handle: int, size: int, overlapped: int | bool) -> tuple[Any, int]: ... def SetNamedPipeHandleState( __named_pipe: int, __mode: int | None, __max_collection_count: int | None, __collect_data_timeout: int | None ) -> None: ... @@ -121,14 +121,14 @@ def WaitForMultipleObjects(__handle_seq: Sequence[int], __wait_flag: bool, __mil def WaitForSingleObject(__handle: int, __milliseconds: int) -> int: ... def WaitNamedPipe(__name: str, __timeout: int) -> None: ... @overload -def WriteFile(handle: int, buffer: bytes, overlapped: Literal[True]) -> Tuple[Overlapped, int]: ... +def WriteFile(handle: int, buffer: bytes, overlapped: Literal[True]) -> tuple[Overlapped, int]: ... @overload -def WriteFile(handle: int, buffer: bytes, overlapped: Literal[False] = ...) -> Tuple[int, int]: ... +def WriteFile(handle: int, buffer: bytes, overlapped: Literal[False] = ...) -> tuple[int, int]: ... @overload -def WriteFile(handle: int, buffer: bytes, overlapped: int | bool) -> Tuple[Any, int]: ... +def WriteFile(handle: int, buffer: bytes, overlapped: int | bool) -> tuple[Any, int]: ... class Overlapped: event: int - def GetOverlappedResult(self, __wait: bool) -> Tuple[int, int]: ... + def GetOverlappedResult(self, __wait: bool) -> tuple[int, int]: ... def cancel(self) -> None: ... def getbuffer(self) -> bytes | None: ... diff --git a/mypy/typeshed/stdlib/aifc.pyi b/mypy/typeshed/stdlib/aifc.pyi index 7d7c6b21f341..79f470a366bb 100644 --- a/mypy/typeshed/stdlib/aifc.pyi +++ b/mypy/typeshed/stdlib/aifc.pyi @@ -61,7 +61,7 @@ class Aifc_write: def setcomptype(self, comptype: bytes, compname: bytes) -> None: ... def getcomptype(self) -> bytes: ... def getcompname(self) -> bytes: ... - def setparams(self, params: Tuple[int, int, int, int, bytes, bytes]) -> None: ... + def setparams(self, params: tuple[int, int, int, int, bytes, bytes]) -> None: ... def getparams(self) -> _aifc_params: ... def setmark(self, id: int, pos: int, name: bytes) -> None: ... def getmark(self, id: int) -> _Marker: ... diff --git a/mypy/typeshed/stdlib/argparse.pyi b/mypy/typeshed/stdlib/argparse.pyi index 631030e94923..b9a09f56a812 100644 --- a/mypy/typeshed/stdlib/argparse.pyi +++ b/mypy/typeshed/stdlib/argparse.pyi @@ -1,8 +1,24 @@ import sys -from typing import IO, Any, Callable, Generator, Iterable, NoReturn, Pattern, Protocol, Sequence, Tuple, Type, TypeVar, overload +from typing import ( + IO, + Any, + Callable, + Generator, + Generic, + Iterable, + NoReturn, + Pattern, + Protocol, + Sequence, + Tuple, + Type, + TypeVar, + overload, +) _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) +_ArgumentParserT = TypeVar("_ArgumentParserT", bound=ArgumentParser) _N = TypeVar("_N") ONE_OR_MORE: str @@ -20,7 +36,7 @@ class ArgumentError(Exception): # undocumented class _AttributeHolder: - def _get_kwargs(self) -> list[Tuple[str, Any]]: ... + def _get_kwargs(self) -> list[tuple[str, Any]]: ... def _get_args(self) -> list[Any]: ... # undocumented @@ -67,10 +83,10 @@ class _ActionsContainer: def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> dict[str, Any]: ... def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ... def _pop_action_class(self, kwargs: Any, default: Type[Action] | None = ...) -> Type[Action]: ... - def _get_handler(self) -> Callable[[Action, Iterable[Tuple[str, Action]]], Any]: ... + def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ... def _check_conflict(self, action: Action) -> None: ... - def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[Tuple[str, Action]]) -> NoReturn: ... - def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[Tuple[str, Action]]) -> None: ... + def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ... + def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> None: ... class _FormatterClass(Protocol): def __call__(self, prog: str) -> HelpFormatter: ... @@ -135,41 +151,70 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): @overload def parse_args(self, *, namespace: _N) -> _N: ... if sys.version_info >= (3, 7): + @overload + def add_subparsers( + self: _ArgumentParserT, + *, + title: str = ..., + description: str | None = ..., + prog: str = ..., + action: Type[Action] = ..., + option_string: str = ..., + dest: str | None = ..., + required: bool = ..., + help: str | None = ..., + metavar: str | None = ..., + ) -> _SubParsersAction[_ArgumentParserT]: ... + @overload def add_subparsers( self, *, title: str = ..., description: str | None = ..., prog: str = ..., - parser_class: Type[ArgumentParser] = ..., + parser_class: Type[_ArgumentParserT] = ..., action: Type[Action] = ..., option_string: str = ..., dest: str | None = ..., required: bool = ..., help: str | None = ..., metavar: str | None = ..., - ) -> _SubParsersAction: ... + ) -> _SubParsersAction[_ArgumentParserT]: ... else: + @overload + def add_subparsers( + self: _ArgumentParserT, + *, + title: str = ..., + description: str | None = ..., + prog: str = ..., + action: Type[Action] = ..., + option_string: str = ..., + dest: str | None = ..., + help: str | None = ..., + metavar: str | None = ..., + ) -> _SubParsersAction[_ArgumentParserT]: ... + @overload def add_subparsers( self, *, title: str = ..., description: str | None = ..., prog: str = ..., - parser_class: Type[ArgumentParser] = ..., + parser_class: Type[_ArgumentParserT] = ..., action: Type[Action] = ..., option_string: str = ..., dest: str | None = ..., help: str | None = ..., metavar: str | None = ..., - ) -> _SubParsersAction: ... + ) -> _SubParsersAction[_ArgumentParserT]: ... def print_usage(self, file: IO[str] | None = ...) -> None: ... def print_help(self, file: IO[str] | None = ...) -> None: ... def format_usage(self) -> str: ... def format_help(self) -> str: ... def parse_known_args( self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... - ) -> Tuple[Namespace, list[str]]: ... + ) -> tuple[Namespace, list[str]]: ... def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ... def exit(self, status: int = ..., message: str | None = ...) -> NoReturn: ... def error(self, message: str) -> NoReturn: ... @@ -177,16 +222,16 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def parse_intermixed_args(self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...) -> Namespace: ... def parse_known_intermixed_args( self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... - ) -> Tuple[Namespace, list[str]]: ... + ) -> tuple[Namespace, list[str]]: ... # undocumented def _get_optional_actions(self) -> list[Action]: ... def _get_positional_actions(self) -> list[Action]: ... - def _parse_known_args(self, arg_strings: list[str], namespace: Namespace) -> Tuple[Namespace, list[str]]: ... + def _parse_known_args(self, arg_strings: list[str], namespace: Namespace) -> tuple[Namespace, list[str]]: ... def _read_args_from_files(self, arg_strings: list[str]) -> list[str]: ... def _match_argument(self, action: Action, arg_strings_pattern: str) -> int: ... def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: str) -> list[int]: ... - def _parse_optional(self, arg_string: str) -> Tuple[Action | None, str, str | None] | None: ... - def _get_option_tuples(self, option_string: str) -> list[Tuple[Action, str, str | None]]: ... + def _parse_optional(self, arg_string: str) -> tuple[Action | None, str, str | None] | None: ... + def _get_option_tuples(self, option_string: str) -> list[tuple[Action, str, str | None]]: ... def _get_nargs_pattern(self, action: Action) -> str: ... def _get_values(self, action: Action, arg_strings: list[str]) -> Any: ... def _get_value(self, action: Action, arg_string: str) -> Any: ... @@ -379,19 +424,19 @@ class _VersionAction(Action): ) -> None: ... # undocumented -class _SubParsersAction(Action): +class _SubParsersAction(Action, Generic[_ArgumentParserT]): _ChoicesPseudoAction: Type[Any] # nested class _prog_prefix: str - _parser_class: Type[ArgumentParser] - _name_parser_map: dict[str, ArgumentParser] - choices: dict[str, ArgumentParser] + _parser_class: Type[_ArgumentParserT] + _name_parser_map: dict[str, _ArgumentParserT] + choices: dict[str, _ArgumentParserT] _choices_actions: list[Action] if sys.version_info >= (3, 7): def __init__( self, option_strings: Sequence[str], prog: str, - parser_class: Type[ArgumentParser], + parser_class: Type[_ArgumentParserT], dest: str = ..., required: bool = ..., help: str | None = ..., @@ -402,13 +447,13 @@ class _SubParsersAction(Action): self, option_strings: Sequence[str], prog: str, - parser_class: Type[ArgumentParser], + parser_class: Type[_ArgumentParserT], dest: str = ..., help: str | None = ..., metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... # TODO: Type keyword args properly. - def add_parser(self, name: str, **kwargs: Any) -> ArgumentParser: ... + def add_parser(self, name: str, **kwargs: Any) -> _ArgumentParserT: ... def _get_subactions(self) -> list[Action]: ... # undocumented diff --git a/mypy/typeshed/stdlib/array.pyi b/mypy/typeshed/stdlib/array.pyi index c32136d559bf..cbb765a6880f 100644 --- a/mypy/typeshed/stdlib/array.pyi +++ b/mypy/typeshed/stdlib/array.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, Tuple, TypeVar, Union, overload +from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, TypeVar, Union, overload from typing_extensions import Literal _IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] @@ -23,7 +23,7 @@ class array(MutableSequence[_T], Generic[_T]): @overload def __init__(self, typecode: str, __initializer: bytes | Iterable[_T] = ...) -> None: ... def append(self, __v: _T) -> None: ... - def buffer_info(self) -> Tuple[int, int]: ... + def buffer_info(self) -> tuple[int, int]: ... def byteswap(self) -> None: ... def count(self, __v: Any) -> int: ... def extend(self, __bb: Iterable[_T]) -> None: ... diff --git a/mypy/typeshed/stdlib/asyncio/base_events.pyi b/mypy/typeshed/stdlib/asyncio/base_events.pyi index 349050258a16..15471f54483f 100644 --- a/mypy/typeshed/stdlib/asyncio/base_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/base_events.pyi @@ -89,8 +89,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): # Network I/O methods returning Futures. async def getaddrinfo( self, host: str | None, port: str | int | None, *, family: int = ..., type: int = ..., proto: int = ..., flags: int = ... - ) -> list[Tuple[AddressFamily, SocketKind, int, str, Tuple[str, int] | Tuple[str, int, int, int]]]: ... - async def getnameinfo(self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ...) -> Tuple[str, str]: ... + ) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ... + async def getnameinfo(self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = ...) -> tuple[str, str]: ... if sys.version_info >= (3, 8): @overload async def create_connection( @@ -104,7 +104,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Tuple[str, int] | None = ..., + local_addr: tuple[str, int] | None = ..., server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., happy_eyeballs_delay: float | None = ..., @@ -141,7 +141,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Tuple[str, int] | None = ..., + local_addr: tuple[str, int] | None = ..., server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... @@ -174,7 +174,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Tuple[str, int] | None = ..., + local_addr: tuple[str, int] | None = ..., server_hostname: str | None = ..., ) -> _TransProtPair: ... @overload @@ -288,8 +288,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def create_datagram_endpoint( self, protocol_factory: _ProtocolFactory, - local_addr: Tuple[str, int] | None = ..., - remote_addr: Tuple[str, int] | None = ..., + local_addr: tuple[str, int] | None = ..., + remote_addr: tuple[str, int] | None = ..., *, family: int = ..., proto: int = ..., @@ -343,12 +343,12 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def sock_recv_into(self, sock: socket, buf: bytearray) -> int: ... async def sock_sendall(self, sock: socket, data: bytes) -> None: ... async def sock_connect(self, sock: socket, address: _Address) -> None: ... - async def sock_accept(self, sock: socket) -> Tuple[socket, _RetAddress]: ... + async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ... else: def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ... def sock_sendall(self, sock: socket, data: bytes) -> Future[None]: ... def sock_connect(self, sock: socket, address: _Address) -> Future[None]: ... - def sock_accept(self, sock: socket) -> Future[Tuple[socket, _RetAddress]]: ... + def sock_accept(self, sock: socket) -> Future[tuple[socket, _RetAddress]]: ... # Signal handling. def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ... def remove_signal_handler(self, sig: int) -> bool: ... diff --git a/mypy/typeshed/stdlib/asyncio/base_futures.pyi b/mypy/typeshed/stdlib/asyncio/base_futures.pyi index 1c5f03e8ea72..72ba6163e9d3 100644 --- a/mypy/typeshed/stdlib/asyncio/base_futures.pyi +++ b/mypy/typeshed/stdlib/asyncio/base_futures.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Sequence, Tuple +from typing import Any, Callable, Sequence from typing_extensions import Literal if sys.version_info >= (3, 7): @@ -14,7 +14,7 @@ _FINISHED: Literal["FINISHED"] # undocumented def isfuture(obj: object) -> bool: ... if sys.version_info >= (3, 7): - def _format_callbacks(cb: Sequence[Tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented + def _format_callbacks(cb: Sequence[tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented else: def _format_callbacks(cb: Sequence[Callable[[futures.Future[Any]], None]]) -> str: ... # undocumented diff --git a/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi b/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi index 6165e0bb88d0..a27fe764359e 100644 --- a/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi +++ b/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi @@ -14,7 +14,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/mypy/typeshed/stdlib/asyncio/coroutines.pyi b/mypy/typeshed/stdlib/asyncio/coroutines.pyi index e514b884c201..df94d5ba156a 100644 --- a/mypy/typeshed/stdlib/asyncio/coroutines.pyi +++ b/mypy/typeshed/stdlib/asyncio/coroutines.pyi @@ -1,7 +1,16 @@ -from typing import Any, Callable, TypeVar +import sys +import types +from collections.abc import Callable, Coroutine +from typing import Any, TypeVar +from typing_extensions import TypeGuard _F = TypeVar("_F", bound=Callable[..., Any]) def coroutine(func: _F) -> _F: ... def iscoroutinefunction(func: object) -> bool: ... -def iscoroutine(obj: object) -> bool: ... + +if sys.version_info < (3, 8): + def iscoroutine(obj: object) -> TypeGuard[types.GeneratorType[Any, Any, Any] | Coroutine[Any, Any, Any]]: ... + +else: + def iscoroutine(obj: object) -> TypeGuard[Coroutine[Any, Any, Any]]: ... diff --git a/mypy/typeshed/stdlib/asyncio/events.pyi b/mypy/typeshed/stdlib/asyncio/events.pyi index 9b77a915e5c9..6ef9117b6491 100644 --- a/mypy/typeshed/stdlib/asyncio/events.pyi +++ b/mypy/typeshed/stdlib/asyncio/events.pyi @@ -113,16 +113,16 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... @abstractmethod - def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Awaitable[_T]: ... + def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Future[_T]: ... @abstractmethod def set_default_executor(self, executor: Any) -> None: ... # Network I/O methods returning Futures. @abstractmethod async def getaddrinfo( self, host: str | None, port: str | int | None, *, family: int = ..., type: int = ..., proto: int = ..., flags: int = ... - ) -> list[Tuple[AddressFamily, SocketKind, int, str, Tuple[str, int] | Tuple[str, int, int, int]]]: ... + ) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ... @abstractmethod - async def getnameinfo(self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ...) -> Tuple[str, str]: ... + async def getnameinfo(self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = ...) -> tuple[str, str]: ... if sys.version_info >= (3, 8): @overload @abstractmethod @@ -137,7 +137,7 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Tuple[str, int] | None = ..., + local_addr: tuple[str, int] | None = ..., server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., happy_eyeballs_delay: float | None = ..., @@ -176,7 +176,7 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Tuple[str, int] | None = ..., + local_addr: tuple[str, int] | None = ..., server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... @@ -211,7 +211,7 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Tuple[str, int] | None = ..., + local_addr: tuple[str, int] | None = ..., server_hostname: str | None = ..., ) -> _TransProtPair: ... @overload @@ -362,8 +362,8 @@ class AbstractEventLoop(metaclass=ABCMeta): async def create_datagram_endpoint( self, protocol_factory: _ProtocolFactory, - local_addr: Tuple[str, int] | None = ..., - remote_addr: Tuple[str, int] | None = ..., + local_addr: tuple[str, int] | None = ..., + remote_addr: tuple[str, int] | None = ..., *, family: int = ..., proto: int = ..., @@ -430,7 +430,7 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod async def sock_connect(self, sock: socket, address: _Address) -> None: ... @abstractmethod - async def sock_accept(self, sock: socket) -> Tuple[socket, _RetAddress]: ... + async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ... else: @abstractmethod def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ... @@ -439,7 +439,7 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod def sock_connect(self, sock: socket, address: _Address) -> Future[None]: ... @abstractmethod - def sock_accept(self, sock: socket) -> Future[Tuple[socket, _RetAddress]]: ... + def sock_accept(self, sock: socket) -> Future[tuple[socket, _RetAddress]]: ... # Signal handling. @abstractmethod def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ... diff --git a/mypy/typeshed/stdlib/asyncio/format_helpers.pyi b/mypy/typeshed/stdlib/asyncio/format_helpers.pyi index 29cb8839716e..be80efe266b1 100644 --- a/mypy/typeshed/stdlib/asyncio/format_helpers.pyi +++ b/mypy/typeshed/stdlib/asyncio/format_helpers.pyi @@ -2,7 +2,7 @@ import functools import sys import traceback from types import FrameType, FunctionType -from typing import Any, Iterable, Tuple, Union, overload +from typing import Any, Iterable, Union, overload class _HasWrapper: __wrapper__: _HasWrapper | FunctionType @@ -11,9 +11,9 @@ _FuncType = Union[FunctionType, _HasWrapper, functools.partial[Any], functools.p if sys.version_info >= (3, 7): @overload - def _get_function_source(func: _FuncType) -> Tuple[str, int]: ... + def _get_function_source(func: _FuncType) -> tuple[str, int]: ... @overload - def _get_function_source(func: object) -> Tuple[str, int] | None: ... + def _get_function_source(func: object) -> tuple[str, int] | None: ... def _format_callback_source(func: object, args: Iterable[Any]) -> str: ... def _format_args_and_kwargs(args: Iterable[Any], kwargs: dict[str, Any]) -> str: ... def _format_callback(func: object, args: Iterable[Any], kwargs: dict[str, Any], suffix: str = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/asyncio/futures.pyi b/mypy/typeshed/stdlib/asyncio/futures.pyi index 4942796b88ae..9788123f427e 100644 --- a/mypy/typeshed/stdlib/asyncio/futures.pyi +++ b/mypy/typeshed/stdlib/asyncio/futures.pyi @@ -1,6 +1,6 @@ import sys from concurrent.futures._base import Error, Future as _ConcurrentFuture -from typing import Any, Awaitable, Callable, Generator, Iterable, Tuple, TypeVar +from typing import Any, Awaitable, Callable, Generator, Iterable, TypeVar from .events import AbstractEventLoop @@ -38,7 +38,7 @@ class Future(Awaitable[_T], Iterable[_T]): def __del__(self) -> None: ... if sys.version_info >= (3, 7): def get_loop(self) -> AbstractEventLoop: ... - def _callbacks(self: _S) -> list[Tuple[Callable[[_S], Any], Context]]: ... + def _callbacks(self: _S) -> list[tuple[Callable[[_S], Any], Context]]: ... def add_done_callback(self: _S, __fn: Callable[[_S], Any], *, context: Context | None = ...) -> None: ... else: @property diff --git a/mypy/typeshed/stdlib/asyncio/protocols.pyi b/mypy/typeshed/stdlib/asyncio/protocols.pyi index ec8131b02e3d..aed6bbfb69ca 100644 --- a/mypy/typeshed/stdlib/asyncio/protocols.pyi +++ b/mypy/typeshed/stdlib/asyncio/protocols.pyi @@ -1,6 +1,5 @@ import sys from asyncio import transports -from typing import Tuple class BaseProtocol: def connection_made(self, transport: transports.BaseTransport) -> None: ... @@ -19,7 +18,7 @@ if sys.version_info >= (3, 7): class DatagramProtocol(BaseProtocol): def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore - def datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None: ... + def datagram_received(self, data: bytes, addr: tuple[str, int]) -> None: ... def error_received(self, exc: Exception) -> None: ... class SubprocessProtocol(BaseProtocol): diff --git a/mypy/typeshed/stdlib/asyncio/sslproto.pyi b/mypy/typeshed/stdlib/asyncio/sslproto.pyi index 9dda54cc84bb..54f2a74f9f5a 100644 --- a/mypy/typeshed/stdlib/asyncio/sslproto.pyi +++ b/mypy/typeshed/stdlib/asyncio/sslproto.pyi @@ -1,6 +1,6 @@ import ssl import sys -from typing import Any, Callable, ClassVar, Deque, Tuple +from typing import Any, Callable, ClassVar, Deque from typing_extensions import Literal from . import constants, events, futures, protocols, transports @@ -38,8 +38,8 @@ class _SSLPipe: def do_handshake(self, callback: Callable[[BaseException | None], None] | None = ...) -> list[bytes]: ... def shutdown(self, callback: Callable[[], None] | None = ...) -> list[bytes]: ... def feed_eof(self) -> None: ... - def feed_ssldata(self, data: bytes, only_handshake: bool = ...) -> Tuple[list[bytes], list[bytes]]: ... - def feed_appdata(self, data: bytes, offset: int = ...) -> Tuple[list[bytes], int]: ... + def feed_ssldata(self, data: bytes, only_handshake: bool = ...) -> tuple[list[bytes], list[bytes]]: ... + def feed_appdata(self, data: bytes, offset: int = ...) -> tuple[list[bytes], int]: ... class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): @@ -73,7 +73,7 @@ class SSLProtocol(protocols.Protocol): _server_hostname: str | None _sslcontext: ssl.SSLContext _extra: dict[str, Any] - _write_backlog: Deque[Tuple[bytes, int]] + _write_backlog: Deque[tuple[bytes, int]] _write_buffer_size: int _waiter: futures.Future[Any] _loop: events.AbstractEventLoop diff --git a/mypy/typeshed/stdlib/asyncio/staggered.pyi b/mypy/typeshed/stdlib/asyncio/staggered.pyi index 6ac405ab77fd..1d76d382555d 100644 --- a/mypy/typeshed/stdlib/asyncio/staggered.pyi +++ b/mypy/typeshed/stdlib/asyncio/staggered.pyi @@ -1,9 +1,9 @@ import sys -from typing import Any, Awaitable, Callable, Iterable, Tuple +from typing import Any, Awaitable, Callable, Iterable from . import events if sys.version_info >= (3, 8): async def staggered_race( coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = ... - ) -> Tuple[Any, int | None, list[Exception | None]]: ... + ) -> tuple[Any, int | None, list[Exception | None]]: ... diff --git a/mypy/typeshed/stdlib/asyncio/streams.pyi b/mypy/typeshed/stdlib/asyncio/streams.pyi index 6598110f87f9..595222280d58 100644 --- a/mypy/typeshed/stdlib/asyncio/streams.pyi +++ b/mypy/typeshed/stdlib/asyncio/streams.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple +from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional from . import events, protocols, transports from .base_events import Server @@ -24,7 +24,7 @@ async def open_connection( limit: int = ..., ssl_handshake_timeout: float | None = ..., **kwds: Any, -) -> Tuple[StreamReader, StreamWriter]: ... +) -> tuple[StreamReader, StreamWriter]: ... async def start_server( client_connected_cb: _ClientConnectedCallback, host: str | None = ..., @@ -43,7 +43,7 @@ if sys.platform != "win32": _PathType = str async def open_unix_connection( path: _PathType | None = ..., *, loop: events.AbstractEventLoop | None = ..., limit: int = ..., **kwds: Any - ) -> Tuple[StreamReader, StreamWriter]: ... + ) -> tuple[StreamReader, StreamWriter]: ... async def start_unix_server( client_connected_cb: _ClientConnectedCallback, path: _PathType | None = ..., diff --git a/mypy/typeshed/stdlib/asyncio/subprocess.pyi b/mypy/typeshed/stdlib/asyncio/subprocess.pyi index 428260af5465..d835c12af3d8 100644 --- a/mypy/typeshed/stdlib/asyncio/subprocess.pyi +++ b/mypy/typeshed/stdlib/asyncio/subprocess.pyi @@ -2,7 +2,7 @@ import subprocess import sys from _typeshed import StrOrBytesPath from asyncio import events, protocols, streams, transports -from typing import IO, Any, Callable, Tuple, Union +from typing import IO, Any, Callable, Union from typing_extensions import Literal if sys.version_info >= (3, 8): @@ -38,7 +38,7 @@ class Process: def send_signal(self, signal: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ... - async def communicate(self, input: bytes | None = ...) -> Tuple[bytes, bytes]: ... + async def communicate(self, input: bytes | None = ...) -> tuple[bytes, bytes]: ... if sys.version_info >= (3, 10): async def create_subprocess_shell( diff --git a/mypy/typeshed/stdlib/asyncio/tasks.pyi b/mypy/typeshed/stdlib/asyncio/tasks.pyi index 8cedc1ef0884..49f70e0db5c2 100644 --- a/mypy/typeshed/stdlib/asyncio/tasks.pyi +++ b/mypy/typeshed/stdlib/asyncio/tasks.pyi @@ -2,7 +2,7 @@ import concurrent.futures import sys from collections.abc import Awaitable, Generator, Iterable, Iterator from types import FrameType -from typing import Any, Generic, Optional, Set, TextIO, Tuple, TypeVar, Union, overload +from typing import Any, Generic, Optional, Set, TextIO, TypeVar, Union, overload from typing_extensions import Literal from .events import AbstractEventLoop @@ -47,11 +47,11 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No # typing PR #1550 for discussion. if sys.version_info >= (3, 10): @overload - def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: Literal[False] = ...) -> Future[Tuple[_T1]]: ... + def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, return_exceptions: Literal[False] = ... - ) -> Future[Tuple[_T1, _T2]]: ... + ) -> Future[tuple[_T1, _T2]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -59,7 +59,7 @@ if sys.version_info >= (3, 10): coro_or_future3: _FutureT[_T3], *, return_exceptions: Literal[False] = ..., - ) -> Future[Tuple[_T1, _T2, _T3]]: ... + ) -> Future[tuple[_T1, _T2, _T3]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -68,7 +68,7 @@ if sys.version_info >= (3, 10): coro_or_future4: _FutureT[_T4], *, return_exceptions: Literal[False] = ..., - ) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ... + ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -78,7 +78,7 @@ if sys.version_info >= (3, 10): coro_or_future5: _FutureT[_T5], *, return_exceptions: Literal[False] = ..., - ) -> Future[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... + ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload def gather( coro_or_future1: _FutureT[Any], @@ -91,11 +91,11 @@ if sys.version_info >= (3, 10): return_exceptions: bool = ..., ) -> Future[list[Any]]: ... @overload - def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: bool = ...) -> Future[Tuple[_T1 | BaseException]]: ... + def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: bool = ...) -> Future[tuple[_T1 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, return_exceptions: bool = ... - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException]]: ... + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -103,7 +103,7 @@ if sys.version_info >= (3, 10): coro_or_future3: _FutureT[_T3], *, return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -112,7 +112,7 @@ if sys.version_info >= (3, 10): coro_or_future4: _FutureT[_T4], *, return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -123,14 +123,14 @@ if sys.version_info >= (3, 10): *, return_exceptions: bool = ..., ) -> Future[ - Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] + tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] ]: ... else: @overload def gather( coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ... - ) -> Future[Tuple[_T1]]: ... + ) -> Future[tuple[_T1]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -138,7 +138,7 @@ else: *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ..., - ) -> Future[Tuple[_T1, _T2]]: ... + ) -> Future[tuple[_T1, _T2]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -147,7 +147,7 @@ else: *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ..., - ) -> Future[Tuple[_T1, _T2, _T3]]: ... + ) -> Future[tuple[_T1, _T2, _T3]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -157,7 +157,7 @@ else: *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ..., - ) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ... + ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -168,7 +168,7 @@ else: *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ..., - ) -> Future[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... + ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload def gather( coro_or_future1: _FutureT[Any], @@ -184,7 +184,7 @@ else: @overload def gather( coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ... - ) -> Future[Tuple[_T1 | BaseException]]: ... + ) -> Future[tuple[_T1 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -192,7 +192,7 @@ else: *, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException]]: ... + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -201,7 +201,7 @@ else: *, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -211,7 +211,7 @@ else: *, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -223,7 +223,7 @@ else: loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., ) -> Future[ - Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] + tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] ]: ... def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... @@ -232,22 +232,22 @@ if sys.version_info >= (3, 10): def shield(arg: _FutureT[_T]) -> Future[_T]: ... def sleep(delay: float, result: _T = ...) -> Future[_T]: ... @overload - def wait(fs: Iterable[_FT], *, timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore + def wait(fs: Iterable[_FT], *, timeout: float | None = ..., return_when: str = ...) -> Future[tuple[Set[_FT], Set[_FT]]]: ... # type: ignore @overload def wait( fs: Iterable[Awaitable[_T]], *, timeout: float | None = ..., return_when: str = ... - ) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ... + ) -> Future[tuple[Set[Task[_T]], Set[Task[_T]]]]: ... def wait_for(fut: _FutureT[_T], timeout: float | None) -> Future[_T]: ... else: def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... def sleep(delay: float, result: _T = ..., *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... @overload - def wait(fs: Iterable[_FT], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore + def wait(fs: Iterable[_FT], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...) -> Future[tuple[Set[_FT], Set[_FT]]]: ... # type: ignore @overload def wait( fs: Iterable[Awaitable[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ... - ) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ... + ) -> Future[tuple[Set[Task[_T]], Set[Task[_T]]]]: ... def wait_for(fut: _FutureT[_T], timeout: float | None, *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... class Task(Future[_T], Generic[_T]): diff --git a/mypy/typeshed/stdlib/asyncio/transports.pyi b/mypy/typeshed/stdlib/asyncio/transports.pyi index 51bf22b882b7..acca0e4c28b4 100644 --- a/mypy/typeshed/stdlib/asyncio/transports.pyi +++ b/mypy/typeshed/stdlib/asyncio/transports.pyi @@ -2,7 +2,7 @@ import sys from asyncio.events import AbstractEventLoop from asyncio.protocols import BaseProtocol from socket import _Address -from typing import Any, Mapping, Tuple +from typing import Any, Mapping class BaseTransport: def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ... @@ -43,4 +43,4 @@ class SubprocessTransport(BaseTransport): class _FlowControlMixin(Transport): def __init__(self, extra: Mapping[Any, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ... - def get_write_buffer_limits(self) -> Tuple[int, int]: ... + def get_write_buffer_limits(self) -> tuple[int, int]: ... diff --git a/mypy/typeshed/stdlib/asyncio/trsock.pyi b/mypy/typeshed/stdlib/asyncio/trsock.pyi index 16c65d5683f6..33ec5d67aaf9 100644 --- a/mypy/typeshed/stdlib/asyncio/trsock.pyi +++ b/mypy/typeshed/stdlib/asyncio/trsock.pyi @@ -34,14 +34,14 @@ if sys.version_info >= (3, 8): def getpeername(self) -> _RetAddress: ... def getsockname(self) -> _RetAddress: ... def getsockbyname(self) -> NoReturn: ... # This method doesn't exist on socket, yet is passed through? - def accept(self) -> Tuple[socket.socket, _RetAddress]: ... + def accept(self) -> tuple[socket.socket, _RetAddress]: ... def connect(self, address: _Address | bytes) -> None: ... def connect_ex(self, address: _Address | bytes) -> int: ... def bind(self, address: _Address | bytes) -> None: ... if sys.platform == "win32": - def ioctl(self, control: int, option: int | Tuple[int, int, int] | bool) -> None: ... + def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ... else: - def ioctl(self, control: int, option: int | Tuple[int, int, int] | bool) -> NoReturn: ... + def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ... def listen(self, __backlog: int = ...) -> None: ... def makefile(self) -> BinaryIO: ... def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ... @@ -70,12 +70,12 @@ if sys.version_info >= (3, 8): else: def share(self, process_id: int) -> NoReturn: ... def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ... - def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> Tuple[int, _RetAddress]: ... + def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ... def recvmsg_into( self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ..., __flags: int = ... - ) -> Tuple[int, list[_CMSG], int, Any]: ... - def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, list[_CMSG], int, Any]: ... - def recvfrom(self, bufsize: int, flags: int = ...) -> Tuple[bytes, _RetAddress]: ... + ) -> tuple[int, list[_CMSG], int, Any]: ... + def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> tuple[bytes, list[_CMSG], int, Any]: ... + def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ... def recv(self, bufsize: int, flags: int = ...) -> bytes: ... def settimeout(self, value: float | None) -> None: ... def gettimeout(self) -> float | None: ... diff --git a/mypy/typeshed/stdlib/asyncio/windows_events.pyi b/mypy/typeshed/stdlib/asyncio/windows_events.pyi index 19e456138394..f0a206a4e139 100644 --- a/mypy/typeshed/stdlib/asyncio/windows_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/windows_events.pyi @@ -1,7 +1,7 @@ import socket import sys from _typeshed import WriteableBuffer -from typing import IO, Any, Callable, ClassVar, NoReturn, Tuple, Type +from typing import IO, Any, Callable, ClassVar, NoReturn, Type from . import events, futures, proactor_events, selector_events, streams, windows_utils @@ -33,7 +33,7 @@ class ProactorEventLoop(proactor_events.BaseProactorEventLoop): def __init__(self, proactor: IocpProactor | None = ...) -> None: ... async def create_pipe_connection( self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str - ) -> Tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ... + ) -> tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ... async def start_serving_pipe( self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str ) -> list[PipeServer]: ... diff --git a/mypy/typeshed/stdlib/asyncio/windows_utils.pyi b/mypy/typeshed/stdlib/asyncio/windows_utils.pyi index f32ed3c80389..bf9cdde25a78 100644 --- a/mypy/typeshed/stdlib/asyncio/windows_utils.pyi +++ b/mypy/typeshed/stdlib/asyncio/windows_utils.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self from types import TracebackType -from typing import Callable, Protocol, Tuple, Type +from typing import Callable, Protocol, Type class _WarnFunction(Protocol): def __call__(self, message: str, category: Type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ...) -> None: ... @@ -10,7 +10,7 @@ BUFSIZE: int PIPE: int STDOUT: int -def pipe(*, duplex: bool = ..., overlapped: Tuple[bool, bool] = ..., bufsize: int = ...) -> Tuple[int, int]: ... +def pipe(*, duplex: bool = ..., overlapped: tuple[bool, bool] = ..., bufsize: int = ...) -> tuple[int, int]: ... class PipeHandle: def __init__(self, handle: int) -> None: ... diff --git a/mypy/typeshed/stdlib/asyncore.pyi b/mypy/typeshed/stdlib/asyncore.pyi index 146d91f807f2..e135221134a5 100644 --- a/mypy/typeshed/stdlib/asyncore.pyi +++ b/mypy/typeshed/stdlib/asyncore.pyi @@ -43,7 +43,7 @@ class dispatcher: def listen(self, num: int) -> 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 accept(self) -> tuple[_socket, Any] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... def close(self) -> None: ... @@ -68,7 +68,7 @@ class dispatcher_with_send(dispatcher): # incompatible signature: # def send(self, data: bytes) -> int | None: ... -def compact_traceback() -> Tuple[Tuple[str, str, str], type, type, str]: ... +def compact_traceback() -> tuple[tuple[str, str, str], type, type, str]: ... def close_all(map: _maptype | None = ..., ignore_all: bool = ...) -> None: ... if sys.platform != "win32": diff --git a/mypy/typeshed/stdlib/audioop.pyi b/mypy/typeshed/stdlib/audioop.pyi index 71671afe487e..321bfe55c4b0 100644 --- a/mypy/typeshed/stdlib/audioop.pyi +++ b/mypy/typeshed/stdlib/audioop.pyi @@ -6,7 +6,7 @@ RatecvState = Tuple[int, Tuple[Tuple[int, int], ...]] class error(Exception): ... def add(__fragment1: bytes, __fragment2: bytes, __width: int) -> bytes: ... -def adpcm2lin(__fragment: bytes, __width: int, __state: AdpcmState | None) -> Tuple[bytes, AdpcmState]: ... +def adpcm2lin(__fragment: bytes, __width: int, __state: AdpcmState | None) -> tuple[bytes, AdpcmState]: ... def alaw2lin(__fragment: bytes, __width: int) -> bytes: ... def avg(__fragment: bytes, __width: int) -> int: ... def avgpp(__fragment: bytes, __width: int) -> int: ... @@ -14,16 +14,16 @@ def bias(__fragment: bytes, __width: int, __bias: int) -> bytes: ... def byteswap(__fragment: bytes, __width: int) -> bytes: ... def cross(__fragment: bytes, __width: int) -> int: ... def findfactor(__fragment: bytes, __reference: bytes) -> float: ... -def findfit(__fragment: bytes, __reference: bytes) -> Tuple[int, float]: ... +def findfit(__fragment: bytes, __reference: bytes) -> tuple[int, float]: ... def findmax(__fragment: bytes, __length: int) -> int: ... def getsample(__fragment: bytes, __width: int, __index: int) -> int: ... -def lin2adpcm(__fragment: bytes, __width: int, __state: AdpcmState | None) -> Tuple[bytes, AdpcmState]: ... +def lin2adpcm(__fragment: bytes, __width: int, __state: AdpcmState | None) -> tuple[bytes, AdpcmState]: ... def lin2alaw(__fragment: bytes, __width: int) -> bytes: ... def lin2lin(__fragment: bytes, __width: int, __newwidth: int) -> bytes: ... def lin2ulaw(__fragment: bytes, __width: int) -> bytes: ... def max(__fragment: bytes, __width: int) -> int: ... def maxpp(__fragment: bytes, __width: int) -> int: ... -def minmax(__fragment: bytes, __width: int) -> Tuple[int, int]: ... +def minmax(__fragment: bytes, __width: int) -> tuple[int, int]: ... def mul(__fragment: bytes, __width: int, __factor: float) -> bytes: ... def ratecv( __fragment: bytes, @@ -34,7 +34,7 @@ def ratecv( __state: RatecvState | None, __weightA: int = ..., __weightB: int = ..., -) -> Tuple[bytes, RatecvState]: ... +) -> tuple[bytes, RatecvState]: ... def reverse(__fragment: bytes, __width: int) -> bytes: ... def rms(__fragment: bytes, __width: int) -> int: ... def tomono(__fragment: bytes, __width: int, __lfactor: float, __rfactor: float) -> bytes: ... diff --git a/mypy/typeshed/stdlib/bdb.pyi b/mypy/typeshed/stdlib/bdb.pyi index 34eb989573aa..068a3d44845e 100644 --- a/mypy/typeshed/stdlib/bdb.pyi +++ b/mypy/typeshed/stdlib/bdb.pyi @@ -56,7 +56,7 @@ class Bdb: def get_breaks(self, filename: str, lineno: int) -> list[Breakpoint]: ... def get_file_breaks(self, filename: str) -> list[Breakpoint]: ... def get_all_breaks(self) -> list[Breakpoint]: ... - def get_stack(self, f: FrameType | None, t: TracebackType | None) -> Tuple[list[Tuple[FrameType, int]], int]: ... + def get_stack(self, f: FrameType | None, t: TracebackType | None) -> tuple[list[tuple[FrameType, int]], int]: ... def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ... def run(self, cmd: str | CodeType, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... def runeval(self, expr: str, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... @@ -66,7 +66,7 @@ class Bdb: class Breakpoint: next: int - bplist: dict[Tuple[str, int], list[Breakpoint]] + bplist: dict[tuple[str, int], list[Breakpoint]] bpbynumber: list[Breakpoint | None] funcname: str | None @@ -90,5 +90,5 @@ class Breakpoint: def __str__(self) -> str: ... def checkfuncname(b: Breakpoint, frame: FrameType) -> bool: ... -def effective(file: str, line: int, frame: FrameType) -> Tuple[Breakpoint, bool] | Tuple[None, None]: ... +def effective(file: str, line: int, frame: FrameType) -> tuple[Breakpoint, bool] | tuple[None, None]: ... def set_trace() -> None: ... diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi index 75da5c830059..4694042cab24 100644 --- a/mypy/typeshed/stdlib/builtins.pyi +++ b/mypy/typeshed/stdlib/builtins.pyi @@ -178,7 +178,7 @@ class int: @overload def __new__(cls: Type[_T], x: str | bytes | bytearray, base: SupportsIndex) -> _T: ... if sys.version_info >= (3, 8): - def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ... + def as_integer_ratio(self) -> tuple[int, Literal[1]]: ... @property def real(self) -> int: ... @property @@ -202,14 +202,14 @@ class int: def __floordiv__(self, x: int) -> int: ... def __truediv__(self, x: int) -> float: ... def __mod__(self, x: int) -> int: ... - def __divmod__(self, x: int) -> Tuple[int, int]: ... + def __divmod__(self, x: int) -> tuple[int, int]: ... def __radd__(self, x: int) -> int: ... def __rsub__(self, x: int) -> int: ... def __rmul__(self, x: int) -> int: ... def __rfloordiv__(self, x: int) -> int: ... def __rtruediv__(self, x: int) -> float: ... def __rmod__(self, x: int) -> int: ... - def __rdivmod__(self, x: int) -> Tuple[int, int]: ... + def __rdivmod__(self, x: int) -> tuple[int, int]: ... @overload def __pow__(self, __x: Literal[2], __modulo: int | None = ...) -> int: ... @overload @@ -232,7 +232,7 @@ class int: def __ceil__(self) -> int: ... def __floor__(self) -> int: ... def __round__(self, ndigits: SupportsIndex = ...) -> int: ... - def __getnewargs__(self) -> Tuple[int]: ... + def __getnewargs__(self) -> tuple[int]: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: int) -> bool: ... @@ -249,7 +249,7 @@ class int: class float: def __new__(cls: Type[_T], x: SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> _T: ... - def as_integer_ratio(self) -> Tuple[int, int]: ... + def as_integer_ratio(self) -> tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @classmethod @@ -265,7 +265,7 @@ class float: def __floordiv__(self, x: float) -> float: ... def __truediv__(self, x: float) -> float: ... def __mod__(self, x: float) -> float: ... - def __divmod__(self, x: float) -> Tuple[float, float]: ... + def __divmod__(self, x: float) -> tuple[float, float]: ... def __pow__( self, x: float, mod: None = ... ) -> float: ... # In Python 3, returns complex if self is negative and x is not whole @@ -275,9 +275,9 @@ class float: def __rfloordiv__(self, x: float) -> float: ... def __rtruediv__(self, x: float) -> float: ... def __rmod__(self, x: float) -> float: ... - def __rdivmod__(self, x: float) -> Tuple[float, float]: ... + def __rdivmod__(self, x: float) -> tuple[float, float]: ... def __rpow__(self, x: float, mod: None = ...) -> float: ... - def __getnewargs__(self) -> Tuple[float]: ... + def __getnewargs__(self) -> tuple[float]: ... def __trunc__(self) -> int: ... if sys.version_info >= (3, 9): def __ceil__(self) -> int: ... @@ -371,7 +371,7 @@ class str(Sequence[str]): def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... def lower(self) -> str: ... def lstrip(self, __chars: str | None = ...) -> str: ... - def partition(self, __sep: str) -> Tuple[str, str, str]: ... + def partition(self, __sep: str) -> tuple[str, str, str]: ... def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ... if sys.version_info >= (3, 9): def removeprefix(self, __prefix: str) -> str: ... @@ -379,7 +379,7 @@ class str(Sequence[str]): def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... - def rpartition(self, __sep: str) -> Tuple[str, str, str]: ... + def rpartition(self, __sep: str) -> tuple[str, str, str]: ... def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... def rstrip(self, __chars: str | None = ...) -> str: ... def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... @@ -417,7 +417,7 @@ class str(Sequence[str]): def __repr__(self) -> str: ... def __rmul__(self, n: SupportsIndex) -> str: ... def __str__(self) -> str: ... - def __getnewargs__(self) -> Tuple[str]: ... + def __getnewargs__(self) -> tuple[str]: ... class bytes(ByteString): @overload @@ -466,7 +466,7 @@ class bytes(ByteString): def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... def lower(self) -> bytes: ... def lstrip(self, __bytes: bytes | None = ...) -> bytes: ... - def partition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... + def partition(self, __sep: bytes) -> tuple[bytes, bytes, bytes]: ... def replace(self, __old: bytes, __new: bytes, __count: SupportsIndex = ...) -> bytes: ... if sys.version_info >= (3, 9): def removeprefix(self, __prefix: bytes) -> bytes: ... @@ -478,7 +478,7 @@ class bytes(ByteString): self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def rjust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... - def rpartition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... + def rpartition(self, __sep: bytes) -> tuple[bytes, bytes, bytes]: ... def rsplit(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytes]: ... def rstrip(self, __bytes: bytes | None = ...) -> bytes: ... def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytes]: ... @@ -493,7 +493,7 @@ class bytes(ByteString): def upper(self) -> bytes: ... def zfill(self, __width: SupportsIndex) -> bytes: ... @classmethod - def fromhex(cls, __s: str) -> bytes: ... + def fromhex(cls: Type[_T], __s: str) -> _T: ... @staticmethod def maketrans(__frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ... @@ -517,7 +517,7 @@ class bytes(ByteString): def __le__(self, x: bytes) -> bool: ... def __gt__(self, x: bytes) -> bool: ... def __ge__(self, x: bytes) -> bool: ... - def __getnewargs__(self) -> Tuple[bytes]: ... + def __getnewargs__(self) -> tuple[bytes]: ... class bytearray(MutableSequence[int], ByteString): @overload @@ -568,7 +568,7 @@ class bytearray(MutableSequence[int], ByteString): def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ... def lower(self) -> bytearray: ... def lstrip(self, __bytes: bytes | None = ...) -> bytearray: ... - def partition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def partition(self, __sep: bytes) -> tuple[bytearray, bytearray, bytearray]: ... if sys.version_info >= (3, 9): def removeprefix(self, __prefix: bytes) -> bytearray: ... def removesuffix(self, __suffix: bytes) -> bytearray: ... @@ -580,7 +580,7 @@ class bytearray(MutableSequence[int], ByteString): self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def rjust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ... - def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def rpartition(self, __sep: bytes) -> tuple[bytearray, bytearray, bytearray]: ... def rsplit(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytearray]: ... def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytearray]: ... @@ -698,7 +698,7 @@ class bool(int): def __rxor__(self, x: bool) -> bool: ... @overload def __rxor__(self, x: int) -> int: ... - def __getnewargs__(self) -> Tuple[int]: ... + def __getnewargs__(self) -> tuple[int]: ... class slice(object): start: Any @@ -709,7 +709,7 @@ class slice(object): @overload def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ... __hash__: None # type: ignore - def indices(self, len: SupportsIndex) -> Tuple[int, int, int]: ... + def indices(self, len: SupportsIndex) -> tuple[int, int, int]: ... class tuple(Sequence[_T_co], Generic[_T_co]): def __new__(cls: Type[_T], iterable: Iterable[_T_co] = ...) -> _T: ... @@ -811,7 +811,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): @overload def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def __init__(self, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def __init__(self, iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... # Next overload is for dict(string.split(sep) for string in iterable) # Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error @overload @@ -819,12 +819,12 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def __new__(cls: Type[_T1], *args: Any, **kwargs: Any) -> _T1: ... def clear(self) -> None: ... def copy(self) -> dict[_KT, _VT]: ... - def popitem(self) -> Tuple[_KT, _VT]: ... + def popitem(self) -> tuple[_KT, _VT]: ... def setdefault(self, __key: _KT, __default: _VT = ...) -> _VT: ... @overload def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def update(self, __m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... @overload def update(self, **kwargs: _VT) -> None: ... def keys(self) -> _dict_keys[_KT, _VT]: ... @@ -917,8 +917,8 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]): 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]: ... + def __iter__(self) -> Iterator[tuple[int, _T]]: ... + def __next__(self) -> tuple[int, _T]: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -1155,7 +1155,7 @@ def min(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsLessThan], de @overload def next(__i: SupportsNext[_T]) -> _T: ... @overload -def next(__i: SupportsNext[_T], default: _VT) -> _T | _VT: ... +def next(__i: SupportsNext[_T], __default: _VT) -> _T | _VT: ... def oct(__number: int | SupportsIndex) -> str: ... _OpenFile = Union[StrOrBytesPath, int] @@ -1327,13 +1327,13 @@ def vars(__object: Any = ...) -> dict[str, Any]: ... class zip(Iterator[_T_co], Generic[_T_co]): if sys.version_info >= (3, 10): @overload - def __new__(cls, __iter1: Iterable[_T1], *, strict: bool = ...) -> zip[Tuple[_T1]]: ... + def __new__(cls, __iter1: Iterable[_T1], *, strict: bool = ...) -> zip[tuple[_T1]]: ... @overload - def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], *, strict: bool = ...) -> zip[Tuple[_T1, _T2]]: ... + def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], *, strict: bool = ...) -> zip[tuple[_T1, _T2]]: ... @overload def __new__( cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], *, strict: bool = ... - ) -> zip[Tuple[_T1, _T2, _T3]]: ... + ) -> zip[tuple[_T1, _T2, _T3]]: ... @overload def __new__( cls, @@ -1343,7 +1343,7 @@ class zip(Iterator[_T_co], Generic[_T_co]): __iter4: Iterable[_T4], *, strict: bool = ..., - ) -> zip[Tuple[_T1, _T2, _T3, _T4]]: ... + ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... @overload def __new__( cls, @@ -1354,7 +1354,7 @@ class zip(Iterator[_T_co], Generic[_T_co]): __iter5: Iterable[_T5], *, strict: bool = ..., - ) -> zip[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... + ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload def __new__( cls, @@ -1369,15 +1369,15 @@ class zip(Iterator[_T_co], Generic[_T_co]): ) -> zip[Tuple[Any, ...]]: ... else: @overload - def __new__(cls, __iter1: Iterable[_T1]) -> zip[Tuple[_T1]]: ... + def __new__(cls, __iter1: Iterable[_T1]) -> zip[tuple[_T1]]: ... @overload - def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> zip[Tuple[_T1, _T2]]: ... + def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> zip[tuple[_T1, _T2]]: ... @overload - def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> zip[Tuple[_T1, _T2, _T3]]: ... + def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> zip[tuple[_T1, _T2, _T3]]: ... @overload def __new__( cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4] - ) -> zip[Tuple[_T1, _T2, _T3, _T4]]: ... + ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... @overload def __new__( cls, @@ -1386,7 +1386,7 @@ class zip(Iterator[_T_co], Generic[_T_co]): __iter3: Iterable[_T3], __iter4: Iterable[_T4], __iter5: Iterable[_T5], - ) -> zip[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... + ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload def __new__( cls, diff --git a/mypy/typeshed/stdlib/calendar.pyi b/mypy/typeshed/stdlib/calendar.pyi index 9d701a788a80..26073fb7281b 100644 --- a/mypy/typeshed/stdlib/calendar.pyi +++ b/mypy/typeshed/stdlib/calendar.pyi @@ -16,7 +16,7 @@ class IllegalWeekdayError(ValueError): def isleap(year: int) -> bool: ... def leapdays(y1: int, y2: int) -> int: ... def weekday(year: int, month: int, day: int) -> int: ... -def monthrange(year: int, month: int) -> Tuple[int, int]: ... +def monthrange(year: int, month: int) -> tuple[int, int]: ... class Calendar: firstweekday: int @@ -25,17 +25,17 @@ class Calendar: def setfirstweekday(self, firstweekday: int) -> None: ... def iterweekdays(self) -> Iterable[int]: ... def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ... - def itermonthdays2(self, year: int, month: int) -> Iterable[Tuple[int, int]]: ... + def itermonthdays2(self, year: int, month: int) -> Iterable[tuple[int, int]]: ... def itermonthdays(self, year: int, month: int) -> Iterable[int]: ... def monthdatescalendar(self, year: int, month: int) -> list[list[datetime.date]]: ... - def monthdays2calendar(self, year: int, month: int) -> list[list[Tuple[int, int]]]: ... + def monthdays2calendar(self, year: int, month: int) -> list[list[tuple[int, int]]]: ... def monthdayscalendar(self, year: int, month: int) -> list[list[int]]: ... def yeardatescalendar(self, year: int, width: int = ...) -> list[list[int]]: ... - def yeardays2calendar(self, year: int, width: int = ...) -> list[list[Tuple[int, int]]]: ... + def yeardays2calendar(self, year: int, width: int = ...) -> list[list[tuple[int, int]]]: ... def yeardayscalendar(self, year: int, width: int = ...) -> list[list[int]]: ... if sys.version_info >= (3, 7): - def itermonthdays3(self, year: int, month: int) -> Iterable[Tuple[int, int, int]]: ... - def itermonthdays4(self, year: int, month: int) -> Iterable[Tuple[int, int, int, int]]: ... + def itermonthdays3(self, year: int, month: int) -> Iterable[tuple[int, int, int]]: ... + def itermonthdays4(self, year: int, month: int) -> Iterable[tuple[int, int, int, int]]: ... class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... diff --git a/mypy/typeshed/stdlib/cgitb.pyi b/mypy/typeshed/stdlib/cgitb.pyi index 90226dc134e8..7576740fc1c0 100644 --- a/mypy/typeshed/stdlib/cgitb.pyi +++ b/mypy/typeshed/stdlib/cgitb.pyi @@ -8,10 +8,10 @@ def reset() -> str: ... # undocumented def small(text: str) -> str: ... # undocumented def strong(text: str) -> str: ... # undocumented def grey(text: str) -> str: ... # undocumented -def lookup(name: str, frame: FrameType, locals: dict[str, Any]) -> Tuple[str | None, Any]: ... # undocumented +def lookup(name: str, frame: FrameType, locals: dict[str, Any]) -> tuple[str | None, Any]: ... # undocumented def scanvars( reader: Callable[[], bytes], frame: FrameType, locals: dict[str, Any] -) -> list[Tuple[str, str | None, Any]]: ... # undocumented +) -> list[tuple[str, str | None, Any]]: ... # undocumented def html(einfo: _ExcInfo, context: int = ...) -> str: ... def text(einfo: _ExcInfo, context: int = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/cmath.pyi b/mypy/typeshed/stdlib/cmath.pyi index 8d67e6c47bb4..3f3327074579 100644 --- a/mypy/typeshed/stdlib/cmath.pyi +++ b/mypy/typeshed/stdlib/cmath.pyi @@ -1,4 +1,4 @@ -from typing import SupportsComplex, SupportsFloat, Tuple, Union +from typing import SupportsComplex, SupportsFloat, Union e: float pi: float @@ -25,7 +25,7 @@ def isnan(__z: _C) -> bool: ... def log(__x: _C, __y_obj: _C = ...) -> complex: ... def log10(__z: _C) -> complex: ... def phase(__z: _C) -> float: ... -def polar(__z: _C) -> Tuple[float, float]: ... +def polar(__z: _C) -> tuple[float, float]: ... def rect(__r: float, __phi: float) -> complex: ... def sin(__z: _C) -> complex: ... def sinh(__z: _C) -> complex: ... diff --git a/mypy/typeshed/stdlib/cmd.pyi b/mypy/typeshed/stdlib/cmd.pyi index 9f2593d3bfdf..f6d818591a4e 100644 --- a/mypy/typeshed/stdlib/cmd.pyi +++ b/mypy/typeshed/stdlib/cmd.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Tuple +from typing import IO, Any, Callable class Cmd: prompt: str @@ -23,7 +23,7 @@ class Cmd: def postcmd(self, stop: bool, line: str) -> bool: ... def preloop(self) -> None: ... def postloop(self) -> None: ... - def parseline(self, line: str) -> Tuple[str | None, str | None, str]: ... + def parseline(self, line: str) -> tuple[str | None, str | None, str]: ... def onecmd(self, line: str) -> bool: ... def emptyline(self) -> bool: ... def default(self, line: str) -> bool: ... diff --git a/mypy/typeshed/stdlib/codecs.pyi b/mypy/typeshed/stdlib/codecs.pyi index 9f27cfebf099..ebd6911c3e63 100644 --- a/mypy/typeshed/stdlib/codecs.pyi +++ b/mypy/typeshed/stdlib/codecs.pyi @@ -12,10 +12,10 @@ from typing_extensions import Literal # They are much more common in Python 2 than in Python 3. class _Encoder(Protocol): - def __call__(self, input: str, errors: str = ...) -> Tuple[bytes, int]: ... # signature of Codec().encode + def __call__(self, input: str, errors: str = ...) -> tuple[bytes, int]: ... # signature of Codec().encode class _Decoder(Protocol): - def __call__(self, input: bytes, errors: str = ...) -> Tuple[str, int]: ... # signature of Codec().decode + def __call__(self, input: bytes, errors: str = ...) -> tuple[str, int]: ... # signature of Codec().decode class _StreamReader(Protocol): def __call__(self, stream: IO[bytes], errors: str = ...) -> StreamReader: ... @@ -63,8 +63,8 @@ def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = . @overload def decode(obj: bytes, encoding: str = ..., errors: str = ...) -> str: ... 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 +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]): @property @@ -124,19 +124,19 @@ BOM_UTF32_LE: bytes # It is expected that different actions be taken depending on which of the # three subclasses of `UnicodeError` is actually ...ed. However, the Union # is still needed for at least one of the cases. -def register_error(__errors: str, __handler: Callable[[UnicodeError], Tuple[str | bytes, int]]) -> None: ... -def lookup_error(__name: str) -> Callable[[UnicodeError], Tuple[str | bytes, int]]: ... -def strict_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... -def replace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... -def ignore_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... -def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... -def backslashreplace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def register_error(__errors: str, __handler: Callable[[UnicodeError], tuple[str | bytes, int]]) -> None: ... +def lookup_error(__name: str) -> Callable[[UnicodeError], tuple[str | bytes, int]]: ... +def strict_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... +def replace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... +def ignore_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... +def xmlcharrefreplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... +def backslashreplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... class Codec: # These are sort of @abstractmethod but sort of not. # The StreamReader and StreamWriter subclasses only implement one. - def encode(self, input: str, errors: str = ...) -> Tuple[bytes, int]: ... - def decode(self, input: bytes, errors: str = ...) -> Tuple[str, int]: ... + def encode(self, input: str, errors: str = ...) -> tuple[bytes, int]: ... + def decode(self, input: bytes, errors: str = ...) -> tuple[str, int]: ... class IncrementalEncoder: errors: str @@ -154,8 +154,8 @@ class IncrementalDecoder: @abstractmethod def decode(self, input: bytes, final: bool = ...) -> str: ... def reset(self) -> None: ... - def getstate(self) -> Tuple[bytes, int]: ... - def setstate(self, state: Tuple[bytes, int]) -> None: ... + def getstate(self) -> tuple[bytes, int]: ... + def setstate(self, state: tuple[bytes, int]) -> None: ... # These are not documented but used in encodings/*.py implementations. class BufferedIncrementalEncoder(IncrementalEncoder): @@ -169,7 +169,7 @@ class BufferedIncrementalDecoder(IncrementalDecoder): buffer: bytes def __init__(self, errors: str = ...) -> None: ... @abstractmethod - def _buffer_decode(self, input: bytes, errors: str, final: bool) -> Tuple[str, int]: ... + def _buffer_decode(self, input: bytes, errors: str, final: bool) -> tuple[str, int]: ... def decode(self, input: bytes, final: bool = ...) -> str: ... # TODO: it is not possible to specify the requirement that all other diff --git a/mypy/typeshed/stdlib/collections/__init__.pyi b/mypy/typeshed/stdlib/collections/__init__.pyi index 2aa0bf76d501..8802a255e471 100644 --- a/mypy/typeshed/stdlib/collections/__init__.pyi +++ b/mypy/typeshed/stdlib/collections/__init__.pyi @@ -86,7 +86,7 @@ class UserString(Sequence[str]): def __int__(self) -> int: ... def __float__(self) -> float: ... def __complex__(self) -> complex: ... - def __getnewargs__(self) -> Tuple[str]: ... + def __getnewargs__(self) -> tuple[str]: ... def __lt__(self, string: str | UserString) -> bool: ... def __le__(self, string: str | UserString) -> bool: ... def __gt__(self, string: str | UserString) -> bool: ... @@ -135,7 +135,7 @@ class UserString(Sequence[str]): @staticmethod @overload def maketrans(x: str, y: str, z: str = ...) -> dict[int, int | None]: ... - def partition(self, sep: str) -> Tuple[str, str, str]: ... + def partition(self, sep: str) -> tuple[str, str, str]: ... if sys.version_info >= (3, 9): def removeprefix(self: _UserStringT, __prefix: str | UserString) -> _UserStringT: ... def removesuffix(self: _UserStringT, __suffix: str | UserString) -> _UserStringT: ... @@ -143,7 +143,7 @@ class UserString(Sequence[str]): def rfind(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def rindex(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def rjust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... - def rpartition(self, sep: str) -> Tuple[str, str, str]: ... + def rpartition(self, sep: str) -> tuple[str, str, str]: ... def rstrip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ... def split(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... @@ -207,7 +207,7 @@ class Counter(Dict[_T, int], Generic[_T]): def __init__(self, __iterable: Iterable[_T]) -> None: ... def copy(self: _S) -> _S: ... def elements(self) -> Iterator[_T]: ... - def most_common(self, n: int | None = ...) -> list[Tuple[_T, int]]: ... + def most_common(self, n: int | None = ...) -> list[tuple[_T, int]]: ... @classmethod def fromkeys(cls, iterable: Any, v: int | None = ...) -> NoReturn: ... # type: ignore @overload @@ -224,7 +224,7 @@ class Counter(Dict[_T, int], Generic[_T]): @overload def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ... @overload - def update(self, __m: Iterable[_T] | Iterable[Tuple[_T, int]], **kwargs: int) -> None: ... + def update(self, __m: Iterable[_T] | Iterable[tuple[_T, int]], **kwargs: int) -> None: ... @overload def update(self, __m: None = ..., **kwargs: int) -> None: ... def __add__(self, other: Counter[_T]) -> Counter[_T]: ... @@ -242,7 +242,7 @@ class _OrderedDictKeysView(_dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): def __reversed__(self) -> Iterator[_KT_co]: ... class _OrderedDictItemsView(_dict_items[_KT_co, _VT_co], Reversible[Tuple[_KT_co, _VT_co]]): - def __reversed__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... + def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... # The generics are the wrong way around because of a mypy limitation # https://github.com/python/mypy/issues/11138 @@ -250,7 +250,7 @@ class _OrderedDictValuesView(_dict_values[_VT_co, _KT_co], Reversible[_VT_co], G def __reversed__(self) -> Iterator[_VT_co]: ... class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): - def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ... + def popitem(self, last: bool = ...) -> tuple[_KT, _VT]: ... def move_to_end(self, key: _KT, last: bool = ...) -> None: ... def copy(self: _S) -> _S: ... def __reversed__(self) -> Iterator[_KT]: ... @@ -271,9 +271,9 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): @overload def __init__(self, default_factory: Callable[[], _VT] | None, map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[tuple[_KT, _VT]]) -> None: ... @overload - def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... def __missing__(self, key: _KT) -> _VT: ... # TODO __reversed__ def copy(self: _S) -> _S: ... diff --git a/mypy/typeshed/stdlib/colorsys.pyi b/mypy/typeshed/stdlib/colorsys.pyi index 8db2e2c9ab3a..00c5f9d22cb1 100644 --- a/mypy/typeshed/stdlib/colorsys.pyi +++ b/mypy/typeshed/stdlib/colorsys.pyi @@ -1,11 +1,9 @@ -from typing import Tuple - -def rgb_to_yiq(r: float, g: float, b: float) -> Tuple[float, float, float]: ... -def yiq_to_rgb(y: float, i: float, q: float) -> Tuple[float, float, float]: ... -def rgb_to_hls(r: float, g: float, b: float) -> Tuple[float, float, float]: ... -def hls_to_rgb(h: float, l: float, s: float) -> Tuple[float, float, float]: ... -def rgb_to_hsv(r: float, g: float, b: float) -> Tuple[float, float, float]: ... -def hsv_to_rgb(h: float, s: float, v: float) -> Tuple[float, float, float]: ... +def rgb_to_yiq(r: float, g: float, b: float) -> tuple[float, float, float]: ... +def yiq_to_rgb(y: float, i: float, q: float) -> tuple[float, float, float]: ... +def rgb_to_hls(r: float, g: float, b: float) -> tuple[float, float, float]: ... +def hls_to_rgb(h: float, l: float, s: float) -> tuple[float, float, float]: ... +def rgb_to_hsv(r: float, g: float, b: float) -> tuple[float, float, float]: ... +def hsv_to_rgb(h: float, s: float, v: float) -> tuple[float, float, float]: ... # TODO undocumented ONE_SIXTH: float diff --git a/mypy/typeshed/stdlib/concurrent/futures/process.pyi b/mypy/typeshed/stdlib/concurrent/futures/process.pyi index 4ae791361bb1..cc48f48f0023 100644 --- a/mypy/typeshed/stdlib/concurrent/futures/process.pyi +++ b/mypy/typeshed/stdlib/concurrent/futures/process.pyi @@ -85,7 +85,7 @@ if sys.version_info >= (3, 7): def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> 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 _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 = ... ) -> None: ... diff --git a/mypy/typeshed/stdlib/configparser.pyi b/mypy/typeshed/stdlib/configparser.pyi index c278b82a6823..a0efa30416dd 100644 --- a/mypy/typeshed/stdlib/configparser.pyi +++ b/mypy/typeshed/stdlib/configparser.pyi @@ -1,7 +1,7 @@ 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, Tuple, Type, TypeVar, overload +from typing import Any, ClassVar, Dict, Optional, Pattern, Type, TypeVar, overload from typing_extensions import Literal # Internal type aliases @@ -220,7 +220,7 @@ class InterpolationSyntaxError(InterpolationError): ... class ParsingError(Error): source: str - errors: list[Tuple[int, str]] + errors: list[tuple[int, str]] def __init__(self, source: str | None = ..., filename: str | None = ...) -> None: ... def append(self, lineno: int, line: str) -> None: ... diff --git a/mypy/typeshed/stdlib/ctypes/__init__.pyi b/mypy/typeshed/stdlib/ctypes/__init__.pyi index 696705833547..4b3dd4b15b51 100644 --- a/mypy/typeshed/stdlib/ctypes/__init__.pyi +++ b/mypy/typeshed/stdlib/ctypes/__init__.pyi @@ -109,7 +109,7 @@ 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 __call__(self, *args: Any, **kwargs: Any) -> Any: ... @@ -252,7 +252,7 @@ class _CField: size: int class _StructUnionMeta(_CDataMeta): - _fields_: Sequence[Tuple[str, Type[_CData]] | Tuple[str, Type[_CData], int]] + _fields_: Sequence[tuple[str, Type[_CData]] | tuple[str, Type[_CData], int]] _pack_: int _anonymous_: Sequence[str] def __getattr__(self, name: str) -> _CField: ... diff --git a/mypy/typeshed/stdlib/dataclasses.pyi b/mypy/typeshed/stdlib/dataclasses.pyi index b6b76af979f9..59efbe77aed6 100644 --- a/mypy/typeshed/stdlib/dataclasses.pyi +++ b/mypy/typeshed/stdlib/dataclasses.pyi @@ -19,7 +19,7 @@ if sys.version_info >= (3, 10): @overload def asdict(obj: Any) -> dict[str, Any]: ... @overload -def asdict(obj: Any, *, dict_factory: Callable[[list[Tuple[str, Any]]], _T]) -> _T: ... +def asdict(obj: Any, *, dict_factory: Callable[[list[tuple[str, Any]]], _T]) -> _T: ... @overload def astuple(obj: Any) -> Tuple[Any, ...]: ... @overload @@ -190,7 +190,7 @@ class InitVar(Generic[_T]): if sys.version_info >= (3, 10): def make_dataclass( cls_name: str, - fields: Iterable[str | Tuple[str, type] | Tuple[str, type, Field[Any]]], + fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, bases: Tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., @@ -207,7 +207,7 @@ if sys.version_info >= (3, 10): else: def make_dataclass( cls_name: str, - fields: Iterable[str | Tuple[str, type] | Tuple[str, type, Field[Any]]], + fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, bases: Tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., diff --git a/mypy/typeshed/stdlib/datetime.pyi b/mypy/typeshed/stdlib/datetime.pyi index 22782d9d46e4..746643d8433c 100644 --- a/mypy/typeshed/stdlib/datetime.pyi +++ b/mypy/typeshed/stdlib/datetime.pyi @@ -1,6 +1,6 @@ import sys from time import struct_time -from typing import ClassVar, NamedTuple, SupportsAbs, Tuple, Type, TypeVar, overload +from typing import ClassVar, NamedTuple, SupportsAbs, Type, TypeVar, overload _S = TypeVar("_S") @@ -79,7 +79,7 @@ class date: if sys.version_info >= (3, 9): def isocalendar(self) -> _IsoCalendarDate: ... else: - def isocalendar(self) -> Tuple[int, int, int]: ... + def isocalendar(self) -> tuple[int, int, int]: ... class time: min: ClassVar[time] @@ -174,7 +174,7 @@ class timedelta(SupportsAbs[timedelta]): @overload def __truediv__(self, other: float) -> timedelta: ... def __mod__(self, other: timedelta) -> timedelta: ... - def __divmod__(self, other: timedelta) -> Tuple[int, timedelta]: ... + def __divmod__(self, other: timedelta) -> tuple[int, timedelta]: ... def __le__(self, other: timedelta) -> bool: ... def __lt__(self, other: timedelta) -> bool: ... def __ge__(self, other: timedelta) -> bool: ... @@ -295,4 +295,4 @@ class datetime(date): if sys.version_info >= (3, 9): def isocalendar(self) -> _IsoCalendarDate: ... else: - def isocalendar(self) -> Tuple[int, int, int]: ... + def isocalendar(self) -> tuple[int, int, int]: ... diff --git a/mypy/typeshed/stdlib/decimal.pyi b/mypy/typeshed/stdlib/decimal.pyi index a21ec92a3d65..f08ed02d6482 100644 --- a/mypy/typeshed/stdlib/decimal.pyi +++ b/mypy/typeshed/stdlib/decimal.pyi @@ -54,11 +54,11 @@ class Decimal(object): def compare(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def __hash__(self) -> int: ... def as_tuple(self) -> DecimalTuple: ... - def as_integer_ratio(self) -> Tuple[int, int]: ... + def as_integer_ratio(self) -> tuple[int, int]: ... def to_eng_string(self, context: Context | None = ...) -> str: ... def __abs__(self) -> Decimal: ... def __add__(self, other: _Decimal) -> Decimal: ... - def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... + def __divmod__(self, other: _Decimal) -> tuple[Decimal, Decimal]: ... def __eq__(self, other: object) -> bool: ... def __floordiv__(self, other: _Decimal) -> Decimal: ... def __ge__(self, other: _ComparableNum) -> bool: ... @@ -71,7 +71,7 @@ class Decimal(object): def __pos__(self) -> Decimal: ... def __pow__(self, other: _Decimal, modulo: _Decimal | None = ...) -> Decimal: ... def __radd__(self, other: _Decimal) -> Decimal: ... - def __rdivmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... + def __rdivmod__(self, other: _Decimal) -> tuple[Decimal, Decimal]: ... def __rfloordiv__(self, other: _Decimal) -> Decimal: ... def __rmod__(self, other: _Decimal) -> Decimal: ... def __rmul__(self, other: _Decimal) -> Decimal: ... @@ -143,7 +143,7 @@ class Decimal(object): def rotate(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def scaleb(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def shift(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __reduce__(self) -> Tuple[Type[Decimal], Tuple[str]]: ... + def __reduce__(self) -> tuple[Type[Decimal], tuple[str]]: ... def __copy__(self) -> Decimal: ... def __deepcopy__(self, memo: Any) -> Decimal: ... def __format__(self, specifier: str, context: Context | None = ...) -> str: ... @@ -181,7 +181,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: ... @@ -204,7 +204,7 @@ class Context(object): def copy_sign(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... def divide(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... def divide_int(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def divmod(self, __x: _Decimal, __y: _Decimal) -> Tuple[Decimal, Decimal]: ... + def divmod(self, __x: _Decimal, __y: _Decimal) -> tuple[Decimal, Decimal]: ... def exp(self, __x: _Decimal) -> Decimal: ... def fma(self, __x: _Decimal, __y: _Decimal, __z: _Decimal) -> Decimal: ... def is_canonical(self, __x: _Decimal) -> bool: ... diff --git a/mypy/typeshed/stdlib/difflib.pyi b/mypy/typeshed/stdlib/difflib.pyi index 5db947293e42..7c4ae8e2f246 100644 --- a/mypy/typeshed/stdlib/difflib.pyi +++ b/mypy/typeshed/stdlib/difflib.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, AnyStr, Callable, Generic, Iterable, Iterator, NamedTuple, Sequence, Tuple, TypeVar, Union, overload +from typing import Any, AnyStr, Callable, Generic, Iterable, Iterator, NamedTuple, Sequence, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -24,8 +24,8 @@ class SequenceMatcher(Generic[_T]): else: def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ... def get_matching_blocks(self) -> list[Match]: ... - def get_opcodes(self) -> list[Tuple[str, int, int, int, int]]: ... - def get_grouped_opcodes(self, n: int = ...) -> Iterable[list[Tuple[str, int, int, int, int]]]: ... + def get_opcodes(self) -> list[tuple[str, int, int, int, int]]: ... + def get_grouped_opcodes(self, n: int = ...) -> Iterable[list[tuple[str, int, int, int, int]]]: ... def ratio(self) -> float: ... def quick_ratio(self) -> float: ... def real_quick_ratio(self) -> float: ... diff --git a/mypy/typeshed/stdlib/dis.pyi b/mypy/typeshed/stdlib/dis.pyi index d9e3c7213c84..a6ea3e950b95 100644 --- a/mypy/typeshed/stdlib/dis.pyi +++ b/mypy/typeshed/stdlib/dis.pyi @@ -16,7 +16,7 @@ from opcode import ( opname as opname, stack_effect as stack_effect, ) -from typing import IO, Any, Callable, Iterator, NamedTuple, Tuple, Union +from typing import IO, Any, Callable, Iterator, NamedTuple, Union # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) @@ -47,7 +47,7 @@ class Bytecode: COMPILER_FLAG_NAMES: dict[int, str] def findlabels(code: _have_code) -> list[int]: ... -def findlinestarts(code: _have_code) -> Iterator[Tuple[int, int]]: ... +def findlinestarts(code: _have_code) -> Iterator[tuple[int, int]]: ... def pretty_flags(flags: int) -> str: ... def code_info(x: _have_code_or_string) -> str: ... diff --git a/mypy/typeshed/stdlib/distutils/cmd.pyi b/mypy/typeshed/stdlib/distutils/cmd.pyi index dd2e1905adf5..875e851bed39 100644 --- a/mypy/typeshed/stdlib/distutils/cmd.pyi +++ b/mypy/typeshed/stdlib/distutils/cmd.pyi @@ -1,9 +1,9 @@ from abc import abstractmethod from distutils.dist import Distribution -from typing import Any, Callable, Iterable, Tuple +from typing import Any, Callable, Iterable class Command: - sub_commands: list[Tuple[str, Callable[[Command], bool] | None]] + sub_commands: list[tuple[str, Callable[[Command], bool] | None]] def __init__(self, dist: Distribution) -> None: ... @abstractmethod def initialize_options(self) -> None: ... @@ -18,7 +18,7 @@ class Command: def ensure_filename(self, option: str) -> None: ... def ensure_dirname(self, option: str) -> None: ... def get_command_name(self) -> str: ... - def set_undefined_options(self, src_cmd: str, *option_pairs: Tuple[str, str]) -> None: ... + def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ... def get_finalized_command(self, command: str, create: int = ...) -> Command: ... def reinitialize_command(self, command: Command | str, reinit_subcommands: int = ...) -> Command: ... def run_command(self, command: str) -> None: ... @@ -34,7 +34,7 @@ class Command: preserve_times: int = ..., link: str | None = ..., level: Any = ..., - ) -> Tuple[str, bool]: ... # level is not used + ) -> tuple[str, bool]: ... # level is not used def copy_tree( self, infile: str, @@ -57,7 +57,7 @@ class Command: ) -> str: ... def make_file( self, - infiles: str | list[str] | Tuple[str], + infiles: str | list[str] | tuple[str], outfile: str, func: Callable[..., Any], args: list[Any], diff --git a/mypy/typeshed/stdlib/distutils/core.pyi b/mypy/typeshed/stdlib/distutils/core.pyi index dc0870895cf9..fc4cd81c4752 100644 --- a/mypy/typeshed/stdlib/distutils/core.pyi +++ b/mypy/typeshed/stdlib/distutils/core.pyi @@ -1,7 +1,7 @@ from distutils.cmd import Command as Command from distutils.dist import Distribution as Distribution from distutils.extension import Extension as Extension -from typing import Any, Mapping, Tuple, Type +from typing import Any, Mapping, Type def setup( *, @@ -28,13 +28,13 @@ def setup( keywords: list[str] | str = ..., platforms: list[str] | str = ..., cmdclass: Mapping[str, Type[Command]] = ..., - data_files: list[Tuple[str, list[str]]] = ..., + data_files: list[tuple[str, list[str]]] = ..., package_dir: Mapping[str, str] = ..., obsoletes: list[str] = ..., provides: list[str] = ..., requires: list[str] = ..., command_packages: list[str] = ..., - command_options: Mapping[str, Mapping[str, Tuple[Any, Any]]] = ..., + command_options: Mapping[str, Mapping[str, tuple[Any, Any]]] = ..., package_data: Mapping[str, list[str]] = ..., include_package_data: bool = ..., libraries: list[str] = ..., diff --git a/mypy/typeshed/stdlib/distutils/dep_util.pyi b/mypy/typeshed/stdlib/distutils/dep_util.pyi index 595dcb80a38c..929d6ffd0c81 100644 --- a/mypy/typeshed/stdlib/distutils/dep_util.pyi +++ b/mypy/typeshed/stdlib/distutils/dep_util.pyi @@ -1,5 +1,3 @@ -from typing import Tuple - def newer(source: str, target: str) -> bool: ... -def newer_pairwise(sources: list[str], targets: list[str]) -> list[Tuple[str, str]]: ... +def newer_pairwise(sources: list[str], targets: list[str]) -> list[tuple[str, str]]: ... def newer_group(sources: list[str], target: str, missing: str = ...) -> bool: ... diff --git a/mypy/typeshed/stdlib/distutils/dist.pyi b/mypy/typeshed/stdlib/distutils/dist.pyi index ca3f108ab681..5bb04b049995 100644 --- a/mypy/typeshed/stdlib/distutils/dist.pyi +++ b/mypy/typeshed/stdlib/distutils/dist.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath, SupportsWrite from distutils.cmd import Command -from typing import IO, Any, Iterable, Mapping, Tuple, Type +from typing import IO, Any, Iterable, Mapping, Type class DistributionMetadata: def __init__(self, path: int | StrOrBytesPath | None = ...) -> None: ... @@ -53,6 +53,6 @@ class Distribution: cmdclass: dict[str, Type[Command]] metadata: DistributionMetadata def __init__(self, attrs: Mapping[str, Any] | None = ...) -> None: ... - def get_option_dict(self, command: str) -> dict[str, Tuple[str, str]]: ... + def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... def parse_config_files(self, filenames: Iterable[str] | None = ...) -> None: ... def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... diff --git a/mypy/typeshed/stdlib/distutils/extension.pyi b/mypy/typeshed/stdlib/distutils/extension.pyi index 0941a402e604..655ea1e9e347 100644 --- a/mypy/typeshed/stdlib/distutils/extension.pyi +++ b/mypy/typeshed/stdlib/distutils/extension.pyi @@ -1,12 +1,10 @@ -from typing import Tuple - class Extension: def __init__( self, name: str, sources: list[str], include_dirs: list[str] | None = ..., - define_macros: list[Tuple[str, str | None]] | None = ..., + define_macros: list[tuple[str, str | None]] | None = ..., undef_macros: list[str] | None = ..., library_dirs: list[str] | None = ..., libraries: list[str] | None = ..., diff --git a/mypy/typeshed/stdlib/distutils/fancy_getopt.pyi b/mypy/typeshed/stdlib/distutils/fancy_getopt.pyi index a2c24187a498..06a0847e4687 100644 --- a/mypy/typeshed/stdlib/distutils/fancy_getopt.pyi +++ b/mypy/typeshed/stdlib/distutils/fancy_getopt.pyi @@ -15,7 +15,7 @@ class FancyGetopt: def getopt(self, args: list[str] | None = ...) -> _GR: ... @overload def getopt(self, args: list[str] | None, object: Any) -> list[str]: ... - def get_option_order(self) -> list[Tuple[str, str]]: ... + def get_option_order(self) -> list[tuple[str, str]]: ... def generate_help(self, header: str | None = ...) -> list[str]: ... class OptionDummy: diff --git a/mypy/typeshed/stdlib/distutils/file_util.pyi b/mypy/typeshed/stdlib/distutils/file_util.pyi index cfe840e71040..a7f24105a678 100644 --- a/mypy/typeshed/stdlib/distutils/file_util.pyi +++ b/mypy/typeshed/stdlib/distutils/file_util.pyi @@ -1,4 +1,4 @@ -from typing import Sequence, Tuple +from typing import Sequence def copy_file( src: str, @@ -9,6 +9,6 @@ def copy_file( link: str | None = ..., verbose: bool = ..., dry_run: bool = ..., -) -> Tuple[str, str]: ... +) -> tuple[str, str]: ... def move_file(src: str, dst: str, verbose: bool = ..., dry_run: bool = ...) -> str: ... def write_file(filename: str, contents: Sequence[str]) -> None: ... diff --git a/mypy/typeshed/stdlib/distutils/text_file.pyi b/mypy/typeshed/stdlib/distutils/text_file.pyi index 6a0aded5176e..ace642e027cf 100644 --- a/mypy/typeshed/stdlib/distutils/text_file.pyi +++ b/mypy/typeshed/stdlib/distutils/text_file.pyi @@ -1,4 +1,4 @@ -from typing import IO, Tuple +from typing import IO class TextFile: def __init__( @@ -15,7 +15,7 @@ class TextFile: ) -> None: ... def open(self, filename: str) -> None: ... def close(self) -> None: ... - def warn(self, msg: str, line: list[int] | Tuple[int, int] | int | None = ...) -> None: ... + def warn(self, msg: str, line: list[int] | tuple[int, int] | int | None = ...) -> None: ... def readline(self) -> str | None: ... def readlines(self) -> list[str]: ... def unreadline(self, line: str) -> str: ... diff --git a/mypy/typeshed/stdlib/distutils/version.pyi b/mypy/typeshed/stdlib/distutils/version.pyi index 29d72174d8db..9921dde39af6 100644 --- a/mypy/typeshed/stdlib/distutils/version.pyi +++ b/mypy/typeshed/stdlib/distutils/version.pyi @@ -21,8 +21,8 @@ class Version: class StrictVersion(Version): version_re: Pattern[str] - version: Tuple[int, int, int] - prerelease: Tuple[str, int] | None + version: tuple[int, int, int] + prerelease: tuple[str, int] | None def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... diff --git a/mypy/typeshed/stdlib/email/_header_value_parser.pyi b/mypy/typeshed/stdlib/email/_header_value_parser.pyi index 04234b482773..a4c060ef46a5 100644 --- a/mypy/typeshed/stdlib/email/_header_value_parser.pyi +++ b/mypy/typeshed/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, Set, Tuple, Type, TypeVar, Union +from typing import Any, Iterable, Iterator, List, Pattern, Set, Type, TypeVar, Union from typing_extensions import Final _T = TypeVar("_T") @@ -281,12 +281,12 @@ class MimeParameters(TokenList): token_type: str syntactic_break: bool @property - def params(self) -> Iterator[Tuple[str, str]]: ... + def params(self) -> Iterator[tuple[str, str]]: ... class ParameterizedHeaderValue(TokenList): syntactic_break: bool @property - def params(self) -> Iterable[Tuple[str, str]]: ... + def params(self) -> Iterable[tuple[str, str]]: ... class ContentType(ParameterizedHeaderValue): token_type: str @@ -334,7 +334,7 @@ class Terminal(str): def pop_trailing_ws(self) -> None: ... @property def comments(self) -> list[str]: ... - def __getnewargs__(self) -> Tuple[str, str]: ... # type: ignore + def __getnewargs__(self) -> tuple[str, str]: ... # type: ignore class WhiteSpaceTerminal(Terminal): @property @@ -356,55 +356,55 @@ DOT: Final[ValueTerminal] ListSeparator: Final[ValueTerminal] RouteComponentMarker: Final[ValueTerminal] -def get_fws(value: str) -> Tuple[WhiteSpaceTerminal, str]: ... -def get_encoded_word(value: str) -> Tuple[EncodedWord, str]: ... +def get_fws(value: str) -> tuple[WhiteSpaceTerminal, str]: ... +def get_encoded_word(value: str) -> tuple[EncodedWord, str]: ... def get_unstructured(value: str) -> UnstructuredTokenList: ... -def get_qp_ctext(value: str) -> Tuple[WhiteSpaceTerminal, str]: ... -def get_qcontent(value: str) -> Tuple[ValueTerminal, str]: ... -def get_atext(value: str) -> Tuple[ValueTerminal, str]: ... -def get_bare_quoted_string(value: str) -> Tuple[BareQuotedString, str]: ... -def get_comment(value: str) -> Tuple[Comment, str]: ... -def get_cfws(value: str) -> Tuple[CFWSList, str]: ... -def get_quoted_string(value: str) -> Tuple[QuotedString, str]: ... -def get_atom(value: str) -> Tuple[Atom, str]: ... -def get_dot_atom_text(value: str) -> Tuple[DotAtomText, str]: ... -def get_dot_atom(value: str) -> Tuple[DotAtom, str]: ... -def get_word(value: str) -> Tuple[Any, str]: ... -def get_phrase(value: str) -> Tuple[Phrase, str]: ... -def get_local_part(value: str) -> Tuple[LocalPart, str]: ... -def get_obs_local_part(value: str) -> Tuple[ObsLocalPart, str]: ... -def get_dtext(value: str) -> Tuple[ValueTerminal, str]: ... -def get_domain_literal(value: str) -> Tuple[DomainLiteral, str]: ... -def get_domain(value: str) -> Tuple[Domain, str]: ... -def get_addr_spec(value: str) -> Tuple[AddrSpec, str]: ... -def get_obs_route(value: str) -> Tuple[ObsRoute, str]: ... -def get_angle_addr(value: str) -> Tuple[AngleAddr, str]: ... -def get_display_name(value: str) -> Tuple[DisplayName, str]: ... -def get_name_addr(value: str) -> Tuple[NameAddr, str]: ... -def get_mailbox(value: str) -> Tuple[Mailbox, str]: ... -def get_invalid_mailbox(value: str, endchars: str) -> Tuple[InvalidMailbox, str]: ... -def get_mailbox_list(value: str) -> Tuple[MailboxList, str]: ... -def get_group_list(value: str) -> Tuple[GroupList, str]: ... -def get_group(value: str) -> Tuple[Group, str]: ... -def get_address(value: str) -> Tuple[Address, str]: ... -def get_address_list(value: str) -> Tuple[AddressList, str]: ... +def get_qp_ctext(value: str) -> tuple[WhiteSpaceTerminal, str]: ... +def get_qcontent(value: str) -> tuple[ValueTerminal, str]: ... +def get_atext(value: str) -> tuple[ValueTerminal, str]: ... +def get_bare_quoted_string(value: str) -> tuple[BareQuotedString, str]: ... +def get_comment(value: str) -> tuple[Comment, str]: ... +def get_cfws(value: str) -> tuple[CFWSList, str]: ... +def get_quoted_string(value: str) -> tuple[QuotedString, str]: ... +def get_atom(value: str) -> tuple[Atom, str]: ... +def get_dot_atom_text(value: str) -> tuple[DotAtomText, str]: ... +def get_dot_atom(value: str) -> tuple[DotAtom, str]: ... +def get_word(value: str) -> tuple[Any, str]: ... +def get_phrase(value: str) -> tuple[Phrase, str]: ... +def get_local_part(value: str) -> tuple[LocalPart, str]: ... +def get_obs_local_part(value: str) -> tuple[ObsLocalPart, str]: ... +def get_dtext(value: str) -> tuple[ValueTerminal, str]: ... +def get_domain_literal(value: str) -> tuple[DomainLiteral, str]: ... +def get_domain(value: str) -> tuple[Domain, str]: ... +def get_addr_spec(value: str) -> tuple[AddrSpec, str]: ... +def get_obs_route(value: str) -> tuple[ObsRoute, str]: ... +def get_angle_addr(value: str) -> tuple[AngleAddr, str]: ... +def get_display_name(value: str) -> tuple[DisplayName, str]: ... +def get_name_addr(value: str) -> tuple[NameAddr, str]: ... +def get_mailbox(value: str) -> tuple[Mailbox, str]: ... +def get_invalid_mailbox(value: str, endchars: str) -> tuple[InvalidMailbox, str]: ... +def get_mailbox_list(value: str) -> tuple[MailboxList, str]: ... +def get_group_list(value: str) -> tuple[GroupList, str]: ... +def get_group(value: str) -> tuple[Group, str]: ... +def get_address(value: str) -> tuple[Address, str]: ... +def get_address_list(value: str) -> tuple[AddressList, str]: ... if sys.version_info >= (3, 8): - def get_no_fold_literal(value: str) -> Tuple[NoFoldLiteral, str]: ... - def get_msg_id(value: str) -> Tuple[MsgID, str]: ... + def get_no_fold_literal(value: str) -> tuple[NoFoldLiteral, str]: ... + def get_msg_id(value: str) -> tuple[MsgID, str]: ... def parse_message_id(value: str) -> MessageID: ... def parse_mime_version(value: str) -> MIMEVersion: ... -def get_invalid_parameter(value: str) -> Tuple[InvalidParameter, str]: ... -def get_ttext(value: str) -> Tuple[ValueTerminal, str]: ... -def get_token(value: str) -> Tuple[Token, str]: ... -def get_attrtext(value: str) -> Tuple[ValueTerminal, str]: ... -def get_attribute(value: str) -> Tuple[Attribute, str]: ... -def get_extended_attrtext(value: str) -> Tuple[ValueTerminal, str]: ... -def get_extended_attribute(value: str) -> Tuple[Attribute, str]: ... -def get_section(value: str) -> Tuple[Section, str]: ... -def get_value(value: str) -> Tuple[Value, str]: ... -def get_parameter(value: str) -> Tuple[Parameter, str]: ... +def get_invalid_parameter(value: str) -> tuple[InvalidParameter, str]: ... +def get_ttext(value: str) -> tuple[ValueTerminal, str]: ... +def get_token(value: str) -> tuple[Token, str]: ... +def get_attrtext(value: str) -> tuple[ValueTerminal, str]: ... +def get_attribute(value: str) -> tuple[Attribute, str]: ... +def get_extended_attrtext(value: str) -> tuple[ValueTerminal, str]: ... +def get_extended_attribute(value: str) -> tuple[Attribute, str]: ... +def get_section(value: str) -> tuple[Section, str]: ... +def get_value(value: str) -> tuple[Value, str]: ... +def get_parameter(value: str) -> tuple[Parameter, str]: ... def parse_mime_parameters(value: str) -> MimeParameters: ... def parse_content_type_header(value: str) -> ContentType: ... def parse_content_disposition_header(value: str) -> ContentDisposition: ... diff --git a/mypy/typeshed/stdlib/email/header.pyi b/mypy/typeshed/stdlib/email/header.pyi index 0d7691a622cb..4bebd50c45e4 100644 --- a/mypy/typeshed/stdlib/email/header.pyi +++ b/mypy/typeshed/stdlib/email/header.pyi @@ -1,5 +1,5 @@ from email.charset import Charset -from typing import Any, Tuple +from typing import Any class Header: def __init__( @@ -17,9 +17,9 @@ class Header: def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... -def decode_header(header: Header | str) -> list[Tuple[bytes, str | None]]: ... +def decode_header(header: Header | str) -> list[tuple[bytes, str | None]]: ... def make_header( - decoded_seq: list[Tuple[bytes, str | None]], + decoded_seq: list[tuple[bytes, str | None]], maxlinelen: int | None = ..., header_name: str | None = ..., continuation_ws: str = ..., diff --git a/mypy/typeshed/stdlib/email/message.pyi b/mypy/typeshed/stdlib/email/message.pyi index 9ad8c1852199..a1749a4cfc2e 100644 --- a/mypy/typeshed/stdlib/email/message.pyi +++ b/mypy/typeshed/stdlib/email/message.pyi @@ -34,7 +34,7 @@ class Message: def __delitem__(self, name: str) -> None: ... def keys(self) -> list[str]: ... def values(self) -> list[_HeaderType]: ... - def items(self) -> list[Tuple[str, _HeaderType]]: ... + def items(self) -> list[tuple[str, _HeaderType]]: ... def get(self, name: str, failobj: _T = ...) -> _HeaderType | _T: ... def get_all(self, name: str, failobj: _T = ...) -> list[_HeaderType] | _T: ... def add_header(self, _name: str, _value: str, **_params: _ParamsType) -> None: ... @@ -44,7 +44,7 @@ class Message: def get_content_subtype(self) -> str: ... def get_default_type(self) -> str: ... def set_default_type(self, ctype: str) -> None: ... - def get_params(self, failobj: _T = ..., header: str = ..., unquote: bool = ...) -> list[Tuple[str, str]] | _T: ... + def get_params(self, failobj: _T = ..., header: str = ..., unquote: bool = ...) -> list[tuple[str, str]] | _T: ... def get_param(self, param: str, failobj: _T = ..., header: str = ..., unquote: bool = ...) -> _T | _ParamType: ... def del_param(self, param: str, header: str = ..., requote: bool = ...) -> None: ... def set_type(self, type: str, header: str = ..., requote: bool = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/email/policy.pyi b/mypy/typeshed/stdlib/email/policy.pyi index 625e6a5dcdbc..72a54bcfbf08 100644 --- a/mypy/typeshed/stdlib/email/policy.pyi +++ b/mypy/typeshed/stdlib/email/policy.pyi @@ -3,7 +3,7 @@ from email.contentmanager import ContentManager from email.errors import MessageDefect from email.header import Header from email.message import Message -from typing import Any, Callable, Tuple +from typing import Any, Callable class Policy: max_line_length: int | None @@ -17,9 +17,9 @@ class Policy: def register_defect(self, obj: Message, defect: MessageDefect) -> None: ... def header_max_count(self, name: str) -> int | None: ... @abstractmethod - def header_source_parse(self, sourcelines: list[str]) -> Tuple[str, str]: ... + def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ... @abstractmethod - def header_store_parse(self, name: str, value: str) -> Tuple[str, str]: ... + def header_store_parse(self, name: str, value: str) -> tuple[str, str]: ... @abstractmethod def header_fetch_parse(self, name: str, value: str) -> str: ... @abstractmethod @@ -28,8 +28,8 @@ class Policy: def fold_binary(self, name: str, value: str) -> bytes: ... class Compat32(Policy): - def header_source_parse(self, sourcelines: list[str]) -> Tuple[str, str]: ... - def header_store_parse(self, name: str, value: str) -> Tuple[str, str]: ... + def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ... + def header_store_parse(self, name: str, value: str) -> tuple[str, str]: ... def header_fetch_parse(self, name: str, value: str) -> str | Header: ... # type: ignore def fold(self, name: str, value: str) -> str: ... def fold_binary(self, name: str, value: str) -> bytes: ... @@ -41,8 +41,8 @@ class EmailPolicy(Policy): refold_source: str header_factory: Callable[[str, str], str] content_manager: ContentManager - def header_source_parse(self, sourcelines: list[str]) -> Tuple[str, str]: ... - def header_store_parse(self, name: str, value: str) -> Tuple[str, str]: ... + def header_source_parse(self, sourcelines: list[str]) -> tuple[str, str]: ... + def header_store_parse(self, name: str, value: str) -> tuple[str, str]: ... def header_fetch_parse(self, name: str, value: str) -> str: ... def fold(self, name: str, value: str) -> str: ... def fold_binary(self, name: str, value: str) -> bytes: ... diff --git a/mypy/typeshed/stdlib/email/utils.pyi b/mypy/typeshed/stdlib/email/utils.pyi index 96d75a63ab12..3c07e98079fc 100644 --- a/mypy/typeshed/stdlib/email/utils.pyi +++ b/mypy/typeshed/stdlib/email/utils.pyi @@ -8,13 +8,13 @@ _PDTZ = Tuple[int, int, int, int, int, int, int, int, int, Optional[int]] def quote(str: str) -> str: ... def unquote(str: str) -> str: ... -def parseaddr(addr: str | None) -> Tuple[str, str]: ... -def formataddr(pair: Tuple[str | None, str], charset: str | Charset = ...) -> str: ... -def getaddresses(fieldvalues: list[str]) -> list[Tuple[str, str]]: ... +def parseaddr(addr: str | None) -> tuple[str, str]: ... +def formataddr(pair: tuple[str | None, str], charset: str | Charset = ...) -> str: ... +def getaddresses(fieldvalues: list[str]) -> list[tuple[str, str]]: ... @overload def parsedate(data: None) -> None: ... @overload -def parsedate(data: str) -> Tuple[int, int, int, int, int, int, int, int, int] | None: ... +def parsedate(data: str) -> tuple[int, int, int, int, int, int, int, int, int] | None: ... @overload def parsedate_tz(data: None) -> None: ... @overload @@ -34,7 +34,7 @@ def formatdate(timeval: float | None = ..., localtime: bool = ..., usegmt: bool def format_datetime(dt: datetime.datetime, usegmt: bool = ...) -> str: ... def localtime(dt: datetime.datetime | None = ..., isdst: int = ...) -> datetime.datetime: ... def make_msgid(idstring: str | None = ..., domain: str | None = ...) -> str: ... -def decode_rfc2231(s: str) -> Tuple[str | None, str | None, str]: ... +def decode_rfc2231(s: str) -> tuple[str | None, str | None, str]: ... def encode_rfc2231(s: str, charset: str | None = ..., language: str | None = ...) -> str: ... def collapse_rfc2231_value(value: _ParamType, errors: str = ..., fallback_charset: str = ...) -> str: ... -def decode_params(params: list[Tuple[str, str]]) -> list[Tuple[str, _ParamType]]: ... +def decode_params(params: list[tuple[str, str]]) -> list[tuple[str, _ParamType]]: ... diff --git a/mypy/typeshed/stdlib/encodings/utf_8.pyi b/mypy/typeshed/stdlib/encodings/utf_8.pyi index 892f2f082af0..568fa6013373 100644 --- a/mypy/typeshed/stdlib/encodings/utf_8.pyi +++ b/mypy/typeshed/stdlib/encodings/utf_8.pyi @@ -1,21 +1,20 @@ import codecs -from typing import Tuple class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input: str, final: bool = ...) -> bytes: ... class IncrementalDecoder(codecs.BufferedIncrementalDecoder): @staticmethod - def _buffer_decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> Tuple[str, int]: ... + def _buffer_decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> tuple[str, int]: ... class StreamWriter(codecs.StreamWriter): @staticmethod - def encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... + def encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... class StreamReader(codecs.StreamReader): @staticmethod - def decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> Tuple[str, int]: ... + def decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> tuple[str, int]: ... def getregentry() -> codecs.CodecInfo: ... -def encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def decode(input: bytes, errors: str | None = ...) -> Tuple[str, int]: ... +def encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... +def decode(input: bytes, errors: str | None = ...) -> tuple[str, int]: ... diff --git a/mypy/typeshed/stdlib/filecmp.pyi b/mypy/typeshed/stdlib/filecmp.pyi index 0cc92ed9e3ed..1c3d0a142a33 100644 --- a/mypy/typeshed/stdlib/filecmp.pyi +++ b/mypy/typeshed/stdlib/filecmp.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from os import PathLike -from typing import Any, AnyStr, Callable, Generic, Iterable, Sequence, Tuple +from typing import Any, AnyStr, Callable, Generic, Iterable, Sequence if sys.version_info >= (3, 9): from types import GenericAlias @@ -11,7 +11,7 @@ DEFAULT_IGNORES: list[str] def cmp(f1: StrOrBytesPath, f2: StrOrBytesPath, shallow: int | bool = ...) -> bool: ... def cmpfiles( a: AnyStr | PathLike[AnyStr], b: AnyStr | PathLike[AnyStr], common: Iterable[AnyStr], shallow: int | bool = ... -) -> Tuple[list[AnyStr], list[AnyStr], list[AnyStr]]: ... +) -> tuple[list[AnyStr], list[AnyStr], list[AnyStr]]: ... class dircmp(Generic[AnyStr]): def __init__( diff --git a/mypy/typeshed/stdlib/fractions.pyi b/mypy/typeshed/stdlib/fractions.pyi index a5d2e21e9a29..3c6808651275 100644 --- a/mypy/typeshed/stdlib/fractions.pyi +++ b/mypy/typeshed/stdlib/fractions.pyi @@ -1,7 +1,7 @@ import sys from decimal import Decimal from numbers import Integral, Rational, Real -from typing import Tuple, Type, TypeVar, Union, overload +from typing import Type, TypeVar, Union, overload from typing_extensions import Literal _ComparableNum = Union[int, float, Decimal, Real] @@ -30,7 +30,7 @@ class Fraction(Rational): def from_decimal(cls, dec: Decimal) -> Fraction: ... def limit_denominator(self, max_denominator: int = ...) -> Fraction: ... if sys.version_info >= (3, 8): - def as_integer_ratio(self) -> Tuple[int, int]: ... + def as_integer_ratio(self) -> tuple[int, int]: ... @property def numerator(self) -> int: ... @property @@ -100,13 +100,13 @@ class Fraction(Rational): @overload def __rmod__(self, other: float) -> float: ... @overload - def __divmod__(self, other: int | Fraction) -> Tuple[int, Fraction]: ... + def __divmod__(self, other: int | Fraction) -> tuple[int, Fraction]: ... @overload - def __divmod__(self, other: float) -> Tuple[float, Fraction]: ... + def __divmod__(self, other: float) -> tuple[float, Fraction]: ... @overload - def __rdivmod__(self, other: int | Fraction) -> Tuple[int, Fraction]: ... + def __rdivmod__(self, other: int | Fraction) -> tuple[int, Fraction]: ... @overload - def __rdivmod__(self, other: float) -> Tuple[float, Fraction]: ... + def __rdivmod__(self, other: float) -> tuple[float, Fraction]: ... @overload def __pow__(self, other: int) -> Fraction: ... @overload diff --git a/mypy/typeshed/stdlib/ftplib.pyi b/mypy/typeshed/stdlib/ftplib.pyi index 4275888f5fc6..3f4f892bb516 100644 --- a/mypy/typeshed/stdlib/ftplib.pyi +++ b/mypy/typeshed/stdlib/ftplib.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import Self, SupportsRead, SupportsReadline from socket import socket from ssl import SSLContext @@ -32,22 +33,39 @@ class FTP: lastresp: str file: TextIO | None encoding: str + + # The following variable is intentionally left undocumented. + # See https://bugs.python.org/issue43285 for relevant discussion + # trust_server_pasv_ipv4_address: bool def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... - source_address: Tuple[str, int] | None - def __init__( - self, - host: str = ..., - user: str = ..., - passwd: str = ..., - acct: str = ..., - timeout: float = ..., - source_address: Tuple[str, int] | None = ..., - ) -> None: ... + source_address: tuple[str, int] | None + if sys.version_info >= (3, 9): + def __init__( + self, + host: str = ..., + user: str = ..., + passwd: str = ..., + acct: str = ..., + timeout: float = ..., + source_address: tuple[str, int] | None = ..., + *, + encoding: str = ..., + ) -> None: ... + else: + def __init__( + self, + host: str = ..., + user: str = ..., + passwd: str = ..., + acct: str = ..., + timeout: float = ..., + source_address: tuple[str, int] | None = ..., + ) -> None: ... def connect( - self, host: str = ..., port: int = ..., timeout: float = ..., source_address: Tuple[str, int] | None = ... + self, host: str = ..., port: int = ..., timeout: float = ..., source_address: tuple[str, int] | None = ... ) -> str: ... def getwelcome(self) -> str: ... def set_debuglevel(self, level: int) -> None: ... @@ -66,10 +84,10 @@ class FTP: def sendport(self, host: str, port: int) -> str: ... def sendeprt(self, host: str, port: int) -> str: ... def makeport(self) -> socket: ... - def makepasv(self) -> Tuple[str, int]: ... + def makepasv(self) -> tuple[str, int]: ... def login(self, user: str = ..., passwd: str = ..., acct: str = ...) -> str: ... # In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers. - def ntransfercmd(self, cmd: str, rest: int | str | None = ...) -> Tuple[socket, int]: ... + def ntransfercmd(self, cmd: str, rest: int | str | None = ...) -> tuple[socket, int]: ... def transfercmd(self, cmd: str, rest: int | str | None = ...) -> socket: ... def retrbinary( self, cmd: str, callback: Callable[[bytes], Any], blocksize: int = ..., rest: int | str | None = ... @@ -88,7 +106,7 @@ class FTP: def nlst(self, *args: str) -> list[str]: ... # Technically only the last arg can be a Callable but ... def dir(self, *args: str | Callable[[str], None]) -> None: ... - def mlsd(self, path: str = ..., facts: Iterable[str] = ...) -> Iterator[Tuple[str, dict[str, str]]]: ... + def mlsd(self, path: str = ..., facts: Iterable[str] = ...) -> Iterator[tuple[str, dict[str, str]]]: ... def rename(self, fromname: str, toname: str) -> str: ... def delete(self, filename: str) -> str: ... def cwd(self, dirname: str) -> str: ... @@ -100,18 +118,34 @@ class FTP: def close(self) -> None: ... class FTP_TLS(FTP): - def __init__( - self, - host: str = ..., - user: str = ..., - passwd: str = ..., - acct: str = ..., - keyfile: str | None = ..., - certfile: str | None = ..., - context: SSLContext | None = ..., - timeout: float = ..., - source_address: Tuple[str, int] | None = ..., - ) -> None: ... + if sys.version_info >= (3, 9): + def __init__( + self, + host: str = ..., + user: str = ..., + passwd: str = ..., + acct: str = ..., + keyfile: str | None = ..., + certfile: str | None = ..., + context: SSLContext | None = ..., + timeout: float = ..., + source_address: tuple[str, int] | None = ..., + *, + encoding: str = ..., + ) -> None: ... + else: + def __init__( + self, + host: str = ..., + user: str = ..., + passwd: str = ..., + acct: str = ..., + keyfile: str | None = ..., + certfile: str | None = ..., + context: SSLContext | None = ..., + timeout: float = ..., + source_address: tuple[str, int] | None = ..., + ) -> None: ... ssl_version: int keyfile: str | None certfile: str | None @@ -123,8 +157,8 @@ class FTP_TLS(FTP): def ccc(self) -> str: ... def parse150(resp: str) -> int | None: ... # undocumented -def parse227(resp: str) -> Tuple[str, int]: ... # undocumented -def parse229(resp: str, peer: Any) -> Tuple[str, int]: ... # undocumented +def parse227(resp: str) -> tuple[str, int]: ... # undocumented +def parse229(resp: str, peer: Any) -> tuple[str, int]: ... # undocumented def parse257(resp: str) -> str: ... # undocumented def ftpcp( source: FTP, sourcename: str, target: FTP, targetname: str = ..., type: Literal["A", "I"] = ... diff --git a/mypy/typeshed/stdlib/gc.pyi b/mypy/typeshed/stdlib/gc.pyi index 6eea01848939..39d2776783ef 100644 --- a/mypy/typeshed/stdlib/gc.pyi +++ b/mypy/typeshed/stdlib/gc.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Tuple +from typing import Any DEBUG_COLLECTABLE: int DEBUG_LEAK: int @@ -12,7 +12,7 @@ garbage: list[Any] def collect(generation: int = ...) -> int: ... def disable() -> None: ... def enable() -> None: ... -def get_count() -> Tuple[int, int, int]: ... +def get_count() -> tuple[int, int, int]: ... def get_debug() -> int: ... if sys.version_info >= (3, 8): @@ -29,7 +29,7 @@ if sys.version_info >= (3, 7): def get_referents(*objs: Any) -> list[Any]: ... def get_referrers(*objs: Any) -> list[Any]: ... def get_stats() -> list[dict[str, Any]]: ... -def get_threshold() -> Tuple[int, int, int]: ... +def get_threshold() -> tuple[int, int, int]: ... def is_tracked(__obj: Any) -> bool: ... if sys.version_info >= (3, 9): diff --git a/mypy/typeshed/stdlib/genericpath.pyi b/mypy/typeshed/stdlib/genericpath.pyi index 1c7be922e941..56683e323178 100644 --- a/mypy/typeshed/stdlib/genericpath.pyi +++ b/mypy/typeshed/stdlib/genericpath.pyi @@ -14,16 +14,16 @@ def commonprefix(m: Sequence[BytesPath]) -> bytes | Literal[""]: ... def commonprefix(m: Sequence[list[SupportsLessThanT]]) -> Sequence[SupportsLessThanT]: ... @overload def commonprefix(m: Sequence[Tuple[SupportsLessThanT, ...]]) -> Sequence[SupportsLessThanT]: ... -def exists(path: StrOrBytesPath) -> bool: ... -def getsize(filename: StrOrBytesPath) -> int: ... -def isfile(path: StrOrBytesPath) -> bool: ... -def isdir(s: StrOrBytesPath) -> bool: ... +def exists(path: StrOrBytesPath | int) -> bool: ... +def getsize(filename: StrOrBytesPath | int) -> int: ... +def isfile(path: StrOrBytesPath | int) -> bool: ... +def isdir(s: StrOrBytesPath | int) -> bool: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(filename: StrOrBytesPath) -> float: ... -def getmtime(filename: StrOrBytesPath) -> float: ... -def getctime(filename: StrOrBytesPath) -> float: ... -def samefile(f1: StrOrBytesPath, f2: StrOrBytesPath) -> bool: ... +def getatime(filename: StrOrBytesPath | int) -> float: ... +def getmtime(filename: StrOrBytesPath | int) -> float: ... +def getctime(filename: StrOrBytesPath | int) -> float: ... +def samefile(f1: StrOrBytesPath | int, f2: StrOrBytesPath | int) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/mypy/typeshed/stdlib/html/parser.pyi b/mypy/typeshed/stdlib/html/parser.pyi index 1cdaf72ff561..fec3f3509522 100644 --- a/mypy/typeshed/stdlib/html/parser.pyi +++ b/mypy/typeshed/stdlib/html/parser.pyi @@ -6,11 +6,11 @@ class HTMLParser(ParserBase): def feed(self, data: str) -> None: ... def close(self) -> None: ... def reset(self) -> None: ... - def getpos(self) -> Tuple[int, int]: ... + def getpos(self) -> tuple[int, int]: ... def get_starttag_text(self) -> str | None: ... - def handle_starttag(self, tag: str, attrs: list[Tuple[str, str | None]]) -> None: ... + def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: ... def handle_endtag(self, tag: str) -> None: ... - def handle_startendtag(self, tag: str, attrs: list[Tuple[str, str | None]]) -> None: ... + def handle_startendtag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: ... def handle_data(self, data: str) -> None: ... def handle_entityref(self, name: str) -> None: ... def handle_charref(self, name: str) -> None: ... diff --git a/mypy/typeshed/stdlib/http/client.pyi b/mypy/typeshed/stdlib/http/client.pyi index 508191556f37..f27cb0b602ed 100644 --- a/mypy/typeshed/stdlib/http/client.pyi +++ b/mypy/typeshed/stdlib/http/client.pyi @@ -5,7 +5,7 @@ import sys import types from _typeshed import Self, WriteableBuffer from socket import socket -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, Tuple, Type, TypeVar, Union, overload +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, Type, TypeVar, Union, overload _DataType = Union[bytes, IO[Any], Iterable[bytes], str] _T = TypeVar("_T") @@ -86,6 +86,10 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): closed: bool status: int reason: str + chunked: bool + chunk_left: int | None + length: int | None + will_close: bool def __init__(self, sock: socket, debuglevel: int = ..., method: str | None = ..., url: str | None = ...) -> None: ... def peek(self, n: int = ...) -> bytes: ... def read(self, amt: int | None = ...) -> bytes: ... @@ -96,7 +100,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): def getheader(self, name: str) -> str | None: ... @overload def getheader(self, name: str, default: _T) -> str | _T: ... - def getheaders(self) -> list[Tuple[str, str]]: ... + def getheaders(self) -> list[tuple[str, str]]: ... def fileno(self) -> int: ... def isclosed(self) -> bool: ... def __iter__(self) -> Iterator[bytes]: ... @@ -118,12 +122,12 @@ class _HTTPConnectionProtocol(Protocol): host: str, port: int | None = ..., timeout: float = ..., - source_address: Tuple[str, int] | None = ..., + source_address: tuple[str, int] | None = ..., blocksize: int = ..., ) -> HTTPConnection: ... else: def __call__( - self, host: str, port: int | None = ..., timeout: float = ..., source_address: Tuple[str, int] | None = ... + self, host: str, port: int | None = ..., timeout: float = ..., source_address: tuple[str, int] | None = ... ) -> HTTPConnection: ... class HTTPConnection: @@ -141,12 +145,12 @@ class HTTPConnection: host: str, port: int | None = ..., timeout: float | None = ..., - source_address: Tuple[str, int] | None = ..., + source_address: tuple[str, int] | None = ..., blocksize: int = ..., ) -> None: ... else: def __init__( - self, host: str, port: int | None = ..., timeout: float | None = ..., source_address: Tuple[str, int] | None = ... + self, host: str, port: int | None = ..., timeout: float | None = ..., source_address: tuple[str, int] | None = ... ) -> None: ... def request( self, method: str, url: str, body: _DataType | None = ..., headers: Mapping[str, str] = ..., *, encode_chunked: bool = ... @@ -170,7 +174,7 @@ class HTTPSConnection(HTTPConnection): key_file: str | None = ..., cert_file: str | None = ..., timeout: float | None = ..., - source_address: Tuple[str, int] | None = ..., + source_address: tuple[str, int] | None = ..., *, context: ssl.SSLContext | None = ..., check_hostname: bool | None = ..., @@ -184,7 +188,7 @@ class HTTPSConnection(HTTPConnection): key_file: str | None = ..., cert_file: str | None = ..., timeout: float | None = ..., - source_address: Tuple[str, int] | None = ..., + source_address: tuple[str, int] | None = ..., *, context: ssl.SSLContext | None = ..., check_hostname: bool | None = ..., diff --git a/mypy/typeshed/stdlib/http/cookies.pyi b/mypy/typeshed/stdlib/http/cookies.pyi index 5a88121f5070..7e9513adb1a1 100644 --- a/mypy/typeshed/stdlib/http/cookies.pyi +++ b/mypy/typeshed/stdlib/http/cookies.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, Generic, Iterable, Mapping, Tuple, TypeVar, Union, overload +from typing import Any, Dict, Generic, Iterable, Mapping, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -32,7 +32,7 @@ class Morsel(Dict[str, Any], Generic[_T]): @overload # type: ignore def update(self, values: Mapping[str, str]) -> None: ... @overload - def update(self, values: Iterable[Tuple[str, str]]) -> None: ... + def update(self, values: Iterable[tuple[str, str]]) -> None: ... def isReservedKey(self, K: str) -> bool: ... def output(self, attrs: list[str] | None = ..., header: str = ...) -> str: ... def js_output(self, attrs: list[str] | None = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/http/server.pyi b/mypy/typeshed/stdlib/http/server.pyi index 92350b23a95f..e3d0a8c318f4 100644 --- a/mypy/typeshed/stdlib/http/server.pyi +++ b/mypy/typeshed/stdlib/http/server.pyi @@ -3,7 +3,7 @@ import io import socketserver import sys from _typeshed import StrPath, SupportsRead, SupportsWrite -from typing import Any, AnyStr, BinaryIO, ClassVar, Mapping, Sequence, Tuple +from typing import Any, AnyStr, BinaryIO, ClassVar, Mapping, Sequence class HTTPServer(socketserver.TCPServer): server_name: str @@ -14,7 +14,7 @@ if sys.version_info >= (3, 7): daemon_threads: bool # undocumented class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): - client_address: Tuple[str, int] + client_address: tuple[str, int] server: socketserver.BaseServer close_connection: bool requestline: str @@ -28,11 +28,11 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): error_content_type: str protocol_version: str MessageClass: type - responses: Mapping[int, Tuple[str, str]] + responses: Mapping[int, tuple[str, str]] default_request_version: str # undocumented weekdayname: ClassVar[Sequence[str]] # undocumented monthname: ClassVar[Sequence[str | None]] # undocumented - def __init__(self, request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer) -> None: ... + def __init__(self, request: bytes, client_address: tuple[str, int], server: socketserver.BaseServer) -> None: ... def handle(self) -> None: ... def handle_one_request(self) -> None: ... def handle_expect_100(self) -> bool: ... @@ -56,10 +56,10 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): extensions_map: dict[str, str] if sys.version_info >= (3, 7): def __init__( - self, request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer, directory: str | None = ... + self, request: bytes, client_address: tuple[str, int], server: socketserver.BaseServer, directory: str | None = ... ) -> None: ... else: - def __init__(self, request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer) -> None: ... + def __init__(self, request: bytes, client_address: tuple[str, int], server: socketserver.BaseServer) -> None: ... def do_GET(self) -> None: ... def do_HEAD(self) -> None: ... def send_head(self) -> io.BytesIO | BinaryIO | None: ... # undocumented diff --git a/mypy/typeshed/stdlib/imaplib.pyi b/mypy/typeshed/stdlib/imaplib.pyi index 63c57a4d4623..a9f19048c9ae 100644 --- a/mypy/typeshed/stdlib/imaplib.pyi +++ b/mypy/typeshed/stdlib/imaplib.pyi @@ -14,6 +14,8 @@ _CommandResults = Tuple[str, List[Any]] _AnyResponseData = Union[List[None], List[Union[bytes, Tuple[bytes, bytes]]]] +_list = list # conflicts with a method named "list" + class IMAP4: error: Type[Exception] abort: Type[Exception] @@ -22,15 +24,15 @@ class IMAP4: debug: int state: str literal: str | None - tagged_commands: dict[bytes, List[bytes] | None] - untagged_responses: dict[str, List[bytes | Tuple[bytes, bytes]]] + tagged_commands: dict[bytes, _list[bytes] | None] + untagged_responses: dict[str, _list[bytes | tuple[bytes, bytes]]] continuation_response: str is_readonly: bool tagnum: int tagpre: str tagre: Pattern[str] welcome: bytes - capabilities: Tuple[str] + capabilities: tuple[str] PROTOCOL_VERSION: str if sys.version_info >= (3, 9): def __init__(self, host: str = ..., port: int = ..., timeout: float | None = ...) -> None: ... @@ -51,7 +53,7 @@ class IMAP4: def recent(self) -> _CommandResults: ... def response(self, code: str) -> _CommandResults: ... def append(self, mailbox: str, flags: str, date_time: str, message: str) -> str: ... - def authenticate(self, mechanism: str, authobject: Callable[[bytes], bytes | None]) -> Tuple[str, str]: ... + def authenticate(self, mechanism: str, authobject: Callable[[bytes], bytes | None]) -> tuple[str, str]: ... def capability(self) -> _CommandResults: ... def check(self) -> _CommandResults: ... def close(self) -> _CommandResults: ... @@ -63,29 +65,29 @@ class IMAP4: def __enter__(self: Self) -> Self: ... def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... def expunge(self) -> _CommandResults: ... - def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ... + def fetch(self, message_set: str, message_parts: str) -> tuple[str, _AnyResponseData]: ... def getacl(self, mailbox: str) -> _CommandResults: ... def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ... def getquota(self, root: str) -> _CommandResults: ... def getquotaroot(self, mailbox: str) -> _CommandResults: ... - def list(self, directory: str = ..., pattern: str = ...) -> Tuple[str, _AnyResponseData]: ... - def login(self, user: str, password: str) -> Tuple[Literal["OK"], List[bytes]]: ... + def list(self, directory: str = ..., pattern: str = ...) -> tuple[str, _AnyResponseData]: ... + def login(self, user: str, password: str) -> tuple[Literal["OK"], _list[bytes]]: ... def login_cram_md5(self, user: str, password: str) -> _CommandResults: ... - def logout(self) -> Tuple[str, _AnyResponseData]: ... + def logout(self) -> tuple[str, _AnyResponseData]: ... def lsub(self, directory: str = ..., pattern: str = ...) -> _CommandResults: ... def myrights(self, mailbox: str) -> _CommandResults: ... def namespace(self) -> _CommandResults: ... - def noop(self) -> Tuple[str, List[bytes]]: ... + def noop(self) -> tuple[str, _list[bytes]]: ... def partial(self, message_num: str, message_part: str, start: str, length: str) -> _CommandResults: ... def proxyauth(self, user: str) -> _CommandResults: ... def rename(self, oldmailbox: str, newmailbox: str) -> _CommandResults: ... def search(self, charset: str | None, *criteria: str) -> _CommandResults: ... - def select(self, mailbox: str = ..., readonly: bool = ...) -> Tuple[str, List[bytes | None]]: ... + def select(self, mailbox: str = ..., readonly: bool = ...) -> tuple[str, _list[bytes | None]]: ... def setacl(self, mailbox: str, who: str, what: str) -> _CommandResults: ... def setannotation(self, *args: str) -> _CommandResults: ... def setquota(self, root: str, limits: str) -> _CommandResults: ... def sort(self, sort_criteria: str, charset: str, *search_criteria: str) -> _CommandResults: ... - def starttls(self, ssl_context: Any | None = ...) -> Tuple[Literal["OK"], List[None]]: ... + def starttls(self, ssl_context: Any | None = ...) -> tuple[Literal["OK"], _list[None]]: ... def status(self, mailbox: str, names: str) -> _CommandResults: ... def store(self, message_set: str, command: str, flags: str) -> _CommandResults: ... def subscribe(self, mailbox: str) -> _CommandResults: ... @@ -163,5 +165,5 @@ class _Authenticator: def Internaldate2tuple(resp: str) -> time.struct_time: ... def Int2AP(num: int) -> str: ... -def ParseFlags(resp: str) -> Tuple[str]: ... +def ParseFlags(resp: str) -> tuple[str]: ... def Time2Internaldate(date_time: float | time.struct_time | str) -> str: ... diff --git a/mypy/typeshed/stdlib/imp.pyi b/mypy/typeshed/stdlib/imp.pyi index aac16f029424..88f2e789329b 100644 --- a/mypy/typeshed/stdlib/imp.pyi +++ b/mypy/typeshed/stdlib/imp.pyi @@ -1,7 +1,7 @@ import types from _typeshed import StrPath from os import PathLike -from typing import IO, Any, Protocol, Tuple, TypeVar +from typing import IO, Any, Protocol, TypeVar from _imp import ( acquire_lock as acquire_lock, @@ -33,7 +33,7 @@ def get_magic() -> bytes: ... def get_tag() -> str: ... def cache_from_source(path: StrPath, debug_override: bool | None = ...) -> str: ... def source_from_cache(path: StrPath) -> str: ... -def get_suffixes() -> list[Tuple[str, str, int]]: ... +def get_suffixes() -> list[tuple[str, str, int]]: ... class NullImporter: def __init__(self, path: StrPath) -> None: ... @@ -53,12 +53,12 @@ class _FileLike(Protocol): def load_source(name: str, pathname: str, file: _FileLike | None = ...) -> types.ModuleType: ... def load_compiled(name: str, pathname: str, file: _FileLike | None = ...) -> types.ModuleType: ... def load_package(name: str, path: StrPath) -> types.ModuleType: ... -def load_module(name: str, file: _FileLike | None, filename: str, details: Tuple[str, str, int]) -> types.ModuleType: ... +def load_module(name: str, file: _FileLike | None, filename: str, details: tuple[str, str, int]) -> types.ModuleType: ... # IO[Any] is a TextIOWrapper if name is a .py file, and a FileIO otherwise. def find_module( name: str, path: None | list[str] | list[PathLike[str]] | list[StrPath] = ... -) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ... +) -> tuple[IO[Any], str, tuple[str, str, int]]: ... def reload(module: types.ModuleType) -> types.ModuleType: ... def init_builtin(name: str) -> types.ModuleType | None: ... def load_dynamic(name: str, path: str, file: Any = ...) -> types.ModuleType: ... # file argument is ignored diff --git a/mypy/typeshed/stdlib/importlib/abc.pyi b/mypy/typeshed/stdlib/importlib/abc.pyi index 6737912fcb1c..2e18f3f899a2 100644 --- a/mypy/typeshed/stdlib/importlib/abc.pyi +++ b/mypy/typeshed/stdlib/importlib/abc.pyi @@ -12,7 +12,7 @@ from _typeshed import ( from abc import ABCMeta, abstractmethod from importlib.machinery import ModuleSpec from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper -from typing import IO, Any, BinaryIO, Iterator, Mapping, Protocol, Sequence, Tuple, Union, overload +from typing import IO, Any, BinaryIO, Iterator, Mapping, Protocol, Sequence, Union, overload from typing_extensions import Literal, runtime_checkable _Path = Union[bytes, str] @@ -55,7 +55,7 @@ class MetaPathFinder(Finder): class PathEntryFinder(Finder): def find_module(self, fullname: str) -> Loader | None: ... - def find_loader(self, fullname: str) -> Tuple[Loader | None, Sequence[_Path]]: ... + def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[_Path]]: ... def invalidate_caches(self) -> None: ... # Not defined on the actual class, but expected to exist. def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... diff --git a/mypy/typeshed/stdlib/importlib/machinery.pyi b/mypy/typeshed/stdlib/importlib/machinery.pyi index 30194f6f2ad6..432bec901161 100644 --- a/mypy/typeshed/stdlib/importlib/machinery.pyi +++ b/mypy/typeshed/stdlib/importlib/machinery.pyi @@ -1,8 +1,7 @@ import importlib.abc import types -from typing import Any, Callable, Sequence, Tuple +from typing import Any, Callable, Sequence -# TODO: the loaders seem a bit backwards, attribute is protocol but __init__ arg isn't? class ModuleSpec: def __init__( self, @@ -14,7 +13,7 @@ class ModuleSpec: is_package: bool | None = ..., ) -> None: ... name: str - loader: importlib.abc._LoaderProtocol | None + loader: importlib.abc.Loader | None origin: str | None submodule_search_locations: list[str] | None loader_state: Any @@ -100,10 +99,10 @@ def all_suffixes() -> list[str]: ... class FileFinder(importlib.abc.PathEntryFinder): path: str - def __init__(self, path: str, *loader_details: Tuple[importlib.abc.Loader, list[str]]) -> None: ... + def __init__(self, path: str, *loader_details: tuple[importlib.abc.Loader, list[str]]) -> None: ... @classmethod def path_hook( - cls, *loader_details: Tuple[importlib.abc.Loader, list[str]] + cls, *loader_details: tuple[importlib.abc.Loader, list[str]] ) -> Callable[[str], importlib.abc.PathEntryFinder]: ... class SourceFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader): diff --git a/mypy/typeshed/stdlib/inspect.pyi b/mypy/typeshed/stdlib/inspect.pyi index e14718777a6e..ddb7293ae701 100644 --- a/mypy/typeshed/stdlib/inspect.pyi +++ b/mypy/typeshed/stdlib/inspect.pyi @@ -32,7 +32,7 @@ class BlockFinder: indecorator: bool decoratorhasargs: bool last: int - def tokeneater(self, type: int, token: str, srowcol: Tuple[int, int], erowcol: Tuple[int, int], line: str) -> None: ... + def tokeneater(self, type: int, token: str, srowcol: tuple[int, int], erowcol: tuple[int, int], line: str) -> None: ... CO_OPTIMIZED: int CO_NEWLOCALS: int @@ -46,7 +46,7 @@ CO_ITERABLE_COROUTINE: int CO_ASYNC_GENERATOR: int TPFLAGS_IS_ABSTRACT: int -def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> list[Tuple[str, Any]]: ... +def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> list[tuple[str, Any]]: ... def getmodulename(path: str) -> str | None: ... def ismodule(object: object) -> TypeGuard[ModuleType]: ... def isclass(object: object) -> TypeGuard[Type[Any]]: ... @@ -62,7 +62,7 @@ else: def iscoroutinefunction(object: object) -> bool: ... def isgenerator(object: object) -> TypeGuard[GeneratorType[Any, Any, Any]]: ... -def iscoroutine(object: object) -> TypeGuard[CoroutineType]: ... +def iscoroutine(object: object) -> TypeGuard[CoroutineType[Any, Any, Any]]: ... def isawaitable(object: object) -> TypeGuard[Awaitable[Any]]: ... if sys.version_info >= (3, 8): @@ -88,7 +88,7 @@ def ismemberdescriptor(object: object) -> bool: ... # _SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] -def findsource(object: _SourceObjectType) -> Tuple[list[str], int]: ... +def findsource(object: _SourceObjectType) -> tuple[list[str], int]: ... def getabsfile(object: _SourceObjectType, _filename: str | None = ...) -> str: ... def getblock(lines: Sequence[str]) -> Sequence[str]: ... def getdoc(object: object) -> str | None: ... @@ -96,7 +96,7 @@ def getcomments(object: object) -> str | None: ... def getfile(object: _SourceObjectType) -> str: ... def getmodule(object: object, _filename: str | None = ...) -> ModuleType | None: ... def getsourcefile(object: _SourceObjectType) -> str | None: ... -def getsourcelines(object: _SourceObjectType) -> Tuple[list[str], int]: ... +def getsourcelines(object: _SourceObjectType) -> tuple[list[str], int]: ... def getsource(object: _SourceObjectType) -> str: ... def cleandoc(doc: str) -> str: ... def indentsize(line: str) -> int: ... diff --git a/mypy/typeshed/stdlib/ipaddress.pyi b/mypy/typeshed/stdlib/ipaddress.pyi index 710ad27dd466..0ded1ef19b47 100644 --- a/mypy/typeshed/stdlib/ipaddress.pyi +++ b/mypy/typeshed/stdlib/ipaddress.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Container, Generic, Iterable, Iterator, SupportsInt, Tuple, TypeVar, overload +from typing import Any, Container, Generic, Iterable, Iterator, SupportsInt, TypeVar, overload # Undocumented length constants IPV4LENGTH: int @@ -126,7 +126,7 @@ class IPv6Address(_BaseAddress): @property def sixtofour(self) -> IPv4Address | None: ... @property - def teredo(self) -> Tuple[IPv4Address, IPv4Address] | None: ... + def teredo(self) -> tuple[IPv4Address, IPv4Address] | None: ... class IPv6Network(_BaseNetwork[IPv6Address]): @property @@ -142,11 +142,11 @@ def summarize_address_range(first: IPv4Address, last: IPv4Address) -> Iterator[I def summarize_address_range(first: IPv6Address, last: IPv6Address) -> Iterator[IPv6Network]: ... def collapse_addresses(addresses: Iterable[_N]) -> Iterator[_N]: ... @overload -def get_mixed_type_key(obj: _A) -> Tuple[int, _A]: ... +def get_mixed_type_key(obj: _A) -> tuple[int, _A]: ... @overload -def get_mixed_type_key(obj: IPv4Network) -> Tuple[int, IPv4Address, IPv4Address]: ... +def get_mixed_type_key(obj: IPv4Network) -> tuple[int, IPv4Address, IPv4Address]: ... @overload -def get_mixed_type_key(obj: IPv6Network) -> Tuple[int, IPv6Address, IPv6Address]: ... +def get_mixed_type_key(obj: IPv6Network) -> tuple[int, IPv6Address, IPv6Address]: ... class AddressValueError(ValueError): ... class NetmaskValueError(ValueError): ... diff --git a/mypy/typeshed/stdlib/itertools.pyi b/mypy/typeshed/stdlib/itertools.pyi index 4ffa181bfd7d..9d666d681781 100644 --- a/mypy/typeshed/stdlib/itertools.pyi +++ b/mypy/typeshed/stdlib/itertools.pyi @@ -91,8 +91,8 @@ class groupby(Iterator[Tuple[_T, Iterator[_S]]], Generic[_T, _S]): def __new__(cls, iterable: Iterable[_T1], key: None = ...) -> groupby[_T1, _T1]: ... @overload def __new__(cls, iterable: Iterable[_T1], key: Callable[[_T1], _T2]) -> groupby[_T2, _T1]: ... - def __iter__(self) -> Iterator[Tuple[_T, Iterator[_S]]]: ... - def __next__(self) -> Tuple[_T, Iterator[_S]]: ... + def __iter__(self) -> Iterator[tuple[_T, Iterator[_S]]]: ... + def __next__(self) -> tuple[_T, Iterator[_S]]: ... class islice(Iterator[_T], Generic[_T]): @overload @@ -126,15 +126,15 @@ _T6 = TypeVar("_T6") class product(Iterator[_T_co], Generic[_T_co]): @overload - def __new__(cls, __iter1: Iterable[_T1]) -> product[Tuple[_T1]]: ... + def __new__(cls, __iter1: Iterable[_T1]) -> product[tuple[_T1]]: ... @overload - def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> product[Tuple[_T1, _T2]]: ... + def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> product[tuple[_T1, _T2]]: ... @overload - def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> product[Tuple[_T1, _T2, _T3]]: ... + def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> product[tuple[_T1, _T2, _T3]]: ... @overload def __new__( cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4] - ) -> product[Tuple[_T1, _T2, _T3, _T4]]: ... + ) -> product[tuple[_T1, _T2, _T3, _T4]]: ... @overload def __new__( cls, @@ -143,7 +143,7 @@ class product(Iterator[_T_co], Generic[_T_co]): __iter3: Iterable[_T3], __iter4: Iterable[_T4], __iter5: Iterable[_T5], - ) -> product[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... + ) -> product[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload def __new__( cls, @@ -153,7 +153,7 @@ class product(Iterator[_T_co], Generic[_T_co]): __iter4: Iterable[_T4], __iter5: Iterable[_T5], __iter6: Iterable[_T6], - ) -> product[Tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... + ) -> product[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... @overload def __new__( cls, @@ -180,13 +180,13 @@ class permutations(Iterator[Tuple[_T, ...]], Generic[_T]): class combinations(Iterator[_T_co], Generic[_T_co]): @overload - def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[Tuple[_T, _T]]: ... + def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[tuple[_T, _T]]: ... @overload - def __new__(cls, iterable: Iterable[_T], r: Literal[3]) -> combinations[Tuple[_T, _T, _T]]: ... + def __new__(cls, iterable: Iterable[_T], r: Literal[3]) -> combinations[tuple[_T, _T, _T]]: ... @overload - def __new__(cls, iterable: Iterable[_T], r: Literal[4]) -> combinations[Tuple[_T, _T, _T, _T]]: ... + def __new__(cls, iterable: Iterable[_T], r: Literal[4]) -> combinations[tuple[_T, _T, _T, _T]]: ... @overload - def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> combinations[Tuple[_T, _T, _T, _T, _T]]: ... + 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 __iter__(self) -> Iterator[_T_co]: ... @@ -199,6 +199,6 @@ class combinations_with_replacement(Iterator[Tuple[_T, ...]], Generic[_T]): if sys.version_info >= (3, 10): class pairwise(Iterator[_T_co], Generic[_T_co]): - def __new__(cls, __iterable: Iterable[_T]) -> pairwise[Tuple[_T, _T]]: ... + def __new__(cls, __iterable: Iterable[_T]) -> pairwise[tuple[_T, _T]]: ... def __iter__(self) -> Iterator[_T_co]: ... def __next__(self) -> _T_co: ... diff --git a/mypy/typeshed/stdlib/json/__init__.pyi b/mypy/typeshed/stdlib/json/__init__.pyi index e37e68ca3b99..3e26d1b14f82 100644 --- a/mypy/typeshed/stdlib/json/__init__.pyi +++ b/mypy/typeshed/stdlib/json/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsRead -from typing import IO, Any, Callable, Tuple, Type +from typing import IO, Any, Callable, Type from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder from .encoder import JSONEncoder as JSONEncoder @@ -13,7 +13,7 @@ def dumps( allow_nan: bool = ..., cls: Type[JSONEncoder] | None = ..., indent: None | int | str = ..., - separators: Tuple[str, str] | None = ..., + separators: tuple[str, str] | None = ..., default: Callable[[Any], Any] | None = ..., sort_keys: bool = ..., **kwds: Any, @@ -28,7 +28,7 @@ def dump( allow_nan: bool = ..., cls: Type[JSONEncoder] | None = ..., indent: None | int | str = ..., - separators: Tuple[str, str] | None = ..., + separators: tuple[str, str] | None = ..., default: Callable[[Any], Any] | None = ..., sort_keys: bool = ..., **kwds: Any, @@ -41,7 +41,7 @@ def loads( parse_float: Callable[[str], Any] | None = ..., parse_int: Callable[[str], Any] | None = ..., parse_constant: Callable[[str], Any] | None = ..., - object_pairs_hook: Callable[[list[Tuple[Any, Any]]], Any] | None = ..., + object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ..., **kwds: Any, ) -> Any: ... def load( @@ -52,7 +52,7 @@ def load( parse_float: Callable[[str], Any] | None = ..., parse_int: Callable[[str], Any] | None = ..., parse_constant: Callable[[str], Any] | None = ..., - object_pairs_hook: Callable[[list[Tuple[Any, Any]]], Any] | None = ..., + object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ..., **kwds: Any, ) -> Any: ... def detect_encoding(b: bytes) -> str: ... # undocumented diff --git a/mypy/typeshed/stdlib/json/decoder.pyi b/mypy/typeshed/stdlib/json/decoder.pyi index 5135eb4e3e45..adf09bb4bb7d 100644 --- a/mypy/typeshed/stdlib/json/decoder.pyi +++ b/mypy/typeshed/stdlib/json/decoder.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Tuple +from typing import Any, Callable class JSONDecodeError(ValueError): msg: str @@ -14,7 +14,7 @@ class JSONDecoder: parse_int: Callable[[str], Any] parse_constant: Callable[[str], Any] strict: bool - object_pairs_hook: Callable[[list[Tuple[str, Any]]], Any] + object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] def __init__( self, *, @@ -23,7 +23,7 @@ class JSONDecoder: parse_int: Callable[[str], Any] | None = ..., parse_constant: Callable[[str], Any] | None = ..., strict: bool = ..., - object_pairs_hook: Callable[[list[Tuple[str, Any]]], Any] | None = ..., + object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] | None = ..., ) -> None: ... def decode(self, s: str, _w: Callable[..., Any] = ...) -> Any: ... # _w is undocumented - def raw_decode(self, s: str, idx: int = ...) -> Tuple[Any, int]: ... + def raw_decode(self, s: str, idx: int = ...) -> tuple[Any, int]: ... diff --git a/mypy/typeshed/stdlib/json/encoder.pyi b/mypy/typeshed/stdlib/json/encoder.pyi index 36113ed229ca..9557a96eee78 100644 --- a/mypy/typeshed/stdlib/json/encoder.pyi +++ b/mypy/typeshed/stdlib/json/encoder.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Iterator, Tuple +from typing import Any, Callable, Iterator def py_encode_basestring(s: str) -> str: ... # undocumented def py_encode_basestring_ascii(s: str) -> str: ... # undocumented @@ -22,7 +22,7 @@ class JSONEncoder: allow_nan: bool = ..., sort_keys: bool = ..., indent: int | None = ..., - separators: Tuple[str, str] | None = ..., + separators: tuple[str, str] | None = ..., default: Callable[..., Any] | None = ..., ) -> None: ... def default(self, o: Any) -> Any: ... diff --git a/mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi b/mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi index d6e1ec4b72b8..feed7269e6bc 100644 --- a/mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi +++ b/mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi @@ -1,6 +1,6 @@ from lib2to3.pgen2.grammar import _DFAS, Grammar from lib2to3.pytree import _NL, _Convert, _RawNode -from typing import Any, Sequence, Set, Tuple +from typing import Any, Sequence, Set _Context = Sequence[Any] @@ -14,7 +14,7 @@ class ParseError(Exception): class Parser: grammar: Grammar convert: _Convert - stack: list[Tuple[_DFAS, int, _RawNode]] + stack: list[tuple[_DFAS, int, _RawNode]] rootnode: _NL | None used_names: Set[str] def __init__(self, grammar: Grammar, convert: _Convert | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi b/mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi index 87b4a8aad71b..11680157d199 100644 --- a/mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi +++ b/mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi @@ -1,7 +1,7 @@ from _typeshed import StrPath from lib2to3.pgen2 import grammar from lib2to3.pgen2.tokenize import _TokenInfo -from typing import IO, Any, Iterable, Iterator, NoReturn, Tuple +from typing import IO, Any, Iterable, Iterator, NoReturn class PgenGrammar(grammar.Grammar): ... @@ -16,21 +16,21 @@ class ParserGenerator: def make_label(self, c: PgenGrammar, label: str) -> int: ... def addfirstsets(self) -> None: ... def calcfirst(self, name: str) -> None: ... - def parse(self) -> Tuple[dict[str, list[DFAState]], str]: ... + def parse(self) -> tuple[dict[str, list[DFAState]], str]: ... def make_dfa(self, start: NFAState, finish: NFAState) -> list[DFAState]: ... def dump_nfa(self, name: str, start: NFAState, finish: NFAState) -> list[DFAState]: ... def dump_dfa(self, name: str, dfa: Iterable[DFAState]) -> None: ... def simplify_dfa(self, dfa: list[DFAState]) -> None: ... - def parse_rhs(self) -> Tuple[NFAState, NFAState]: ... - def parse_alt(self) -> Tuple[NFAState, NFAState]: ... - def parse_item(self) -> Tuple[NFAState, NFAState]: ... - def parse_atom(self) -> Tuple[NFAState, NFAState]: ... + def parse_rhs(self) -> tuple[NFAState, NFAState]: ... + def parse_alt(self) -> tuple[NFAState, NFAState]: ... + def parse_item(self) -> tuple[NFAState, NFAState]: ... + def parse_atom(self) -> tuple[NFAState, NFAState]: ... def expect(self, type: int, value: Any | None = ...) -> str: ... def gettoken(self) -> None: ... def raise_error(self, msg: str, *args: Any) -> NoReturn: ... class NFAState: - arcs: list[Tuple[str | None, NFAState]] + arcs: list[tuple[str | None, NFAState]] def __init__(self) -> None: ... def addarc(self, next: NFAState, label: str | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi b/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi index 467fb0de25b9..e96a0d8c8eb3 100644 --- a/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi @@ -17,7 +17,7 @@ class Untokenizer: def __init__(self) -> None: ... def add_whitespace(self, start: _Coord) -> None: ... def untokenize(self, iterable: Iterable[_TokenInfo]) -> str: ... - def compat(self, token: Tuple[int, str], iterable: Iterable[_TokenInfo]) -> None: ... + def compat(self, token: tuple[int, str], iterable: Iterable[_TokenInfo]) -> None: ... def untokenize(iterable: Iterable[_TokenInfo]) -> str: ... def generate_tokens(readline: Callable[[], str]) -> Iterator[_TokenInfo]: ... diff --git a/mypy/typeshed/stdlib/lib2to3/pytree.pyi b/mypy/typeshed/stdlib/lib2to3/pytree.pyi index f926e6f7f8b3..eab82cbc200d 100644 --- a/mypy/typeshed/stdlib/lib2to3/pytree.pyi +++ b/mypy/typeshed/stdlib/lib2to3/pytree.pyi @@ -68,7 +68,7 @@ class BasePattern: def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns def match(self, node: _NL, results: _Results | None = ...) -> bool: ... def match_seq(self, nodes: list[_NL], results: _Results | None = ...) -> bool: ... - def generate_matches(self, nodes: list[_NL]) -> Iterator[Tuple[int, _Results]]: ... + def generate_matches(self, nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ... class LeafPattern(BasePattern): def __init__(self, type: int | None = ..., content: str | None = ..., name: str | None = ...) -> None: ... @@ -85,4 +85,4 @@ class WildcardPattern(BasePattern): class NegatedPattern(BasePattern): def __init__(self, content: str | None = ...) -> None: ... -def generate_matches(patterns: list[BasePattern], nodes: list[_NL]) -> Iterator[Tuple[int, _Results]]: ... +def generate_matches(patterns: list[BasePattern], nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ... diff --git a/mypy/typeshed/stdlib/locale.pyi b/mypy/typeshed/stdlib/locale.pyi index fa2e7885ae9d..1f80c8a62483 100644 --- a/mypy/typeshed/stdlib/locale.pyi +++ b/mypy/typeshed/stdlib/locale.pyi @@ -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/mypy/typeshed/stdlib/logging/config.pyi b/mypy/typeshed/stdlib/logging/config.pyi index f84865e35f92..cb9ad5995d9d 100644 --- a/mypy/typeshed/stdlib/logging/config.pyi +++ b/mypy/typeshed/stdlib/logging/config.pyi @@ -3,12 +3,14 @@ from _typeshed import StrOrBytesPath, StrPath from collections.abc import Callable from configparser import RawConfigParser from threading import Thread -from typing import IO, Any, Pattern +from typing import IO, Any, Pattern, Sequence + +from . import _Level if sys.version_info >= (3, 8): - from typing import Literal + from typing import Literal, TypedDict else: - from typing_extensions import Literal + from typing_extensions import Literal, TypedDict if sys.version_info >= (3, 7): _Path = StrOrBytesPath @@ -19,7 +21,29 @@ DEFAULT_LOGGING_CONFIG_PORT: int RESET_ERROR: int # undocumented IDENTIFIER: Pattern[str] # undocumented -def dictConfig(config: dict[str, Any]) -> None: ... +class _RootLoggerConfiguration(TypedDict, total=False): + level: _Level + filters: Sequence[str] + handlers: Sequence[str] + +class _LoggerConfiguration(_RootLoggerConfiguration, TypedDict, total=False): + propagate: bool + +class _OptionalDictConfigArgs(TypedDict, total=False): + # these two can have custom factories (key: `()`) which can have extra keys + formatters: dict[str, dict[str, Any]] + filters: dict[str, dict[str, Any]] + # type checkers would warn about extra keys if this was a TypedDict + handlers: dict[str, dict[str, Any]] + loggers: dict[str, _LoggerConfiguration] + root: _RootLoggerConfiguration | None + incremental: bool + disable_existing_loggers: bool + +class _DictConfigArgs(_OptionalDictConfigArgs, TypedDict): + version: Literal[1] + +def dictConfig(config: _DictConfigArgs) -> None: ... if sys.version_info >= (3, 10): def fileConfig( diff --git a/mypy/typeshed/stdlib/macpath.pyi b/mypy/typeshed/stdlib/macpath.pyi index 5657adde9a84..2512e086b735 100644 --- a/mypy/typeshed/stdlib/macpath.pyi +++ b/mypy/typeshed/stdlib/macpath.pyi @@ -32,7 +32,7 @@ from posixpath import ( splitext as splitext, supports_unicode_filenames as supports_unicode_filenames, ) -from typing import AnyStr, Tuple, overload +from typing import AnyStr, overload altsep: str | None @@ -64,6 +64,6 @@ def join(s: StrPath, *paths: StrPath) -> str: ... @overload def join(s: BytesPath, *paths: BytesPath) -> bytes: ... @overload -def split(s: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... +def split(s: PathLike[AnyStr]) -> tuple[AnyStr, AnyStr]: ... @overload -def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +def split(s: AnyStr) -> tuple[AnyStr, AnyStr]: ... diff --git a/mypy/typeshed/stdlib/mailbox.pyi b/mypy/typeshed/stdlib/mailbox.pyi index 544760cc5e8c..ffd9c3005cec 100644 --- a/mypy/typeshed/stdlib/mailbox.pyi +++ b/mypy/typeshed/stdlib/mailbox.pyi @@ -13,7 +13,6 @@ from typing import ( Mapping, Protocol, Sequence, - Tuple, Type, TypeVar, Union, @@ -29,10 +28,10 @@ _MessageT = TypeVar("_MessageT", bound=Message) _MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]] class _HasIteritems(Protocol): - def iteritems(self) -> Iterator[Tuple[str, _MessageData]]: ... + def iteritems(self) -> Iterator[tuple[str, _MessageData]]: ... class _HasItems(Protocol): - def items(self) -> Iterator[Tuple[str, _MessageData]]: ... + def items(self) -> Iterator[tuple[str, _MessageData]]: ... linesep: bytes @@ -63,8 +62,8 @@ class Mailbox(Generic[_MessageT]): def itervalues(self) -> Iterator[_MessageT]: ... def __iter__(self) -> Iterator[_MessageT]: ... def values(self) -> list[_MessageT]: ... - def iteritems(self) -> Iterator[Tuple[str, _MessageT]]: ... - def items(self) -> list[Tuple[str, _MessageT]]: ... + def iteritems(self) -> Iterator[tuple[str, _MessageT]]: ... + def items(self) -> list[tuple[str, _MessageT]]: ... def __contains__(self, key: str) -> bool: ... def __len__(self) -> int: ... def clear(self) -> None: ... @@ -72,8 +71,8 @@ class Mailbox(Generic[_MessageT]): def pop(self, key: str, default: None = ...) -> _MessageT | None: ... @overload def pop(self, key: str, default: _T = ...) -> _MessageT | _T: ... - def popitem(self) -> Tuple[str, _MessageT]: ... - def update(self, arg: _HasIteritems | _HasItems | Iterable[Tuple[str, _MessageData]] | None = ...) -> None: ... + def popitem(self) -> tuple[str, _MessageT]: ... + def update(self, arg: _HasIteritems | _HasItems | Iterable[tuple[str, _MessageData]] | None = ...) -> None: ... def flush(self) -> None: ... def lock(self) -> None: ... def unlock(self) -> None: ... @@ -149,7 +148,7 @@ class MaildirMessage(Message): class _mboxMMDFMessage(Message): def get_from(self) -> str: ... - def set_from(self, from_: str, time_: bool | Tuple[int, int, int, int, int, int, int, int, int] | None = ...) -> None: ... + def set_from(self, from_: str, time_: bool | tuple[int, int, int, int, int, int, int, int, int] | None = ...) -> None: ... def get_flags(self) -> str: ... def set_flags(self, flags: Iterable[str]) -> None: ... def add_flag(self, flag: str) -> None: ... diff --git a/mypy/typeshed/stdlib/mailcap.pyi b/mypy/typeshed/stdlib/mailcap.pyi index 2d4008f48c6c..9eaa771ed3d3 100644 --- a/mypy/typeshed/stdlib/mailcap.pyi +++ b/mypy/typeshed/stdlib/mailcap.pyi @@ -1,8 +1,8 @@ -from typing import Dict, Mapping, Sequence, Tuple, Union +from typing import Dict, Mapping, Sequence, Union _Cap = Dict[str, Union[str, int]] def findmatch( caps: Mapping[str, list[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... -) -> Tuple[str | None, _Cap | None]: ... +) -> tuple[str | None, _Cap | None]: ... def getcaps() -> dict[str, list[_Cap]]: ... diff --git a/mypy/typeshed/stdlib/math.pyi b/mypy/typeshed/stdlib/math.pyi index 1046676bec4a..19042962b28f 100644 --- a/mypy/typeshed/stdlib/math.pyi +++ b/mypy/typeshed/stdlib/math.pyi @@ -1,6 +1,9 @@ import sys from _typeshed import SupportsTrunc -from typing import Iterable, SupportsFloat, SupportsInt, Tuple, overload +from typing import Iterable, SupportsFloat, Union, overload +from typing_extensions import SupportsIndex + +_SupportsFloatOrIndex = Union[SupportsFloat, SupportsIndex] e: float pi: float @@ -8,94 +11,100 @@ inf: float nan: float tau: float -def acos(__x: SupportsFloat) -> float: ... -def acosh(__x: SupportsFloat) -> float: ... -def asin(__x: SupportsFloat) -> float: ... -def asinh(__x: SupportsFloat) -> float: ... -def atan(__x: SupportsFloat) -> float: ... -def atan2(__y: SupportsFloat, __x: SupportsFloat) -> float: ... -def atanh(__x: SupportsFloat) -> float: ... -def ceil(__x: SupportsFloat) -> int: ... +def acos(__x: _SupportsFloatOrIndex) -> float: ... +def acosh(__x: _SupportsFloatOrIndex) -> float: ... +def asin(__x: _SupportsFloatOrIndex) -> float: ... +def asinh(__x: _SupportsFloatOrIndex) -> float: ... +def atan(__x: _SupportsFloatOrIndex) -> float: ... +def atan2(__y: _SupportsFloatOrIndex, __x: _SupportsFloatOrIndex) -> float: ... +def atanh(__x: _SupportsFloatOrIndex) -> float: ... +def ceil(__x: _SupportsFloatOrIndex) -> int: ... if sys.version_info >= (3, 8): - def comb(__n: int, __k: int) -> int: ... + def comb(__n: SupportsIndex, __k: SupportsIndex) -> int: ... -def copysign(__x: SupportsFloat, __y: SupportsFloat) -> float: ... -def cos(__x: SupportsFloat) -> float: ... -def cosh(__x: SupportsFloat) -> float: ... -def degrees(__x: SupportsFloat) -> float: ... +def copysign(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ... +def cos(__x: _SupportsFloatOrIndex) -> float: ... +def cosh(__x: _SupportsFloatOrIndex) -> float: ... +def degrees(__x: _SupportsFloatOrIndex) -> float: ... if sys.version_info >= (3, 8): - def dist(__p: Iterable[SupportsFloat], __q: Iterable[SupportsFloat]) -> float: ... - -def erf(__x: SupportsFloat) -> float: ... -def erfc(__x: SupportsFloat) -> float: ... -def exp(__x: SupportsFloat) -> float: ... -def expm1(__x: SupportsFloat) -> float: ... -def fabs(__x: SupportsFloat) -> float: ... -def factorial(__x: SupportsInt) -> int: ... -def floor(__x: SupportsFloat) -> int: ... -def fmod(__x: SupportsFloat, __y: SupportsFloat) -> float: ... -def frexp(__x: SupportsFloat) -> Tuple[float, int]: ... -def fsum(__seq: Iterable[float]) -> float: ... -def gamma(__x: SupportsFloat) -> float: ... + def dist(__p: Iterable[_SupportsFloatOrIndex], __q: Iterable[_SupportsFloatOrIndex]) -> float: ... + +def erf(__x: _SupportsFloatOrIndex) -> float: ... +def erfc(__x: _SupportsFloatOrIndex) -> float: ... +def exp(__x: _SupportsFloatOrIndex) -> float: ... +def expm1(__x: _SupportsFloatOrIndex) -> float: ... +def fabs(__x: _SupportsFloatOrIndex) -> float: ... +def factorial(__x: SupportsIndex) -> int: ... +def floor(__x: _SupportsFloatOrIndex) -> int: ... +def fmod(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ... +def frexp(__x: _SupportsFloatOrIndex) -> tuple[float, int]: ... +def fsum(__seq: Iterable[_SupportsFloatOrIndex]) -> float: ... +def gamma(__x: _SupportsFloatOrIndex) -> float: ... if sys.version_info >= (3, 9): - def gcd(*integers: int) -> int: ... + def gcd(*integers: SupportsIndex) -> int: ... else: - def gcd(__x: int, __y: int) -> int: ... + def gcd(__x: SupportsIndex, __y: SupportsIndex) -> int: ... if sys.version_info >= (3, 8): - def hypot(*coordinates: SupportsFloat) -> float: ... + def hypot(*coordinates: _SupportsFloatOrIndex) -> float: ... else: - def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... - -def isclose(a: SupportsFloat, b: SupportsFloat, *, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... -def isinf(__x: SupportsFloat) -> bool: ... -def isfinite(__x: SupportsFloat) -> bool: ... -def isnan(__x: SupportsFloat) -> bool: ... + def hypot(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ... + +def isclose( + a: _SupportsFloatOrIndex, + b: _SupportsFloatOrIndex, + *, + rel_tol: _SupportsFloatOrIndex = ..., + abs_tol: _SupportsFloatOrIndex = ..., +) -> bool: ... +def isinf(__x: _SupportsFloatOrIndex) -> bool: ... +def isfinite(__x: _SupportsFloatOrIndex) -> bool: ... +def isnan(__x: _SupportsFloatOrIndex) -> bool: ... if sys.version_info >= (3, 8): - def isqrt(__n: int) -> int: ... + def isqrt(__n: SupportsIndex) -> int: ... if sys.version_info >= (3, 9): - def lcm(*integers: int) -> int: ... + def lcm(*integers: SupportsIndex) -> int: ... -def ldexp(__x: SupportsFloat, __i: int) -> float: ... -def lgamma(__x: SupportsFloat) -> float: ... -def log(x: SupportsFloat, base: SupportsFloat = ...) -> float: ... -def log10(__x: SupportsFloat) -> float: ... -def log1p(__x: SupportsFloat) -> float: ... -def log2(__x: SupportsFloat) -> float: ... -def modf(__x: SupportsFloat) -> Tuple[float, float]: ... +def ldexp(__x: _SupportsFloatOrIndex, __i: int) -> float: ... +def lgamma(__x: _SupportsFloatOrIndex) -> float: ... +def log(x: _SupportsFloatOrIndex, base: _SupportsFloatOrIndex = ...) -> float: ... +def log10(__x: _SupportsFloatOrIndex) -> float: ... +def log1p(__x: _SupportsFloatOrIndex) -> float: ... +def log2(__x: _SupportsFloatOrIndex) -> float: ... +def modf(__x: _SupportsFloatOrIndex) -> tuple[float, float]: ... if sys.version_info >= (3, 9): - def nextafter(__x: SupportsFloat, __y: SupportsFloat) -> float: ... + def nextafter(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ... if sys.version_info >= (3, 8): - def perm(__n: int, __k: int | None = ...) -> int: ... + def perm(__n: SupportsIndex, __k: SupportsIndex | None = ...) -> int: ... -def pow(__x: SupportsFloat, __y: SupportsFloat) -> float: ... +def pow(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ... if sys.version_info >= (3, 8): @overload - def prod(__iterable: Iterable[int], *, start: int = ...) -> int: ... # type: ignore + def prod(__iterable: Iterable[SupportsIndex], *, start: SupportsIndex = ...) -> int: ... # type: ignore @overload - def prod(__iterable: Iterable[SupportsFloat], *, start: SupportsFloat = ...) -> float: ... + def prod(__iterable: Iterable[_SupportsFloatOrIndex], *, start: _SupportsFloatOrIndex = ...) -> float: ... -def radians(__x: SupportsFloat) -> float: ... +def radians(__x: _SupportsFloatOrIndex) -> float: ... if sys.version_info >= (3, 7): - def remainder(__x: SupportsFloat, __y: SupportsFloat) -> float: ... + def remainder(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ... -def sin(__x: SupportsFloat) -> float: ... -def sinh(__x: SupportsFloat) -> float: ... -def sqrt(__x: SupportsFloat) -> float: ... -def tan(__x: SupportsFloat) -> float: ... -def tanh(__x: SupportsFloat) -> float: ... +def sin(__x: _SupportsFloatOrIndex) -> float: ... +def sinh(__x: _SupportsFloatOrIndex) -> float: ... +def sqrt(__x: _SupportsFloatOrIndex) -> float: ... +def tan(__x: _SupportsFloatOrIndex) -> float: ... +def tanh(__x: _SupportsFloatOrIndex) -> float: ... def trunc(__x: SupportsTrunc) -> int: ... if sys.version_info >= (3, 9): - def ulp(__x: SupportsFloat) -> float: ... + def ulp(__x: _SupportsFloatOrIndex) -> float: ... diff --git a/mypy/typeshed/stdlib/mimetypes.pyi b/mypy/typeshed/stdlib/mimetypes.pyi index 5a3ec91acbcd..90c87d2cf385 100644 --- a/mypy/typeshed/stdlib/mimetypes.pyi +++ b/mypy/typeshed/stdlib/mimetypes.pyi @@ -3,10 +3,10 @@ from _typeshed import StrPath from typing import IO, Sequence, Tuple if sys.version_info >= (3, 8): - def guess_type(url: StrPath, strict: bool = ...) -> Tuple[str | None, str | None]: ... + def guess_type(url: StrPath, strict: bool = ...) -> tuple[str | None, str | None]: ... else: - def guess_type(url: str, strict: bool = ...) -> Tuple[str | None, str | None]: ... + def guess_type(url: str, strict: bool = ...) -> tuple[str | None, str | None]: ... def guess_all_extensions(type: str, strict: bool = ...) -> list[str]: ... def guess_extension(type: str, strict: bool = ...) -> str | None: ... @@ -24,11 +24,11 @@ common_types: dict[str, str] class MimeTypes: suffix_map: dict[str, str] encodings_map: dict[str, str] - types_map: Tuple[dict[str, str], dict[str, str]] - types_map_inv: Tuple[dict[str, str], 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 guess_extension(self, type: str, strict: bool = ...) -> str | None: ... - def guess_type(self, url: str, strict: bool = ...) -> Tuple[str | None, 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]: ... def read(self, filename: str, strict: bool = ...) -> None: ... def readfp(self, fp: IO[str], strict: bool = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/modulefinder.pyi b/mypy/typeshed/stdlib/modulefinder.pyi index 89f8bd45f106..e77a108e9525 100644 --- a/mypy/typeshed/stdlib/modulefinder.pyi +++ b/mypy/typeshed/stdlib/modulefinder.pyi @@ -6,7 +6,7 @@ LOAD_CONST: int # undocumented IMPORT_NAME: int # undocumented STORE_NAME: int # undocumented STORE_GLOBAL: int # undocumented -STORE_OPS: Tuple[int, int] # undocumented +STORE_OPS: tuple[int, int] # undocumented EXTENDED_ARG: int # undocumented packagePathMap: dict[str, list[str]] # undocumented @@ -29,7 +29,7 @@ class ModuleFinder: debug: int # undocumented indent: int # undocumented excludes: Container[str] # undocumented - replace_paths: Sequence[Tuple[str, str]] # undocumented + replace_paths: Sequence[tuple[str, str]] # undocumented if sys.version_info >= (3, 8): def __init__( @@ -37,7 +37,7 @@ class ModuleFinder: path: list[str] | None = ..., debug: int = ..., excludes: Container[str] | None = ..., - replace_paths: Sequence[Tuple[str, str]] | None = ..., + replace_paths: Sequence[tuple[str, str]] | None = ..., ) -> None: ... else: def __init__( @@ -45,7 +45,7 @@ class ModuleFinder: path: list[str] | None = ..., debug: int = ..., excludes: Container[str] = ..., - replace_paths: Sequence[Tuple[str, str]] = ..., + replace_paths: Sequence[tuple[str, str]] = ..., ) -> None: ... def msg(self, level: int, str: str, *args: Any) -> None: ... # undocumented def msgin(self, *args: Any) -> None: ... # undocumented @@ -56,20 +56,20 @@ class ModuleFinder: self, name: str, caller: Module | None = ..., fromlist: list[str] | None = ..., level: int = ... ) -> Module | None: ... # undocumented def determine_parent(self, caller: Module | None, level: int = ...) -> Module | None: ... # undocumented - def find_head_package(self, parent: Module, name: str) -> Tuple[Module, str]: ... # undocumented + def find_head_package(self, parent: Module, name: str) -> tuple[Module, str]: ... # undocumented def load_tail(self, q: Module, tail: str) -> Module: ... # undocumented def ensure_fromlist(self, m: Module, fromlist: Iterable[str], recursive: int = ...) -> None: ... # undocumented 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 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_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 def find_module( self, name: str, path: str | None, parent: Module | None = ... - ) -> Tuple[IO[Any] | None, str | None, Tuple[str, str, int]]: ... # undocumented + ) -> tuple[IO[Any] | None, str | None, tuple[str, str, int]]: ... # undocumented def report(self) -> None: ... def any_missing(self) -> list[str]: ... # undocumented - def any_missing_maybe(self) -> Tuple[list[str], list[str]]: ... # undocumented + def any_missing_maybe(self) -> tuple[list[str], list[str]]: ... # undocumented def replace_paths_in_code(self, co: CodeType) -> CodeType: ... # undocumented diff --git a/mypy/typeshed/stdlib/msilib/__init__.pyi b/mypy/typeshed/stdlib/msilib/__init__.pyi index ca05ee6f4309..d72c8efc8452 100644 --- a/mypy/typeshed/stdlib/msilib/__init__.pyi +++ b/mypy/typeshed/stdlib/msilib/__init__.pyi @@ -25,14 +25,14 @@ if sys.platform == "win32": class Table: name: str - fields: list[Tuple[int, str, int]] + fields: list[tuple[int, str, int]] def __init__(self, name: str) -> None: ... def add_field(self, index: int, name: str, type: int) -> None: ... def sql(self) -> str: ... def create(self, db: _Database) -> None: ... class _Unspecified: ... def change_sequence( - seq: Sequence[Tuple[str, str | None, int]], + seq: Sequence[tuple[str, str | None, int]], action: str, seqno: int | Type[_Unspecified] = ..., cond: str | Type[_Unspecified] = ..., @@ -48,12 +48,12 @@ if sys.platform == "win32": class CAB: name: str - files: list[Tuple[str, str]] + files: list[tuple[str, str]] filenames: Set[str] index: int def __init__(self, name: str) -> None: ... def gen_id(self, file: str) -> str: ... - def append(self, full: str, file: str, logical: str) -> Tuple[int, str]: ... + def append(self, full: str, file: str, logical: str) -> tuple[int, str]: ... def commit(self, db: _Database) -> None: ... _directories: Set[str] class Directory: diff --git a/mypy/typeshed/stdlib/msilib/schema.pyi b/mypy/typeshed/stdlib/msilib/schema.pyi index df57ade15a2f..4ad9a1783fcd 100644 --- a/mypy/typeshed/stdlib/msilib/schema.pyi +++ b/mypy/typeshed/stdlib/msilib/schema.pyi @@ -1,5 +1,4 @@ import sys -from typing import Tuple if sys.platform == "win32": from . import Table @@ -92,4 +91,4 @@ if sys.platform == "win32": tables: list[Table] - _Validation_records: list[Tuple[str, str, str, int | None, int | None, str | None, int | None, str | None, str | None, str]] + _Validation_records: list[tuple[str, str, str, int | None, int | None, str | None, int | None, str | None, str | None, str]] diff --git a/mypy/typeshed/stdlib/msilib/text.pyi b/mypy/typeshed/stdlib/msilib/text.pyi index fe2dc23830e0..879429ecea85 100644 --- a/mypy/typeshed/stdlib/msilib/text.pyi +++ b/mypy/typeshed/stdlib/msilib/text.pyi @@ -1,9 +1,8 @@ import sys -from typing import Tuple if sys.platform == "win32": - ActionText: list[Tuple[str, str, str | None]] - UIText: list[Tuple[str, str | None]] + ActionText: list[tuple[str, str, str | None]] + UIText: list[tuple[str, str | None]] tables: list[str] diff --git a/mypy/typeshed/stdlib/multiprocessing/connection.pyi b/mypy/typeshed/stdlib/multiprocessing/connection.pyi index 4f6dc1ba7efa..56ea5c7c0b0b 100644 --- a/mypy/typeshed/stdlib/multiprocessing/connection.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/connection.pyi @@ -60,4 +60,4 @@ def wait( object_list: Iterable[Connection | socket.socket | int], timeout: float | None = ... ) -> list[Connection | socket.socket | int]: ... def Client(address: _Address, family: str | None = ..., authkey: bytes | None = ...) -> Connection: ... -def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ... +def Pipe(duplex: bool = ...) -> tuple[Connection, Connection]: ... diff --git a/mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi b/mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi index 71e9a50fab21..4ef3d095911f 100644 --- a/mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi @@ -35,4 +35,4 @@ class Listener(object): def close(self) -> None: ... def Client(address: _Address) -> Connection: ... -def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ... +def Pipe(duplex: bool = ...) -> tuple[Connection, Connection]: ... diff --git a/mypy/typeshed/stdlib/multiprocessing/managers.pyi b/mypy/typeshed/stdlib/multiprocessing/managers.pyi index 568845bfb9e4..22a33f226c0b 100644 --- a/mypy/typeshed/stdlib/multiprocessing/managers.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/managers.pyi @@ -30,12 +30,12 @@ _Namespace = Namespace class Token(object): typeid: str | bytes | None - address: Tuple[str | bytes, int] + address: tuple[str | bytes, int] id: str | bytes | int | None - def __init__(self, typeid: bytes | str | None, address: Tuple[str | bytes, int], id: str | bytes | int | None) -> None: ... + def __init__(self, typeid: bytes | str | None, address: tuple[str | bytes, int], id: str | bytes | int | None) -> None: ... def __repr__(self) -> str: ... - def __getstate__(self) -> Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]: ... - def __setstate__(self, state: Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]) -> None: ... + def __getstate__(self) -> tuple[str | bytes | None, tuple[str | bytes, int], str | bytes | int | None]: ... + def __setstate__(self, state: tuple[str | bytes | None, tuple[str | bytes, int], str | bytes | int | None]) -> None: ... class BaseProxy(object): _address_to_local: dict[Any, Any] @@ -53,7 +53,7 @@ class BaseProxy(object): def __deepcopy__(self, memo: Any | None) -> Any: ... 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]]]: ... + def __reduce__(self) -> tuple[Any, tuple[Any, Any, str, dict[Any, Any]]]: ... class ValueProxy(BaseProxy, Generic[_T]): def get(self) -> _T: ... @@ -66,7 +66,7 @@ class ValueProxy(BaseProxy, Generic[_T]): class Server: address: Any def __init__( - self, registry: dict[str, Tuple[Callable[..., Any], Any, Any, Any]], address: Any, authkey: bytes, serializer: str + self, registry: dict[str, tuple[Callable[..., Any], Any, Any, Any]], address: Any, authkey: bytes, serializer: str ) -> None: ... def serve_forever(self) -> None: ... def accept_connection(self, c: Connection, name: str) -> None: ... diff --git a/mypy/typeshed/stdlib/multiprocessing/pool.pyi b/mypy/typeshed/stdlib/multiprocessing/pool.pyi index 20cfc59633d5..75583aae8012 100644 --- a/mypy/typeshed/stdlib/multiprocessing/pool.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/pool.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self -from typing import Any, Callable, ContextManager, Dict, Generic, Iterable, Iterator, List, Mapping, TypeVar +from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias @@ -17,7 +17,7 @@ class ApplyResult(Generic[_T]): else: def __init__( self, - cache: Dict[int, ApplyResult[Any]], + cache: dict[int, ApplyResult[Any]], callback: Callable[[_T], None] | None, error_callback: Callable[[BaseException], None] | None, ) -> None: ... @@ -38,16 +38,16 @@ class MapResult(ApplyResult[List[_T]]): pool: Pool, chunksize: int, length: int, - callback: Callable[[List[_T]], None] | None, + callback: Callable[[list[_T]], None] | None, error_callback: Callable[[BaseException], None] | None, ) -> None: ... else: def __init__( self, - cache: Dict[int, ApplyResult[Any]], + cache: dict[int, ApplyResult[Any]], chunksize: int, length: int, - callback: Callable[[List[_T]], None] | None, + callback: Callable[[list[_T]], None] | None, error_callback: Callable[[BaseException], None] | None, ) -> None: ... @@ -55,7 +55,7 @@ class IMapIterator(Iterator[_T]): if sys.version_info >= (3, 8): def __init__(self, pool: Pool) -> None: ... else: - def __init__(self, cache: Dict[int, IMapIterator[Any]]) -> None: ... + def __init__(self, cache: dict[int, IMapIterator[Any]]) -> None: ... def __iter__(self: _S) -> _S: ... def next(self, timeout: float | None = ...) -> _T: ... def __next__(self, timeout: float | None = ...) -> _T: ... diff --git a/mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi b/mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi index 47669aa4bcb5..6ffc2542087a 100644 --- a/mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi @@ -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/mypy/typeshed/stdlib/nntplib.pyi b/mypy/typeshed/stdlib/nntplib.pyi index 4acb8b210a7a..508b5f679bc3 100644 --- a/mypy/typeshed/stdlib/nntplib.pyi +++ b/mypy/typeshed/stdlib/nntplib.pyi @@ -54,30 +54,30 @@ class _NNTPBase: def getcapabilities(self) -> dict[str, _list[str]]: ... def set_debuglevel(self, level: int) -> None: ... def debug(self, level: int) -> None: ... - def capabilities(self) -> Tuple[str, dict[str, _list[str]]]: ... - def newgroups(self, date: datetime.date | datetime.datetime, *, file: _File = ...) -> Tuple[str, _list[str]]: ... - def newnews(self, group: str, date: datetime.date | datetime.datetime, *, file: _File = ...) -> Tuple[str, _list[str]]: ... - def list(self, group_pattern: str | None = ..., *, file: _File = ...) -> Tuple[str, _list[str]]: ... + def capabilities(self) -> tuple[str, dict[str, _list[str]]]: ... + def newgroups(self, date: datetime.date | datetime.datetime, *, file: _File = ...) -> tuple[str, _list[str]]: ... + def newnews(self, group: str, date: datetime.date | datetime.datetime, *, file: _File = ...) -> tuple[str, _list[str]]: ... + def list(self, group_pattern: str | None = ..., *, file: _File = ...) -> tuple[str, _list[str]]: ... def description(self, group: str) -> str: ... - def descriptions(self, group_pattern: str) -> Tuple[str, dict[str, str]]: ... - def group(self, name: str) -> Tuple[str, int, int, int, str]: ... - def help(self, *, file: _File = ...) -> Tuple[str, _list[str]]: ... - def stat(self, message_spec: Any = ...) -> Tuple[str, int, str]: ... - def next(self) -> Tuple[str, int, str]: ... - def last(self) -> Tuple[str, int, str]: ... - def head(self, message_spec: Any = ..., *, file: _File = ...) -> Tuple[str, ArticleInfo]: ... - def body(self, message_spec: Any = ..., *, file: _File = ...) -> Tuple[str, ArticleInfo]: ... - def article(self, message_spec: Any = ..., *, file: _File = ...) -> Tuple[str, ArticleInfo]: ... + def descriptions(self, group_pattern: str) -> tuple[str, dict[str, str]]: ... + def group(self, name: str) -> tuple[str, int, int, int, str]: ... + def help(self, *, file: _File = ...) -> tuple[str, _list[str]]: ... + def stat(self, message_spec: Any = ...) -> tuple[str, int, str]: ... + def next(self) -> tuple[str, int, str]: ... + def last(self) -> tuple[str, int, str]: ... + def head(self, message_spec: Any = ..., *, file: _File = ...) -> tuple[str, ArticleInfo]: ... + def body(self, message_spec: Any = ..., *, file: _File = ...) -> tuple[str, ArticleInfo]: ... + def article(self, message_spec: Any = ..., *, file: _File = ...) -> tuple[str, ArticleInfo]: ... def slave(self) -> str: ... - 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 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 = ... - ) -> Tuple[str, _list[Tuple[int, dict[str, str]]]]: ... + ) -> 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]]]: ... - def xpath(self, id: Any) -> Tuple[str, str]: ... - def date(self) -> Tuple[str, datetime.datetime]: ... + def xgtitle(self, group: str, *, file: _File = ...) -> tuple[str, _list[tuple[str, str]]]: ... + def xpath(self, id: Any) -> tuple[str, str]: ... + def date(self) -> tuple[str, datetime.datetime]: ... def post(self, data: bytes | Iterable[bytes]) -> str: ... def ihave(self, message_id: Any, data: bytes | Iterable[bytes]) -> str: ... def quit(self) -> str: ... diff --git a/mypy/typeshed/stdlib/ntpath.pyi b/mypy/typeshed/stdlib/ntpath.pyi index d454d7f93fbf..45d715704157 100644 --- a/mypy/typeshed/stdlib/ntpath.pyi +++ b/mypy/typeshed/stdlib/ntpath.pyi @@ -42,11 +42,11 @@ from posixpath import ( splitext as splitext, supports_unicode_filenames as supports_unicode_filenames, ) -from typing import AnyStr, Tuple, overload +from typing import AnyStr, overload altsep: str if sys.version_info < (3, 7) and sys.platform == "win32": - def splitunc(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated + def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated # Similar to posixpath, but have slightly different argument names @overload diff --git a/mypy/typeshed/stdlib/operator.pyi b/mypy/typeshed/stdlib/operator.pyi index c9fe47c4a70f..5cbfda7a84d1 100644 --- a/mypy/typeshed/stdlib/operator.pyi +++ b/mypy/typeshed/stdlib/operator.pyi @@ -120,11 +120,11 @@ class attrgetter(Generic[_T_co]): @overload def __new__(cls, attr: str) -> attrgetter[Any]: ... @overload - def __new__(cls, attr: str, __attr2: str) -> attrgetter[Tuple[Any, Any]]: ... + def __new__(cls, attr: str, __attr2: str) -> attrgetter[tuple[Any, Any]]: ... @overload - def __new__(cls, attr: str, __attr2: str, __attr3: str) -> attrgetter[Tuple[Any, Any, Any]]: ... + def __new__(cls, attr: str, __attr2: str, __attr3: str) -> attrgetter[tuple[Any, Any, Any]]: ... @overload - def __new__(cls, attr: str, __attr2: str, __attr3: str, __attr4: str) -> attrgetter[Tuple[Any, Any, Any, Any]]: ... + 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 __call__(self, obj: Any) -> _T_co: ... @@ -133,11 +133,11 @@ class itemgetter(Generic[_T_co]): @overload def __new__(cls, item: Any) -> itemgetter[Any]: ... @overload - def __new__(cls, item: Any, __item2: Any) -> itemgetter[Tuple[Any, Any]]: ... + def __new__(cls, item: Any, __item2: Any) -> itemgetter[tuple[Any, Any]]: ... @overload - def __new__(cls, item: Any, __item2: Any, __item3: Any) -> itemgetter[Tuple[Any, Any, Any]]: ... + def __new__(cls, item: Any, __item2: Any, __item3: Any) -> itemgetter[tuple[Any, Any, Any]]: ... @overload - def __new__(cls, item: Any, __item2: Any, __item3: Any, __item4: Any) -> itemgetter[Tuple[Any, Any, Any, Any]]: ... + 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 __call__(self, obj: Any) -> _T_co: ... diff --git a/mypy/typeshed/stdlib/optparse.pyi b/mypy/typeshed/stdlib/optparse.pyi index 38c7746a9ff8..b8ea9d2fff38 100644 --- a/mypy/typeshed/stdlib/optparse.pyi +++ b/mypy/typeshed/stdlib/optparse.pyi @@ -201,7 +201,7 @@ class OptionParser(OptionContainer): def add_option_group(self, __opt_group: OptionGroup) -> OptionGroup: ... @overload def add_option_group(self, *args: Any, **kwargs: Any) -> OptionGroup: ... - def check_values(self, values: Values, args: list[str]) -> Tuple[Values, list[str]]: ... + def check_values(self, values: Values, args: list[str]) -> tuple[Values, list[str]]: ... def disable_interspersed_args(self) -> None: ... def enable_interspersed_args(self) -> None: ... def error(self, msg: str) -> None: ... @@ -215,7 +215,7 @@ class OptionParser(OptionContainer): def get_prog_name(self) -> str: ... def get_usage(self) -> str: ... def get_version(self) -> str: ... - def parse_args(self, args: Sequence[AnyStr] | None = ..., values: Values | None = ...) -> Tuple[Values, list[AnyStr]]: ... + def parse_args(self, args: Sequence[AnyStr] | None = ..., values: Values | None = ...) -> tuple[Values, list[AnyStr]]: ... def print_usage(self, file: IO[str] | None = ...) -> None: ... def print_help(self, file: IO[str] | None = ...) -> None: ... def print_version(self, file: IO[str] | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/os/__init__.pyi b/mypy/typeshed/stdlib/os/__init__.pyi index 9af9aa34a6ca..b2bfa0d64d14 100644 --- a/mypy/typeshed/stdlib/os/__init__.pyi +++ b/mypy/typeshed/stdlib/os/__init__.pyi @@ -398,8 +398,8 @@ if sys.platform != "win32": def getpriority(which: int, who: int) -> int: ... def setpriority(which: int, who: int, priority: int) -> None: ... if sys.platform != "darwin": - def getresuid() -> Tuple[int, int, int]: ... - def getresgid() -> Tuple[int, int, int]: ... + def getresuid() -> tuple[int, int, int]: ... + def getresgid() -> tuple[int, int, int]: ... def getuid() -> int: ... def setegid(__egid: int) -> None: ... def seteuid(__euid: int) -> None: ... @@ -528,7 +528,7 @@ def fstat(fd: int) -> stat_result: ... def fsync(fd: FileDescriptorLike) -> None: ... def lseek(__fd: int, __position: int, __how: int) -> int: ... def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: int | None = ...) -> int: ... -def pipe() -> Tuple[int, int]: ... +def pipe() -> tuple[int, int]: ... def read(__fd: int, __length: int) -> bytes: ... if sys.platform != "win32": @@ -544,9 +544,9 @@ if sys.platform != "win32": def set_blocking(__fd: int, __blocking: bool) -> None: ... def isatty(__fd: int) -> bool: ... def lockf(__fd: int, __command: int, __length: int) -> None: ... - def openpty() -> Tuple[int, int]: ... # some flavors of Unix + def openpty() -> tuple[int, int]: ... # some flavors of Unix if sys.platform != "darwin": - def pipe2(flags: int) -> Tuple[int, int]: ... # some flavors of Unix + def pipe2(flags: int) -> tuple[int, int]: ... # some flavors of Unix def posix_fallocate(fd: int, offset: int, length: int) -> None: ... def posix_fadvise(fd: int, offset: int, length: int, advice: int) -> None: ... def pread(__fd: int, __length: int, __offset: int) -> bytes: ... @@ -675,9 +675,9 @@ def truncate(path: _FdOrAnyPath, length: int) -> None: ... # Unix only up to ve def unlink(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... def utime( path: _FdOrAnyPath, - times: Tuple[int, int] | Tuple[float, float] | None = ..., + times: tuple[int, int] | tuple[float, float] | None = ..., *, - ns: Tuple[int, int] = ..., + ns: tuple[int, int] = ..., dir_fd: int | None = ..., follow_symlinks: bool = ..., ) -> None: ... @@ -686,7 +686,7 @@ _OnError = Callable[[OSError], Any] def walk( top: AnyStr | PathLike[AnyStr], topdown: bool = ..., onerror: _OnError | None = ..., followlinks: bool = ... -) -> Iterator[Tuple[AnyStr, list[AnyStr], list[AnyStr]]]: ... +) -> Iterator[tuple[AnyStr, list[AnyStr], list[AnyStr]]]: ... if sys.platform != "win32": if sys.version_info >= (3, 7): @@ -698,7 +698,7 @@ if sys.platform != "win32": *, follow_symlinks: bool = ..., dir_fd: int | None = ..., - ) -> Iterator[Tuple[str, list[str], list[str], int]]: ... + ) -> Iterator[tuple[str, list[str], list[str], int]]: ... @overload def fwalk( top: bytes, @@ -707,7 +707,7 @@ if sys.platform != "win32": *, follow_symlinks: bool = ..., dir_fd: int | None = ..., - ) -> Iterator[Tuple[bytes, list[bytes], list[bytes], int]]: ... + ) -> Iterator[tuple[bytes, list[bytes], list[bytes], int]]: ... else: def fwalk( top: StrPath = ..., @@ -716,7 +716,7 @@ if sys.platform != "win32": *, follow_symlinks: bool = ..., dir_fd: int | None = ..., - ) -> Iterator[Tuple[str, list[str], list[str], int]]: ... + ) -> Iterator[tuple[str, list[str], list[str], int]]: ... if sys.platform == "linux": def getxattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> bytes: ... def listxattr(path: _FdOrAnyPath | None = ..., *, follow_symlinks: bool = ...) -> list[str]: ... @@ -762,7 +762,7 @@ def kill(__pid: int, __signal: int) -> None: ... if sys.platform != "win32": # Unix only def fork() -> int: ... - def forkpty() -> Tuple[int, int]: ... # some flavors of Unix + def forkpty() -> tuple[int, int]: ... # some flavors of Unix def killpg(__pgid: int, __signal: int) -> None: ... def nice(__increment: int) -> int: ... if sys.platform != "darwin": @@ -786,7 +786,7 @@ else: def system(command: StrOrBytesPath) -> int: ... def times() -> times_result: ... -def waitpid(__pid: int, __options: int) -> Tuple[int, int]: ... +def waitpid(__pid: int, __options: int) -> tuple[int, int]: ... if sys.platform == "win32": def startfile(path: StrOrBytesPath, operation: str | None = ...) -> None: ... @@ -797,12 +797,12 @@ else: def spawnlpe(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: ... # Imprecise signature def spawnvp(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: ... def spawnvpe(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: ... - def wait() -> Tuple[int, int]: ... # Unix only + def wait() -> tuple[int, int]: ... # Unix only if sys.platform != "darwin": from posix import waitid_result def waitid(idtype: int, ident: int, options: int) -> waitid_result: ... - def wait3(options: int) -> Tuple[int, int, Any]: ... - def wait4(pid: int, options: int) -> Tuple[int, int, Any]: ... + def wait3(options: int) -> tuple[int, int, Any]: ... + def wait4(pid: int, options: int) -> tuple[int, int, Any]: ... def WCOREDUMP(__status: int) -> bool: ... def WIFCONTINUED(status: int) -> bool: ... def WIFSTOPPED(status: int) -> bool: ... @@ -833,7 +833,7 @@ def cpu_count() -> int | None: ... if sys.platform != "win32": # Unix only def confstr(__name: str | int) -> str | None: ... - def getloadavg() -> Tuple[float, float, float]: ... + def getloadavg() -> tuple[float, float, float]: ... def sysconf(__name: str | int) -> int: ... if sys.platform == "linux": diff --git a/mypy/typeshed/stdlib/pdb.pyi b/mypy/typeshed/stdlib/pdb.pyi index 0a25786d409f..83bd32d76450 100644 --- a/mypy/typeshed/stdlib/pdb.pyi +++ b/mypy/typeshed/stdlib/pdb.pyi @@ -4,7 +4,7 @@ from bdb import Bdb from cmd import Cmd from inspect import _SourceObjectType from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, ClassVar, Iterable, Mapping, Sequence, Tuple, TypeVar +from typing import IO, Any, Callable, ClassVar, Iterable, Mapping, Sequence, TypeVar _T = TypeVar("_T") @@ -41,7 +41,7 @@ class Pdb(Bdb, Cmd): commands_defining: bool commands_bnum: int | None lineno: int | None - stack: list[Tuple[FrameType, int]] + stack: list[tuple[FrameType, int]] curindex: int curframe: FrameType | None curframe_locals: Mapping[str, Any] @@ -62,11 +62,11 @@ class Pdb(Bdb, Cmd): def displayhook(self, obj: object) -> None: ... def handle_command_def(self, line: str) -> bool: ... def defaultFile(self) -> str: ... - def lineinfo(self, identifier: str) -> Tuple[None, None, None] | Tuple[str, str, int]: ... + def lineinfo(self, identifier: str) -> tuple[None, None, None] | tuple[str, str, int]: ... def checkline(self, filename: str, lineno: int) -> int: ... def _getval(self, arg: str) -> object: ... def print_stack_trace(self) -> None: ... - def print_stack_entry(self, frame_lineno: Tuple[FrameType, int], prompt_prefix: str = ...) -> None: ... + def print_stack_entry(self, frame_lineno: tuple[FrameType, int], prompt_prefix: str = ...) -> None: ... def lookupmodule(self, filename: str) -> str | None: ... def _runscript(self, filename: str) -> None: ... def do_commands(self, arg: str) -> bool | None: ... @@ -164,10 +164,10 @@ class Pdb(Bdb, Cmd): # undocumented -def find_function(funcname: str, filename: str) -> Tuple[str, str, int] | None: ... +def find_function(funcname: str, filename: str) -> tuple[str, str, int] | None: ... def main() -> None: ... def help() -> None: ... -def getsourcelines(obj: _SourceObjectType) -> Tuple[list[str], int]: ... +def getsourcelines(obj: _SourceObjectType) -> tuple[list[str], int]: ... def lasti2lineno(code: CodeType, lasti: int) -> int: ... class _rstr(str): diff --git a/mypy/typeshed/stdlib/pickletools.pyi b/mypy/typeshed/stdlib/pickletools.pyi index 0f0fb47da5f9..9fa51a3848ee 100644 --- a/mypy/typeshed/stdlib/pickletools.pyi +++ b/mypy/typeshed/stdlib/pickletools.pyi @@ -152,7 +152,7 @@ class OpcodeInfo(object): opcodes: list[OpcodeInfo] -def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Any | None, int | None]]: ... +def genops(pickle: bytes | IO[bytes]) -> Iterator[tuple[OpcodeInfo, Any | None, int | None]]: ... def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( pickle: bytes | IO[bytes], diff --git a/mypy/typeshed/stdlib/pkgutil.pyi b/mypy/typeshed/stdlib/pkgutil.pyi index 54e0f22e4915..e0f392fd91d8 100644 --- a/mypy/typeshed/stdlib/pkgutil.pyi +++ b/mypy/typeshed/stdlib/pkgutil.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import SupportsRead from importlib.abc import Loader, MetaPathFinder, PathEntryFinder -from typing import IO, Any, Callable, Iterable, Iterator, NamedTuple, Tuple +from typing import IO, Any, Callable, Iterable, Iterator, NamedTuple class ModuleInfo(NamedTuple): module_finder: MetaPathFinder | PathEntryFinder @@ -14,7 +14,7 @@ class ImpImporter: def __init__(self, path: str | None = ...) -> None: ... class ImpLoader: - def __init__(self, fullname: str, file: IO[str], filename: str, etc: Tuple[str, str, int]) -> None: ... + def __init__(self, fullname: str, file: IO[str], filename: str, etc: tuple[str, str, int]) -> None: ... def find_loader(fullname: str) -> Loader | None: ... def get_importer(path_item: str) -> PathEntryFinder | None: ... diff --git a/mypy/typeshed/stdlib/platform.pyi b/mypy/typeshed/stdlib/platform.pyi index d0f08a20fcd6..7db2d59ff7ea 100644 --- a/mypy/typeshed/stdlib/platform.pyi +++ b/mypy/typeshed/stdlib/platform.pyi @@ -7,10 +7,10 @@ if sys.version_info < (3, 8): from typing import NamedTuple, Tuple if sys.version_info >= (3, 8): - def libc_ver(executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ... + def libc_ver(executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> tuple[str, str]: ... else: - def libc_ver(executable: str = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ... + def libc_ver(executable: str = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> tuple[str, str]: ... if sys.version_info < (3, 8): def linux_distribution( @@ -19,25 +19,25 @@ if sys.version_info < (3, 8): id: str = ..., supported_dists: Tuple[str, ...] = ..., full_distribution_name: bool = ..., - ) -> Tuple[str, str, str]: ... + ) -> tuple[str, str, str]: ... def dist( distname: str = ..., version: str = ..., id: str = ..., supported_dists: Tuple[str, ...] = ... - ) -> Tuple[str, str, str]: ... + ) -> tuple[str, str, str]: ... -def win32_ver(release: str = ..., version: str = ..., csd: str = ..., ptype: str = ...) -> Tuple[str, str, str, str]: ... +def win32_ver(release: str = ..., version: str = ..., csd: str = ..., ptype: str = ...) -> tuple[str, str, str, str]: ... if sys.version_info >= (3, 8): def win32_edition() -> str: ... def win32_is_iot() -> bool: ... def mac_ver( - release: str = ..., versioninfo: Tuple[str, str, str] = ..., machine: str = ... -) -> Tuple[str, Tuple[str, str, str], str]: ... + release: str = ..., versioninfo: tuple[str, str, str] = ..., machine: str = ... +) -> tuple[str, tuple[str, str, str], str]: ... def java_ver( - release: str = ..., vendor: str = ..., vminfo: Tuple[str, str, str] = ..., osinfo: Tuple[str, str, str] = ... -) -> Tuple[str, str, Tuple[str, str, str], Tuple[str, str, str]]: ... -def system_alias(system: str, release: str, version: str) -> Tuple[str, str, str]: ... -def architecture(executable: str = ..., bits: str = ..., linkage: str = ...) -> Tuple[str, str]: ... + release: str = ..., vendor: str = ..., vminfo: tuple[str, str, str] = ..., osinfo: tuple[str, str, str] = ... +) -> tuple[str, str, tuple[str, str, str], tuple[str, str, str]]: ... +def system_alias(system: str, release: str, version: str) -> tuple[str, str, str]: ... +def architecture(executable: str = ..., bits: str = ..., linkage: str = ...) -> tuple[str, str]: ... class uname_result(NamedTuple): system: str @@ -56,9 +56,9 @@ def machine() -> str: ... def processor() -> str: ... def python_implementation() -> str: ... def python_version() -> str: ... -def python_version_tuple() -> Tuple[str, str, str]: ... +def python_version_tuple() -> tuple[str, str, str]: ... def python_branch() -> str: ... def python_revision() -> str: ... -def python_build() -> Tuple[str, str]: ... +def python_build() -> tuple[str, str]: ... def python_compiler() -> str: ... def platform(aliased: bool = ..., terse: bool = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/plistlib.pyi b/mypy/typeshed/stdlib/plistlib.pyi index 93d4fdc2480a..07b6963746be 100644 --- a/mypy/typeshed/stdlib/plistlib.pyi +++ b/mypy/typeshed/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, List, Mapping, MutableMapping, Tuple, Type +from typing import IO, Any, Dict as _Dict, Mapping, MutableMapping, Tuple, 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 = ..., diff --git a/mypy/typeshed/stdlib/poplib.pyi b/mypy/typeshed/stdlib/poplib.pyi index 8d19067f0445..28fba4ce951f 100644 --- a/mypy/typeshed/stdlib/poplib.pyi +++ b/mypy/typeshed/stdlib/poplib.pyi @@ -12,6 +12,8 @@ CR: bytes LF: bytes CRLF: bytes +_list = list # conflicts with a method named "list" + class POP3: encoding: str host: str @@ -24,7 +26,7 @@ class POP3: def set_debuglevel(self, level: int) -> None: ... def user(self, user: str) -> bytes: ... def pass_(self, pswd: str) -> bytes: ... - def stat(self) -> Tuple[int, int]: ... + def stat(self) -> tuple[int, int]: ... def list(self, which: Any | None = ...) -> _LongResp: ... def retr(self, which: Any) -> _LongResp: ... def dele(self, which: Any) -> bytes: ... @@ -41,7 +43,7 @@ class POP3: @overload def uidl(self, which: Any) -> bytes: ... def utf8(self) -> bytes: ... - def capa(self) -> dict[str, List[str]]: ... + def capa(self) -> dict[str, _list[str]]: ... def stls(self, context: ssl.SSLContext | None = ...) -> bytes: ... class POP3_SSL(POP3): diff --git a/mypy/typeshed/stdlib/posix.pyi b/mypy/typeshed/stdlib/posix.pyi index aef3b54413a4..4993371b5333 100644 --- a/mypy/typeshed/stdlib/posix.pyi +++ b/mypy/typeshed/stdlib/posix.pyi @@ -179,7 +179,7 @@ if sys.platform != "win32" and sys.version_info >= (3, 8): setsid: bool = ..., setsigmask: Iterable[int] = ..., setsigdef: Iterable[int] = ..., - scheduler: Tuple[Any, sched_param] | None = ..., + scheduler: tuple[Any, sched_param] | None = ..., ) -> int: ... def posix_spawnp( path: StrOrBytesPath, @@ -192,7 +192,7 @@ if sys.platform != "win32" and sys.version_info >= (3, 8): setsid: bool = ..., setsigmask: Iterable[int] = ..., setsigdef: Iterable[int] = ..., - scheduler: Tuple[Any, sched_param] | None = ..., + scheduler: tuple[Any, sched_param] | None = ..., ) -> int: ... if sys.platform == "win32": diff --git a/mypy/typeshed/stdlib/posixpath.pyi b/mypy/typeshed/stdlib/posixpath.pyi index cc5e5cb8ed50..ae3d0d5cc65f 100644 --- a/mypy/typeshed/stdlib/posixpath.pyi +++ b/mypy/typeshed/stdlib/posixpath.pyi @@ -14,7 +14,7 @@ from genericpath import ( samestat as samestat, ) from os import PathLike -from typing import AnyStr, Sequence, Tuple, overload +from typing import AnyStr, Sequence, overload supports_unicode_filenames: bool # aliases (also in os) @@ -82,18 +82,18 @@ def relpath(path: BytesPath, start: BytesPath | None = ...) -> bytes: ... @overload def relpath(path: StrPath, start: StrPath | None = ...) -> str: ... @overload -def split(p: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... +def split(p: PathLike[AnyStr]) -> tuple[AnyStr, AnyStr]: ... @overload -def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +def split(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... @overload -def splitdrive(p: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... +def splitdrive(p: PathLike[AnyStr]) -> tuple[AnyStr, AnyStr]: ... @overload -def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +def splitdrive(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... @overload -def splitext(p: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... +def splitext(p: PathLike[AnyStr]) -> tuple[AnyStr, AnyStr]: ... @overload -def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +def splitext(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... def isabs(s: StrOrBytesPath) -> bool: ... -def islink(path: StrOrBytesPath) -> bool: ... -def ismount(path: StrOrBytesPath) -> bool: ... -def lexists(path: StrOrBytesPath) -> bool: ... +def islink(path: StrOrBytesPath | int) -> bool: ... +def ismount(path: StrOrBytesPath | int) -> bool: ... +def lexists(path: StrOrBytesPath | int) -> bool: ... diff --git a/mypy/typeshed/stdlib/pprint.pyi b/mypy/typeshed/stdlib/pprint.pyi index dcf3fd6b81da..9e343feb49bc 100644 --- a/mypy/typeshed/stdlib/pprint.pyi +++ b/mypy/typeshed/stdlib/pprint.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, Tuple +from typing import IO, Any if sys.version_info >= (3, 10): def pformat( @@ -130,4 +130,4 @@ class PrettyPrinter: def pprint(self, object: object) -> None: ... def isreadable(self, object: object) -> bool: ... def isrecursive(self, object: object) -> bool: ... - def format(self, object: object, context: dict[int, Any], maxlevels: int, level: int) -> Tuple[str, bool, bool]: ... + def format(self, object: object, context: dict[int, Any], maxlevels: int, level: int) -> tuple[str, bool, bool]: ... diff --git a/mypy/typeshed/stdlib/pstats.pyi b/mypy/typeshed/stdlib/pstats.pyi index 6811ec94b349..e8256f9f98ab 100644 --- a/mypy/typeshed/stdlib/pstats.pyi +++ b/mypy/typeshed/stdlib/pstats.pyi @@ -21,7 +21,7 @@ if sys.version_info >= (3, 7): TIME: str class Stats: - sort_arg_dict_default: dict[str, Tuple[Any, str]] + sort_arg_dict_default: dict[str, tuple[Any, str]] def __init__( self: _T, __arg: None | str | Profile | _cProfile = ..., @@ -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 @@ -41,8 +41,8 @@ class Stats: def reverse_order(self: _T) -> _T: ... def strip_dirs(self: _T) -> _T: ... def calc_callees(self) -> None: ... - def eval_print_amount(self, sel: _Selector, list: list[str], msg: str) -> Tuple[list[str], str]: ... - def get_print_list(self, sel_list: Iterable[_Selector]) -> Tuple[int, list[str]]: ... + def eval_print_amount(self, sel: _Selector, list: list[str], msg: str) -> tuple[list[str], str]: ... + def get_print_list(self, sel_list: Iterable[_Selector]) -> tuple[int, list[str]]: ... def print_stats(self: _T, *amount: _Selector) -> _T: ... def print_callees(self: _T, *amount: _Selector) -> _T: ... def print_callers(self: _T, *amount: _Selector) -> _T: ... diff --git a/mypy/typeshed/stdlib/pty.pyi b/mypy/typeshed/stdlib/pty.pyi index ba6b9b40edc0..f943cebdb157 100644 --- a/mypy/typeshed/stdlib/pty.pyi +++ b/mypy/typeshed/stdlib/pty.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Iterable, Tuple +from typing import Callable, Iterable _Reader = Callable[[int], bytes] @@ -8,8 +8,8 @@ STDERR_FILENO: int CHILD: int -def openpty() -> Tuple[int, int]: ... -def master_open() -> Tuple[int, str]: ... +def openpty() -> tuple[int, int]: ... +def master_open() -> tuple[int, str]: ... def slave_open(tty_name: str) -> int: ... -def fork() -> Tuple[int, int]: ... +def fork() -> tuple[int, int]: ... def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... diff --git a/mypy/typeshed/stdlib/pydoc.pyi b/mypy/typeshed/stdlib/pydoc.pyi index 778a2e535706..97e71f389616 100644 --- a/mypy/typeshed/stdlib/pydoc.pyi +++ b/mypy/typeshed/stdlib/pydoc.pyi @@ -13,7 +13,7 @@ __credits__: str def pathdirs() -> list[str]: ... def getdoc(object: object) -> str: ... -def splitdoc(doc: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +def splitdoc(doc: AnyStr) -> tuple[AnyStr, AnyStr]: ... def classname(object: object, modname: str) -> str: ... def isdata(object: object) -> bool: ... def replace(text: AnyStr, *pairs: AnyStr) -> AnyStr: ... @@ -21,10 +21,10 @@ def cram(text: str, maxlen: int) -> str: ... def stripid(text: str) -> str: ... def allmethods(cl: type) -> MutableMapping[str, MethodType]: ... def visiblename(name: str, all: Container[str] | None = ..., obj: object | None = ...) -> bool: ... -def classify_class_attrs(object: object) -> list[Tuple[str, str, type, str]]: ... +def classify_class_attrs(object: object) -> list[tuple[str, str, type, str]]: ... def ispackage(path: str) -> bool: ... def source_synopsis(file: IO[AnyStr]) -> AnyStr | None: ... -def synopsis(filename: str, cache: MutableMapping[str, Tuple[int, str]] = ...) -> str | None: ... +def synopsis(filename: str, cache: MutableMapping[str, tuple[int, str]] = ...) -> str | None: ... class ErrorDuringImport(Exception): filename: str @@ -86,7 +86,7 @@ class HTMLDoc(Doc): def namelink(self, name: str, *dicts: MutableMapping[str, str]) -> str: ... def classlink(self, object: object, modname: str) -> str: ... def modulelink(self, object: object) -> str: ... - def modpkglink(self, modpkginfo: Tuple[str, str, bool, bool]) -> str: ... + def modpkglink(self, modpkginfo: tuple[str, str, bool, bool]) -> str: ... def markup( self, text: 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( @@ -148,7 +148,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 = ..., *ignored: Any) -> str: ... def docclass(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... @@ -188,7 +188,7 @@ html: HTMLDoc class _OldStyleClass: ... -def resolve(thing: str | object, forceload: bool = ...) -> Tuple[object, str] | None: ... +def resolve(thing: str | object, forceload: bool = ...) -> tuple[object, str] | None: ... def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Doc | None = ...) -> str: ... def doc(thing: str | object, title: str = ..., forceload: bool = ..., output: SupportsWrite[str] | None = ...) -> None: ... def writedoc(thing: str | object, forceload: bool = ...) -> None: ... @@ -197,7 +197,7 @@ def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... _list = list # "list" conflicts with method name class Helper: - keywords: dict[str, str | Tuple[str, str]] + keywords: dict[str, str | tuple[str, str]] symbols: dict[str, str] topics: dict[str, str | Tuple[str, ...]] def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/pyexpat/__init__.pyi b/mypy/typeshed/stdlib/pyexpat/__init__.pyi index 95c1f98d5652..d1993496aee7 100644 --- a/mypy/typeshed/stdlib/pyexpat/__init__.pyi +++ b/mypy/typeshed/stdlib/pyexpat/__init__.pyi @@ -4,9 +4,9 @@ from _typeshed import SupportsRead from typing import Any, Callable, Optional, Tuple EXPAT_VERSION: str # undocumented -version_info: Tuple[int, int, int] # undocumented +version_info: tuple[int, int, int] # undocumented native_encoding: str # undocumented -features: list[Tuple[str, int]] # undocumented +features: list[tuple[str, int]] # undocumented class ExpatError(Exception): code: int diff --git a/mypy/typeshed/stdlib/re.pyi b/mypy/typeshed/stdlib/re.pyi index f2869470dfcf..01a60d170c50 100644 --- a/mypy/typeshed/stdlib/re.pyi +++ b/mypy/typeshed/stdlib/re.pyi @@ -1,7 +1,7 @@ import enum import sys from sre_constants import error as error -from typing import Any, AnyStr, Callable, Iterator, Tuple, Union, overload +from typing import Any, AnyStr, Callable, Iterator, Union, overload # ----- re variables and constants ----- if sys.version_info >= (3, 7): @@ -99,19 +99,19 @@ def sub( pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ... ) -> AnyStr: ... @overload -def subn(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> Tuple[AnyStr, int]: ... +def subn(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> tuple[AnyStr, int]: ... @overload def subn( pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ... -) -> Tuple[AnyStr, int]: ... +) -> tuple[AnyStr, int]: ... @overload def subn( pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ... -) -> Tuple[AnyStr, int]: ... +) -> tuple[AnyStr, int]: ... @overload def subn( pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ... -) -> Tuple[AnyStr, int]: ... +) -> tuple[AnyStr, int]: ... def escape(pattern: AnyStr) -> AnyStr: ... def purge() -> None: ... def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ... diff --git a/mypy/typeshed/stdlib/resource.pyi b/mypy/typeshed/stdlib/resource.pyi index 742e43814bcc..d7124edcc2fa 100644 --- a/mypy/typeshed/stdlib/resource.pyi +++ b/mypy/typeshed/stdlib/resource.pyi @@ -45,14 +45,14 @@ class struct_rusage(_Tuple16): ru_nivcsw: int def getpagesize() -> int: ... -def getrlimit(__resource: int) -> Tuple[int, int]: ... +def getrlimit(__resource: int) -> tuple[int, int]: ... def getrusage(__who: int) -> struct_rusage: ... -def setrlimit(__resource: int, __limits: Tuple[int, int]) -> None: ... +def setrlimit(__resource: int, __limits: tuple[int, int]) -> None: ... if sys.platform == "linux": @overload - def prlimit(pid: int, resource: int, limits: Tuple[int, int]) -> Tuple[int, int]: ... + def prlimit(pid: int, resource: int, limits: tuple[int, int]) -> tuple[int, int]: ... @overload - def prlimit(pid: int, resource: int) -> Tuple[int, int]: ... + def prlimit(pid: int, resource: int) -> tuple[int, int]: ... error = OSError diff --git a/mypy/typeshed/stdlib/select.pyi b/mypy/typeshed/stdlib/select.pyi index fd503dc0033a..0329dbaa2c11 100644 --- a/mypy/typeshed/stdlib/select.pyi +++ b/mypy/typeshed/stdlib/select.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike, Self from types import TracebackType -from typing import Any, Iterable, Tuple, Type +from typing import Any, Iterable, Type if sys.platform != "win32": PIPE_BUF: int @@ -22,11 +22,11 @@ class poll: def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: float | None = ...) -> list[Tuple[int, int]]: ... + def poll(self, timeout: float | None = ...) -> list[tuple[int, int]]: ... def select( __rlist: Iterable[Any], __wlist: Iterable[Any], __xlist: Iterable[Any], __timeout: float | None = ... -) -> Tuple[list[Any], list[Any], list[Any]]: ... +) -> tuple[list[Any], list[Any], list[Any]]: ... error = OSError @@ -114,7 +114,7 @@ if sys.platform == "linux": def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: float | None = ..., maxevents: int = ...) -> list[Tuple[int, int]]: ... + def poll(self, timeout: float | None = ..., maxevents: int = ...) -> list[tuple[int, int]]: ... @classmethod def fromfd(cls, __fd: FileDescriptorLike) -> epoll: ... EPOLLERR: int @@ -140,4 +140,4 @@ if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: float | None = ...) -> list[Tuple[int, int]]: ... + def poll(self, timeout: float | None = ...) -> list[tuple[int, int]]: ... diff --git a/mypy/typeshed/stdlib/selectors.pyi b/mypy/typeshed/stdlib/selectors.pyi index a28dc1d53899..c3fe7ec47ace 100644 --- a/mypy/typeshed/stdlib/selectors.pyi +++ b/mypy/typeshed/stdlib/selectors.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptor, FileDescriptorLike, Self from abc import ABCMeta, abstractmethod -from typing import Any, Mapping, NamedTuple, Tuple +from typing import Any, Mapping, NamedTuple _EventMask = int @@ -21,7 +21,7 @@ class BaseSelector(metaclass=ABCMeta): def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... def modify(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... @abstractmethod - def select(self, timeout: float | None = ...) -> list[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ... def close(self) -> None: ... def get_key(self, fileobj: FileDescriptorLike) -> SelectorKey: ... @abstractmethod @@ -32,14 +32,14 @@ class BaseSelector(metaclass=ABCMeta): class SelectSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: float | None = ...) -> list[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... if sys.platform != "win32": class PollSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: float | None = ...) -> list[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... if sys.platform == "linux": @@ -47,25 +47,25 @@ if sys.platform == "linux": def fileno(self) -> int: ... def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: float | None = ...) -> list[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class DevpollSelector(BaseSelector): def fileno(self) -> int: ... def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: float | None = ...) -> list[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class KqueueSelector(BaseSelector): def fileno(self) -> int: ... def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: float | None = ...) -> list[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class DefaultSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: float | None = ...) -> list[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... diff --git a/mypy/typeshed/stdlib/shlex.pyi b/mypy/typeshed/stdlib/shlex.pyi index b517d03daf93..dfe554b0a773 100644 --- a/mypy/typeshed/stdlib/shlex.pyi +++ b/mypy/typeshed/stdlib/shlex.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Iterable, TextIO, Tuple, TypeVar +from typing import Any, Iterable, TextIO, TypeVar def split(s: str, comments: bool = ..., posix: bool = ...) -> list[str]: ... @@ -36,7 +36,7 @@ class shlex(Iterable[str]): def get_token(self) -> str: ... def push_token(self, tok: str) -> None: ... def read_token(self) -> str: ... - def sourcehook(self, newfile: str) -> Tuple[str, TextIO]: ... + def sourcehook(self, newfile: str) -> tuple[str, TextIO]: ... # TODO argument types def push_source(self, newstream: Any, newfile: Any = ...) -> None: ... def pop_source(self) -> None: ... diff --git a/mypy/typeshed/stdlib/shutil.pyi b/mypy/typeshed/stdlib/shutil.pyi index cd2f28c59825..12341d72e8c3 100644 --- a/mypy/typeshed/stdlib/shutil.pyi +++ b/mypy/typeshed/stdlib/shutil.pyi @@ -1,7 +1,7 @@ import os import sys -from _typeshed import StrPath, SupportsRead, SupportsWrite -from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, Set, Tuple, TypeVar, Union, overload +from _typeshed import StrOrBytesPath, StrPath, SupportsRead, SupportsWrite +from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, Set, TypeVar, Union, overload _PathT = TypeVar("_PathT", str, os.PathLike[str]) # Return value of some functions that may either return a path-like object that was passed in or @@ -60,7 +60,7 @@ class _ntuple_diskusage(NamedTuple): used: int free: int -def disk_usage(path: StrPath) -> _ntuple_diskusage: ... +def disk_usage(path: int | StrOrBytesPath) -> _ntuple_diskusage: ... def chown(path: StrPath, user: str | int | None = ..., group: str | int | None = ...) -> None: ... if sys.version_info >= (3, 8): @@ -83,11 +83,11 @@ def make_archive( group: str | None = ..., logger: Any | None = ..., ) -> str: ... -def get_archive_formats() -> list[Tuple[str, str]]: ... +def get_archive_formats() -> list[tuple[str, str]]: ... def register_archive_format( name: str, function: Callable[..., Any], - extra_args: Sequence[Tuple[str, Any] | list[Any]] | None = ..., + extra_args: Sequence[tuple[str, Any] | list[Any]] | None = ..., description: str = ..., ) -> None: ... def unregister_archive_format(name: str) -> None: ... @@ -100,8 +100,8 @@ else: def unpack_archive(filename: str, extract_dir: StrPath | None = ..., format: str | None = ...) -> None: ... def register_unpack_format( - name: str, extensions: list[str], function: Any, extra_args: Sequence[Tuple[str, Any]] | None = ..., description: str = ... + name: str, extensions: list[str], function: Any, extra_args: Sequence[tuple[str, Any]] | None = ..., description: str = ... ) -> None: ... def unregister_unpack_format(name: str) -> None: ... -def get_unpack_formats() -> list[Tuple[str, list[str], str]]: ... -def get_terminal_size(fallback: Tuple[int, int] = ...) -> os.terminal_size: ... +def get_unpack_formats() -> list[tuple[str, list[str], str]]: ... +def get_terminal_size(fallback: tuple[int, int] = ...) -> os.terminal_size: ... diff --git a/mypy/typeshed/stdlib/signal.pyi b/mypy/typeshed/stdlib/signal.pyi index 21ad232c7189..d36dbc2d6aa7 100644 --- a/mypy/typeshed/stdlib/signal.pyi +++ b/mypy/typeshed/stdlib/signal.pyi @@ -161,7 +161,7 @@ if sys.platform != "win32": def default_int_handler(signum: int, frame: FrameType) -> None: ... if sys.platform != "win32": - def getitimer(__which: int) -> Tuple[float, float]: ... + def getitimer(__which: int) -> tuple[float, float]: ... def getsignal(__signalnum: _SIGNUM) -> _HANDLER: ... @@ -182,7 +182,7 @@ else: def set_wakeup_fd(fd: int) -> int: ... if sys.platform != "win32": - def setitimer(__which: int, __seconds: float, __interval: float = ...) -> Tuple[float, float]: ... + def setitimer(__which: int, __seconds: float, __interval: float = ...) -> tuple[float, float]: ... def siginterrupt(__signalnum: int, __flag: bool) -> None: ... def signal(__signalnum: _SIGNUM, __handler: _HANDLER) -> _HANDLER: ... diff --git a/mypy/typeshed/stdlib/site.pyi b/mypy/typeshed/stdlib/site.pyi index fc331c113163..a73d188a7e5c 100644 --- a/mypy/typeshed/stdlib/site.pyi +++ b/mypy/typeshed/stdlib/site.pyi @@ -1,3 +1,4 @@ +from _typeshed import StrPath from typing import Iterable PREFIXES: list[str] @@ -6,7 +7,21 @@ USER_SITE: str | None USER_BASE: str | None def main() -> None: ... -def addsitedir(sitedir: str, known_paths: Iterable[str] | None = ...) -> None: ... +def abs_paths() -> None: ... # undocumented +def addpackage(sitedir: StrPath, name: StrPath, known_paths: set[str] | None) -> set[str] | None: ... # undocumented +def addsitedir(sitedir: str, known_paths: set[str] | None = ...) -> None: ... +def addsitepackages(known_paths: set[str] | None, prefixes: Iterable[str] | None = ...) -> set[str] | None: ... # undocumented +def addusersitepackages(known_paths: set[str] | None) -> set[str] | None: ... # undocumented +def check_enableusersite() -> bool | None: ... # undocumented +def enablerlcompleter() -> None: ... # undocumented +def execsitecustomize() -> None: ... # undocumented +def execusercustomize() -> None: ... # undocumented def getsitepackages(prefixes: Iterable[str] | None = ...) -> list[str]: ... def getuserbase() -> str: ... def getusersitepackages() -> str: ... +def makepath(*paths: StrPath) -> tuple[str, str]: ... # undocumented +def removeduppaths() -> set[str]: ... # undocumented +def setcopyright() -> None: ... # undocumented +def sethelper() -> None: ... # undocumented +def setquit() -> None: ... # undocumented +def venv(known_paths: set[str] | None) -> set[str] | None: ... # undocumented diff --git a/mypy/typeshed/stdlib/smtplib.pyi b/mypy/typeshed/stdlib/smtplib.pyi index 6b3b9bfad704..5dbdf5d44c29 100644 --- a/mypy/typeshed/stdlib/smtplib.pyi +++ b/mypy/typeshed/stdlib/smtplib.pyi @@ -24,19 +24,19 @@ class SMTPServerDisconnected(SMTPException): ... class SMTPResponseException(SMTPException): smtp_code: int smtp_error: bytes | str - args: Tuple[int, bytes | str] | Tuple[int, bytes, str] + args: tuple[int, bytes | str] | tuple[int, bytes, str] def __init__(self, code: int, msg: bytes | str) -> None: ... class SMTPSenderRefused(SMTPResponseException): smtp_code: int smtp_error: bytes sender: str - args: Tuple[int, bytes, str] + args: tuple[int, bytes, str] def __init__(self, code: int, msg: bytes, sender: str) -> None: ... class SMTPRecipientsRefused(SMTPException): recipients: _SendErrs - args: Tuple[_SendErrs] + args: tuple[_SendErrs] def __init__(self, recipients: _SendErrs) -> None: ... class SMTPDataError(SMTPResponseException): ... diff --git a/mypy/typeshed/stdlib/socket.pyi b/mypy/typeshed/stdlib/socket.pyi index f72115301ace..1f5ae6eb76c8 100644 --- a/mypy/typeshed/stdlib/socket.pyi +++ b/mypy/typeshed/stdlib/socket.pyi @@ -341,6 +341,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 8): if sys.platform == "linux" and sys.version_info >= (3, 9): from _socket import ( CAN_J1939 as CAN_J1939, + CAN_RAW_JOIN_FILTERS as CAN_RAW_JOIN_FILTERS, J1939_EE_INFO_NONE as J1939_EE_INFO_NONE, J1939_EE_INFO_TX_ABORT as J1939_EE_INFO_TX_ABORT, J1939_FILTER_MAX as J1939_FILTER_MAX, diff --git a/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi b/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi index abce96305c7b..fa817b089254 100644 --- a/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi +++ b/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, Tuple, Type, TypeVar +from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, Type, TypeVar _T = TypeVar("_T") @@ -16,8 +16,8 @@ def DateFromTicks(ticks: float) -> Date: ... def TimeFromTicks(ticks: float) -> Time: ... def TimestampFromTicks(ticks: float) -> Timestamp: ... -version_info: Tuple[int, int, int] -sqlite_version_info: Tuple[int, int, int] +version_info: tuple[int, int, int] +sqlite_version_info: tuple[int, int, int] Binary = memoryview # The remaining definitions are imported from _sqlite3. @@ -167,7 +167,7 @@ class Cursor(Iterator[Any]): description: Any lastrowid: Any row_factory: Any - rowcount: Any + rowcount: int # TODO: Cursor class accepts exactly 1 argument # required type is sqlite3.Connection (which is imported as _Connection) # however, the name of the __init__ variable is unknown diff --git a/mypy/typeshed/stdlib/sre_parse.pyi b/mypy/typeshed/stdlib/sre_parse.pyi index a242ca34afd2..f493bee945de 100644 --- a/mypy/typeshed/stdlib/sre_parse.pyi +++ b/mypy/typeshed/stdlib/sre_parse.pyi @@ -9,8 +9,8 @@ OCTDIGITS: FrozenSet[str] HEXDIGITS: FrozenSet[str] ASCIILETTERS: FrozenSet[str] WHITESPACE: FrozenSet[str] -ESCAPES: dict[str, Tuple[_NIC, int]] -CATEGORIES: dict[str, Tuple[_NIC, _NIC] | Tuple[_NIC, list[Tuple[_NIC, _NIC]]]] +ESCAPES: dict[str, tuple[_NIC, int]] +CATEGORIES: dict[str, tuple[_NIC, _NIC] | tuple[_NIC, list[tuple[_NIC, _NIC]]]] FLAGS: dict[str, int] GLOBAL_FLAGS: int diff --git a/mypy/typeshed/stdlib/ssl.pyi b/mypy/typeshed/stdlib/ssl.pyi index 759b992f6c1c..689b083d764c 100644 --- a/mypy/typeshed/stdlib/ssl.pyi +++ b/mypy/typeshed/stdlib/ssl.pyi @@ -96,13 +96,13 @@ else: _create_default_https_context: Callable[..., SSLContext] def RAND_bytes(__num: int) -> bytes: ... -def RAND_pseudo_bytes(__num: int) -> Tuple[bytes, bool]: ... +def RAND_pseudo_bytes(__num: int) -> tuple[bytes, bool]: ... def RAND_status() -> bool: ... def RAND_egd(path: str) -> None: ... def RAND_add(__s: bytes, __entropy: float) -> None: ... def match_hostname(cert: _PeerCertRetType, hostname: str) -> None: ... def cert_time_to_seconds(cert_time: str) -> int: ... -def get_server_certificate(addr: Tuple[str, int], ssl_version: int = ..., ca_certs: str | None = ...) -> str: ... +def get_server_certificate(addr: tuple[str, int], ssl_version: int = ..., ca_certs: str | None = ...) -> str: ... def DER_cert_to_PEM_cert(der_cert_bytes: bytes) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... @@ -213,7 +213,7 @@ HAS_NPN: bool CHANNEL_BINDING_TYPES: list[str] OPENSSL_VERSION: str -OPENSSL_VERSION_INFO: Tuple[int, int, int, int, int] +OPENSSL_VERSION_INFO: tuple[int, int, int, int, int] OPENSSL_VERSION_NUMBER: int class AlertDescription(enum.IntEnum): @@ -341,13 +341,13 @@ class SSLSocket(socket.socket): def getpeercert(self, binary_form: Literal[True]) -> bytes | None: ... @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... - def cipher(self) -> Tuple[str, str, int] | None: ... - def shared_ciphers(self) -> list[Tuple[str, str, int]] | None: ... + def cipher(self) -> tuple[str, str, int] | None: ... + def shared_ciphers(self) -> list[tuple[str, str, int]] | None: ... def compression(self) -> str | None: ... def get_channel_binding(self, cb_type: str = ...) -> bytes | None: ... def selected_alpn_protocol(self) -> str | None: ... def selected_npn_protocol(self) -> str | None: ... - def accept(self) -> Tuple[SSLSocket, socket._RetAddress]: ... + def accept(self) -> tuple[SSLSocket, socket._RetAddress]: ... def unwrap(self) -> socket.socket: ... def version(self) -> str | None: ... def pending(self) -> int: ... @@ -442,8 +442,8 @@ class SSLObject: def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... def selected_alpn_protocol(self) -> str | None: ... def selected_npn_protocol(self) -> str | None: ... - def cipher(self) -> Tuple[str, str, int] | None: ... - def shared_ciphers(self) -> list[Tuple[str, str, int]] | None: ... + def cipher(self) -> tuple[str, str, int] | None: ... + def shared_ciphers(self) -> list[tuple[str, str, int]] | None: ... def compression(self) -> str | None: ... def pending(self) -> int: ... def do_handshake(self) -> None: ... diff --git a/mypy/typeshed/stdlib/string.pyi b/mypy/typeshed/stdlib/string.pyi index 321b2647fbb2..374d59959ac9 100644 --- a/mypy/typeshed/stdlib/string.pyi +++ b/mypy/typeshed/stdlib/string.pyi @@ -1,6 +1,6 @@ import sys from re import RegexFlag -from typing import Any, Iterable, Mapping, Sequence, Tuple +from typing import Any, Iterable, Mapping, Sequence if sys.version_info >= (3, 8): from re import Pattern @@ -34,7 +34,7 @@ class Template: class Formatter: def format(self, __format_string: str, *args: Any, **kwargs: Any) -> str: ... def vformat(self, format_string: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> str: ... - def parse(self, format_string: str) -> Iterable[Tuple[str, str | None, str | None, str | None]]: ... + def parse(self, format_string: str) -> Iterable[tuple[str, str | None, str | None, str | None]]: ... def get_field(self, field_name: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... def get_value(self, key: int | str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... def check_unused_args(self, used_args: Sequence[int | str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... diff --git a/mypy/typeshed/stdlib/subprocess.pyi b/mypy/typeshed/stdlib/subprocess.pyi index ed8dce29363d..fce517745ee6 100644 --- a/mypy/typeshed/stdlib/subprocess.pyi +++ b/mypy/typeshed/stdlib/subprocess.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from types import TracebackType -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Type, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -1002,7 +1002,7 @@ class Popen(Generic[AnyStr]): input: AnyStr | None = ..., timeout: float | None = ..., # morally this should be optional - ) -> Tuple[AnyStr, AnyStr]: ... + ) -> tuple[AnyStr, AnyStr]: ... def send_signal(self, sig: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ... @@ -1014,9 +1014,14 @@ class Popen(Generic[AnyStr]): def __class_getitem__(cls, item: Any) -> GenericAlias: ... # The result really is always a str. -def getstatusoutput(cmd: _TXT) -> Tuple[int, str]: ... +def getstatusoutput(cmd: _TXT) -> tuple[int, str]: ... def getoutput(cmd: _TXT) -> str: ... -def list2cmdline(seq: Iterable[str]) -> str: ... # undocumented + +if sys.version_info >= (3, 8): + def list2cmdline(seq: Iterable[StrOrBytesPath]) -> str: ... # undocumented + +else: + def list2cmdline(seq: Iterable[str]) -> str: ... # undocumented if sys.platform == "win32": class STARTUPINFO: diff --git a/mypy/typeshed/stdlib/sys.pyi b/mypy/typeshed/stdlib/sys.pyi index 5ccf9dff714c..43d33ec62135 100644 --- a/mypy/typeshed/stdlib/sys.pyi +++ b/mypy/typeshed/stdlib/sys.pyi @@ -70,8 +70,8 @@ if sys.version_info >= (3, 9): prefix: str if sys.version_info >= (3, 8): pycache_prefix: str | None -ps1: str -ps2: str +ps1: object +ps2: object stdin: TextIO stdout: TextIO stderr: TextIO @@ -205,7 +205,7 @@ class _WinVersion(Tuple[int, int, int, int, str, int, int, int, int, Tuple[int, service_pack_major: int suite_mast: int product_type: int - platform_version: Tuple[int, int, int] + platform_version: tuple[int, int, int] if sys.platform == "win32": def getwindowsversion() -> _WinVersion: ... diff --git a/mypy/typeshed/stdlib/tabnanny.pyi b/mypy/typeshed/stdlib/tabnanny.pyi index 584c6d4e26bd..4c7be83b0511 100644 --- a/mypy/typeshed/stdlib/tabnanny.pyi +++ b/mypy/typeshed/stdlib/tabnanny.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import Iterable, Tuple +from typing import Iterable verbose: int filename_only: int @@ -11,4 +11,4 @@ class NannyNag(Exception): def get_line(self) -> str: ... def check(file: StrOrBytesPath) -> None: ... -def process_tokens(tokens: Iterable[Tuple[int, str, Tuple[int, int], Tuple[int, int], str]]) -> None: ... +def process_tokens(tokens: Iterable[tuple[int, str, tuple[int, int], tuple[int, int], str]]) -> None: ... diff --git a/mypy/typeshed/stdlib/telnetlib.pyi b/mypy/typeshed/stdlib/telnetlib.pyi index b9c984550c2c..cf00856d9332 100644 --- a/mypy/typeshed/stdlib/telnetlib.pyi +++ b/mypy/typeshed/stdlib/telnetlib.pyi @@ -1,6 +1,6 @@ import socket from _typeshed import Self -from typing import Any, Callable, Match, Pattern, Sequence, Tuple +from typing import Any, Callable, Match, Pattern, Sequence DEBUGLEVEL: int TELNET_PORT: int @@ -109,6 +109,6 @@ class Telnet: def listener(self) -> None: ... def expect( self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = ... - ) -> Tuple[int, Match[bytes] | None, bytes]: ... + ) -> tuple[int, Match[bytes] | None, bytes]: ... def __enter__(self: Self) -> Self: ... def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... diff --git a/mypy/typeshed/stdlib/tempfile.pyi b/mypy/typeshed/stdlib/tempfile.pyi index 270f506ed594..9f69f3da4778 100644 --- a/mypy/typeshed/stdlib/tempfile.pyi +++ b/mypy/typeshed/stdlib/tempfile.pyi @@ -334,11 +334,11 @@ class TemporaryDirectory(Generic[AnyStr]): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @overload -def mkstemp() -> Tuple[int, str]: ... +def mkstemp() -> tuple[int, str]: ... @overload def mkstemp( suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ..., text: bool = ... -) -> Tuple[int, AnyStr]: ... +) -> tuple[int, AnyStr]: ... @overload def mkdtemp() -> str: ... @overload diff --git a/mypy/typeshed/stdlib/time.pyi b/mypy/typeshed/stdlib/time.pyi index 039350c5b7ad..29bfebed62d3 100644 --- a/mypy/typeshed/stdlib/time.pyi +++ b/mypy/typeshed/stdlib/time.pyi @@ -7,7 +7,7 @@ _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] altzone: int daylight: int timezone: int -tzname: Tuple[str, str] +tzname: tuple[str, str] if sys.version_info >= (3, 7): if sys.platform == "linux": @@ -51,16 +51,16 @@ class _struct_time(NamedTuple): class struct_time(_struct_time): def __init__( self, - o: Tuple[int, int, int, int, int, int, int, int, int] - | Tuple[int, int, int, int, int, int, int, int, int, str] - | Tuple[int, int, int, int, int, int, int, int, int, str, int], + o: tuple[int, int, int, int, int, int, int, int, int] + | tuple[int, int, int, int, int, int, int, int, int, str] + | tuple[int, int, int, int, int, int, int, int, int, str, int], _arg: Any = ..., ) -> None: ... def __new__( cls, - o: Tuple[int, int, int, int, int, int, int, int, int] - | Tuple[int, int, int, int, int, int, int, int, int, str] - | Tuple[int, int, int, int, int, int, int, int, int, str, int], + o: tuple[int, int, int, int, int, int, int, int, int] + | tuple[int, int, int, int, int, int, int, int, int, str] + | tuple[int, int, int, int, int, int, int, int, int, str, int], _arg: Any = ..., ) -> struct_time: ... @property diff --git a/mypy/typeshed/stdlib/timeit.pyi b/mypy/typeshed/stdlib/timeit.pyi index 2a8330d1cee1..d82dd80598dc 100644 --- a/mypy/typeshed/stdlib/timeit.pyi +++ b/mypy/typeshed/stdlib/timeit.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Sequence, Tuple, Union +from typing import IO, Any, Callable, Sequence, Union _Timer = Callable[[], float] _Stmt = Union[str, Callable[[], Any]] @@ -12,7 +12,7 @@ class Timer: def print_exc(self, file: IO[str] | None = ...) -> None: ... def timeit(self, number: int = ...) -> float: ... def repeat(self, repeat: int = ..., number: int = ...) -> list[float]: ... - def autorange(self, callback: Callable[[int, float], Any] | None = ...) -> Tuple[int, float]: ... + def autorange(self, callback: Callable[[int, float], Any] | None = ...) -> tuple[int, float]: ... def timeit( stmt: _Stmt = ..., setup: _Stmt = ..., timer: _Timer = ..., number: int = ..., globals: dict[str, Any] | None = ... diff --git a/mypy/typeshed/stdlib/tkinter/__init__.pyi b/mypy/typeshed/stdlib/tkinter/__init__.pyi index 9ca63924f1ef..f994b843c5d4 100644 --- a/mypy/typeshed/stdlib/tkinter/__init__.pyi +++ b/mypy/typeshed/stdlib/tkinter/__init__.pyi @@ -68,23 +68,20 @@ EXCEPTION = _tkinter.EXCEPTION # something, then you may actually want Callable[something] | str, # because it's often possible to specify a string of Tcl code. # +# - If you think the correct type is Iterable[Foo] or Sequence[Foo], it is +# probably list[Foo] | tuple[Foo, ...], disallowing other sequences such +# as deques: +# +# >>> tkinter.Label(font=('Helvetica', 12, collections.deque(['bold']))) +# Traceback (most recent call last): +# ... +# _tkinter.TclError: unknown font style "deque(['bold'])" +# # - Some options can be set only in __init__, but all options are available # when getting their values with configure's return value or cget. # # - Asks other tkinter users if you haven't worked much with tkinter. -# _TkinterSequence[T] represents a sequence that tkinter understands. It -# differs from typing.Sequence[T]. For example, collections.deque a valid -# Sequence but not a valid _TkinterSequence: -# -# >>> tkinter.Label(font=('Helvetica', 12, collections.deque(['bold']))) -# Traceback (most recent call last): -# ... -# _tkinter.TclError: unknown font style "deque(['bold'])" -_T = TypeVar("_T") -_TkinterSequence = Union[List[_T], Tuple[_T, ...]] -_TkinterSequence2D = Union[List[List[_T]], List[Tuple[_T, ...]], Tuple[List[_T], ...], Tuple[Tuple[_T, ...], ...]] - # Some widgets have an option named -compound that accepts different values # than the _Compound defined here. Many other options have similar things. _Anchor = Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] # manual page: Tk_GetAnchor @@ -95,7 +92,7 @@ _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 _EntryValidateCommand = Union[ - Callable[[], bool], str, _TkinterSequence[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() @@ -186,7 +183,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 @@ -306,11 +303,11 @@ class Misc: def winfo_pathname(self, id: int, displayof: Literal[0] | Misc | None = ...): ... def winfo_pixels(self, number: _ScreenUnits) -> int: ... def winfo_pointerx(self) -> int: ... - def winfo_pointerxy(self) -> Tuple[int, int]: ... + def winfo_pointerxy(self) -> tuple[int, int]: ... def winfo_pointery(self) -> int: ... def winfo_reqheight(self) -> int: ... def winfo_reqwidth(self) -> int: ... - def winfo_rgb(self, color: _Color) -> Tuple[int, int, int]: ... + def winfo_rgb(self, color: _Color) -> tuple[int, int, int]: ... def winfo_rootx(self) -> int: ... def winfo_rooty(self) -> int: ... def winfo_screen(self) -> str: ... @@ -326,7 +323,7 @@ class Misc: def winfo_viewable(self) -> bool: ... def winfo_visual(self) -> str: ... def winfo_visualid(self) -> str: ... - def winfo_visualsavailable(self, includeids: int = ...) -> list[Tuple[str, int]]: ... + def winfo_visualsavailable(self, includeids: int = ...) -> list[tuple[str, int]]: ... def winfo_vrootheight(self) -> int: ... def winfo_vrootwidth(self) -> int: ... def winfo_vrootx(self) -> int: ... @@ -385,11 +382,11 @@ class Misc: @overload def grid_bbox( self, column: None = ..., row: None = ..., col2: None = ..., row2: None = ... - ) -> Tuple[int, int, int, int] | None: ... + ) -> tuple[int, int, int, int] | None: ... @overload - def grid_bbox(self, column: int, row: int, col2: None = ..., row2: None = ...) -> Tuple[int, int, int, int] | None: ... + def grid_bbox(self, column: int, row: int, col2: None = ..., row2: None = ...) -> tuple[int, int, int, int] | None: ... @overload - def grid_bbox(self, column: int, row: int, col2: int, row2: int) -> Tuple[int, int, int, int] | None: ... + def grid_bbox(self, column: int, row: int, col2: int, row2: int) -> tuple[int, int, int, int] | None: ... bbox = grid_bbox def grid_columnconfigure( self, @@ -413,12 +410,12 @@ class Misc: ) -> _GridIndexInfo | Any: ... # can be None but annoyying to check columnconfigure = grid_columnconfigure rowconfigure = grid_rowconfigure - def grid_location(self, x: _ScreenUnits, y: _ScreenUnits) -> Tuple[int, int]: ... + def grid_location(self, x: _ScreenUnits, y: _ScreenUnits) -> tuple[int, int]: ... @overload def grid_propagate(self, flag: bool) -> None: ... @overload def grid_propagate(self) -> bool: ... - def grid_size(self) -> Tuple[int, int]: ... + def grid_size(self) -> tuple[int, int]: ... size = grid_size # Widget because Toplevel or Tk is never a slave def pack_slaves(self) -> list[Widget]: ... @@ -478,7 +475,7 @@ class CallWrapper: class XView: @overload - def xview(self) -> Tuple[float, float]: ... + def xview(self) -> tuple[float, float]: ... @overload def xview(self, *args: Any) -> Any: ... def xview_moveto(self, fraction: float) -> None: ... @@ -489,7 +486,7 @@ class XView: class YView: @overload - def yview(self) -> Tuple[float, float]: ... + def yview(self) -> tuple[float, float]: ... @overload def yview(self, *args: Any) -> Any: ... def yview_moveto(self, fraction: float) -> None: ... @@ -504,7 +501,7 @@ class Wm: @overload def wm_aspect( self, minNumer: None = ..., minDenom: None = ..., maxNumer: None = ..., maxDenom: None = ... - ) -> Tuple[int, int, int, int] | None: ... + ) -> tuple[int, int, int, int] | None: ... aspect = wm_aspect @overload def wm_attributes(self) -> Tuple[Any, ...]: ... @@ -518,7 +515,7 @@ class Wm: @overload def wm_colormapwindows(self) -> list[Misc]: ... @overload - def wm_colormapwindows(self, __wlist: _TkinterSequence[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 @@ -561,12 +558,12 @@ class Wm: def wm_manage(self, widget): ... manage = wm_manage @overload - def wm_maxsize(self, width: None = ..., height: None = ...) -> Tuple[int, int]: ... + def wm_maxsize(self, width: None = ..., height: None = ...) -> tuple[int, int]: ... @overload def wm_maxsize(self, width: int, height: int) -> None: ... maxsize = wm_maxsize @overload - def wm_minsize(self, width: None = ..., height: None = ...) -> Tuple[int, int]: ... + def wm_minsize(self, width: None = ..., height: None = ...) -> tuple[int, int]: ... @overload def wm_minsize(self, width: int, height: int) -> None: ... minsize = wm_minsize @@ -585,7 +582,7 @@ class Wm: 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]: ... + def wm_resizable(self, width: None = ..., height: None = ...) -> tuple[bool, bool]: ... @overload def wm_resizable(self, width: bool, height: bool) -> None: ... resizable = wm_resizable @@ -645,9 +642,9 @@ class Tk(Misc, Wm): relief: _Relief = ..., takefocus: _TakeFocusValue = ..., width: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def loadtk(self) -> None: ... # differs from _tkinter.TkappType.loadtk def destroy(self) -> None: ... @@ -702,8 +699,8 @@ class _PackInfo(_InMiscTotal): # can be specified in pack(). ipadx: int ipady: int - padx: int | Tuple[int, int] - pady: int | Tuple[int, int] + padx: int | tuple[int, int] + pady: int | tuple[int, int] class Pack: # _PackInfo is not the valid type for cnf because pad stuff accepts any @@ -722,8 +719,8 @@ class Pack: side: Literal["left", "right", "top", "bottom"] = ..., ipadx: _ScreenUnits = ..., ipady: _ScreenUnits = ..., - padx: _ScreenUnits | Tuple[_ScreenUnits, _ScreenUnits] = ..., - pady: _ScreenUnits | Tuple[_ScreenUnits, _ScreenUnits] = ..., + padx: _ScreenUnits | tuple[_ScreenUnits, _ScreenUnits] = ..., + pady: _ScreenUnits | tuple[_ScreenUnits, _ScreenUnits] = ..., in_: Misc = ..., **kw: Any, # allow keyword argument named 'in', see #4836 ) -> None: ... @@ -791,8 +788,8 @@ class _GridInfo(_InMiscNonTotal): # empty dict if widget hasn't been gridded rowspan: int ipadx: int ipady: int - padx: int | Tuple[int, int] - pady: int | Tuple[int, int] + padx: int | tuple[int, int] + pady: int | tuple[int, int] sticky: str # consists of letters 'n', 's', 'w', 'e', no repeats, may be empty class Grid: @@ -806,8 +803,8 @@ class Grid: rowspan: int = ..., ipadx: _ScreenUnits = ..., ipady: _ScreenUnits = ..., - padx: _ScreenUnits | Tuple[_ScreenUnits, _ScreenUnits] = ..., - pady: _ScreenUnits | Tuple[_ScreenUnits, _ScreenUnits] = ..., + padx: _ScreenUnits | tuple[_ScreenUnits, _ScreenUnits] = ..., + pady: _ScreenUnits | tuple[_ScreenUnits, _ScreenUnits] = ..., sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty in_: Misc = ..., **kw: Any, # allow keyword argument named 'in', see #4836 @@ -887,7 +884,7 @@ class Toplevel(BaseWidget, Wm): screen: str = ..., # can't be changed after creating widget takefocus: _TakeFocusValue = ..., use: int = ..., - visual: str | Tuple[str, int] = ..., + visual: str | tuple[str, int] = ..., width: _ScreenUnits = ..., ) -> None: ... @overload @@ -911,9 +908,9 @@ class Toplevel(BaseWidget, Wm): relief: _Relief = ..., takefocus: _TakeFocusValue = ..., width: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Button(Widget): @@ -1006,9 +1003,9 @@ class Button(Widget): underline: int = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def flash(self): ... def invoke(self) -> Any: ... @@ -1043,7 +1040,7 @@ class Canvas(Widget, XView, YView): relief: _Relief = ..., # Setting scrollregion to None doesn't reset it back to empty, # but setting it to () does. - scrollregion: Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | Tuple[()] = ..., + scrollregion: tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | tuple[()] = ..., selectbackground: _Color = ..., selectborderwidth: _ScreenUnits = ..., selectforeground: _Color = ..., @@ -1080,7 +1077,7 @@ class Canvas(Widget, XView, YView): insertwidth: _ScreenUnits = ..., offset: Any = ..., # undocumented relief: _Relief = ..., - scrollregion: Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | Tuple[()] = ..., + scrollregion: tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | tuple[()] = ..., selectbackground: _Color = ..., selectborderwidth: _ScreenUnits = ..., selectforeground: _Color = ..., @@ -1091,9 +1088,9 @@ class Canvas(Widget, XView, YView): xscrollincrement: _ScreenUnits = ..., yscrollcommand: _XYScrollCommand = ..., yscrollincrement: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def addtag(self, *args): ... # internal method def addtag_above(self, newtag: str, tagOrId: str | _CanvasItemId) -> None: ... @@ -1125,7 +1122,7 @@ class Canvas(Widget, XView, YView): # Canvas.bbox() args are `str | _CanvasItemId`, but mypy rejects that # description because it's incompatible with Misc.bbox(), an alias for # Misc.grid_bbox(). Yes it is, but there's not much we can do about it. - def bbox(self, *args: str | _CanvasItemId) -> Tuple[int, int, int, int]: ... # type: ignore + def bbox(self, *args: str | _CanvasItemId) -> tuple[int, int, int, int]: ... # type: ignore @overload def tag_bind( self, @@ -1144,7 +1141,7 @@ class Canvas(Widget, XView, YView): @overload def coords(self) -> list[float]: ... @overload - def coords(self, __args: _TkinterSequence[int] | _TkinterSequence[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. @@ -1160,16 +1157,16 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | _TkinterSequence[int] = ..., + activedash: str | list[int] | Tuple[int, ...] = ..., activefill: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., arrow: Literal["first", "last", "both"] = ..., - arrowshape: Tuple[float, float, float] = ..., + arrowshape: tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: str | _TkinterSequence[int] = ..., + dash: str | list[int] | Tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | _TkinterSequence[int] = ..., + disableddash: str | list[int] | Tuple[int, ...] = ..., disabledfill: _Color = ..., disabledstipple: _Bitmap = ..., disabledwidth: _ScreenUnits = ..., @@ -1180,7 +1177,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1188,16 +1185,16 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | _TkinterSequence[int] = ..., + activedash: str | list[int] | Tuple[int, ...] = ..., activefill: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., arrow: Literal["first", "last", "both"] = ..., - arrowshape: Tuple[float, float, float] = ..., + arrowshape: tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: str | _TkinterSequence[int] = ..., + dash: str | list[int] | Tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | _TkinterSequence[int] = ..., + disableddash: str | list[int] | Tuple[int, ...] = ..., disabledfill: _Color = ..., disabledstipple: _Bitmap = ..., disabledwidth: _ScreenUnits = ..., @@ -1208,7 +1205,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1219,15 +1216,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | _TkinterSequence[int] = ..., + activedash: str | list[int] | Tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | _TkinterSequence[int] = ..., + dash: str | list[int] | Tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | _TkinterSequence[int] = ..., + disableddash: str | list[int] | Tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1240,7 +1237,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1248,15 +1245,15 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | _TkinterSequence[int] = ..., + activedash: str | list[int] | Tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | _TkinterSequence[int] = ..., + dash: str | list[int] | Tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | _TkinterSequence[int] = ..., + disableddash: str | list[int] | Tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1269,7 +1266,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1280,15 +1277,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *xy_pairs: float, - activedash: str | _TkinterSequence[int] = ..., + activedash: str | list[int] | Tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | _TkinterSequence[int] = ..., + dash: str | list[int] | Tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | _TkinterSequence[int] = ..., + disableddash: str | list[int] | Tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1304,7 +1301,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1312,15 +1309,15 @@ class Canvas(Widget, XView, YView): self, __coords: Tuple[float, ...] | list[int] | list[float], *, - activedash: str | _TkinterSequence[int] = ..., + activedash: str | list[int] | Tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | _TkinterSequence[int] = ..., + dash: str | list[int] | Tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | _TkinterSequence[int] = ..., + disableddash: str | list[int] | Tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1336,7 +1333,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1347,15 +1344,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | _TkinterSequence[int] = ..., + activedash: str | list[int] | Tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | _TkinterSequence[int] = ..., + dash: str | list[int] | Tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | _TkinterSequence[int] = ..., + disableddash: str | list[int] | Tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1368,7 +1365,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1376,15 +1373,15 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | _TkinterSequence[int] = ..., + activedash: str | list[int] | Tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | _TkinterSequence[int] = ..., + dash: str | list[int] | Tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | _TkinterSequence[int] = ..., + disableddash: str | list[int] | Tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1397,7 +1394,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1417,7 +1414,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1437,7 +1434,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1450,7 +1447,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1462,7 +1459,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: str | _TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1614,9 +1611,9 @@ class Checkbutton(Widget): variable: Variable | Literal[""] = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def deselect(self): ... def flash(self): ... @@ -1713,9 +1710,9 @@ class Entry(Widget, XView): vcmd: _EntryValidateCommand = ..., width: int = ..., xscrollcommand: _XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def delete(self, first: _EntryIndex, last: _EntryIndex | None = ...) -> None: ... def get(self) -> str: ... @@ -1761,7 +1758,7 @@ class Frame(Widget): pady: _ScreenUnits = ..., relief: _Relief = ..., takefocus: _TakeFocusValue = ..., - visual: str | Tuple[str, int] = ..., + visual: str | tuple[str, int] = ..., width: _ScreenUnits = ..., ) -> None: ... @overload @@ -1784,9 +1781,9 @@ class Frame(Widget): relief: _Relief = ..., takefocus: _TakeFocusValue = ..., width: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Label(Widget): @@ -1864,9 +1861,9 @@ class Label(Widget): underline: int = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Listbox(Widget, XView, YView): @@ -1954,9 +1951,9 @@ class Listbox(Widget, XView, YView): width: int = ..., xscrollcommand: _XYScrollCommand = ..., yscrollcommand: _XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def activate(self, index): ... def bbox(self, index): ... @@ -2042,9 +2039,9 @@ class Menu(Widget): tearoffcommand: Callable[[str, str], Any] | str = ..., title: str = ..., type: Literal["menubar", "tearoff", "normal"] = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def tk_popup(self, x: int, y: int, entry: _MenuIndex = ...) -> None: ... def activate(self, index: _MenuIndex) -> None: ... @@ -2244,7 +2241,7 @@ class Menu(Widget): def entrycget(self, index: _MenuIndex, option: str) -> Any: ... def entryconfigure( self, index: _MenuIndex, cnf: dict[str, Any] | None = ..., **kw: Any - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... entryconfig = entryconfigure def index(self, index: _MenuIndex) -> int | None: ... def invoke(self, index: _MenuIndex) -> Any: ... @@ -2335,9 +2332,9 @@ class Menubutton(Widget): underline: int = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Message(Widget): @@ -2398,9 +2395,9 @@ class Message(Widget): text: float | str = ..., textvariable: Variable = ..., width: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Radiobutton(Widget): @@ -2498,9 +2495,9 @@ class Radiobutton(Widget): variable: Variable | Literal[""] = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def deselect(self): ... def flash(self): ... @@ -2589,9 +2586,9 @@ class Scale(Widget): troughcolor: _Color = ..., variable: IntVar | DoubleVar = ..., width: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def get(self): ... def set(self, value): ... @@ -2615,7 +2612,7 @@ class Scrollbar(Widget): # 'SCROLLING COMMANDS' in scrollbar man page. There doesn't seem to # be any way to specify an overloaded callback function, so we say # that it can take any args while it can't in reality. - command: Callable[..., Tuple[float, float] | None] | str = ..., + command: Callable[..., tuple[float, float] | None] | str = ..., cursor: _Cursor = ..., elementborderwidth: _ScreenUnits = ..., highlightbackground: _Color = ..., @@ -2643,7 +2640,7 @@ class Scrollbar(Widget): bg: _Color = ..., border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - command: Callable[..., Tuple[float, float] | None] | str = ..., + command: Callable[..., tuple[float, float] | None] | str = ..., cursor: _Cursor = ..., elementborderwidth: _ScreenUnits = ..., highlightbackground: _Color = ..., @@ -2657,9 +2654,9 @@ class Scrollbar(Widget): takefocus: _TakeFocusValue = ..., troughcolor: _Color = ..., width: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def activate(self, index: Any | None = ...): ... def delta(self, deltax, deltay): ... @@ -2777,11 +2774,11 @@ class Text(Widget, XView, YView): wrap: Literal["none", "char", "word"] = ..., xscrollcommand: _XYScrollCommand = ..., yscrollcommand: _XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure - def bbox(self, index: _TextIndex) -> Tuple[int, int, int, int] | None: ... # type: ignore + def bbox(self, index: _TextIndex) -> tuple[int, int, int, int] | None: ... # type: ignore def compare(self, index1: _TextIndex, op: Literal["<", "<=", "==", ">=", ">", "!="], index2: _TextIndex) -> bool: ... def count(self, index1, index2, *args): ... # TODO @overload @@ -2789,7 +2786,7 @@ class Text(Widget, XView, YView): @overload def debug(self, boolean: bool) -> None: ... def delete(self, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... - def dlineinfo(self, index: _TextIndex) -> Tuple[int, int, int, int, int] | None: ... + def dlineinfo(self, index: _TextIndex) -> tuple[int, int, int, int, int] | None: ... @overload def dump( self, @@ -2803,7 +2800,7 @@ class Text(Widget, XView, YView): tag: bool = ..., text: bool = ..., window: bool = ..., - ) -> list[Tuple[str, str, str]]: ... + ) -> list[tuple[str, str, str]]: ... @overload def dump( self, @@ -2848,7 +2845,7 @@ 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 | _TkinterSequence[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 @@ -2861,7 +2858,7 @@ class Text(Widget, XView, YView): # **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 | _TkinterSequence[str]) -> None: ... + 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( @@ -2923,15 +2920,15 @@ class Text(Widget, XView, YView): underline: bool = ..., underlinefg: _Color = ..., wrap: Literal["none", "char", "word"] = ..., # be careful with "none" vs None - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def tag_configure(self, tagName: str, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def tag_configure(self, tagName: str, cnf: str) -> tuple[str, str, str, Any, Any]: ... 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_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_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, ...]: ... # tag_remove and tag_delete are different @@ -3016,9 +3013,21 @@ class PhotoImage(Image): def copy(self) -> PhotoImage: ... def zoom(self, x: int, y: int | Literal[""] = ...) -> PhotoImage: ... def subsample(self, x: int, y: int | Literal[""] = ...) -> PhotoImage: ... - def get(self, x: int, y: int) -> Tuple[int, int, int]: ... - def put(self, data: str | _TkinterSequence[str] | _TkinterSequence2D[_Color], to: Tuple[int, int] | None = ...) -> None: ... - def write(self, filename: StrOrBytesPath, format: str | None = ..., from_coords: Tuple[int, int] | None = ...) -> None: ... + def get(self, x: int, y: int) -> tuple[int, int, int]: ... + def put( + self, + data: ( + str + | list[str] + | list[list[_Color]] + | list[Tuple[_Color, ...]] + | Tuple[str, ...] + | Tuple[list[_Color], ...] + | Tuple[Tuple[_Color, ...], ...] + ), + to: tuple[int, int] | None = ..., + ) -> None: ... + def write(self, filename: StrOrBytesPath, format: str | None = ..., from_coords: tuple[int, int] | None = ...) -> None: ... if sys.version_info >= (3, 8): def transparency_get(self, x: int, y: int) -> bool: ... def transparency_set(self, x: int, y: int, boolean: bool) -> None: ... @@ -3057,8 +3066,8 @@ class Spinbox(Widget, XView): buttoncursor: _Cursor = ..., buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., - # percent substitutions don't seem to be supported, it's similar to Entry's validion stuff - command: Callable[[], Any] | str | _TkinterSequence[str] = ..., + # percent substitutions don't seem to be supported, it's similar to Entry's validation stuff + command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3095,7 +3104,7 @@ class Spinbox(Widget, XView): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., vcmd: _EntryValidateCommand = ..., - values: _TkinterSequence[str] = ..., + values: list[str] | Tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., @@ -3115,7 +3124,7 @@ class Spinbox(Widget, XView): buttoncursor: _Cursor = ..., buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., - command: Callable[[], Any] | str | _TkinterSequence[str] = ..., + command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3151,13 +3160,13 @@ class Spinbox(Widget, XView): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., vcmd: _EntryValidateCommand = ..., - values: _TkinterSequence[str] = ..., + values: list[str] | Tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, index): ... def delete(self, first, last: Any | None = ...): ... @@ -3212,7 +3221,7 @@ class LabelFrame(Widget): relief: _Relief = ..., takefocus: _TakeFocusValue = ..., text: float | str = ..., - visual: str | Tuple[str, int] = ..., + visual: str | tuple[str, int] = ..., width: _ScreenUnits = ..., ) -> None: ... @overload @@ -3241,9 +3250,9 @@ class LabelFrame(Widget): takefocus: _TakeFocusValue = ..., text: float | str = ..., width: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class PanedWindow(Widget): @@ -3301,9 +3310,9 @@ class PanedWindow(Widget): sashwidth: _ScreenUnits = ..., showhandle: bool = ..., width: _ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def add(self, child: Widget, **kw): ... def remove(self, child): ... diff --git a/mypy/typeshed/stdlib/tkinter/colorchooser.pyi b/mypy/typeshed/stdlib/tkinter/colorchooser.pyi index 184f9a2c9914..b5fdc7c54914 100644 --- a/mypy/typeshed/stdlib/tkinter/colorchooser.pyi +++ b/mypy/typeshed/stdlib/tkinter/colorchooser.pyi @@ -1,7 +1,7 @@ from tkinter.commondialog import Dialog -from typing import Any, ClassVar, Tuple +from typing import Any, ClassVar class Chooser(Dialog): command: ClassVar[str] -def askcolor(color: str | bytes | None = ..., **options: Any) -> Tuple[None, None] | Tuple[Tuple[float, float, float], str]: ... +def askcolor(color: str | bytes | None = ..., **options: Any) -> tuple[None, None] | tuple[tuple[float, float, float], str]: ... diff --git a/mypy/typeshed/stdlib/tkinter/filedialog.pyi b/mypy/typeshed/stdlib/tkinter/filedialog.pyi index ca5ecfff262d..0fc7d6e8a3bc 100644 --- a/mypy/typeshed/stdlib/tkinter/filedialog.pyi +++ b/mypy/typeshed/stdlib/tkinter/filedialog.pyi @@ -1,9 +1,9 @@ from _typeshed import StrOrBytesPath -from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, _TkinterSequence, commondialog +from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog from typing import IO, Any, ClassVar, Iterable, Tuple from typing_extensions import Literal -dialogstates: dict[Any, Tuple[Any, Any]] +dialogstates: dict[Any, tuple[Any, Any]] class FileDialog: title: str @@ -64,7 +64,7 @@ def asksaveasfilename( *, confirmoverwrite: bool | None = ..., defaultextension: str | None = ..., - filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[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] | Tuple[str, _TkinterSequence[str]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -84,7 +84,7 @@ def askopenfilename( def askopenfilenames( *, defaultextension: str | None = ..., - filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[str]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -101,7 +101,7 @@ def asksaveasfile( *, confirmoverwrite: bool | None = ..., defaultextension: str | None = ..., - filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[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] | Tuple[str, _TkinterSequence[str]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -123,7 +123,7 @@ def askopenfiles( mode: str = ..., *, defaultextension: str | None = ..., - filetypes: Iterable[Tuple[str, str] | Tuple[str, _TkinterSequence[str]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., diff --git a/mypy/typeshed/stdlib/tkinter/font.pyi b/mypy/typeshed/stdlib/tkinter/font.pyi index df828c448ae3..fccc0fbf1f0a 100644 --- a/mypy/typeshed/stdlib/tkinter/font.pyi +++ b/mypy/typeshed/stdlib/tkinter/font.pyi @@ -1,7 +1,7 @@ import _tkinter import sys import tkinter -from typing import Any, Tuple, Union, overload +from typing import Any, List, Tuple, Union, overload from typing_extensions import Literal, TypedDict NORMAL: Literal["normal"] @@ -15,7 +15,8 @@ _FontDescription = Union[ # A font object constructed in Python Font, # ("Helvetica", 12, BOLD) - tkinter._TkinterSequence[Any], + List[Any], + Tuple[Any, ...], # A font object constructed in Tcl _tkinter.Tcl_Obj, ] diff --git a/mypy/typeshed/stdlib/tkinter/tix.pyi b/mypy/typeshed/stdlib/tkinter/tix.pyi index 3518802aaa71..3037212c0ad1 100644 --- a/mypy/typeshed/stdlib/tkinter/tix.pyi +++ b/mypy/typeshed/stdlib/tkinter/tix.pyi @@ -193,7 +193,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def indicator_delete(self, entry: str) -> None: ... 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_bbox(self, entry: str) -> tuple[int, int, int, int]: ... def info_children(self, entry: str | None = ...) -> Tuple[str, ...]: ... def info_data(self, entry: str) -> Any: ... def info_dragsite(self) -> str: ... @@ -296,6 +296,6 @@ class Form: def form(self, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... def check(self) -> bool: ... def forget(self) -> None: ... - def grid(self, xsize: int = ..., ysize: int = ...) -> Tuple[int, int] | None: ... + def grid(self, xsize: int = ..., ysize: int = ...) -> tuple[int, int] | None: ... def info(self, option: str | None = ...) -> Any: ... def slaves(self) -> list[tkinter.Widget]: ... diff --git a/mypy/typeshed/stdlib/tkinter/ttk.pyi b/mypy/typeshed/stdlib/tkinter/ttk.pyi index cb7a7b63d0f4..20f74d4a5ec2 100644 --- a/mypy/typeshed/stdlib/tkinter/ttk.pyi +++ b/mypy/typeshed/stdlib/tkinter/ttk.pyi @@ -75,9 +75,9 @@ class Button(Widget): textvariable: tkinter.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def invoke(self) -> Any: ... @@ -127,9 +127,9 @@ class Checkbutton(Widget): underline: int = ..., variable: tkinter.Variable = ..., width: int | Literal[""] = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def invoke(self) -> Any: ... @@ -179,9 +179,9 @@ class Entry(Widget, tkinter.Entry): validatecommand: tkinter._EntryValidateCommand = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Entry().config is mypy error (don't know why) @overload # type: ignore def config( @@ -204,9 +204,9 @@ class Entry(Widget, tkinter.Entry): validatecommand: tkinter._EntryValidateCommand = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... def bbox(self, index): ... def identify(self, x, y): ... def validate(self): ... @@ -234,7 +234,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented validatecommand: tkinter._EntryValidateCommand = ..., # undocumented - values: tkinter._TkinterSequence[str] = ..., + values: list[str] | Tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented ) -> None: ... @@ -259,12 +259,12 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: tkinter._TkinterSequence[str] = ..., + values: list[str] | Tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Combobox().config is mypy error (don't know why) @overload # type: ignore def config( @@ -287,12 +287,12 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: tkinter._TkinterSequence[str] = ..., + values: list[str] | Tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... def current(self, newindex: Any | None = ...): ... def set(self, value): ... @@ -327,9 +327,9 @@ class Frame(Widget): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., width: tkinter._ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Label(Widget): @@ -385,9 +385,9 @@ class Label(Widget): underline: int = ..., width: int | Literal[""] = ..., wraplength: tkinter._ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Labelframe(Widget): @@ -429,9 +429,9 @@ class Labelframe(Widget): text: float | str = ..., underline: int = ..., width: tkinter._ScreenUnits = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure LabelFrame = Labelframe @@ -475,9 +475,9 @@ class Menubutton(Widget): textvariable: tkinter.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Notebook(Widget): @@ -505,9 +505,9 @@ class Notebook(Widget): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., width: int = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def add( self, @@ -557,9 +557,9 @@ class Panedwindow(Widget, tkinter.PanedWindow): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., width: int = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Panedwindow().config is mypy error (don't know why) @overload # type: ignore def config( @@ -571,9 +571,9 @@ class Panedwindow(Widget, tkinter.PanedWindow): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., width: int = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... forget: Any def insert(self, pos, child, **kw): ... def pane(self, pane, option: Any | None = ..., **kw): ... @@ -614,9 +614,9 @@ class Progressbar(Widget): takefocus: tkinter._TakeFocusValue = ..., value: float = ..., variable: tkinter.IntVar | tkinter.DoubleVar = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def start(self, interval: Any | None = ...): ... def step(self, amount: Any | None = ...): ... @@ -663,9 +663,9 @@ class Radiobutton(Widget): value: Any = ..., variable: tkinter.Variable | Literal[""] = ..., width: int | Literal[""] = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def invoke(self) -> Any: ... @@ -704,9 +704,9 @@ class Scale(Widget, tkinter.Scale): to: float = ..., value: float = ..., variable: tkinter.IntVar | tkinter.DoubleVar = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Scale().config is mypy error (don't know why) @overload # type: ignore def config( @@ -724,9 +724,9 @@ class Scale(Widget, tkinter.Scale): to: float = ..., value: float = ..., variable: tkinter.IntVar | tkinter.DoubleVar = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... def get(self, x: Any | None = ..., y: Any | None = ...): ... class Scrollbar(Widget, tkinter.Scrollbar): @@ -735,7 +735,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): master: tkinter.Misc | None = ..., *, class_: str = ..., - command: Callable[..., Tuple[float, float] | None] | str = ..., + command: Callable[..., tuple[float, float] | None] | str = ..., cursor: tkinter._Cursor = ..., name: str = ..., orient: Literal["horizontal", "vertical"] = ..., @@ -747,28 +747,28 @@ class Scrollbar(Widget, tkinter.Scrollbar): self, cnf: dict[str, Any] | None = ..., *, - command: Callable[..., Tuple[float, float] | None] | str = ..., + command: Callable[..., tuple[float, float] | None] | str = ..., cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Scrollbar().config is mypy error (don't know why) @overload # type: ignore def config( self, cnf: dict[str, Any] | None = ..., *, - command: Callable[..., Tuple[float, float] | None] | str = ..., + command: Callable[..., tuple[float, float] | None] | str = ..., cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... class Separator(Widget): def __init__( @@ -791,9 +791,9 @@ class Separator(Widget): orient: Literal["horizontal", "vertical"] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure class Sizegrip(Widget): @@ -815,9 +815,9 @@ class Sizegrip(Widget): cursor: tkinter._Cursor = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure if sys.version_info >= (3, 7): @@ -828,7 +828,7 @@ if sys.version_info >= (3, 7): *, background: tkinter._Color = ..., # undocumented class_: str = ..., - command: Callable[[], Any] | str | tkinter._TkinterSequence[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: tkinter._TkinterSequence[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 | tkinter._TkinterSequence[str] = ..., + command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., @@ -876,22 +876,22 @@ if sys.version_info >= (3, 7): to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: tkinter._TkinterSequence[str] = ..., + values: list[str] | Tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure # type: ignore def set(self, value: Any) -> None: ... class _TreeviewItemDict(TypedDict): text: str - image: Literal[""] | list[str] # no idea why it's wrapped in list - values: list[Any] + image: list[str] | Literal[""] # no idea why it's wrapped in list + values: list[Any] | Literal[""] open: bool # actually 0 or 1 - tags: list[str] + tags: list[str] | Literal[""] class _TreeviewTagDict(TypedDict): # There is also 'text' and 'anchor', but they don't seem to do anything, using them is likely a bug @@ -922,18 +922,18 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): master: tkinter.Misc | None = ..., *, class_: str = ..., - columns: str | tkinter._TkinterSequence[str] = ..., + columns: str | list[str] | Tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: str | tkinter._TkinterSequence[str] | tkinter._TkinterSequence[int] | Literal["#all"] = ..., + displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ..., height: int = ..., name: str = ..., padding: tkinter._Padding = ..., selectmode: Literal["extended", "browse", "none"] = ..., - # _TkinterSequences of Literal don't actually work, using str instead. + # list/tuple of Literal don't actually work in mypy # # 'tree headings' is same as ['tree', 'headings'], and I wouldn't be - # surprised if someone was using it. - show: Literal["tree", "headings", "tree headings", ""] | tkinter._TkinterSequence[str] = ..., + # surprised if someone is using it. + show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -944,22 +944,22 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): self, cnf: dict[str, Any] | None = ..., *, - columns: str | tkinter._TkinterSequence[str] = ..., + columns: str | list[str] | Tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: str | tkinter._TkinterSequence[str] | tkinter._TkinterSequence[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", ""] | tkinter._TkinterSequence[str] = ..., + show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., yscrollcommand: tkinter._XYScrollCommand = ..., - ) -> dict[str, Tuple[str, str, str, Any, Any]] | None: ... + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload - def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + 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 + def bbox(self, item, column: _TreeviewColumnId | None = ...) -> tuple[int, int, int, int] | Literal[""]: ... # type: ignore def get_children(self, item: str | None = ...) -> Tuple[str, ...]: ... def set_children(self, item: str, *newchildren: str) -> None: ... @overload @@ -994,7 +994,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): @overload def heading(self, column: _TreeviewColumnId, option: Literal["text"]) -> str: ... @overload - def heading(self, column: _TreeviewColumnId, option: Literal["image"]) -> Tuple[str]: ... + def heading(self, column: _TreeviewColumnId, option: Literal["image"]) -> tuple[str]: ... @overload def heading(self, column: _TreeviewColumnId, option: Literal["anchor"]) -> _tkinter.Tcl_Obj: ... @overload @@ -1027,20 +1027,20 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): id: str = ..., # same as iid text: str = ..., image: tkinter._ImageSpec = ..., - values: tkinter._TkinterSequence[Any] = ..., + values: list[Any] | Tuple[Any, ...] = ..., open: bool = ..., - tags: str | tkinter._TkinterSequence[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"]) -> Literal[""] | Tuple[str]: ... + def item(self, item: str, option: Literal["image"]) -> tuple[str] | Literal[""]: ... @overload - def item(self, item: str, option: Literal["values"]) -> Literal[""] | Tuple[Any, ...]: ... + 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"]) -> Literal[""] | Tuple[str, ...]: ... + 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: tkinter._TkinterSequence[Any] = ..., + values: list[Any] | Tuple[Any, ...] | Literal[""] = ..., open: bool = ..., - tags: str | tkinter._TkinterSequence[str] = ..., + tags: str | list[str] | Tuple[str, ...] = ..., ) -> _TreeviewItemDict | None: ... def move(self, item: str, parent: str, index: int) -> None: ... reattach = move @@ -1065,10 +1065,10 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def selection(self) -> Tuple[str, ...]: ... else: def selection(self, selop: Any | None = ..., items: Any | None = ...) -> Tuple[str, ...]: ... - def selection_set(self, items: str | tkinter._TkinterSequence[str]) -> None: ... - def selection_add(self, items: str | tkinter._TkinterSequence[str]) -> None: ... - def selection_remove(self, items: str | tkinter._TkinterSequence[str]) -> None: ... - def selection_toggle(self, items: str | tkinter._TkinterSequence[str]) -> None: ... + 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 diff --git a/mypy/typeshed/stdlib/tokenize.pyi b/mypy/typeshed/stdlib/tokenize.pyi index 136dcfcf0a14..4a42795b9491 100644 --- a/mypy/typeshed/stdlib/tokenize.pyi +++ b/mypy/typeshed/stdlib/tokenize.pyi @@ -44,7 +44,7 @@ class Untokenizer: # the docstring says "returns bytes" but is incorrect -- # if the ENCODING token is missing, it skips the encode def untokenize(iterable: Iterable[_Token]) -> Any: ... -def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ... +def detect_encoding(readline: Callable[[], bytes]) -> tuple[str, Sequence[bytes]]: ... def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... # undocumented def open(filename: StrOrBytesPath | int) -> TextIO: ... diff --git a/mypy/typeshed/stdlib/trace.pyi b/mypy/typeshed/stdlib/trace.pyi index c6d993bf6143..bab75c9ada8d 100644 --- a/mypy/typeshed/stdlib/trace.pyi +++ b/mypy/typeshed/stdlib/trace.pyi @@ -12,17 +12,17 @@ _fileModuleFunction = Tuple[str, Optional[str], str] class CoverageResults: def __init__( self, - counts: dict[Tuple[str, int], int] | None = ..., + counts: dict[tuple[str, int], int] | None = ..., calledfuncs: dict[_fileModuleFunction, int] | None = ..., infile: StrPath | None = ..., - callers: dict[Tuple[_fileModuleFunction, _fileModuleFunction], int] | None = ..., + callers: dict[tuple[_fileModuleFunction, _fileModuleFunction], int] | None = ..., outfile: StrPath | None = ..., ) -> None: ... # undocumented def update(self, other: CoverageResults) -> None: ... def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: StrPath | None = ...) -> None: ... def write_results_file( self, path: StrPath, lines: Sequence[str], lnotab: Any, lines_hit: Mapping[int, int], encoding: str | None = ... - ) -> Tuple[int, int]: ... + ) -> tuple[int, int]: ... def is_ignored_filename(self, filename: str) -> bool: ... # undocumented class Trace: diff --git a/mypy/typeshed/stdlib/traceback.pyi b/mypy/typeshed/stdlib/traceback.pyi index a6474a13aeae..eaf9850b2126 100644 --- a/mypy/typeshed/stdlib/traceback.pyi +++ b/mypy/typeshed/stdlib/traceback.pyi @@ -65,8 +65,8 @@ def format_exc(limit: int | None = ..., chain: bool = ...) -> str: ... def format_tb(tb: TracebackType | None, limit: int | None = ...) -> list[str]: ... def format_stack(f: FrameType | None = ..., limit: int | None = ...) -> list[str]: ... def clear_frames(tb: TracebackType) -> None: ... -def walk_stack(f: FrameType | None) -> Iterator[Tuple[FrameType, int]]: ... -def walk_tb(tb: TracebackType | None) -> Iterator[Tuple[FrameType, int]]: ... +def walk_stack(f: FrameType | None) -> Iterator[tuple[FrameType, int]]: ... +def walk_tb(tb: TracebackType | None) -> Iterator[tuple[FrameType, int]]: ... class TracebackException: __cause__: TracebackException @@ -146,7 +146,7 @@ class StackSummary(List[FrameSummary]): @classmethod def extract( cls, - frame_gen: Iterable[Tuple[FrameType, int]], + frame_gen: Iterable[tuple[FrameType, int]], *, limit: int | None = ..., lookup_lines: bool = ..., diff --git a/mypy/typeshed/stdlib/turtle.pyi b/mypy/typeshed/stdlib/turtle.pyi index a289fd03b068..9371f2a7a547 100644 --- a/mypy/typeshed/stdlib/turtle.pyi +++ b/mypy/typeshed/stdlib/turtle.pyi @@ -81,7 +81,7 @@ class TurtleScreen(TurtleScreenBase): @overload def bgpic(self, picname: str) -> None: ... @overload - def screensize(self, canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> Tuple[int, int]: ... + def screensize(self, canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> tuple[int, int]: ... # Looks like if self.cv is not a ScrolledCanvas, this could return a tuple as well @overload def screensize(self, canvwidth: int, canvheight: int, bg: _Color | None = ...) -> None: ... @@ -109,18 +109,18 @@ class TNavigator(object): def xcor(self) -> float: ... def ycor(self) -> float: ... @overload - def goto(self, x: Tuple[float, float], y: None = ...) -> None: ... + def goto(self, x: tuple[float, float], y: None = ...) -> None: ... @overload def goto(self, x: float, y: float) -> None: ... def home(self) -> None: ... def setx(self, x: float) -> None: ... def sety(self, y: float) -> None: ... @overload - def distance(self, x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... + def distance(self, x: TNavigator | tuple[float, float], y: None = ...) -> float: ... @overload def distance(self, x: float, y: float) -> float: ... @overload - def towards(self, x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... + def towards(self, x: TNavigator | tuple[float, float], y: None = ...) -> float: ... @overload def towards(self, x: float, y: float) -> float: ... def heading(self) -> float: ... @@ -166,7 +166,7 @@ class TPen(object): @overload def fillcolor(self, r: float, g: float, b: float) -> None: ... @overload - def color(self) -> Tuple[_AnyColor, _AnyColor]: ... + def color(self) -> tuple[_AnyColor, _AnyColor]: ... @overload def color(self, color: _Color) -> None: ... @overload @@ -191,7 +191,7 @@ class TPen(object): pensize: int = ..., speed: int = ..., resizemode: str = ..., - stretchfactor: Tuple[float, float] = ..., + stretchfactor: tuple[float, float] = ..., outline: int = ..., tilt: float = ..., ) -> None: ... @@ -220,7 +220,7 @@ class RawTurtle(TPen, TNavigator): def shape(self, name: str) -> None: ... # Unsafely overlaps when no arguments are provided @overload - def shapesize(self) -> Tuple[float, float, float]: ... # type: ignore + def shapesize(self) -> tuple[float, float, float]: ... # type: ignore @overload def shapesize( self, stretch_wid: float | None = ..., stretch_len: float | None = ..., outline: float | None = ... @@ -231,7 +231,7 @@ class RawTurtle(TPen, TNavigator): def shearfactor(self, shear: float) -> None: ... # Unsafely overlaps when no arguments are provided @overload - def shapetransform(self) -> Tuple[float, float, float, float]: ... # type: ignore + def shapetransform(self) -> tuple[float, float, float, float]: ... # type: ignore @overload def shapetransform( self, t11: float | None = ..., t12: float | None = ..., t21: float | None = ..., t22: float | None = ... @@ -253,7 +253,7 @@ class RawTurtle(TPen, TNavigator): def begin_fill(self) -> None: ... def end_fill(self) -> None: ... def dot(self, size: int | None = ..., *color: _Color) -> None: ... - def write(self, arg: object, move: bool = ..., align: str = ..., font: Tuple[str, int, str] = ...) -> None: ... + def write(self, arg: object, move: bool = ..., align: str = ..., font: tuple[str, int, str] = ...) -> None: ... def begin_poly(self) -> None: ... def end_poly(self) -> None: ... def get_poly(self) -> _PolygonCoords | None: ... @@ -346,7 +346,7 @@ def bgpic(picname: None = ...) -> str: ... @overload def bgpic(picname: str) -> None: ... @overload -def screensize(canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> Tuple[int, int]: ... +def screensize(canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> tuple[int, int]: ... @overload def screensize(canvwidth: int, canvheight: int, bg: _Color | None = ...) -> None: ... @@ -379,18 +379,18 @@ def pos() -> Vec2D: ... def xcor() -> float: ... def ycor() -> float: ... @overload -def goto(x: Tuple[float, float], y: None = ...) -> None: ... +def goto(x: tuple[float, float], y: None = ...) -> None: ... @overload def goto(x: float, y: float) -> None: ... def home() -> None: ... def setx(x: float) -> None: ... def sety(y: float) -> None: ... @overload -def distance(x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... +def distance(x: TNavigator | tuple[float, float], y: None = ...) -> float: ... @overload def distance(x: float, y: float) -> float: ... @overload -def towards(x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... +def towards(x: TNavigator | tuple[float, float], y: None = ...) -> float: ... @overload def towards(x: float, y: float) -> float: ... def heading() -> float: ... @@ -436,7 +436,7 @@ def fillcolor(color: _Color) -> None: ... @overload def fillcolor(r: float, g: float, b: float) -> None: ... @overload -def color() -> Tuple[_AnyColor, _AnyColor]: ... +def color() -> tuple[_AnyColor, _AnyColor]: ... @overload def color(color: _Color) -> None: ... @overload @@ -461,7 +461,7 @@ def pen( pensize: int = ..., speed: int = ..., resizemode: str = ..., - stretchfactor: Tuple[float, float] = ..., + stretchfactor: tuple[float, float] = ..., outline: int = ..., tilt: float = ..., ) -> None: ... @@ -485,7 +485,7 @@ def shape(name: str) -> None: ... # Unsafely overlaps when no arguments are provided @overload -def shapesize() -> Tuple[float, float, float]: ... # type: ignore +def shapesize() -> tuple[float, float, float]: ... # type: ignore @overload def shapesize(stretch_wid: float | None = ..., stretch_len: float | None = ..., outline: float | None = ...) -> None: ... @overload @@ -495,7 +495,7 @@ def shearfactor(shear: float) -> None: ... # Unsafely overlaps when no arguments are provided @overload -def shapetransform() -> Tuple[float, float, float, float]: ... # type: ignore +def shapetransform() -> tuple[float, float, float, float]: ... # type: ignore @overload def shapetransform( t11: float | None = ..., t12: float | None = ..., t21: float | None = ..., t22: float | None = ... @@ -518,7 +518,7 @@ def filling() -> bool: ... def begin_fill() -> None: ... def end_fill() -> None: ... def dot(size: int | None = ..., *color: _Color) -> None: ... -def write(arg: object, move: bool = ..., align: str = ..., font: Tuple[str, int, str] = ...) -> None: ... +def write(arg: object, move: bool = ..., align: str = ..., font: tuple[str, int, str] = ...) -> None: ... def begin_poly() -> None: ... def end_poly() -> None: ... def get_poly() -> _PolygonCoords | None: ... diff --git a/mypy/typeshed/stdlib/types.pyi b/mypy/typeshed/stdlib/types.pyi index 26d8263ead21..e60c6475e2e9 100644 --- a/mypy/typeshed/stdlib/types.pyi +++ b/mypy/typeshed/stdlib/types.pyi @@ -6,6 +6,7 @@ from typing import ( AsyncGenerator, Awaitable, Callable, + Coroutine, Generator, Generic, ItemsView, @@ -13,6 +14,7 @@ from typing import ( Iterator, KeysView, Mapping, + MutableSequence, Tuple, Type, TypeVar, @@ -173,6 +175,7 @@ class ModuleType: __dict__: dict[str, Any] __loader__: _LoaderProtocol | None __package__: str | None + __path__: MutableSequence[str] __spec__: ModuleSpec | None def __init__(self, name: str, doc: str | None = ...) -> None: ... @@ -211,7 +214,7 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): def aclose(self) -> Awaitable[None]: ... @final -class CoroutineType: +class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]): __name__: str __qualname__: str cr_await: Any | None @@ -219,12 +222,14 @@ class CoroutineType: cr_frame: FrameType cr_running: bool def close(self) -> None: ... - def __await__(self) -> Generator[Any, None, Any]: ... - def send(self, __arg: Any) -> Any: ... + def __await__(self) -> Generator[Any, None, _V_co]: ... + def send(self, __arg: _T_contra) -> _T_co: ... @overload - def throw(self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...) -> Any: ... + def throw( + self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... + ) -> _T_co: ... @overload - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Any: ... + def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... class _StaticFunctionType: """Fictional type to correct the type of MethodType.__func__. @@ -360,12 +365,12 @@ else: def prepare_class( name: str, bases: Tuple[type, ...] = ..., kwds: dict[str, Any] | None = ... -) -> Tuple[type, dict[str, Any], dict[str, Any]]: ... +) -> tuple[type, dict[str, Any], dict[str, Any]]: ... # Actually a different type, but `property` is special and we want that too. DynamicClassAttribute = property -def coroutine(func: Callable[..., Any]) -> CoroutineType: ... +def coroutine(func: Callable[..., Any]) -> CoroutineType[Any, Any, Any]: ... if sys.version_info >= (3, 8): CellType = _Cell diff --git a/mypy/typeshed/stdlib/typing.pyi b/mypy/typeshed/stdlib/typing.pyi index 4dc92e0ff9d9..9df12664be01 100644 --- a/mypy/typeshed/stdlib/typing.pyi +++ b/mypy/typeshed/stdlib/typing.pyi @@ -304,9 +304,7 @@ class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]): @abstractmethod def __len__(self) -> int: ... -_Collection = Collection[_T_co] - -class Sequence(_Collection[_T_co], Reversible[_T_co], Generic[_T_co]): +class Sequence(Collection[_T_co], Reversible[_T_co], Generic[_T_co]): @overload @abstractmethod def __getitem__(self, i: int) -> _T_co: ... @@ -350,7 +348,7 @@ class MutableSequence(Sequence[_T], Generic[_T]): def remove(self, value: _T) -> None: ... def __iadd__(self, x: Iterable[_T]) -> MutableSequence[_T]: ... -class AbstractSet(_Collection[_T_co], Generic[_T_co]): +class AbstractSet(Collection[_T_co], Generic[_T_co]): @abstractmethod def __contains__(self, x: object) -> bool: ... # Mixin methods @@ -384,18 +382,18 @@ class MappingView(Sized): class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]): def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented - def __and__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ... + def __and__(self, o: Iterable[Any]) -> Set[tuple[_KT_co, _VT_co]]: ... def __rand__(self, o: Iterable[_T]) -> Set[_T]: ... def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... + def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... if sys.version_info >= (3, 8): - def __reversed__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... - def __or__(self, o: Iterable[_T]) -> Set[Tuple[_KT_co, _VT_co] | _T]: ... - def __ror__(self, o: Iterable[_T]) -> Set[Tuple[_KT_co, _VT_co] | _T]: ... - def __sub__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ... + def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... + def __or__(self, o: Iterable[_T]) -> Set[tuple[_KT_co, _VT_co] | _T]: ... + def __ror__(self, o: Iterable[_T]) -> Set[tuple[_KT_co, _VT_co] | _T]: ... + def __sub__(self, o: Iterable[Any]) -> Set[tuple[_KT_co, _VT_co]]: ... def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ... - def __xor__(self, o: Iterable[_T]) -> Set[Tuple[_KT_co, _VT_co] | _T]: ... - def __rxor__(self, o: Iterable[_T]) -> Set[Tuple[_KT_co, _VT_co] | _T]: ... + def __xor__(self, o: Iterable[_T]) -> Set[tuple[_KT_co, _VT_co] | _T]: ... + def __rxor__(self, o: Iterable[_T]) -> Set[tuple[_KT_co, _VT_co] | _T]: ... class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented @@ -430,10 +428,10 @@ class ContextManager(Protocol[_T_co]): class AsyncContextManager(Protocol[_T_co]): def __aenter__(self) -> Awaitable[_T_co]: ... def __aexit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> Awaitable[bool | None]: ... -class Mapping(_Collection[_KT], Generic[_KT, _VT_co]): +class Mapping(Collection[_KT], Generic[_KT, _VT_co]): # TODO: We wish the key type could also be covariant, but that doesn't work, # see discussion in https://github.com/python/typing/pull/273. @abstractmethod @@ -458,7 +456,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): def pop(self, key: _KT) -> _VT: ... @overload def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ... - def popitem(self) -> Tuple[_KT, _VT]: ... + def popitem(self) -> tuple[_KT, _VT]: ... def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ... # 'update' used to take a Union, but using overloading is better. # The second overloaded type here is a bit too general, because @@ -473,7 +471,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def update(self, __m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... @overload def update(self, **kwargs: _VT) -> None: ... @@ -583,9 +581,9 @@ class Match(Generic[AnyStr]): def groupdict(self, default: _T) -> dict[str, AnyStr | _T]: ... def start(self, __group: int | str = ...) -> int: ... def end(self, __group: int | str = ...) -> int: ... - def span(self, __group: int | str = ...) -> Tuple[int, int]: ... + def span(self, __group: int | str = ...) -> tuple[int, int]: ... @property - def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented + def regs(self) -> Tuple[tuple[int, int], ...]: ... # undocumented # __getitem__() returns "AnyStr" or "AnyStr | None", depending on the pattern. @overload def __getitem__(self, __key: _Literal[0]) -> AnyStr: ... @@ -610,9 +608,9 @@ class Pattern(Generic[AnyStr]): @overload def sub(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ...) -> AnyStr: ... @overload - def subn(self, repl: AnyStr, string: AnyStr, count: int = ...) -> Tuple[AnyStr, int]: ... + def subn(self, repl: AnyStr, string: AnyStr, count: int = ...) -> tuple[AnyStr, int]: ... @overload - def subn(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ...) -> Tuple[AnyStr, int]: ... + def subn(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ...) -> tuple[AnyStr, int]: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -668,7 +666,7 @@ class NamedTuple(Tuple[Any, ...]): _fields: Tuple[str, ...] _source: str @overload - def __init__(self, typename: str, fields: Iterable[Tuple[str, Any]] = ...) -> None: ... + def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ... @overload def __init__(self, typename: str, fields: None = ..., **kwargs: Any) -> None: ... @classmethod diff --git a/mypy/typeshed/stdlib/unittest/mock.pyi b/mypy/typeshed/stdlib/unittest/mock.pyi index 5b3816d047d3..567ce346f464 100644 --- a/mypy/typeshed/stdlib/unittest/mock.pyi +++ b/mypy/typeshed/stdlib/unittest/mock.pyi @@ -181,7 +181,7 @@ class _patch(Generic[_T]): def __call__(self, func: Callable[..., _R]) -> Callable[..., _R]: ... def decorate_class(self, klass: _TT) -> _TT: ... def decorate_callable(self, func: Callable[..., _R]) -> Callable[..., _R]: ... - def get_original(self) -> Tuple[Any, bool]: ... + def get_original(self) -> tuple[Any, bool]: ... target: Any temp_original: Any is_local: bool diff --git a/mypy/typeshed/stdlib/unittest/result.pyi b/mypy/typeshed/stdlib/unittest/result.pyi index 676c0cd4aeda..20c43cf38aa4 100644 --- a/mypy/typeshed/stdlib/unittest/result.pyi +++ b/mypy/typeshed/stdlib/unittest/result.pyi @@ -10,10 +10,10 @@ _F = TypeVar("_F", bound=Callable[..., Any]) def failfast(method: _F) -> _F: ... class TestResult: - errors: list[Tuple[unittest.case.TestCase, str]] - failures: list[Tuple[unittest.case.TestCase, str]] - skipped: list[Tuple[unittest.case.TestCase, str]] - expectedFailures: list[Tuple[unittest.case.TestCase, str]] + errors: list[tuple[unittest.case.TestCase, str]] + failures: list[tuple[unittest.case.TestCase, str]] + skipped: list[tuple[unittest.case.TestCase, str]] + expectedFailures: list[tuple[unittest.case.TestCase, str]] unexpectedSuccesses: list[unittest.case.TestCase] shouldStop: bool testsRun: int diff --git a/mypy/typeshed/stdlib/unittest/runner.pyi b/mypy/typeshed/stdlib/unittest/runner.pyi index 128909b2090b..bf8f3c05c1cd 100644 --- a/mypy/typeshed/stdlib/unittest/runner.pyi +++ b/mypy/typeshed/stdlib/unittest/runner.pyi @@ -1,7 +1,7 @@ import unittest.case import unittest.result import unittest.suite -from typing import Callable, TextIO, Tuple, Type +from typing import Callable, TextIO, Type _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] @@ -15,7 +15,7 @@ class TextTestResult(unittest.result.TestResult): def __init__(self, stream: TextIO, descriptions: bool, verbosity: int) -> None: ... def getDescription(self, test: unittest.case.TestCase) -> str: ... def printErrors(self) -> None: ... - def printErrorList(self, flavour: str, errors: Tuple[unittest.case.TestCase, str]) -> None: ... + def printErrorList(self, flavour: str, errors: tuple[unittest.case.TestCase, str]) -> None: ... class TextTestRunner(object): resultclass: _ResultClassType diff --git a/mypy/typeshed/stdlib/unittest/util.pyi b/mypy/typeshed/stdlib/unittest/util.pyi index ffce5d52677c..ab6ed053a6ff 100644 --- a/mypy/typeshed/stdlib/unittest/util.pyi +++ b/mypy/typeshed/stdlib/unittest/util.pyi @@ -11,11 +11,11 @@ _MIN_COMMON_LEN: int _MIN_DIFF_LEN: int def _shorten(s: str, prefixlen: int, suffixlen: int) -> str: ... -def _common_shorten_repr(*args: str) -> Tuple[str]: ... +def _common_shorten_repr(*args: str) -> tuple[str]: ... def safe_repr(obj: object, short: bool = ...) -> str: ... def strclass(cls: type) -> str: ... -def sorted_list_difference(expected: Sequence[_T], actual: Sequence[_T]) -> Tuple[list[_T], list[_T]]: ... -def unorderable_list_difference(expected: Sequence[_T], actual: Sequence[_T]) -> Tuple[list[_T], list[_T]]: ... +def sorted_list_difference(expected: Sequence[_T], actual: Sequence[_T]) -> tuple[list[_T], list[_T]]: ... +def unorderable_list_difference(expected: Sequence[_T], actual: Sequence[_T]) -> tuple[list[_T], list[_T]]: ... def three_way_cmp(x: Any, y: Any) -> int: ... def _count_diff_all_purpose(actual: Sequence[_T], expected: Sequence[_T]) -> list[_Mismatch[_T]]: ... def _count_diff_hashable(actual: Sequence[_T], expected: Sequence[_T]) -> list[_Mismatch[_T]]: ... diff --git a/mypy/typeshed/stdlib/urllib/error.pyi b/mypy/typeshed/stdlib/urllib/error.pyi index 557f84a40159..1d91fedceeca 100644 --- a/mypy/typeshed/stdlib/urllib/error.pyi +++ b/mypy/typeshed/stdlib/urllib/error.pyi @@ -1,5 +1,5 @@ from email.message import Message -from typing import IO, Tuple +from typing import IO from urllib.response import addinfourl # Stubs for urllib.error @@ -13,5 +13,5 @@ class HTTPError(URLError, addinfourl): def __init__(self, url: str, code: int, msg: str, hdrs: Message, fp: IO[bytes] | None) -> None: ... class ContentTooShortError(URLError): - content: Tuple[str, Message] - def __init__(self, message: str, content: Tuple[str, Message]) -> None: ... + content: tuple[str, Message] + def __init__(self, message: str, content: tuple[str, Message]) -> None: ... diff --git a/mypy/typeshed/stdlib/urllib/parse.pyi b/mypy/typeshed/stdlib/urllib/parse.pyi index 49a3dd1cedf4..a2467e96c43c 100644 --- a/mypy/typeshed/stdlib/urllib/parse.pyi +++ b/mypy/typeshed/stdlib/urllib/parse.pyi @@ -96,7 +96,7 @@ def parse_qsl( errors: str = ..., max_num_fields: int | None = ..., separator: str = ..., -) -> list[Tuple[AnyStr, AnyStr]]: ... +) -> list[tuple[AnyStr, AnyStr]]: ... @overload def quote(string: str, safe: _Str = ..., encoding: str | None = ..., errors: str | None = ...) -> str: ... @overload @@ -114,7 +114,7 @@ def urldefrag(url: str) -> DefragResult: ... @overload def urldefrag(url: bytes | None) -> DefragResultBytes: ... def urlencode( - query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[Tuple[Any, Any]] | Sequence[Tuple[Any, Sequence[Any]]], + query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]], doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., @@ -132,11 +132,11 @@ def urlsplit(url: str, scheme: str | None = ..., allow_fragments: bool = ...) -> def urlsplit(url: bytes | None, scheme: bytes | None = ..., allow_fragments: bool = ...) -> SplitResultBytes: ... @overload def urlunparse( - components: Tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None] + components: tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None] ) -> AnyStr: ... @overload def urlunparse(components: Sequence[AnyStr | None]) -> AnyStr: ... @overload -def urlunsplit(components: Tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None]) -> AnyStr: ... +def urlunsplit(components: tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None]) -> AnyStr: ... @overload def urlunsplit(components: Sequence[AnyStr | None]) -> AnyStr: ... diff --git a/mypy/typeshed/stdlib/urllib/request.pyi b/mypy/typeshed/stdlib/urllib/request.pyi index 9ac320c680db..3c8a6facde6f 100644 --- a/mypy/typeshed/stdlib/urllib/request.pyi +++ b/mypy/typeshed/stdlib/urllib/request.pyi @@ -77,11 +77,11 @@ class Request: def get_header(self, header_name: str) -> str | None: ... @overload def get_header(self, header_name: str, default: _T) -> str | _T: ... - def header_items(self) -> list[Tuple[str, str]]: ... + def header_items(self) -> list[tuple[str, str]]: ... def has_proxy(self) -> bool: ... class OpenerDirector: - addheaders: list[Tuple[str, str]] + addheaders: list[tuple[str, str]] def add_handler(self, handler: BaseHandler) -> None: ... def open(self, fullurl: str | Request, data: bytes | None = ..., timeout: float | None = ...) -> _UrlopenRet: ... def error(self, proto: str, *args: Any) -> _UrlopenRet: ... @@ -125,13 +125,13 @@ class ProxyHandler(BaseHandler): class HTTPPasswordMgr: def add_password(self, realm: str, uri: str | Sequence[str], user: str, passwd: str) -> None: ... - def find_user_password(self, realm: str, authuri: str) -> Tuple[str | None, str | None]: ... + def find_user_password(self, realm: str, authuri: str) -> tuple[str | None, str | None]: ... def is_suburi(self, base: str, test: str) -> bool: ... # undocumented def reduce_uri(self, uri: str, default_port: bool = ...) -> str: ... # undocumented class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): def add_password(self, realm: str | None, uri: str | Sequence[str], user: str, passwd: str) -> None: ... - def find_user_password(self, realm: str | None, authuri: str) -> Tuple[str | None, str | None]: ... + def find_user_password(self, realm: str | None, authuri: str) -> tuple[str | None, str | None]: ... class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm): def add_password( @@ -167,7 +167,7 @@ class AbstractDigestAuthHandler: def retry_http_digest_auth(self, req: Request, auth: str) -> _UrlopenRet | None: ... def get_cnonce(self, nonce: str) -> str: ... def get_authorization(self, req: Request, chal: Mapping[str, str]) -> str: ... - def get_algorithm_impls(self, algorithm: str) -> Tuple[Callable[[str], str], Callable[[str, str], str]]: ... + def get_algorithm_impls(self, algorithm: str) -> tuple[Callable[[str], str], Callable[[str, str], str]]: ... def get_entity_digest(self, data: bytes | None, chal: Mapping[str, str]) -> str | None: ... class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): @@ -213,7 +213,7 @@ class ftpwrapper: # undocumented def file_close(self) -> None: ... def init(self) -> None: ... def real_close(self) -> None: ... - def retrfile(self, file: str, type: str) -> Tuple[addclosehook, int]: ... + def retrfile(self, file: str, type: str) -> tuple[addclosehook, int]: ... class FTPHandler(BaseHandler): def ftp_open(self, req: Request) -> addinfourl: ... @@ -242,7 +242,7 @@ def urlretrieve( filename: StrOrBytesPath | None = ..., reporthook: Callable[[int, int, int], None] | None = ..., data: bytes | None = ..., -) -> Tuple[str, HTTPMessage]: ... +) -> tuple[str, HTTPMessage]: ... def urlcleanup() -> None: ... class URLopener: @@ -256,8 +256,8 @@ class URLopener: filename: str | None = ..., reporthook: Callable[[int, int, int], None] | None = ..., data: bytes | None = ..., - ) -> Tuple[str, Message | None]: ... - def addheader(self, *args: Tuple[str, str]) -> None: ... # undocumented + ) -> tuple[str, Message | None]: ... + def addheader(self, *args: tuple[str, str]) -> None: ... # undocumented def cleanup(self) -> None: ... # undocumented def close(self) -> None: ... # undocumented def http_error( @@ -275,8 +275,8 @@ class URLopener: def open_unknown_proxy(self, proxy: str, fullurl: str, data: bytes | None = ...) -> None: ... # undocumented class FancyURLopener(URLopener): - def prompt_user_passwd(self, host: str, realm: str) -> Tuple[str, str]: ... - def get_user_passwd(self, host: str, realm: str, clear_cache: int = ...) -> Tuple[str, str]: ... # undocumented + def prompt_user_passwd(self, host: str, realm: str) -> tuple[str, str]: ... + def get_user_passwd(self, host: str, realm: str, clear_cache: int = ...) -> tuple[str, str]: ... # undocumented def http_error_301( self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None = ... ) -> _UrlopenRet | addinfourl | None: ... # undocumented diff --git a/mypy/typeshed/stdlib/warnings.pyi b/mypy/typeshed/stdlib/warnings.pyi index 62c41c871853..f6ab5a456d33 100644 --- a/mypy/typeshed/stdlib/warnings.pyi +++ b/mypy/typeshed/stdlib/warnings.pyi @@ -4,6 +4,8 @@ from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit +_ActionKind = Literal["default", "error", "ignore", "always", "module", "once"] + filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] # undocumented, do not mutate def showwarning( @@ -11,9 +13,14 @@ def showwarning( ) -> None: ... def formatwarning(message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ... def filterwarnings( - action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ... + action: _ActionKind, + message: str = ..., + category: Type[Warning] = ..., + module: str = ..., + lineno: int = ..., + append: bool = ..., ) -> None: ... -def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ... +def simplefilter(action: _ActionKind, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ... def resetwarnings() -> None: ... class _OptionError(Exception): ... diff --git a/mypy/typeshed/stdlib/weakref.pyi b/mypy/typeshed/stdlib/weakref.pyi index 12158ee6c8f4..64abec36c7ec 100644 --- a/mypy/typeshed/stdlib/weakref.pyi +++ b/mypy/typeshed/stdlib/weakref.pyi @@ -1,4 +1,3 @@ -import types from _weakrefset import WeakSet as WeakSet from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, Tuple, Type, TypeVar, overload @@ -16,18 +15,19 @@ _S = TypeVar("_S") _T = TypeVar("_T") _KT = TypeVar("_KT") _VT = TypeVar("_VT") +_CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) ProxyTypes: Tuple[Type[Any], ...] -class WeakMethod(ref[types.MethodType]): - def __new__(cls, meth: types.MethodType, callback: Callable[[types.MethodType], Any] | None = ...) -> WeakMethod: ... - def __call__(self) -> types.MethodType | None: ... +class WeakMethod(ref[_CallableT], Generic[_CallableT]): + def __new__(cls, meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> WeakMethod[_CallableT]: ... + def __call__(self) -> _CallableT | None: ... class WeakValueDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self) -> None: ... @overload - def __init__(self, __other: Mapping[_KT, _VT] | Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... + def __init__(self, __other: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... @@ -39,7 +39,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): # These are incompatible with Mapping def keys(self) -> Iterator[_KT]: ... # type: ignore def values(self) -> Iterator[_VT]: ... # type: ignore - def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore + def items(self) -> Iterator[tuple[_KT, _VT]]: ... # type: ignore def itervaluerefs(self) -> Iterator[KeyedRef[_KT, _VT]]: ... def valuerefs(self) -> list[KeyedRef[_KT, _VT]]: ... @@ -53,7 +53,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self, dict: None = ...) -> None: ... @overload - def __init__(self, dict: Mapping[_KT, _VT] | Iterable[Tuple[_KT, _VT]]) -> None: ... + def __init__(self, dict: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]]) -> None: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... @@ -65,13 +65,13 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): # These are incompatible with Mapping def keys(self) -> Iterator[_KT]: ... # type: ignore def values(self) -> Iterator[_VT]: ... # type: ignore - def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore + def items(self) -> Iterator[tuple[_KT, _VT]]: ... # type: ignore def keyrefs(self) -> list[ref[_KT]]: ... 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/mypy/typeshed/stdlib/winreg.pyi b/mypy/typeshed/stdlib/winreg.pyi index 3c7ab0113e04..aeba48630a75 100644 --- a/mypy/typeshed/stdlib/winreg.pyi +++ b/mypy/typeshed/stdlib/winreg.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Any, Tuple, Type, Union +from typing import Any, Type, Union _KeyType = Union[HKEYType, int] @@ -12,15 +12,15 @@ def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ... def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ... def DeleteValue(__key: _KeyType, __value: str) -> None: ... def EnumKey(__key: _KeyType, __index: int) -> str: ... -def EnumValue(__key: _KeyType, __index: int) -> Tuple[str, Any, int]: ... +def EnumValue(__key: _KeyType, __index: int) -> tuple[str, Any, int]: ... def ExpandEnvironmentStrings(__str: str) -> str: ... def FlushKey(__key: _KeyType) -> None: ... def LoadKey(__key: _KeyType, __sub_key: str, __file_name: str) -> None: ... def OpenKey(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ... def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ... -def QueryInfoKey(__key: _KeyType) -> Tuple[int, int, int]: ... +def QueryInfoKey(__key: _KeyType) -> tuple[int, int, int]: ... def QueryValue(__key: _KeyType, __sub_key: str | None) -> str: ... -def QueryValueEx(__key: _KeyType, __name: str) -> Tuple[Any, int]: ... +def QueryValueEx(__key: _KeyType, __name: str) -> tuple[Any, int]: ... def SaveKey(__key: _KeyType, __file_name: str) -> None: ... def SetValue(__key: _KeyType, __sub_key: str, __type: int, __value: str) -> None: ... def SetValueEx( diff --git a/mypy/typeshed/stdlib/wsgiref/handlers.pyi b/mypy/typeshed/stdlib/wsgiref/handlers.pyi index b9899389cd3b..ac1e56b7664e 100644 --- a/mypy/typeshed/stdlib/wsgiref/handlers.pyi +++ b/mypy/typeshed/stdlib/wsgiref/handlers.pyi @@ -12,7 +12,7 @@ def format_date_time(timestamp: float | None) -> str: ... # undocumented def read_environ() -> dict[str, str]: ... class BaseHandler: - wsgi_version: Tuple[int, int] # undocumented + wsgi_version: tuple[int, int] # undocumented wsgi_multithread: bool wsgi_multiprocess: bool wsgi_run_once: bool @@ -28,7 +28,7 @@ class BaseHandler: traceback_limit: int | None error_status: str - error_headers: list[Tuple[str, str]] + error_headers: list[tuple[str, str]] error_body: bytes def run(self, application: WSGIApplication) -> None: ... def setup_environ(self) -> None: ... @@ -37,7 +37,7 @@ class BaseHandler: def set_content_length(self) -> None: ... def cleanup_headers(self) -> None: ... def start_response( - self, status: str, headers: list[Tuple[str, str]], exc_info: _exc_info | None = ... + self, status: str, headers: list[tuple[str, str]], exc_info: _exc_info | None = ... ) -> Callable[[bytes], None]: ... def send_preamble(self) -> None: ... def write(self, data: bytes) -> None: ... diff --git a/mypy/typeshed/stdlib/xml/dom/domreg.pyi b/mypy/typeshed/stdlib/xml/dom/domreg.pyi index 64c18ae80f0c..b9e2dd9eb263 100644 --- a/mypy/typeshed/stdlib/xml/dom/domreg.pyi +++ b/mypy/typeshed/stdlib/xml/dom/domreg.pyi @@ -1,8 +1,8 @@ from _typeshed.xml import DOMImplementation -from typing import Callable, Iterable, Tuple +from typing import Callable, Iterable well_known_implementations: dict[str, str] registered: dict[str, Callable[[], DOMImplementation]] def registerDOMImplementation(name: str, factory: Callable[[], DOMImplementation]) -> None: ... -def getDOMImplementation(name: str | None = ..., features: str | Iterable[Tuple[str, str | None]] = ...) -> DOMImplementation: ... +def getDOMImplementation(name: str | None = ..., features: str | Iterable[tuple[str, str | None]] = ...) -> DOMImplementation: ... diff --git a/mypy/typeshed/stdlib/xml/dom/minicompat.pyi b/mypy/typeshed/stdlib/xml/dom/minicompat.pyi index e9b0395ab50d..4bc60f7ab965 100644 --- a/mypy/typeshed/stdlib/xml/dom/minicompat.pyi +++ b/mypy/typeshed/stdlib/xml/dom/minicompat.pyi @@ -2,7 +2,7 @@ from typing import Any, Iterable, List, Tuple, Type, TypeVar _T = TypeVar("_T") -StringTypes: Tuple[Type[str]] +StringTypes: tuple[Type[str]] class NodeList(List[_T]): length: int diff --git a/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi b/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi index b9ecf52edf58..03a20dcad4cb 100644 --- a/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi +++ b/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi @@ -12,7 +12,6 @@ from typing import ( KeysView, MutableSequence, Sequence, - Tuple, TypeVar, Union, overload, @@ -26,7 +25,7 @@ VERSION: str class ParseError(SyntaxError): code: int - position: Tuple[int, int] + position: tuple[int, int] def iselement(element: object) -> bool: ... @@ -232,16 +231,16 @@ if sys.version_info >= (3, 9): def indent(tree: Element | ElementTree, space: str = ..., level: int = ...) -> None: ... def parse(source: _File, parser: XMLParser | None = ...) -> ElementTree: ... -def iterparse(source: _File, events: Sequence[str] | None = ..., parser: XMLParser | None = ...) -> Iterator[Tuple[str, Any]]: ... +def iterparse(source: _File, events: Sequence[str] | None = ..., parser: XMLParser | None = ...) -> Iterator[tuple[str, Any]]: ... class XMLPullParser: def __init__(self, events: Sequence[str] | None = ..., *, _parser: XMLParser | None = ...) -> None: ... def feed(self, data: bytes) -> None: ... def close(self) -> None: ... - def read_events(self) -> Iterator[Tuple[str, Element]]: ... + def read_events(self) -> Iterator[tuple[str, Element]]: ... def XML(text: str | bytes, parser: XMLParser | None = ...) -> Element: ... -def XMLID(text: str | bytes, parser: XMLParser | None = ...) -> Tuple[Element, dict[str, Element]]: ... +def XMLID(text: str | bytes, parser: XMLParser | None = ...) -> tuple[Element, dict[str, Element]]: ... # This is aliased to XML in the source. fromstring = XML diff --git a/mypy/typeshed/stdlib/xml/sax/xmlreader.pyi b/mypy/typeshed/stdlib/xml/sax/xmlreader.pyi index 8afc566b16a1..684e9cef1f42 100644 --- a/mypy/typeshed/stdlib/xml/sax/xmlreader.pyi +++ b/mypy/typeshed/stdlib/xml/sax/xmlreader.pyi @@ -1,4 +1,4 @@ -from typing import Mapping, Tuple +from typing import Mapping class XMLReader: def __init__(self) -> None: ... @@ -64,7 +64,7 @@ class AttributesImpl: def values(self): ... class AttributesNSImpl(AttributesImpl): - def __init__(self, attrs: Mapping[Tuple[str, str], str], qnames: Mapping[Tuple[str, str], str]) -> None: ... + def __init__(self, attrs: Mapping[tuple[str, str], str], qnames: Mapping[tuple[str, str], str]) -> None: ... def getValueByQName(self, name): ... def getNameByQName(self, name): ... def getQNameByName(self, name): ... diff --git a/mypy/typeshed/stdlib/xmlrpc/client.pyi b/mypy/typeshed/stdlib/xmlrpc/client.pyi index d0144e732bb7..061df849eff2 100644 --- a/mypy/typeshed/stdlib/xmlrpc/client.pyi +++ b/mypy/typeshed/stdlib/xmlrpc/client.pyi @@ -69,7 +69,7 @@ class DateTime: def __gt__(self, other: _DateTimeComparable) -> bool: ... def __ge__(self, other: _DateTimeComparable) -> bool: ... def __eq__(self, other: _DateTimeComparable) -> bool: ... # type: ignore - def make_comparable(self, other: _DateTimeComparable) -> Tuple[str, str]: ... # undocumented + def make_comparable(self, other: _DateTimeComparable) -> tuple[str, str]: ... # undocumented def timetuple(self) -> time.struct_time: ... # undocumented def decode(self, data: Any) -> None: ... def encode(self, out: SupportsWrite[str]) -> None: ... @@ -86,7 +86,7 @@ class Binary: def _binary(data: bytes) -> Binary: ... # undocumented -WRAPPERS: Tuple[Type[DateTime], Type[Binary]] # undocumented +WRAPPERS: tuple[Type[DateTime], Type[Binary]] # undocumented class ExpatParser: # undocumented def __init__(self, target: Unmarshaller) -> None: ... @@ -159,9 +159,9 @@ 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 __init__(self, call_list: list[tuple[str, _Marshallable]], name: str) -> None: ... def __getattr__(self, name: str) -> _MultiCallMethod: ... def __call__(self, *args: _Marshallable) -> None: ... @@ -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: ... @@ -184,7 +184,7 @@ FastMarshaller: Marshaller | None FastParser: ExpatParser | None FastUnmarshaller: Unmarshaller | None -def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[ExpatParser, Unmarshaller]: ... +def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[ExpatParser, Unmarshaller]: ... def dumps( params: Fault | Tuple[_Marshallable, ...], methodname: str | None = ..., @@ -192,7 +192,7 @@ def dumps( 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 @@ -218,13 +218,13 @@ class Transport: _use_datetime: bool _use_builtin_types: bool - _connection: Tuple[_HostType | None, http.client.HTTPConnection | None] - _headers: list[Tuple[str, str]] - _extra_headers: list[Tuple[str, str]] + _connection: tuple[_HostType | None, http.client.HTTPConnection | None] + _headers: list[tuple[str, str]] + _extra_headers: list[tuple[str, str]] if sys.version_info >= (3, 8): def __init__( - self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ... + self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[tuple[str, str]] = ... ) -> None: ... else: def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ... @@ -232,12 +232,12 @@ class Transport: def single_request( self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ... ) -> Tuple[_Marshallable, ...]: ... - def getparser(self) -> Tuple[ExpatParser, Unmarshaller]: ... - def get_host_info(self, host: _HostType) -> Tuple[str, list[Tuple[str, str]], dict[str, str]]: ... + def getparser(self) -> tuple[ExpatParser, Unmarshaller]: ... + def get_host_info(self, host: _HostType) -> tuple[str, list[tuple[str, str]], dict[str, str]]: ... def make_connection(self, host: _HostType) -> http.client.HTTPConnection: ... def close(self) -> None: ... def send_request(self, host: _HostType, handler: str, request_body: bytes, debug: bool) -> http.client.HTTPConnection: ... - def send_headers(self, connection: http.client.HTTPConnection, headers: list[Tuple[str, str]]) -> None: ... + def send_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, ...]: ... @@ -249,7 +249,7 @@ class SafeTransport(Transport): use_datetime: bool = ..., use_builtin_types: bool = ..., *, - headers: Iterable[Tuple[str, str]] = ..., + headers: Iterable[tuple[str, str]] = ..., context: Any | None = ..., ) -> None: ... else: @@ -276,7 +276,7 @@ class ServerProxy: use_datetime: bool = ..., use_builtin_types: bool = ..., *, - headers: Iterable[Tuple[str, str]] = ..., + headers: Iterable[tuple[str, str]] = ..., context: Any | None = ..., ) -> None: ... else: diff --git a/mypy/typeshed/stdlib/xmlrpc/server.pyi b/mypy/typeshed/stdlib/xmlrpc/server.pyi index 3240181a0467..bf5611fbaa96 100644 --- a/mypy/typeshed/stdlib/xmlrpc/server.pyi +++ b/mypy/typeshed/stdlib/xmlrpc/server.pyi @@ -64,7 +64,7 @@ class SimpleXMLRPCDispatcher: # undocumented class SimpleXMLRPCRequestHandler(http.server.BaseHTTPRequestHandler): - rpc_paths: Tuple[str, str] + rpc_paths: tuple[str, str] encode_threshold: int # undocumented aepattern: Pattern[str] # undocumented def accept_encodings(self) -> dict[str, float]: ... @@ -80,7 +80,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher): _send_traceback_handler: bool def __init__( self, - addr: Tuple[str, int], + addr: tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., @@ -96,7 +96,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented encoding: str def __init__( self, - addr: Tuple[str, int], + addr: tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., @@ -140,7 +140,7 @@ class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): class DocXMLRPCServer(SimpleXMLRPCServer, XMLRPCDocGenerator): def __init__( self, - addr: Tuple[str, int], + addr: tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., diff --git a/mypy/typeshed/stdlib/zipimport.pyi b/mypy/typeshed/stdlib/zipimport.pyi index 8ca97bf69845..155b9742aa57 100644 --- a/mypy/typeshed/stdlib/zipimport.pyi +++ b/mypy/typeshed/stdlib/zipimport.pyi @@ -1,7 +1,7 @@ import os import sys from types import CodeType, ModuleType -from typing import Any, Tuple +from typing import Any if sys.version_info >= (3, 7): from importlib.abc import ResourceReader @@ -12,7 +12,7 @@ class zipimporter(object): archive: str prefix: str def __init__(self, path: str | bytes | os.PathLike[Any]) -> None: ... - def find_loader(self, fullname: str, path: str | None = ...) -> Tuple[zipimporter | None, list[str]]: ... # undocumented + def find_loader(self, fullname: str, path: str | None = ...) -> tuple[zipimporter | None, list[str]]: ... # undocumented def find_module(self, fullname: str, path: str | None = ...) -> zipimporter | None: ... def get_code(self, fullname: str) -> CodeType: ... def get_data(self, pathname: str) -> str: ... diff --git a/mypy/typeshed/stubs/mypy-extensions/METADATA.toml b/mypy/typeshed/stubs/mypy-extensions/METADATA.toml index 8732c02c405f..79b51931ee0b 100644 --- a/mypy/typeshed/stubs/mypy-extensions/METADATA.toml +++ b/mypy/typeshed/stubs/mypy-extensions/METADATA.toml @@ -1,2 +1,2 @@ -version = "0.4" +version = "0.4.*" python2 = true