From 83b5bfbeeea45ecc4d6f308b0c0271d50032329e Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 22:09:35 +0000 Subject: [PATCH 1/7] Add a failing test --- tests/check_new_syntax.py | 155 +++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 78 deletions(-) diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index 906160fe79e2..0be99532312e 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -12,16 +12,42 @@ CONTEXT_MANAGER_ALIASES = {"ContextManager": "AbstractContextManager", "AsyncContextManager": "AbstractAsyncContextManager"} CONTEXTLIB_ALIAS_ALLOWLIST = frozenset({Path("stdlib/contextlib.pyi"), Path("stdlib/typing_extensions.pyi")}) +FORBIDDEN_BUILTIN_TYPING_IMPORTS = frozenset({"List", "FrozenSet", "Set", "Dict", "Tuple"}) + IMPORTED_FROM_TYPING_NOT_TYPING_EXTENSIONS = frozenset( - {"ClassVar", "Type", "NewType", "overload", "Text", "Protocol", "runtime_checkable", "NoReturn"} + {"ClassVar", "NewType", "overload", "Text", "Protocol", "runtime_checkable", "NoReturn"} ) -IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING_EXTENSIONS = frozenset( - {"Awaitable", "Coroutine", "AsyncIterable", "AsyncIterator", "AsyncGenerator"} -) +# AbstractSet intentionally omitted from this list -- special-cased +IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING = frozenset({ + "ByteString", + "Collection", + "Container", + "ItemsView", + "KeysView", + "Mapping", + "MappingView", + "MutableMapping", + "MutableSequence", + "MutableSet", + "Sequence", + "ValuesView", + "Iterable", + "Iterator", + "Generator", + "Hashable", + "Reversible", + "Sized", + "Coroutine", + "AsyncGenerator", + "AsyncIterable", + "AsyncIterator", + "Awaitable", + "Callable", + }) # The values in the mapping are what these are called in `collections` -IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS = { +IMPORTED_FROM_COLLECTIONS_NOT_TYPING = { "Counter": "Counter", "Deque": "deque", "DefaultDict": "defaultdict", @@ -34,21 +60,28 @@ def check_new_syntax(tree: ast.AST, path: Path) -> list[str]: errors = [] python_2_support_required = any(directory in path.parents for directory in STUBS_SUPPORTING_PYTHON_2) - def unparse_without_tuple_parens(node: ast.AST) -> str: - if isinstance(node, ast.Tuple) and node.elts: - return ast.unparse(node)[1:-1] - return ast.unparse(node) - - def is_dotdotdot(node: ast.AST) -> bool: - return isinstance(node, ast.Constant) and node.s is Ellipsis - - def add_contextlib_alias_error(node: ast.ImportFrom | ast.Attribute, alias: str) -> None: - errors.append(f"{path}:{node.lineno}: Use `contextlib.{CONTEXT_MANAGER_ALIASES[alias]}` instead of `typing.{alias}`") - - class OldSyntaxFinder(ast.NodeVisitor): - def __init__(self, *, set_from_collections_abc: bool) -> None: - self.set_from_collections_abc = set_from_collections_abc + def check_object_from_typing(node: ast.ImportFrom | ast.Attribute, object_name: str): + if object_name in FORBIDDEN_BUILTIN_TYPING_IMPORTS: + errors.append(f"{path}:{node.lineno}: Use `builtins.{object_name.lower()}` instead of `typing.{object_name}`") + elif object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING: + errors.append( + f"{path}:{node.lineno}: " + f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING[object_name]}` instead of `typing.{object_name}`" + ) + elif object_name in IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING: + if path not in {Path("stdlib/_collections_abc.pyi"), Path("stdlib/builtins.pyi")}: + errors.append(f"{path}:{node.lineno}: Use `collections.abc.{object_name}` instead of `typing.{object_name}`") + elif object_name == "AbstractSet": + if path != Path("stdlib/_collections_abc.pyi"): + errors.append( + f"{path}:{node.lineno}: Use `from collections.abc import Set as AbstractSet` instead of `typing.AbstractSet`" + ) + elif not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST and object_name in CONTEXT_MANAGER_ALIASES: + errors.append( + f"{path}:{node.lineno}: Use `contextlib.{CONTEXT_MANAGER_ALIASES[object_name]}` instead of `typing.{object_name}`" + ) + class UnionFinder(ast.NodeVisitor): def visit_Subscript(self, node: ast.Subscript) -> None: if isinstance(node.value, ast.Name): if node.value.id == "Union" and isinstance(node.slice, ast.Tuple): @@ -57,30 +90,6 @@ def visit_Subscript(self, node: ast.Subscript) -> None: if node.value.id == "Optional": new_syntax = f"{ast.unparse(node.slice)} | None" errors.append(f"{path}:{node.lineno}: Use PEP 604 syntax for Optional, e.g. `{new_syntax}`") - if node.value.id in {"List", "FrozenSet"}: - new_syntax = f"{node.value.id.lower()}[{ast.unparse(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use built-in generics, e.g. `{new_syntax}`") - if not self.set_from_collections_abc and node.value.id == "Set": - new_syntax = f"set[{ast.unparse(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use built-in generics, e.g. `{new_syntax}`") - if node.value.id == "Deque": - new_syntax = f"collections.deque[{ast.unparse(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use `collections.deque` instead of `typing.Deque`, e.g. `{new_syntax}`") - if node.value.id == "Dict": - new_syntax = f"dict[{unparse_without_tuple_parens(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use built-in generics, e.g. `{new_syntax}`") - if node.value.id == "DefaultDict": - new_syntax = f"collections.defaultdict[{unparse_without_tuple_parens(node.slice)}]" - errors.append( - f"{path}:{node.lineno}: Use `collections.defaultdict` instead of `typing.DefaultDict`, " - f"e.g. `{new_syntax}`" - ) - # Tuple[Foo, ...] must be allowed because of mypy bugs - if node.value.id == "Tuple" and not ( - isinstance(node.slice, ast.Tuple) and len(node.slice.elts) == 2 and is_dotdotdot(node.slice.elts[1]) - ): - new_syntax = f"tuple[{unparse_without_tuple_parens(node.slice)}]" - errors.append(f"{path}:{node.lineno}: Use built-in generics, e.g. `{new_syntax}`") self.generic_visit(node) @@ -88,21 +97,9 @@ def visit_Subscript(self, node: ast.Subscript) -> None: # currently supported # # TODO: can use built-in generics in type aliases - class AnnotationFinder(ast.NodeVisitor): - def __init__(self) -> None: - self.set_from_collections_abc = False - - def old_syntax_finder(self) -> OldSyntaxFinder: - """Convenience method to create an `OldSyntaxFinder` instance with the correct state""" - return OldSyntaxFinder(set_from_collections_abc=self.set_from_collections_abc) - + class OldSyntaxFinder(ast.NodeVisitor): def visit_ImportFrom(self, node: ast.ImportFrom) -> None: - if node.module == "collections.abc": - imported_classes = node.names - if any(cls.name == "Set" for cls in imported_classes): - self.set_from_collections_abc = True - - elif node.module == "typing_extensions": + if node.module == "typing_extensions": for imported_object in node.names: imported_object_name = imported_object.name if imported_object_name in IMPORTED_FROM_TYPING_NOT_TYPING_EXTENSIONS: @@ -110,17 +107,17 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: f"{path}:{node.lineno}: " f"Use `typing.{imported_object_name}` instead of `typing_extensions.{imported_object_name}`" ) - elif imported_object_name in IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING_EXTENSIONS: + elif imported_object_name in IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING: errors.append( f"{path}:{node.lineno}: " f"Use `collections.abc.{imported_object_name}` or `typing.{imported_object_name}` " f"instead of `typing_extensions.{imported_object_name}`" ) - elif imported_object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS: + elif imported_object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING: errors.append( f"{path}:{node.lineno}: " - f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS[imported_object_name]}` " - f"or `typing.{imported_object_name}` instead of `typing_extensions.{imported_object_name}`" + f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING[imported_object_name]}` " + f"instead of `typing_extensions.{imported_object_name}`" ) elif imported_object_name in CONTEXT_MANAGER_ALIASES: if python_2_support_required: @@ -134,36 +131,38 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: f"instead of `typing_extensions.{imported_object_name}`" ) - elif not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST and node.module == "typing": - for imported_class in node.names: - imported_class_name = imported_class.name - if imported_class_name in CONTEXT_MANAGER_ALIASES: - add_contextlib_alias_error(node, imported_class_name) - - self.generic_visit(node) + elif node.module == "collections.abc": + for imported_object in node.names: + if imported_object.name == "Set" and imported_object.asname != "AbstractSet": + errors.append( + f"{path}:{node.lineno}: " + f"Use `from collections.abc import Set as AbstractSet` to avoid ambiguity with `builtins.set`" + ) - if not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST: + elif node.module == "typing" and path != Path("stdlib/typing_extensions.pyi"): + for imported_object in node.names: + check_object_from_typing(node, imported_object.name) - def visit_Attribute(self, node: ast.Attribute) -> None: - if isinstance(node.value, ast.Name) and node.value.id == "typing" and node.attr in CONTEXT_MANAGER_ALIASES: - add_contextlib_alias_error(node, node.attr) - self.generic_visit(node) + def visit_Attribute(self, node: ast.Attribute) -> None: + if isinstance(node.value, ast.Name) and node.value.id == "typing" and path != Path("stdlib/typing_extensions.pyi"): + check_object_from_typing(node, node.attr) + self.generic_visit(node) def visit_AnnAssign(self, node: ast.AnnAssign) -> None: - self.old_syntax_finder().visit(node.annotation) + UnionFinder().visit(node.annotation) def visit_arg(self, node: ast.arg) -> None: if node.annotation is not None: - self.old_syntax_finder().visit(node.annotation) + UnionFinder().visit(node.annotation) def visit_FunctionDef(self, node: ast.FunctionDef) -> None: if node.returns is not None: - self.old_syntax_finder().visit(node.returns) + UnionFinder().visit(node.returns) self.generic_visit(node) def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None: if node.returns is not None: - self.old_syntax_finder().visit(node.returns) + UnionFinder().visit(node.returns) self.generic_visit(node) class IfFinder(ast.NodeVisitor): @@ -176,7 +175,7 @@ def visit_If(self, node: ast.If) -> None: ) self.generic_visit(node) - AnnotationFinder().visit(tree) + OldSyntaxFinder().visit(tree) IfFinder().visit(tree) return errors From dcdfa4ca04fe670d076321810ab5223954096aa1 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 22:40:40 +0000 Subject: [PATCH 2/7] Apply PEP 585 syntax everywhere, using script --- stdlib/_bisect.pyi | 3 +- stdlib/_codecs.pyi | 7 +- stdlib/_compression.pyi | 5 +- stdlib/_csv.pyi | 5 +- stdlib/_dummy_thread.pyi | 5 +- stdlib/_dummy_threading.pyi | 3 +- stdlib/_json.pyi | 3 +- stdlib/_operator.pyi | 21 +-- stdlib/_osx_support.pyi | 7 +- stdlib/_posixsubprocess.pyi | 3 +- stdlib/_py_abc.pyi | 4 +- stdlib/_random.pyi | 4 +- stdlib/_sitebuiltins.pyi | 3 +- stdlib/_socket.pyi | 8 +- stdlib/_thread.pyi | 7 +- stdlib/_threading_local.pyi | 4 +- stdlib/_tracemalloc.pyi | 3 +- stdlib/_typeshed/__init__.pyi | 3 +- stdlib/_typeshed/wsgi.pyi | 5 +- stdlib/_weakref.pyi | 3 +- stdlib/_weakrefset.pyi | 3 +- stdlib/_winapi.pyi | 3 +- stdlib/abc.pyi | 5 +- stdlib/aifc.pyi | 4 +- stdlib/argparse.pyi | 29 ++-- stdlib/array.pyi | 3 +- stdlib/ast.pyi | 3 +- stdlib/asyncio/base_events.pyi | 9 +- stdlib/asyncio/base_futures.pyi | 3 +- stdlib/asyncio/base_subprocess.pyi | 5 +- stdlib/asyncio/events.pyi | 7 +- stdlib/asyncio/format_helpers.pyi | 3 +- stdlib/asyncio/futures.pyi | 3 +- stdlib/asyncio/locks.pyi | 3 +- stdlib/asyncio/proactor_events.pyi | 3 +- stdlib/asyncio/runners.pyi | 3 +- stdlib/asyncio/sslproto.pyi | 3 +- stdlib/asyncio/staggered.pyi | 3 +- stdlib/asyncio/streams.pyi | 3 +- stdlib/asyncio/subprocess.pyi | 3 +- stdlib/asyncio/threads.pyi | 3 +- stdlib/asyncio/transports.pyi | 3 +- stdlib/asyncio/trsock.pyi | 7 +- stdlib/asyncio/unix_events.pyi | 3 +- stdlib/asyncio/windows_events.pyi | 3 +- stdlib/asyncio/windows_utils.pyi | 3 +- stdlib/asyncore.pyi | 8 +- stdlib/atexit.pyi | 3 +- stdlib/audioop.pyi | 6 +- stdlib/bdb.pyi | 5 +- stdlib/binhex.pyi | 4 +- stdlib/builtins.pyi | 72 ++++---- stdlib/bz2.pyi | 3 +- stdlib/cProfile.pyi | 5 +- stdlib/calendar.pyi | 7 +- stdlib/cgitb.pyi | 5 +- stdlib/cmd.pyi | 3 +- stdlib/code.pyi | 3 +- stdlib/codecs.pyi | 5 +- stdlib/collections/__init__.pyi | 18 +- stdlib/concurrent/futures/_base.pyi | 5 +- stdlib/concurrent/futures/process.pyi | 13 +- stdlib/concurrent/futures/thread.pyi | 9 +- stdlib/configparser.pyi | 4 +- stdlib/contextlib.pyi | 9 +- stdlib/contextvars.pyi | 3 +- stdlib/copyreg.pyi | 5 +- stdlib/csv.pyi | 2 +- stdlib/ctypes/__init__.pyi | 21 +-- stdlib/curses/__init__.pyi | 3 +- stdlib/curses/textpad.pyi | 3 +- stdlib/dataclasses.pyi | 11 +- stdlib/dbm/__init__.pyi | 3 +- stdlib/dbm/dumb.pyi | 3 +- stdlib/decimal.pyi | 9 +- stdlib/difflib.pyi | 3 +- stdlib/dis.pyi | 3 +- stdlib/distutils/ccompiler.pyi | 7 +- stdlib/distutils/cmd.pyi | 3 +- stdlib/distutils/command/install.pyi | 4 +- stdlib/distutils/core.pyi | 3 +- stdlib/distutils/dist.pyi | 3 +- stdlib/distutils/fancy_getopt.pyi | 7 +- stdlib/distutils/file_util.pyi | 3 +- stdlib/distutils/filelist.pyi | 3 +- stdlib/distutils/sysconfig.pyi | 3 +- stdlib/distutils/util.pyi | 4 +- stdlib/distutils/version.pyi | 4 +- stdlib/doctest.pyi | 5 +- stdlib/email/__init__.pyi | 3 +- stdlib/email/_header_value_parser.pyi | 5 +- stdlib/email/charset.pyi | 3 +- stdlib/email/contentmanager.pyi | 3 +- stdlib/email/feedparser.pyi | 3 +- stdlib/email/headerregistry.pyi | 10 +- stdlib/email/iterators.pyi | 3 +- stdlib/email/message.pyi | 9 +- stdlib/email/mime/application.pyi | 5 +- stdlib/email/mime/audio.pyi | 5 +- stdlib/email/mime/base.pyi | 4 +- stdlib/email/mime/image.pyi | 5 +- stdlib/email/mime/multipart.pyi | 5 +- stdlib/email/parser.pyi | 3 +- stdlib/email/policy.pyi | 3 +- stdlib/email/utils.pyi | 6 +- stdlib/enum.pyi | 10 +- stdlib/errno.pyi | 3 +- stdlib/filecmp.pyi | 3 +- stdlib/fileinput.pyi | 3 +- stdlib/fnmatch.pyi | 3 +- stdlib/formatter.pyi | 11 +- stdlib/ftplib.pyi | 5 +- stdlib/functools.pyi | 11 +- stdlib/genericpath.pyi | 5 +- stdlib/gettext.pyi | 3 +- stdlib/glob.pyi | 3 +- stdlib/graphlib.pyi | 5 +- stdlib/grp.pyi | 4 +- stdlib/heapq.pyi | 3 +- stdlib/hmac.pyi | 3 +- stdlib/html/parser.pyi | 4 +- stdlib/http/client.pyi | 3 +- stdlib/http/cookiejar.pyi | 7 +- stdlib/http/cookies.pyi | 7 +- stdlib/http/server.pyi | 3 +- stdlib/imaplib.pyi | 7 +- stdlib/imghdr.pyi | 3 +- stdlib/importlib/__init__.pyi | 3 +- stdlib/importlib/abc.pyi | 3 +- stdlib/importlib/machinery.pyi | 3 +- stdlib/importlib/metadata/__init__.pyi | 5 +- stdlib/importlib/metadata/_meta.pyi | 3 +- stdlib/importlib/resources.pyi | 3 +- stdlib/importlib/util.pyi | 3 +- stdlib/inspect.pyi | 12 +- stdlib/io.pyi | 7 +- stdlib/ipaddress.pyi | 3 +- stdlib/itertools.pyi | 33 ++-- stdlib/json/__init__.pyi | 3 +- stdlib/json/decoder.pyi | 3 +- stdlib/json/encoder.pyi | 3 +- stdlib/keyword.pyi | 3 +- stdlib/lib2to3/pgen2/driver.pyi | 3 +- stdlib/lib2to3/pgen2/grammar.pyi | 8 +- stdlib/lib2to3/pgen2/parse.pyi | 3 +- stdlib/lib2to3/pgen2/pgen.pyi | 3 +- stdlib/lib2to3/pgen2/tokenize.pyi | 7 +- stdlib/lib2to3/pytree.pyi | 9 +- stdlib/linecache.pyi | 6 +- stdlib/locale.pyi | 5 +- stdlib/logging/__init__.pyi | 6 +- stdlib/logging/config.pyi | 3 +- stdlib/lzma.pyi | 3 +- stdlib/mailbox.pyi | 11 +- stdlib/mailcap.pyi | 5 +- stdlib/math.pyi | 3 +- stdlib/mimetypes.pyi | 5 +- stdlib/mmap.pyi | 3 +- stdlib/modulefinder.pyi | 5 +- stdlib/msilib/__init__.pyi | 5 +- stdlib/msilib/sequence.pyi | 4 +- stdlib/multiprocessing/connection.pyi | 5 +- stdlib/multiprocessing/dummy/__init__.pyi | 3 +- stdlib/multiprocessing/dummy/connection.pyi | 4 +- stdlib/multiprocessing/managers.pyi | 5 +- stdlib/multiprocessing/pool.pyi | 5 +- stdlib/multiprocessing/process.pyi | 7 +- stdlib/multiprocessing/shared_memory.pyi | 5 +- stdlib/multiprocessing/spawn.pyi | 3 +- stdlib/multiprocessing/synchronize.pyi | 3 +- stdlib/netrc.pyi | 4 +- stdlib/nntplib.pyi | 5 +- stdlib/opcode.pyi | 3 +- stdlib/optparse.pyi | 19 ++- stdlib/os/__init__.pyi | 53 +++--- stdlib/parser.pyi | 7 +- stdlib/pathlib.pyi | 5 +- stdlib/pdb.pyi | 3 +- stdlib/pickle.pyi | 13 +- stdlib/pickletools.pyi | 9 +- stdlib/pkgutil.pyi | 3 +- stdlib/platform.pyi | 6 +- stdlib/plistlib.pyi | 9 +- stdlib/poplib.pyi | 4 +- stdlib/posixpath.pyi | 3 +- stdlib/profile.pyi | 5 +- stdlib/pstats.pyi | 5 +- stdlib/pty.pyi | 3 +- stdlib/pwd.pyi | 4 +- stdlib/pyclbr.pyi | 3 +- stdlib/pydoc.pyi | 11 +- stdlib/pyexpat/__init__.pyi | 5 +- stdlib/random.pyi | 6 +- stdlib/re.pyi | 3 +- stdlib/readline.pyi | 3 +- stdlib/reprlib.pyi | 5 +- stdlib/resource.pyi | 4 +- stdlib/sched.pyi | 9 +- stdlib/select.pyi | 3 +- stdlib/selectors.pyi | 3 +- stdlib/shlex.pyi | 3 +- stdlib/shutil.pyi | 3 +- stdlib/signal.pyi | 5 +- stdlib/site.pyi | 3 +- stdlib/smtpd.pyi | 4 +- stdlib/smtplib.pyi | 9 +- stdlib/socketserver.pyi | 7 +- stdlib/spwd.pyi | 4 +- stdlib/sqlite3/dbapi2.pyi | 3 +- stdlib/sre_parse.pyi | 17 +- stdlib/ssl.pyi | 11 +- stdlib/statistics.pyi | 3 +- stdlib/string.pyi | 3 +- stdlib/struct.pyi | 15 +- stdlib/subprocess.pyi | 3 +- stdlib/symtable.pyi | 15 +- stdlib/sys.pyi | 21 +-- stdlib/sysconfig.pyi | 6 +- stdlib/tabnanny.pyi | 3 +- stdlib/tarfile.pyi | 10 +- stdlib/telnetlib.pyi | 3 +- stdlib/tempfile.pyi | 5 +- stdlib/termios.pyi | 4 +- stdlib/textwrap.pyi | 3 +- stdlib/threading.pyi | 3 +- stdlib/time.pyi | 4 +- stdlib/timeit.pyi | 3 +- stdlib/tkinter/__init__.pyi | 161 +++++++++--------- stdlib/tkinter/commondialog.pyi | 3 +- stdlib/tkinter/dialog.pyi | 3 +- stdlib/tkinter/filedialog.pyi | 19 ++- stdlib/tkinter/font.pyi | 10 +- stdlib/tkinter/tix.pyi | 10 +- stdlib/tkinter/ttk.pyi | 59 +++---- stdlib/tokenize.pyi | 5 +- stdlib/trace.pyi | 5 +- stdlib/traceback.pyi | 7 +- stdlib/tracemalloc.pyi | 9 +- stdlib/turtle.pyi | 15 +- stdlib/types.pyi | 101 +++++------ stdlib/typing_extensions.pyi | 34 ++-- stdlib/unittest/async_case.pyi | 3 +- stdlib/unittest/case.pyi | 43 ++--- stdlib/unittest/loader.pyi | 5 +- stdlib/unittest/main.pyi | 3 +- stdlib/unittest/mock.pyi | 7 +- stdlib/unittest/result.pyi | 5 +- stdlib/unittest/runner.pyi | 3 +- stdlib/unittest/signals.pyi | 3 +- stdlib/unittest/suite.pyi | 3 +- stdlib/unittest/util.pyi | 5 +- stdlib/urllib/parse.pyi | 5 +- stdlib/urllib/request.pyi | 7 +- stdlib/urllib/response.pyi | 5 +- stdlib/urllib/robotparser.pyi | 3 +- stdlib/uuid.pyi | 4 +- stdlib/venv/__init__.pyi | 3 +- stdlib/warnings.pyi | 3 +- stdlib/weakref.pyi | 9 +- stdlib/webbrowser.pyi | 3 +- stdlib/wsgiref/handlers.pyi | 5 +- stdlib/wsgiref/headers.pyi | 4 +- stdlib/wsgiref/util.pyi | 3 +- stdlib/wsgiref/validate.pyi | 3 +- stdlib/xdrlib.pyi | 3 +- stdlib/xml/dom/domreg.pyi | 3 +- stdlib/xml/dom/minicompat.pyi | 7 +- stdlib/xml/dom/pulldom.pyi | 5 +- stdlib/xml/etree/ElementInclude.pyi | 3 +- stdlib/xml/etree/ElementPath.pyi | 7 +- stdlib/xml/etree/ElementTree.pyi | 23 +-- stdlib/xml/sax/__init__.pyi | 3 +- stdlib/xml/sax/saxutils.pyi | 3 +- stdlib/xml/sax/xmlreader.pyi | 3 +- stdlib/xmlrpc/client.pyi | 33 ++-- stdlib/xmlrpc/server.pyi | 9 +- stdlib/zipapp.pyi | 3 +- stdlib/zipfile.pyi | 5 +- stdlib/zoneinfo/__init__.pyi | 3 +- .../DateTimeRange/datetimerange/__init__.pyi | 3 +- stubs/Deprecated/deprecated/classic.pyi | 3 +- stubs/Deprecated/deprecated/sphinx.pyi | 3 +- stubs/JACK-Client/jack/__init__.pyi | 3 +- stubs/Markdown/markdown/blockparser.pyi | 5 +- stubs/Markdown/markdown/core.pyi | 3 +- .../Markdown/markdown/extensions/__init__.pyi | 3 +- stubs/Pillow/PIL/ExifTags.pyi | 3 +- stubs/Pillow/PIL/Image.pyi | 21 +-- stubs/Pillow/PIL/ImageColor.pyi | 6 +- stubs/Pillow/PIL/ImageDraw.pyi | 5 +- stubs/Pillow/PIL/ImageFilter.pyi | 5 +- stubs/Pillow/PIL/ImageOps.pyi | 3 +- stubs/Pillow/PIL/PdfParser.pyi | 4 +- stubs/Pillow/PIL/TiffTags.pyi | 4 +- stubs/PyMySQL/pymysql/__init__.pyi | 4 +- stubs/PyMySQL/pymysql/connections.pyi | 5 +- stubs/PyMySQL/pymysql/cursors.pyi | 21 +-- .../Pygments/pygments/formatters/__init__.pyi | 3 +- stubs/Pygments/pygments/lexer.pyi | 4 +- stubs/Pygments/pygments/lexers/__init__.pyi | 4 +- stubs/Pygments/pygments/token.pyi | 4 +- stubs/aiofiles/aiofiles/base.pyi | 3 +- stubs/aiofiles/aiofiles/os.pyi | 3 +- .../aiofiles/aiofiles/threadpool/__init__.pyi | 3 +- stubs/aiofiles/aiofiles/threadpool/binary.pyi | 3 +- stubs/aiofiles/aiofiles/threadpool/text.pyi | 5 +- stubs/atomicwrites/atomicwrites/__init__.pyi | 3 +- .../aws_xray_sdk/core/patcher.pyi | 3 +- .../aws_xray_sdk/core/recorder.pyi | 3 +- stubs/babel/babel/messages/plurals.pyi | 4 +- stubs/beautifulsoup4/bs4/__init__.pyi | 3 +- stubs/beautifulsoup4/bs4/dammit.pyi | 4 +- stubs/beautifulsoup4/bs4/element.pyi | 11 +- stubs/beautifulsoup4/bs4/formatter.pyi | 3 +- stubs/bleach/bleach/sanitizer.pyi | 6 +- stubs/boto/boto/kms/layer1.pyi | 3 +- stubs/boto/boto/s3/bucketlistresultset.pyi | 3 +- stubs/boto/boto/s3/cors.pyi | 4 +- stubs/boto/boto/s3/key.pyi | 3 +- stubs/boto/boto/s3/lifecycle.pyi | 6 +- stubs/boto/boto/s3/tagging.pyi | 6 +- stubs/boto/boto/s3/website.pyi | 4 +- stubs/boto/boto/utils.pyi | 7 +- stubs/cachetools/cachetools/__init__.pyi | 3 +- stubs/cachetools/cachetools/func.pyi | 3 +- stubs/cachetools/cachetools/keys.pyi | 7 +- .../characteristic/__init__.pyi | 3 +- stubs/chardet/chardet/__init__.pyi | 12 +- stubs/chardet/chardet/langbulgarianmodel.pyi | 8 +- stubs/chardet/chardet/langcyrillicmodel.pyi | 16 +- stubs/chardet/chardet/langgreekmodel.pyi | 8 +- stubs/chardet/chardet/langhebrewmodel.pyi | 6 +- stubs/chardet/chardet/langhungarianmodel.pyi | 8 +- stubs/chardet/chardet/langthaimodel.pyi | 6 +- stubs/chardet/chardet/langturkishmodel.pyi | 6 +- .../click-spinner/click_spinner/__init__.pyi | 3 +- stubs/colorama/colorama/ansitowin32.pyi | 7 +- stubs/colorama/colorama/win32.pyi | 3 +- stubs/contextvars/contextvars.pyi | 3 +- stubs/croniter/croniter.pyi | 11 +- .../hazmat/primitives/serialization/pkcs7.pyi | 3 +- .../cryptography/x509/__init__.pyi | 3 +- .../cryptography/x509/extensions.pyi | 3 +- stubs/dataclasses/dataclasses.pyi | 9 +- stubs/dateparser/dateparser/date.pyi | 3 +- .../dateparser/languages/loader.pyi | 3 +- .../dateparser/dateparser/search/__init__.pyi | 6 +- .../dateparser/dateparser/utils/__init__.pyi | 3 +- stubs/decorator/decorator.pyi | 11 +- stubs/docopt/docopt.pyi | 3 +- stubs/docutils/docutils/__init__.pyi | 12 +- stubs/docutils/docutils/frontend.pyi | 4 +- stubs/docutils/docutils/parsers/null.pyi | 4 +- .../docutils/parsers/rst/__init__.pyi | 4 +- stubs/docutils/docutils/parsers/rst/roles.pyi | 7 +- stubs/editdistance/editdistance.pyi | 3 +- stubs/entrypoints/entrypoints.pyi | 3 +- stubs/first/first.pyi | 3 +- stubs/flake8-2020/flake8_2020.pyi | 3 +- stubs/flake8-bugbear/bugbear.pyi | 3 +- stubs/flake8-builtins/flake8_builtins.pyi | 3 +- stubs/flake8-docstrings/flake8_docstrings.pyi | 3 +- .../flake8_plugin_utils/plugin.pyi | 5 +- stubs/flake8-simplify/flake8_simplify.pyi | 3 +- .../flake8_typing_imports.pyi | 3 +- stubs/fpdf2/fpdf/image_parsing.pyi | 4 +- stubs/fpdf2/fpdf/syntax.pyi | 4 +- stubs/fpdf2/fpdf/util.pyi | 4 +- stubs/frozendict/frozendict.pyi | 3 +- .../google/cloud/ndb/context.pyi | 3 +- .../google/cloud/ndb/model.pyi | 3 +- stubs/hdbcli/hdbcli/dbapi.pyi | 17 +- stubs/hdbcli/hdbcli/resultrow.pyi | 6 +- stubs/html5lib/html5lib/_tokenizer.pyi | 4 +- stubs/html5lib/html5lib/_utils.pyi | 4 +- stubs/html5lib/html5lib/treebuilders/base.pyi | 4 +- stubs/httplib2/httplib2/__init__.pyi | 4 +- stubs/jsonschema/jsonschema/_format.pyi | 3 +- .../jsonschema/_legacy_validators.pyi | 3 +- stubs/jsonschema/jsonschema/_types.pyi | 3 +- stubs/jsonschema/jsonschema/_utils.pyi | 3 +- stubs/jsonschema/jsonschema/protocols.pyi | 3 +- stubs/jsonschema/jsonschema/validators.pyi | 3 +- stubs/ldap3/ldap3/__init__.pyi | 10 +- stubs/mock/mock/mock.pyi | 8 +- stubs/mypy-extensions/mypy_extensions.pyi | 3 +- stubs/mysqlclient/MySQLdb/__init__.pyi | 4 +- stubs/mysqlclient/MySQLdb/_mysql.pyi | 4 +- stubs/oauthlib/oauthlib/common.pyi | 4 +- .../oauthlib/oauth2/rfc6749/tokens.pyi | 4 +- .../opentracing/harness/scope_check.pyi | 3 +- stubs/paramiko/paramiko/agent.pyi | 4 +- stubs/paramiko/paramiko/auth_handler.pyi | 5 +- stubs/paramiko/paramiko/ber.pyi | 3 +- stubs/paramiko/paramiko/channel.pyi | 3 +- stubs/paramiko/paramiko/client.pyi | 3 +- stubs/paramiko/paramiko/config.pyi | 5 +- stubs/paramiko/paramiko/dsskey.pyi | 3 +- stubs/paramiko/paramiko/ecdsakey.pyi | 3 +- stubs/paramiko/paramiko/file.pyi | 5 +- stubs/paramiko/paramiko/hostkeys.pyi | 3 +- stubs/paramiko/paramiko/kex_curve25519.pyi | 3 +- stubs/paramiko/paramiko/kex_ecdh_nist.pyi | 3 +- stubs/paramiko/paramiko/kex_gex.pyi | 3 +- stubs/paramiko/paramiko/kex_group1.pyi | 3 +- stubs/paramiko/paramiko/kex_group14.pyi | 3 +- stubs/paramiko/paramiko/kex_group16.pyi | 3 +- stubs/paramiko/paramiko/message.pyi | 3 +- stubs/paramiko/paramiko/packet.pyi | 3 +- stubs/paramiko/paramiko/py3compat.pyi | 3 +- stubs/paramiko/paramiko/rsakey.pyi | 3 +- stubs/paramiko/paramiko/server.pyi | 4 +- stubs/paramiko/paramiko/sftp_client.pyi | 3 +- stubs/paramiko/paramiko/sftp_file.pyi | 3 +- stubs/paramiko/paramiko/ssh_exception.pyi | 3 +- stubs/paramiko/paramiko/ssh_gss.pyi | 4 +- stubs/paramiko/paramiko/transport.pyi | 7 +- stubs/paramiko/paramiko/util.pyi | 3 +- stubs/polib/polib.pyi | 5 +- stubs/psutil/psutil/__init__.pyi | 7 +- stubs/psutil/psutil/_common.pyi | 3 +- stubs/psycopg2/psycopg2/_psycopg.pyi | 9 +- stubs/psycopg2/psycopg2/extras.pyi | 4 +- stubs/pyOpenSSL/OpenSSL/SSL.pyi | 3 +- stubs/pyOpenSSL/OpenSSL/crypto.pyi | 7 +- stubs/pyaudio/pyaudio.pyi | 5 +- stubs/pycurl/pycurl.pyi | 4 +- stubs/pysftp/pysftp/__init__.pyi | 3 +- stubs/pysftp/pysftp/helpers.pyi | 3 +- .../pytest_lazyfixture.pyi | 3 +- .../dateutil/parser/__init__.pyi | 3 +- stubs/python-dateutil/dateutil/rrule.pyi | 3 +- stubs/python-gflags/gflags.pyi | 3 +- stubs/python-nmap/nmap/nmap.pyi | 5 +- stubs/python-slugify/slugify/slugify.pyi | 3 +- stubs/python-slugify/slugify/special.pyi | 3 +- stubs/pytz/pytz/__init__.pyi | 3 +- stubs/redis/redis/client.pyi | 15 +- stubs/redis/redis/connection.pyi | 3 +- stubs/requests/requests/adapters.pyi | 3 +- stubs/requests/requests/cookies.pyi | 3 +- stubs/requests/requests/models.pyi | 3 +- .../packages/urllib3/_collections.pyi | 3 +- stubs/requests/requests/sessions.pyi | 11 +- stubs/requests/requests/structures.pyi | 5 +- stubs/requests/requests/utils.pyi | 3 +- stubs/retry/retry/api.pyi | 7 +- stubs/setuptools/pkg_resources/__init__.pyi | 19 ++- .../setuptools/command/easy_install.pyi | 4 +- stubs/setuptools/setuptools/command/test.pyi | 3 +- stubs/singledispatch/singledispatch.pyi | 3 +- stubs/six/six/__init__.pyi | 6 +- stubs/stripe/stripe/stripe_object.pyi | 4 +- stubs/tabulate/tabulate.pyi | 7 +- stubs/termcolor/termcolor.pyi | 3 +- stubs/toml/toml.pyi | 3 +- stubs/toposort/toposort.pyi | 3 +- stubs/typed-ast/typed_ast/ast27.pyi | 3 +- stubs/typed-ast/typed_ast/ast3.pyi | 3 +- stubs/vobject/vobject/base.pyi | 3 +- stubs/vobject/vobject/icalendar.pyi | 12 +- stubs/waitress/waitress/__init__.pyi | 4 +- stubs/waitress/waitress/adjustments.pyi | 3 +- stubs/waitress/waitress/buffers.pyi | 3 +- stubs/waitress/waitress/channel.pyi | 3 +- stubs/waitress/waitress/parser.pyi | 3 +- stubs/waitress/waitress/proxy_headers.pyi | 3 +- stubs/waitress/waitress/runner.pyi | 3 +- stubs/waitress/waitress/server.pyi | 3 +- stubs/waitress/waitress/task.pyi | 3 +- stubs/waitress/waitress/trigger.pyi | 3 +- stubs/waitress/waitress/utilities.pyi | 3 +- stubs/waitress/waitress/wasyncore.pyi | 3 +- 473 files changed, 1651 insertions(+), 1271 deletions(-) diff --git a/stdlib/_bisect.pyi b/stdlib/_bisect.pyi index 1f67dadd89a0..0fe373bf2dc1 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, MutableSequence, Sequence import sys from _typeshed import SupportsRichComparison -from typing import Callable, MutableSequence, Sequence, TypeVar +from typing import TypeVar _T = TypeVar("_T") diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index a44a8a1a7c2a..fe31c7fab296 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -1,13 +1,14 @@ +from collections.abc import Callable import codecs import sys -from typing import Any, Callable, Dict, Tuple, Union +from typing import Any, Union # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap: def size(self) -> int: ... -_MapT = Union[Dict[int, int], _EncodingMap] -_Handler = Callable[[Exception], Tuple[str, int]] +_MapT = Union[dict[int, int], _EncodingMap] +_Handler = Callable[[Exception], tuple[str, int]] def register(__search_function: Callable[[str], Any]) -> None: ... def register_error(__errors: str, __handler: _Handler) -> None: ... diff --git a/stdlib/_compression.pyi b/stdlib/_compression.pyi index 8f81847ff492..4bd476088a91 100644 --- a/stdlib/_compression.pyi +++ b/stdlib/_compression.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable from _typeshed import WriteableBuffer from io import BufferedIOBase, RawIOBase -from typing import Any, Callable, Protocol, Tuple, Type +from typing import Any, Protocol, Type BUFFER_SIZE: Any @@ -16,7 +17,7 @@ class DecompressReader(RawIOBase): self, fp: _Reader, decomp_factory: Callable[..., object], - trailing_error: Type[Exception] | Tuple[Type[Exception], ...] = ..., + trailing_error: Type[Exception] | tuple[Type[Exception], ...] = ..., **decomp_args: Any, ) -> None: ... def readable(self) -> bool: ... diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index 65f0ca27f0ec..6e03994dce49 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Iterator, List, Protocol, Type, Union +from collections.abc import Iterable, Iterator +from typing import Any, Protocol, Type, Union QUOTE_ALL: int QUOTE_MINIMAL: int @@ -20,7 +21,7 @@ class Dialect: _DialectLike = Union[str, Dialect, Type[Dialect]] -class _reader(Iterator[List[str]]): +class _reader(Iterator[list[str]]): dialect: Dialect line_num: int def __next__(self) -> list[str]: ... diff --git a/stdlib/_dummy_thread.pyi b/stdlib/_dummy_thread.pyi index 886d9d739780..1570cd05992c 100644 --- a/stdlib/_dummy_thread.pyi +++ b/stdlib/_dummy_thread.pyi @@ -1,9 +1,10 @@ -from typing import Any, Callable, NoReturn, Tuple +from collections.abc import Callable +from typing import Any, NoReturn TIMEOUT_MAX: int error = RuntimeError -def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... +def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... def exit() -> NoReturn: ... def get_ident() -> int: ... def allocate_lock() -> LockType: ... diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index 64998d86bf9f..f24d8a092e88 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Mapping import sys from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, Mapping, Optional, Type, TypeVar +from typing import Any, Optional, Type, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] diff --git a/stdlib/_json.pyi b/stdlib/_json.pyi index 7395288afdbc..59f696fe49ba 100644 --- a/stdlib/_json.pyi +++ b/stdlib/_json.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable +from collections.abc import Callable +from typing import Any class make_encoder: sort_keys: Any diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index 408ec7ca28dc..ea5cfce0a56e 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -1,19 +1,20 @@ +from collections.abc import Callable, Container, Iterable, Mapping, MutableMapping, MutableSequence, Sequence import sys from _typeshed import SupportsAnyComparison from typing import ( Any, AnyStr, - Callable, - Container, + + Generic, - Iterable, - Mapping, - MutableMapping, - MutableSequence, + + + + Protocol, - Sequence, + SupportsAbs, - Tuple, + TypeVar, overload, ) @@ -99,7 +100,7 @@ class attrgetter(Generic[_T_co]): @overload def __new__(cls, attr: str, __attr2: str, __attr3: str, __attr4: str) -> attrgetter[tuple[Any, Any, Any, Any]]: ... @overload - def __new__(cls, attr: str, *attrs: str) -> attrgetter[Tuple[Any, ...]]: ... + def __new__(cls, attr: str, *attrs: str) -> attrgetter[tuple[Any, ...]]: ... def __call__(self, obj: Any) -> _T_co: ... @final @@ -113,7 +114,7 @@ class itemgetter(Generic[_T_co]): @overload def __new__(cls, item: Any, __item2: Any, __item3: Any, __item4: Any) -> itemgetter[tuple[Any, Any, Any, Any]]: ... @overload - def __new__(cls, item: Any, *items: Any) -> itemgetter[Tuple[Any, ...]]: ... + def __new__(cls, item: Any, *items: Any) -> itemgetter[tuple[Any, ...]]: ... def __call__(self, obj: Any) -> _T_co: ... @final diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index 49ebf93c31b7..1f99b460f3bb 100644 --- a/stdlib/_osx_support.pyi +++ b/stdlib/_osx_support.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Sequence import sys -from typing import Iterable, Sequence, Tuple, TypeVar +from typing import TypeVar _T = TypeVar("_T") _K = TypeVar("_K") @@ -7,8 +8,8 @@ _V = TypeVar("_V") __all__: list[str] -_UNIVERSAL_CONFIG_VARS: Tuple[str, ...] # undocumented -_COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented +_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented +_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented _INITPRE: str # undocumented def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented diff --git a/stdlib/_posixsubprocess.pyi b/stdlib/_posixsubprocess.pyi index 0eae723e7a67..dcd0f3eee23e 100644 --- a/stdlib/_posixsubprocess.pyi +++ b/stdlib/_posixsubprocess.pyi @@ -1,6 +1,7 @@ # NOTE: These are incomplete! -from typing import Callable, Sequence +from collections.abc import Callable, Sequence + def cloexec_pipe() -> tuple[int, int]: ... def fork_exec( diff --git a/stdlib/_py_abc.pyi b/stdlib/_py_abc.pyi index 8d7938918271..697a7f17111a 100644 --- a/stdlib/_py_abc.pyi +++ b/stdlib/_py_abc.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple, Type, TypeVar +from typing import Any, Type, TypeVar _T = TypeVar("_T") @@ -6,5 +6,5 @@ _T = TypeVar("_T") def get_cache_token() -> object: ... class ABCMeta(type): - def __new__(__mcls, __name: str, __bases: Tuple[Type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ... + def __new__(__mcls, __name: str, __bases: tuple[Type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ... def register(cls, subclass: Type[_T]) -> Type[_T]: ... diff --git a/stdlib/_random.pyi b/stdlib/_random.pyi index fa80c6d98144..d5d46fca61bd 100644 --- a/stdlib/_random.pyi +++ b/stdlib/_random.pyi @@ -1,7 +1,7 @@ -from typing import Tuple + # Actually Tuple[(int,) * 625] -_State = Tuple[int, ...] +_State = tuple[int, ...] class Random(object): def __init__(self, seed: object = ...) -> None: ... diff --git a/stdlib/_sitebuiltins.pyi b/stdlib/_sitebuiltins.pyi index a71364b8db65..4a35921e1ef7 100644 --- a/stdlib/_sitebuiltins.pyi +++ b/stdlib/_sitebuiltins.pyi @@ -1,4 +1,5 @@ -from typing import ClassVar, Iterable, NoReturn +from collections.abc import Iterable +from typing import ClassVar, NoReturn from typing_extensions import Literal class Quitter: diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 82898177286b..d7d7f73ea37d 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Iterable -from typing import Any, SupportsInt, Tuple, Union, overload +from typing import Any, SupportsInt, Union, overload if sys.version_info >= (3, 8): from typing import SupportsIndex @@ -10,12 +10,12 @@ if sys.version_info >= (3, 8): else: _FD = SupportsInt -_CMSG = Tuple[int, int, bytes] -_CMSGArg = Tuple[int, int, ReadableBuffer] +_CMSG = tuple[int, int, bytes] +_CMSGArg = tuple[int, int, ReadableBuffer] # Addresses can be either tuples of varying lengths (AF_INET, AF_INET6, # AF_NETLINK, AF_TIPC) or strings (AF_UNIX). -_Address = Union[Tuple[Any, ...], str] +_Address = Union[tuple[Any, ...], str] _RetAddress = Any # TODO Most methods allow bytes as address objects diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 55ca3e80c7de..ed94178284c4 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable import sys from _typeshed import structseq from threading import Thread from types import TracebackType -from typing import Any, Callable, NoReturn, Optional, Tuple, Type +from typing import Any, NoReturn, Optional, Type from typing_extensions import final error = RuntimeError @@ -21,7 +22,7 @@ class LockType: self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... -def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ... +def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ... def interrupt_main() -> None: ... def exit() -> NoReturn: ... def allocate_lock() -> LockType: ... @@ -34,7 +35,7 @@ if sys.version_info >= (3, 8): def get_native_id() -> int: ... # only available on some platforms @final class _ExceptHookArgs( - structseq[Any], Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]] + structseq[Any], tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]] ): @property def exc_type(self) -> Type[BaseException]: ... diff --git a/stdlib/_threading_local.pyi b/stdlib/_threading_local.pyi index bab69a7c2e7d..9e1e3f48d286 100644 --- a/stdlib/_threading_local.pyi +++ b/stdlib/_threading_local.pyi @@ -1,7 +1,7 @@ -from typing import Any, Dict +from typing import Any from weakref import ReferenceType -localdict = Dict[Any, Any] +localdict = dict[Any, Any] class _localimpl: key: str diff --git a/stdlib/_tracemalloc.pyi b/stdlib/_tracemalloc.pyi index fd159dc586cb..8a6e30305126 100644 --- a/stdlib/_tracemalloc.pyi +++ b/stdlib/_tracemalloc.pyi @@ -1,6 +1,7 @@ +from collections.abc import Sequence import sys from tracemalloc import _FrameTupleT, _TraceTupleT -from typing import Sequence + def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ... def _get_traces() -> Sequence[_TraceTupleT]: ... diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index a7f8c5147103..c249c964a1d4 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -2,12 +2,13 @@ # # See the README.md file in this directory for more information. +from collections.abc import Awaitable, Container, Iterable import array import ctypes import mmap import sys from os import PathLike -from typing import AbstractSet, Any, Awaitable, ClassVar, Container, Generic, Iterable, Protocol, Type, TypeVar, Union +from typing import AbstractSet, Any, ClassVar, Generic, Protocol, Type, TypeVar, Union from typing_extensions import Literal, final _KT = TypeVar("_KT") diff --git a/stdlib/_typeshed/wsgi.pyi b/stdlib/_typeshed/wsgi.pyi index 658b0fed2c6c..087751b75f13 100644 --- a/stdlib/_typeshed/wsgi.pyi +++ b/stdlib/_typeshed/wsgi.pyi @@ -2,8 +2,9 @@ # # See the README.md file in this directory for more information. +from collections.abc import Callable, Iterable from sys import _OptExcInfo -from typing import Any, Callable, Dict, Iterable, Protocol +from typing import Any, Protocol # stable class StartResponse(Protocol): @@ -11,7 +12,7 @@ class StartResponse(Protocol): self, status: str, headers: list[tuple[str, str]], exc_info: _OptExcInfo | None = ... ) -> Callable[[bytes], Any]: ... -WSGIEnvironment = Dict[str, Any] # stable +WSGIEnvironment = dict[str, Any] # stable WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] # stable # WSGI input streams per PEP 3333, stable diff --git a/stdlib/_weakref.pyi b/stdlib/_weakref.pyi index 00dc2d5114b8..c7956c2b9e95 100644 --- a/stdlib/_weakref.pyi +++ b/stdlib/_weakref.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable import sys -from typing import Any, Callable, Generic, TypeVar, overload +from typing import Any, Generic, TypeVar, overload from typing_extensions import final if sys.version_info >= (3, 9): diff --git a/stdlib/_weakrefset.pyi b/stdlib/_weakrefset.pyi index 1f0132f4c240..cdcb806c6914 100644 --- a/stdlib/_weakrefset.pyi +++ b/stdlib/_weakrefset.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Iterator, MutableSet import sys -from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar +from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index 83089d485c17..6eeb05e37257 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence import sys -from typing import Any, NoReturn, Sequence, overload +from typing import Any, NoReturn, overload from typing_extensions import Literal, final CREATE_NEW_CONSOLE: int diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index c9dbda103ef3..899a4b14cd6d 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import sys from _typeshed import SupportsWrite -from typing import Any, Callable, Tuple, Type, TypeVar +from typing import Any, Type, TypeVar _T = TypeVar("_T") _FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) @@ -8,7 +9,7 @@ _FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) # These definitions have special processing in mypy class ABCMeta(type): __abstractmethods__: frozenset[str] - def __init__(self, name: str, bases: Tuple[type, ...], namespace: dict[str, Any]) -> None: ... + def __init__(self, name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> None: ... def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ... diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index 79f470a366bb..e19bf2478bf3 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self from types import TracebackType -from typing import IO, Any, NamedTuple, Tuple, Type, Union, overload +from typing import IO, Any, NamedTuple, Type, Union, overload from typing_extensions import Literal class Error(Exception): ... @@ -15,7 +15,7 @@ class _aifc_params(NamedTuple): compname: bytes _File = Union[str, IO[bytes]] -_Marker = Tuple[int, int, bytes] +_Marker = tuple[int, int, bytes] class Aifc_read: def __init__(self, f: _File) -> None: ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 8e252ddc75c6..8af7478a58e9 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -1,16 +1,17 @@ +from collections.abc import Callable, Generator, Iterable, Sequence import sys from typing import ( IO, Any, - Callable, - Generator, + + Generic, - Iterable, + NoReturn, Pattern, Protocol, - Sequence, - Tuple, + + Type, TypeVar, overload, @@ -70,7 +71,7 @@ class _ActionsContainer: choices: Iterable[_T] | None = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., dest: str | None = ..., version: str = ..., **kwargs: Any, @@ -274,7 +275,7 @@ class HelpFormatter: def _format_text(self, text: str) -> str: ... def _format_action(self, action: Action) -> str: ... def _format_action_invocation(self, action: Action) -> str: ... - def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], Tuple[str, ...]]: ... + def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], tuple[str, ...]]: ... def _format_args(self, action: Action, default_metavar: str) -> str: ... def _expand_help(self, action: Action) -> str: ... def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ... @@ -299,7 +300,7 @@ class Action(_AttributeHolder): choices: Iterable[Any] | None required: bool help: str | None - metavar: str | Tuple[str, ...] | None + metavar: str | tuple[str, ...] | None def __init__( self, option_strings: Sequence[str], @@ -311,7 +312,7 @@ class Action(_AttributeHolder): choices: Iterable[_T] | None = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... def __call__( self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = ... @@ -330,7 +331,7 @@ if sys.version_info >= (3, 9): choices: Iterable[_T] | None = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... class Namespace(_AttributeHolder): @@ -375,7 +376,7 @@ class _StoreConstAction(Action): default: Any = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... # undocumented @@ -403,7 +404,7 @@ class _AppendConstAction(Action): default: Any = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... # undocumented @@ -440,7 +441,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): dest: str = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... else: def __init__( @@ -450,7 +451,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): parser_class: Type[_ArgumentParserT], dest: str = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: str, **kwargs: Any) -> _ArgumentParserT: ... diff --git a/stdlib/array.pyi b/stdlib/array.pyi index f49eb2c916c2..98094548db47 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, MutableSequence import sys -from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, TypeVar, Union, overload +from typing import Any, BinaryIO, Generic, TypeVar, Union, overload from typing_extensions import Literal, SupportsIndex _IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 8494a3a99126..48faade265a6 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -6,10 +6,11 @@ # is imported in both modules. unfortunately we can't just rename sys, # since mypy only supports version checks with a sys that is named # sys. +from collections.abc import Iterator import sys import typing as _typing from _ast import * -from typing import Any, Iterator, TypeVar, overload +from typing import Any, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 8): diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index e804c2f5d3bd..1ad6ce557f26 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -1,3 +1,4 @@ +from collections.abc import Awaitable, Callable, Generator, Sequence import ssl import sys from _typeshed import FileDescriptorLike @@ -9,18 +10,18 @@ from asyncio.tasks import Task from asyncio.transports import BaseTransport from collections.abc import Iterable from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Awaitable, Callable, Dict, Generator, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 7): from contextvars import Context _T = TypeVar("_T") -_Context = Dict[str, Any] +_Context = dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] _ProtocolFactory = Callable[[], BaseProtocol] _SSLContext = Union[bool, None, ssl.SSLContext] -_TransProtPair = Tuple[BaseTransport, BaseProtocol] +_TransProtPair = tuple[BaseTransport, BaseProtocol] class Server(AbstractServer): if sys.version_info >= (3, 7): @@ -37,7 +38,7 @@ class Server(AbstractServer): def __init__(self, loop: AbstractEventLoop, sockets: list[socket]) -> None: ... if sys.version_info >= (3, 8): @property - def sockets(self) -> Tuple[socket, ...]: ... + def sockets(self) -> tuple[socket, ...]: ... elif sys.version_info >= (3, 7): @property def sockets(self) -> list[socket]: ... diff --git a/stdlib/asyncio/base_futures.pyi b/stdlib/asyncio/base_futures.pyi index 72ba6163e9d3..9feb2c96fe71 100644 --- a/stdlib/asyncio/base_futures.pyi +++ b/stdlib/asyncio/base_futures.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Sequence import sys -from typing import Any, Callable, Sequence +from typing import Any from typing_extensions import Literal if sys.version_info >= (3, 7): diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index 096bce60f7e3..e84394fe9f55 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Sequence import subprocess from collections import deque -from typing import IO, Any, Callable, Optional, Sequence, Tuple, Union +from typing import IO, Any, Optional, Union from . import events, futures, protocols, transports @@ -15,7 +16,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): _pid: int | None # undocumented _returncode: int | None # undocumented _exit_waiters: list[futures.Future[Any]] # undocumented - _pending_calls: deque[tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented + _pending_calls: deque[tuple[Callable[..., Any], tuple[Any, ...]]] # undocumented _pipes: dict[int, _File] # undocumented _finished: bool # undocumented def __init__( diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 6ef9117b6491..30af853f8843 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -1,9 +1,10 @@ +from collections.abc import Awaitable, Callable, Generator, Sequence import ssl import sys from _typeshed import FileDescriptorLike, Self from abc import ABCMeta, abstractmethod from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Awaitable, Callable, Dict, Generator, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, TypeVar, Union, overload from typing_extensions import Literal from .base_events import Server @@ -17,11 +18,11 @@ if sys.version_info >= (3, 7): from contextvars import Context _T = TypeVar("_T") -_Context = Dict[str, Any] +_Context = dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] _ProtocolFactory = Callable[[], BaseProtocol] _SSLContext = Union[bool, None, ssl.SSLContext] -_TransProtPair = Tuple[BaseTransport, BaseProtocol] +_TransProtPair = tuple[BaseTransport, BaseProtocol] class Handle: _cancelled = False diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index be80efe266b1..9f1bf77caf93 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -1,8 +1,9 @@ +from collections.abc import Iterable import functools import sys import traceback from types import FrameType, FunctionType -from typing import Any, Iterable, Union, overload +from typing import Any, Union, overload class _HasWrapper: __wrapper__: _HasWrapper | FunctionType diff --git a/stdlib/asyncio/futures.pyi b/stdlib/asyncio/futures.pyi index 9788123f427e..9c5382d055f0 100644 --- a/stdlib/asyncio/futures.pyi +++ b/stdlib/asyncio/futures.pyi @@ -1,6 +1,7 @@ +from collections.abc import Awaitable, Callable, Generator, Iterable import sys from concurrent.futures._base import Error, Future as _ConcurrentFuture -from typing import Any, Awaitable, Callable, Generator, Iterable, TypeVar +from typing import Any, TypeVar from .events import AbstractEventLoop diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 7c4f40d9e4ca..2c5305753b12 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,7 +1,8 @@ +from collections.abc import Awaitable, Callable, Generator import sys from collections import deque from types import TracebackType -from typing import Any, Awaitable, Callable, Generator, Type, TypeVar +from typing import Any, Type, TypeVar from .events import AbstractEventLoop from .futures import Future diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index 1e9cff1b1dd6..d79e1fd70174 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -1,6 +1,7 @@ +from collections.abc import Mapping import sys from socket import socket -from typing import Any, Mapping, Protocol, Type +from typing import Any, Protocol, Type from typing_extensions import Literal from . import base_events, constants, events, futures, streams, transports diff --git a/stdlib/asyncio/runners.pyi b/stdlib/asyncio/runners.pyi index 3f0f42eef48b..0a2164634f76 100644 --- a/stdlib/asyncio/runners.pyi +++ b/stdlib/asyncio/runners.pyi @@ -1,7 +1,8 @@ +from collections.abc import Awaitable import sys if sys.version_info >= (3, 7): - from typing import Awaitable, TypeVar + from typing import TypeVar _T = TypeVar("_T") if sys.version_info >= (3, 8): diff --git a/stdlib/asyncio/sslproto.pyi b/stdlib/asyncio/sslproto.pyi index 082e96dc0233..a7ceb3e78c2e 100644 --- a/stdlib/asyncio/sslproto.pyi +++ b/stdlib/asyncio/sslproto.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import ssl import sys from collections import deque -from typing import Any, Callable, ClassVar +from typing import Any, ClassVar from typing_extensions import Literal from . import constants, events, futures, protocols, transports diff --git a/stdlib/asyncio/staggered.pyi b/stdlib/asyncio/staggered.pyi index 1d76d382555d..49fd19004e1e 100644 --- a/stdlib/asyncio/staggered.pyi +++ b/stdlib/asyncio/staggered.pyi @@ -1,5 +1,6 @@ +from collections.abc import Awaitable, Callable, Iterable import sys -from typing import Any, Awaitable, Callable, Iterable +from typing import Any from . import events diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index 595222280d58..d9b002a69c9b 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -1,6 +1,7 @@ +from collections.abc import AsyncIterator, Awaitable, Callable, Iterable import sys from _typeshed import StrPath -from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional +from typing import Any, Optional from . import events, protocols, transports from .base_events import Server diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index d835c12af3d8..d736156a87e5 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable import subprocess import sys from _typeshed import StrOrBytesPath from asyncio import events, protocols, streams, transports -from typing import IO, Any, Callable, Union +from typing import IO, Any, Union from typing_extensions import Literal if sys.version_info >= (3, 8): diff --git a/stdlib/asyncio/threads.pyi b/stdlib/asyncio/threads.pyi index c13c0c6d1194..062aebd0dba8 100644 --- a/stdlib/asyncio/threads.pyi +++ b/stdlib/asyncio/threads.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable import sys -from typing import Callable, TypeVar +from typing import TypeVar from typing_extensions import ParamSpec _P = ParamSpec("_P") diff --git a/stdlib/asyncio/transports.pyi b/stdlib/asyncio/transports.pyi index acca0e4c28b4..797146030c6f 100644 --- a/stdlib/asyncio/transports.pyi +++ b/stdlib/asyncio/transports.pyi @@ -1,8 +1,9 @@ +from collections.abc import Mapping import sys from asyncio.events import AbstractEventLoop from asyncio.protocols import BaseProtocol from socket import _Address -from typing import Any, Mapping +from typing import Any class BaseTransport: def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ... diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 33ec5d67aaf9..ba4ae0bb2719 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -1,14 +1,15 @@ +from collections.abc import Iterable import socket import sys from types import TracebackType -from typing import Any, BinaryIO, Iterable, NoReturn, Tuple, Type, Union, overload +from typing import Any, BinaryIO, NoReturn, Type, Union, overload if sys.version_info >= (3, 8): # These are based in socket, maybe move them out into _typeshed.pyi or such - _Address = Union[Tuple[Any, ...], str] + _Address = Union[tuple[Any, ...], str] _RetAddress = Any _WriteBuffer = Union[bytearray, memoryview] - _CMSG = Tuple[int, int, bytes] + _CMSG = tuple[int, int, bytes] class TransportSocket: def __init__(self, sock: socket.socket) -> None: ... def _na(self, what: str) -> None: ... diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index e8e57a20a765..6520aedfd742 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable import sys import types from _typeshed import Self from socket import socket -from typing import Any, Callable, Type +from typing import Any, Type from .base_events import Server from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index 6d17bada312f..be7ee876d7d5 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import socket import sys from _typeshed import WriteableBuffer -from typing import IO, Any, Callable, ClassVar, NoReturn, Type +from typing import IO, Any, ClassVar, NoReturn, Type from . import events, futures, proactor_events, selector_events, streams, windows_utils diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index bf9cdde25a78..8979f14cc723 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import sys from _typeshed import Self from types import TracebackType -from typing import Callable, Protocol, Type +from typing import Protocol, Type class _WarnFunction(Protocol): def __call__(self, message: str, category: Type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ...) -> None: ... diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index e135221134a5..123da2677a7e 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -1,10 +1,10 @@ import sys from _typeshed import FileDescriptorLike from socket import socket -from typing import Any, Dict, Tuple, overload +from typing import Any, overload # cyclic dependence with asynchat -_maptype = Dict[int, Any] +_maptype = dict[int, Any] _socket = socket socket_map: _maptype # undocumented @@ -41,8 +41,8 @@ class dispatcher: def readable(self) -> bool: ... def writable(self) -> bool: ... def listen(self, num: int) -> None: ... - def bind(self, addr: Tuple[Any, ...] | str) -> None: ... - def connect(self, address: Tuple[Any, ...] | str) -> None: ... + def bind(self, addr: tuple[Any, ...] | str) -> None: ... + def connect(self, address: tuple[Any, ...] | str) -> None: ... def accept(self) -> tuple[_socket, Any] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... diff --git a/stdlib/atexit.pyi b/stdlib/atexit.pyi index 9395c60678b8..a7a89c3eafb9 100644 --- a/stdlib/atexit.pyi +++ b/stdlib/atexit.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, TypeVar +from collections.abc import Callable +from typing import Any, TypeVar from typing_extensions import ParamSpec _T = TypeVar("_T") diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index 321bfe55c4b0..0abf550f553c 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,7 +1,7 @@ -from typing import Tuple -AdpcmState = Tuple[int, int] -RatecvState = Tuple[int, Tuple[Tuple[int, int], ...]] + +AdpcmState = tuple[int, int] +RatecvState = tuple[int, tuple[tuple[int, int], ...]] class error(Exception): ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index 1d03ddf19a0e..2d570fc55c6e 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -1,9 +1,10 @@ +from collections.abc import Callable, Iterable, Mapping from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, Tuple, Type, TypeVar +from typing import IO, Any, SupportsInt, Type, TypeVar _T = TypeVar("_T") _TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type -_ExcInfo = Tuple[Type[BaseException], BaseException, FrameType] +_ExcInfo = tuple[Type[BaseException], BaseException, FrameType] GENERATOR_AND_COROUTINE_FLAGS: int diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index 02d094faf923..4e295b8ed903 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Tuple, Union +from typing import IO, Any, Union class Error(Exception): ... @@ -12,7 +12,7 @@ class FInfo: Creator: str Flags: int -_FileInfoTuple = Tuple[str, FInfo, int, int] +_FileInfoTuple = tuple[str, FInfo, int, int] _FileHandleUnion = Union[str, IO[bytes]] def getfileinfo(name: str) -> _FileInfoTuple: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 0daf9d154227..ad7a383723d3 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -49,7 +49,7 @@ from typing import ( SupportsFloat, SupportsInt, SupportsRound, - Tuple, + Type, TypeVar, Union, @@ -108,11 +108,11 @@ class object: def __sizeof__(self) -> int: ... # return type of pickle methods is rather hard to express in the current type system # see #6661 and https://docs.python.org/3/library/pickle.html#object.__reduce__ - def __reduce__(self) -> str | Tuple[Any, ...]: ... + def __reduce__(self) -> str | tuple[Any, ...]: ... if sys.version_info >= (3, 8): - def __reduce_ex__(self, __protocol: SupportsIndex) -> str | Tuple[Any, ...]: ... + def __reduce_ex__(self, __protocol: SupportsIndex) -> str | tuple[Any, ...]: ... else: - def __reduce_ex__(self, __protocol: int) -> str | Tuple[Any, ...]: ... + def __reduce_ex__(self, __protocol: int) -> str | tuple[Any, ...]: ... def __dir__(self) -> Iterable[str]: ... def __init_subclass__(cls) -> None: ... @@ -141,14 +141,14 @@ class classmethod(Generic[_R]): # Special, only valid as a decorator. class type(object): __base__: type - __bases__: Tuple[type, ...] + __bases__: tuple[type, ...] __basicsize__: int __dict__: dict[str, Any] __dictoffset__: int __flags__: int __itemsize__: int __module__: str - __mro__: Tuple[type, ...] + __mro__: tuple[type, ...] __name__: str __qualname__: str __text_signature__: str | None @@ -156,11 +156,11 @@ class type(object): @overload def __init__(self, __o: object) -> None: ... @overload - def __init__(self, __name: str, __bases: Tuple[type, ...], __dict: dict[str, Any], **kwds: Any) -> None: ... + def __init__(self, __name: str, __bases: tuple[type, ...], __dict: dict[str, Any], **kwds: Any) -> None: ... @overload def __new__(cls, __o: object) -> type: ... @overload - def __new__(cls: Type[_TT], __name: str, __bases: Tuple[type, ...], __namespace: dict[str, Any], **kwds: Any) -> _TT: ... + def __new__(cls: Type[_TT], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwds: Any) -> _TT: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... def __subclasses__(self: _TT) -> list[_TT]: ... # Note: the documentation doesn't specify what the return type is, the standard @@ -169,7 +169,7 @@ class type(object): def __instancecheck__(self, __instance: Any) -> bool: ... def __subclasscheck__(self, __subclass: type) -> bool: ... @classmethod - def __prepare__(metacls, __name: str, __bases: Tuple[type, ...], **kwds: Any) -> Mapping[str, object]: ... + def __prepare__(metacls, __name: str, __bases: tuple[type, ...], **kwds: Any) -> Mapping[str, object]: ... if sys.version_info >= (3, 10): def __or__(self, __t: Any) -> types.UnionType: ... def __ror__(self, __t: Any) -> types.UnionType: ... @@ -370,7 +370,7 @@ class str(Sequence[str]): def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ... def endswith( - self, __suffix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __suffix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... @@ -411,7 +411,7 @@ class str(Sequence[str]): def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... def splitlines(self, keepends: bool = ...) -> list[str]: ... def startswith( - self, __prefix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __prefix: str | tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... def strip(self, __chars: str | None = ...) -> str: ... def swapcase(self) -> str: ... @@ -463,7 +463,7 @@ class bytes(ByteString): ) -> int: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( - self, __suffix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __suffix: bytes | tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ... @@ -510,7 +510,7 @@ class bytes(ByteString): def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytes]: ... def splitlines(self, keepends: bool = ...) -> list[bytes]: ... def startswith( - self, __prefix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __prefix: bytes | tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... def strip(self, __bytes: bytes | None = ...) -> bytes: ... def swapcase(self) -> bytes: ... @@ -565,7 +565,7 @@ class bytearray(MutableSequence[int], ByteString): def copy(self) -> bytearray: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( - self, __suffix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __suffix: bytes | tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ... @@ -614,7 +614,7 @@ class bytearray(MutableSequence[int], ByteString): def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> list[bytearray]: ... def splitlines(self, keepends: bool = ...) -> list[bytearray]: ... def startswith( - self, __prefix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... + self, __prefix: bytes | tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... def strip(self, __bytes: bytes | None = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... @@ -659,9 +659,9 @@ class bytearray(MutableSequence[int], ByteString): class memoryview(Sized, Sequence[int]): format: str itemsize: int - shape: Tuple[int, ...] | None - strides: Tuple[int, ...] | None - suboffsets: Tuple[int, ...] | None + shape: tuple[int, ...] | None + strides: tuple[int, ...] | None + suboffsets: tuple[int, ...] | None readonly: bool ndim: int @@ -675,7 +675,7 @@ class memoryview(Sized, Sequence[int]): def __exit__( self, __exc_type: Type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None ) -> None: ... - def cast(self, format: str, shape: list[int] | Tuple[int, ...] = ...) -> memoryview: ... + def cast(self, format: str, shape: list[int] | tuple[int, ...] = ...) -> memoryview: ... @overload def __getitem__(self, __i: SupportsIndex) -> int: ... @overload @@ -748,18 +748,18 @@ class tuple(Sequence[_T_co], Generic[_T_co]): @overload def __getitem__(self, __x: SupportsIndex) -> _T_co: ... @overload - def __getitem__(self, __x: slice) -> Tuple[_T_co, ...]: ... + def __getitem__(self, __x: slice) -> tuple[_T_co, ...]: ... def __iter__(self) -> Iterator[_T_co]: ... - def __lt__(self, __x: Tuple[_T_co, ...]) -> bool: ... - def __le__(self, __x: Tuple[_T_co, ...]) -> bool: ... - def __gt__(self, __x: Tuple[_T_co, ...]) -> bool: ... - def __ge__(self, __x: Tuple[_T_co, ...]) -> bool: ... + def __lt__(self, __x: tuple[_T_co, ...]) -> bool: ... + def __le__(self, __x: tuple[_T_co, ...]) -> bool: ... + def __gt__(self, __x: tuple[_T_co, ...]) -> bool: ... + def __ge__(self, __x: tuple[_T_co, ...]) -> bool: ... @overload - def __add__(self, __x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... + def __add__(self, __x: tuple[_T_co, ...]) -> tuple[_T_co, ...]: ... @overload - def __add__(self, __x: Tuple[_T, ...]) -> Tuple[_T_co | _T, ...]: ... - def __mul__(self, __n: SupportsIndex) -> Tuple[_T_co, ...]: ... - def __rmul__(self, __n: SupportsIndex) -> Tuple[_T_co, ...]: ... + def __add__(self, __x: tuple[_T, ...]) -> tuple[_T_co | _T, ...]: ... + def __mul__(self, __n: SupportsIndex) -> tuple[_T_co, ...]: ... + def __rmul__(self, __n: SupportsIndex) -> tuple[_T_co, ...]: ... def count(self, __value: Any) -> int: ... def index(self, __value: Any, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ... if sys.version_info >= (3, 9): @@ -924,7 +924,7 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]): if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... -class enumerate(Iterator[Tuple[int, _T]], Generic[_T]): +class enumerate(Iterator[tuple[int, _T]], Generic[_T]): def __init__(self, iterable: Iterable[_T], start: int = ...) -> None: ... def __iter__(self) -> Iterator[tuple[int, _T]]: ... def __next__(self) -> tuple[int, _T]: ... @@ -1090,15 +1090,15 @@ def iter(__function: Callable[[], _T], __sentinel: object) -> Iterator[_T]: ... # We need recursive types to express the type of the second argument to `isinstance` properly, hence the use of `Any` if sys.version_info >= (3, 10): def isinstance( - __obj: object, __class_or_tuple: type | types.UnionType | Tuple[type | types.UnionType | Tuple[Any, ...], ...] + __obj: object, __class_or_tuple: type | types.UnionType | tuple[type | types.UnionType | tuple[Any, ...], ...] ) -> bool: ... def issubclass( - __cls: type, __class_or_tuple: type | types.UnionType | Tuple[type | types.UnionType | Tuple[Any, ...], ...] + __cls: type, __class_or_tuple: type | types.UnionType | tuple[type | types.UnionType | tuple[Any, ...], ...] ) -> bool: ... else: - def isinstance(__obj: object, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... - def issubclass(__cls: type, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... + def isinstance(__obj: object, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... + def issubclass(__cls: type, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... def len(__obj: Sized) -> int: ... def license() -> None: ... @@ -1449,7 +1449,7 @@ class zip(Iterator[_T_co], Generic[_T_co]): __iter6: Iterable[Any], *iterables: Iterable[Any], strict: bool = ..., - ) -> zip[Tuple[Any, ...]]: ... + ) -> zip[tuple[Any, ...]]: ... else: @overload def __new__(cls, __iter1: Iterable[_T1]) -> zip[tuple[_T1]]: ... @@ -1480,7 +1480,7 @@ class zip(Iterator[_T_co], Generic[_T_co]): __iter5: Iterable[Any], __iter6: Iterable[Any], *iterables: Iterable[Any], - ) -> zip[Tuple[Any, ...]]: ... + ) -> zip[tuple[Any, ...]]: ... def __iter__(self) -> Iterator[_T_co]: ... def __next__(self) -> _T_co: ... @@ -1502,7 +1502,7 @@ class ellipsis: ... Ellipsis: ellipsis class BaseException(object): - args: Tuple[Any, ...] + args: tuple[Any, ...] __cause__: BaseException | None __context__: BaseException | None __suppress_context__: bool diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index c26698d88dd7..e98583d6c909 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -1,8 +1,9 @@ +from collections.abc import Iterable import _compression import sys from _compression import BaseStream from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer -from typing import IO, Any, Iterable, Protocol, TextIO, TypeVar, overload +from typing import IO, Any, Protocol, TextIO, TypeVar, overload from typing_extensions import Literal, SupportsIndex, final # The following attributes and methods are optional: diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index f4a7ab50cc11..c25897034ccb 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import sys from _typeshed import Self, StrOrBytesPath from types import CodeType -from typing import Any, Callable, Tuple, TypeVar +from typing import Any, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( @@ -9,7 +10,7 @@ def runctx( ) -> None: ... _T = TypeVar("_T") -_Label = Tuple[str, int, str] +_Label = tuple[str, int, str] class Profile: stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 26073fb7281b..445928c01d99 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -1,9 +1,10 @@ +from collections.abc import Iterable, Sequence import datetime import sys from time import struct_time -from typing import Any, Iterable, Optional, Sequence, Tuple +from typing import Any, Optional -_LocaleType = Tuple[Optional[str], Optional[str]] +_LocaleType = tuple[Optional[str], Optional[str]] class IllegalMonthError(ValueError): def __init__(self, month: int) -> None: ... @@ -97,7 +98,7 @@ c: TextCalendar def setfirstweekday(firstweekday: int) -> None: ... def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... -def timegm(tuple: Tuple[int, ...] | struct_time) -> int: ... +def timegm(tuple: tuple[int, ...] | struct_time) -> int: ... # Data attributes day_name: Sequence[str] diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index 7576740fc1c0..616880cd2f49 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable from _typeshed import StrOrBytesPath from types import FrameType, TracebackType -from typing import IO, Any, Callable, Optional, Tuple, Type +from typing import IO, Any, Optional, Type -_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_ExcInfo = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] def reset() -> str: ... # undocumented def small(text: str) -> str: ... # undocumented diff --git a/stdlib/cmd.pyi b/stdlib/cmd.pyi index f6d818591a4e..9cc1894f3eb9 100644 --- a/stdlib/cmd.pyi +++ b/stdlib/cmd.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Callable +from collections.abc import Callable +from typing import IO, Any class Cmd: prompt: str diff --git a/stdlib/code.pyi b/stdlib/code.pyi index ed00eaf96a5c..35440b0f207e 100644 --- a/stdlib/code.pyi +++ b/stdlib/code.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Mapping from codeop import CommandCompiler from types import CodeType -from typing import Any, Callable, Mapping +from typing import Any class InteractiveInterpreter: locals: Mapping[str, Any] # undocumented diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 63de22d99188..4af9a6d3f7df 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable, Generator, Iterable, Iterator import sys import types from _typeshed import Self from abc import abstractmethod -from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, Tuple, Type, TypeVar, overload +from typing import IO, Any, BinaryIO, Protocol, TextIO, Type, TypeVar, overload from typing_extensions import Literal BOM32_BE: bytes @@ -71,7 +72,7 @@ def lookup(__encoding: str) -> CodecInfo: ... def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> tuple[str, int]: ... # undocumented def utf_16_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... # undocumented -class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): +class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): @property def encode(self) -> _Encoder: ... @property diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index d4808d326efe..adcdf29fa690 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,7 +1,7 @@ import sys from _collections_abc import dict_items, dict_keys, dict_values from _typeshed import Self, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT -from typing import Any, Dict, Generic, NoReturn, Tuple, Type, TypeVar, overload +from typing import Any, Generic, NoReturn, Type, TypeVar, overload from typing_extensions import SupportsIndex, final if sys.version_info >= (3, 9): @@ -28,12 +28,12 @@ if sys.version_info >= (3, 7): rename: bool = ..., module: str | None = ..., defaults: Iterable[Any] | None = ..., - ) -> Type[Tuple[Any, ...]]: ... + ) -> Type[tuple[Any, ...]]: ... else: def namedtuple( typename: str, field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., module: str | None = ... - ) -> Type[Tuple[Any, ...]]: ... + ) -> Type[tuple[Any, ...]]: ... class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): data: dict[_KT, _VT] @@ -132,7 +132,7 @@ class UserString(Sequence[str]): def encode(self: UserString, encoding: str | None = ..., errors: str | None = ...) -> bytes: ... else: def encode(self: _UserStringT, encoding: str | None = ..., errors: str | None = ...) -> _UserStringT: ... - def endswith(self, suffix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... + def endswith(self, suffix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ... def find(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def format(self, *args: Any, **kwds: Any) -> str: ... @@ -174,7 +174,7 @@ class UserString(Sequence[str]): def split(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... def splitlines(self, keepends: bool = ...) -> list[str]: ... - def startswith(self, prefix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... + def startswith(self, prefix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... def strip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ... def swapcase(self: _UserStringT) -> _UserStringT: ... def title(self: _UserStringT) -> _UserStringT: ... @@ -214,7 +214,7 @@ class deque(MutableSequence[_T], Generic[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... -class Counter(Dict[_T, int], Generic[_T]): +class Counter(dict[_T, int], Generic[_T]): @overload def __init__(self, __iterable: None = ..., **kwargs: int) -> None: ... @overload @@ -261,14 +261,14 @@ class _OrderedDictKeysView(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # ty def __reversed__(self) -> Iterator[_KT_co]: ... @final -class _OrderedDictItemsView(dict_items[_KT_co, _VT_co], Reversible[Tuple[_KT_co, _VT_co]]): # type: ignore[misc] +class _OrderedDictItemsView(dict_items[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]): # type: ignore[misc] def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... @final class _OrderedDictValuesView(dict_values[_KT_co, _VT_co], Reversible[_VT_co], Generic[_KT_co, _VT_co]): # type: ignore[misc] def __reversed__(self) -> Iterator[_VT_co]: ... -class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): +class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def popitem(self, last: bool = ...) -> tuple[_KT, _VT]: ... def move_to_end(self, key: _KT, last: bool = ...) -> None: ... def copy(self: Self) -> Self: ... @@ -286,7 +286,7 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): @overload def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> OrderedDict[_T, _S]: ... -class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): +class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]): default_factory: Callable[[], _VT] | None @overload def __init__(self, **kwargs: _VT) -> None: ... diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index c1a44c997381..9d39fe7445d6 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -1,10 +1,11 @@ +from collections.abc import Callable import sys import threading from _typeshed import Self from abc import abstractmethod from collections.abc import Container, Iterable, Iterator, Sequence from logging import Logger -from typing import Any, Callable, Generic, Protocol, Set, TypeVar, overload +from typing import Any, Generic, Protocol, TypeVar, overload from typing_extensions import SupportsIndex if sys.version_info >= (3, 9): @@ -76,7 +77,7 @@ class Executor: def as_completed(fs: Iterable[Future[_T]], timeout: float | None = ...) -> Iterator[Future[_T]]: ... # Ideally this would be a namedtuple, but mypy doesn't support generic tuple types. See #1976 -class DoneAndNotDoneFutures(Sequence[Set[Future[_T]]]): +class DoneAndNotDoneFutures(Sequence[set[Future[_T]]]): done: set[Future[_T]] not_done: set[Future[_T]] def __new__(_cls, done: set[Future[_T]], not_done: set[Future[_T]]) -> DoneAndNotDoneFutures[_T]: ... diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index cc48f48f0023..f40008b07545 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable import sys from collections.abc import Generator, Iterable, Mapping, MutableMapping, MutableSequence from multiprocessing.connection import Connection @@ -5,7 +6,7 @@ from multiprocessing.context import BaseContext, Process from multiprocessing.queues import Queue, SimpleQueue from threading import Lock, Semaphore, Thread from types import TracebackType -from typing import Any, Callable, Generic, Tuple, TypeVar +from typing import Any, Generic, TypeVar from weakref import ref from ._base import Executor, Future @@ -37,7 +38,7 @@ class _ExceptionWithTraceback: exc: BaseException tb: TracebackType def __init__(self, exc: BaseException, tb: TracebackType) -> None: ... - def __reduce__(self) -> str | Tuple[Any, ...]: ... + def __reduce__(self) -> str | tuple[Any, ...]: ... def _rebuild_exc(exc: Exception, tb: str) -> Exception: ... @@ -84,7 +85,7 @@ if sys.version_info >= (3, 7): ) -> None: ... def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ... -def _get_chunks(*iterables: Any, chunksize: int) -> Generator[Tuple[Any, ...], None, None]: ... +def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...], None, None]: ... def _process_chunk(fn: Callable[..., Any], chunk: tuple[Any, None, None]) -> Generator[Any, None, None]: ... def _sendback_result( result_queue: SimpleQueue[_WorkItem[Any]], work_id: int, result: Any | None = ..., exception: Exception | None = ... @@ -95,7 +96,7 @@ if sys.version_info >= (3, 7): call_queue: Queue[_CallItem], result_queue: SimpleQueue[_ResultItem], initializer: Callable[..., None] | None, - initargs: Tuple[Any, ...], + initargs: tuple[Any, ...], ) -> None: ... else: @@ -139,7 +140,7 @@ else: class ProcessPoolExecutor(Executor): _mp_context: BaseContext | None = ... _initializer: Callable[..., None] | None = ... - _initargs: Tuple[Any, ...] = ... + _initargs: tuple[Any, ...] = ... _executor_manager_thread: _ThreadWakeup _processes: MutableMapping[int, Process] _shutdown_thread: bool @@ -158,7 +159,7 @@ class ProcessPoolExecutor(Executor): max_workers: int | None = ..., mp_context: BaseContext | None = ..., initializer: Callable[..., None] | None = ..., - initargs: Tuple[Any, ...] = ..., + initargs: tuple[Any, ...] = ..., ) -> None: ... else: def __init__(self, max_workers: int | None = ...) -> None: ... diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 5ad5b65d3bec..0418a129ddb2 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable import queue import sys from collections.abc import Iterable, Mapping, Set # equivalent to typing.AbstractSet, not builtins.set from threading import Lock, Semaphore, Thread -from typing import Any, Callable, Generic, Tuple, TypeVar +from typing import Any, Generic, TypeVar from weakref import ref from ._base import Executor, Future @@ -33,7 +34,7 @@ if sys.version_info >= (3, 7): executor_reference: ref[Any], work_queue: queue.SimpleQueue[Any], initializer: Callable[..., None], - initargs: Tuple[Any, ...], + initargs: tuple[Any, ...], ) -> None: ... else: @@ -52,7 +53,7 @@ class ThreadPoolExecutor(Executor): _shutdown_lock: Lock _thread_name_prefix: str | None = ... _initializer: Callable[..., None] | None = ... - _initargs: Tuple[Any, ...] = ... + _initargs: tuple[Any, ...] = ... if sys.version_info >= (3, 7): _work_queue: queue.SimpleQueue[_WorkItem[Any]] else: @@ -63,7 +64,7 @@ class ThreadPoolExecutor(Executor): max_workers: int | None = ..., thread_name_prefix: str = ..., initializer: Callable[..., None] | None = ..., - initargs: Tuple[Any, ...] = ..., + initargs: tuple[Any, ...] = ..., ) -> None: ... else: def __init__(self, max_workers: int | None = ..., thread_name_prefix: str = ...) -> None: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 83d9d969080a..dc81cb78577a 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -1,14 +1,14 @@ import sys from _typeshed import StrOrBytesPath, StrPath, SupportsWrite from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence -from typing import Any, ClassVar, Dict, Optional, Pattern, Type, TypeVar, overload +from typing import Any, ClassVar, Optional, Pattern, Type, TypeVar, overload from typing_extensions import Literal # Internal type aliases _section = Mapping[str, str] _parser = MutableMapping[str, _section] _converter = Callable[[str], Any] -_converters = Dict[str, _converter] +_converters = dict[str, _converter] _T = TypeVar("_T") if sys.version_info >= (3, 7): diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index fe72d6dd42d9..1623034aa2f4 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -1,15 +1,16 @@ +from collections.abc import AsyncIterator, Awaitable, Callable, Iterator import sys from _typeshed import Self, StrOrBytesPath from types import TracebackType from typing import ( IO, Any, - AsyncIterator, - Awaitable, - Callable, + + + ContextManager, Generic, - Iterator, + Optional, Protocol, Type, diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index e97f62188dcb..9598bc8f42dc 100644 --- a/stdlib/contextvars.pyi +++ b/stdlib/contextvars.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterator, Mapping import sys -from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, overload +from typing import Any, ClassVar, Generic, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/copyreg.pyi b/stdlib/copyreg.pyi index 320097b3a204..92bdb9310402 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -1,7 +1,8 @@ -from typing import Any, Callable, Hashable, Optional, SupportsInt, Tuple, TypeVar, Union +from collections.abc import Callable, Hashable +from typing import Any, Optional, SupportsInt, TypeVar, Union _TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] +_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Optional[Any]]] __all__: list[str] diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 0b69cb2272d3..ae68403ac859 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -21,7 +21,7 @@ from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence from typing import Any, Generic, Type, TypeVar, overload if sys.version_info >= (3, 8): - from typing import Dict as _DictReadMapping + _DictReadMapping = dict else: from collections import OrderedDict as _DictReadMapping diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 5cf8ce289148..d7c9dec6118b 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -1,17 +1,18 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence import sys from _typeshed import ReadableBuffer, WriteableBuffer from abc import abstractmethod from typing import ( Any, - Callable, + ClassVar, Generic, - Iterable, - Iterator, - Mapping, + + + Optional, - Sequence, - Tuple, + + Type, TypeVar, Union as _UnionT, @@ -98,8 +99,8 @@ class _CData(metaclass=_CDataMeta): class _CanCastTo(_CData): ... class _PointerLike(_CanCastTo): ... -_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, Tuple[_CData, ...]], _CData] -_PF = _UnionT[Tuple[int], Tuple[int, str], Tuple[int, str, Any]] +_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, tuple[_CData, ...]], _CData] +_PF = _UnionT[tuple[int], tuple[int, str], tuple[int, str, Any]] class _FuncPointer(_PointerLike, _CData): restype: Type[_CData] | Callable[[int], Any] | None @@ -110,9 +111,9 @@ class _FuncPointer(_PointerLike, _CData): @overload def __init__(self, callable: Callable[..., Any]) -> None: ... @overload - def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: Tuple[_PF, ...] = ...) -> None: ... + def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] = ...) -> None: ... @overload - def __init__(self, vtlb_index: int, name: str, paramflags: Tuple[_PF, ...] = ..., iid: pointer[c_int] = ...) -> None: ... + def __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: pointer[c_int] = ...) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class _NamedFuncPointer(_FuncPointer): diff --git a/stdlib/curses/__init__.pyi b/stdlib/curses/__init__.pyi index 73e84fba3763..3e3d2e6c836a 100644 --- a/stdlib/curses/__init__.pyi +++ b/stdlib/curses/__init__.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable from _curses import * # noqa: F403 from _curses import _CursesWindow as _CursesWindow -from typing import Any, Callable, TypeVar +from typing import Any, TypeVar _T = TypeVar("_T") diff --git a/stdlib/curses/textpad.pyi b/stdlib/curses/textpad.pyi index 578a579fda38..a919c1a2ecdb 100644 --- a/stdlib/curses/textpad.pyi +++ b/stdlib/curses/textpad.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from _curses import _CursesWindow -from typing import Callable + def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 6dfe83c2d4a8..4678278ec2b5 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Mapping import sys import types -from typing import Any, Callable, Generic, Iterable, Mapping, Protocol, Tuple, Type, TypeVar, overload +from typing import Any, Generic, Protocol, Type, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -20,7 +21,7 @@ def asdict(obj: Any) -> dict[str, Any]: ... @overload def asdict(obj: Any, *, dict_factory: Callable[[list[tuple[str, Any]]], _T]) -> _T: ... @overload -def astuple(obj: Any) -> Tuple[Any, ...]: ... +def astuple(obj: Any) -> tuple[Any, ...]: ... @overload def astuple(obj: Any, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ... @@ -172,7 +173,7 @@ else: metadata: Mapping[Any, Any] | None = ..., ) -> Any: ... -def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... +def fields(class_or_instance: Any) -> tuple[Field[Any], ...]: ... def is_dataclass(obj: Any) -> bool: ... class FrozenInstanceError(AttributeError): ... @@ -191,7 +192,7 @@ if sys.version_info >= (3, 10): cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., @@ -209,7 +210,7 @@ else: cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 5ecacd91b4ed..b2c16e06b3e4 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterator, MutableMapping from _typeshed import Self from types import TracebackType -from typing import Iterator, MutableMapping, Type, Union +from typing import Type, Union from typing_extensions import Literal _KeyType = Union[str, bytes] diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index 0a941b070754..c4c89facf255 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterator, MutableMapping from _typeshed import Self from types import TracebackType -from typing import Iterator, MutableMapping, Type, Union +from typing import Type, Union _KeyType = Union[str, bytes] _ValueType = Union[str, bytes] diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 959af69675c9..284f4a1e152b 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -1,16 +1,17 @@ +from collections.abc import Container, Sequence import numbers import sys from types import TracebackType -from typing import Any, Container, NamedTuple, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, NamedTuple, Type, TypeVar, Union, overload _Decimal = Union[Decimal, int] -_DecimalNew = Union[Decimal, float, str, Tuple[int, Sequence[int], int]] +_DecimalNew = Union[Decimal, float, str, tuple[int, Sequence[int], int]] _ComparableNum = Union[Decimal, float, numbers.Rational] _DecimalT = TypeVar("_DecimalT", bound=Decimal) class DecimalTuple(NamedTuple): sign: int - digits: Tuple[int, ...] + digits: tuple[int, ...] exponent: int ROUND_DOWN: str @@ -184,7 +185,7 @@ class Context(object): # __setattr__() only allows to set a specific set of attributes, # already defined above. def __delattr__(self, __name: str) -> None: ... - def __reduce__(self) -> tuple[Type[Context], Tuple[Any, ...]]: ... + def __reduce__(self) -> tuple[Type[Context], tuple[Any, ...]]: ... def clear_flags(self) -> None: ... def clear_traps(self) -> None: ... def copy(self) -> Context: ... diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index 944a63966241..371e083ea37d 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable, Iterator, Sequence import sys -from typing import Any, AnyStr, Callable, Generic, Iterable, Iterator, NamedTuple, Sequence, TypeVar, Union, overload +from typing import Any, AnyStr, Generic, NamedTuple, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index ac0632d25c9c..832fbfbdf0c3 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable, Iterator import sys import types from opcode import ( @@ -16,7 +17,7 @@ from opcode import ( opname as opname, stack_effect as stack_effect, ) -from typing import IO, Any, Callable, Iterator, NamedTuple, Union +from typing import IO, Any, NamedTuple, Union # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) diff --git a/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index d21de4691503..eee4577dd005 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,6 +1,7 @@ -from typing import Any, Callable, Optional, Tuple, Union +from collections.abc import Callable +from typing import Any, Optional, Union -_Macro = Union[Tuple[str], Tuple[str, Optional[str]]] +_Macro = Union[tuple[str], tuple[str, Optional[str]]] def gen_lib_options( compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str] @@ -141,7 +142,7 @@ class CCompiler: def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... def object_filenames(self, source_filenames: list[str], strip_dir: int = ..., output_dir: str = ...) -> list[str]: ... def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... + def execute(self, func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... def spawn(self, cmd: list[str]) -> None: ... def mkpath(self, name: str, mode: int = ...) -> None: ... def move_file(self, src: str, dst: str) -> str: ... diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 875e851bed39..b2fcd74c69a2 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable from abc import abstractmethod from distutils.dist import Distribution -from typing import Any, Callable, Iterable +from typing import Any class Command: sub_commands: list[tuple[str, Callable[[Command], bool] | None]] diff --git a/stdlib/distutils/command/install.pyi b/stdlib/distutils/command/install.pyi index 47fa8b08d1b2..661d256e6f07 100644 --- a/stdlib/distutils/command/install.pyi +++ b/stdlib/distutils/command/install.pyi @@ -1,9 +1,9 @@ -from typing import Any, Tuple +from typing import Any from ..cmd import Command HAS_USER_SITE: bool -SCHEME_KEYS: Tuple[str, ...] +SCHEME_KEYS: tuple[str, ...] INSTALL_SCHEMES: dict[str, dict[Any, Any]] class install(Command): diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index fc4cd81c4752..b1398d694804 100644 --- a/stdlib/distutils/core.pyi +++ b/stdlib/distutils/core.pyi @@ -1,7 +1,8 @@ +from collections.abc import Mapping 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, Type +from typing import Any, Type def setup( *, diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 5bb04b049995..a0fed84fb5cf 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterable, Mapping from _typeshed import StrOrBytesPath, SupportsWrite from distutils.cmd import Command -from typing import IO, Any, Iterable, Mapping, Type +from typing import IO, Any, Type class DistributionMetadata: def __init__(self, path: int | StrOrBytesPath | None = ...) -> None: ... diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index 06a0847e4687..f7eb7fadf575 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,7 +1,8 @@ -from typing import Any, Iterable, List, Mapping, Optional, Tuple, overload +from collections.abc import Iterable, Mapping +from typing import Any, Optional, overload -_Option = Tuple[str, Optional[str], str] -_GR = Tuple[List[str], OptionDummy] +_Option = tuple[str, Optional[str], str] +_GR = tuple[list[str], OptionDummy] def fancy_getopt( options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None diff --git a/stdlib/distutils/file_util.pyi b/stdlib/distutils/file_util.pyi index a7f24105a678..0ab03496e26b 100644 --- a/stdlib/distutils/file_util.pyi +++ b/stdlib/distutils/file_util.pyi @@ -1,4 +1,5 @@ -from typing import Sequence +from collections.abc import Sequence + def copy_file( src: str, diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 2b436938f13e..361cb13f0c47 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -1,4 +1,5 @@ -from typing import Iterable, Pattern, overload +from collections.abc import Iterable +from typing import Pattern, overload from typing_extensions import Literal # class is entirely undocumented diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index 3f579be40882..5afcc7cc203f 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping from distutils.ccompiler import CCompiler -from typing import Mapping + PREFIX: str EXEC_PREFIX: str diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index 9b0915570ece..03ee0185cac4 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -1,6 +1,6 @@ from _typeshed import StrPath from collections.abc import Callable, Container, Iterable, Mapping -from typing import Any, Tuple +from typing import Any def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... @@ -9,7 +9,7 @@ def check_environ() -> None: ... def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... def split_quoted(s: str) -> list[str]: ... def execute( - func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... + func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... def strtobool(val: str) -> bool: ... def byte_compile( diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 9921dde39af6..1908cdeda97a 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Pattern, Tuple, TypeVar +from typing import Pattern, TypeVar _T = TypeVar("_T", bound=Version) @@ -31,7 +31,7 @@ class StrictVersion(Version): class LooseVersion(Version): component_re: Pattern[str] vstring: str - version: Tuple[str | int, ...] + version: tuple[str | int, ...] def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 9a9f83b0d8fe..b291ff073066 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import types import unittest -from typing import Any, Callable, NamedTuple, Tuple, Type +from typing import Any, NamedTuple, Type class TestResults(NamedTuple): failed: int @@ -86,7 +87,7 @@ class DocTestFinder: ) -> list[DocTest]: ... _Out = Callable[[str], Any] -_ExcInfo = Tuple[Type[BaseException], BaseException, types.TracebackType] +_ExcInfo = tuple[Type[BaseException], BaseException, types.TracebackType] class DocTestRunner: DIVIDER: str diff --git a/stdlib/email/__init__.pyi b/stdlib/email/__init__.pyi index e2c22554a092..908455046b38 100644 --- a/stdlib/email/__init__.pyi +++ b/stdlib/email/__init__.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable from email.message import Message from email.policy import Policy -from typing import IO, Callable +from typing import IO def message_from_string(s: str, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ... def message_from_bytes(s: bytes, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ... diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index a14f5a2d2238..61cf16ed523b 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -1,7 +1,8 @@ +from collections.abc import Iterable, Iterator import sys from email.errors import HeaderParseError, MessageDefect from email.policy import Policy -from typing import Any, Iterable, Iterator, List, Pattern, Type, TypeVar, Union +from typing import Any, Pattern, Type, TypeVar, Union from typing_extensions import Final _T = TypeVar("_T") @@ -23,7 +24,7 @@ def quote_string(value: Any) -> str: ... if sys.version_info >= (3, 7): rfc2047_matcher: Pattern[str] -class TokenList(List[Union[TokenList, Terminal]]): +class TokenList(list[Union[TokenList, Terminal]]): token_type: str | None syntactic_break: bool ew_combine_allowed: bool diff --git a/stdlib/email/charset.pyi b/stdlib/email/charset.pyi index 4bf5d11690eb..cff0fa9928d1 100644 --- a/stdlib/email/charset.pyi +++ b/stdlib/email/charset.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any QP: int # undocumented BASE64: int # undocumented diff --git a/stdlib/email/contentmanager.pyi b/stdlib/email/contentmanager.pyi index 68fe99c8c09f..3ac665eaa7bf 100644 --- a/stdlib/email/contentmanager.pyi +++ b/stdlib/email/contentmanager.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from email.message import Message -from typing import Any, Callable +from typing import Any class ContentManager: def __init__(self) -> None: ... diff --git a/stdlib/email/feedparser.pyi b/stdlib/email/feedparser.pyi index ffcf4f0a7c6e..ddeccf7f69e9 100644 --- a/stdlib/email/feedparser.pyi +++ b/stdlib/email/feedparser.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable from email.message import Message from email.policy import Policy -from typing import Callable, Generic, TypeVar, overload +from typing import Generic, TypeVar, overload _M = TypeVar("_M", bound=Message) diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index 6a3d6ca5b2a7..abf10ed4a4fd 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -13,7 +13,7 @@ from email._header_value_parser import ( ) from email.errors import MessageDefect from email.policy import Policy -from typing import Any, ClassVar, Tuple, Type +from typing import Any, ClassVar, Type from typing_extensions import Literal class BaseHeader(str): @@ -22,7 +22,7 @@ class BaseHeader(str): @property def name(self) -> str: ... @property - def defects(self) -> Tuple[MessageDefect, ...]: ... + def defects(self) -> tuple[MessageDefect, ...]: ... def __new__(cls, name: str, value: Any) -> BaseHeader: ... def init(self, name: str, *, parse_tree: TokenList, defects: Iterable[MessageDefect]) -> None: ... def fold(self, *, policy: Policy) -> str: ... @@ -54,9 +54,9 @@ class AddressHeader: max_count: ClassVar[Literal[1] | None] def init(self, name: str, *, parse_tree: TokenList, defects: Iterable[MessageDefect], groups: Iterable[Group]) -> None: ... @property - def groups(self) -> Tuple[Group, ...]: ... + def groups(self) -> tuple[Group, ...]: ... @property - def addresses(self) -> Tuple[Address, ...]: ... + def addresses(self) -> tuple[Address, ...]: ... @staticmethod def value_parser(value: str) -> AddressList: ... @classmethod @@ -165,6 +165,6 @@ class Group: @property def display_name(self) -> str | None: ... @property - def addresses(self) -> Tuple[Address, ...]: ... + def addresses(self) -> tuple[Address, ...]: ... def __init__(self, display_name: str | None = ..., addresses: Iterable[Address] | None = ...) -> None: ... def __str__(self) -> str: ... diff --git a/stdlib/email/iterators.pyi b/stdlib/email/iterators.pyi index 9081a3e3ba73..179c1b2190b8 100644 --- a/stdlib/email/iterators.pyi +++ b/stdlib/email/iterators.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterator from email.message import Message -from typing import Iterator + def body_line_iterator(msg: Message, decode: bool = ...) -> Iterator[str]: ... def typed_subpart_iterator(msg: Message, maintype: str = ..., subtype: str | None = ...) -> Iterator[str]: ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index a1749a4cfc2e..8a2f66584a8f 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -1,15 +1,16 @@ +from collections.abc import Generator, Iterator, Sequence from email.charset import Charset from email.contentmanager import ContentManager from email.errors import MessageDefect from email.policy import Policy -from typing import Any, Generator, Iterator, List, Optional, Sequence, Tuple, TypeVar, Union +from typing import Any, Optional, TypeVar, Union _T = TypeVar("_T") -_PayloadType = Union[List[Message], str, bytes] +_PayloadType = Union[list[Message], str, bytes] _CharsetType = Union[Charset, str, None] -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] -_ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] +_ParamType = Union[str, tuple[Optional[str], Optional[str], str]] _HeaderType = Any class Message: diff --git a/stdlib/email/mime/application.pyi b/stdlib/email/mime/application.pyi index 11fc470e9dd1..08d0918f890c 100644 --- a/stdlib/email/mime/application.pyi +++ b/stdlib/email/mime/application.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEApplication(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/audio.pyi b/stdlib/email/mime/audio.pyi index ee6de410bf53..82fea0a040d9 100644 --- a/stdlib/email/mime/audio.pyi +++ b/stdlib/email/mime/audio.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEAudio(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/base.pyi b/stdlib/email/mime/base.pyi index b88dfd492554..cb655607b032 100644 --- a/stdlib/email/mime/base.pyi +++ b/stdlib/email/mime/base.pyi @@ -1,8 +1,8 @@ import email.message from email.policy import Policy -from typing import Optional, Tuple, Union +from typing import Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEBase(email.message.Message): def __init__(self, _maintype: str, _subtype: str, *, policy: Policy | None = ..., **_params: _ParamsType) -> None: ... diff --git a/stdlib/email/mime/image.pyi b/stdlib/email/mime/image.pyi index 886aa74d5fe5..ee0ba631782b 100644 --- a/stdlib/email/mime/image.pyi +++ b/stdlib/email/mime/image.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEImage(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/multipart.pyi b/stdlib/email/mime/multipart.pyi index 6259ddf5ab8f..88890117971c 100644 --- a/stdlib/email/mime/multipart.pyi +++ b/stdlib/email/mime/multipart.pyi @@ -1,9 +1,10 @@ +from collections.abc import Sequence from email.message import Message from email.mime.base import MIMEBase from email.policy import Policy -from typing import Optional, Sequence, Tuple, Union +from typing import Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEMultipart(MIMEBase): def __init__( diff --git a/stdlib/email/parser.pyi b/stdlib/email/parser.pyi index 574c927eeaf5..e044f458e8ca 100644 --- a/stdlib/email/parser.pyi +++ b/stdlib/email/parser.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import email.feedparser from email.message import Message from email.policy import Policy -from typing import BinaryIO, Callable, TextIO +from typing import BinaryIO, TextIO FeedParser = email.feedparser.FeedParser BytesFeedParser = email.feedparser.BytesFeedParser diff --git a/stdlib/email/policy.pyi b/stdlib/email/policy.pyi index 15991c7e084b..567573da8028 100644 --- a/stdlib/email/policy.pyi +++ b/stdlib/email/policy.pyi @@ -1,9 +1,10 @@ +from collections.abc import Callable from abc import ABCMeta, abstractmethod 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 +from typing import Any class Policy(metaclass=ABCMeta): max_line_length: int | None diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index 3c07e98079fc..728a5a53f230 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -1,10 +1,10 @@ import datetime import sys from email.charset import Charset -from typing import Optional, Tuple, Union, overload +from typing import Optional, Union, overload -_ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] -_PDTZ = Tuple[int, int, int, int, int, int, int, int, int, Optional[int]] +_ParamType = Union[str, tuple[Optional[str], Optional[str], str]] +_PDTZ = tuple[int, int, int, int, int, int, int, int, int, Optional[int]] def quote(str: str) -> str: ... def unquote(str: str) -> str: ... diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index e8846ba5293e..a80a022ad6f5 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -3,7 +3,7 @@ import types from abc import ABCMeta from builtins import property as _builtins_property from collections.abc import Iterable, Iterator, Mapping -from typing import Any, Dict, Tuple, Type, TypeVar, Union, overload +from typing import Any, Type, TypeVar, Union, overload _T = TypeVar("_T") _S = TypeVar("_S", bound=Type[Enum]) @@ -21,7 +21,7 @@ _S = TypeVar("_S", bound=Type[Enum]) # _EnumNames = Union[str, Iterable[str], Iterable[Iterable[Union[str, Any]]], Mapping[str, Any]] -class _EnumDict(Dict[str, Any]): +class _EnumDict(dict[str, Any]): def __init__(self) -> None: ... # Note: EnumMeta actually subclasses type directly, not ABCMeta. @@ -34,7 +34,7 @@ class EnumMeta(ABCMeta): def __new__( metacls: Type[_T], cls: str, - bases: Tuple[type, ...], + bases: tuple[type, ...], classdict: _EnumDict, *, boundary: FlagBoundary | None = ..., @@ -42,9 +42,9 @@ class EnumMeta(ABCMeta): **kwds: Any, ) -> _T: ... elif sys.version_info >= (3, 9): - def __new__(metacls: Type[_T], cls: str, bases: Tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> _T: ... # type: ignore + def __new__(metacls: Type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> _T: ... # type: ignore else: - def __new__(metacls: Type[_T], cls: str, bases: Tuple[type, ...], classdict: _EnumDict) -> _T: ... # type: ignore + def __new__(metacls: Type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> _T: ... # type: ignore def __iter__(self: Type[_T]) -> Iterator[_T]: ... def __reversed__(self: Type[_T]) -> Iterator[_T]: ... def __contains__(self: Type[Any], member: object) -> bool: ... diff --git a/stdlib/errno.pyi b/stdlib/errno.pyi index b053604fc33a..fcbe48570af4 100644 --- a/stdlib/errno.pyi +++ b/stdlib/errno.pyi @@ -1,4 +1,5 @@ -from typing import Mapping +from collections.abc import Mapping + errorcode: Mapping[int, str] diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 1c3d0a142a33..424994270da6 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Iterable, Sequence import sys from _typeshed import StrOrBytesPath from os import PathLike -from typing import Any, AnyStr, Callable, Generic, Iterable, Sequence +from typing import Any, AnyStr, Generic if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index 576822059560..c4c7b95ab153 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Iterator import sys from _typeshed import Self, StrOrBytesPath -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator +from typing import IO, Any, AnyStr, Generic if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/fnmatch.pyi b/stdlib/fnmatch.pyi index 1cbcf00729ed..40b7ab44426a 100644 --- a/stdlib/fnmatch.pyi +++ b/stdlib/fnmatch.pyi @@ -1,4 +1,5 @@ -from typing import AnyStr, Iterable +from collections.abc import Iterable +from typing import AnyStr def fnmatch(name: AnyStr, pat: AnyStr) -> bool: ... def fnmatchcase(name: AnyStr, pat: AnyStr) -> bool: ... diff --git a/stdlib/formatter.pyi b/stdlib/formatter.pyi index 7c3b97688dbd..6641f00f7126 100644 --- a/stdlib/formatter.pyi +++ b/stdlib/formatter.pyi @@ -1,8 +1,9 @@ -from typing import IO, Any, Iterable, Tuple +from collections.abc import Iterable +from typing import IO, Any AS_IS: None -_FontType = Tuple[str, bool, bool, bool] -_StylesType = Tuple[Any, ...] +_FontType = tuple[str, bool, bool, bool] +_StylesType = tuple[Any, ...] class NullFormatter: writer: NullWriter | None @@ -68,7 +69,7 @@ class NullWriter: def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... def new_spacing(self, spacing: str | None) -> None: ... - def new_styles(self, styles: Tuple[Any, ...]) -> None: ... + def new_styles(self, styles: tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... @@ -81,7 +82,7 @@ class AbstractWriter(NullWriter): def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... def new_spacing(self, spacing: str | None) -> None: ... - def new_styles(self, styles: Tuple[Any, ...]) -> None: ... + def new_styles(self, styles: tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index 745669ce0f18..edb39a0b9ada 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -1,9 +1,10 @@ +from collections.abc import Callable, Iterable, Iterator import sys from _typeshed import Self, SupportsRead, SupportsReadline from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Callable, Iterable, Iterator, TextIO, Tuple, Type +from typing import Any, TextIO, Type from typing_extensions import Literal MSG_OOB: int @@ -18,7 +19,7 @@ class error_temp(Error): ... class error_perm(Error): ... class error_proto(Error): ... -all_errors: Tuple[Type[Exception], ...] +all_errors: tuple[Type[Exception], ...] class FTP: debugging: int diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 78ed5992a468..82f50ccc5124 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Hashable, Iterable, Sequence, Sized import sys import types from _typeshed import SupportsAllComparisons, SupportsItems -from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, Tuple, Type, TypeVar, overload +from typing import Any, Generic, NamedTuple, Type, TypeVar, overload from typing_extensions import final if sys.version_info >= (3, 9): @@ -49,7 +50,7 @@ def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], SupportsAllComp class partial(Generic[_T]): func: Callable[..., _T] - args: Tuple[Any, ...] + args: tuple[Any, ...] keywords: dict[str, Any] def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> _T: ... @@ -61,7 +62,7 @@ _Descriptor = Any class partialmethod(Generic[_T]): func: Callable[..., _T] | _Descriptor - args: Tuple[Any, ...] + args: tuple[Any, ...] keywords: dict[str, Any] @overload def __init__(self, __func: Callable[..., _T], *args: Any, **keywords: Any) -> None: ... @@ -120,10 +121,10 @@ if sys.version_info >= (3, 9): def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ... def _make_key( - args: Tuple[Hashable, ...], + args: tuple[Hashable, ...], kwds: SupportsItems[Any, Any], typed: bool, - kwd_mark: Tuple[object, ...] = ..., + kwd_mark: tuple[object, ...] = ..., fasttypes: set[type] = ..., tuple: type = ..., type: Any = ..., diff --git a/stdlib/genericpath.pyi b/stdlib/genericpath.pyi index c9829ae350f1..09582d35ea8b 100644 --- a/stdlib/genericpath.pyi +++ b/stdlib/genericpath.pyi @@ -1,6 +1,7 @@ +from collections.abc import Sequence import os from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRichComparisonT -from typing import Sequence, Tuple, overload +from typing import overload from typing_extensions import Literal # All overloads can return empty string. Ideally, Literal[""] would be a valid @@ -13,7 +14,7 @@ def commonprefix(m: Sequence[BytesPath]) -> bytes | Literal[""]: ... @overload def commonprefix(m: Sequence[list[SupportsRichComparisonT]]) -> Sequence[SupportsRichComparisonT]: ... @overload -def commonprefix(m: Sequence[Tuple[SupportsRichComparisonT, ...]]) -> Sequence[SupportsRichComparisonT]: ... +def commonprefix(m: Sequence[tuple[SupportsRichComparisonT, ...]]) -> Sequence[SupportsRichComparisonT]: ... def exists(path: StrOrBytesPath | int) -> bool: ... def getsize(filename: StrOrBytesPath | int) -> int: ... def isfile(path: StrOrBytesPath | int) -> bool: ... diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index 21be9fb1ff29..5868fd7371b9 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -1,6 +1,7 @@ +from collections.abc import Container, Iterable, Sequence import sys from _typeshed import StrPath -from typing import IO, Any, Container, Iterable, Sequence, Type, TypeVar, overload +from typing import IO, Any, Type, TypeVar, overload from typing_extensions import Literal class NullTranslations: diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index c1cd176f500c..b1c72f4191af 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterator import sys from _typeshed import StrOrBytesPath -from typing import AnyStr, Iterator +from typing import AnyStr def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... diff --git a/stdlib/graphlib.pyi b/stdlib/graphlib.pyi index 0872af4a54a4..583fd8a88fd2 100644 --- a/stdlib/graphlib.pyi +++ b/stdlib/graphlib.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable from _typeshed import SupportsItems -from typing import Generic, Iterable, Tuple, TypeVar +from typing import Generic, TypeVar _T = TypeVar("_T") @@ -10,7 +11,7 @@ class TopologicalSorter(Generic[_T]): def is_active(self) -> bool: ... def __bool__(self) -> bool: ... def done(self, *nodes: _T) -> None: ... - def get_ready(self) -> Tuple[_T, ...]: ... + def get_ready(self) -> tuple[_T, ...]: ... def static_order(self) -> Iterable[_T]: ... class CycleError(ValueError): ... diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 33f2a9774be8..52be219f354f 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -1,9 +1,9 @@ from _typeshed import structseq -from typing import Any, List, Optional, Tuple +from typing import Any, Optional from typing_extensions import final @final -class struct_group(structseq[Any], Tuple[str, Optional[str], int, List[str]]): +class struct_group(structseq[Any], tuple[str, Optional[str], int, list[str]]): @property def gr_name(self) -> str: ... @property diff --git a/stdlib/heapq.pyi b/stdlib/heapq.pyi index fd3c2db8ad66..8d3c0d5d5fb3 100644 --- a/stdlib/heapq.pyi +++ b/stdlib/heapq.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable from _typeshed import SupportsRichComparison -from typing import Any, Callable, Iterable, TypeVar +from typing import Any, TypeVar _T = TypeVar("_T") diff --git a/stdlib/hmac.pyi b/stdlib/hmac.pyi index 88c88631f99a..c4cc76bc4604 100644 --- a/stdlib/hmac.pyi +++ b/stdlib/hmac.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import sys from _typeshed import ReadableBuffer from types import ModuleType -from typing import Any, AnyStr, Callable, Union, overload +from typing import Any, AnyStr, Union, overload # TODO more precise type for object of hashlib _Hash = Any diff --git a/stdlib/html/parser.pyi b/stdlib/html/parser.pyi index 66515cad03ba..60e0de51d3b8 100644 --- a/stdlib/html/parser.pyi +++ b/stdlib/html/parser.pyi @@ -1,5 +1,5 @@ from _markupbase import ParserBase -from typing import Pattern, Tuple +from typing import Pattern class HTMLParser(ParserBase): def __init__(self, *, convert_charrefs: bool = ...) -> None: ... @@ -18,7 +18,7 @@ class HTMLParser(ParserBase): def handle_decl(self, decl: str) -> None: ... def handle_pi(self, data: str) -> None: ... def unknown_decl(self, data: str) -> None: ... - CDATA_CONTENT_ELEMENTS: Tuple[str, ...] + CDATA_CONTENT_ELEMENTS: tuple[str, ...] def check_for_whole_start_tag(self, i: int) -> int: ... # undocumented def clear_cdata_mode(self) -> None: ... # undocumented def goahead(self, end: bool) -> None: ... # undocumented diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 1558f6ff46e8..4a1eb8bcc2da 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping import email.message import io import ssl @@ -5,7 +6,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, Type, TypeVar, Union, overload +from typing import IO, Any, BinaryIO, Protocol, Type, TypeVar, Union, overload _DataType = Union[bytes, IO[Any], Iterable[bytes], str] _T = TypeVar("_T") diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index f37fb19cebe9..3700570b2057 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,7 +1,8 @@ +from collections.abc import Iterable, Iterator, Sequence import sys from _typeshed import StrPath from http.client import HTTPResponse -from typing import ClassVar, Iterable, Iterator, Pattern, Sequence, Tuple, TypeVar, overload +from typing import ClassVar, Pattern, TypeVar, overload from urllib.request import Request _T = TypeVar("_T") @@ -102,10 +103,10 @@ class DefaultCookiePolicy(CookiePolicy): strict_ns_set_initial_dollar: bool = ..., strict_ns_set_path: bool = ..., ) -> None: ... - def blocked_domains(self) -> Tuple[str, ...]: ... + def blocked_domains(self) -> tuple[str, ...]: ... def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ... def is_blocked(self, domain: str) -> bool: ... - def allowed_domains(self) -> Tuple[str, ...] | None: ... + def allowed_domains(self) -> tuple[str, ...] | None: ... def set_allowed_domains(self, allowed_domains: Sequence[str] | None) -> None: ... def is_not_allowed(self, domain: str) -> bool: ... def set_ok_version(self, cookie: Cookie, request: Request) -> bool: ... # undocumented diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 4244c0c6aa0d..ee6fc9e3e860 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Mapping import sys -from typing import Any, Dict, Generic, Iterable, Mapping, TypeVar, Union, overload +from typing import Any, Generic, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -18,7 +19,7 @@ def _unquote(str: str) -> str: ... class CookieError(Exception): ... -class Morsel(Dict[str, Any], Generic[_T]): +class Morsel(dict[str, Any], Generic[_T]): value: str coded_value: _T key: str @@ -40,7 +41,7 @@ class Morsel(Dict[str, Any], Generic[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]): +class BaseCookie(dict[str, Morsel[_T]], Generic[_T]): def __init__(self, input: _DataType | None = ...) -> None: ... def value_decode(self, val: str) -> _T: ... def value_encode(self, val: _T) -> str: ... diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index e3d0a8c318f4..f6b2a66af8ea 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -1,9 +1,10 @@ +from collections.abc import Mapping, Sequence import email.message import io import socketserver import sys from _typeshed import StrPath, SupportsRead, SupportsWrite -from typing import Any, AnyStr, BinaryIO, ClassVar, Mapping, Sequence +from typing import Any, AnyStr, BinaryIO, ClassVar class HTTPServer(socketserver.TCPServer): server_name: str diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index a9f19048c9ae..5d01663533c2 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable import subprocess import sys import time @@ -5,14 +6,14 @@ from _typeshed import Self from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Callable, List, Pattern, Tuple, Type, Union +from typing import IO, Any, Pattern, Type, Union from typing_extensions import Literal # TODO: Commands should use their actual return types, not this type alias. # E.g. Tuple[Literal["OK"], List[bytes]] -_CommandResults = Tuple[str, List[Any]] +_CommandResults = tuple[str, list[Any]] -_AnyResponseData = Union[List[None], List[Union[bytes, Tuple[bytes, bytes]]]] +_AnyResponseData = Union[list[None], list[Union[bytes, tuple[bytes, bytes]]]] _list = list # conflicts with a method named "list" diff --git a/stdlib/imghdr.pyi b/stdlib/imghdr.pyi index 4515cf2269b0..85e475b1fa41 100644 --- a/stdlib/imghdr.pyi +++ b/stdlib/imghdr.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from _typeshed import StrPath -from typing import Any, BinaryIO, Callable, Protocol, overload +from typing import Any, BinaryIO, Protocol, overload class _ReadableBinary(Protocol): def tell(self) -> int: ... diff --git a/stdlib/importlib/__init__.pyi b/stdlib/importlib/__init__.pyi index 1b91cc55f2df..748f536bdd7e 100644 --- a/stdlib/importlib/__init__.pyi +++ b/stdlib/importlib/__init__.pyi @@ -1,6 +1,7 @@ +from collections.abc import Mapping, Sequence from importlib.abc import Loader from types import ModuleType -from typing import Mapping, Sequence + # Signature of `builtins.__import__` should be kept identical to `importlib.__import__` def __import__( diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 9bb370dfd7e8..6e45f234aabf 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -1,3 +1,4 @@ +from collections.abc import Iterator, Mapping, Sequence import sys import types from _typeshed import ( @@ -12,7 +13,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, NoReturn, Protocol, Sequence, Union, overload, runtime_checkable +from typing import IO, Any, BinaryIO, NoReturn, Protocol, Union, overload, runtime_checkable from typing_extensions import Literal _Path = Union[bytes, str] diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index b73f9c527583..4d481c0bf8f8 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Iterable, Sequence import importlib.abc import sys import types -from typing import Any, Callable, Iterable, Sequence +from typing import Any if sys.version_info >= (3, 8): from importlib.metadata import DistributionFinder, PathDistribution diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index c5d9efba9ad6..5b85beb3640f 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -1,3 +1,4 @@ +from collections.abc import Iterable import abc import pathlib import sys @@ -7,7 +8,7 @@ from email.message import Message from importlib.abc import MetaPathFinder from os import PathLike from pathlib import Path -from typing import Any, ClassVar, Iterable, NamedTuple, Pattern, Tuple, overload +from typing import Any, ClassVar, NamedTuple, Pattern, overload if sys.version_info >= (3, 10): from importlib.metadata._meta import PackageMetadata as PackageMetadata @@ -101,6 +102,6 @@ if sys.version_info >= (3, 8): ) -> Iterable[Distribution]: ... def metadata(distribution_name: str) -> Message: ... def version(distribution_name: str) -> str: ... - def entry_points() -> dict[str, Tuple[EntryPoint, ...]]: ... + def entry_points() -> dict[str, tuple[EntryPoint, ...]]: ... def files(distribution_name: str) -> list[PackagePath] | None: ... def requires(distribution_name: str) -> list[str] | None: ... diff --git a/stdlib/importlib/metadata/_meta.pyi b/stdlib/importlib/metadata/_meta.pyi index a5e5733396d7..a1101df0d5ce 100644 --- a/stdlib/importlib/metadata/_meta.pyi +++ b/stdlib/importlib/metadata/_meta.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator, Protocol, TypeVar +from collections.abc import Iterator +from typing import Any, Protocol, TypeVar _T = TypeVar("_T") diff --git a/stdlib/importlib/resources.pyi b/stdlib/importlib/resources.pyi index b484d7126b21..c856196332e3 100644 --- a/stdlib/importlib/resources.pyi +++ b/stdlib/importlib/resources.pyi @@ -1,3 +1,4 @@ +from collections.abc import Iterator import sys from typing import Any @@ -7,7 +8,7 @@ if sys.version_info >= (3, 7): from contextlib import AbstractContextManager from pathlib import Path from types import ModuleType - from typing import BinaryIO, Iterator, TextIO, Union + from typing import BinaryIO, TextIO, Union Package = Union[str, ModuleType] Resource = Union[str, os.PathLike[Any]] diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index 96db3146863e..4e09c8cb8010 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -1,9 +1,10 @@ +from collections.abc import Callable import importlib.abc import importlib.machinery import sys import types from _typeshed import StrOrBytesPath -from typing import Any, Callable +from typing import Any from typing_extensions import ParamSpec _P = ParamSpec("_P") diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 35c9149c01f0..d4c81f474db4 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -23,7 +23,7 @@ from types import ( if sys.version_info >= (3, 7): from types import ClassMethodDescriptorType, WrapperDescriptorType, MemberDescriptorType, MethodDescriptorType -from typing import Any, ClassVar, NamedTuple, Protocol, Tuple, Type, TypeVar, Union +from typing import Any, ClassVar, NamedTuple, Protocol, Type, TypeVar, Union from typing_extensions import Literal, TypeGuard # @@ -234,7 +234,7 @@ class Parameter: class BoundArguments: arguments: OrderedDict[str, Any] - args: Tuple[Any, ...] + args: tuple[Any, ...] kwargs: dict[str, Any] signature: Signature def __init__(self, signature: Signature, arguments: OrderedDict[str, Any]) -> None: ... @@ -262,14 +262,14 @@ if sys.version_info < (3, 11): args: list[str] varargs: str | None keywords: str | None - defaults: Tuple[Any, ...] + defaults: tuple[Any, ...] def getargspec(func: object) -> ArgSpec: ... class FullArgSpec(NamedTuple): args: list[str] varargs: str | None varkw: str | None - defaults: Tuple[Any, ...] | None + defaults: tuple[Any, ...] | None kwonlyargs: list[str] kwonlydefaults: dict[str, Any] | None annotations: dict[str, Any] @@ -291,7 +291,7 @@ if sys.version_info < (3, 11): args: list[str], varargs: str | None = ..., varkw: str | None = ..., - defaults: Tuple[Any, ...] | None = ..., + defaults: tuple[Any, ...] | None = ..., kwonlyargs: Sequence[str] | None = ..., kwonlydefaults: dict[str, Any] | None = ..., annotations: dict[str, Any] = ..., @@ -313,7 +313,7 @@ def formatargvalues( formatvarkw: Callable[[str], str] | None = ..., formatvalue: Callable[[Any], str] | None = ..., ) -> str: ... -def getmro(cls: type) -> Tuple[type, ...]: ... +def getmro(cls: type) -> tuple[type, ...]: ... def getcallargs(__func: Callable[..., Any], *args: Any, **kwds: Any) -> dict[str, Any]: ... class ClosureVars(NamedTuple): diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 29c42ed9da71..bc470d8d7c20 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -1,10 +1,11 @@ +from collections.abc import Callable, Iterable, Iterator import builtins import codecs import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer from os import _Opener from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, TextIO, Tuple, Type +from typing import IO, Any, BinaryIO, TextIO, Type DEFAULT_BUFFER_SIZE: int @@ -119,7 +120,7 @@ class BufferedRWPair(BufferedIOBase): class TextIOBase(IOBase): encoding: str errors: str | None - newlines: str | Tuple[str, ...] | None + newlines: str | tuple[str, ...] | None def __iter__(self) -> Iterator[str]: ... # type: ignore[override] def __next__(self) -> str: ... # type: ignore[override] def detach(self) -> BinaryIO: ... @@ -179,4 +180,4 @@ class IncrementalNewlineDecoder(codecs.IncrementalDecoder): def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ... def decode(self, input: bytes | str, final: bool = ...) -> str: ... @property - def newlines(self) -> str | Tuple[str, ...] | None: ... + def newlines(self) -> str | tuple[str, ...] | None: ... diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index 6af3ebc3a2bd..e0b631bc652b 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -1,5 +1,6 @@ +from collections.abc import Container, Iterable, Iterator import sys -from typing import Any, Container, Generic, Iterable, Iterator, SupportsInt, TypeVar, overload +from typing import Any, Generic, SupportsInt, TypeVar, overload # Undocumented length constants IPV4LENGTH: int diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 1ff7ffc181ed..8b0a41922526 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -1,15 +1,16 @@ +from collections.abc import Callable, Iterable, Iterator import sys from _typeshed import _T_co from typing import ( Any, - Callable, + Generic, - Iterable, - Iterator, + + SupportsComplex, SupportsFloat, SupportsInt, - Tuple, + Type, TypeVar, Union, @@ -91,7 +92,7 @@ class filterfalse(Iterator[_T], Generic[_T]): _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") -class groupby(Iterator[Tuple[_T, Iterator[_S]]], Generic[_T, _S]): +class groupby(Iterator[tuple[_T, Iterator[_S]]], Generic[_T, _S]): @overload def __new__(cls, iterable: Iterable[_T1], key: None = ...) -> groupby[_T1, _T1]: ... @overload @@ -117,7 +118,7 @@ class takewhile(Iterator[_T], Generic[_T]): def __iter__(self) -> Iterator[_T]: ... def __next__(self) -> _T: ... -def tee(__iterable: Iterable[_T], __n: int = ...) -> Tuple[Iterator[_T], ...]: ... +def tee(__iterable: Iterable[_T], __n: int = ...) -> tuple[Iterator[_T], ...]: ... class zip_longest(Iterator[Any]): def __init__(self, *p: Iterable[Any], fillvalue: Any = ...) -> None: ... @@ -170,18 +171,18 @@ class product(Iterator[_T_co], Generic[_T_co]): __iter6: Iterable[Any], __iter7: Iterable[Any], *iterables: Iterable[Any], - ) -> product[Tuple[Any, ...]]: ... + ) -> product[tuple[Any, ...]]: ... @overload - def __new__(cls, *iterables: Iterable[_T1], repeat: int) -> product[Tuple[_T1, ...]]: ... + def __new__(cls, *iterables: Iterable[_T1], repeat: int) -> product[tuple[_T1, ...]]: ... @overload - def __new__(cls, *iterables: Iterable[Any], repeat: int = ...) -> product[Tuple[Any, ...]]: ... + def __new__(cls, *iterables: Iterable[Any], repeat: int = ...) -> product[tuple[Any, ...]]: ... def __iter__(self) -> Iterator[_T_co]: ... def __next__(self) -> _T_co: ... -class permutations(Iterator[Tuple[_T, ...]], Generic[_T]): +class permutations(Iterator[tuple[_T, ...]], Generic[_T]): def __init__(self, iterable: Iterable[_T], r: int | None = ...) -> None: ... - def __iter__(self) -> Iterator[Tuple[_T, ...]]: ... - def __next__(self) -> Tuple[_T, ...]: ... + def __iter__(self) -> Iterator[tuple[_T, ...]]: ... + def __next__(self) -> tuple[_T, ...]: ... class combinations(Iterator[_T_co], Generic[_T_co]): @overload @@ -193,14 +194,14 @@ class combinations(Iterator[_T_co], Generic[_T_co]): @overload def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> combinations[tuple[_T, _T, _T, _T, _T]]: ... @overload - def __new__(cls, iterable: Iterable[_T], r: int) -> combinations[Tuple[_T, ...]]: ... + def __new__(cls, iterable: Iterable[_T], r: int) -> combinations[tuple[_T, ...]]: ... def __iter__(self) -> Iterator[_T_co]: ... def __next__(self) -> _T_co: ... -class combinations_with_replacement(Iterator[Tuple[_T, ...]], Generic[_T]): +class combinations_with_replacement(Iterator[tuple[_T, ...]], Generic[_T]): def __init__(self, iterable: Iterable[_T], r: int) -> None: ... - def __iter__(self) -> Iterator[Tuple[_T, ...]]: ... - def __next__(self) -> Tuple[_T, ...]: ... + def __iter__(self) -> Iterator[tuple[_T, ...]]: ... + def __next__(self) -> tuple[_T, ...]: ... if sys.version_info >= (3, 10): class pairwise(Iterator[_T_co], Generic[_T_co]): diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index 3e26d1b14f82..69871bfba614 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from _typeshed import SupportsRead -from typing import IO, Any, Callable, Type +from typing import IO, Any, Type from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder from .encoder import JSONEncoder as JSONEncoder diff --git a/stdlib/json/decoder.pyi b/stdlib/json/decoder.pyi index adf09bb4bb7d..61aa5d1cdfb2 100644 --- a/stdlib/json/decoder.pyi +++ b/stdlib/json/decoder.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable +from collections.abc import Callable +from typing import Any class JSONDecodeError(ValueError): msg: str diff --git a/stdlib/json/encoder.pyi b/stdlib/json/encoder.pyi index 6dd74896e5a0..ecd1fa78ad99 100644 --- a/stdlib/json/encoder.pyi +++ b/stdlib/json/encoder.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Iterator, Pattern +from collections.abc import Callable, Iterator +from typing import Any, Pattern ESCAPE: Pattern[str] ESCAPE_ASCII: Pattern[str] diff --git a/stdlib/keyword.pyi b/stdlib/keyword.pyi index ac052feeba58..e0581663889d 100644 --- a/stdlib/keyword.pyi +++ b/stdlib/keyword.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence import sys -from typing import Sequence + def iskeyword(s: str) -> bool: ... diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index a8159dccf037..c579cc568acd 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -1,8 +1,9 @@ +from collections.abc import Iterable from _typeshed import StrPath from lib2to3.pgen2.grammar import Grammar from lib2to3.pytree import _NL, _Convert from logging import Logger -from typing import IO, Any, Iterable +from typing import IO, Any class Driver: grammar: Grammar diff --git a/stdlib/lib2to3/pgen2/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index 48cb4eae916c..77cc6aec3d67 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -1,10 +1,10 @@ from _typeshed import StrPath -from typing import Dict, List, Optional, Tuple, TypeVar +from typing import Optional, TypeVar _P = TypeVar("_P") -_Label = Tuple[int, Optional[str]] -_DFA = List[List[Tuple[int, int]]] -_DFAS = Tuple[_DFA, Dict[int, int]] +_Label = tuple[int, Optional[str]] +_DFA = list[list[tuple[int, int]]] +_DFAS = tuple[_DFA, dict[int, int]] class Grammar: symbol2number: dict[str, int] diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index e776ed1e5a61..27f0fa382f10 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -1,6 +1,7 @@ +from collections.abc import Sequence from lib2to3.pgen2.grammar import _DFAS, Grammar from lib2to3.pytree import _NL, _Convert, _RawNode -from typing import Any, Sequence +from typing import Any _Context = Sequence[Any] diff --git a/stdlib/lib2to3/pgen2/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index 11680157d199..abb4f8cdebb2 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -1,7 +1,8 @@ +from collections.abc import Iterable, Iterator from _typeshed import StrPath from lib2to3.pgen2 import grammar from lib2to3.pgen2.tokenize import _TokenInfo -from typing import IO, Any, Iterable, Iterator, NoReturn +from typing import IO, Any, NoReturn class PgenGrammar(grammar.Grammar): ... diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index e96a0d8c8eb3..0d920bc8f1e1 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,9 +1,10 @@ +from collections.abc import Callable, Iterable, Iterator from lib2to3.pgen2.token import * # noqa -from typing import Callable, Iterable, Iterator, Tuple -_Coord = Tuple[int, int] + +_Coord = tuple[int, int] _TokenEater = Callable[[int, str, _Coord, _Coord, str], None] -_TokenInfo = Tuple[int, str, _Coord, _Coord, str] +_TokenInfo = tuple[int, str, _Coord, _Coord, str] class TokenError(Exception): ... class StopTokenizing(Exception): ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index eab82cbc200d..28ef63d117dc 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,11 +1,12 @@ +from collections.abc import Callable, Iterator from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union +from typing import Any, Optional, TypeVar, Union _P = TypeVar("_P") _NL = Union[Node, Leaf] -_Context = Tuple[str, int, int] -_Results = Dict[str, _NL] -_RawNode = Tuple[int, str, _Context, Optional[List[_NL]]] +_Context = tuple[str, int, int] +_Results = dict[str, _NL] +_RawNode = tuple[int, str, _Context, Optional[list[_NL]]] _Convert = Callable[[Grammar, _RawNode], Any] HUGE: int diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index a66614bf6b37..e53d3efea5b2 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,7 +1,7 @@ -from typing import Any, Dict, List, Protocol, Tuple +from typing import Any, Protocol -_ModuleGlobals = Dict[str, Any] -_ModuleMetadata = Tuple[int, float, List[str], str] +_ModuleGlobals = dict[str, Any] +_ModuleMetadata = tuple[int, float, list[str], str] class _SourceLoader(Protocol): def __call__(self) -> str | None: ... diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index c6289f27da2c..ef4e15980989 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -1,10 +1,11 @@ +from collections.abc import Callable, Iterable, Mapping, Sequence import sys # This module defines a function "str()", which is why "str" can't be used # as a type annotation or type alias. from builtins import str as _str from decimal import Decimal -from typing import Any, Callable, Iterable, Mapping, Sequence, Tuple +from typing import Any CODESET: int D_T_FMT: int @@ -82,7 +83,7 @@ class Error(Exception): ... def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... def localeconv() -> Mapping[_str, int | _str | list[int]]: ... def nl_langinfo(__key: int) -> _str: ... -def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> tuple[_str | None, _str | None]: ... +def getdefaultlocale(envvars: tuple[_str, ...] = ...) -> tuple[_str | None, _str | None]: ... def getlocale(category: int = ...) -> Sequence[_str]: ... def getpreferredencoding(do_setlocale: bool = ...) -> _str: ... def normalize(localename: _str) -> _str: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 7d4fa279155c..d580c668181b 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -6,12 +6,12 @@ from io import TextIOWrapper from string import Template from time import struct_time from types import FrameType, TracebackType -from typing import Any, ClassVar, Generic, Optional, Pattern, TextIO, Tuple, Type, TypeVar, Union, overload +from typing import Any, ClassVar, Generic, Optional, Pattern, TextIO, Type, TypeVar, Union, overload from typing_extensions import Literal -_SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, Optional[TracebackType]], Tuple[None, None, None]] +_SysExcInfoType = Union[tuple[Type[BaseException], BaseException, Optional[TracebackType]], tuple[None, None, None]] _ExcInfoType = Union[None, bool, _SysExcInfoType, BaseException] -_ArgsType = Union[Tuple[object, ...], Mapping[str, object]] +_ArgsType = Union[tuple[object, ...], Mapping[str, object]] _FilterType = Union[Filter, Callable[[LogRecord], int]] _Level = Union[int, str] _FormatStyle = Literal["%", "{", "$"] diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index 8ee9e7b339b5..68a61805614c 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -1,9 +1,10 @@ +from collections.abc import Sequence import sys from _typeshed import StrOrBytesPath, StrPath from collections.abc import Callable from configparser import RawConfigParser from threading import Thread -from typing import IO, Any, Pattern, Sequence +from typing import IO, Any, Pattern from . import _Level diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index e1da3024c4ac..84231d655d5a 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -1,6 +1,7 @@ +from collections.abc import Mapping, Sequence import io from _typeshed import ReadableBuffer, Self, StrOrBytesPath -from typing import IO, Any, Mapping, Sequence, TextIO, Union, overload +from typing import IO, Any, TextIO, Union, overload from typing_extensions import Literal, final _OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"] diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index ffd9c3005cec..3dbf606e2252 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence import email.message import sys from _typeshed import Self, StrOrBytesPath @@ -6,13 +7,13 @@ from typing import ( IO, Any, AnyStr, - Callable, + Generic, - Iterable, - Iterator, - Mapping, + + + Protocol, - Sequence, + Type, TypeVar, Union, diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index 9eaa771ed3d3..f3a96b180f62 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -1,6 +1,7 @@ -from typing import Dict, Mapping, Sequence, Union +from collections.abc import Mapping, Sequence +from typing import Union -_Cap = Dict[str, Union[str, int]] +_Cap = dict[str, Union[str, int]] def findmatch( caps: Mapping[str, list[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... diff --git a/stdlib/math.pyi b/stdlib/math.pyi index d5e6f99dfa68..a7d907fb6464 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterable import sys from _typeshed import SupportsTrunc -from typing import Iterable, SupportsFloat, Union, overload +from typing import SupportsFloat, Union, overload from typing_extensions import SupportsIndex if sys.version_info >= (3, 8): diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index 90c87d2cf385..e996498eb1a4 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -1,6 +1,7 @@ +from collections.abc import Sequence import sys from _typeshed import StrPath -from typing import IO, Sequence, Tuple +from typing import IO if sys.version_info >= (3, 8): def guess_type(url: StrPath, strict: bool = ...) -> tuple[str | None, str | None]: ... @@ -26,7 +27,7 @@ class MimeTypes: encodings_map: dict[str, str] types_map: tuple[dict[str, str], dict[str, str]] types_map_inv: tuple[dict[str, str], dict[str, str]] - def __init__(self, filenames: Tuple[str, ...] = ..., strict: bool = ...) -> None: ... + def __init__(self, filenames: tuple[str, ...] = ..., strict: bool = ...) -> None: ... def guess_extension(self, type: str, strict: bool = ...) -> str | None: ... def guess_type(self, url: str, strict: bool = ...) -> tuple[str | None, str | None]: ... def guess_all_extensions(self, type: str, strict: bool = ...) -> list[str]: ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index b79ab92f0c87..1a27d2d091bb 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -1,7 +1,8 @@ +from collections.abc import Iterable, Iterator, Sized import sys from _typeshed import ReadableBuffer from contextlib import AbstractContextManager -from typing import Iterable, Iterator, NoReturn, Sized, overload +from typing import NoReturn, overload ACCESS_DEFAULT: int ACCESS_READ: int diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index e77a108e9525..25d2fd1c66c4 100644 --- a/stdlib/modulefinder.pyi +++ b/stdlib/modulefinder.pyi @@ -1,6 +1,7 @@ +from collections.abc import Container, Iterable, Iterator, Sequence import sys from types import CodeType -from typing import IO, Any, Container, Iterable, Iterator, Sequence, Tuple +from typing import IO, Any LOAD_CONST: int # undocumented IMPORT_NAME: int # undocumented @@ -62,7 +63,7 @@ class ModuleFinder: def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented def import_module(self, partname: str, fqname: str, parent: Module) -> Module | None: ... # undocumented def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: tuple[str, str, str]) -> Module: ... # undocumented - def scan_opcodes(self, co: CodeType) -> Iterator[tuple[str, Tuple[Any, ...]]]: ... # undocumented + def scan_opcodes(self, co: CodeType) -> Iterator[tuple[str, tuple[Any, ...]]]: ... # undocumented def scan_code(self, co: CodeType, m: Module) -> None: ... # undocumented def load_package(self, fqname: str, pathname: str) -> Module: ... # undocumented def add_module(self, fqname: str) -> Module: ... # undocumented diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 4e1a7e6a7c02..b5f3d023619e 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -1,6 +1,7 @@ +from collections.abc import Container, Iterable, Sequence import sys from types import ModuleType -from typing import Any, Container, Iterable, Sequence, Tuple, Type +from typing import Any, Type from typing_extensions import Literal if sys.platform == "win32": @@ -37,7 +38,7 @@ if sys.platform == "win32": seqno: int | Type[_Unspecified] = ..., cond: str | Type[_Unspecified] = ..., ) -> None: ... - def add_data(db: _Database, table: str, values: Iterable[Tuple[Any, ...]]) -> None: ... + def add_data(db: _Database, table: str, values: Iterable[tuple[Any, ...]]) -> None: ... def add_stream(db: _Database, name: str, path: str) -> None: ... def init_database( name: str, schema: ModuleType, ProductName: str, ProductCode: str, ProductVersion: str, Manufacturer: str diff --git a/stdlib/msilib/sequence.pyi b/stdlib/msilib/sequence.pyi index 123d232886f7..87dff754009d 100644 --- a/stdlib/msilib/sequence.pyi +++ b/stdlib/msilib/sequence.pyi @@ -1,9 +1,9 @@ import sys -from typing import List, Optional, Tuple +from typing import Optional if sys.platform == "win32": - _SequenceType = List[Tuple[str, Optional[str], int]] + _SequenceType = list[tuple[str, Optional[str], int]] AdminExecuteSequence: _SequenceType AdminUISequence: _SequenceType diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index 56ea5c7c0b0b..da83213e5784 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -1,14 +1,15 @@ +from collections.abc import Iterable import socket import sys import types from _typeshed import Self -from typing import Any, Iterable, Tuple, Type, Union +from typing import Any, Type, Union if sys.version_info >= (3, 8): from typing import SupportsIndex # https://docs.python.org/3/library/multiprocessing.html#address-formats -_Address = Union[str, Tuple[str, int]] +_Address = Union[str, tuple[str, int]] class _ConnectionBase: if sys.version_info >= (3, 8): diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index b4d1c8404d8d..80e4403b7a5e 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable, Iterable, Mapping, Sequence import array import threading import weakref from queue import Queue as Queue -from typing import Any, Callable, Iterable, Mapping, Sequence +from typing import Any JoinableQueue = Queue Barrier = threading.Barrier diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index 4ef3d095911f..0f7a20693a85 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -1,11 +1,11 @@ from _typeshed import Self from queue import Queue from types import TracebackType -from typing import Any, Tuple, Type, Union +from typing import Any, Type, Union families: list[None] -_Address = Union[str, Tuple[str, int]] +_Address = Union[str, tuple[str, int]] class Connection(object): _in: Any diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 6d406bc4e4da..fafc2cafebd2 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -1,10 +1,11 @@ # NOTE: These are incomplete! +from collections.abc import Callable, Iterable, Mapping, Sequence import queue import sys import threading from contextlib import AbstractContextManager -from typing import Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Tuple, TypeVar +from typing import Any, AnyStr, Generic, TypeVar from .connection import Connection from .context import BaseContext @@ -52,7 +53,7 @@ class BaseProxy(object): manager_owned: bool = ..., ) -> None: ... def __deepcopy__(self, memo: Any | None) -> Any: ... - def _callmethod(self, methodname: str, args: Tuple[Any, ...] = ..., kwds: dict[Any, Any] = ...) -> None: ... + def _callmethod(self, methodname: str, args: tuple[Any, ...] = ..., kwds: dict[Any, Any] = ...) -> None: ... def _getvalue(self) -> Any: ... def __reduce__(self) -> tuple[Any, tuple[Any, Any, str, dict[Any, Any]]]: ... diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index 40fb8ef170ab..b58d871af769 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping import sys from _typeshed import Self from contextlib import AbstractContextManager -from typing import Any, Callable, Generic, Iterable, Iterator, List, Mapping, TypeVar +from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias @@ -32,7 +33,7 @@ class ApplyResult(Generic[_T]): # alias created during issue #17805 AsyncResult = ApplyResult -class MapResult(ApplyResult[List[_T]]): +class MapResult(ApplyResult[list[_T]]): if sys.version_info >= (3, 8): def __init__( self, diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index 32c22d19f6e5..eb3eb24e8e47 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -1,17 +1,18 @@ +from collections.abc import Callable, Mapping import sys -from typing import Any, Callable, Mapping, Tuple +from typing import Any class BaseProcess: name: str daemon: bool authkey: bytes - _identity: Tuple[int, ...] # undocumented + _identity: tuple[int, ...] # undocumented def __init__( self, group: None = ..., target: Callable[..., Any] | None = ..., name: str | None = ..., - args: Tuple[Any, ...] = ..., + args: tuple[Any, ...] = ..., kwargs: Mapping[str, Any] = ..., *, daemon: bool | None = ..., diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index 6ffc2542087a..74cf3dcb98d6 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable import sys -from typing import Any, Generic, Iterable, Tuple, TypeVar +from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias @@ -23,7 +24,7 @@ if sys.version_info >= (3, 8): def __init__(self, sequence: Iterable[_SLT] | None = ..., *, name: str | None = ...) -> None: ... def __getitem__(self, position: int) -> _SLT: ... def __setitem__(self, position: int, value: _SLT) -> None: ... - def __reduce__(self: _S) -> tuple[_S, Tuple[_SLT, ...]]: ... + def __reduce__(self: _S) -> tuple[_S, tuple[_SLT, ...]]: ... def __len__(self) -> int: ... @property def format(self) -> str: ... diff --git a/stdlib/multiprocessing/spawn.pyi b/stdlib/multiprocessing/spawn.pyi index 34c7322e0d46..689bd2575cc1 100644 --- a/stdlib/multiprocessing/spawn.pyi +++ b/stdlib/multiprocessing/spawn.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping, Sequence from types import ModuleType -from typing import Any, Mapping, Sequence +from typing import Any WINEXE: bool WINSERVICE: bool diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index c32c9aafe9a4..521846e5e06b 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable import sys import threading from contextlib import AbstractContextManager from multiprocessing.context import BaseContext -from typing import Any, Callable, Union +from typing import Any, Union _LockLike = Union[Lock, RLock] diff --git a/stdlib/netrc.pyi b/stdlib/netrc.pyi index b8eac307740a..7c1c2068aff6 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import Optional, Tuple +from typing import Optional class NetrcParseError(Exception): filename: str | None @@ -8,7 +8,7 @@ class NetrcParseError(Exception): def __init__(self, msg: str, filename: StrOrBytesPath | None = ..., lineno: int | None = ...) -> None: ... # (login, account, password) tuple -_NetrcTuple = Tuple[str, Optional[str], Optional[str]] +_NetrcTuple = tuple[str, Optional[str], Optional[str]] class netrc: hosts: dict[str, _NetrcTuple] diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 508b5f679bc3..abbc0388fb8c 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -1,9 +1,10 @@ +from collections.abc import Iterable import datetime import socket import ssl import sys from _typeshed import Self -from typing import IO, Any, Iterable, NamedTuple, Tuple, Union +from typing import IO, Any, NamedTuple, Union _File = Union[IO[bytes], bytes, str, None] @@ -72,7 +73,7 @@ class _NNTPBase: def xhdr(self, hdr: str, str: Any, *, file: _File = ...) -> tuple[str, _list[str]]: ... def xover(self, start: int, end: int, *, file: _File = ...) -> tuple[str, _list[tuple[int, dict[str, str]]]]: ... def over( - self, message_spec: None | str | _list[Any] | Tuple[Any, ...], *, file: _File = ... + self, message_spec: None | str | _list[Any] | tuple[Any, ...], *, file: _File = ... ) -> tuple[str, _list[tuple[int, dict[str, str]]]]: ... if sys.version_info < (3, 9): def xgtitle(self, group: str, *, file: _File = ...) -> tuple[str, _list[tuple[str, str]]]: ... diff --git a/stdlib/opcode.pyi b/stdlib/opcode.pyi index 982ddee43a63..3e2fb84b20d5 100644 --- a/stdlib/opcode.pyi +++ b/stdlib/opcode.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence import sys -from typing import Sequence + cmp_op: Sequence[str] hasconst: list[int] diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index b8ea9d2fff38..40eb47e7b9ce 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -1,6 +1,7 @@ -from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, Tuple, Type, overload +from collections.abc import Callable, Iterable, Mapping, Sequence +from typing import IO, Any, AnyStr, Type, overload -NO_DEFAULT: Tuple[str, ...] +NO_DEFAULT: tuple[str, ...] SUPPRESS_HELP: str SUPPRESS_USAGE: str @@ -72,14 +73,14 @@ class TitledHelpFormatter(HelpFormatter): def format_usage(self, usage: str) -> str: ... class Option: - ACTIONS: Tuple[str, ...] - ALWAYS_TYPED_ACTIONS: Tuple[str, ...] + ACTIONS: tuple[str, ...] + ALWAYS_TYPED_ACTIONS: tuple[str, ...] ATTRS: list[str] CHECK_METHODS: list[Callable[..., Any]] | None - CONST_ACTIONS: Tuple[str, ...] - STORE_ACTIONS: Tuple[str, ...] - TYPED_ACTIONS: Tuple[str, ...] - TYPES: Tuple[str, ...] + CONST_ACTIONS: tuple[str, ...] + STORE_ACTIONS: tuple[str, ...] + TYPED_ACTIONS: tuple[str, ...] + TYPES: tuple[str, ...] TYPE_CHECKER: dict[str, Callable[..., Any]] _long_opts: list[str] _short_opts: list[str] @@ -89,7 +90,7 @@ class Option: nargs: int type: Any callback: Callable[..., Any] | None - callback_args: Tuple[Any, ...] | None + callback_args: tuple[Any, ...] | None callback_kwargs: dict[str, Any] | None help: str | None metavar: str | None diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 5d4b6b246662..1d521050948c 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence import sys from _typeshed import ( FileDescriptorLike, @@ -20,17 +21,17 @@ from typing import ( Any, AnyStr, BinaryIO, - Callable, + Generic, - Iterable, - Iterator, - List, - Mapping, - MutableMapping, + + + + + NoReturn, Protocol, - Sequence, - Tuple, + + TypeVar, Union, overload, @@ -284,7 +285,7 @@ TMP_MAX: int # Undocumented, but used by tempfile # ----- os classes (structures) ----- @final -class stat_result(structseq[float], Tuple[int, int, int, int, int, int, int, float, float, float]): +class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, float, float, float]): # The constructor of this class takes an iterable of variable length (though it must be at least 10). # # However, this class behaves like a tuple of 10 elements, @@ -383,7 +384,7 @@ class DirEntry(Generic[AnyStr]): if sys.version_info >= (3, 7): @final - class statvfs_result(structseq[int], Tuple[int, int, int, int, int, int, int, int, int, int, int]): + class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int, int]): @property def f_bsize(self) -> int: ... @property @@ -409,7 +410,7 @@ if sys.version_info >= (3, 7): else: @final - class statvfs_result(structseq[int], Tuple[int, int, int, int, int, int, int, int, int, int]): + class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int]): @property def f_bsize(self) -> int: ... @property @@ -447,7 +448,7 @@ def getppid() -> int: ... def strerror(__code: int) -> str: ... def umask(__mask: int) -> int: ... @final -class uname_result(structseq[str], Tuple[str, str, str, str, str]): +class uname_result(structseq[str], tuple[str, str, str, str, str]): @property def sysname(self) -> str: ... @property @@ -639,7 +640,7 @@ if sys.platform != "win32": def writev(__fd: int, __buffers: Sequence[bytes]) -> int: ... @final -class terminal_size(structseq[int], Tuple[int, int]): +class terminal_size(structseq[int], tuple[int, int]): @property def columns(self) -> int: ... @property @@ -813,14 +814,14 @@ def execlpe(file: StrOrBytesPath, __arg0: StrOrBytesPath, *args: Any) -> NoRetur # in practice, and doing so would explode the number of combinations in this already long union. # All these combinations are necessary due to list being invariant. _ExecVArgs = Union[ - Tuple[StrOrBytesPath, ...], - List[bytes], - List[str], - List[PathLike[Any]], - List[Union[bytes, str]], - List[Union[bytes, PathLike[Any]]], - List[Union[str, PathLike[Any]]], - List[Union[bytes, str, PathLike[Any]]], + tuple[StrOrBytesPath, ...], + list[bytes], + list[str], + list[PathLike[Any]], + list[Union[bytes, str]], + list[Union[bytes, PathLike[Any]]], + list[Union[str, PathLike[Any]]], + list[Union[bytes, str, PathLike[Any]]], ] _ExecEnv = Union[Mapping[bytes, Union[bytes, str]], Mapping[str, Union[bytes, str]]] @@ -858,7 +859,7 @@ else: def system(command: StrOrBytesPath) -> int: ... @final -class times_result(structseq[float], Tuple[float, float, float, float, float]): +class times_result(structseq[float], tuple[float, float, float, float, float]): @property def user(self) -> float: ... @property @@ -884,7 +885,7 @@ else: def wait() -> tuple[int, int]: ... # Unix only if sys.platform != "darwin": @final - class waitid_result(structseq[int], Tuple[int, int, int, int, int]): + class waitid_result(structseq[int], tuple[int, int, int, int, int]): @property def si_pid(self) -> int: ... @property @@ -912,7 +913,7 @@ else: argv: _ExecVArgs, env: _ExecEnv, *, - file_actions: Sequence[Tuple[Any, ...]] | None = ..., + file_actions: Sequence[tuple[Any, ...]] | None = ..., setpgroup: int | None = ..., resetids: bool = ..., setsid: bool = ..., @@ -925,7 +926,7 @@ else: argv: _ExecVArgs, env: _ExecEnv, *, - file_actions: Sequence[Tuple[Any, ...]] | None = ..., + file_actions: Sequence[tuple[Any, ...]] | None = ..., setpgroup: int | None = ..., resetids: bool = ..., setsid: bool = ..., @@ -936,7 +937,7 @@ else: if sys.platform != "win32": @final - class sched_param(structseq[int], Tuple[int]): + class sched_param(structseq[int], tuple[int]): def __new__(cls, sched_priority: int) -> sched_param: ... @property def sched_priority(self) -> int: ... diff --git a/stdlib/parser.pyi b/stdlib/parser.pyi index aecf3244ca8d..06da2febfe9a 100644 --- a/stdlib/parser.pyi +++ b/stdlib/parser.pyi @@ -1,13 +1,14 @@ +from collections.abc import Sequence from _typeshed import StrOrBytesPath from types import CodeType -from typing import Any, Sequence, Tuple +from typing import Any def expr(source: str) -> STType: ... def suite(source: str) -> STType: ... def sequence2st(sequence: Sequence[Any]) -> STType: ... def tuple2st(sequence: Sequence[Any]) -> STType: ... def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... -def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any, ...]: ... +def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... def compilest(st: STType, filename: StrOrBytesPath = ...) -> CodeType: ... def isexpr(st: STType) -> bool: ... def issuite(st: STType) -> bool: ... @@ -19,4 +20,4 @@ class STType: def isexpr(self) -> bool: ... def issuite(self) -> bool: ... def tolist(self, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... - def totuple(self, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any, ...]: ... + def totuple(self, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 7d5f7ff2dba8..d34ec1300a66 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -1,3 +1,4 @@ +from collections.abc import Generator, Sequence import sys from _typeshed import ( OpenBinaryMode, @@ -11,7 +12,7 @@ from _typeshed import ( from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from os import PathLike, stat_result from types import TracebackType -from typing import IO, Any, BinaryIO, Generator, Sequence, Tuple, Type, TypeVar, overload +from typing import IO, Any, BinaryIO, Type, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -20,7 +21,7 @@ if sys.version_info >= (3, 9): _P = TypeVar("_P", bound=PurePath) class PurePath(PathLike[str]): - parts: Tuple[str, ...] + parts: tuple[str, ...] drive: str root: str anchor: str diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index 83bd32d76450..82f436a00963 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -1,10 +1,11 @@ +from collections.abc import Callable, Iterable, Mapping, Sequence import signal import sys 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, TypeVar +from typing import IO, Any, ClassVar, TypeVar _T = TypeVar("_T") diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index cef1ffe9eb9b..d5754420e8cd 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -1,11 +1,12 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping import sys -from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Tuple, Type, Union +from typing import Any, ClassVar, Optional, Protocol, Type, Union from typing_extensions import final HIGHEST_PROTOCOL: int DEFAULT_PROTOCOL: int -bytes_types: Tuple[Type[Any], ...] # undocumented +bytes_types: tuple[Type[Any], ...] # undocumented class _ReadableFileobj(Protocol): def read(self, __n: int) -> bytes: ... @@ -58,10 +59,10 @@ class UnpicklingError(PickleError): ... _reducedtype = Union[ str, - Tuple[Callable[..., Any], Tuple[Any, ...]], - Tuple[Callable[..., Any], Tuple[Any, ...], Any], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]]], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]], + tuple[Callable[..., Any], tuple[Any, ...]], + tuple[Callable[..., Any], tuple[Any, ...], Any], + tuple[Callable[..., Any], tuple[Any, ...], Any, Optional[Iterator[Any]]], + tuple[Callable[..., Any], tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]], ] class Pickler: diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 9fa51a3848ee..ea7f2e3e57ac 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -1,7 +1,8 @@ -from typing import IO, Any, Callable, Iterator, MutableMapping, Tuple, Type +from collections.abc import Callable, Iterator, MutableMapping +from typing import IO, Any, Type _Reader = Callable[[IO[bytes]], Any] -bytes_types: Tuple[Type[Any], ...] +bytes_types: tuple[Type[Any], ...] UP_TO_NEWLINE: int TAKEN_FROM_ARGUMENT1: int @@ -108,9 +109,9 @@ long4: ArgumentDescriptor class StackObject(object): name: str - obtype: Type[Any] | Tuple[Type[Any], ...] + obtype: Type[Any] | tuple[Type[Any], ...] doc: str - def __init__(self, name: str, obtype: Type[Any] | Tuple[Type[Any], ...], doc: str) -> None: ... + def __init__(self, name: str, obtype: Type[Any] | tuple[Type[Any], ...], doc: str) -> None: ... pyint: StackObject pylong: StackObject diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index e0f392fd91d8..9bf908d77a48 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Iterable, Iterator import sys from _typeshed import SupportsRead from importlib.abc import Loader, MetaPathFinder, PathEntryFinder -from typing import IO, Any, Callable, Iterable, Iterator, NamedTuple +from typing import IO, Any, NamedTuple class ModuleInfo(NamedTuple): module_finder: MetaPathFinder | PathEntryFinder diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index aa8cea4dc01a..765a7a5ea5f9 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -4,7 +4,7 @@ if sys.version_info < (3, 8): import os DEV_NULL = os.devnull -from typing import NamedTuple, Tuple +from typing import NamedTuple if sys.version_info >= (3, 8): def libc_ver(executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> tuple[str, str]: ... @@ -17,11 +17,11 @@ if sys.version_info < (3, 8): distname: str = ..., version: str = ..., id: str = ..., - supported_dists: Tuple[str, ...] = ..., + supported_dists: tuple[str, ...] = ..., full_distribution_name: bool = ..., ) -> tuple[str, str, str]: ... def dist( - distname: str = ..., version: str = ..., id: str = ..., supported_dists: Tuple[str, ...] = ... + distname: str = ..., version: str = ..., id: str = ..., supported_dists: tuple[str, ...] = ... ) -> tuple[str, str, str]: ... def win32_ver(release: str = ..., version: str = ..., csd: str = ..., ptype: str = ...) -> tuple[str, str, str, str]: ... diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index 07b6963746be..5a380ac9583a 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -1,7 +1,8 @@ +from collections.abc import Mapping, MutableMapping import sys from datetime import datetime from enum import Enum -from typing import IO, Any, Dict as _Dict, Mapping, MutableMapping, Tuple, Type +from typing import IO, Any, Type class PlistFormat(Enum): FMT_XML: int @@ -31,7 +32,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 +40,7 @@ def dump( skipkeys: bool = ..., ) -> None: ... def dumps( - value: Mapping[str, Any] | list[Any] | Tuple[Any, ...] | str | bool | float | bytes | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | datetime, *, fmt: PlistFormat = ..., skipkeys: bool = ..., @@ -53,7 +54,7 @@ if sys.version_info < (3, 9): def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... if sys.version_info < (3, 7): - class Dict(_Dict[str, Any]): + class Dict(dict[str, Any]): def __getattr__(self, attr: str) -> Any: ... def __setattr__(self, attr: str, value: Any) -> None: ... def __delattr__(self, attr: str) -> None: ... diff --git a/stdlib/poplib.pyi b/stdlib/poplib.pyi index 28fba4ce951f..028af412847b 100644 --- a/stdlib/poplib.pyi +++ b/stdlib/poplib.pyi @@ -1,8 +1,8 @@ import socket import ssl -from typing import Any, BinaryIO, List, Pattern, Tuple, overload +from typing import Any, BinaryIO, Pattern, overload -_LongResp = Tuple[bytes, List[bytes], int] +_LongResp = tuple[bytes, list[bytes], int] class error_proto(Exception): ... diff --git a/stdlib/posixpath.pyi b/stdlib/posixpath.pyi index ae3d0d5cc65f..55449b511e84 100644 --- a/stdlib/posixpath.pyi +++ b/stdlib/posixpath.pyi @@ -1,3 +1,4 @@ +from collections.abc import Sequence import sys from _typeshed import BytesPath, StrOrBytesPath, StrPath from genericpath import ( @@ -14,7 +15,7 @@ from genericpath import ( samestat as samestat, ) from os import PathLike -from typing import AnyStr, Sequence, overload +from typing import AnyStr, overload supports_unicode_filenames: bool # aliases (also in os) diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index cb0cbf7c9388..9a8a38a5e75c 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from _typeshed import StrOrBytesPath -from typing import Any, Callable, Tuple, TypeVar +from typing import Any, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( @@ -8,7 +9,7 @@ def runctx( _SelfT = TypeVar("_SelfT", bound=Profile) _T = TypeVar("_T") -_Label = Tuple[str, int, str] +_Label = tuple[str, int, str] class Profile: bias: int diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index e8256f9f98ab..f46ee70dfbc6 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -1,8 +1,9 @@ +from collections.abc import Iterable import sys from _typeshed import StrOrBytesPath from cProfile import Profile as _cProfile from profile import Profile -from typing import IO, Any, Iterable, Tuple, TypeVar, Union, overload +from typing import IO, Any, TypeVar, Union, overload _Selector = Union[str, float, int] _T = TypeVar("_T", bound=Stats) @@ -33,7 +34,7 @@ class Stats: def get_top_level_stats(self) -> None: ... def add(self: _T, *arg_list: None | str | Profile | _cProfile | _T) -> _T: ... def dump_stats(self, filename: StrOrBytesPath) -> None: ... - def get_sort_arg_defs(self) -> dict[str, tuple[Tuple[tuple[int, int], ...], str]]: ... + def get_sort_arg_defs(self) -> dict[str, tuple[tuple[tuple[int, int], ...], str]]: ... @overload def sort_stats(self: _T, field: int) -> _T: ... @overload diff --git a/stdlib/pty.pyi b/stdlib/pty.pyi index f943cebdb157..ecac08809945 100644 --- a/stdlib/pty.pyi +++ b/stdlib/pty.pyi @@ -1,4 +1,5 @@ -from typing import Callable, Iterable +from collections.abc import Callable, Iterable + _Reader = Callable[[int], bytes] diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index a16175879f67..3ed6111bde31 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -1,9 +1,9 @@ from _typeshed import structseq -from typing import Any, Tuple +from typing import Any from typing_extensions import final @final -class struct_passwd(structseq[Any], Tuple[str, str, int, int, str, str, str]): +class struct_passwd(structseq[Any], tuple[str, str, int, int, str, str, str]): @property def pw_name(self) -> str: ... @property diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index 10d106b4f511..aa6f45ecc8cb 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence import sys -from typing import Sequence + class Class: module: str diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index b60ef8f9bcb3..07c3e9600891 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -1,10 +1,11 @@ +from collections.abc import Callable, Container, Mapping, MutableMapping from _typeshed import SupportsWrite from reprlib import Repr from types import MethodType, ModuleType, TracebackType -from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, Optional, Tuple, Type +from typing import IO, Any, AnyStr, NoReturn, Optional, Type # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ -_Exc_Info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_Exc_Info = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] __author__: str __date__: str @@ -96,7 +97,7 @@ class HTMLDoc(Doc): methods: Mapping[str, str] = ..., ) -> str: ... def formattree( - self, tree: list[tuple[type, Tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ... + self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ... ) -> str: ... def docmodule(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... def docclass( @@ -143,7 +144,7 @@ class TextDoc(Doc): def indent(self, text: str, prefix: str = ...) -> str: ... def section(self, title: str, contents: str) -> str: ... def formattree( - self, tree: list[tuple[type, Tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ..., prefix: str = ... + self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ..., prefix: str = ... ) -> str: ... def docmodule(self, object: object, name: str | None = ..., mod: Any | None = ...) -> str: ... # type: ignore[override] def docclass(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... @@ -187,7 +188,7 @@ _list = list # "list" conflicts with method name class Helper: keywords: dict[str, str | tuple[str, str]] symbols: dict[str, str] - topics: dict[str, str | Tuple[str, ...]] + topics: dict[str, str | tuple[str, ...]] def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... input: IO[str] output: IO[str] diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 6a3d6cd56791..9e5940d4d944 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import pyexpat.errors as errors import pyexpat.model as model from _typeshed import SupportsRead -from typing import Any, Callable, Optional, Tuple +from typing import Any, Optional from typing_extensions import final EXPAT_VERSION: str # undocumented @@ -20,7 +21,7 @@ XML_PARAM_ENTITY_PARSING_NEVER: int XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int XML_PARAM_ENTITY_PARSING_ALWAYS: int -_Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] +_Model = tuple[int, int, Optional[str], tuple[Any, ...]] @final class XMLParserType(object): diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 4834dab6552e..ffa866ef9aa0 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -3,7 +3,7 @@ import sys from _typeshed import SupportsLenAndGetItem from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set as AbstractSet from fractions import Fraction -from typing import Any, ClassVar, NoReturn, Tuple, TypeVar +from typing import Any, ClassVar, NoReturn, TypeVar _T = TypeVar("_T") @@ -11,8 +11,8 @@ class Random(_random.Random): VERSION: ClassVar[int] def __init__(self, x: Any = ...) -> None: ... def seed(self, a: Any = ..., version: int = ...) -> None: ... - def getstate(self) -> Tuple[Any, ...]: ... - def setstate(self, state: Tuple[Any, ...]) -> None: ... + def getstate(self) -> tuple[Any, ...]: ... + def setstate(self, state: tuple[Any, ...]) -> None: ... def getrandbits(self, __k: int) -> int: ... def randrange(self, start: int, stop: int | None = ..., step: int = ...) -> int: ... def randint(self, a: int, b: int) -> int: ... diff --git a/stdlib/re.pyi b/stdlib/re.pyi index 01a60d170c50..a2489760e4f6 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Iterator import enum import sys from sre_constants import error as error -from typing import Any, AnyStr, Callable, Iterator, Union, overload +from typing import Any, AnyStr, Union, overload # ----- re variables and constants ----- if sys.version_info >= (3, 7): diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index 2de749b2c216..a68fbc7d7449 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Sequence from _typeshed import StrOrBytesPath -from typing import Callable, Optional, Sequence +from typing import Optional _CompleterT = Optional[Callable[[str, int], Optional[str]]] _CompDispT = Optional[Callable[[str, Sequence[str], int], None]] diff --git a/stdlib/reprlib.pyi b/stdlib/reprlib.pyi index 4d400554a4ff..8534dc0b2ba4 100644 --- a/stdlib/reprlib.pyi +++ b/stdlib/reprlib.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable from array import array from collections import deque -from typing import Any, Callable, Tuple +from typing import Any _ReprFunc = Callable[[Any], str] @@ -21,7 +22,7 @@ class Repr: def __init__(self) -> None: ... def repr(self, x: Any) -> str: ... def repr1(self, x: Any, level: int) -> str: ... - def repr_tuple(self, x: Tuple[Any, ...], level: int) -> str: ... + def repr_tuple(self, x: tuple[Any, ...], level: int) -> str: ... def repr_list(self, x: list[Any], level: int) -> str: ... def repr_array(self, x: array[Any], level: int) -> str: ... def repr_set(self, x: set[Any], level: int) -> str: ... diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index ff6f1d79e483..8e01bc717684 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import structseq -from typing import Tuple, overload +from typing import overload from typing_extensions import final RLIMIT_AS: int @@ -26,7 +26,7 @@ if sys.platform == "linux": RUSAGE_THREAD: int @final -class struct_rusage(structseq[float], Tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int]): +class struct_rusage(structseq[float], tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int]): @property def ru_utime(self) -> float: ... @property diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index cb96dc2bbf4a..13e470e6eb57 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,10 +1,11 @@ -from typing import Any, Callable, NamedTuple, Tuple +from collections.abc import Callable +from typing import Any, NamedTuple class Event(NamedTuple): time: float priority: Any action: Callable[..., Any] - argument: Tuple[Any, ...] + argument: tuple[Any, ...] kwargs: dict[str, Any] class scheduler: @@ -14,7 +15,7 @@ class scheduler: time: float, priority: Any, action: Callable[..., Any], - argument: Tuple[Any, ...] = ..., + argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ..., ) -> Event: ... def enter( @@ -22,7 +23,7 @@ class scheduler: delay: float, priority: Any, action: Callable[..., Any], - argument: Tuple[Any, ...] = ..., + argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ..., ) -> Event: ... def run(self, blocking: bool = ...) -> float | None: ... diff --git a/stdlib/select.pyi b/stdlib/select.pyi index 5650ed4c9a2c..73258991782d 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -1,7 +1,8 @@ +from collections.abc import Iterable import sys from _typeshed import FileDescriptorLike, Self from types import TracebackType -from typing import Any, Iterable, Type +from typing import Any, Type if sys.platform != "win32": PIPE_BUF: int diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index c3fe7ec47ace..af35783ef08d 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -1,7 +1,8 @@ +from collections.abc import Mapping import sys from _typeshed import FileDescriptor, FileDescriptorLike, Self from abc import ABCMeta, abstractmethod -from typing import Any, Mapping, NamedTuple +from typing import Any, NamedTuple _EventMask = int diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index dfe554b0a773..60c8f6e8ffda 100644 --- a/stdlib/shlex.pyi +++ b/stdlib/shlex.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable import sys -from typing import Any, Iterable, TextIO, TypeVar +from typing import Any, TextIO, TypeVar def split(s: str, comments: bool = ..., posix: bool = ...) -> list[str]: ... diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index f4c492caccaf..d28c5308e67c 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Iterable, Sequence import os import sys from _typeshed import StrOrBytesPath, StrPath, SupportsRead, SupportsWrite -from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, TypeVar, Union, overload +from typing import Any, AnyStr, NamedTuple, 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 diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index 6c93662fb326..1ed954ca647b 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable, Iterable import sys from _typeshed import structseq from enum import IntEnum from types import FrameType -from typing import Any, Callable, Iterable, Optional, Tuple, Union +from typing import Any, Optional, Union from typing_extensions import final NSIG: int @@ -132,7 +133,7 @@ else: SIGRTMAX: Signals SIGRTMIN: Signals @final - class struct_siginfo(structseq[int], Tuple[int, int, int, int, int, int, int]): + class struct_siginfo(structseq[int], tuple[int, int, int, int, int, int, int]): @property def si_signo(self) -> int: ... @property diff --git a/stdlib/site.pyi b/stdlib/site.pyi index a73d188a7e5c..787b61222af2 100644 --- a/stdlib/site.pyi +++ b/stdlib/site.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable from _typeshed import StrPath -from typing import Iterable + PREFIXES: list[str] ENABLE_USER_SITE: bool | None diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index ef0ada2c72de..e5401552caae 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -2,9 +2,9 @@ import asynchat import asyncore import socket from collections import defaultdict -from typing import Any, Tuple, Type +from typing import Any, Type -_Address = Tuple[str, int] # (host, port) +_Address = tuple[str, int] # (host, port) class SMTPChannel(asynchat.async_chat): COMMAND: int diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index a6f7d07ee7ec..9480a184b41d 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -1,15 +1,16 @@ +from collections.abc import Sequence import sys from _typeshed import Self from email.message import Message as _Message from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Dict, Pattern, Protocol, Sequence, Tuple, Type, Union, overload +from typing import Any, Pattern, Protocol, Type, Union, overload -_Reply = Tuple[int, bytes] -_SendErrs = Dict[str, _Reply] +_Reply = tuple[int, bytes] +_SendErrs = dict[str, _Reply] # Should match source_address for socket.create_connection -_SourceAddress = Tuple[Union[bytearray, bytes, str], int] +_SourceAddress = tuple[Union[bytearray, bytes, str], int] SMTP_PORT: int SMTP_SSL_PORT: int diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index c64408cfab07..ed46f8ea4362 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -1,12 +1,13 @@ +from collections.abc import Callable import sys import types from _typeshed import Self from socket import socket as _socket -from typing import Any, BinaryIO, Callable, ClassVar, Tuple, Type, TypeVar, Union +from typing import Any, BinaryIO, ClassVar, Type, TypeVar, Union _T = TypeVar("_T") -_RequestType = Union[_socket, Tuple[bytes, _socket]] -_AddressType = Union[Tuple[str, int], str] +_RequestType = Union[_socket, tuple[bytes, _socket]] +_AddressType = Union[tuple[str, int], str] class BaseServer: address_family: int diff --git a/stdlib/spwd.pyi b/stdlib/spwd.pyi index fc3d8ce90021..10f1ab1fb721 100644 --- a/stdlib/spwd.pyi +++ b/stdlib/spwd.pyi @@ -1,9 +1,9 @@ from _typeshed import structseq -from typing import Any, Tuple +from typing import Any from typing_extensions import final @final -class struct_spwd(structseq[Any], Tuple[str, str, int, int, int, int, int, int, int]): +class struct_spwd(structseq[Any], tuple[str, str, int, int, int, int, int, int, int]): @property def sp_namp(self) -> str: ... @property diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 0c52c1c2e6a1..b3949875ceee 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Generator, Iterable, Iterator import sys from _typeshed import Self, StrOrBytesPath from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, Type, TypeVar +from typing import Any, Protocol, Type, TypeVar _T = TypeVar("_T") diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index 598e61d6a8e0..ea6baa9a167b 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -1,7 +1,8 @@ +from collections.abc import Iterable import sys from sre_constants import * from sre_constants import _NamedIntConstant as _NIC, error as _Error -from typing import Any, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload +from typing import Any, Match, Optional, Pattern as _Pattern, Union, overload SPECIAL_CHARS: str REPEAT_CHARS: str @@ -37,12 +38,12 @@ if sys.version_info >= (3, 8): else: Pattern = _State -_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern] -_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern] -_OpInType = List[Tuple[_NIC, int]] -_OpBranchType = Tuple[None, List[SubPattern]] +_OpSubpatternType = tuple[Optional[int], int, int, SubPattern] +_OpGroupRefExistsType = tuple[int, SubPattern, SubPattern] +_OpInType = list[tuple[_NIC, int]] +_OpBranchType = tuple[None, list[SubPattern]] _AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType] -_CodeType = Tuple[_NIC, _AvType] +_CodeType = tuple[_NIC, _AvType] class SubPattern: data: list[_CodeType] @@ -85,8 +86,8 @@ class Tokenizer: def fix_flags(src: str | bytes, flags: int) -> int: ... -_TemplateType = Tuple[List[Tuple[int, int]], List[Optional[str]]] -_TemplateByteType = Tuple[List[Tuple[int, int]], List[Optional[bytes]]] +_TemplateType = tuple[list[tuple[int, int]], list[Optional[str]]] +_TemplateByteType = tuple[list[tuple[int, int]], list[Optional[bytes]]] if sys.version_info >= (3, 8): def parse(str: str, flags: int = ..., state: State | None = ...) -> SubPattern: ... @overload diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 628139634bac..a6751ddf6934 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -1,15 +1,16 @@ +from collections.abc import Callable, Iterable import enum import socket import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer -from typing import Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Optional, Set, Tuple, Type, Union, overload +from typing import Any, ClassVar, NamedTuple, Optional, Type, Union, overload from typing_extensions import Literal, TypedDict -_PCTRTT = Tuple[Tuple[str, str], ...] -_PCTRTTT = Tuple[_PCTRTT, ...] -_PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] +_PCTRTT = tuple[tuple[str, str], ...] +_PCTRTTT = tuple[_PCTRTT, ...] +_PeerCertRetDictType = dict[str, Union[str, _PCTRTTT, _PCTRTT]] _PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] -_EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] +_EnumRetType = list[tuple[bytes, str, Union[set[str], bool]]] _PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes] _SrvnmeCbType = Callable[[Union[SSLSocket, SSLObject], Optional[str], SSLSocket], Optional[int]] diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 908d6adaf45d..eebd972fe8cc 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -1,8 +1,9 @@ +from collections.abc import Hashable, Iterable, Sequence import sys from _typeshed import SupportsRichComparisonT from decimal import Decimal from fractions import Fraction -from typing import Any, Hashable, Iterable, NamedTuple, Sequence, SupportsFloat, Type, TypeVar, Union +from typing import Any, NamedTuple, SupportsFloat, Type, TypeVar, Union _T = TypeVar("_T") # Most functions in this module accept homogeneous collections of one of these types diff --git a/stdlib/string.pyi b/stdlib/string.pyi index 374d59959ac9..df9bbf706f08 100644 --- a/stdlib/string.pyi +++ b/stdlib/string.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterable, Mapping, Sequence import sys from re import RegexFlag -from typing import Any, Iterable, Mapping, Sequence +from typing import Any if sys.version_info >= (3, 8): from re import Pattern diff --git a/stdlib/struct.pyi b/stdlib/struct.pyi index d7c9cbef7dce..937131af9769 100644 --- a/stdlib/struct.pyi +++ b/stdlib/struct.pyi @@ -1,14 +1,15 @@ +from collections.abc import Iterator import sys from _typeshed import ReadableBuffer, WriteableBuffer -from typing import Any, Iterator, Tuple +from typing import Any class error(Exception): ... def pack(fmt: str | bytes, *v: Any) -> bytes: ... def pack_into(fmt: str | bytes, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... -def unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... -def unpack_from(__format: str | bytes, buffer: ReadableBuffer, offset: int = ...) -> Tuple[Any, ...]: ... -def iter_unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Iterator[Tuple[Any, ...]]: ... +def unpack(__format: str | bytes, __buffer: ReadableBuffer) -> tuple[Any, ...]: ... +def unpack_from(__format: str | bytes, buffer: ReadableBuffer, offset: int = ...) -> tuple[Any, ...]: ... +def iter_unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Iterator[tuple[Any, ...]]: ... def calcsize(__format: str | bytes) -> int: ... class Struct: @@ -20,6 +21,6 @@ class Struct: def __init__(self, format: str | bytes) -> None: ... def pack(self, *v: Any) -> bytes: ... def pack_into(self, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... - def unpack(self, __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... - def unpack_from(self, buffer: ReadableBuffer, offset: int = ...) -> Tuple[Any, ...]: ... - def iter_unpack(self, __buffer: ReadableBuffer) -> Iterator[Tuple[Any, ...]]: ... + def unpack(self, __buffer: ReadableBuffer) -> tuple[Any, ...]: ... + def unpack_from(self, buffer: ReadableBuffer, offset: int = ...) -> tuple[Any, ...]: ... + def iter_unpack(self, __buffer: ReadableBuffer) -> Iterator[tuple[Any, ...]]: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index fce517745ee6..910a8907fbb3 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Iterable, Mapping, Sequence import sys from _typeshed import Self, StrOrBytesPath from types import TracebackType -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Type, TypeVar, Union, overload +from typing import IO, Any, AnyStr, Generic, Type, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/symtable.pyi b/stdlib/symtable.pyi index 2f8961faa5f6..33a6f286502d 100644 --- a/stdlib/symtable.pyi +++ b/stdlib/symtable.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence import sys -from typing import Any, Sequence, Tuple +from typing import Any def symtable(code: str, filename: str, compile_type: str) -> SymbolTable: ... @@ -19,15 +20,15 @@ class SymbolTable(object): def get_children(self) -> list[SymbolTable]: ... class Function(SymbolTable): - def get_parameters(self) -> Tuple[str, ...]: ... - def get_locals(self) -> Tuple[str, ...]: ... - def get_globals(self) -> Tuple[str, ...]: ... - def get_frees(self) -> Tuple[str, ...]: ... + def get_parameters(self) -> tuple[str, ...]: ... + def get_locals(self) -> tuple[str, ...]: ... + def get_globals(self) -> tuple[str, ...]: ... + def get_frees(self) -> tuple[str, ...]: ... if sys.version_info >= (3, 8): - def get_nonlocals(self) -> Tuple[str, ...]: ... + def get_nonlocals(self) -> tuple[str, ...]: ... class Class(SymbolTable): - def get_methods(self) -> Tuple[str, ...]: ... + def get_methods(self) -> tuple[str, ...]: ... class Symbol(object): if sys.version_info >= (3, 8): diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index b5829884482a..7ff38a8eaa87 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -1,3 +1,4 @@ +from collections.abc import AsyncGenerator, Callable, Sequence import sys from builtins import object as _object from importlib.abc import PathEntryFinder @@ -6,14 +7,14 @@ from io import TextIOWrapper from types import FrameType, ModuleType, TracebackType from typing import ( Any, - AsyncGenerator, - Callable, + + NoReturn, Optional, Protocol, - Sequence, + TextIO, - Tuple, + Type, TypeVar, Union, @@ -24,8 +25,8 @@ from typing_extensions import Literal _T = TypeVar("_T") # The following type alias are stub-only and do not exist during runtime -_ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType] -_OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]] +_ExcInfo = tuple[Type[BaseException], BaseException, TracebackType] +_OptExcInfo = Union[_ExcInfo, tuple[None, None, None]] # Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder` class _MetaPathFinder(Protocol): @@ -146,7 +147,7 @@ class _int_info: bits_per_digit: int sizeof_digit: int -class _version_info(Tuple[int, int, int, str, int]): +class _version_info(tuple[int, int, int, str, int]): major: int minor: int micro: int @@ -192,7 +193,7 @@ _TraceFunc = Callable[[FrameType, str, Any], Optional[Callable[[FrameType, str, def gettrace() -> _TraceFunc | None: ... def settrace(tracefunc: _TraceFunc | None) -> None: ... -class _WinVersion(Tuple[int, int, int, int, str, int, int, int, int, Tuple[int, int, int]]): +class _WinVersion(tuple[int, int, int, int, str, int, int, int, int, tuple[int, int, int]]): major: int minor: int build: int @@ -234,12 +235,12 @@ if sys.version_info >= (3, 8): err_msg: str | None object: _object | None unraisablehook: Callable[[UnraisableHookArgs], Any] - def addaudithook(hook: Callable[[str, Tuple[Any, ...]], Any]) -> None: ... + def addaudithook(hook: Callable[[str, tuple[Any, ...]], Any]) -> None: ... def audit(__event: str, *args: Any) -> None: ... _AsyncgenHook = Optional[Callable[[AsyncGenerator[Any, Any]], None]] -class _asyncgen_hooks(Tuple[_AsyncgenHook, _AsyncgenHook]): +class _asyncgen_hooks(tuple[_AsyncgenHook, _AsyncgenHook]): firstiter: _AsyncgenHook finalizer: _AsyncgenHook diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index ff828d519912..17077144f6e9 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -1,12 +1,12 @@ -from typing import IO, Any, Tuple, overload +from typing import IO, Any, overload def get_config_var(name: str) -> str | None: ... @overload def get_config_vars() -> dict[str, Any]: ... @overload def get_config_vars(arg: str, *args: str) -> list[Any]: ... -def get_scheme_names() -> Tuple[str, ...]: ... -def get_path_names() -> Tuple[str, ...]: ... +def get_scheme_names() -> tuple[str, ...]: ... +def get_path_names() -> tuple[str, ...]: ... def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> str: ... def get_paths(scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> dict[str, str]: ... def get_python_version() -> str: ... diff --git a/stdlib/tabnanny.pyi b/stdlib/tabnanny.pyi index 4c7be83b0511..fb4103eeafd3 100644 --- a/stdlib/tabnanny.pyi +++ b/stdlib/tabnanny.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable from _typeshed import StrOrBytesPath -from typing import Iterable + verbose: int filename_only: int diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 0134316d8107..4931a6f0e679 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -5,7 +5,7 @@ from _typeshed import Self, StrOrBytesPath, StrPath from collections.abc import Callable, Iterable, Iterator, Mapping from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj from types import TracebackType -from typing import IO, Protocol, Tuple, Type, TypeVar, overload +from typing import IO, Protocol, Type, TypeVar, overload from typing_extensions import Literal _TF = TypeVar("_TF", bound=TarFile) @@ -62,10 +62,10 @@ DEFAULT_FORMAT: int # tarfile constants -SUPPORTED_TYPES: Tuple[bytes, ...] -REGULAR_TYPES: Tuple[bytes, ...] -GNU_TYPES: Tuple[bytes, ...] -PAX_FIELDS: Tuple[str, ...] +SUPPORTED_TYPES: tuple[bytes, ...] +REGULAR_TYPES: tuple[bytes, ...] +GNU_TYPES: tuple[bytes, ...] +PAX_FIELDS: tuple[str, ...] PAX_NUMBER_FIELDS: dict[str, type] PAX_NAME_FIELDS: set[str] diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index cf00856d9332..217229a61438 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Sequence import socket from _typeshed import Self -from typing import Any, Callable, Match, Pattern, Sequence +from typing import Any, Match, Pattern DEBUGLEVEL: int TELNET_PORT: int diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 119c111bc4e1..b7db68465093 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -1,8 +1,9 @@ +from collections.abc import Iterable, Iterator import os import sys from _typeshed import Self from types import TracebackType -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, Tuple, Type, Union, overload +from typing import IO, Any, AnyStr, Generic, Type, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -206,7 +207,7 @@ class SpooledTemporaryFile(IO[AnyStr]): @property def encoding(self) -> str: ... # undocumented @property - def newlines(self) -> str | Tuple[str, ...] | None: ... # undocumented + def newlines(self) -> str | tuple[str, ...] | None: ... # undocumented # bytes needs to go first, as default mode is to open as bytes if sys.version_info >= (3, 8): @overload diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index ed8522dccc51..c4da38417243 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -1,7 +1,7 @@ from _typeshed import FileDescriptorLike -from typing import Any, List, Union +from typing import Any, Union -_Attr = List[Union[int, List[Union[bytes, int]]]] +_Attr = list[Union[int, list[Union[bytes, int]]]] # TODO constants not really documented B0: int diff --git a/stdlib/textwrap.pyi b/stdlib/textwrap.pyi index 3b8fd5c0349a..b1c4198f9b22 100644 --- a/stdlib/textwrap.pyi +++ b/stdlib/textwrap.pyi @@ -1,4 +1,5 @@ -from typing import Callable, Pattern +from collections.abc import Callable +from typing import Pattern class TextWrapper: width: int diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index d6ac9f7251c2..f7432cf41900 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Mapping import sys from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, Mapping, Optional, Type, TypeVar +from typing import Any, Optional, Type, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] diff --git a/stdlib/time.pyi b/stdlib/time.pyi index fc929b112185..6e23b331d1c8 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -1,10 +1,10 @@ import sys from _typeshed import structseq from types import SimpleNamespace -from typing import Any, Tuple, Union +from typing import Any, Union from typing_extensions import final -_TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] +_TimeTuple = tuple[int, int, int, int, int, int, int, int, int] altzone: int daylight: int diff --git a/stdlib/timeit.pyi b/stdlib/timeit.pyi index d82dd80598dc..4638011afa36 100644 --- a/stdlib/timeit.pyi +++ b/stdlib/timeit.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Callable, Sequence, Union +from collections.abc import Callable, Sequence +from typing import IO, Any, Union _Timer = Callable[[], float] _Stmt = Union[str, Callable[[], Any]] diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index a32fe5554157..4bb0f39b1f55 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable, Mapping, Sequence import _tkinter import sys from _typeshed import StrOrBytesPath @@ -5,7 +6,7 @@ from enum import Enum from tkinter.constants import * from tkinter.font import _FontDescription from types import TracebackType -from typing import Any, Callable, Generic, List, Mapping, Optional, Protocol, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Generic, Optional, Protocol, Type, TypeVar, Union, overload from typing_extensions import Literal, TypedDict # Using anything from tkinter.font in this file means that 'import tkinter' @@ -42,18 +43,18 @@ _ButtonCommand = Union[str, Callable[[], Any]] # accepts string of tcl code, re _CanvasItemId = int _Color = str # typically '#rrggbb', '#rgb' or color names. _Compound = Literal["top", "left", "center", "right", "bottom", "none"] # -compound in manual page named 'options' -_Cursor = Union[str, Tuple[str], Tuple[str, str], Tuple[str, str, str], Tuple[str, str, str, str]] # manual page: Tk_GetCursor +_Cursor = Union[str, tuple[str], tuple[str, str], tuple[str, str, str], tuple[str, str, str, str]] # manual page: Tk_GetCursor _EntryValidateCommand = Union[ - Callable[[], bool], str, List[str], Tuple[str, ...] + Callable[[], bool], str, list[str], tuple[str, ...] ] # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P'] _GridIndex = Union[int, str, Literal["all"]] _ImageSpec = Union[_Image, str] # str can be from e.g. tkinter.image_names() _Padding = Union[ _ScreenUnits, - Tuple[_ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], ] _Relief = Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] # manual page: Tk_GetRelief _ScreenUnits = Union[str, float] # Often the right type instead of int. Manual page: Tk_GetPixels @@ -137,7 +138,7 @@ class Variable: def get(self) -> Any: ... def trace_add(self, mode: _TraceMode, callback: Callable[[str, str, str], Any]) -> str: ... def trace_remove(self, mode: _TraceMode, cbname: str) -> None: ... - def trace_info(self) -> list[tuple[Tuple[_TraceMode, ...], str]]: ... + def trace_info(self) -> list[tuple[tuple[_TraceMode, ...], str]]: ... def trace_variable(self, mode, callback): ... # deprecated def trace_vdelete(self, mode, cbname): ... # deprecated def trace_vinfo(self): ... # deprecated @@ -249,7 +250,7 @@ class Misc: def winfo_geometry(self) -> str: ... def winfo_height(self) -> int: ... def winfo_id(self) -> int: ... - def winfo_interps(self, displayof: Literal[0] | Misc | None = ...) -> Tuple[str, ...]: ... + def winfo_interps(self, displayof: Literal[0] | Misc | None = ...) -> tuple[str, ...]: ... def winfo_ismapped(self) -> bool: ... def winfo_manager(self) -> str: ... def winfo_name(self) -> str: ... @@ -420,9 +421,9 @@ class Misc: x: _ScreenUnits = ..., y: _ScreenUnits = ..., ) -> None: ... - def event_info(self, virtual: str | None = ...) -> Tuple[str, ...]: ... - def image_names(self) -> Tuple[str, ...]: ... - def image_types(self) -> Tuple[str, ...]: ... + def event_info(self, virtual: str | None = ...) -> tuple[str, ...]: ... + def image_names(self) -> tuple[str, ...]: ... + def image_types(self) -> tuple[str, ...]: ... # See #4363 and #4891 def __setitem__(self, key: str, value: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... @@ -468,7 +469,7 @@ class Wm: ) -> tuple[int, int, int, int] | None: ... aspect = wm_aspect @overload - def wm_attributes(self) -> Tuple[Any, ...]: ... + def wm_attributes(self) -> tuple[Any, ...]: ... @overload def wm_attributes(self, __option: str) -> Any: ... @overload @@ -479,7 +480,7 @@ class Wm: @overload def wm_colormapwindows(self) -> list[Misc]: ... @overload - def wm_colormapwindows(self, __wlist: list[Misc] | Tuple[Misc, ...]) -> None: ... + def wm_colormapwindows(self, __wlist: list[Misc] | tuple[Misc, ...]) -> None: ... @overload def wm_colormapwindows(self, __first_wlist_item: Misc, *other_wlist_items: Misc) -> None: ... colormapwindows = wm_colormapwindows @@ -543,7 +544,7 @@ class Wm: @overload def wm_protocol(self, name: str, func: None = ...) -> str: ... @overload - def wm_protocol(self, name: None = ..., func: None = ...) -> Tuple[str, ...]: ... + def wm_protocol(self, name: None = ..., func: None = ...) -> tuple[str, ...]: ... protocol = wm_protocol @overload def wm_resizable(self, width: None = ..., height: None = ...) -> tuple[bool, bool]: ... @@ -1043,17 +1044,17 @@ class Canvas(Widget, XView, YView): def addtag_overlapping(self, newtag: str, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: _ScreenUnits) -> None: ... def addtag_withtag(self, newtag: str, tagOrId: str | _CanvasItemId) -> None: ... def find(self, *args): ... # internal method - def find_above(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... - def find_all(self) -> Tuple[_CanvasItemId, ...]: ... - def find_below(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... + def find_above(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... + def find_all(self) -> tuple[_CanvasItemId, ...]: ... + def find_below(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... def find_closest( self, x: _ScreenUnits, y: _ScreenUnits, halo: _ScreenUnits | None = ..., start: str | _CanvasItemId | None = ... - ) -> Tuple[_CanvasItemId, ...]: ... + ) -> tuple[_CanvasItemId, ...]: ... def find_enclosed( self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: _ScreenUnits - ) -> Tuple[_CanvasItemId, ...]: ... - def find_overlapping(self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: float) -> Tuple[_CanvasItemId, ...]: ... - def find_withtag(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... + ) -> tuple[_CanvasItemId, ...]: ... + def find_overlapping(self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: float) -> tuple[_CanvasItemId, ...]: ... + def find_withtag(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... # Incompatible with Misc.bbox(), tkinter violates LSP def bbox(self, *args: str | _CanvasItemId) -> tuple[int, int, int, int]: ... # type: ignore[override] @overload @@ -1076,7 +1077,7 @@ class Canvas(Widget, XView, YView): @overload def coords(self) -> list[float]: ... @overload - def coords(self, __args: list[int] | list[float] | Tuple[float, ...]) -> None: ... + def coords(self, __args: list[int] | list[float] | tuple[float, ...]) -> None: ... @overload def coords(self, __x1: float, __y1: float, *args: float) -> None: ... # create_foo() methods accept coords as a list, a tuple, or as separate arguments. @@ -1092,16 +1093,16 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., arrow: Literal["first", "last", "both"] = ..., arrowshape: tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledstipple: _Bitmap = ..., disabledwidth: _ScreenUnits = ..., @@ -1112,7 +1113,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1120,16 +1121,16 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., arrow: Literal["first", "last", "both"] = ..., arrowshape: tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledstipple: _Bitmap = ..., disabledwidth: _ScreenUnits = ..., @@ -1140,7 +1141,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1151,15 +1152,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1172,7 +1173,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1180,15 +1181,15 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1201,7 +1202,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1212,15 +1213,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *xy_pairs: float, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1236,23 +1237,23 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload def create_polygon( self, - __coords: Tuple[float, ...] | list[int] | list[float], + __coords: tuple[float, ...] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1268,7 +1269,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1279,15 +1280,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1300,7 +1301,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1308,15 +1309,15 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1329,7 +1330,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1349,7 +1350,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1369,7 +1370,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1382,7 +1383,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1394,7 +1395,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1405,7 +1406,7 @@ class Canvas(Widget, XView, YView): @overload def dtag(self, __id: _CanvasItemId, __tag_to_delete: str) -> None: ... def focus(self, *args): ... - def gettags(self, __tagOrId: str | _CanvasItemId) -> Tuple[str, ...]: ... + def gettags(self, __tagOrId: str | _CanvasItemId) -> tuple[str, ...]: ... def icursor(self, *args): ... def index(self, *args): ... def insert(self, *args): ... @@ -2650,7 +2651,7 @@ class Text(Widget, XView, YView): startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., # Literal inside Tuple doesn't actually work - tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., + tabs: _ScreenUnits | str | tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2701,7 +2702,7 @@ class Text(Widget, XView, YView): spacing3: _ScreenUnits = ..., startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., - tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., + tabs: _ScreenUnits | str | tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2780,20 +2781,20 @@ class Text(Widget, XView, YView): def image_create(self, index, cnf=..., **kw): ... def image_names(self): ... def index(self, index: _TextIndex) -> str: ... - def insert(self, index: _TextIndex, chars: str, *args: str | list[str] | Tuple[str, ...]) -> None: ... + def insert(self, index: _TextIndex, chars: str, *args: str | list[str] | tuple[str, ...]) -> None: ... @overload def mark_gravity(self, markName: str, direction: None = ...) -> Literal["left", "right"]: ... @overload def mark_gravity(self, markName: str, direction: Literal["left", "right"]) -> None: ... # actually returns empty string - def mark_names(self) -> Tuple[str, ...]: ... + def mark_names(self) -> tuple[str, ...]: ... def mark_set(self, markName: str, index: _TextIndex) -> None: ... def mark_unset(self, *markNames: str) -> None: ... def mark_next(self, index: _TextIndex) -> str | None: ... def mark_previous(self, index: _TextIndex) -> str | None: ... # **kw of peer_create is same as the kwargs of Text.__init__ def peer_create(self, newPathName: str | Text, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def peer_names(self) -> Tuple[_tkinter.Tcl_Obj, ...]: ... - def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | list[str] | Tuple[str, ...]) -> None: ... + def peer_names(self) -> tuple[_tkinter.Tcl_Obj, ...]: ... + def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | list[str] | tuple[str, ...]) -> None: ... def scan_mark(self, x: int, y: int) -> None: ... def scan_dragto(self, x: int, y: int) -> None: ... def search( @@ -2865,11 +2866,11 @@ class Text(Widget, XView, YView): tag_config = tag_configure def tag_delete(self, __first_tag_name: str, *tagNames: str) -> None: ... # error if no tag names given def tag_lower(self, tagName: str, belowThis: str | None = ...) -> None: ... - def tag_names(self, index: _TextIndex | None = ...) -> Tuple[str, ...]: ... + def tag_names(self, index: _TextIndex | None = ...) -> tuple[str, ...]: ... def tag_nextrange(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> tuple[str, str] | tuple[()]: ... def tag_prevrange(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> tuple[str, str] | tuple[()]: ... def tag_raise(self, tagName: str, aboveThis: str | None = ...) -> None: ... - def tag_ranges(self, tagName: str) -> Tuple[_tkinter.Tcl_Obj, ...]: ... + def tag_ranges(self, tagName: str) -> tuple[_tkinter.Tcl_Obj, ...]: ... # tag_remove and tag_delete are different def tag_remove(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... # TODO: window_* methods @@ -2959,10 +2960,10 @@ class PhotoImage(Image): str | list[str] | list[list[_Color]] - | list[Tuple[_Color, ...]] - | Tuple[str, ...] - | Tuple[list[_Color], ...] - | Tuple[Tuple[_Color, ...], ...] + | list[tuple[_Color, ...]] + | tuple[str, ...] + | tuple[list[_Color], ...] + | tuple[tuple[_Color, ...], ...] ), to: tuple[int, int] | None = ..., ) -> None: ... @@ -2986,8 +2987,8 @@ class BitmapImage(Image): maskfile: StrOrBytesPath = ..., ) -> None: ... -def image_names() -> Tuple[str, ...]: ... -def image_types() -> Tuple[str, ...]: ... +def image_names() -> tuple[str, ...]: ... +def image_types() -> tuple[str, ...]: ... class Spinbox(Widget, XView): def __init__( @@ -3006,7 +3007,7 @@ class Spinbox(Widget, XView): buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., # percent substitutions don't seem to be supported, it's similar to Entry's validation stuff - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3043,7 +3044,7 @@ class Spinbox(Widget, XView): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., vcmd: _EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., @@ -3063,7 +3064,7 @@ class Spinbox(Widget, XView): buttoncursor: _Cursor = ..., buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3099,7 +3100,7 @@ class Spinbox(Widget, XView): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., vcmd: _EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., @@ -3119,7 +3120,7 @@ class Spinbox(Widget, XView): def scan(self, *args): ... def scan_mark(self, x): ... def scan_dragto(self, x): ... - def selection(self, *args: Any) -> Tuple[int, ...]: ... + def selection(self, *args: Any) -> tuple[int, ...]: ... def selection_adjust(self, index): ... def selection_clear(self): ... def selection_element(self, element: Any | None = ...): ... diff --git a/stdlib/tkinter/commondialog.pyi b/stdlib/tkinter/commondialog.pyi index aee58111c73f..8f100751ec28 100644 --- a/stdlib/tkinter/commondialog.pyi +++ b/stdlib/tkinter/commondialog.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar, Mapping +from collections.abc import Mapping +from typing import Any, ClassVar class Dialog: command: ClassVar[str | None] diff --git a/stdlib/tkinter/dialog.pyi b/stdlib/tkinter/dialog.pyi index bc927e1f24ac..20c25af78a39 100644 --- a/stdlib/tkinter/dialog.pyi +++ b/stdlib/tkinter/dialog.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping from tkinter import Widget -from typing import Any, Mapping +from typing import Any DIALOG_ICON: str diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index 0fc7d6e8a3bc..d6b38693f07a 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterable from _typeshed import StrOrBytesPath from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog -from typing import IO, Any, ClassVar, Iterable, Tuple +from typing import IO, Any, ClassVar from typing_extensions import Literal dialogstates: dict[Any, tuple[Any, Any]] @@ -64,7 +65,7 @@ def asksaveasfilename( *, confirmoverwrite: bool | None = ..., defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -74,7 +75,7 @@ def asksaveasfilename( def askopenfilename( *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -84,13 +85,13 @@ def askopenfilename( def askopenfilenames( *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> Literal[""] | Tuple[str, ...]: ... +) -> Literal[""] | tuple[str, ...]: ... def askdirectory( *, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = ..., parent: Misc | None = ..., title: str | None = ... ) -> str: ... # can be empty string @@ -101,7 +102,7 @@ def asksaveasfile( *, confirmoverwrite: bool | None = ..., defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -112,7 +113,7 @@ def askopenfile( mode: str = ..., *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -123,11 +124,11 @@ def askopenfiles( mode: str = ..., *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> Tuple[IO[Any], ...]: ... # can be empty tuple +) -> tuple[IO[Any], ...]: ... # can be empty tuple def test() -> None: ... diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index fccc0fbf1f0a..211e8ec9a0be 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,7 +1,7 @@ import _tkinter import sys import tkinter -from typing import Any, List, Tuple, Union, overload +from typing import Any, Union, overload from typing_extensions import Literal, TypedDict NORMAL: Literal["normal"] @@ -15,8 +15,8 @@ _FontDescription = Union[ # A font object constructed in Python Font, # ("Helvetica", 12, BOLD) - List[Any], - Tuple[Any, ...], + list[Any], + tuple[Any, ...], # A font object constructed in Tcl _tkinter.Tcl_Obj, ] @@ -102,8 +102,8 @@ class Font: def metrics(self, *, displayof: tkinter.Misc | None = ...) -> _MetricsDict: ... def measure(self, text: str, displayof: tkinter.Misc | None = ...) -> int: ... -def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> Tuple[str, ...]: ... -def names(root: tkinter.Misc | None = ...) -> Tuple[str, ...]: ... +def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> tuple[str, ...]: ... +def names(root: tkinter.Misc | None = ...) -> tuple[str, ...]: ... if sys.version_info >= (3, 10): def nametofont(name: str, root: tkinter.Misc | None = ...) -> Font: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 4914234c4eed..6842ab7b1108 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -1,5 +1,5 @@ import tkinter -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal WINDOW: Literal["window"] @@ -194,7 +194,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def indicator_size(self, entry: str) -> int: ... def info_anchor(self) -> str: ... def info_bbox(self, entry: str) -> tuple[int, int, int, int]: ... - def info_children(self, entry: str | None = ...) -> Tuple[str, ...]: ... + def info_children(self, entry: str | None = ...) -> tuple[str, ...]: ... def info_data(self, entry: str) -> Any: ... def info_dragsite(self) -> str: ... def info_dropsite(self) -> str: ... @@ -203,7 +203,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def info_next(self, entry: str) -> str: ... def info_parent(self, entry: str) -> str: ... def info_prev(self, entry: str) -> str: ... - def info_selection(self) -> Tuple[str, ...]: ... + def info_selection(self) -> tuple[str, ...]: ... def item_cget(self, entry: str, col: int, opt: Any) -> Any: ... def item_configure(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> Any | None: ... def item_create(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... @@ -224,7 +224,7 @@ class CheckList(TixWidget): def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... def open(self, entrypath: str) -> None: ... - def getselection(self, mode: str = ...) -> Tuple[str, ...]: ... + def getselection(self, mode: str = ...) -> tuple[str, ...]: ... def getstatus(self, entrypath: str) -> str: ... def setstatus(self, entrypath: str, mode: str = ...) -> None: ... @@ -253,7 +253,7 @@ class TList(TixWidget, tkinter.XView, tkinter.YView): def info_down(self, index: int) -> int: ... def info_left(self, index: int) -> int: ... def info_right(self, index: int) -> int: ... - def info_selection(self) -> Tuple[int, ...]: ... + def info_selection(self) -> tuple[int, ...]: ... def info_size(self) -> int: ... def info_up(self, index: int) -> int: ... def nearest(self, x: int, y: int) -> int: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 3ef348d91ab2..3f6d753dba55 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable import _tkinter import sys import tkinter from tkinter.font import _FontDescription -from typing import Any, Callable, Tuple, Union, overload +from typing import Any, Union, overload from typing_extensions import Literal, TypedDict def tclobjs_to_py(adict): ... @@ -24,7 +25,7 @@ class Style: def element_options(self, elementname): ... def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...): ... def theme_settings(self, themename, settings): ... - def theme_names(self) -> Tuple[str, ...]: ... + def theme_names(self) -> tuple[str, ...]: ... @overload def theme_use(self, themename: str) -> None: ... @overload @@ -234,7 +235,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented validatecommand: tkinter._EntryValidateCommand = ..., # undocumented - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented ) -> None: ... @@ -259,7 +260,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -287,7 +288,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -828,7 +829,7 @@ if sys.version_info >= (3, 7): *, background: tkinter._Color = ..., # undocumented class_: str = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., # undocumented font: _FontDescription = ..., # undocumented @@ -847,7 +848,7 @@ if sys.version_info >= (3, 7): to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., # undocumented wrap: bool = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -858,7 +859,7 @@ if sys.version_info >= (3, 7): cnf: dict[str, Any] | None = ..., *, background: tkinter._Color = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., @@ -876,7 +877,7 @@ if sys.version_info >= (3, 7): to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -922,9 +923,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): master: tkinter.Misc | None = ..., *, class_: str = ..., - columns: str | list[str] | Tuple[str, ...] = ..., + columns: str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ..., + displaycolumns: str | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] | Literal["#all"] = ..., height: int = ..., name: str = ..., padding: tkinter._Padding = ..., @@ -933,7 +934,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): # # 'tree headings' is same as ['tree', 'headings'], and I wouldn't be # surprised if someone is using it. - show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ..., + show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -944,13 +945,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): self, cnf: dict[str, Any] | None = ..., *, - columns: str | list[str] | Tuple[str, ...] = ..., + columns: str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ..., + displaycolumns: str | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] | Literal["#all"] = ..., height: int = ..., padding: tkinter._Padding = ..., selectmode: Literal["extended", "browse", "none"] = ..., - show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ..., + show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -960,7 +961,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, item, column: _TreeviewColumnId | None = ...) -> tuple[int, int, int, int] | Literal[""]: ... # type: ignore[override] - def get_children(self, item: str | None = ...) -> Tuple[str, ...]: ... + def get_children(self, item: str | None = ...) -> tuple[str, ...]: ... def set_children(self, item: str, *newchildren: str) -> None: ... @overload def column(self, column: _TreeviewColumnId, option: Literal["width", "minwidth"]) -> int: ... @@ -1027,20 +1028,20 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): id: str = ..., # same as iid text: str = ..., image: tkinter._ImageSpec = ..., - values: list[Any] | Tuple[Any, ...] = ..., + values: list[Any] | tuple[Any, ...] = ..., open: bool = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., ) -> str: ... @overload def item(self, item: str, option: Literal["text"]) -> str: ... @overload def item(self, item: str, option: Literal["image"]) -> tuple[str] | Literal[""]: ... @overload - def item(self, item: str, option: Literal["values"]) -> Tuple[Any, ...] | Literal[""]: ... + def item(self, item: str, option: Literal["values"]) -> tuple[Any, ...] | Literal[""]: ... @overload def item(self, item: str, option: Literal["open"]) -> bool: ... # actually 0 or 1 @overload - def item(self, item: str, option: Literal["tags"]) -> Tuple[str, ...] | Literal[""]: ... + def item(self, item: str, option: Literal["tags"]) -> tuple[str, ...] | Literal[""]: ... @overload def item(self, item: str, option: str) -> Any: ... @overload @@ -1051,9 +1052,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): *, text: str = ..., image: tkinter._ImageSpec = ..., - values: list[Any] | Tuple[Any, ...] | Literal[""] = ..., + values: list[Any] | tuple[Any, ...] | Literal[""] = ..., open: bool = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., ) -> _TreeviewItemDict | None: ... def move(self, item: str, parent: str, index: int) -> None: ... reattach = move @@ -1062,13 +1063,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def prev(self, item: str) -> str: ... # returning empty string means first item def see(self, item: str) -> None: ... if sys.version_info >= (3, 8): - def selection(self) -> Tuple[str, ...]: ... + def selection(self) -> tuple[str, ...]: ... else: - def selection(self, selop: Any | None = ..., items: Any | None = ...) -> Tuple[str, ...]: ... - def selection_set(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_add(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_remove(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_toggle(self, items: str | list[str] | Tuple[str, ...]) -> None: ... + def selection(self, selop: Any | None = ..., items: Any | None = ...) -> tuple[str, ...]: ... + def selection_set(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_add(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_remove(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_toggle(self, items: str | list[str] | tuple[str, ...]) -> None: ... @overload def set(self, item: str, column: None = ..., value: None = ...) -> dict[str, Any]: ... @overload @@ -1104,7 +1105,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): image: tkinter._ImageSpec = ..., ) -> _TreeviewTagDict | Any: ... # can be None but annoying to check @overload - def tag_has(self, tagname: str, item: None = ...) -> Tuple[str, ...]: ... + def tag_has(self, tagname: str, item: None = ...) -> tuple[str, ...]: ... @overload def tag_has(self, tagname: str, item: str) -> bool: ... diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index a8294adb653f..fa7f92f1a0d5 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable, Generator, Iterable, Sequence import sys from _typeshed import StrOrBytesPath from builtins import open as _builtin_open from token import * # noqa: F403 -from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, TextIO, Tuple, Union +from typing import Any, NamedTuple, Pattern, TextIO, Union if sys.version_info < (3, 7): COMMENT: int @@ -12,7 +13,7 @@ if sys.version_info < (3, 7): cookie_re: Pattern[str] blank_re: Pattern[bytes] -_Position = Tuple[int, int] +_Position = tuple[int, int] class _TokenInfo(NamedTuple): type: int diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index bab75c9ada8d..a88b0f75ffa6 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -1,13 +1,14 @@ +from collections.abc import Callable, Mapping, Sequence import sys import types from _typeshed import StrPath -from typing import Any, Callable, Mapping, Optional, Sequence, Tuple, TypeVar +from typing import Any, Optional, TypeVar from typing_extensions import ParamSpec _T = TypeVar("_T") _P = ParamSpec("_P") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] -_fileModuleFunction = Tuple[str, Optional[str], str] +_fileModuleFunction = tuple[str, Optional[str], str] class CoverageResults: def __init__( diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index f09a3cc70ade..5123336ad142 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -1,9 +1,10 @@ +from collections.abc import Generator, Iterable, Iterator, Mapping import sys from _typeshed import SupportsWrite from types import FrameType, TracebackType -from typing import IO, Any, Generator, Iterable, Iterator, List, Mapping, Optional, Tuple, Type, overload +from typing import IO, Any, Optional, Type, overload -_PT = Tuple[str, int, str, Optional[str]] +_PT = tuple[str, int, str, Optional[str]] def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | None = ...) -> None: ... @@ -146,7 +147,7 @@ class FrameSummary(Iterable[Any]): def __getitem__(self, i: int) -> Any: ... def __iter__(self) -> Iterator[Any]: ... -class StackSummary(List[FrameSummary]): +class StackSummary(list[FrameSummary]): @classmethod def extract( cls, diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 4666bd1565a0..6e0599ac2688 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,6 +1,7 @@ +from collections.abc import Sequence import sys from _tracemalloc import * -from typing import Optional, Sequence, Tuple, Union, overload +from typing import Optional, Union, overload from typing_extensions import SupportsIndex def get_object_traceback(obj: object) -> Traceback | None: ... @@ -35,7 +36,7 @@ class StatisticDiff: traceback: Traceback def __init__(self, traceback: Traceback, size: int, size_diff: int, count: int, count_diff: int) -> None: ... -_FrameTupleT = Tuple[str, int] +_FrameTupleT = tuple[str, int] class Frame: filename: str @@ -43,9 +44,9 @@ class Frame: def __init__(self, frame: _FrameTupleT) -> None: ... if sys.version_info >= (3, 9): - _TraceTupleT = Union[Tuple[int, int, Sequence[_FrameTupleT], Optional[int]], Tuple[int, int, Sequence[_FrameTupleT]]] + _TraceTupleT = Union[tuple[int, int, Sequence[_FrameTupleT], Optional[int]], tuple[int, int, Sequence[_FrameTupleT]]] else: - _TraceTupleT = Tuple[int, int, Sequence[_FrameTupleT]] + _TraceTupleT = tuple[int, int, Sequence[_FrameTupleT]] class Trace: domain: int diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 8542fc8bfa24..088d65049ed3 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -1,22 +1,23 @@ +from collections.abc import Callable, Sequence from tkinter import Canvas, Frame, PhotoImage -from typing import Any, Callable, ClassVar, Dict, Sequence, Tuple, TypeVar, Union, overload +from typing import Any, ClassVar, TypeVar, Union, overload # Note: '_Color' is the alias we use for arguments and _AnyColor is the # alias we use for return types. Really, these two aliases should be the # same, but as per the "no union returns" typeshed policy, we'll return # Any instead. -_Color = Union[str, Tuple[float, float, float]] +_Color = Union[str, tuple[float, float, float]] _AnyColor = Any # TODO: Replace this with a TypedDict once it becomes standardized. -_PenState = Dict[str, Any] +_PenState = dict[str, Any] _Speed = Union[str, float] -_PolygonCoords = Sequence[Tuple[float, float]] +_PolygonCoords = Sequence[tuple[float, float]] # TODO: Type this more accurately # Vec2D is actually a custom subclass of 'tuple'. -Vec2D = Tuple[float, float] +Vec2D = tuple[float, float] class ScrolledCanvas(Frame): ... @@ -251,7 +252,7 @@ class RawTurtle(TPen, TNavigator): # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp(self) -> Any: ... - def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... + def clearstamp(self, stampid: int | tuple[int, ...]) -> None: ... def clearstamps(self, n: int | None = ...) -> None: ... def filling(self) -> bool: ... def begin_fill(self) -> None: ... @@ -516,7 +517,7 @@ def tilt(angle: float) -> None: ... # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp() -> Any: ... -def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... +def clearstamp(stampid: int | tuple[int, ...]) -> None: ... def clearstamps(n: int | None = ...) -> None: ... def filling() -> bool: ... def begin_fill() -> None: ... diff --git a/stdlib/types.pyi b/stdlib/types.pyi index b018d56acd6a..f38bca93b90a 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -1,25 +1,26 @@ +from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Generator, ItemsView, Iterable, Iterator, KeysView, Mapping, MutableSequence, ValuesView import sys from _typeshed import SupportsKeysAndGetItem from importlib.abc import _LoaderProtocol from importlib.machinery import ModuleSpec from typing import ( Any, - AsyncGenerator, - Awaitable, - Callable, - Coroutine, - Generator, + + + + + Generic, - ItemsView, - Iterable, - Iterator, - KeysView, - Mapping, - MutableSequence, - Tuple, + + + + + + + Type, TypeVar, - ValuesView, + overload, ) from typing_extensions import Literal, ParamSpec, final @@ -42,9 +43,9 @@ class _Cell: @final class FunctionType: - __closure__: Tuple[_Cell, ...] | None + __closure__: tuple[_Cell, ...] | None __code__: CodeType - __defaults__: Tuple[Any, ...] | None + __defaults__: tuple[Any, ...] | None __dict__: dict[str, Any] __globals__: dict[str, Any] __name__: str @@ -56,8 +57,8 @@ class FunctionType: code: CodeType, globals: dict[str, Any], name: str | None = ..., - argdefs: Tuple[object, ...] | None = ..., - closure: Tuple[_Cell, ...] | None = ..., + argdefs: tuple[object, ...] | None = ..., + closure: tuple[_Cell, ...] | None = ..., ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __get__(self, obj: object | None, type: type | None) -> MethodType: ... @@ -76,15 +77,15 @@ class CodeType: co_stacksize: int co_flags: int co_code: bytes - co_consts: Tuple[Any, ...] - co_names: Tuple[str, ...] - co_varnames: Tuple[str, ...] + co_consts: tuple[Any, ...] + co_names: tuple[str, ...] + co_varnames: tuple[str, ...] co_filename: str co_name: str co_firstlineno: int co_lnotab: bytes - co_freevars: Tuple[str, ...] - co_cellvars: Tuple[str, ...] + co_freevars: tuple[str, ...] + co_cellvars: tuple[str, ...] if sys.version_info >= (3, 8): def __init__( self, @@ -95,15 +96,15 @@ class CodeType: stacksize: int, flags: int, codestring: bytes, - constants: Tuple[Any, ...], - names: Tuple[str, ...], - varnames: Tuple[str, ...], + constants: tuple[Any, ...], + names: tuple[str, ...], + varnames: tuple[str, ...], filename: str, name: str, firstlineno: int, lnotab: bytes, - freevars: Tuple[str, ...] = ..., - cellvars: Tuple[str, ...] = ..., + freevars: tuple[str, ...] = ..., + cellvars: tuple[str, ...] = ..., ) -> None: ... else: def __init__( @@ -114,15 +115,15 @@ class CodeType: stacksize: int, flags: int, codestring: bytes, - constants: Tuple[Any, ...], - names: Tuple[str, ...], - varnames: Tuple[str, ...], + constants: tuple[Any, ...], + names: tuple[str, ...], + varnames: tuple[str, ...], filename: str, name: str, firstlineno: int, lnotab: bytes, - freevars: Tuple[str, ...] = ..., - cellvars: Tuple[str, ...] = ..., + freevars: tuple[str, ...] = ..., + cellvars: tuple[str, ...] = ..., ) -> None: ... if sys.version_info >= (3, 10): def replace( @@ -136,11 +137,11 @@ class CodeType: co_flags: int = ..., co_firstlineno: int = ..., co_code: bytes = ..., - co_consts: Tuple[Any, ...] = ..., - co_names: Tuple[str, ...] = ..., - co_varnames: Tuple[str, ...] = ..., - co_freevars: Tuple[str, ...] = ..., - co_cellvars: Tuple[str, ...] = ..., + co_consts: tuple[Any, ...] = ..., + co_names: tuple[str, ...] = ..., + co_varnames: tuple[str, ...] = ..., + co_freevars: tuple[str, ...] = ..., + co_cellvars: tuple[str, ...] = ..., co_filename: str = ..., co_name: str = ..., co_linetable: object = ..., @@ -159,11 +160,11 @@ class CodeType: co_flags: int = ..., co_firstlineno: int = ..., co_code: bytes = ..., - co_consts: Tuple[Any, ...] = ..., - co_names: Tuple[str, ...] = ..., - co_varnames: Tuple[str, ...] = ..., - co_freevars: Tuple[str, ...] = ..., - co_cellvars: Tuple[str, ...] = ..., + co_consts: tuple[Any, ...] = ..., + co_names: tuple[str, ...] = ..., + co_varnames: tuple[str, ...] = ..., + co_freevars: tuple[str, ...] = ..., + co_cellvars: tuple[str, ...] = ..., co_filename: str = ..., co_name: str = ..., co_lnotab: bytes = ..., @@ -281,8 +282,8 @@ class _StaticFunctionType: @final class MethodType: - __closure__: Tuple[_Cell, ...] | None # inherited from the added function - __defaults__: Tuple[Any, ...] | None # inherited from the added function + __closure__: tuple[_Cell, ...] | None # inherited from the added function + __defaults__: tuple[Any, ...] | None # inherited from the added function __func__: _StaticFunctionType __self__: object __name__: str # inherited from the added function @@ -385,18 +386,18 @@ if sys.version_info >= (3, 7): kwds: dict[str, Any] | None = ..., exec_body: Callable[[dict[str, Any]], None] | None = ..., ) -> type: ... - def resolve_bases(bases: Iterable[object]) -> Tuple[Any, ...]: ... + def resolve_bases(bases: Iterable[object]) -> tuple[Any, ...]: ... else: def new_class( name: str, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., kwds: dict[str, Any] | None = ..., exec_body: Callable[[dict[str, Any]], None] | None = ..., ) -> type: ... def prepare_class( - name: str, bases: Tuple[type, ...] = ..., kwds: dict[str, Any] | None = ... + name: str, bases: tuple[type, ...] = ..., kwds: dict[str, Any] | None = ... ) -> tuple[type, dict[str, Any], dict[str, Any]]: ... # Actually a different type, but `property` is special and we want that too. @@ -418,8 +419,8 @@ if sys.version_info >= (3, 8): if sys.version_info >= (3, 9): class GenericAlias: __origin__: type - __args__: Tuple[Any, ...] - __parameters__: Tuple[Any, ...] + __args__: tuple[Any, ...] + __parameters__: tuple[Any, ...] def __init__(self, origin: type, args: Any) -> None: ... def __getattr__(self, name: str) -> Any: ... # incomplete @@ -433,6 +434,6 @@ if sys.version_info >= (3, 10): NotImplementedType = _NotImplementedType # noqa F811 from builtins @final class UnionType: - __args__: Tuple[Any, ...] + __args__: tuple[Any, ...] def __or__(self, obj: Any) -> UnionType: ... def __ror__(self, obj: Any) -> UnionType: ... diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 3eb41c797f4a..06ae9043eadd 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -1,31 +1,33 @@ +from collections.abc import AsyncGenerator as AsyncGenerator, AsyncIterable as AsyncIterable, AsyncIterator as AsyncIterator, Awaitable as Awaitable, Callable, Coroutine as Coroutine, ItemsView, KeysView, Mapping, ValuesView +from collections import ChainMap as ChainMap, Counter as Counter, defaultdict as DefaultDict, deque as Deque import abc import sys from typing import ( TYPE_CHECKING as TYPE_CHECKING, Any, AsyncContextManager as AsyncContextManager, - AsyncGenerator as AsyncGenerator, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - Awaitable as Awaitable, - Callable, - ChainMap as ChainMap, + + + + + + ClassVar as ClassVar, ContextManager as ContextManager, - Coroutine as Coroutine, - Counter as Counter, - DefaultDict as DefaultDict, - Deque as Deque, - ItemsView, - KeysView, - Mapping, + + + + + + + NewType as NewType, NoReturn as NoReturn, Text as Text, - Tuple, + Type as Type, TypeVar, - ValuesView, + _Alias, overload as overload, ) @@ -87,7 +89,7 @@ if sys.version_info >= (3, 7): localns: dict[str, Any] | None = ..., include_extras: bool = ..., ) -> dict[str, Any]: ... - def get_args(tp: Any) -> Tuple[Any, ...]: ... + def get_args(tp: Any) -> tuple[Any, ...]: ... def get_origin(tp: Any) -> Any | None: ... Annotated: _SpecialForm = ... diff --git a/stdlib/unittest/async_case.pyi b/stdlib/unittest/async_case.pyi index bdf534b37c9f..8912c2c26fbb 100644 --- a/stdlib/unittest/async_case.pyi +++ b/stdlib/unittest/async_case.pyi @@ -1,5 +1,6 @@ +from collections.abc import Awaitable, Callable import sys -from typing import Any, Awaitable, Callable +from typing import Any from .case import TestCase diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 602a5020b9d4..b3c71066eb13 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable, Container, Iterable, Mapping, Sequence import datetime import logging import sys @@ -9,17 +10,17 @@ from types import TracebackType from typing import ( Any, AnyStr, - Callable, + ClassVar, - Container, + Generic, - Iterable, - Mapping, + + NamedTuple, NoReturn, Pattern, - Sequence, - Tuple, + + Type, TypeVar, overload, @@ -102,8 +103,8 @@ class TestCase: def assertIsNotNone(self, obj: Any, msg: Any = ...) -> None: ... def assertIn(self, member: Any, container: Iterable[Any] | Container[Any], msg: Any = ...) -> None: ... def assertNotIn(self, member: Any, container: Iterable[Any] | Container[Any], msg: Any = ...) -> None: ... - def assertIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: Any = ...) -> None: ... - def assertNotIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: Any = ...) -> None: ... + def assertIsInstance(self, obj: Any, cls: type | tuple[type, ...], msg: Any = ...) -> None: ... + def assertNotIsInstance(self, obj: Any, cls: type | tuple[type, ...], msg: Any = ...) -> None: ... def assertGreater(self, a: Any, b: Any, msg: Any = ...) -> None: ... def assertGreaterEqual(self, a: Any, b: Any, msg: Any = ...) -> None: ... def assertLess(self, a: Any, b: Any, msg: Any = ...) -> None: ... @@ -111,17 +112,17 @@ class TestCase: @overload def assertRaises( # type: ignore[misc] self, - expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...], + expected_exception: Type[BaseException] | tuple[Type[BaseException], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any, ) -> None: ... @overload - def assertRaises(self, expected_exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... + def assertRaises(self, expected_exception: Type[_E] | tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... @overload def assertRaisesRegex( # type: ignore[misc] self, - expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...], + expected_exception: Type[BaseException] | tuple[Type[BaseException], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -130,20 +131,20 @@ class TestCase: @overload def assertRaisesRegex( self, - expected_exception: Type[_E] | Tuple[Type[_E], ...], + expected_exception: Type[_E] | tuple[Type[_E], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertRaisesContext[_E]: ... @overload def assertWarns( # type: ignore[misc] - self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any + self, expected_warning: Type[Warning] | tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any ) -> None: ... @overload - def assertWarns(self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ... + def assertWarns(self, expected_warning: Type[Warning] | tuple[Type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ... @overload def assertWarnsRegex( # type: ignore[misc] self, - expected_warning: Type[Warning] | Tuple[Type[Warning], ...], + expected_warning: Type[Warning] | tuple[Type[Warning], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -152,7 +153,7 @@ class TestCase: @overload def assertWarnsRegex( self, - expected_warning: Type[Warning] | Tuple[Type[Warning], ...], + expected_warning: Type[Warning] | tuple[Type[Warning], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertWarnsContext: ... @@ -200,7 +201,7 @@ class TestCase: self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: Type[Sequence[Any]] | None = ... ) -> None: ... def assertListEqual(self, list1: list[Any], list2: list[Any], msg: Any = ...) -> None: ... - def assertTupleEqual(self, tuple1: Tuple[Any, ...], tuple2: Tuple[Any, ...], msg: Any = ...) -> None: ... + def assertTupleEqual(self, tuple1: tuple[Any, ...], tuple2: tuple[Any, ...], msg: Any = ...) -> None: ... def assertSetEqual(self, set1: Set[object], set2: Set[object], msg: Any = ...) -> None: ... def assertDictEqual(self, d1: Mapping[Any, object], d2: Mapping[Any, object], msg: Any = ...) -> None: ... def fail(self, msg: Any = ...) -> NoReturn: ... @@ -231,13 +232,13 @@ class TestCase: @overload def failUnlessRaises( # type: ignore[misc] self, - exception: Type[BaseException] | Tuple[Type[BaseException], ...], + exception: Type[BaseException] | tuple[Type[BaseException], ...], callable: Callable[..., Any] = ..., *args: Any, **kwargs: Any, ) -> None: ... @overload - def failUnlessRaises(self, exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... + def failUnlessRaises(self, exception: Type[_E] | tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... def failUnlessAlmostEqual(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... def assertAlmostEquals( self, first: float, second: float, places: int = ..., msg: Any = ..., delta: float = ... @@ -251,7 +252,7 @@ class TestCase: @overload def assertRaisesRegexp( # type: ignore[misc] self, - exception: Type[BaseException] | Tuple[Type[BaseException], ...], + exception: Type[BaseException] | tuple[Type[BaseException], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -260,7 +261,7 @@ class TestCase: @overload def assertRaisesRegexp( self, - exception: Type[_E] | Tuple[Type[_E], ...], + exception: Type[_E] | tuple[Type[_E], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertRaisesContext[_E]: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 394e9c9166eb..07503f5134dc 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -1,12 +1,13 @@ +from collections.abc import Callable, Sequence import sys import unittest.case import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Callable, List, Pattern, Sequence, Type +from typing import Any, Pattern, Type _SortComparisonMethod = Callable[[str, str], int] -_SuiteClass = Callable[[List[unittest.case.TestCase]], unittest.suite.TestSuite] +_SuiteClass = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite] VALID_MODULE_NAME: Pattern[str] diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 6d1117ecaf79..321e68d24d80 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -1,10 +1,11 @@ +from collections.abc import Iterable import sys import unittest.case import unittest.loader import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Iterable, Protocol, Type +from typing import Any, Protocol, Type MAIN_EXAMPLES: str MODULE_EXAMPLES: str diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index a84ab67b49f8..1697737af709 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -1,5 +1,6 @@ +from collections.abc import Awaitable, Callable, Iterable, Mapping, Sequence import sys -from typing import Any, Awaitable, Callable, Generic, Iterable, List, Mapping, Sequence, Tuple, Type, TypeVar, overload +from typing import Any, Generic, Type, TypeVar, overload _T = TypeVar("_T") _TT = TypeVar("_TT", bound=Type[Any]) @@ -96,7 +97,7 @@ class _Call(tuple[Any, ...]): call: _Call -class _CallList(List[_Call]): +class _CallList(list[_Call]): def __contains__(self, value: Any) -> bool: ... class Base: @@ -155,7 +156,7 @@ class NonCallableMock(Base, Any): call_args_list: _CallList mock_calls: _CallList def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ... - def _call_matcher(self, _call: Tuple[_Call, ...]) -> _Call: ... + def _call_matcher(self, _call: tuple[_Call, ...]) -> _Call: ... def _get_child_mock(self, **kw: Any) -> NonCallableMock: ... class CallableMixin(Base): diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 0ec4e9170388..6bf2ba420408 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable import unittest.case from types import TracebackType -from typing import Any, Callable, TextIO, Tuple, Type, TypeVar, Union +from typing import Any, TextIO, Type, TypeVar, Union -_SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, TracebackType], Tuple[None, None, None]] +_SysExcInfoType = Union[tuple[Type[BaseException], BaseException, TracebackType], tuple[None, None, None]] _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index bf8f3c05c1cd..53b1ee5fef87 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import unittest.case import unittest.result import unittest.suite -from typing import Callable, TextIO, Type +from typing import TextIO, Type _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] diff --git a/stdlib/unittest/signals.pyi b/stdlib/unittest/signals.pyi index 453bc9caf9e7..392cbca90339 100644 --- a/stdlib/unittest/signals.pyi +++ b/stdlib/unittest/signals.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable import unittest.result -from typing import Callable, TypeVar, overload +from typing import TypeVar, overload from typing_extensions import ParamSpec _P = ParamSpec("_P") diff --git a/stdlib/unittest/suite.pyi b/stdlib/unittest/suite.pyi index 396b46eadf5a..43e15533f71c 100644 --- a/stdlib/unittest/suite.pyi +++ b/stdlib/unittest/suite.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterable, Iterator import unittest.case import unittest.result -from typing import Iterable, Iterator, Union +from typing import Union _TestType = Union[unittest.case.TestCase, TestSuite] diff --git a/stdlib/unittest/util.pyi b/stdlib/unittest/util.pyi index ab6ed053a6ff..f9a12926c39a 100644 --- a/stdlib/unittest/util.pyi +++ b/stdlib/unittest/util.pyi @@ -1,7 +1,8 @@ -from typing import Any, Sequence, Tuple, TypeVar +from collections.abc import Sequence +from typing import Any, TypeVar _T = TypeVar("_T") -_Mismatch = Tuple[_T, _T, int] +_Mismatch = tuple[_T, _T, int] _MAX_LENGTH: int _PLACEHOLDER_LEN: int diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index a5afbdc26bf2..e1d70a8c68d5 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Mapping, Sequence import sys -from typing import Any, AnyStr, Callable, Generic, Mapping, NamedTuple, Sequence, Tuple, Union, overload +from typing import Any, AnyStr, Generic, NamedTuple, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -35,7 +36,7 @@ class _NetlocResultMixinBase(Generic[AnyStr]): class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ... class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ... -class _DefragResultBase(Tuple[Any, ...], Generic[AnyStr]): +class _DefragResultBase(tuple[Any, ...], Generic[AnyStr]): url: AnyStr fragment: AnyStr diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 3c8a6facde6f..13e7ca309f3d 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -1,10 +1,11 @@ +from collections.abc import Callable, Mapping, Sequence import ssl import sys from _typeshed import StrOrBytesPath from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar -from typing import IO, Any, Callable, ClassVar, Mapping, NoReturn, Pattern, Sequence, Tuple, TypeVar, overload +from typing import IO, Any, ClassVar, NoReturn, Pattern, TypeVar, overload from urllib.error import HTTPError from urllib.response import addclosehook, addinfourl @@ -196,9 +197,9 @@ class HTTPSHandler(AbstractHTTPHandler): def https_request(self, request: Request) -> Request: ... # undocumented class FileHandler(BaseHandler): - names: ClassVar[Tuple[str, ...] | None] # undocumented + names: ClassVar[tuple[str, ...] | None] # undocumented def file_open(self, req: Request) -> addinfourl: ... - def get_names(self) -> Tuple[str, ...]: ... # undocumented + def get_names(self) -> tuple[str, ...]: ... # undocumented def open_local_file(self, req: Request) -> addinfourl: ... # undocumented class DataHandler(BaseHandler): diff --git a/stdlib/urllib/response.pyi b/stdlib/urllib/response.pyi index 647ebf874432..264c11fe0ab9 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable, Iterable import sys from _typeshed import Self from email.message import Message from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Tuple, Type, TypeVar +from typing import IO, Any, BinaryIO, Type, TypeVar _AIUT = TypeVar("_AIUT", bound=addbase) @@ -37,7 +38,7 @@ class addbase(BinaryIO): class addclosehook(addbase): closehook: Callable[..., object] - hookargs: Tuple[Any, ...] + hookargs: tuple[Any, ...] def __init__(self, fp: IO[bytes], closehook: Callable[..., object], *hookargs: Any) -> None: ... class addinfo(addbase): diff --git a/stdlib/urllib/robotparser.pyi b/stdlib/urllib/robotparser.pyi index 361126327993..8a29d8bda69a 100644 --- a/stdlib/urllib/robotparser.pyi +++ b/stdlib/urllib/robotparser.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable import sys -from typing import Iterable, NamedTuple +from typing import NamedTuple class _RequestRate(NamedTuple): requests: int diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index da13d819fbdf..782c0491ffb2 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -1,10 +1,10 @@ import sys -from typing import Any, Tuple +from typing import Any # Because UUID has properties called int and bytes we need to rename these temporarily. _Int = int _Bytes = bytes -_FieldsType = Tuple[int, int, int, int, int, int] +_FieldsType = tuple[int, int, int, int, int, int] if sys.version_info >= (3, 7): from enum import Enum diff --git a/stdlib/venv/__init__.pyi b/stdlib/venv/__init__.pyi index 7650e87d98b4..96d133c7cdef 100644 --- a/stdlib/venv/__init__.pyi +++ b/stdlib/venv/__init__.pyi @@ -1,7 +1,8 @@ +from collections.abc import Sequence import sys from _typeshed import StrOrBytesPath from types import SimpleNamespace -from typing import Sequence + if sys.version_info >= (3, 9): CORE_VENV_DEPS: tuple[str, ...] diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index b1c9f4dda8ed..d240813e48c8 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,6 +1,7 @@ +from collections.abc import Sequence from _warnings import warn as warn, warn_explicit as warn_explicit from types import ModuleType, TracebackType -from typing import Any, Sequence, TextIO, Type, overload +from typing import Any, TextIO, Type, overload from typing_extensions import Literal _ActionKind = Literal["default", "error", "ignore", "always", "module", "once"] diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 16ebba39ef17..e22924437129 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping from _weakrefset import WeakSet as WeakSet -from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, Tuple, Type, TypeVar, overload +from typing import Any, Generic, Type, TypeVar, overload from _weakref import ( CallableProxyType as CallableProxyType, @@ -17,7 +18,7 @@ _KT = TypeVar("_KT") _VT = TypeVar("_VT") _CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) -ProxyTypes: Tuple[Type[Any], ...] +ProxyTypes: tuple[Type[Any], ...] class WeakMethod(ref[_CallableT], Generic[_CallableT]): def __new__(cls, meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> WeakMethod[_CallableT]: ... @@ -81,7 +82,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): class finalize: def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... def __call__(self, _: Any = ...) -> Any | None: ... - def detach(self) -> tuple[Any, Any, Tuple[Any, ...], dict[str, Any]] | None: ... - def peek(self) -> tuple[Any, Any, Tuple[Any, ...], dict[str, Any]] | None: ... + def detach(self) -> tuple[Any, Any, tuple[Any, ...], dict[str, Any]] | None: ... + def peek(self) -> tuple[Any, Any, tuple[Any, ...], dict[str, Any]] | None: ... alive: bool atexit: bool diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index 459d886ac930..6acb72c282da 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Sequence import sys -from typing import Callable, Sequence + class Error(Exception): ... diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index ac1e56b7664e..3fe87c57e876 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -1,12 +1,13 @@ +from collections.abc import Callable, MutableMapping from abc import abstractmethod from types import TracebackType -from typing import IO, Callable, MutableMapping, Optional, Tuple, Type +from typing import IO, Optional, Type from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment from .util import FileWrapper -_exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_exc_info = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] def format_date_time(timestamp: float | None) -> str: ... # undocumented def read_environ() -> dict[str, str]: ... diff --git a/stdlib/wsgiref/headers.pyi b/stdlib/wsgiref/headers.pyi index 531a521d3824..b62124a2a936 100644 --- a/stdlib/wsgiref/headers.pyi +++ b/stdlib/wsgiref/headers.pyi @@ -1,6 +1,6 @@ -from typing import List, Pattern, Tuple, overload +from typing import Pattern, overload -_HeaderList = List[Tuple[str, str]] +_HeaderList = list[tuple[str, str]] tspecials: Pattern[str] # undocumented diff --git a/stdlib/wsgiref/util.pyi b/stdlib/wsgiref/util.pyi index c769c77d36e9..7484004dfa9f 100644 --- a/stdlib/wsgiref/util.pyi +++ b/stdlib/wsgiref/util.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable import sys -from typing import IO, Any, Callable +from typing import IO, Any from .types import WSGIEnvironment diff --git a/stdlib/wsgiref/validate.pyi b/stdlib/wsgiref/validate.pyi index 68e22727bc73..e3fae57525c4 100644 --- a/stdlib/wsgiref/validate.pyi +++ b/stdlib/wsgiref/validate.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable, Iterator from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication -from typing import Any, Callable, Iterable, Iterator, NoReturn +from typing import Any, NoReturn class WSGIWarning(Warning): ... diff --git a/stdlib/xdrlib.pyi b/stdlib/xdrlib.pyi index f59843f8ee9d..bd4aa64334f9 100644 --- a/stdlib/xdrlib.pyi +++ b/stdlib/xdrlib.pyi @@ -1,4 +1,5 @@ -from typing import Callable, Sequence, TypeVar +from collections.abc import Callable, Sequence +from typing import TypeVar _T = TypeVar("_T") diff --git a/stdlib/xml/dom/domreg.pyi b/stdlib/xml/dom/domreg.pyi index b9e2dd9eb263..1b91c1f01bfd 100644 --- a/stdlib/xml/dom/domreg.pyi +++ b/stdlib/xml/dom/domreg.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable from _typeshed.xml import DOMImplementation -from typing import Callable, Iterable + well_known_implementations: dict[str, str] registered: dict[str, Callable[[], DOMImplementation]] diff --git a/stdlib/xml/dom/minicompat.pyi b/stdlib/xml/dom/minicompat.pyi index 46d55c666cb0..6fc39152b3c3 100644 --- a/stdlib/xml/dom/minicompat.pyi +++ b/stdlib/xml/dom/minicompat.pyi @@ -1,14 +1,15 @@ -from typing import Any, Iterable, List, Tuple, Type, TypeVar +from collections.abc import Iterable +from typing import Any, Type, TypeVar _T = TypeVar("_T") StringTypes: tuple[Type[str]] -class NodeList(List[_T]): +class NodeList(list[_T]): length: int def item(self, index: int) -> _T | None: ... -class EmptyNodeList(Tuple[Any, ...]): +class EmptyNodeList(tuple[Any, ...]): length: int def item(self, index: int) -> None: ... def __add__(self, other: Iterable[_T]) -> NodeList[_T]: ... # type: ignore[override] diff --git a/stdlib/xml/dom/pulldom.pyi b/stdlib/xml/dom/pulldom.pyi index 530c1988e743..2417204cc971 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence import sys -from typing import IO, Any, Sequence, Tuple, Union +from typing import IO, Any, Union from typing_extensions import Literal from xml.dom.minidom import Document, DOMImplementation, Element, Text from xml.sax.handler import ContentHandler @@ -17,7 +18,7 @@ CHARACTERS: Literal["CHARACTERS"] _DocumentFactory = Union[DOMImplementation, None] _Node = Union[Document, Element, Text] -_Event = Tuple[ +_Event = tuple[ Literal[ Literal["START_ELEMENT"], Literal["END_ELEMENT"], diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index b355bef1208c..3f09a23c2af6 100644 --- a/stdlib/xml/etree/ElementInclude.pyi +++ b/stdlib/xml/etree/ElementInclude.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable import sys -from typing import Callable + from xml.etree.ElementTree import Element XINCLUDE: str diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index db4bd6a4e958..188d69ee507e 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -1,11 +1,12 @@ -from typing import Callable, Generator, List, Pattern, Tuple, TypeVar +from collections.abc import Callable, Generator +from typing import Pattern, TypeVar from xml.etree.ElementTree import Element xpath_tokenizer_re: Pattern[str] -_token = Tuple[str, str] +_token = tuple[str, str] _next = Callable[[], _token] -_callback = Callable[[_SelectorContext, List[Element]], Generator[Element, None, None]] +_callback = Callable[[_SelectorContext, list[Element]], Generator[Element, None, None]] def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = ...) -> Generator[_token, None, None]: ... def get_parent_map(context: _SelectorContext) -> dict[Element, Element]: ... diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 6ee578b9aa81..dc1bec89d267 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -1,18 +1,19 @@ +from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, KeysView, Mapping, MutableSequence, Sequence import sys from _typeshed import FileDescriptor, StrOrBytesPath, SupportsWrite from typing import ( IO, Any, - Callable, - Dict, - Generator, - ItemsView, - Iterable, - Iterator, - KeysView, - Mapping, - MutableSequence, - Sequence, + + + + + + + + + + TypeVar, Union, overload, @@ -257,7 +258,7 @@ def fromstringlist(sequence: Sequence[str | bytes], parser: XMLParser | None = . # TreeBuilder is called by client code (they could pass strs, bytes or whatever); # but we don't want to use a too-broad type, or it would be too hard to write # elementfactories. -_ElementFactory = Callable[[Any, Dict[Any, Any]], Element] +_ElementFactory = Callable[[Any, dict[Any, Any]], Element] class TreeBuilder: if sys.version_info >= (3, 8): diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index a123e7e894e2..660be30bc915 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable import sys -from typing import IO, Any, Iterable, NoReturn +from typing import IO, Any, NoReturn from xml.sax.handler import ContentHandler, ErrorHandler from xml.sax.xmlreader import Locator, XMLReader diff --git a/stdlib/xml/sax/saxutils.pyi b/stdlib/xml/sax/saxutils.pyi index c7304f4b5261..6d4c5b06a69e 100644 --- a/stdlib/xml/sax/saxutils.pyi +++ b/stdlib/xml/sax/saxutils.pyi @@ -1,7 +1,8 @@ +from collections.abc import Mapping from _typeshed import SupportsWrite from codecs import StreamReaderWriter, StreamWriter from io import RawIOBase, TextIOBase -from typing import Mapping + from xml.sax import handler, xmlreader def escape(data: str, entities: Mapping[str, str] = ...) -> str: ... diff --git a/stdlib/xml/sax/xmlreader.pyi b/stdlib/xml/sax/xmlreader.pyi index 684e9cef1f42..a1b4a21fd6a8 100644 --- a/stdlib/xml/sax/xmlreader.pyi +++ b/stdlib/xml/sax/xmlreader.pyi @@ -1,4 +1,5 @@ -from typing import Mapping +from collections.abc import Mapping + class XMLReader: def __init__(self) -> None: ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index b715e8b2928a..09fd839b5cc0 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable, Iterable, Mapping import gzip import http.client import sys @@ -6,16 +7,16 @@ from _typeshed import Self, SupportsRead, SupportsWrite from datetime import datetime from io import BytesIO from types import TracebackType -from typing import Any, Callable, Dict, Iterable, List, Mapping, Protocol, Tuple, Type, Union, overload +from typing import Any, Protocol, Type, Union, overload from typing_extensions import Literal class _SupportsTimeTuple(Protocol): def timetuple(self) -> time.struct_time: ... _DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple] -_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime, DateTime, Binary] -_XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time] -_HostType = Union[Tuple[str, Dict[str, str]], str] +_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime, DateTime, Binary] +_XMLDate = Union[int, datetime, tuple[int, ...], time.struct_time] +_HostType = Union[tuple[str, dict[str, str]], str] def escape(s: str) -> str: ... # undocumented @@ -63,7 +64,7 @@ def _strftime(value: _XMLDate) -> str: ... # undocumented class DateTime: value: str # undocumented - def __init__(self, value: int | str | datetime | time.struct_time | Tuple[int, ...] = ...) -> None: ... + def __init__(self, value: int | str | datetime | time.struct_time | tuple[int, ...] = ...) -> None: ... def __lt__(self, other: _DateTimeComparable) -> bool: ... def __le__(self, other: _DateTimeComparable) -> bool: ... def __gt__(self, other: _DateTimeComparable) -> bool: ... @@ -135,7 +136,7 @@ class Unmarshaller: _use_datetime: bool _use_builtin_types: bool def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ... - def close(self) -> Tuple[_Marshallable, ...]: ... + def close(self) -> tuple[_Marshallable, ...]: ... def getmethodname(self) -> str | None: ... def xml(self, encoding: str, standalone: Any) -> None: ... # Standalone is ignored def start(self, tag: str, attrs: dict[str, str]) -> None: ... @@ -159,7 +160,7 @@ class Unmarshaller: class _MultiCallMethod: # undocumented - __call_list: list[tuple[str, Tuple[_Marshallable, ...]]] + __call_list: list[tuple[str, tuple[_Marshallable, ...]]] __name: str def __init__(self, call_list: list[tuple[str, _Marshallable]], name: str) -> None: ... def __getattr__(self, name: str) -> _MultiCallMethod: ... @@ -174,7 +175,7 @@ class MultiCallIterator: # undocumented class MultiCall: __server: ServerProxy - __call_list: list[tuple[str, Tuple[_Marshallable, ...]]] + __call_list: list[tuple[str, tuple[_Marshallable, ...]]] def __init__(self, server: ServerProxy) -> None: ... def __getattr__(self, item: str) -> _MultiCallMethod: ... def __call__(self) -> MultiCallIterator: ... @@ -186,13 +187,13 @@ FastUnmarshaller: Unmarshaller | None def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[ExpatParser, Unmarshaller]: ... def dumps( - params: Fault | Tuple[_Marshallable, ...], + params: Fault | tuple[_Marshallable, ...], methodname: str | None = ..., methodresponse: bool | None = ..., encoding: str | None = ..., allow_none: bool = ..., ) -> str: ... -def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[Tuple[_Marshallable, ...], str | None]: ... +def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[tuple[_Marshallable, ...], str | None]: ... def gzip_encode(data: bytes) -> bytes: ... # undocumented def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ... # undocumented @@ -204,9 +205,9 @@ class GzipDecodedResponse(gzip.GzipFile): # undocumented class _Method: # undocumented - __send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable] + __send: Callable[[str, tuple[_Marshallable, ...]], _Marshallable] __name: str - def __init__(self, send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ... + def __init__(self, send: Callable[[str, tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ... def __getattr__(self, name: str) -> _Method: ... def __call__(self, *args: _Marshallable) -> _Marshallable: ... @@ -228,10 +229,10 @@ class Transport: ) -> None: ... else: def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ... - def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> Tuple[_Marshallable, ...]: ... + def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> tuple[_Marshallable, ...]: ... def single_request( self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ... - ) -> Tuple[_Marshallable, ...]: ... + ) -> tuple[_Marshallable, ...]: ... def getparser(self) -> tuple[ExpatParser, Unmarshaller]: ... def get_host_info(self, host: _HostType) -> tuple[str, list[tuple[str, str]], dict[str, str]]: ... def make_connection(self, host: _HostType) -> http.client.HTTPConnection: ... @@ -239,7 +240,7 @@ class Transport: def send_request(self, host: _HostType, handler: str, request_body: bytes, debug: bool) -> http.client.HTTPConnection: ... def send_headers(self, connection: http.client.HTTPConnection, headers: list[tuple[str, str]]) -> None: ... def send_content(self, connection: http.client.HTTPConnection, request_body: bytes) -> None: ... - def parse_response(self, response: http.client.HTTPResponse) -> Tuple[_Marshallable, ...]: ... + def parse_response(self, response: http.client.HTTPResponse) -> tuple[_Marshallable, ...]: ... class SafeTransport(Transport): @@ -304,6 +305,6 @@ class ServerProxy: self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __close(self) -> None: ... # undocumented - def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ... # undocumented + def __request(self, methodname: str, params: tuple[_Marshallable, ...]) -> tuple[_Marshallable, ...]: ... # undocumented Server = ServerProxy diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index f84253cef568..2f5e2187c1a3 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -1,13 +1,14 @@ +from collections.abc import Callable, Iterable, Mapping import http.server import pydoc import socketserver import sys from datetime import datetime -from typing import Any, Callable, Dict, Iterable, List, Mapping, Pattern, Protocol, Tuple, Type, Union +from typing import Any, Pattern, Protocol, Type, Union from xmlrpc.client import Fault # TODO: Recursive type on tuple, list, dict -_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime] +_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime] # The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy class _DispatchArity0(Protocol): @@ -53,7 +54,7 @@ class SimpleXMLRPCDispatcher: # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ..., + dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = ..., path: Any | None = ..., ) -> str: ... # undocumented def system_listMethods(self) -> list[str]: ... # undocumented @@ -109,7 +110,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ..., + dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = ..., path: Any | None = ..., ) -> str: ... diff --git a/stdlib/zipapp.pyi b/stdlib/zipapp.pyi index 581d2b72a664..58b765a31869 100644 --- a/stdlib/zipapp.pyi +++ b/stdlib/zipapp.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import sys from pathlib import Path -from typing import BinaryIO, Callable, Union +from typing import BinaryIO, Union _Path = Union[str, Path, BinaryIO] diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 710b9b237b4c..75608427ee46 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -1,12 +1,13 @@ +from collections.abc import Callable, Iterable, Iterator, Sequence import io import sys from _typeshed import Self, StrPath from os import PathLike from types import TracebackType -from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, Tuple, Type, overload +from typing import IO, Any, Protocol, Type, overload from typing_extensions import Literal -_DateTuple = Tuple[int, int, int, int, int, int] +_DateTuple = tuple[int, int, int, int, int, int] _ReadWriteMode = Literal["r", "w"] _ReadWriteBinaryMode = Literal["r", "w", "rb", "wb"] _ZipFileMode = Literal["r", "w", "x", "a"] diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 4f924e0cc4bf..5d7cd52d728b 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -1,7 +1,8 @@ +from collections.abc import Iterable, Sequence import typing from _typeshed import StrPath from datetime import tzinfo -from typing import Any, Iterable, Protocol, Sequence, Type +from typing import Any, Protocol, Type _T = typing.TypeVar("_T", bound="ZoneInfo") diff --git a/stubs/DateTimeRange/datetimerange/__init__.pyi b/stubs/DateTimeRange/datetimerange/__init__.pyi index b38cad3bf897..61ae72eca2d4 100644 --- a/stubs/DateTimeRange/datetimerange/__init__.pyi +++ b/stubs/DateTimeRange/datetimerange/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable import datetime -from typing import Iterable + from dateutil.relativedelta import relativedelta diff --git a/stubs/Deprecated/deprecated/classic.pyi b/stubs/Deprecated/deprecated/classic.pyi index b6f546235047..661d6135036e 100644 --- a/stubs/Deprecated/deprecated/classic.pyi +++ b/stubs/Deprecated/deprecated/classic.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Type, TypeVar, overload +from collections.abc import Callable +from typing import Any, Type, TypeVar, overload from typing_extensions import Literal _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/stubs/Deprecated/deprecated/sphinx.pyi b/stubs/Deprecated/deprecated/sphinx.pyi index e5acd9406e68..75948cbb1682 100644 --- a/stubs/Deprecated/deprecated/sphinx.pyi +++ b/stubs/Deprecated/deprecated/sphinx.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Type, TypeVar +from collections.abc import Callable +from typing import Any, Type, TypeVar from typing_extensions import Literal from .classic import ClassicAdapter, _Actions diff --git a/stubs/JACK-Client/jack/__init__.pyi b/stubs/JACK-Client/jack/__init__.pyi index 1f62eb116430..6a24b84b6ed2 100644 --- a/stubs/JACK-Client/jack/__init__.pyi +++ b/stubs/JACK-Client/jack/__init__.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Generator, Iterable, Iterator, Sequence, overload +from collections.abc import Callable, Generator, Iterable, Iterator, Sequence +from typing import Any, overload _NDArray = Any # FIXME: no typings for numpy arrays diff --git a/stubs/Markdown/markdown/blockparser.pyi b/stubs/Markdown/markdown/blockparser.pyi index a747902f718e..fa9a0bf88172 100644 --- a/stubs/Markdown/markdown/blockparser.pyi +++ b/stubs/Markdown/markdown/blockparser.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, List, TypeVar +from collections.abc import Iterable +from typing import Any, TypeVar from xml.etree.ElementTree import Element, ElementTree from . import Markdown @@ -6,7 +7,7 @@ from .util import Registry _T = TypeVar("_T") -class State(List[_T]): +class State(list[_T]): def set(self, state: _T) -> None: ... def reset(self) -> None: ... def isstate(self, state: _T) -> bool: ... diff --git a/stubs/Markdown/markdown/core.pyi b/stubs/Markdown/markdown/core.pyi index e43df00dfdb1..64c213521952 100644 --- a/stubs/Markdown/markdown/core.pyi +++ b/stubs/Markdown/markdown/core.pyi @@ -1,4 +1,5 @@ -from typing import Any, BinaryIO, Callable, ClassVar, Mapping, Sequence, Text, TextIO +from collections.abc import Callable, Mapping, Sequence +from typing import Any, BinaryIO, ClassVar, Text, TextIO from typing_extensions import Literal from xml.etree.ElementTree import Element diff --git a/stubs/Markdown/markdown/extensions/__init__.pyi b/stubs/Markdown/markdown/extensions/__init__.pyi index 8b6cd2a4795f..e01e02de6ca2 100644 --- a/stubs/Markdown/markdown/extensions/__init__.pyi +++ b/stubs/Markdown/markdown/extensions/__init__.pyi @@ -1,4 +1,5 @@ -from typing import Any, Mapping +from collections.abc import Mapping +from typing import Any from markdown.core import Markdown diff --git a/stubs/Pillow/PIL/ExifTags.pyi b/stubs/Pillow/PIL/ExifTags.pyi index 0ad93f535979..8aad8b764811 100644 --- a/stubs/Pillow/PIL/ExifTags.pyi +++ b/stubs/Pillow/PIL/ExifTags.pyi @@ -1,4 +1,5 @@ -from typing import Mapping +from collections.abc import Mapping + TAGS: Mapping[int, str] GPSTAGS: Mapping[int, str] diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 4d7113496b60..a98a3d7e782c 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Sequence from _typeshed import SupportsRead, SupportsWrite from collections.abc import Iterable, Iterator, MutableMapping from pathlib import Path -from typing import Any, Callable, Dict, Protocol, Sequence, SupportsBytes, Tuple, Union +from typing import Any, Protocol, SupportsBytes, Union from typing_extensions import Literal from ._imaging import ( @@ -16,13 +17,13 @@ from .ImagePalette import ImagePalette _Mode = Literal["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"] _Resample = Literal[0, 1, 2, 3, 4, 5] -_Size = Tuple[int, int] -_Box = Tuple[int, int, int, int] +_Size = tuple[int, int] +_Box = tuple[int, int, int, int] _ConversionMatrix = Union[ - Tuple[float, float, float, float], Tuple[float, float, float, float, float, float, float, float, float, float, float, float], + tuple[float, float, float, float], tuple[float, float, float, float, float, float, float, float, float, float, float, float], ] -_Color = Union[float, Tuple[float, ...]] +_Color = Union[float, tuple[float, ...]] class _Writeable(SupportsWrite[bytes], Protocol): def seek(self, __offset: int) -> Any: ... @@ -88,7 +89,7 @@ MODES: list[_Mode] def getmodebase(mode: _Mode) -> Literal["L", "RGB"]: ... def getmodetype(mode: _Mode) -> Literal["L", "I", "F"]: ... -def getmodebandnames(mode: _Mode) -> Tuple[str, ...]: ... +def getmodebandnames(mode: _Mode) -> tuple[str, ...]: ... def getmodebands(mode: _Mode) -> int: ... def preinit() -> None: ... def init() -> None: ... @@ -99,7 +100,7 @@ class _E: def __add__(self, other) -> _E: ... def __mul__(self, other) -> _E: ... -_ImageState = Tuple[Dict[str, Any], str, Tuple[int, int], Any, bytes] +_ImageState = tuple[dict[str, Any], str, tuple[int, int], Any, bytes] class Image: format: Any @@ -149,7 +150,7 @@ class Image: def crop(self, box: _Box | None = ...) -> Image: ... def draft(self, mode: str, size: _Size) -> None: ... def filter(self, filter: Filter | Callable[[], Filter]) -> Image: ... - def getbands(self) -> Tuple[str, ...]: ... + def getbands(self) -> tuple[str, ...]: ... def getbbox(self) -> tuple[int, int, int, int] | None: ... def getcolors(self, maxcolors: int = ...) -> list[tuple[int, int]]: ... def getdata(self, band: int | None = ...): ... @@ -197,7 +198,7 @@ class Image: ) -> None: ... def seek(self, frame: int) -> None: ... def show(self, title: str | None = ..., command: str | None = ...) -> None: ... - def split(self) -> Tuple[Image, ...]: ... + def split(self) -> tuple[Image, ...]: ... def getchannel(self, channel: int | str) -> Image: ... def tell(self) -> int: ... def thumbnail(self, size: tuple[int, int], resample: _Resample = ..., reducing_gap: float = ...) -> None: ... @@ -218,7 +219,7 @@ class Image: class ImagePointHandler: ... class ImageTransformHandler: ... -def new(mode: _Mode, size: tuple[int, int], color: float | Tuple[float, ...] | str = ...) -> Image: ... +def new(mode: _Mode, size: tuple[int, int], color: float | tuple[float, ...] | str = ...) -> Image: ... def frombytes(mode: _Mode, size: tuple[int, int], data, decoder_name: str = ..., *args) -> Image: ... def frombuffer(mode: _Mode, size: tuple[int, int], data, decoder_name: str = ..., *args) -> Image: ... def fromarray(obj, mode: _Mode | None = ...) -> Image: ... diff --git a/stubs/Pillow/PIL/ImageColor.pyi b/stubs/Pillow/PIL/ImageColor.pyi index 8e0db5292296..79aaba0ba7c1 100644 --- a/stubs/Pillow/PIL/ImageColor.pyi +++ b/stubs/Pillow/PIL/ImageColor.pyi @@ -1,8 +1,8 @@ -from typing import Tuple, Union +from typing import Union -_RGB = Union[Tuple[int, int, int], Tuple[int, int, int, int]] +_RGB = Union[tuple[int, int, int], tuple[int, int, int, int]] _Ink = Union[str, int, _RGB] -_GreyScale = Tuple[int, int] +_GreyScale = tuple[int, int] def getrgb(color: _Ink) -> _RGB: ... def getcolor(color: _Ink, mode: str) -> _RGB | _GreyScale: ... diff --git a/stubs/Pillow/PIL/ImageDraw.pyi b/stubs/Pillow/PIL/ImageDraw.pyi index 5ca32e3b3c8f..63251213730f 100644 --- a/stubs/Pillow/PIL/ImageDraw.pyi +++ b/stubs/Pillow/PIL/ImageDraw.pyi @@ -1,12 +1,13 @@ +from collections.abc import Sequence from collections.abc import Container -from typing import Any, Sequence, Tuple, Union, overload +from typing import Any, Union, overload from typing_extensions import Literal from .Image import Image from .ImageColor import _Ink from .ImageFont import _Font -_XY = Sequence[Union[float, Tuple[float, float]]] +_XY = Sequence[Union[float, tuple[float, float]]] _Outline = Any class ImageDraw: diff --git a/stubs/Pillow/PIL/ImageFilter.pyi b/stubs/Pillow/PIL/ImageFilter.pyi index af03bce671dd..565e559adb5e 100644 --- a/stubs/Pillow/PIL/ImageFilter.pyi +++ b/stubs/Pillow/PIL/ImageFilter.pyi @@ -1,10 +1,11 @@ +from collections.abc import Callable, Iterable, Sequence from _typeshed import Self -from typing import Any, Callable, Iterable, Sequence, Tuple, Type +from typing import Any, Type from typing_extensions import Literal from .Image import Image -_FilterArgs = Tuple[Sequence[int], int, int, Sequence[int]] +_FilterArgs = tuple[Sequence[int], int, int, Sequence[int]] # filter image parameters below are the C images, i.e. Image().im. diff --git a/stubs/Pillow/PIL/ImageOps.pyi b/stubs/Pillow/PIL/ImageOps.pyi index 2c84e4dc6ba1..b07be6160773 100644 --- a/stubs/Pillow/PIL/ImageOps.pyi +++ b/stubs/Pillow/PIL/ImageOps.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Protocol, Union +from collections.abc import Iterable +from typing import Any, Protocol, Union from .Image import Image, _Resample, _Size from .ImageColor import _Ink diff --git a/stubs/Pillow/PIL/PdfParser.pyi b/stubs/Pillow/PIL/PdfParser.pyi index 4e484ae2a817..6cf70bc63668 100644 --- a/stubs/Pillow/PIL/PdfParser.pyi +++ b/stubs/Pillow/PIL/PdfParser.pyi @@ -1,5 +1,5 @@ import collections -from typing import Any, List +from typing import Any def encode_text(s: str) -> bytes: ... @@ -44,7 +44,7 @@ class PdfName: allowed_chars: Any def __bytes__(self): ... -class PdfArray(List[Any]): +class PdfArray(list[Any]): def __bytes__(self): ... class PdfDict(collections.UserDict): diff --git a/stubs/Pillow/PIL/TiffTags.pyi b/stubs/Pillow/PIL/TiffTags.pyi index 5559e169bd5c..64ede121bfb6 100644 --- a/stubs/Pillow/PIL/TiffTags.pyi +++ b/stubs/Pillow/PIL/TiffTags.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, NamedTuple, Tuple, Union +from typing import Any, NamedTuple, Union from typing_extensions import Literal class _TagInfo(NamedTuple): @@ -36,7 +36,7 @@ DOUBLE: Literal[12] IFD: Literal[13] _TagType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] -_TagTuple = Union[Tuple[str, _TagType, int], Tuple[str, _TagInfo, int, Dict[str, int]]] +_TagTuple = Union[tuple[str, _TagType, int], tuple[str, _TagInfo, int, dict[str, int]]] TAGS_V2: dict[int, _TagTuple] TAGS_V2_GROUPS: dict[int, dict[int, _TagTuple]] diff --git a/stubs/PyMySQL/pymysql/__init__.pyi b/stubs/PyMySQL/pymysql/__init__.pyi index 6babdc3fb4e5..80966cdddbe7 100644 --- a/stubs/PyMySQL/pymysql/__init__.pyi +++ b/stubs/PyMySQL/pymysql/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import FrozenSet + from .connections import Connection as Connection from .constants import FIELD_TYPE as FIELD_TYPE @@ -30,7 +30,7 @@ threadsafety: int apilevel: str paramstyle: str -class DBAPISet(FrozenSet[int]): +class DBAPISet(frozenset[int]): def __ne__(self, other) -> bool: ... def __eq__(self, other) -> bool: ... def __hash__(self) -> int: ... diff --git a/stubs/PyMySQL/pymysql/connections.pyi b/stubs/PyMySQL/pymysql/connections.pyi index f30e0366167a..e2307965d92d 100644 --- a/stubs/PyMySQL/pymysql/connections.pyi +++ b/stubs/PyMySQL/pymysql/connections.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping from socket import socket as _socket -from typing import Any, AnyStr, Generic, Mapping, Tuple, Type, TypeVar, overload +from typing import Any, AnyStr, Generic, Type, TypeVar, overload from .charset import charset_by_id as charset_by_id, charset_by_name as charset_by_name from .constants import CLIENT as CLIENT, COMMAND as COMMAND, FIELD_TYPE as FIELD_TYPE, SERVER_STATUS as SERVER_STATUS @@ -35,7 +36,7 @@ class MysqlPacket: def read_uint64(self) -> Any: ... def read_length_encoded_integer(self) -> int: ... def read_length_coded_string(self) -> bytes: ... - def read_struct(self, fmt: str) -> Tuple[Any, ...]: ... + def read_struct(self, fmt: str) -> tuple[Any, ...]: ... def is_ok_packet(self) -> bool: ... def is_eof_packet(self) -> bool: ... def is_auth_switch_request(self) -> bool: ... diff --git a/stubs/PyMySQL/pymysql/cursors.pyi b/stubs/PyMySQL/pymysql/cursors.pyi index 45942196111e..deb1050b3658 100644 --- a/stubs/PyMySQL/pymysql/cursors.pyi +++ b/stubs/PyMySQL/pymysql/cursors.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Iterator, Text, Tuple, TypeVar +from collections.abc import Iterable, Iterator +from typing import Any, Text, TypeVar from .connections import Connection @@ -6,7 +7,7 @@ _SelfT = TypeVar("_SelfT") class Cursor: connection: Connection[Any] - description: Tuple[Text, ...] + description: tuple[Text, ...] rownumber: int rowcount: int arraysize: int @@ -27,21 +28,21 @@ class Cursor: def __enter__(self: _SelfT) -> _SelfT: ... def __exit__(self, *exc_info: Any) -> None: ... # Methods returning result tuples are below. - def fetchone(self) -> Tuple[Any, ...] | None: ... - def fetchmany(self, size: int | None = ...) -> Tuple[Tuple[Any, ...], ...]: ... - def fetchall(self) -> Tuple[Tuple[Any, ...], ...]: ... - def __iter__(self) -> Iterator[Tuple[Any, ...]]: ... + def fetchone(self) -> tuple[Any, ...] | None: ... + def fetchmany(self, size: int | None = ...) -> tuple[tuple[Any, ...], ...]: ... + def fetchall(self) -> tuple[tuple[Any, ...], ...]: ... + def __iter__(self) -> Iterator[tuple[Any, ...]]: ... class DictCursorMixin: dict_type: Any # TODO: add support if someone needs this def fetchone(self) -> dict[Text, Any] | None: ... - def fetchmany(self, size: int | None = ...) -> Tuple[dict[Text, Any], ...]: ... - def fetchall(self) -> Tuple[dict[Text, Any], ...]: ... + def fetchmany(self, size: int | None = ...) -> tuple[dict[Text, Any], ...]: ... + def fetchall(self) -> tuple[dict[Text, Any], ...]: ... def __iter__(self) -> Iterator[dict[Text, Any]]: ... class SSCursor(Cursor): - def fetchall(self) -> list[Tuple[Any, ...]]: ... # type: ignore[override] - def fetchall_unbuffered(self) -> Iterator[Tuple[Any, ...]]: ... + def fetchall(self) -> list[tuple[Any, ...]]: ... # type: ignore[override] + def fetchall_unbuffered(self) -> Iterator[tuple[Any, ...]]: ... def scroll(self, value: int, mode: Text = ...) -> None: ... class DictCursor(DictCursorMixin, Cursor): ... # type: ignore[misc] diff --git a/stubs/Pygments/pygments/formatters/__init__.pyi b/stubs/Pygments/pygments/formatters/__init__.pyi index b77043bb31e1..082ba35dee9b 100644 --- a/stubs/Pygments/pygments/formatters/__init__.pyi +++ b/stubs/Pygments/pygments/formatters/__init__.pyi @@ -1,4 +1,5 @@ -from typing import Generator, Type +from collections.abc import Generator +from typing import Type from ..formatter import Formatter from .bbcode import BBCodeFormatter as BBCodeFormatter diff --git a/stubs/Pygments/pygments/lexer.pyi b/stubs/Pygments/pygments/lexer.pyi index 6ede8438bc04..379ba530816e 100644 --- a/stubs/Pygments/pygments/lexer.pyi +++ b/stubs/Pygments/pygments/lexer.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Iterator, Sequence -from typing import Any, Tuple +from typing import Any from pygments.token import _TokenType from pygments.util import Future @@ -40,7 +40,7 @@ class _inherit: ... inherit: Any -class combined(Tuple[Any]): +class combined(tuple[Any]): def __new__(cls, *args): ... def __init__(self, *args) -> None: ... diff --git a/stubs/Pygments/pygments/lexers/__init__.pyi b/stubs/Pygments/pygments/lexers/__init__.pyi index 23a2966c3890..14ca6673bd27 100644 --- a/stubs/Pygments/pygments/lexers/__init__.pyi +++ b/stubs/Pygments/pygments/lexers/__init__.pyi @@ -1,13 +1,13 @@ from _typeshed import StrOrBytesPath, StrPath from collections.abc import Iterator -from typing import Any, Tuple, Union +from typing import Any, Union from pygments.lexer import Lexer, LexerMeta _OpenFile = Union[StrOrBytesPath, int] # copy/pasted from builtins.pyi # TODO: use lower-case tuple once mypy updated -def get_all_lexers() -> Iterator[tuple[str, Tuple[str, ...], Tuple[str, ...], Tuple[str, ...]]]: ... +def get_all_lexers() -> Iterator[tuple[str, tuple[str, ...], tuple[str, ...], tuple[str, ...]]]: ... def find_lexer_class(name: str) -> LexerMeta | None: ... def find_lexer_class_by_name(_alias: str) -> LexerMeta: ... def get_lexer_by_name(_alias: str, **options: Any) -> Lexer: ... diff --git a/stubs/Pygments/pygments/token.pyi b/stubs/Pygments/pygments/token.pyi index 74a918f52dfb..bcc10fd1a771 100644 --- a/stubs/Pygments/pygments/token.pyi +++ b/stubs/Pygments/pygments/token.pyi @@ -1,7 +1,7 @@ from collections.abc import Mapping -from typing import Tuple -class _TokenType(Tuple[str]): # TODO: change to lower-case tuple once new mypy released + +class _TokenType(tuple[str]): # TODO: change to lower-case tuple once new mypy released parent: _TokenType | None def split(self) -> list[_TokenType]: ... subtypes: set[_TokenType] diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index 3859bc5ce660..0ab485bb8ebe 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -1,6 +1,7 @@ +from collections.abc import Coroutine, Generator, Iterator from _typeshed import Self from types import CodeType, FrameType, TracebackType, coroutine -from typing import Any, Coroutine, Generator, Generic, Iterator, Type, TypeVar +from typing import Any, Generic, Type, TypeVar _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index b48884c4430e..0462a6cbc43a 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -1,7 +1,8 @@ +from collections.abc import Sequence import sys from _typeshed import StrOrBytesPath from os import stat_result -from typing import Sequence, Union, overload +from typing import Union, overload _FdOrAnyPath = Union[int, StrOrBytesPath] diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index a43b5ab0defb..1c9c828461eb 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -1,3 +1,4 @@ +from collections.abc import Callable from _typeshed import ( OpenBinaryMode, OpenBinaryModeReading, @@ -7,7 +8,7 @@ from _typeshed import ( StrOrBytesPath, ) from asyncio import AbstractEventLoop -from typing import Any, Callable, Union, overload +from typing import Any, Union, overload from typing_extensions import Literal from ..base import AiofilesContextManager diff --git a/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/stubs/aiofiles/aiofiles/threadpool/binary.pyi index 27bfd7c8516b..1b66fca96c91 100644 --- a/stubs/aiofiles/aiofiles/threadpool/binary.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/binary.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterable from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from io import FileIO -from typing import Iterable + from ..base import AsyncBase diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index fd2a90122e2a..71d61887cc73 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable from _typeshed import StrOrBytesPath -from typing import BinaryIO, Iterable, Tuple +from typing import BinaryIO from ..base import AsyncBase @@ -31,7 +32,7 @@ class AsyncTextIOWrapper(AsyncBase[str]): @property def line_buffering(self) -> bool: ... @property - def newlines(self) -> str | Tuple[str, ...] | None: ... + def newlines(self) -> str | tuple[str, ...] | None: ... @property def name(self) -> StrOrBytesPath | int: ... @property diff --git a/stubs/atomicwrites/atomicwrites/__init__.pyi b/stubs/atomicwrites/atomicwrites/__init__.pyi index 388ac27182fe..244f5f60d619 100644 --- a/stubs/atomicwrites/atomicwrites/__init__.pyi +++ b/stubs/atomicwrites/atomicwrites/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from _typeshed import StrOrBytesPath -from typing import IO, Any, AnyStr, Callable, ContextManager, Text, Type +from typing import IO, Any, AnyStr, ContextManager, Text, Type def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... def move_atomic(src: AnyStr, dst: AnyStr) -> None: ... diff --git a/stubs/aws-xray-sdk/aws_xray_sdk/core/patcher.pyi b/stubs/aws-xray-sdk/aws_xray_sdk/core/patcher.pyi index 49a46c7b1d65..e0c095775ba2 100644 --- a/stubs/aws-xray-sdk/aws_xray_sdk/core/patcher.pyi +++ b/stubs/aws-xray-sdk/aws_xray_sdk/core/patcher.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable from logging import Logger -from typing import Any, Iterable +from typing import Any from aws_xray_sdk import global_sdk_config as global_sdk_config diff --git a/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi b/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi index f1c47af48298..840e2c753113 100644 --- a/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi +++ b/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable import time from logging import Logger -from typing import Any, Callable, Iterable +from typing import Any from aws_xray_sdk import global_sdk_config as global_sdk_config from aws_xray_sdk.version import VERSION as VERSION diff --git a/stubs/babel/babel/messages/plurals.pyi b/stubs/babel/babel/messages/plurals.pyi index 0f9ac943b0f5..5f75160f3d7f 100644 --- a/stubs/babel/babel/messages/plurals.pyi +++ b/stubs/babel/babel/messages/plurals.pyi @@ -1,10 +1,10 @@ -from typing import Any, Tuple +from typing import Any LC_CTYPE: Any PLURALS: Any DEFAULT_PLURAL: Any -class _PluralTuple(Tuple[int, str]): +class _PluralTuple(tuple[int, str]): num_plurals: Any plural_expr: Any plural_forms: Any diff --git a/stubs/beautifulsoup4/bs4/__init__.pyi b/stubs/beautifulsoup4/bs4/__init__.pyi index d975dfc8f061..1224020db2ac 100644 --- a/stubs/beautifulsoup4/bs4/__init__.pyi +++ b/stubs/beautifulsoup4/bs4/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence from _typeshed import Self, SupportsRead -from typing import Any, Sequence, Type +from typing import Any, Type from .builder import TreeBuilder from .element import PageElement, SoupStrainer, Tag diff --git a/stubs/beautifulsoup4/bs4/dammit.pyi b/stubs/beautifulsoup4/bs4/dammit.pyi index 97df5bfda88c..9dd69f4b4c46 100644 --- a/stubs/beautifulsoup4/bs4/dammit.pyi +++ b/stubs/beautifulsoup4/bs4/dammit.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable, Iterator from logging import Logger -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal chardet_type: Any @@ -77,7 +77,7 @@ class UnicodeDammit: @property def declared_html_encoding(self) -> str | None: ... def find_codec(self, charset: str) -> str | None: ... - MS_CHARS: dict[bytes, str | Tuple[str, ...]] + MS_CHARS: dict[bytes, str | tuple[str, ...]] MS_CHARS_TO_ASCII: dict[bytes, str] WINDOWS_1252_TO_UTF8: dict[int, bytes] MULTIBYTE_MARKERS_AND_SIZES: list[tuple[int, int, int]] diff --git a/stubs/beautifulsoup4/bs4/element.pyi b/stubs/beautifulsoup4/bs4/element.pyi index 9e7b2d1c2a35..84d6f2f53d5a 100644 --- a/stubs/beautifulsoup4/bs4/element.pyi +++ b/stubs/beautifulsoup4/bs4/element.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Mapping from _typeshed import Self from collections.abc import Iterator -from typing import Any, Callable, Generic, Iterable, List, Mapping, Pattern, Tuple, Type, TypeVar, Union, overload +from typing import Any, Generic, Pattern, Type, TypeVar, Union, overload from . import BeautifulSoup from .builder import TreeBuilder @@ -53,7 +54,7 @@ class PageElement: previousSibling: PageElement | None @property def stripped_strings(self) -> Iterator[str]: ... - def get_text(self, separator: str = ..., strip: bool = ..., types: Tuple[Type[NavigableString], ...] = ...) -> str: ... + def get_text(self, separator: str = ..., strip: bool = ..., types: tuple[Type[NavigableString], ...] = ...) -> str: ... getText = get_text @property def text(self) -> str: ... @@ -256,7 +257,7 @@ class Tag(PageElement): can_be_empty_element: bool | None = ..., cdata_list_attributes: list[str] | None = ..., preserve_whitespace_tags: list[str] | None = ..., - interesting_string_types: Type[NavigableString] | Tuple[Type[NavigableString], ...] | None = ..., + interesting_string_types: Type[NavigableString] | tuple[Type[NavigableString], ...] | None = ..., ) -> None: ... parserClass: Type[BeautifulSoup] | None def __copy__(self: Self) -> Self: ... @@ -267,7 +268,7 @@ class Tag(PageElement): def string(self) -> str | None: ... @string.setter def string(self, string: str) -> None: ... - DEFAULT_INTERESTING_STRING_TYPES: Tuple[Type[NavigableString], ...] + DEFAULT_INTERESTING_STRING_TYPES: tuple[Type[NavigableString], ...] @property def strings(self) -> Iterable[str]: ... def decompose(self) -> None: ... @@ -348,6 +349,6 @@ class SoupStrainer: searchTag = search_tag def search(self, markup: PageElement | Iterable[PageElement]): ... -class ResultSet(List[_PageElementT], Generic[_PageElementT]): +class ResultSet(list[_PageElementT], Generic[_PageElementT]): source: SoupStrainer def __init__(self, source: SoupStrainer, result: Iterable[_PageElementT] = ...) -> None: ... diff --git a/stubs/beautifulsoup4/bs4/formatter.pyi b/stubs/beautifulsoup4/bs4/formatter.pyi index 4250419fdc47..7f39f1b1aab4 100644 --- a/stubs/beautifulsoup4/bs4/formatter.pyi +++ b/stubs/beautifulsoup4/bs4/formatter.pyi @@ -1,4 +1,5 @@ -from typing import Callable +from collections.abc import Callable + from .dammit import EntitySubstitution as EntitySubstitution diff --git a/stubs/bleach/bleach/sanitizer.pyi b/stubs/bleach/bleach/sanitizer.pyi index 0966af2096d6..4adf96e47194 100644 --- a/stubs/bleach/bleach/sanitizer.pyi +++ b/stubs/bleach/bleach/sanitizer.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Container, Iterable -from typing import Any, Dict, List, Pattern, Union +from typing import Any, Pattern, Union from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter @@ -39,8 +39,8 @@ class Cleaner(object): def clean(self, text: str) -> str: ... _AttributeFilter = Callable[[str, str, str], bool] -_AttributeDict = Union[Dict[str, Union[List[str], _AttributeFilter]], Dict[str, List[str]], Dict[str, _AttributeFilter]] -_Attributes = Union[_AttributeFilter, _AttributeDict, List[str]] +_AttributeDict = Union[dict[str, Union[list[str], _AttributeFilter]], dict[str, list[str]], dict[str, _AttributeFilter]] +_Attributes = Union[_AttributeFilter, _AttributeDict, list[str]] def attribute_filter_factory(attributes: _Attributes) -> _AttributeFilter: ... diff --git a/stubs/boto/boto/kms/layer1.pyi b/stubs/boto/boto/kms/layer1.pyi index e2755233678d..3ef359fd1a94 100644 --- a/stubs/boto/boto/kms/layer1.pyi +++ b/stubs/boto/boto/kms/layer1.pyi @@ -1,4 +1,5 @@ -from typing import Any, Mapping, Type +from collections.abc import Mapping +from typing import Any, Type from boto.connection import AWSQueryConnection diff --git a/stubs/boto/boto/s3/bucketlistresultset.pyi b/stubs/boto/boto/s3/bucketlistresultset.pyi index e327ac42404c..258af6c35967 100644 --- a/stubs/boto/boto/s3/bucketlistresultset.pyi +++ b/stubs/boto/boto/s3/bucketlistresultset.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Iterator +from collections.abc import Iterable, Iterator +from typing import Any from .key import Key diff --git a/stubs/boto/boto/s3/cors.pyi b/stubs/boto/boto/s3/cors.pyi index f31e612f748d..125587f9ba0e 100644 --- a/stubs/boto/boto/s3/cors.pyi +++ b/stubs/boto/boto/s3/cors.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class CORSRule: allowed_method: Any @@ -20,7 +20,7 @@ class CORSRule: def endElement(self, name, value, connection): ... def to_xml(self) -> str: ... -class CORSConfiguration(List[CORSRule]): +class CORSConfiguration(list[CORSRule]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self) -> str: ... diff --git a/stubs/boto/boto/s3/key.pyi b/stubs/boto/boto/s3/key.pyi index 1a8b365a2604..3b6d49648e98 100644 --- a/stubs/boto/boto/s3/key.pyi +++ b/stubs/boto/boto/s3/key.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Text, overload +from collections.abc import Callable +from typing import Any, Text, overload class Key: DefaultContentType: str diff --git a/stubs/boto/boto/s3/lifecycle.pyi b/stubs/boto/boto/s3/lifecycle.pyi index bf750bb2e50f..7919bad712df 100644 --- a/stubs/boto/boto/s3/lifecycle.pyi +++ b/stubs/boto/boto/s3/lifecycle.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class Rule: id: Any @@ -33,7 +33,7 @@ class Transition: def __init__(self, days: Any | None = ..., date: Any | None = ..., storage_class: Any | None = ...) -> None: ... def to_xml(self): ... -class Transitions(List[Transition]): +class Transitions(list[Transition]): transition_properties: int current_transition_property: int temp_days: Any @@ -51,7 +51,7 @@ class Transitions(List[Transition]): @property def storage_class(self): ... -class Lifecycle(List[Rule]): +class Lifecycle(list[Rule]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... diff --git a/stubs/boto/boto/s3/tagging.pyi b/stubs/boto/boto/s3/tagging.pyi index ad1bcf8039f4..98a954d5fd8e 100644 --- a/stubs/boto/boto/s3/tagging.pyi +++ b/stubs/boto/boto/s3/tagging.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class Tag: key: Any @@ -9,13 +9,13 @@ class Tag: def to_xml(self): ... def __eq__(self, other): ... -class TagSet(List[Tag]): +class TagSet(list[Tag]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def add_tag(self, key, value): ... def to_xml(self): ... -class Tags(List[TagSet]): +class Tags(list[TagSet]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... diff --git a/stubs/boto/boto/s3/website.pyi b/stubs/boto/boto/s3/website.pyi index 186afdf1fdd1..e913f6dde791 100644 --- a/stubs/boto/boto/s3/website.pyi +++ b/stubs/boto/boto/s3/website.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any def tag(key, value): ... @@ -33,7 +33,7 @@ class RedirectLocation(_XMLKeyValue): def __init__(self, hostname: Any | None = ..., protocol: Any | None = ...) -> None: ... def to_xml(self): ... -class RoutingRules(List[RoutingRule]): +class RoutingRules(list[RoutingRule]): def add_rule(self, rule: RoutingRule) -> RoutingRules: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 3e650b1fea31..9e4994eac4d3 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -1,9 +1,10 @@ +from collections.abc import Callable, Iterable, Mapping, Sequence import datetime import logging.handlers import subprocess import sys import time -from typing import IO, Any, Callable, ContextManager, Dict, Iterable, Mapping, Sequence, Type, TypeVar +from typing import IO, Any, ContextManager, Type, TypeVar import boto.connection @@ -50,7 +51,7 @@ def merge_meta( def get_aws_metadata(headers: Mapping[str, str], provider: _Provider | None = ...) -> Mapping[str, str]: ... def retry_url(url: str, retry_on_404: bool = ..., num_retries: int = ..., timeout: int | None = ...) -> str: ... -class LazyLoadMetadata(Dict[_KT, _VT]): +class LazyLoadMetadata(dict[_KT, _VT]): def __init__(self, url: str, num_retries: int, timeout: int | None = ...) -> None: ... def get_instance_metadata( @@ -101,7 +102,7 @@ class AuthSMTPHandler(logging.handlers.SMTPHandler): self, mailhost: str, username: str, password: str, fromaddr: str, toaddrs: Sequence[str], subject: str ) -> None: ... -class LRUCache(Dict[_KT, _VT]): +class LRUCache(dict[_KT, _VT]): class _Item: previous: LRUCache._Item | None next: LRUCache._Item | None diff --git a/stubs/cachetools/cachetools/__init__.pyi b/stubs/cachetools/cachetools/__init__.pyi index 06088cadd40a..0f083bd25e01 100644 --- a/stubs/cachetools/cachetools/__init__.pyi +++ b/stubs/cachetools/cachetools/__init__.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, MutableMapping from _typeshed import IdentityFunction from collections.abc import Iterator, Sequence from contextlib import AbstractContextManager -from typing import Any, Callable, Generic, MutableMapping, TypeVar, overload +from typing import Any, Generic, TypeVar, overload _KT = TypeVar("_KT") _VT = TypeVar("_VT") diff --git a/stubs/cachetools/cachetools/func.pyi b/stubs/cachetools/cachetools/func.pyi index d081d5166316..349dde8d6d89 100644 --- a/stubs/cachetools/cachetools/func.pyi +++ b/stubs/cachetools/cachetools/func.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Sequence from _typeshed import IdentityFunction -from typing import Callable, Sequence, TypeVar +from typing import TypeVar _T = TypeVar("_T") diff --git a/stubs/cachetools/cachetools/keys.pyi b/stubs/cachetools/cachetools/keys.pyi index 9effbe6e171f..5a43d2a0b970 100644 --- a/stubs/cachetools/cachetools/keys.pyi +++ b/stubs/cachetools/cachetools/keys.pyi @@ -1,4 +1,5 @@ -from typing import Hashable, Tuple +from collections.abc import Hashable -def hashkey(*args: Hashable, **kwargs: Hashable) -> Tuple[Hashable, ...]: ... -def typedkey(*args: Hashable, **kwargs: Hashable) -> Tuple[Hashable, ...]: ... + +def hashkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... +def typedkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... diff --git a/stubs/characteristic/characteristic/__init__.pyi b/stubs/characteristic/characteristic/__init__.pyi index 08056c3e6c07..7050510d89fb 100644 --- a/stubs/characteristic/characteristic/__init__.pyi +++ b/stubs/characteristic/characteristic/__init__.pyi @@ -1,4 +1,5 @@ -from typing import Any, AnyStr, Callable, Sequence, Type, TypeVar +from collections.abc import Callable, Sequence +from typing import Any, AnyStr, Type, TypeVar def with_repr(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... def with_cmp(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... diff --git a/stubs/chardet/chardet/__init__.pyi b/stubs/chardet/chardet/__init__.pyi index 54e48f5c7233..7f883dabaf7b 100644 --- a/stubs/chardet/chardet/__init__.pyi +++ b/stubs/chardet/chardet/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Tuple +from typing import Any from .universaldetector import UniversalDetector as UniversalDetector @@ -11,16 +11,16 @@ else: from typing_extensions import TypedDict class _LangModelType(TypedDict): - char_to_order_map: Tuple[int, ...] - precedence_matrix: Tuple[int, ...] + char_to_order_map: tuple[int, ...] + precedence_matrix: tuple[int, ...] typical_positive_ratio: float keep_english_letter: bool charset_name: str language: str class _SMModelType(TypedDict): - class_table: Tuple[int, ...] + class_table: tuple[int, ...] class_factor: int - state_table: Tuple[int, ...] - char_len_table: Tuple[int, ...] + state_table: tuple[int, ...] + char_len_table: tuple[int, ...] name: str diff --git a/stubs/chardet/chardet/langbulgarianmodel.pyi b/stubs/chardet/chardet/langbulgarianmodel.pyi index de07cfa7b1b4..1ff0ded19c25 100644 --- a/stubs/chardet/chardet/langbulgarianmodel.pyi +++ b/stubs/chardet/chardet/langbulgarianmodel.pyi @@ -1,9 +1,9 @@ -from typing import Tuple + from . import _LangModelType -Latin5_BulgarianCharToOrderMap: Tuple[int, ...] -win1251BulgarianCharToOrderMap: Tuple[int, ...] -BulgarianLangModel: Tuple[int, ...] +Latin5_BulgarianCharToOrderMap: tuple[int, ...] +win1251BulgarianCharToOrderMap: tuple[int, ...] +BulgarianLangModel: tuple[int, ...] Latin5BulgarianModel: _LangModelType Win1251BulgarianModel: _LangModelType diff --git a/stubs/chardet/chardet/langcyrillicmodel.pyi b/stubs/chardet/chardet/langcyrillicmodel.pyi index 40a7044b1398..8f7997d04099 100644 --- a/stubs/chardet/chardet/langcyrillicmodel.pyi +++ b/stubs/chardet/chardet/langcyrillicmodel.pyi @@ -1,14 +1,14 @@ -from typing import Tuple + from . import _LangModelType -KOI8R_char_to_order_map: Tuple[int, ...] -win1251_char_to_order_map: Tuple[int, ...] -latin5_char_to_order_map: Tuple[int, ...] -macCyrillic_char_to_order_map: Tuple[int, ...] -IBM855_char_to_order_map: Tuple[int, ...] -IBM866_char_to_order_map: Tuple[int, ...] -RussianLangModel: Tuple[int, ...] +KOI8R_char_to_order_map: tuple[int, ...] +win1251_char_to_order_map: tuple[int, ...] +latin5_char_to_order_map: tuple[int, ...] +macCyrillic_char_to_order_map: tuple[int, ...] +IBM855_char_to_order_map: tuple[int, ...] +IBM866_char_to_order_map: tuple[int, ...] +RussianLangModel: tuple[int, ...] Koi8rModel: _LangModelType Win1251CyrillicModel: _LangModelType Latin5CyrillicModel: _LangModelType diff --git a/stubs/chardet/chardet/langgreekmodel.pyi b/stubs/chardet/chardet/langgreekmodel.pyi index f0fa3e8c21d3..05c1f4f310a9 100644 --- a/stubs/chardet/chardet/langgreekmodel.pyi +++ b/stubs/chardet/chardet/langgreekmodel.pyi @@ -1,9 +1,9 @@ -from typing import Tuple + from . import _LangModelType -Latin7_char_to_order_map: Tuple[int, ...] -win1253_char_to_order_map: Tuple[int, ...] -GreekLangModel: Tuple[int, ...] +Latin7_char_to_order_map: tuple[int, ...] +win1253_char_to_order_map: tuple[int, ...] +GreekLangModel: tuple[int, ...] Latin7GreekModel: _LangModelType Win1253GreekModel: _LangModelType diff --git a/stubs/chardet/chardet/langhebrewmodel.pyi b/stubs/chardet/chardet/langhebrewmodel.pyi index 08bfbc91bf26..a228d9c2aac5 100644 --- a/stubs/chardet/chardet/langhebrewmodel.pyi +++ b/stubs/chardet/chardet/langhebrewmodel.pyi @@ -1,7 +1,7 @@ -from typing import Tuple + from . import _LangModelType -WIN1255_CHAR_TO_ORDER_MAP: Tuple[int, ...] -HEBREW_LANG_MODEL: Tuple[int, ...] +WIN1255_CHAR_TO_ORDER_MAP: tuple[int, ...] +HEBREW_LANG_MODEL: tuple[int, ...] Win1255HebrewModel: _LangModelType diff --git a/stubs/chardet/chardet/langhungarianmodel.pyi b/stubs/chardet/chardet/langhungarianmodel.pyi index 01e4a44380c2..23875c22ec59 100644 --- a/stubs/chardet/chardet/langhungarianmodel.pyi +++ b/stubs/chardet/chardet/langhungarianmodel.pyi @@ -1,9 +1,9 @@ -from typing import Tuple + from . import _LangModelType -Latin2_HungarianCharToOrderMap: Tuple[int, ...] -win1250HungarianCharToOrderMap: Tuple[int, ...] -HungarianLangModel: Tuple[int, ...] +Latin2_HungarianCharToOrderMap: tuple[int, ...] +win1250HungarianCharToOrderMap: tuple[int, ...] +HungarianLangModel: tuple[int, ...] Latin2HungarianModel: _LangModelType Win1250HungarianModel: _LangModelType diff --git a/stubs/chardet/chardet/langthaimodel.pyi b/stubs/chardet/chardet/langthaimodel.pyi index 93149e72b16c..d52281bb5b9e 100644 --- a/stubs/chardet/chardet/langthaimodel.pyi +++ b/stubs/chardet/chardet/langthaimodel.pyi @@ -1,7 +1,7 @@ -from typing import Tuple + from . import _LangModelType -TIS620CharToOrderMap: Tuple[int, ...] -ThaiLangModel: Tuple[int, ...] +TIS620CharToOrderMap: tuple[int, ...] +ThaiLangModel: tuple[int, ...] TIS620ThaiModel: _LangModelType diff --git a/stubs/chardet/chardet/langturkishmodel.pyi b/stubs/chardet/chardet/langturkishmodel.pyi index 65b1bdcbbe2d..d5f614174a86 100644 --- a/stubs/chardet/chardet/langturkishmodel.pyi +++ b/stubs/chardet/chardet/langturkishmodel.pyi @@ -1,7 +1,7 @@ -from typing import Tuple + from . import _LangModelType -Latin5_TurkishCharToOrderMap: Tuple[int, ...] -TurkishLangModel: Tuple[int, ...] +Latin5_TurkishCharToOrderMap: tuple[int, ...] +TurkishLangModel: tuple[int, ...] Latin5TurkishModel: _LangModelType diff --git a/stubs/click-spinner/click_spinner/__init__.pyi b/stubs/click-spinner/click_spinner/__init__.pyi index 6ddb0e8f42fd..01012e37a51c 100644 --- a/stubs/click-spinner/click_spinner/__init__.pyi +++ b/stubs/click-spinner/click_spinner/__init__.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterator import threading from types import TracebackType -from typing import Iterator, Protocol, Type +from typing import Protocol, Type from typing_extensions import Literal __version__: str diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index 117fe8f6265c..dbdb6315dc7b 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Sequence import sys from _typeshed import SupportsWrite -from typing import Any, Callable, Dict, Optional, Pattern, Sequence, TextIO, Tuple, Union +from typing import Any, Optional, Pattern, TextIO, Union if sys.platform == "win32": from .winterm import WinTerm @@ -20,7 +21,7 @@ class StreamWrapper: def closed(self) -> bool: ... _WinTermCall = Callable[[Optional[int], bool, bool], None] -_WinTermCallDict = Dict[int, Union[Tuple[_WinTermCall], Tuple[_WinTermCall, int], Tuple[_WinTermCall, int, bool]]] +_WinTermCallDict = dict[int, Union[tuple[_WinTermCall], tuple[_WinTermCall, int], tuple[_WinTermCall, int, bool]]] class AnsiToWin32: ANSI_CSI_RE: Pattern[str] = ... @@ -40,6 +41,6 @@ class AnsiToWin32: def write_and_convert(self, text: str) -> None: ... def write_plain_text(self, text: str, start: int, end: int) -> None: ... def convert_ansi(self, paramstring: str, command: str) -> None: ... - def extract_params(self, command: str, paramstring: str) -> Tuple[int, ...]: ... + def extract_params(self, command: str, paramstring: str) -> tuple[int, ...]: ... def call_win32(self, command: str, params: Sequence[int]) -> None: ... def convert_osc(self, text: str) -> str: ... diff --git a/stubs/colorama/colorama/win32.pyi b/stubs/colorama/colorama/win32.pyi index 37e6a0b99f9d..a169c6b2d331 100644 --- a/stubs/colorama/colorama/win32.pyi +++ b/stubs/colorama/colorama/win32.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable import sys -from typing import Callable + from typing_extensions import Literal STDOUT: Literal[-11] diff --git a/stubs/contextvars/contextvars.pyi b/stubs/contextvars/contextvars.pyi index 429d2037afb2..ffeefc7a326e 100644 --- a/stubs/contextvars/contextvars.pyi +++ b/stubs/contextvars/contextvars.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterator, Mapping import sys -from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar +from typing import Any, ClassVar, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stubs/croniter/croniter.pyi b/stubs/croniter/croniter.pyi index 820e0ee50a42..b12530a8ee24 100644 --- a/stubs/croniter/croniter.pyi +++ b/stubs/croniter/croniter.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterator import datetime -from typing import Any, Iterator, Text, Tuple, Type, TypeVar, Union +from typing import Any, Text, Type, TypeVar, Union from typing_extensions import Literal _RetType = Union[Type[float], Type[datetime.datetime]] @@ -12,7 +13,7 @@ class CroniterNotAlphaError(CroniterError): ... class croniter(Iterator[Any]): MONTHS_IN_YEAR: Literal[12] - RANGES: Tuple[tuple[int, int], ...] + RANGES: tuple[tuple[int, int], ...] DAYS: tuple[ Literal[31], Literal[28], @@ -27,9 +28,9 @@ class croniter(Iterator[Any]): Literal[30], Literal[31], ] - ALPHACONV: Tuple[dict[str, Any], ...] - LOWMAP: Tuple[dict[int, Any], ...] - LEN_MEANS_ALL: Tuple[int, ...] + ALPHACONV: tuple[dict[str, Any], ...] + LOWMAP: tuple[dict[int, Any], ...] + LEN_MEANS_ALL: tuple[int, ...] bad_length: str tzinfo: datetime.tzinfo | None cur: float diff --git a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi index c403282f3df2..3bf5678a4f48 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable from enum import Enum -from typing import Any, Iterable +from typing import Any from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index be3b7bdabd3f..6bd125cab935 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -1,8 +1,9 @@ +from collections.abc import Generator, Iterable, Sequence import datetime from abc import ABCMeta, abstractmethod from enum import Enum from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network -from typing import Any, ClassVar, Generator, Generic, Iterable, Sequence, Text, Type, TypeVar +from typing import Any, ClassVar, Generic, Text, Type, TypeVar from cryptography.hazmat.backends.interfaces import X509Backend from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey diff --git a/stubs/cryptography/cryptography/x509/extensions.pyi b/stubs/cryptography/cryptography/x509/extensions.pyi index a9b2ad08b530..c8c81d392215 100644 --- a/stubs/cryptography/cryptography/x509/extensions.pyi +++ b/stubs/cryptography/cryptography/x509/extensions.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator +from collections.abc import Iterator +from typing import Any from cryptography.x509 import GeneralName, ObjectIdentifier diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index a76db82bd6ac..65a14506b4a5 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable, Mapping import sys -from typing import Any, Callable, Generic, Iterable, Mapping, Tuple, Type, TypeVar, overload +from typing import Any, Generic, Type, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -15,7 +16,7 @@ def asdict(obj: Any) -> dict[str, Any]: ... @overload def asdict(obj: Any, *, dict_factory: Callable[[list[tuple[str, Any]]], _T]) -> _T: ... @overload -def astuple(obj: Any) -> Tuple[Any, ...]: ... +def astuple(obj: Any) -> tuple[Any, ...]: ... @overload def astuple(obj: Any, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ... @overload @@ -66,7 +67,7 @@ def field( def field( *, init: bool = ..., repr: bool = ..., hash: bool | None = ..., compare: bool = ..., metadata: Mapping[str, Any] | None = ... ) -> Any: ... -def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... +def fields(class_or_instance: Any) -> tuple[Field[Any], ...]: ... def is_dataclass(obj: Any) -> bool: ... class FrozenInstanceError(AttributeError): ... @@ -79,7 +80,7 @@ def make_dataclass( cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., diff --git a/stubs/dateparser/dateparser/date.pyi b/stubs/dateparser/dateparser/date.pyi index cc5118dcedb9..198d3e017c72 100644 --- a/stubs/dateparser/dateparser/date.pyi +++ b/stubs/dateparser/dateparser/date.pyi @@ -1,8 +1,9 @@ +from collections.abc import Iterable, Iterator import collections import sys from _typeshed import Self as Self from datetime import datetime -from typing import ClassVar, Iterable, Iterator, Type, overload +from typing import ClassVar, Type, overload from dateparser import _Settings from dateparser.conf import Settings diff --git a/stubs/dateparser/dateparser/languages/loader.pyi b/stubs/dateparser/dateparser/languages/loader.pyi index 8eaa38c77b08..c8010bec4fd3 100644 --- a/stubs/dateparser/dateparser/languages/loader.pyi +++ b/stubs/dateparser/dateparser/languages/loader.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterator from collections import OrderedDict -from typing import Any, Iterator +from typing import Any from .locale import Locale diff --git a/stubs/dateparser/dateparser/search/__init__.pyi b/stubs/dateparser/dateparser/search/__init__.pyi index e14bcc05f634..10a2f4c922c3 100644 --- a/stubs/dateparser/dateparser/search/__init__.pyi +++ b/stubs/dateparser/dateparser/search/__init__.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Mapping, Set from datetime import datetime -from typing import Any, Tuple, overload +from typing import Any, overload if sys.version_info >= (3, 8): from typing import Literal @@ -11,14 +11,14 @@ else: @overload def search_dates( text: str, - languages: list[str] | Tuple[str, ...] | Set[str] | None, + languages: list[str] | tuple[str, ...] | Set[str] | None, settings: Mapping[Any, Any] | None, add_detected_language: Literal[True], ) -> list[tuple[str, datetime, str]]: ... @overload def search_dates( text: str, - languages: list[str] | Tuple[str, ...] | Set[str] | None = ..., + languages: list[str] | tuple[str, ...] | Set[str] | None = ..., settings: Mapping[Any, Any] | None = ..., add_detected_language: Literal[False] = ..., ) -> list[tuple[str, datetime]]: ... diff --git a/stubs/dateparser/dateparser/utils/__init__.pyi b/stubs/dateparser/dateparser/utils/__init__.pyi index 1dd81898563c..9d7c636e43aa 100644 --- a/stubs/dateparser/dateparser/utils/__init__.pyi +++ b/stubs/dateparser/dateparser/utils/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping from collections import OrderedDict -from typing import Any, Mapping +from typing import Any def strip_braces(date_string: str) -> str: ... def normalize_unicode(string: str, form: str = ...) -> str: ... diff --git a/stubs/decorator/decorator.pyi b/stubs/decorator/decorator.pyi index 0d50a5412a1d..c17ca7f26f5b 100644 --- a/stubs/decorator/decorator.pyi +++ b/stubs/decorator/decorator.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterator import sys -from typing import Any, Callable, Iterator, NamedTuple, Pattern, Text, Tuple, TypeVar +from typing import Any, NamedTuple, Pattern, Text, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) _Func = TypeVar("_Func", bound=Callable[..., Any]) @@ -14,7 +15,7 @@ else: args: list[str] varargs: str | None varkw: str | None - defaults: Tuple[Any, ...] + defaults: tuple[Any, ...] kwonlyargs: list[str] kwonlydefaults: dict[str, Any] annotations: dict[str, Any] @@ -34,7 +35,7 @@ class FunctionMaker(object): args: list[Text] varargs: Text | None varkw: Text | None - defaults: Tuple[Any, ...] + defaults: tuple[Any, ...] kwonlyargs: list[Text] kwonlydefaults: Text | None shortsignature: Text | None @@ -49,7 +50,7 @@ class FunctionMaker(object): func: Callable[..., Any] | None = ..., name: Text | None = ..., signature: Text | None = ..., - defaults: Tuple[Any, ...] | None = ..., + defaults: tuple[Any, ...] | None = ..., doc: Text | None = ..., module: Text | None = ..., funcdict: _dict[Text, Any] | None = ..., @@ -64,7 +65,7 @@ class FunctionMaker(object): obj: Any, body: Text, evaldict: _dict[Text, Any], - defaults: Tuple[Any, ...] | None = ..., + defaults: tuple[Any, ...] | None = ..., doc: Text | None = ..., module: Text | None = ..., addsource: bool = ..., diff --git a/stubs/docopt/docopt.pyi b/stubs/docopt/docopt.pyi index 7f7bba6a7e69..820ab1e97758 100644 --- a/stubs/docopt/docopt.pyi +++ b/stubs/docopt/docopt.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Union +from collections.abc import Iterable +from typing import Any, Union __version__: str diff --git a/stubs/docutils/docutils/__init__.pyi b/stubs/docutils/docutils/__init__.pyi index d4477b9624b0..4a113c725fa4 100644 --- a/stubs/docutils/docutils/__init__.pyi +++ b/stubs/docutils/docutils/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, NamedTuple, Tuple +from typing import Any, ClassVar, NamedTuple __docformat__: str __version__: str @@ -23,19 +23,19 @@ class ApplicationError(Exception): ... class DataError(ApplicationError): ... class SettingsSpec: - settings_spec: ClassVar[Tuple[Any, ...]] + settings_spec: ClassVar[tuple[Any, ...]] settings_defaults: ClassVar[dict[Any, Any] | None] settings_default_overrides: ClassVar[dict[Any, Any] | None] - relative_path_settings: ClassVar[Tuple[Any, ...]] + relative_path_settings: ClassVar[tuple[Any, ...]] config_section: ClassVar[str | None] - config_section_dependencies: ClassVar[Tuple[str, ...] | None] + config_section_dependencies: ClassVar[tuple[str, ...] | None] class TransformSpec: def get_transforms(self) -> list[Any]: ... - default_transforms: ClassVar[Tuple[Any, ...]] + default_transforms: ClassVar[tuple[Any, ...]] unknown_reference_resolvers: ClassVar[list[Any]] class Component(SettingsSpec, TransformSpec): component_type: ClassVar[str | None] - supported: ClassVar[Tuple[str, ...]] + supported: ClassVar[tuple[str, ...]] def supports(self, format: str) -> bool: ... diff --git a/stubs/docutils/docutils/frontend.pyi b/stubs/docutils/docutils/frontend.pyi index c32dc44ffb5e..0ec65862916f 100644 --- a/stubs/docutils/docutils/frontend.pyi +++ b/stubs/docutils/docutils/frontend.pyi @@ -1,7 +1,7 @@ import optparse from collections.abc import Iterable, Mapping from configparser import RawConfigParser -from typing import Any, ClassVar, Tuple, Type +from typing import Any, ClassVar, Type from docutils import SettingsSpec from docutils.parsers import Parser @@ -45,7 +45,7 @@ def validate_smartquotes_locales( ) -> list[tuple[str, str]]: ... def make_paths_absolute(pathdict, keys, base_path: Any | None = ...) -> None: ... def make_one_path_absolute(base_path, path) -> str: ... -def filter_settings_spec(settings_spec, *exclude, **replace) -> Tuple[Any, ...]: ... +def filter_settings_spec(settings_spec, *exclude, **replace) -> tuple[Any, ...]: ... class Values(optparse.Values): def update(self, other_dict, option_parser) -> None: ... diff --git a/stubs/docutils/docutils/parsers/null.pyi b/stubs/docutils/docutils/parsers/null.pyi index 1d3629109243..edc977325a1d 100644 --- a/stubs/docutils/docutils/parsers/null.pyi +++ b/stubs/docutils/docutils/parsers/null.pyi @@ -1,6 +1,6 @@ -from typing import ClassVar, Tuple +from typing import ClassVar from docutils import parsers class Parser(parsers.Parser): - config_section_dependencies: ClassVar[Tuple[str, ...]] + config_section_dependencies: ClassVar[tuple[str, ...]] diff --git a/stubs/docutils/docutils/parsers/rst/__init__.pyi b/stubs/docutils/docutils/parsers/rst/__init__.pyi index f605176c4173..b9cc02940ce0 100644 --- a/stubs/docutils/docutils/parsers/rst/__init__.pyi +++ b/stubs/docutils/docutils/parsers/rst/__init__.pyi @@ -1,11 +1,11 @@ -from typing import Any, ClassVar, Tuple +from typing import Any, ClassVar from typing_extensions import Literal from docutils import parsers from docutils.parsers.rst import states class Parser(parsers.Parser): - config_section_dependencies: ClassVar[Tuple[str, ...]] + config_section_dependencies: ClassVar[tuple[str, ...]] initial_state: Literal["Body", "RFC2822Body"] state_classes: Any inliner: Any diff --git a/stubs/docutils/docutils/parsers/rst/roles.pyi b/stubs/docutils/docutils/parsers/rst/roles.pyi index 2c3d65b68c94..6742726ad03a 100644 --- a/stubs/docutils/docutils/parsers/rst/roles.pyi +++ b/stubs/docutils/docutils/parsers/rst/roles.pyi @@ -1,11 +1,12 @@ -from typing import Any, Callable, Dict, List, Tuple +from collections.abc import Callable +from typing import Any import docutils.nodes import docutils.parsers.rst.states _RoleFn = Callable[ - [str, str, str, int, docutils.parsers.rst.states.Inliner, Dict[str, Any], List[str]], - Tuple[List[docutils.nodes.reference], List[docutils.nodes.reference]], + [str, str, str, int, docutils.parsers.rst.states.Inliner, dict[str, Any], list[str]], + tuple[list[docutils.nodes.reference], list[docutils.nodes.reference]], ] def register_local_role(name: str, role_fn: _RoleFn) -> None: ... diff --git a/stubs/editdistance/editdistance.pyi b/stubs/editdistance/editdistance.pyi index 082b0acc0f3b..9ecabaea63c6 100644 --- a/stubs/editdistance/editdistance.pyi +++ b/stubs/editdistance/editdistance.pyi @@ -1,4 +1,5 @@ -from typing import Hashable, Iterable +from collections.abc import Hashable, Iterable + def eval(a: Iterable[Hashable], b: Iterable[Hashable]) -> int: ... def distance(a: Iterable[Hashable], b: Iterable[Hashable]) -> int: ... diff --git a/stubs/entrypoints/entrypoints.pyi b/stubs/entrypoints/entrypoints.pyi index 8b64db4c78cc..c0adfb883d05 100644 --- a/stubs/entrypoints/entrypoints.pyi +++ b/stubs/entrypoints/entrypoints.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterator, Sequence import sys from _typeshed import Self -from typing import Any, Iterator, Sequence, Text, Type +from typing import Any, Text, Type if sys.version_info >= (3, 0): from configparser import ConfigParser diff --git a/stubs/first/first.pyi b/stubs/first/first.pyi index 2306d521be3c..d2e894151349 100644 --- a/stubs/first/first.pyi +++ b/stubs/first/first.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Iterable, TypeVar, overload +from collections.abc import Callable, Iterable +from typing import Any, TypeVar, overload _T = TypeVar("_T") _S = TypeVar("_S") diff --git a/stubs/flake8-2020/flake8_2020.pyi b/stubs/flake8-2020/flake8_2020.pyi index 3577b66a6d12..b4ec565ef343 100644 --- a/stubs/flake8-2020/flake8_2020.pyi +++ b/stubs/flake8-2020/flake8_2020.pyi @@ -2,8 +2,9 @@ # This PEP does not support distributing typing information as part of module-only distributions or single-file modules within namespace packages. # Therefore typeshed is the best place. +from collections.abc import Generator import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Type class Plugin: name: ClassVar[str] diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index b435e5bcecda..bae16350b7a0 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -1,6 +1,7 @@ +from collections.abc import Sequence import argparse import ast -from typing import Any, Sequence +from typing import Any class BugBearChecker: name: str diff --git a/stubs/flake8-builtins/flake8_builtins.pyi b/stubs/flake8-builtins/flake8_builtins.pyi index e5a3d89c5f11..471841a23139 100644 --- a/stubs/flake8-builtins/flake8_builtins.pyi +++ b/stubs/flake8-builtins/flake8_builtins.pyi @@ -1,5 +1,6 @@ +from collections.abc import Generator import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Type class BuiltinsChecker: name: ClassVar[str] diff --git a/stubs/flake8-docstrings/flake8_docstrings.pyi b/stubs/flake8-docstrings/flake8_docstrings.pyi index bd8621cfec95..263c9fc6d888 100644 --- a/stubs/flake8-docstrings/flake8_docstrings.pyi +++ b/stubs/flake8-docstrings/flake8_docstrings.pyi @@ -1,6 +1,7 @@ +from collections.abc import Generator, Iterable import argparse import ast -from typing import Any, ClassVar, Generator, Iterable, Type +from typing import Any, ClassVar, Type class pep257Checker: name: ClassVar[str] diff --git a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi index 066a43e538c5..0ba060fef518 100644 --- a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi +++ b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi @@ -1,8 +1,9 @@ +from collections.abc import Iterable, Iterator import argparse import ast -from typing import Any, Generic, Iterable, Iterator, Tuple, Type, TypeVar +from typing import Any, Generic, Type, TypeVar -FLAKE8_ERROR = Tuple[int, int, str, Type[Any]] +FLAKE8_ERROR = tuple[int, int, str, Type[Any]] TConfig = TypeVar("TConfig") # noqa: Y001 class Error: diff --git a/stubs/flake8-simplify/flake8_simplify.pyi b/stubs/flake8-simplify/flake8_simplify.pyi index 0d5e35b60672..40f652c1293e 100644 --- a/stubs/flake8-simplify/flake8_simplify.pyi +++ b/stubs/flake8-simplify/flake8_simplify.pyi @@ -1,5 +1,6 @@ +from collections.abc import Generator import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Type class Plugin: name: ClassVar[str] diff --git a/stubs/flake8-typing-imports/flake8_typing_imports.pyi b/stubs/flake8-typing-imports/flake8_typing_imports.pyi index 04585966849f..b5a0da29047e 100644 --- a/stubs/flake8-typing-imports/flake8_typing_imports.pyi +++ b/stubs/flake8-typing-imports/flake8_typing_imports.pyi @@ -1,6 +1,7 @@ +from collections.abc import Generator import argparse import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Type class Plugin: name: ClassVar[str] diff --git a/stubs/fpdf2/fpdf/image_parsing.pyi b/stubs/fpdf2/fpdf/image_parsing.pyi index 6355b3adf3c2..14c4f4bcd261 100644 --- a/stubs/fpdf2/fpdf/image_parsing.pyi +++ b/stubs/fpdf2/fpdf/image_parsing.pyi @@ -1,9 +1,9 @@ -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal _ImageFilter = Literal["AUTO", "FlateDecode", "DCTDecode", "JPXDecode"] -SUPPORTED_IMAGE_FILTERS: Tuple[_ImageFilter, ...] +SUPPORTED_IMAGE_FILTERS: tuple[_ImageFilter, ...] def load_image(filename): ... diff --git a/stubs/fpdf2/fpdf/syntax.pyi b/stubs/fpdf2/fpdf/syntax.pyi index 54788032540a..838880de0794 100644 --- a/stubs/fpdf2/fpdf/syntax.pyi +++ b/stubs/fpdf2/fpdf/syntax.pyi @@ -1,5 +1,5 @@ from abc import ABC -from typing import Any, List +from typing import Any def clear_empty_fields(d): ... def create_dictionary_string( @@ -29,7 +29,7 @@ def camel_case(property_name): ... class PDFString(str): def serialize(self): ... -class PDFArray(List[Any]): +class PDFArray(list[Any]): def serialize(self): ... class Destination(ABC): diff --git a/stubs/fpdf2/fpdf/util.pyi b/stubs/fpdf2/fpdf/util.pyi index 0455c3f2a6b8..21b00796ab70 100644 --- a/stubs/fpdf2/fpdf/util.pyi +++ b/stubs/fpdf2/fpdf/util.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal _Unit = Literal["pt", "mm", "cm", "in"] @@ -14,5 +14,5 @@ def convert_unit( to_convert: float | Iterable[float | Iterable[Any]], old_unit: str | float, new_unit: str | float, -) -> float | Tuple[float, ...]: ... +) -> float | tuple[float, ...]: ... def dochecks() -> None: ... diff --git a/stubs/frozendict/frozendict.pyi b/stubs/frozendict/frozendict.pyi index 10c78c8e646d..7b5e31001bd6 100644 --- a/stubs/frozendict/frozendict.pyi +++ b/stubs/frozendict/frozendict.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Iterator, Mapping import collections -from typing import Any, Generic, Iterable, Iterator, Mapping, Type, TypeVar, overload +from typing import Any, Generic, Type, TypeVar, overload _S = TypeVar("_S") _KT = TypeVar("_KT") diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/context.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/context.pyi index bb3538fab21c..f912293fa5ec 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/context.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/context.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, NamedTuple +from collections.abc import Callable +from typing import Any, NamedTuple from google.cloud.ndb import Key, exceptions as exceptions diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi index 08d663f96e97..352f8ad5b3cd 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import datetime from collections.abc import Iterable, Sequence -from typing import Callable, NoReturn, Type +from typing import NoReturn, Type from typing_extensions import Literal from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 7ab8c8be9f23..942335cc1388 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -1,14 +1,15 @@ +from collections.abc import Sequence import decimal from _typeshed import ReadableBuffer from datetime import date, datetime, time -from typing import Any, Sequence, Tuple, Type, overload +from typing import Any, Type, overload from typing_extensions import Literal from .resultrow import ResultRow apilevel: str threadsafety: int -paramstyle: Tuple[str, ...] +paramstyle: tuple[str, ...] connect = Connection class Connection: @@ -44,19 +45,19 @@ class LOB: def read(self, size: int = ..., position: int = ...) -> str | bytes: ... def write(self, object: str | bytes) -> int: ... -_Parameters = Sequence[Tuple[Any, ...]] +_Parameters = Sequence[tuple[Any, ...]] class Cursor: - description: Tuple[Tuple[Any, ...], ...] + description: tuple[tuple[Any, ...], ...] rowcount: int statementhash: str | None connection: Connection arraysize: int def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def callproc(self, procname: str, parameters: Tuple[Any, ...] = ..., overview: bool = ...) -> Tuple[Any, ...]: ... + def callproc(self, procname: str, parameters: tuple[Any, ...] = ..., overview: bool = ...) -> tuple[Any, ...]: ... def close(self) -> None: ... - def description_ext(self) -> Sequence[Tuple[Any, ...]]: ... - def execute(self, operation: str, parameters: Tuple[Any, ...]) -> bool: ... + def description_ext(self) -> Sequence[tuple[Any, ...]]: ... + def execute(self, operation: str, parameters: tuple[Any, ...]) -> bool: ... def executemany(self, operation: str, parameters: _Parameters) -> Any: ... def executemanyprepared(self, parameters: _Parameters) -> Any: ... def executeprepared(self, parameters: _Parameters = ...) -> Any: ... @@ -67,7 +68,7 @@ class Cursor: def getwarning(self) -> Warning | None: ... def haswarning(self) -> bool: ... def nextset(self) -> None: ... - def parameter_description(self) -> Tuple[str, ...]: ... + def parameter_description(self) -> tuple[str, ...]: ... @overload def prepare(self, operation: str, newcursor: Literal[True]) -> Cursor: ... @overload diff --git a/stubs/hdbcli/hdbcli/resultrow.pyi b/stubs/hdbcli/hdbcli/resultrow.pyi index 02a02eca91d4..cf0ee12ecd88 100644 --- a/stubs/hdbcli/hdbcli/resultrow.pyi +++ b/stubs/hdbcli/hdbcli/resultrow.pyi @@ -1,6 +1,6 @@ -from typing import Any, Tuple +from typing import Any class ResultRow: def __init__(self, *args: Any, **kwargs: Any) -> None: ... - column_names: Tuple[str, ...] - column_values: Tuple[Any, ...] + column_names: tuple[str, ...] + column_values: tuple[Any, ...] diff --git a/stubs/html5lib/html5lib/_tokenizer.pyi b/stubs/html5lib/html5lib/_tokenizer.pyi index cf62e2ca65d9..fd9f6dac7caf 100644 --- a/stubs/html5lib/html5lib/_tokenizer.pyi +++ b/stubs/html5lib/html5lib/_tokenizer.pyi @@ -1,10 +1,10 @@ import sys from collections import OrderedDict -from typing import Any, Dict +from typing import Any entitiesTrie: Any if sys.version_info >= (3, 7): - attributeMap = Dict[Any, Any] + attributeMap = dict[Any, Any] else: attributeMap = OrderedDict[Any, Any] diff --git a/stubs/html5lib/html5lib/_utils.pyi b/stubs/html5lib/html5lib/_utils.pyi index c6f85f5a622f..1ea974392438 100644 --- a/stubs/html5lib/html5lib/_utils.pyi +++ b/stubs/html5lib/html5lib/_utils.pyi @@ -1,9 +1,9 @@ from collections.abc import Mapping -from typing import Any, Dict +from typing import Any supports_lone_surrogates: bool -class MethodDispatcher(Dict[Any, Any]): +class MethodDispatcher(dict[Any, Any]): default: Any def __init__(self, items=...) -> None: ... def __getitem__(self, key): ... diff --git a/stubs/html5lib/html5lib/treebuilders/base.pyi b/stubs/html5lib/html5lib/treebuilders/base.pyi index 12e89bb296d4..8c73d5257666 100644 --- a/stubs/html5lib/html5lib/treebuilders/base.pyi +++ b/stubs/html5lib/html5lib/treebuilders/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any Marker: Any listElementsMap: Any @@ -18,7 +18,7 @@ class Node: def cloneNode(self) -> None: ... def hasContent(self) -> None: ... -class ActiveFormattingElements(List[Any]): +class ActiveFormattingElements(list[Any]): def append(self, node) -> None: ... def nodesEqual(self, node1, node2): ... diff --git a/stubs/httplib2/httplib2/__init__.pyi b/stubs/httplib2/httplib2/__init__.pyi index 14bf1dba7af8..f1da1887fee3 100644 --- a/stubs/httplib2/httplib2/__init__.pyi +++ b/stubs/httplib2/httplib2/__init__.pyi @@ -1,6 +1,6 @@ import http.client from collections.abc import Generator -from typing import Any, Dict, TypeVar +from typing import Any, TypeVar from .error import * @@ -175,7 +175,7 @@ class Http: connection_type: Any | None = ..., ): ... -class Response(Dict[str, Any]): +class Response(dict[str, Any]): fromcache: bool version: int status: int diff --git a/stubs/jsonschema/jsonschema/_format.pyi b/stubs/jsonschema/jsonschema/_format.pyi index 492800ab5190..7a42455fbc4d 100644 --- a/stubs/jsonschema/jsonschema/_format.pyi +++ b/stubs/jsonschema/jsonschema/_format.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable +from collections.abc import Iterable +from typing import Any class FormatChecker: checkers: Any diff --git a/stubs/jsonschema/jsonschema/_legacy_validators.pyi b/stubs/jsonschema/jsonschema/_legacy_validators.pyi index 08a7dd5394ea..783d3e5b3820 100644 --- a/stubs/jsonschema/jsonschema/_legacy_validators.pyi +++ b/stubs/jsonschema/jsonschema/_legacy_validators.pyi @@ -1,4 +1,5 @@ -from typing import Any, ItemsView +from collections.abc import ItemsView +from typing import Any def ignore_ref_siblings(schema) -> list[tuple[str, Any]] | ItemsView[str, Any]: ... def dependencies_draft3(validator, dependencies, instance, schema) -> None: ... diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi index 5c97055445e0..17bfd3a17afc 100644 --- a/stubs/jsonschema/jsonschema/_types.pyi +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -1,4 +1,5 @@ -from typing import Callable, Iterable, Mapping +from collections.abc import Callable, Iterable, Mapping + def is_array(checker, instance) -> bool: ... def is_bool(checker, instance) -> bool: ... diff --git a/stubs/jsonschema/jsonschema/_utils.pyi b/stubs/jsonschema/jsonschema/_utils.pyi index 448be7e91cfa..c90ce15e8e08 100644 --- a/stubs/jsonschema/jsonschema/_utils.pyi +++ b/stubs/jsonschema/jsonschema/_utils.pyi @@ -1,4 +1,5 @@ -from typing import Any, Generator, Iterable, Mapping, MutableMapping, Sized +from collections.abc import Generator, Iterable, Mapping, MutableMapping, Sized +from typing import Any class URIDict(MutableMapping[Any, Any]): def normalize(self, uri: str) -> str: ... diff --git a/stubs/jsonschema/jsonschema/protocols.pyi b/stubs/jsonschema/jsonschema/protocols.pyi index 451e4ec67976..c25a8b3b052a 100644 --- a/stubs/jsonschema/jsonschema/protocols.pyi +++ b/stubs/jsonschema/jsonschema/protocols.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar, Iterator, Protocol +from collections.abc import Iterator +from typing import Any, ClassVar, Protocol from jsonschema._format import FormatChecker from jsonschema._types import TypeChecker diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi index 7829021784ac..dd4c12dc7187 100644 --- a/stubs/jsonschema/jsonschema/validators.pyi +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable +from collections.abc import Callable +from typing import Any def validates(version: str) -> Callable[..., Any]: ... def create(meta_schema, validators=..., version: Any | None = ..., type_checker=..., id_of=..., applicable_validators=...): ... diff --git a/stubs/ldap3/ldap3/__init__.pyi b/stubs/ldap3/ldap3/__init__.pyi index 4f72194fa2bd..2336956e8e71 100644 --- a/stubs/ldap3/ldap3/__init__.pyi +++ b/stubs/ldap3/ldap3/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Tuple, Type +from typing import Any, Type from typing_extensions import Literal from .abstract.attrDef import AttrDef as AttrDef @@ -98,7 +98,7 @@ HASHED_SALTED_SHA384: Literal["SALTED_SHA384"] HASHED_SALTED_SHA512: Literal["SALTED_SHA512"] HASHED_SALTED_MD5: Literal["SALTED_MD5"] -NUMERIC_TYPES: Tuple[Type[Any], ...] -INTEGER_TYPES: Tuple[Type[Any], ...] -STRING_TYPES: Tuple[Type[Any], ...] -SEQUENCE_TYPES: Tuple[Type[Any], ...] +NUMERIC_TYPES: tuple[Type[Any], ...] +INTEGER_TYPES: tuple[Type[Any], ...] +STRING_TYPES: tuple[Type[Any], ...] +SEQUENCE_TYPES: tuple[Type[Any], ...] diff --git a/stubs/mock/mock/mock.pyi b/stubs/mock/mock/mock.pyi index 2b29be0345a5..c5c215c2eecf 100644 --- a/stubs/mock/mock/mock.pyi +++ b/stubs/mock/mock/mock.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Mapping, Sequence -from typing import Any, Generic, List, Tuple, Type, TypeVar, overload +from typing import Any, Generic, Type, TypeVar, overload _F = TypeVar("_F", bound=Callable[..., Any]) _T = TypeVar("_T") @@ -40,7 +40,7 @@ class _Sentinel: sentinel: Any DEFAULT: Any -class _Call(Tuple[Any, ...]): +class _Call(tuple[Any, ...]): def __new__( cls, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ... ) -> Any: ... @@ -60,7 +60,7 @@ class _Call(Tuple[Any, ...]): call: _Call -class _CallList(List[_Call]): +class _CallList(list[_Call]): def __contains__(self, value: Any) -> bool: ... class _MockIter: @@ -113,7 +113,7 @@ class NonCallableMock(Base, Any): call_args_list: _CallList mock_calls: _CallList def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ... - def _call_matcher(self, _call: Tuple[_Call, ...]) -> _Call: ... + def _call_matcher(self, _call: tuple[_Call, ...]) -> _Call: ... def _get_child_mock(self, **kw: Any) -> NonCallableMock: ... class CallableMixin(Base): diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index dd182c485177..459903d6cccf 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, ItemsView, KeysView, Mapping, ValuesView import abc import sys -from typing import Any, Callable, Generic, ItemsView, KeysView, Mapping, Type, TypeVar, ValuesView +from typing import Any, Generic, Type, TypeVar _T = TypeVar("_T") _U = TypeVar("_U") diff --git a/stubs/mysqlclient/MySQLdb/__init__.pyi b/stubs/mysqlclient/MySQLdb/__init__.pyi index 88d6eb25bd2c..7e8070b3e09f 100644 --- a/stubs/mysqlclient/MySQLdb/__init__.pyi +++ b/stubs/mysqlclient/MySQLdb/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, FrozenSet +from typing import Any from MySQLdb import connections as connections, constants as constants, converters as converters, cursors as cursors from MySQLdb._mysql import ( @@ -35,7 +35,7 @@ threadsafety: int apilevel: str paramstyle: str -class DBAPISet(FrozenSet[Any]): +class DBAPISet(frozenset[Any]): def __eq__(self, other): ... STRING: Any diff --git a/stubs/mysqlclient/MySQLdb/_mysql.pyi b/stubs/mysqlclient/MySQLdb/_mysql.pyi index 690e3469893f..3e79317aafff 100644 --- a/stubs/mysqlclient/MySQLdb/_mysql.pyi +++ b/stubs/mysqlclient/MySQLdb/_mysql.pyi @@ -1,9 +1,9 @@ import builtins -from typing import Any, Tuple +from typing import Any import MySQLdb._exceptions -version_info: Tuple[Any, ...] +version_info: tuple[Any, ...] class DataError(MySQLdb._exceptions.DatabaseError): ... class DatabaseError(MySQLdb._exceptions.Error): ... diff --git a/stubs/oauthlib/oauthlib/common.pyi b/stubs/oauthlib/oauthlib/common.pyi index bdd765525fe8..622e9e3ea8da 100644 --- a/stubs/oauthlib/oauthlib/common.pyi +++ b/stubs/oauthlib/oauthlib/common.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any UNICODE_ASCII_CHARACTER_SET: str CLIENT_ID_CHARACTER_SET: str @@ -28,7 +28,7 @@ def add_params_to_uri(uri, params, fragment: bool = ...): ... def safe_string_equals(a, b): ... def to_unicode(data, encoding: str = ...): ... -class CaseInsensitiveDict(Dict[Any, Any]): +class CaseInsensitiveDict(dict[Any, Any]): proxy: Any def __init__(self, data) -> None: ... def __contains__(self, k): ... diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi index c11b07b2d41d..d4901f5aa653 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi @@ -1,6 +1,6 @@ -from typing import Any, Dict +from typing import Any -class OAuth2Token(Dict[Any, Any]): +class OAuth2Token(dict[Any, Any]): def __init__(self, params, old_scope: Any | None = ...) -> None: ... @property def scope_changed(self): ... diff --git a/stubs/opentracing/opentracing/harness/scope_check.pyi b/stubs/opentracing/opentracing/harness/scope_check.pyi index affe51501d6d..dd7618a0a969 100644 --- a/stubs/opentracing/opentracing/harness/scope_check.pyi +++ b/stubs/opentracing/opentracing/harness/scope_check.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable +from collections.abc import Callable +from typing import Any from ..scope_manager import ScopeManager diff --git a/stubs/paramiko/paramiko/agent.pyi b/stubs/paramiko/paramiko/agent.pyi index bad43a1bc15f..24926ac1eb5c 100644 --- a/stubs/paramiko/paramiko/agent.pyi +++ b/stubs/paramiko/paramiko/agent.pyi @@ -1,6 +1,6 @@ from socket import _RetAddress, socket from threading import Thread -from typing import Protocol, Tuple +from typing import Protocol from paramiko.channel import Channel from paramiko.message import Message @@ -18,7 +18,7 @@ SSH2_AGENT_SIGN_RESPONSE: int class AgentSSH: def __init__(self) -> None: ... - def get_keys(self) -> Tuple[AgentKey, ...]: ... + def get_keys(self) -> tuple[AgentKey, ...]: ... class AgentProxyThread(Thread): def __init__(self, agent: _AgentProxy) -> None: ... diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index 6c412620ef19..3001c385ce0c 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -1,11 +1,12 @@ +from collections.abc import Callable from threading import Event -from typing import Callable, List, Tuple + from paramiko.pkey import PKey from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.transport import Transport -_InteractiveCallback = Callable[[str, str, List[Tuple[str, bool]]], List[str]] +_InteractiveCallback = Callable[[str, str, list[tuple[str, bool]]], list[str]] class AuthHandler: transport: Transport diff --git a/stubs/paramiko/paramiko/ber.pyi b/stubs/paramiko/paramiko/ber.pyi index 906dd2564338..831ef1ef6780 100644 --- a/stubs/paramiko/paramiko/ber.pyi +++ b/stubs/paramiko/paramiko/ber.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable +from collections.abc import Iterable +from typing import Any class BERException(Exception): ... diff --git a/stubs/paramiko/paramiko/channel.pyi b/stubs/paramiko/paramiko/channel.pyi index 1870c9e1fded..a48fedac50cc 100644 --- a/stubs/paramiko/paramiko/channel.pyi +++ b/stubs/paramiko/paramiko/channel.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Mapping from logging import Logger from threading import Condition, Event, Lock -from typing import Any, Callable, Mapping, TypeVar +from typing import Any, TypeVar from paramiko.buffered_pipe import BufferedPipe from paramiko.file import BufferedFile diff --git a/stubs/paramiko/paramiko/client.pyi b/stubs/paramiko/paramiko/client.pyi index f088dbe537cb..ea0ae1d37eb1 100644 --- a/stubs/paramiko/paramiko/client.pyi +++ b/stubs/paramiko/paramiko/client.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Mapping from socket import socket -from typing import Iterable, Mapping, NoReturn, Type +from typing import NoReturn, Type from paramiko.channel import Channel, ChannelFile, ChannelStderrFile, ChannelStdinFile from paramiko.hostkeys import HostKeys diff --git a/stubs/paramiko/paramiko/config.pyi b/stubs/paramiko/paramiko/config.pyi index 65bb71f450a8..b1048b48d962 100644 --- a/stubs/paramiko/paramiko/config.pyi +++ b/stubs/paramiko/paramiko/config.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Dict, Iterable, Pattern +from collections.abc import Iterable +from typing import IO, Any, Pattern from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize @@ -25,7 +26,7 @@ class LazyFqdn: host: str | None def __init__(self, config: SSHConfigDict, host: str | None = ...) -> None: ... -class SSHConfigDict(Dict[str, str]): +class SSHConfigDict(dict[str, str]): def __init__(self, *args: Any, **kwargs: Any) -> None: ... def as_bool(self, key: str) -> bool: ... def as_int(self, key: str) -> int: ... diff --git a/stubs/paramiko/paramiko/dsskey.pyi b/stubs/paramiko/paramiko/dsskey.pyi index 86a57d5e3916..af46bc9a8add 100644 --- a/stubs/paramiko/paramiko/dsskey.pyi +++ b/stubs/paramiko/paramiko/dsskey.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Callable +from collections.abc import Callable +from typing import IO, Any from paramiko.message import Message from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/ecdsakey.pyi b/stubs/paramiko/paramiko/ecdsakey.pyi index 698362879747..8036f243b035 100644 --- a/stubs/paramiko/paramiko/ecdsakey.pyi +++ b/stubs/paramiko/paramiko/ecdsakey.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Callable, Sequence, Type +from collections.abc import Callable, Sequence +from typing import IO, Any, Type from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/paramiko/paramiko/file.pyi b/stubs/paramiko/paramiko/file.pyi index dbf35fc39c93..e84863cf500e 100644 --- a/stubs/paramiko/paramiko/file.pyi +++ b/stubs/paramiko/paramiko/file.pyi @@ -1,4 +1,5 @@ -from typing import Any, AnyStr, Generic, Iterable, Tuple +from collections.abc import Iterable +from typing import Any, AnyStr, Generic from paramiko.util import ClosingContextManager @@ -15,7 +16,7 @@ class BufferedFile(ClosingContextManager, Generic[AnyStr]): FLAG_LINE_BUFFERED: int FLAG_UNIVERSAL_NEWLINE: int - newlines: None | AnyStr | Tuple[AnyStr, ...] + newlines: None | AnyStr | tuple[AnyStr, ...] def __init__(self) -> None: ... def __del__(self) -> None: ... def __iter__(self) -> BufferedFile[Any]: ... diff --git a/stubs/paramiko/paramiko/hostkeys.pyi b/stubs/paramiko/paramiko/hostkeys.pyi index 32f05bfc0ab6..ec3da629addb 100644 --- a/stubs/paramiko/paramiko/hostkeys.pyi +++ b/stubs/paramiko/paramiko/hostkeys.pyi @@ -1,4 +1,5 @@ -from typing import Iterator, Mapping, MutableMapping +from collections.abc import Iterator, Mapping, MutableMapping + from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/kex_curve25519.pyi b/stubs/paramiko/paramiko/kex_curve25519.pyi index c2811dd70c96..3965dea60759 100644 --- a/stubs/paramiko/paramiko/kex_curve25519.pyi +++ b/stubs/paramiko/paramiko/kex_curve25519.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import sys from _typeshed import ReadableBuffer as ReadableBuffer -from typing import Callable + from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi index aec8d912aff0..e0739e69748f 100644 --- a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi +++ b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import sys from _typeshed import ReadableBuffer -from typing import Callable + from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/kex_gex.pyi b/stubs/paramiko/paramiko/kex_gex.pyi index a47717ec9c4f..18a00f28e5bd 100644 --- a/stubs/paramiko/paramiko/kex_gex.pyi +++ b/stubs/paramiko/paramiko/kex_gex.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import sys from _typeshed import ReadableBuffer -from typing import Callable + from paramiko.message import Message from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/kex_group1.pyi b/stubs/paramiko/paramiko/kex_group1.pyi index 8b6ae8842f34..b068c49f333a 100644 --- a/stubs/paramiko/paramiko/kex_group1.pyi +++ b/stubs/paramiko/paramiko/kex_group1.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import sys from _typeshed import ReadableBuffer -from typing import Callable + from paramiko.message import Message from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/kex_group14.pyi b/stubs/paramiko/paramiko/kex_group14.pyi index 276f9e5cd7ed..5b45272400e9 100644 --- a/stubs/paramiko/paramiko/kex_group14.pyi +++ b/stubs/paramiko/paramiko/kex_group14.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import sys from _typeshed import ReadableBuffer -from typing import Callable + from paramiko.kex_group1 import KexGroup1 as KexGroup1 diff --git a/stubs/paramiko/paramiko/kex_group16.pyi b/stubs/paramiko/paramiko/kex_group16.pyi index d85490cd486c..38a49ef1a45e 100644 --- a/stubs/paramiko/paramiko/kex_group16.pyi +++ b/stubs/paramiko/paramiko/kex_group16.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable import sys from _typeshed import ReadableBuffer -from typing import Callable + from paramiko.kex_group1 import KexGroup1 as KexGroup1 diff --git a/stubs/paramiko/paramiko/message.pyi b/stubs/paramiko/paramiko/message.pyi index e4fd1dfc27da..49e7eda72f8f 100644 --- a/stubs/paramiko/paramiko/message.pyi +++ b/stubs/paramiko/paramiko/message.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable import sys -from typing import Any, Iterable, Text +from typing import Any, Text from .common import _LikeBytes diff --git a/stubs/paramiko/paramiko/packet.pyi b/stubs/paramiko/paramiko/packet.pyi index 5d2c251db650..843c81379256 100644 --- a/stubs/paramiko/paramiko/packet.pyi +++ b/stubs/paramiko/paramiko/packet.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import sys from logging import Logger from socket import socket -from typing import Any, Callable +from typing import Any from cryptography.hazmat.primitives.ciphers import Cipher from paramiko.compress import ZlibCompressor, ZlibDecompressor diff --git a/stubs/paramiko/paramiko/py3compat.pyi b/stubs/paramiko/paramiko/py3compat.pyi index b41a04ff2f14..59898d529518 100644 --- a/stubs/paramiko/paramiko/py3compat.pyi +++ b/stubs/paramiko/paramiko/py3compat.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Sequence import sys -from typing import Any, Iterable, Sequence, Text, Type, TypeVar +from typing import Any, Text, Type, TypeVar _T = TypeVar("_T") diff --git a/stubs/paramiko/paramiko/rsakey.pyi b/stubs/paramiko/paramiko/rsakey.pyi index 7c76e60e23d9..7ce264ef1a94 100644 --- a/stubs/paramiko/paramiko/rsakey.pyi +++ b/stubs/paramiko/paramiko/rsakey.pyi @@ -1,4 +1,5 @@ -from typing import IO, Any, Callable +from collections.abc import Callable +from typing import IO, Any from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey, RSAPublicNumbers from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/server.pyi b/stubs/paramiko/paramiko/server.pyi index 22647fd22f69..74b7d7d83245 100644 --- a/stubs/paramiko/paramiko/server.pyi +++ b/stubs/paramiko/paramiko/server.pyi @@ -1,5 +1,5 @@ import threading -from typing import Tuple + from paramiko.channel import Channel from paramiko.message import Message @@ -19,7 +19,7 @@ class ServerInterface: def enable_auth_gssapi(self) -> bool: ... def check_port_forward_request(self, address: str, port: int) -> int: ... def cancel_port_forward_request(self, address: str, port: int) -> None: ... - def check_global_request(self, kind: str, msg: Message) -> bool | Tuple[bool | int | str, ...]: ... + def check_global_request(self, kind: str, msg: Message) -> bool | tuple[bool | int | str, ...]: ... def check_channel_pty_request( self, channel: Channel, term: bytes, width: int, height: int, pixelwidth: int, pixelheight: int, modes: bytes ) -> bool: ... diff --git a/stubs/paramiko/paramiko/sftp_client.pyi b/stubs/paramiko/paramiko/sftp_client.pyi index fd49ff3be620..eb990a246a80 100644 --- a/stubs/paramiko/paramiko/sftp_client.pyi +++ b/stubs/paramiko/paramiko/sftp_client.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterator from logging import Logger -from typing import IO, Any, Callable, Iterator, Text +from typing import IO, Any, Text from paramiko.channel import Channel from paramiko.sftp import BaseSFTP diff --git a/stubs/paramiko/paramiko/sftp_file.pyi b/stubs/paramiko/paramiko/sftp_file.pyi index 9663fccaba31..50415d127597 100644 --- a/stubs/paramiko/paramiko/sftp_file.pyi +++ b/stubs/paramiko/paramiko/sftp_file.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterator, Sequence +from collections.abc import Iterator, Sequence +from typing import Any from paramiko.file import BufferedFile from paramiko.sftp_attr import SFTPAttributes diff --git a/stubs/paramiko/paramiko/ssh_exception.pyi b/stubs/paramiko/paramiko/ssh_exception.pyi index c122d63e162b..940400e67301 100644 --- a/stubs/paramiko/paramiko/ssh_exception.pyi +++ b/stubs/paramiko/paramiko/ssh_exception.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping import socket -from typing import Mapping + from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/ssh_gss.pyi b/stubs/paramiko/paramiko/ssh_gss.pyi index aed5ae7672fe..7f750a4236ba 100644 --- a/stubs/paramiko/paramiko/ssh_gss.pyi +++ b/stubs/paramiko/paramiko/ssh_gss.pyi @@ -1,7 +1,7 @@ -from typing import Any, Tuple, Type +from typing import Any, Type GSS_AUTH_AVAILABLE: bool -GSS_EXCEPTIONS: Tuple[Type[Exception], ...] +GSS_EXCEPTIONS: tuple[Type[Exception], ...] def GSSAuth(auth_method: str, gss_deleg_creds: bool = ...) -> _SSH_GSSAuth: ... diff --git a/stubs/paramiko/paramiko/transport.pyi b/stubs/paramiko/paramiko/transport.pyi index f294c9ad591c..ea4943c4bcc0 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable, Iterable, Sequence from logging import Logger from socket import socket from threading import Condition, Event, Lock, Thread from types import ModuleType -from typing import Any, Callable, Iterable, Protocol, Sequence, Tuple, Type +from typing import Any, Protocol, Type from paramiko.auth_handler import AuthHandler, _InteractiveCallback from paramiko.channel import Channel @@ -14,7 +15,7 @@ from paramiko.sftp_client import SFTPClient from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.util import ClosingContextManager -_Addr = Tuple[str, int] +_Addr = tuple[str, int] class _KexEngine(Protocol): def start_kex(self) -> None: ... @@ -67,7 +68,7 @@ class Transport(Thread, ClosingContextManager): server_key_dict: dict[str, PKey] server_accepts: list[Channel] server_accept_cv: Condition - subsystem_table: dict[str, tuple[Type[SubsystemHandler], Tuple[Any, ...], dict[str, Any]]] + subsystem_table: dict[str, tuple[Type[SubsystemHandler], tuple[Any, ...], dict[str, Any]]] sys: ModuleType def __init__( self, diff --git a/stubs/paramiko/paramiko/util.pyi b/stubs/paramiko/paramiko/util.pyi index 05bd5c73ffe8..7ea67abfeaa2 100644 --- a/stubs/paramiko/paramiko/util.pyi +++ b/stubs/paramiko/paramiko/util.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import sys from logging import Logger, LogRecord from types import TracebackType -from typing import IO, AnyStr, Callable, Protocol, Type, TypeVar +from typing import IO, AnyStr, Protocol, Type, TypeVar from paramiko.config import SSHConfig, SSHConfigDict from paramiko.hostkeys import HostKeys diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index c4c361f1836c..a2007db00314 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable import textwrap -from typing import IO, Any, Callable, Generic, List, Text, Type, TypeVar, overload +from typing import IO, Any, Generic, Text, Type, TypeVar, overload from typing_extensions import SupportsIndex _TB = TypeVar("_TB", bound="_BaseEntry") @@ -23,7 +24,7 @@ def detect_encoding(file: bytes | Text, binary_mode: bool = ...) -> str: ... def escape(st: Text) -> Text: ... def unescape(st: Text) -> Text: ... -class _BaseFile(List[_TB]): +class _BaseFile(list[_TB]): fpath: Text wrapwidth: int encoding: Text diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 1eed72c28165..cc197ac1f8b0 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterable, Iterator import sys from contextlib import AbstractContextManager -from typing import Any, Callable, Iterable, Iterator, Tuple, TypeVar +from typing import Any, TypeVar from ._common import ( AIX as AIX, @@ -125,7 +126,7 @@ class Process: def pid(self) -> int: ... def oneshot(self) -> AbstractContextManager[None]: ... def as_dict( - self, attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... + self, attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... ) -> dict[str, Any]: ... def parent(self) -> Process: ... def parents(self) -> list[Process]: ... @@ -188,7 +189,7 @@ class Popen(Process): def pids() -> list[int]: ... def pid_exists(pid: int) -> bool: ... def process_iter( - attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... + attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... ) -> Iterator[Process]: ... def wait_procs( procs: Iterable[Process], timeout: float | None = ..., callback: Callable[[Process], Any] | None = ... diff --git a/stubs/psutil/psutil/_common.pyi b/stubs/psutil/psutil/_common.pyi index 9fa49d105581..c8e08d8e4be7 100644 --- a/stubs/psutil/psutil/_common.pyi +++ b/stubs/psutil/psutil/_common.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable import enum from _typeshed import StrOrBytesPath, SupportsWrite from socket import AddressFamily, SocketKind -from typing import Any, Callable, NamedTuple, TypeVar, overload +from typing import Any, NamedTuple, TypeVar, overload from typing_extensions import Literal POSIX: bool diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi index 149a29f52276..090d237253a7 100644 --- a/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Tuple, TypeVar, overload +from collections.abc import Callable +from typing import Any, TypeVar, overload import psycopg2 import psycopg2.extensions @@ -360,9 +361,9 @@ class cursor: def copy_to(self, file, table, sep=..., null=..., columns=...): ... def execute(self, query, vars=...): ... def executemany(self, query, vars_list): ... - def fetchall(self) -> list[Tuple[Any, ...]]: ... - def fetchmany(self, size=...) -> list[Tuple[Any, ...]]: ... - def fetchone(self) -> Tuple[Any, ...] | Any: ... + def fetchall(self) -> list[tuple[Any, ...]]: ... + def fetchmany(self, size=...) -> list[tuple[Any, ...]]: ... + def fetchone(self) -> tuple[Any, ...] | Any: ... def mogrify(self, *args, **kwargs): ... def nextset(self): ... def scroll(self, value, mode=...): ... diff --git a/stubs/psycopg2/psycopg2/extras.pyi b/stubs/psycopg2/psycopg2/extras.pyi index 364de1a2f85a..fdd7cf429b34 100644 --- a/stubs/psycopg2/psycopg2/extras.pyi +++ b/stubs/psycopg2/psycopg2/extras.pyi @@ -1,5 +1,5 @@ from collections import OrderedDict -from typing import Any, List +from typing import Any from psycopg2._ipaddress import register_ipaddress as register_ipaddress from psycopg2._json import ( @@ -45,7 +45,7 @@ class DictCursor(DictCursorBase): def execute(self, query, vars: Any | None = ...): ... def callproc(self, procname, vars: Any | None = ...): ... -class DictRow(List[Any]): +class DictRow(list[Any]): def __init__(self, cursor) -> None: ... def __getitem__(self, x): ... def __setitem__(self, x, v) -> None: ... diff --git a/stubs/pyOpenSSL/OpenSSL/SSL.pyi b/stubs/pyOpenSSL/OpenSSL/SSL.pyi index e947c788b667..4298539c857a 100644 --- a/stubs/pyOpenSSL/OpenSSL/SSL.pyi +++ b/stubs/pyOpenSSL/OpenSSL/SSL.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Sequence import socket -from typing import Any, Callable, Sequence +from typing import Any from OpenSSL.crypto import X509, PKey diff --git a/stubs/pyOpenSSL/OpenSSL/crypto.pyi b/stubs/pyOpenSSL/OpenSSL/crypto.pyi index abfb1e3ab85d..3c4370153c73 100644 --- a/stubs/pyOpenSSL/OpenSSL/crypto.pyi +++ b/stubs/pyOpenSSL/OpenSSL/crypto.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable, Sequence from datetime import datetime -from typing import Any, Callable, Iterable, Sequence, Text, Tuple, Union +from typing import Any, Text, Union from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey @@ -118,7 +119,7 @@ class CRL: @classmethod def from_cryptography(cls, crypto_crl: CertificateRevocationList) -> CRL: ... def get_issuer(self) -> X509Name: ... - def get_revoked(self) -> Tuple[Revoked, ...]: ... + def get_revoked(self) -> tuple[Revoked, ...]: ... def set_lastUpdate(self, when: bytes) -> None: ... def set_nextUpdate(self, when: bytes) -> None: ... def set_version(self, version: int) -> None: ... @@ -166,7 +167,7 @@ class PKCS7: class PKCS12: def __init__(self) -> None: ... def export(self, passphrase: bytes | None = ..., iter: int = ..., maciter: int = ...) -> bytes: ... - def get_ca_certificates(self) -> Tuple[X509, ...]: ... + def get_ca_certificates(self) -> tuple[X509, ...]: ... def get_certificate(self) -> X509: ... def get_friendlyname(self) -> bytes | None: ... def get_privatekey(self) -> PKey: ... diff --git a/stubs/pyaudio/pyaudio.pyi b/stubs/pyaudio/pyaudio.pyi index 6849056b1d47..5895f27bc2c1 100644 --- a/stubs/pyaudio/pyaudio.pyi +++ b/stubs/pyaudio/pyaudio.pyi @@ -1,4 +1,5 @@ -from typing import Callable, Mapping, Optional, Sequence, Tuple, Union +from collections.abc import Callable, Mapping, Sequence +from typing import Optional, Union from typing_extensions import Final paFloat32: Final[int] = ... @@ -70,7 +71,7 @@ paMacCoreStreamInfo: PaMacCoreStreamInfo _ChannelMap = Sequence[int] _PaHostApiInfo = Mapping[str, Union[str, int]] _PaDeviceInfo = Mapping[str, Union[str, int, float]] -_StreamCallback = Callable[[Optional[bytes], int, Mapping[str, float], int], Tuple[Optional[bytes], int]] +_StreamCallback = Callable[[Optional[bytes], int, Mapping[str, float], int], tuple[Optional[bytes], int]] def get_format_from_width(width: int, unsigned: bool = ...) -> int: ... def get_portaudio_version() -> int: ... diff --git a/stubs/pycurl/pycurl.pyi b/stubs/pycurl/pycurl.pyi index f69b2b6c0060..c3517e112676 100644 --- a/stubs/pycurl/pycurl.pyi +++ b/stubs/pycurl/pycurl.pyi @@ -1,6 +1,6 @@ # TODO(MichalPokorny): more precise types -from typing import Any, Text, Tuple +from typing import Any, Text GLOBAL_ACK_EINTR: int GLOBAL_ALL: int @@ -14,7 +14,7 @@ def global_cleanup() -> None: ... version: str -def version_info() -> tuple[int, str, int, str, int, str, int, str, Tuple[str, ...], Any, int, Any]: ... +def version_info() -> tuple[int, str, int, str, int, str, int, str, tuple[str, ...], Any, int, Any]: ... class error(Exception): ... diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 58e051248fc2..dad750fd5ea7 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Sequence from stat import S_IMODE as S_IMODE from types import TracebackType -from typing import IO, Any, Callable, ContextManager, Sequence, Text, Type, Union +from typing import IO, Any, ContextManager, Text, Type, Union from typing_extensions import Literal import paramiko diff --git a/stubs/pysftp/pysftp/helpers.pyi b/stubs/pysftp/pysftp/helpers.pyi index c1e0138d47f9..dd339743849b 100644 --- a/stubs/pysftp/pysftp/helpers.pyi +++ b/stubs/pysftp/pysftp/helpers.pyi @@ -1,4 +1,5 @@ -from typing import Callable, ContextManager, Iterator +from collections.abc import Callable, Iterator +from typing import ContextManager def known_hosts() -> str: ... def st_mode_to_int(val: int) -> int: ... diff --git a/stubs/pytest-lazy-fixture/pytest_lazyfixture.pyi b/stubs/pytest-lazy-fixture/pytest_lazyfixture.pyi index b5cc42079cb1..bcbf329c06ab 100644 --- a/stubs/pytest-lazy-fixture/pytest_lazyfixture.pyi +++ b/stubs/pytest-lazy-fixture/pytest_lazyfixture.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, overload +from collections.abc import Iterable +from typing import Any, overload class LazyFixture: name: str diff --git a/stubs/python-dateutil/dateutil/parser/__init__.pyi b/stubs/python-dateutil/dateutil/parser/__init__.pyi index a408f649bc54..90943e06ca4e 100644 --- a/stubs/python-dateutil/dateutil/parser/__init__.pyi +++ b/stubs/python-dateutil/dateutil/parser/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping from datetime import datetime, tzinfo -from typing import IO, Any, Mapping, Text, Union +from typing import IO, Any, Text, Union from .isoparser import isoparse as isoparse, isoparser as isoparser diff --git a/stubs/python-dateutil/dateutil/rrule.pyi b/stubs/python-dateutil/dateutil/rrule.pyi index bc95dcf2aa6e..e645d9406289 100644 --- a/stubs/python-dateutil/dateutil/rrule.pyi +++ b/stubs/python-dateutil/dateutil/rrule.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable import datetime -from typing import Any, Iterable +from typing import Any from ._common import weekday as weekdaybase diff --git a/stubs/python-gflags/gflags.pyi b/stubs/python-gflags/gflags.pyi index bc674935cb24..b37f98c3f0e5 100644 --- a/stubs/python-gflags/gflags.pyi +++ b/stubs/python-gflags/gflags.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable, Sequence from types import ModuleType -from typing import IO, Any, Callable, Iterable, Sequence, Text +from typing import IO, Any, Text class Error(Exception): ... diff --git a/stubs/python-nmap/nmap/nmap.pyi b/stubs/python-nmap/nmap/nmap.pyi index a07d4b5e13ba..4fa5cdf117f6 100644 --- a/stubs/python-nmap/nmap/nmap.pyi +++ b/stubs/python-nmap/nmap/nmap.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, Text, TypeVar +from collections.abc import Callable, Iterable, Iterator +from typing import Any, Text, TypeVar from typing_extensions import TypedDict _T = TypeVar("_T") @@ -101,7 +102,7 @@ class PortScannerYield(PortScannerAsync): def wait(self, timeout: int | None = ...) -> None: ... def still_scanning(self) -> None: ... # type: ignore[override] -class PortScannerHostDict(Dict[str, Any]): +class PortScannerHostDict(dict[str, Any]): def hostnames(self) -> list[_ResultHostNames]: ... def hostname(self) -> str: ... def state(self) -> str: ... diff --git a/stubs/python-slugify/slugify/slugify.pyi b/stubs/python-slugify/slugify/slugify.pyi index 1a3ef13cddfe..13924dff255b 100644 --- a/stubs/python-slugify/slugify/slugify.pyi +++ b/stubs/python-slugify/slugify/slugify.pyi @@ -1,4 +1,5 @@ -from typing import Iterable +from collections.abc import Iterable + def smart_truncate( string: str, max_length: int = ..., word_boundary: bool = ..., separator: str = ..., save_order: bool = ... diff --git a/stubs/python-slugify/slugify/special.pyi b/stubs/python-slugify/slugify/special.pyi index 29ca15bdad61..9a67781467e8 100644 --- a/stubs/python-slugify/slugify/special.pyi +++ b/stubs/python-slugify/slugify/special.pyi @@ -1,4 +1,5 @@ -from typing import Sequence +from collections.abc import Sequence + def add_uppercase_char(char_list: Sequence[tuple[str, str]]) -> Sequence[tuple[str, str]]: ... diff --git a/stubs/pytz/pytz/__init__.pyi b/stubs/pytz/pytz/__init__.pyi index 4838e7614128..f0fd590901df 100644 --- a/stubs/pytz/pytz/__init__.pyi +++ b/stubs/pytz/pytz/__init__.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping import datetime -from typing import ClassVar, Mapping +from typing import ClassVar from .exceptions import ( AmbiguousTimeError as AmbiguousTimeError, diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 90655ab8f910..c68cfb1f9d9a 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -1,18 +1,19 @@ +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence import builtins import threading from _typeshed import Self, SupportsItems from datetime import datetime, timedelta from typing import ( Any, - Callable, + ClassVar, - Dict, + Generic, - Iterable, - Iterator, - Mapping, + + + Pattern, - Sequence, + Type, TypeVar, Union, @@ -36,7 +37,7 @@ _StrType = TypeVar("_StrType", bound=Union[str, bytes]) _VT = TypeVar("_VT") _T = TypeVar("_T") -class CaseInsensitiveDict(Dict[_StrType, _VT]): +class CaseInsensitiveDict(dict[_StrType, _VT]): def __init__(self, data: SupportsItems[_StrType, _VT]) -> None: ... def update(self, data: SupportsItems[_StrType, _VT]) -> None: ... # type: ignore[override] @overload diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index 875068195014..edee8ca19e96 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -1,4 +1,5 @@ -from typing import Any, Mapping, Type +from collections.abc import Mapping +from typing import Any, Type from .retry import Retry diff --git a/stubs/requests/requests/adapters.pyi b/stubs/requests/requests/adapters.pyi index 34cc23ef5ca8..0e461a14e619 100644 --- a/stubs/requests/requests/adapters.pyi +++ b/stubs/requests/requests/adapters.pyi @@ -1,4 +1,5 @@ -from typing import Any, Container, Mapping, Text +from collections.abc import Container, Mapping +from typing import Any, Text from . import cookies, exceptions, models, structures, utils from .packages.urllib3 import exceptions as urllib3_exceptions, poolmanager, response diff --git a/stubs/requests/requests/cookies.pyi b/stubs/requests/requests/cookies.pyi index 673852193703..94491cd002a1 100644 --- a/stubs/requests/requests/cookies.pyi +++ b/stubs/requests/requests/cookies.pyi @@ -1,5 +1,6 @@ +from collections.abc import MutableMapping import sys -from typing import Any, MutableMapping +from typing import Any if sys.version_info >= (3, 0): from http.cookiejar import CookieJar diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 957a0e074f78..86250f0cb301 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Iterator import datetime from json import JSONDecoder -from typing import Any, Callable, Iterator, Text, Type +from typing import Any, Text, Type from . import auth, cookies, exceptions, hooks, status_codes, structures, utils from .cookies import RequestsCookieJar diff --git a/stubs/requests/requests/packages/urllib3/_collections.pyi b/stubs/requests/requests/packages/urllib3/_collections.pyi index 15aca7bd6209..27366cca4a50 100644 --- a/stubs/requests/requests/packages/urllib3/_collections.pyi +++ b/stubs/requests/requests/packages/urllib3/_collections.pyi @@ -1,4 +1,5 @@ -from typing import Any, MutableMapping, NoReturn, TypeVar +from collections.abc import MutableMapping +from typing import Any, NoReturn, TypeVar _KT = TypeVar("_KT") _VT = TypeVar("_VT") diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index 89ba100c02af..5de0ca210dc6 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Iterable, Mapping, MutableMapping from _typeshed import SupportsItems -from typing import IO, Any, Callable, Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, TypeVar, Union +from typing import IO, Any, Optional, Text, TypeVar, Union from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, structures, utils from .models import Response @@ -43,18 +44,18 @@ class SessionRedirectMixin: def rebuild_proxies(self, prepared_request, proxies): ... def should_strip_auth(self, old_url, new_url): ... -_Data = Union[None, Text, bytes, Mapping[str, Any], Mapping[Text, Any], Iterable[Tuple[Text, Optional[Text]]], IO[Any]] +_Data = Union[None, Text, bytes, Mapping[str, Any], Mapping[Text, Any], Iterable[tuple[Text, Optional[Text]]], IO[Any]] _Hook = Callable[[Response], Any] -_Hooks = MutableMapping[Text, List[_Hook]] +_Hooks = MutableMapping[Text, list[_Hook]] _HooksInput = MutableMapping[Text, Union[Iterable[_Hook], _Hook]] _ParamsMappingKeyType = Union[Text, bytes, int, float] _ParamsMappingValueType = Union[Text, bytes, int, float, Iterable[Union[Text, bytes, int, float]], None] _Params = Union[ SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType], - Tuple[_ParamsMappingKeyType, _ParamsMappingValueType], - Iterable[Tuple[_ParamsMappingKeyType, _ParamsMappingValueType]], + tuple[_ParamsMappingKeyType, _ParamsMappingValueType], + Iterable[tuple[_ParamsMappingKeyType, _ParamsMappingValueType]], Union[Text, bytes], ] _TextMapping = MutableMapping[Text, Text] diff --git a/stubs/requests/requests/structures.pyi b/stubs/requests/requests/structures.pyi index ed7d9a2f225c..2e1ce105c53f 100644 --- a/stubs/requests/requests/structures.pyi +++ b/stubs/requests/requests/structures.pyi @@ -1,4 +1,5 @@ -from typing import Any, Dict, Generic, Iterable, Iterator, Mapping, MutableMapping, TypeVar +from collections.abc import Iterable, Iterator, Mapping, MutableMapping +from typing import Any, Generic, TypeVar _VT = TypeVar("_VT") @@ -12,7 +13,7 @@ class CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]): def __len__(self) -> int: ... def copy(self) -> CaseInsensitiveDict[_VT]: ... -class LookupDict(Dict[str, _VT]): +class LookupDict(dict[str, _VT]): name: Any def __init__(self, name: Any = ...) -> None: ... def __getitem__(self, key: str) -> _VT | None: ... # type: ignore[override] diff --git a/stubs/requests/requests/utils.pyi b/stubs/requests/requests/utils.pyi index 994652846491..a8ecaf5b1755 100644 --- a/stubs/requests/requests/utils.pyi +++ b/stubs/requests/requests/utils.pyi @@ -1,4 +1,5 @@ -from typing import Any, AnyStr, Iterable, Mapping, Text +from collections.abc import Iterable, Mapping +from typing import Any, AnyStr, Text from . import compat, cookies, exceptions, structures diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index a0b68c1a6d79..f1e6cca9e492 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable, Sequence from _typeshed import IdentityFunction from logging import Logger -from typing import Any, Callable, Sequence, Tuple, Type, TypeVar +from typing import Any, Type, TypeVar _R = TypeVar("_R") @@ -8,7 +9,7 @@ def retry_call( f: Callable[..., _R], fargs: Sequence[Any] | None = ..., fkwargs: dict[str, Any] | None = ..., - exceptions: Type[Exception] | Tuple[Type[Exception], ...] = ..., + exceptions: Type[Exception] | tuple[Type[Exception], ...] = ..., tries: int = ..., delay: float = ..., max_delay: float | None = ..., @@ -17,7 +18,7 @@ def retry_call( logger: Logger | None = ..., ) -> _R: ... def retry( - exceptions: Type[Exception] | Tuple[Type[Exception], ...] = ..., + exceptions: Type[Exception] | tuple[Type[Exception], ...] = ..., tries: int = ..., delay: float = ..., max_delay: float | None = ..., diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index 9f121f3340fc..11203afd0a09 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -1,8 +1,9 @@ +from collections.abc import Callable, Generator, Iterable, Sequence import importlib.abc import types import zipimport from abc import ABCMeta -from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Optional, TypeVar, Union, overload LegacyVersion = Any # from packaging.version Version = Any # from packaging.version @@ -70,14 +71,14 @@ class Requirement: unsafe_name: str project_name: str key: str - extras: Tuple[str, ...] + extras: tuple[str, ...] specs: list[tuple[str, str]] # TODO: change this to packaging.markers.Marker | None once we can import # packaging.markers marker: Any | None @staticmethod def parse(s: str | Iterable[str]) -> Requirement: ... - def __contains__(self, item: Distribution | str | Tuple[str, ...]) -> bool: ... + def __contains__(self, item: Distribution | str | tuple[str, ...]) -> bool: ... def __eq__(self, other_requirement: Any) -> bool: ... def load_entry_point(dist: _EPDistType, group: str, name: str) -> Any: ... @@ -90,15 +91,15 @@ def get_entry_map(dist: _EPDistType, group: str) -> dict[str, EntryPoint]: ... class EntryPoint: name: str module_name: str - attrs: Tuple[str, ...] - extras: Tuple[str, ...] + attrs: tuple[str, ...] + extras: tuple[str, ...] dist: Distribution | None def __init__( self, name: str, module_name: str, - attrs: Tuple[str, ...] = ..., - extras: Tuple[str, ...] = ..., + attrs: tuple[str, ...] = ..., + extras: tuple[str, ...] = ..., dist: Distribution | None = ..., ) -> None: ... @classmethod @@ -123,7 +124,7 @@ class Distribution(IResourceProvider, IMetadataProvider): key: str extras: list[str] version: str - parsed_version: Tuple[str, ...] + parsed_version: tuple[str, ...] py_version: str platform: str | None precedence: int @@ -145,7 +146,7 @@ class Distribution(IResourceProvider, IMetadataProvider): def from_filename(cls, filename: str, metadata: _MetadataType = ..., **kw: str | None | int) -> Distribution: ... def activate(self, path: list[str] | None = ...) -> None: ... def as_requirement(self) -> Requirement: ... - def requires(self, extras: Tuple[str, ...] = ...) -> list[Requirement]: ... + def requires(self, extras: tuple[str, ...] = ...) -> list[Requirement]: ... def clone(self, **kw: str | int | None) -> Requirement: ... def egg_name(self) -> str: ... def __cmp__(self, other: Any) -> bool: ... diff --git a/stubs/setuptools/setuptools/command/easy_install.pyi b/stubs/setuptools/setuptools/command/easy_install.pyi index 11f8224e69ad..6d7bc390a8da 100644 --- a/stubs/setuptools/setuptools/command/easy_install.pyi +++ b/stubs/setuptools/setuptools/command/easy_install.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from pkg_resources import Environment from setuptools import Command, SetuptoolsDeprecationWarning @@ -106,7 +106,7 @@ class RewritePthDistributions(PthDistributions): prelude: Any postlude: Any -class CommandSpec(List[str]): +class CommandSpec(list[str]): options: Any split_args: Any @classmethod diff --git a/stubs/setuptools/setuptools/command/test.pyi b/stubs/setuptools/setuptools/command/test.pyi index 8d0309ab023e..a46972b07672 100644 --- a/stubs/setuptools/setuptools/command/test.pyi +++ b/stubs/setuptools/setuptools/command/test.pyi @@ -1,6 +1,7 @@ +from collections.abc import Callable from _typeshed import Self from types import ModuleType -from typing import Any, Callable, Generic, TypeVar, overload +from typing import Any, Generic, TypeVar, overload from unittest import TestLoader, TestSuite from setuptools import Command diff --git a/stubs/singledispatch/singledispatch.pyi b/stubs/singledispatch/singledispatch.pyi index f264047ac201..2ef2f4d99ff6 100644 --- a/stubs/singledispatch/singledispatch.pyi +++ b/stubs/singledispatch/singledispatch.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Generic, Mapping, TypeVar, overload +from collections.abc import Callable, Mapping +from typing import Any, Generic, TypeVar, overload _T = TypeVar("_T") diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 1f36799d6cfe..4143db17678e 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -6,7 +6,7 @@ from builtins import next as next from collections.abc import Callable, ItemsView, Iterable, Iterator as _Iterator, KeysView, Mapping, ValuesView from functools import wraps as wraps from io import BytesIO as BytesIO, StringIO as StringIO -from typing import Any, AnyStr, NoReturn, Pattern, Tuple, Type, TypeVar, overload +from typing import Any, AnyStr, NoReturn, Pattern, Type, TypeVar, overload from typing_extensions import Literal from . import moves as moves @@ -39,9 +39,9 @@ Iterator = object def get_method_function(meth: types.MethodType) -> types.FunctionType: ... def get_method_self(meth: types.MethodType) -> object | None: ... -def get_function_closure(fun: types.FunctionType) -> Tuple[types._Cell, ...] | None: ... +def get_function_closure(fun: types.FunctionType) -> tuple[types._Cell, ...] | None: ... def get_function_code(fun: types.FunctionType) -> types.CodeType: ... -def get_function_defaults(fun: types.FunctionType) -> Tuple[Any, ...] | None: ... +def get_function_defaults(fun: types.FunctionType) -> tuple[Any, ...] | None: ... def get_function_globals(fun: types.FunctionType) -> dict[str, Any]: ... def iterkeys(d: Mapping[_K, Any]) -> _Iterator[_K]: ... def itervalues(d: Mapping[Any, _V]) -> _Iterator[_V]: ... diff --git a/stubs/stripe/stripe/stripe_object.pyi b/stubs/stripe/stripe/stripe_object.pyi index 25ed72a9de70..5b496bfb631a 100644 --- a/stubs/stripe/stripe/stripe_object.pyi +++ b/stubs/stripe/stripe/stripe_object.pyi @@ -1,9 +1,9 @@ import json -from typing import Any, Dict +from typing import Any from stripe import api_requestor as api_requestor -class StripeObject(Dict[Any, Any]): +class StripeObject(dict[Any, Any]): class ReprJSONEncoder(json.JSONEncoder): def default(self, obj): ... def __init__( diff --git a/stubs/tabulate/tabulate.pyi b/stubs/tabulate/tabulate.pyi index 8b5efde5bf08..40afea603aa3 100644 --- a/stubs/tabulate/tabulate.pyi +++ b/stubs/tabulate/tabulate.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Container, Iterable, List, Mapping, NamedTuple, Sequence, Union +from collections.abc import Callable, Container, Iterable, Mapping, Sequence +from typing import Any, NamedTuple, Union LATEX_ESCAPE_RULES: dict[str, str] MIN_PADDING: int @@ -18,8 +19,8 @@ class DataRow(NamedTuple): sep: str end: str -_TableFormatLine = Union[None, Line, Callable[[List[int], List[str]], str]] -_TableFormatRow = Union[None, DataRow, Callable[[List[Any], List[int], List[str]], str]] +_TableFormatLine = Union[None, Line, Callable[[list[int], list[str]], str]] +_TableFormatRow = Union[None, DataRow, Callable[[list[Any], list[int], list[str]], str]] class TableFormat(NamedTuple): lineabove: _TableFormatLine diff --git a/stubs/termcolor/termcolor.pyi b/stubs/termcolor/termcolor.pyi index 534ae2747d60..da55f9fdbda4 100644 --- a/stubs/termcolor/termcolor.pyi +++ b/stubs/termcolor/termcolor.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Text +from collections.abc import Iterable +from typing import Any, Text ATTRIBUTES: dict[str, int] COLORS: dict[str, int] diff --git a/stubs/toml/toml.pyi b/stubs/toml/toml.pyi index 3f8580b33376..ba961a439b18 100644 --- a/stubs/toml/toml.pyi +++ b/stubs/toml/toml.pyi @@ -1,6 +1,7 @@ +from collections.abc import Mapping, MutableMapping import sys from _typeshed import StrPath, SupportsWrite -from typing import IO, Any, Mapping, MutableMapping, Text, Type, Union +from typing import IO, Any, Text, Type, Union if sys.version_info >= (3, 6): _PathLike = StrPath diff --git a/stubs/toposort/toposort.pyi b/stubs/toposort/toposort.pyi index ccde29046763..10e0d91b00ca 100644 --- a/stubs/toposort/toposort.pyi +++ b/stubs/toposort/toposort.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Iterator from _typeshed import SupportsItems -from typing import Any, Iterable, Iterator, Protocol, TypeVar +from typing import Any, Protocol, TypeVar _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index 93dbae12ee4d..4bc463f0ba06 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterator import typing -from typing import Any, Iterator +from typing import Any class NodeVisitor: def visit(self, node: AST) -> Any: ... diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 8d0a830541a9..3b8a391c10ed 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterator import typing -from typing import Any, Iterator +from typing import Any class NodeVisitor: def visit(self, node: AST) -> Any: ... diff --git a/stubs/vobject/vobject/base.pyi b/stubs/vobject/vobject/base.pyi index 98407fc433c1..bc0c2523be34 100644 --- a/stubs/vobject/vobject/base.pyi +++ b/stubs/vobject/vobject/base.pyi @@ -1,6 +1,7 @@ +from collections.abc import Iterator from _typeshed import SupportsWrite from collections.abc import Iterable -from typing import Any, Iterator, TypeVar, overload +from typing import Any, TypeVar, overload from typing_extensions import Literal DEBUG: bool diff --git a/stubs/vobject/vobject/icalendar.pyi b/stubs/vobject/vobject/icalendar.pyi index bbd568502c94..6a9728e0ae9c 100644 --- a/stubs/vobject/vobject/icalendar.pyi +++ b/stubs/vobject/vobject/icalendar.pyi @@ -1,15 +1,15 @@ from datetime import timedelta -from typing import Any, Tuple +from typing import Any from .base import Component from .behavior import Behavior -DATENAMES: Tuple[str, ...] -RULENAMES: Tuple[str, ...] -DATESANDRULES: Tuple[str, ...] +DATENAMES: tuple[str, ...] +RULENAMES: tuple[str, ...] +DATESANDRULES: tuple[str, ...] PRODID: str -WEEKDAYS: Tuple[str, ...] -FREQUENCIES: Tuple[str, ...] +WEEKDAYS: tuple[str, ...] +FREQUENCIES: tuple[str, ...] zeroDelta: timedelta twoHours: timedelta diff --git a/stubs/waitress/waitress/__init__.pyi b/stubs/waitress/waitress/__init__.pyi index 2abd726d3e38..f3aef6fbab97 100644 --- a/stubs/waitress/waitress/__init__.pyi +++ b/stubs/waitress/waitress/__init__.pyi @@ -1,7 +1,7 @@ -from typing import Any, Tuple +from typing import Any from waitress.server import create_server as create_server def serve(app: Any, **kw: Any) -> None: ... def serve_paste(app: Any, global_conf: Any, **kw: Any) -> int: ... -def profile(cmd: Any, globals: Any, locals: Any, sort_order: Tuple[str, ...], callers: bool) -> None: ... +def profile(cmd: Any, globals: Any, locals: Any, sort_order: tuple[str, ...], callers: bool) -> None: ... diff --git a/stubs/waitress/waitress/adjustments.pyi b/stubs/waitress/waitress/adjustments.pyi index 9a62dd85d48f..433f79564c53 100644 --- a/stubs/waitress/waitress/adjustments.pyi +++ b/stubs/waitress/waitress/adjustments.pyi @@ -1,5 +1,6 @@ +from collections.abc import Iterable, Sequence from socket import socket -from typing import Any, Iterable, Sequence +from typing import Any from .compat import HAS_IPV6 as HAS_IPV6, PY2 as PY2, WIN as WIN, string_types as string_types from .proxy_headers import PROXY_HEADERS as PROXY_HEADERS diff --git a/stubs/waitress/waitress/buffers.pyi b/stubs/waitress/waitress/buffers.pyi index 128b1cef4b23..0babddaefb23 100644 --- a/stubs/waitress/waitress/buffers.pyi +++ b/stubs/waitress/waitress/buffers.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable from io import BufferedIOBase, BufferedRandom, BytesIO -from typing import Any, Callable +from typing import Any COPY_BYTES: int STRBUF_LIMIT: int diff --git a/stubs/waitress/waitress/channel.pyi b/stubs/waitress/waitress/channel.pyi index eee8c317cf8e..ba96cb4443db 100644 --- a/stubs/waitress/waitress/channel.pyi +++ b/stubs/waitress/waitress/channel.pyi @@ -1,6 +1,7 @@ +from collections.abc import Mapping, Sequence from socket import socket from threading import Condition, Lock -from typing import Mapping, Sequence + from waitress.adjustments import Adjustments from waitress.buffers import OverflowableBuffer diff --git a/stubs/waitress/waitress/parser.pyi b/stubs/waitress/waitress/parser.pyi index 193c4a97347e..1211c4bb0303 100644 --- a/stubs/waitress/waitress/parser.pyi +++ b/stubs/waitress/waitress/parser.pyi @@ -1,5 +1,6 @@ +from collections.abc import Mapping, Sequence from io import BytesIO -from typing import Any, Mapping, Pattern, Sequence +from typing import Any, Pattern from waitress.adjustments import Adjustments from waitress.receiver import ChunkedReceiver, FixedStreamReceiver diff --git a/stubs/waitress/waitress/proxy_headers.pyi b/stubs/waitress/waitress/proxy_headers.pyi index 3d3c6e1d8ea8..d5b7745398fa 100644 --- a/stubs/waitress/waitress/proxy_headers.pyi +++ b/stubs/waitress/waitress/proxy_headers.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Mapping, Sequence from logging import Logger -from typing import Any, Callable, Mapping, NamedTuple, Sequence +from typing import Any, NamedTuple from .utilities import BadRequest as BadRequest diff --git a/stubs/waitress/waitress/runner.pyi b/stubs/waitress/waitress/runner.pyi index 9ce1156c3864..6967c6ebbe27 100644 --- a/stubs/waitress/waitress/runner.pyi +++ b/stubs/waitress/waitress/runner.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Sequence from io import TextIOWrapper -from typing import Any, Callable, Pattern, Sequence +from typing import Any, Pattern HELP: str RUNNER_PATTERN: Pattern[Any] diff --git a/stubs/waitress/waitress/server.pyi b/stubs/waitress/waitress/server.pyi index 8179b6743eaa..e8cb00ae2b2d 100644 --- a/stubs/waitress/waitress/server.pyi +++ b/stubs/waitress/waitress/server.pyi @@ -1,5 +1,6 @@ +from collections.abc import Sequence from socket import socket -from typing import Any, Sequence +from typing import Any from waitress.adjustments import Adjustments from waitress.channel import HTTPChannel diff --git a/stubs/waitress/waitress/task.pyi b/stubs/waitress/waitress/task.pyi index d7a17d6bb39c..dd2a6c38afae 100644 --- a/stubs/waitress/waitress/task.pyi +++ b/stubs/waitress/waitress/task.pyi @@ -1,7 +1,8 @@ +from collections.abc import Mapping, Sequence from collections import deque from logging import Logger from threading import Condition, Lock -from typing import Any, Mapping, Sequence +from typing import Any from .channel import HTTPChannel from .utilities import Error diff --git a/stubs/waitress/waitress/trigger.pyi b/stubs/waitress/waitress/trigger.pyi index 8196dbbfafbe..9ada2ed7f76a 100644 --- a/stubs/waitress/waitress/trigger.pyi +++ b/stubs/waitress/waitress/trigger.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Mapping import sys from socket import socket from threading import Lock -from typing import Callable, Mapping + from typing_extensions import Literal from . import wasyncore as wasyncore diff --git a/stubs/waitress/waitress/utilities.pyi b/stubs/waitress/waitress/utilities.pyi index 9f7482b51399..f8ebc1135404 100644 --- a/stubs/waitress/waitress/utilities.pyi +++ b/stubs/waitress/waitress/utilities.pyi @@ -1,5 +1,6 @@ +from collections.abc import Callable, Mapping, Sequence from logging import Logger -from typing import Any, Callable, Mapping, Match, Pattern, Sequence +from typing import Any, Match, Pattern from .rfc7230 import OBS_TEXT as OBS_TEXT, VCHAR as VCHAR diff --git a/stubs/waitress/waitress/wasyncore.pyi b/stubs/waitress/waitress/wasyncore.pyi index b7bb0b5d864c..1aeef24103e7 100644 --- a/stubs/waitress/waitress/wasyncore.pyi +++ b/stubs/waitress/waitress/wasyncore.pyi @@ -1,7 +1,8 @@ +from collections.abc import Callable, Mapping from io import BytesIO from logging import Logger from socket import socket -from typing import Any, Callable, Mapping +from typing import Any from . import compat as compat, utilities as utilities From 0e1acd2e654de955b5a48456cc7bab60c1b233e7 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 22:50:25 +0000 Subject: [PATCH 3/7] Add exemption for `collections` to `check_new_syntax` --- tests/check_new_syntax.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index 0be99532312e..fb96f575aaff 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -19,7 +19,8 @@ ) # AbstractSet intentionally omitted from this list -- special-cased -IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING = frozenset({ +IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING = frozenset( + { "ByteString", "Collection", "Container", @@ -44,7 +45,8 @@ "AsyncIterator", "Awaitable", "Callable", - }) + } +) # The values in the mapping are what these are called in `collections` IMPORTED_FROM_COLLECTIONS_NOT_TYPING = { @@ -69,7 +71,11 @@ def check_object_from_typing(node: ast.ImportFrom | ast.Attribute, object_name: f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING[object_name]}` instead of `typing.{object_name}`" ) elif object_name in IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING: - if path not in {Path("stdlib/_collections_abc.pyi"), Path("stdlib/builtins.pyi")}: + if path not in { + Path("stdlib/_collections_abc.pyi"), + Path("stdlib/builtins.pyi"), + Path("stdlib/collections/__init__.pyi"), + }: errors.append(f"{path}:{node.lineno}: Use `collections.abc.{object_name}` instead of `typing.{object_name}`") elif object_name == "AbstractSet": if path != Path("stdlib/_collections_abc.pyi"): From e64695dc3b95f696dd1f6f37737ed1b6c661368d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 22:58:19 +0000 Subject: [PATCH 4/7] Apply isort/black; Manually apply `AbstractSet` fixes & fixes for typed-ast --- stdlib/_bisect.pyi | 2 +- stdlib/_codecs.pyi | 2 +- stdlib/_compression.pyi | 2 +- stdlib/_dummy_threading.pyi | 2 +- stdlib/_operator.pyi | 20 ++----------- stdlib/_osx_support.pyi | 2 +- stdlib/_posixsubprocess.pyi | 1 - stdlib/_random.pyi | 2 -- stdlib/_thread.pyi | 2 +- stdlib/_tracemalloc.pyi | 3 +- stdlib/_typeshed/__init__.pyi | 4 +-- stdlib/_weakref.pyi | 2 +- stdlib/_weakrefset.pyi | 2 +- stdlib/_winapi.pyi | 2 +- stdlib/abc.pyi | 2 +- stdlib/argparse.pyi | 19 ++---------- stdlib/array.pyi | 2 +- stdlib/ast.pyi | 7 +++-- stdlib/asyncio/base_events.pyi | 3 +- stdlib/asyncio/base_futures.pyi | 2 +- stdlib/asyncio/base_subprocess.pyi | 2 +- stdlib/asyncio/events.pyi | 2 +- stdlib/asyncio/format_helpers.pyi | 2 +- stdlib/asyncio/futures.pyi | 2 +- stdlib/asyncio/locks.pyi | 2 +- stdlib/asyncio/proactor_events.pyi | 2 +- stdlib/asyncio/runners.pyi | 2 +- stdlib/asyncio/sslproto.pyi | 2 +- stdlib/asyncio/staggered.pyi | 2 +- stdlib/asyncio/streams.pyi | 2 +- stdlib/asyncio/subprocess.pyi | 2 +- stdlib/asyncio/threads.pyi | 2 +- stdlib/asyncio/transports.pyi | 2 +- stdlib/asyncio/trsock.pyi | 2 +- stdlib/asyncio/unix_events.pyi | 2 +- stdlib/asyncio/windows_events.pyi | 2 +- stdlib/asyncio/windows_utils.pyi | 2 +- stdlib/audioop.pyi | 2 -- stdlib/builtins.pyi | 3 +- stdlib/bz2.pyi | 2 +- stdlib/cProfile.pyi | 2 +- stdlib/calendar.pyi | 2 +- stdlib/cgitb.pyi | 2 +- stdlib/code.pyi | 2 +- stdlib/codecs.pyi | 2 +- stdlib/concurrent/futures/_base.pyi | 3 +- stdlib/concurrent/futures/process.pyi | 3 +- stdlib/concurrent/futures/thread.pyi | 5 ++-- stdlib/contextlib.pyi | 18 ++---------- stdlib/contextvars.pyi | 2 +- stdlib/ctypes/__init__.pyi | 19 ++---------- stdlib/curses/__init__.pyi | 2 +- stdlib/curses/textpad.pyi | 3 +- stdlib/dataclasses.pyi | 2 +- stdlib/dbm/__init__.pyi | 2 +- stdlib/dbm/dumb.pyi | 2 +- stdlib/decimal.pyi | 2 +- stdlib/difflib.pyi | 2 +- stdlib/dis.pyi | 2 +- stdlib/distutils/cmd.pyi | 2 +- stdlib/distutils/dist.pyi | 2 +- stdlib/distutils/file_util.pyi | 1 - stdlib/distutils/sysconfig.pyi | 1 - stdlib/doctest.pyi | 2 +- stdlib/email/_header_value_parser.pyi | 2 +- stdlib/email/iterators.pyi | 1 - stdlib/email/parser.pyi | 2 +- stdlib/email/policy.pyi | 2 +- stdlib/errno.pyi | 1 - stdlib/filecmp.pyi | 2 +- stdlib/fileinput.pyi | 2 +- stdlib/ftplib.pyi | 2 +- stdlib/functools.pyi | 2 +- stdlib/genericpath.pyi | 2 +- stdlib/gettext.pyi | 2 +- stdlib/glob.pyi | 2 +- stdlib/graphlib.pyi | 2 +- stdlib/hashlib.pyi | 2 +- stdlib/heapq.pyi | 2 +- stdlib/hmac.pyi | 2 +- stdlib/http/client.pyi | 2 +- stdlib/http/cookiejar.pyi | 2 +- stdlib/http/cookies.pyi | 2 +- stdlib/http/server.pyi | 2 +- stdlib/imaplib.pyi | 2 +- stdlib/imghdr.pyi | 2 +- stdlib/importlib/__init__.pyi | 1 - stdlib/importlib/abc.pyi | 2 +- stdlib/importlib/machinery.pyi | 2 +- stdlib/importlib/metadata/__init__.pyi | 3 +- stdlib/importlib/resources.pyi | 2 +- stdlib/importlib/util.pyi | 2 +- stdlib/io.pyi | 2 +- stdlib/ipaddress.pyi | 2 +- stdlib/itertools.pyi | 18 ++---------- stdlib/json/__init__.pyi | 2 +- stdlib/keyword.pyi | 3 +- stdlib/lib2to3/pgen2/driver.pyi | 2 +- stdlib/lib2to3/pgen2/pgen.pyi | 2 +- stdlib/lib2to3/pgen2/tokenize.pyi | 1 - stdlib/locale.pyi | 2 +- stdlib/logging/config.pyi | 3 +- stdlib/lzma.pyi | 2 +- stdlib/mailbox.pyi | 19 ++---------- stdlib/math.pyi | 2 +- stdlib/mimetypes.pyi | 2 +- stdlib/mmap.pyi | 2 +- stdlib/modulefinder.pyi | 2 +- stdlib/msilib/__init__.pyi | 2 +- stdlib/multiprocessing/connection.pyi | 2 +- stdlib/multiprocessing/dummy/__init__.pyi | 2 +- stdlib/multiprocessing/managers.pyi | 2 +- stdlib/multiprocessing/pool.pyi | 2 +- stdlib/multiprocessing/process.pyi | 2 +- stdlib/multiprocessing/shared_memory.pyi | 2 +- stdlib/multiprocessing/synchronize.pyi | 2 +- stdlib/nntplib.pyi | 2 +- stdlib/opcode.pyi | 3 +- stdlib/os/__init__.pyi | 24 ++------------- stdlib/parser.pyi | 2 +- stdlib/pathlib.pyi | 2 +- stdlib/pdb.pyi | 2 +- stdlib/pickle.pyi | 2 +- stdlib/pkgutil.pyi | 2 +- stdlib/plistlib.pyi | 2 +- stdlib/posixpath.pyi | 2 +- stdlib/profile.pyi | 2 +- stdlib/pstats.pyi | 2 +- stdlib/pty.pyi | 1 - stdlib/pyclbr.pyi | 3 +- stdlib/pydoc.pyi | 2 +- stdlib/pyexpat/__init__.pyi | 2 +- stdlib/re.pyi | 2 +- stdlib/readline.pyi | 2 +- stdlib/reprlib.pyi | 2 +- stdlib/select.pyi | 2 +- stdlib/selectors.pyi | 2 +- stdlib/shlex.pyi | 2 +- stdlib/shutil.pyi | 2 +- stdlib/signal.pyi | 2 +- stdlib/site.pyi | 3 +- stdlib/smtplib.pyi | 2 +- stdlib/socketserver.pyi | 2 +- stdlib/sqlite3/dbapi2.pyi | 2 +- stdlib/sre_parse.pyi | 2 +- stdlib/ssl.pyi | 2 +- stdlib/statistics.pyi | 2 +- stdlib/string.pyi | 2 +- stdlib/struct.pyi | 2 +- stdlib/subprocess.pyi | 2 +- stdlib/symtable.pyi | 2 +- stdlib/sys.pyi | 18 ++---------- stdlib/tabnanny.pyi | 3 +- stdlib/telnetlib.pyi | 2 +- stdlib/tempfile.pyi | 2 +- stdlib/threading.pyi | 2 +- stdlib/tkinter/__init__.pyi | 2 +- stdlib/tkinter/filedialog.pyi | 2 +- stdlib/tkinter/ttk.pyi | 2 +- stdlib/tokenize.pyi | 2 +- stdlib/trace.pyi | 2 +- stdlib/traceback.pyi | 2 +- stdlib/tracemalloc.pyi | 2 +- stdlib/types.pyi | 36 ++++++++++------------- stdlib/typing_extensions.pyi | 30 ++++++++----------- stdlib/unittest/async_case.pyi | 2 +- stdlib/unittest/case.pyi | 24 ++------------- stdlib/unittest/loader.pyi | 2 +- stdlib/unittest/main.pyi | 2 +- stdlib/unittest/mock.pyi | 2 +- stdlib/unittest/result.pyi | 2 +- stdlib/unittest/runner.pyi | 2 +- stdlib/unittest/signals.pyi | 2 +- stdlib/unittest/suite.pyi | 2 +- stdlib/urllib/parse.pyi | 2 +- stdlib/urllib/request.pyi | 2 +- stdlib/urllib/response.pyi | 2 +- stdlib/urllib/robotparser.pyi | 2 +- stdlib/warnings.pyi | 2 +- stdlib/weakref.pyi | 2 +- stdlib/webbrowser.pyi | 3 +- stdlib/wsgiref/handlers.pyi | 2 +- stdlib/wsgiref/util.pyi | 2 +- stdlib/wsgiref/validate.pyi | 2 +- stdlib/xml/dom/domreg.pyi | 3 +- stdlib/xml/dom/pulldom.pyi | 2 +- stdlib/xml/etree/ElementInclude.pyi | 3 +- stdlib/xml/etree/ElementTree.pyi | 20 ++----------- stdlib/xml/sax/__init__.pyi | 2 +- stdlib/xml/sax/saxutils.pyi | 3 +- stdlib/xml/sax/xmlreader.pyi | 1 - stdlib/xmlrpc/client.pyi | 2 +- stdlib/xmlrpc/server.pyi | 2 +- stdlib/zipapp.pyi | 2 +- stdlib/zipfile.pyi | 2 +- stdlib/zoneinfo/__init__.pyi | 2 +- 196 files changed, 227 insertions(+), 424 deletions(-) diff --git a/stdlib/_bisect.pyi b/stdlib/_bisect.pyi index 0fe373bf2dc1..4120898f1231 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, MutableSequence, Sequence import sys from _typeshed import SupportsRichComparison +from collections.abc import Callable, MutableSequence, Sequence from typing import TypeVar _T = TypeVar("_T") diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index fe31c7fab296..ff9cac62b4f7 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import codecs import sys +from collections.abc import Callable from typing import Any, Union # This type is not exposed; it is defined in unicodeobject.c diff --git a/stdlib/_compression.pyi b/stdlib/_compression.pyi index 4bd476088a91..9aa9d0d6a34a 100644 --- a/stdlib/_compression.pyi +++ b/stdlib/_compression.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import WriteableBuffer +from collections.abc import Callable from io import BufferedIOBase, RawIOBase from typing import Any, Protocol, Type diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index f24d8a092e88..a317e9f2143a 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Mapping import sys +from collections.abc import Callable, Iterable, Mapping from types import FrameType, TracebackType from typing import Any, Optional, Type, TypeVar diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index ea5cfce0a56e..3428f15677fd 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -1,23 +1,7 @@ -from collections.abc import Callable, Container, Iterable, Mapping, MutableMapping, MutableSequence, Sequence import sys from _typeshed import SupportsAnyComparison -from typing import ( - Any, - AnyStr, - - - Generic, - - - - - Protocol, - - SupportsAbs, - - TypeVar, - overload, -) +from collections.abc import Callable, Container, Iterable, Mapping, MutableMapping, MutableSequence, Sequence +from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, TypeVar, overload from typing_extensions import ParamSpec, SupportsIndex, final _R = TypeVar("_R") diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index 1f99b460f3bb..6cdfcfdc9103 100644 --- a/stdlib/_osx_support.pyi +++ b/stdlib/_osx_support.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Sequence import sys +from collections.abc import Iterable, Sequence from typing import TypeVar _T = TypeVar("_T") diff --git a/stdlib/_posixsubprocess.pyi b/stdlib/_posixsubprocess.pyi index dcd0f3eee23e..97f0719e8fd8 100644 --- a/stdlib/_posixsubprocess.pyi +++ b/stdlib/_posixsubprocess.pyi @@ -2,7 +2,6 @@ from collections.abc import Callable, Sequence - def cloexec_pipe() -> tuple[int, int]: ... def fork_exec( args: Sequence[str], diff --git a/stdlib/_random.pyi b/stdlib/_random.pyi index d5d46fca61bd..654277ec421a 100644 --- a/stdlib/_random.pyi +++ b/stdlib/_random.pyi @@ -1,5 +1,3 @@ - - # Actually Tuple[(int,) * 625] _State = tuple[int, ...] diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index ed94178284c4..1c129ee847bd 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import structseq +from collections.abc import Callable from threading import Thread from types import TracebackType from typing import Any, NoReturn, Optional, Type diff --git a/stdlib/_tracemalloc.pyi b/stdlib/_tracemalloc.pyi index 8a6e30305126..6e3c4e59a07a 100644 --- a/stdlib/_tracemalloc.pyi +++ b/stdlib/_tracemalloc.pyi @@ -1,8 +1,7 @@ -from collections.abc import Sequence import sys +from collections.abc import Sequence from tracemalloc import _FrameTupleT, _TraceTupleT - def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ... def _get_traces() -> Sequence[_TraceTupleT]: ... def clear_traces() -> None: ... diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index c249c964a1d4..7420c38cd462 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -2,13 +2,13 @@ # # See the README.md file in this directory for more information. -from collections.abc import Awaitable, Container, Iterable import array import ctypes import mmap import sys +from collections.abc import Awaitable, Container, Iterable, Set as AbstractSet from os import PathLike -from typing import AbstractSet, Any, ClassVar, Generic, Protocol, Type, TypeVar, Union +from typing import Any, ClassVar, Generic, Protocol, Type, TypeVar, Union from typing_extensions import Literal, final _KT = TypeVar("_KT") diff --git a/stdlib/_weakref.pyi b/stdlib/_weakref.pyi index c7956c2b9e95..b4fff9f99f54 100644 --- a/stdlib/_weakref.pyi +++ b/stdlib/_weakref.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import sys +from collections.abc import Callable from typing import Any, Generic, TypeVar, overload from typing_extensions import final diff --git a/stdlib/_weakrefset.pyi b/stdlib/_weakrefset.pyi index cdcb806c6914..0183ae91b5cd 100644 --- a/stdlib/_weakrefset.pyi +++ b/stdlib/_weakrefset.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Iterator, MutableSet import sys +from collections.abc import Iterable, Iterator, MutableSet from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index 6eeb05e37257..b464039740c5 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -1,5 +1,5 @@ -from collections.abc import Sequence import sys +from collections.abc import Sequence from typing import Any, NoReturn, overload from typing_extensions import Literal, final diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 899a4b14cd6d..42b0d38c6519 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import SupportsWrite +from collections.abc import Callable from typing import Any, Type, TypeVar _T = TypeVar("_T") diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 8af7478a58e9..f3f8941fb75d 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -1,21 +1,6 @@ -from collections.abc import Callable, Generator, Iterable, Sequence import sys -from typing import ( - IO, - Any, - - - Generic, - - NoReturn, - Pattern, - Protocol, - - - Type, - TypeVar, - overload, -) +from collections.abc import Callable, Generator, Iterable, Sequence +from typing import IO, Any, Generic, NoReturn, Pattern, Protocol, Type, TypeVar, overload _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) diff --git a/stdlib/array.pyi b/stdlib/array.pyi index 98094548db47..5336dddd4929 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, MutableSequence import sys +from collections.abc import Iterable, MutableSequence from typing import Any, BinaryIO, Generic, TypeVar, Union, overload from typing_extensions import Literal, SupportsIndex diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 48faade265a6..c0ad2d91bcf2 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -2,14 +2,15 @@ # from _ast below when loaded in an unorthodox way by the Dropbox # internal Bazel integration. +import sys +import typing as _typing +from _ast import * + # The same unorthodox Bazel integration causes issues with sys, which # is imported in both modules. unfortunately we can't just rename sys, # since mypy only supports version checks with a sys that is named # sys. from collections.abc import Iterator -import sys -import typing as _typing -from _ast import * from typing import Any, TypeVar, overload from typing_extensions import Literal diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 1ad6ce557f26..1d05a92b4117 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -1,4 +1,3 @@ -from collections.abc import Awaitable, Callable, Generator, Sequence import ssl import sys from _typeshed import FileDescriptorLike @@ -8,7 +7,7 @@ from asyncio.futures import Future from asyncio.protocols import BaseProtocol from asyncio.tasks import Task from asyncio.transports import BaseTransport -from collections.abc import Iterable +from collections.abc import Awaitable, Callable, Generator, Iterable, Sequence from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket from typing import IO, Any, TypeVar, Union, overload from typing_extensions import Literal diff --git a/stdlib/asyncio/base_futures.pyi b/stdlib/asyncio/base_futures.pyi index 9feb2c96fe71..9cf638927a3b 100644 --- a/stdlib/asyncio/base_futures.pyi +++ b/stdlib/asyncio/base_futures.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Sequence import sys +from collections.abc import Callable, Sequence from typing import Any from typing_extensions import Literal diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index e84394fe9f55..e917388ea611 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Sequence import subprocess from collections import deque +from collections.abc import Callable, Sequence from typing import IO, Any, Optional, Union from . import events, futures, protocols, transports diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 30af853f8843..be08bebe2795 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -1,8 +1,8 @@ -from collections.abc import Awaitable, Callable, Generator, Sequence import ssl import sys from _typeshed import FileDescriptorLike, Self from abc import ABCMeta, abstractmethod +from collections.abc import Awaitable, Callable, Generator, Sequence from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket from typing import IO, Any, TypeVar, Union, overload from typing_extensions import Literal diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index 9f1bf77caf93..2a392df47b2c 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -1,7 +1,7 @@ -from collections.abc import Iterable import functools import sys import traceback +from collections.abc import Iterable from types import FrameType, FunctionType from typing import Any, Union, overload diff --git a/stdlib/asyncio/futures.pyi b/stdlib/asyncio/futures.pyi index 9c5382d055f0..99a1f656749c 100644 --- a/stdlib/asyncio/futures.pyi +++ b/stdlib/asyncio/futures.pyi @@ -1,5 +1,5 @@ -from collections.abc import Awaitable, Callable, Generator, Iterable import sys +from collections.abc import Awaitable, Callable, Generator, Iterable from concurrent.futures._base import Error, Future as _ConcurrentFuture from typing import Any, TypeVar diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 2c5305753b12..716fed139f5e 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,6 +1,6 @@ -from collections.abc import Awaitable, Callable, Generator import sys from collections import deque +from collections.abc import Awaitable, Callable, Generator from types import TracebackType from typing import Any, Type, TypeVar diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index d79e1fd70174..970a524ad944 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -1,5 +1,5 @@ -from collections.abc import Mapping import sys +from collections.abc import Mapping from socket import socket from typing import Any, Protocol, Type from typing_extensions import Literal diff --git a/stdlib/asyncio/runners.pyi b/stdlib/asyncio/runners.pyi index 0a2164634f76..522f9cfda822 100644 --- a/stdlib/asyncio/runners.pyi +++ b/stdlib/asyncio/runners.pyi @@ -1,5 +1,5 @@ -from collections.abc import Awaitable import sys +from collections.abc import Awaitable if sys.version_info >= (3, 7): from typing import TypeVar diff --git a/stdlib/asyncio/sslproto.pyi b/stdlib/asyncio/sslproto.pyi index a7ceb3e78c2e..7e4612816eb1 100644 --- a/stdlib/asyncio/sslproto.pyi +++ b/stdlib/asyncio/sslproto.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable import ssl import sys from collections import deque +from collections.abc import Callable from typing import Any, ClassVar from typing_extensions import Literal diff --git a/stdlib/asyncio/staggered.pyi b/stdlib/asyncio/staggered.pyi index 49fd19004e1e..e89c39919c2e 100644 --- a/stdlib/asyncio/staggered.pyi +++ b/stdlib/asyncio/staggered.pyi @@ -1,5 +1,5 @@ -from collections.abc import Awaitable, Callable, Iterable import sys +from collections.abc import Awaitable, Callable, Iterable from typing import Any from . import events diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index d9b002a69c9b..342e8b649d9c 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -1,6 +1,6 @@ -from collections.abc import AsyncIterator, Awaitable, Callable, Iterable import sys from _typeshed import StrPath +from collections.abc import AsyncIterator, Awaitable, Callable, Iterable from typing import Any, Optional from . import events, protocols, transports diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index d736156a87e5..9faaef70a4c8 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable import subprocess import sys from _typeshed import StrOrBytesPath from asyncio import events, protocols, streams, transports +from collections.abc import Callable from typing import IO, Any, Union from typing_extensions import Literal diff --git a/stdlib/asyncio/threads.pyi b/stdlib/asyncio/threads.pyi index 062aebd0dba8..7c5ecaaecb34 100644 --- a/stdlib/asyncio/threads.pyi +++ b/stdlib/asyncio/threads.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import sys +from collections.abc import Callable from typing import TypeVar from typing_extensions import ParamSpec diff --git a/stdlib/asyncio/transports.pyi b/stdlib/asyncio/transports.pyi index 797146030c6f..d5b86c8c6d3b 100644 --- a/stdlib/asyncio/transports.pyi +++ b/stdlib/asyncio/transports.pyi @@ -1,7 +1,7 @@ -from collections.abc import Mapping import sys from asyncio.events import AbstractEventLoop from asyncio.protocols import BaseProtocol +from collections.abc import Mapping from socket import _Address from typing import Any diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index ba4ae0bb2719..d9c38cb6b624 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable import socket import sys +from collections.abc import Iterable from types import TracebackType from typing import Any, BinaryIO, NoReturn, Type, Union, overload diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index 6520aedfd742..8e99dec719b6 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable import sys import types from _typeshed import Self +from collections.abc import Callable from socket import socket from typing import Any, Type diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index be7ee876d7d5..e4e5b197c32b 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable import socket import sys from _typeshed import WriteableBuffer +from collections.abc import Callable from typing import IO, Any, ClassVar, NoReturn, Type from . import events, futures, proactor_events, selector_events, streams, windows_utils diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index 8979f14cc723..97b4dc2419e8 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import Self +from collections.abc import Callable from types import TracebackType from typing import Protocol, Type diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index 0abf550f553c..b08731b85b0b 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,5 +1,3 @@ - - AdpcmState = tuple[int, int] RatecvState = tuple[int, tuple[tuple[int, int], ...]] diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index ad7a383723d3..48a815a82ec0 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -22,11 +22,11 @@ from _typeshed import ( SupportsTrunc, SupportsWrite, ) +from collections.abc import Set as AbstractSet from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from types import CodeType, TracebackType from typing import ( IO, - AbstractSet, Any, BinaryIO, ByteString, @@ -49,7 +49,6 @@ from typing import ( SupportsFloat, SupportsInt, SupportsRound, - Type, TypeVar, Union, diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index e98583d6c909..ef2ae5e0a2ca 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -1,8 +1,8 @@ -from collections.abc import Iterable import _compression import sys from _compression import BaseStream from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer +from collections.abc import Iterable from typing import IO, Any, Protocol, TextIO, TypeVar, overload from typing_extensions import Literal, SupportsIndex, final diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index c25897034ccb..f577b0cbdcab 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import Self, StrOrBytesPath +from collections.abc import Callable from types import CodeType from typing import Any, TypeVar diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 445928c01d99..d3ae5c590e05 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable, Sequence import datetime import sys +from collections.abc import Iterable, Sequence from time import struct_time from typing import Any, Optional diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index 616880cd2f49..d94bb41d9834 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import StrOrBytesPath +from collections.abc import Callable from types import FrameType, TracebackType from typing import IO, Any, Optional, Type diff --git a/stdlib/code.pyi b/stdlib/code.pyi index 35440b0f207e..bc96bc447ab1 100644 --- a/stdlib/code.pyi +++ b/stdlib/code.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Mapping from codeop import CommandCompiler +from collections.abc import Callable, Mapping from types import CodeType from typing import Any diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 4af9a6d3f7df..445888674013 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Generator, Iterable, Iterator import sys import types from _typeshed import Self from abc import abstractmethod +from collections.abc import Callable, Generator, Iterable, Iterator from typing import IO, Any, BinaryIO, Protocol, TextIO, Type, TypeVar, overload from typing_extensions import Literal diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index 9d39fe7445d6..2d966318c87b 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -1,9 +1,8 @@ -from collections.abc import Callable import sys import threading from _typeshed import Self from abc import abstractmethod -from collections.abc import Container, Iterable, Iterator, Sequence +from collections.abc import Callable, Container, Iterable, Iterator, Sequence from logging import Logger from typing import Any, Generic, Protocol, TypeVar, overload from typing_extensions import SupportsIndex diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index f40008b07545..c60b7ebff5ae 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable import sys -from collections.abc import Generator, Iterable, Mapping, MutableMapping, MutableSequence +from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping, MutableSequence from multiprocessing.connection import Connection from multiprocessing.context import BaseContext, Process from multiprocessing.queues import Queue, SimpleQueue diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 0418a129ddb2..fb9c6f987dd6 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import queue import sys -from collections.abc import Iterable, Mapping, Set # equivalent to typing.AbstractSet, not builtins.set +from collections.abc import Callable, Iterable, Mapping, Set as AbstractSet from threading import Lock, Semaphore, Thread from typing import Any, Generic, TypeVar from weakref import ref @@ -47,7 +46,7 @@ if sys.version_info >= (3, 7): class ThreadPoolExecutor(Executor): _max_workers: int _idle_semaphore: Semaphore - _threads: Set[Thread] + _threads: AbstractSet[Thread] _broken: bool _shutdown: bool _shutdown_lock: Lock diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 1623034aa2f4..79601cc9e1e9 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -1,22 +1,8 @@ -from collections.abc import AsyncIterator, Awaitable, Callable, Iterator import sys from _typeshed import Self, StrOrBytesPath +from collections.abc import AsyncIterator, Awaitable, Callable, Iterator from types import TracebackType -from typing import ( - IO, - Any, - - - - ContextManager, - Generic, - - Optional, - Protocol, - Type, - TypeVar, - overload, -) +from typing import IO, Any, ContextManager, Generic, Optional, Protocol, Type, TypeVar, overload from typing_extensions import ParamSpec AbstractContextManager = ContextManager diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index 9598bc8f42dc..4ec64983c5ba 100644 --- a/stdlib/contextvars.pyi +++ b/stdlib/contextvars.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterator, Mapping import sys +from collections.abc import Callable, Iterator, Mapping from typing import Any, ClassVar, Generic, TypeVar, overload if sys.version_info >= (3, 9): diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index d7c9dec6118b..73599482c210 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -1,23 +1,8 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence import sys from _typeshed import ReadableBuffer, WriteableBuffer from abc import abstractmethod -from typing import ( - Any, - - ClassVar, - Generic, - - - - Optional, - - - Type, - TypeVar, - Union as _UnionT, - overload, -) +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence +from typing import Any, ClassVar, Generic, Optional, Type, TypeVar, Union as _UnionT, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/curses/__init__.pyi b/stdlib/curses/__init__.pyi index 3e3d2e6c836a..9a03037a0378 100644 --- a/stdlib/curses/__init__.pyi +++ b/stdlib/curses/__init__.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable from _curses import * # noqa: F403 from _curses import _CursesWindow as _CursesWindow +from collections.abc import Callable from typing import Any, TypeVar _T = TypeVar("_T") diff --git a/stdlib/curses/textpad.pyi b/stdlib/curses/textpad.pyi index a919c1a2ecdb..49aac0d4e665 100644 --- a/stdlib/curses/textpad.pyi +++ b/stdlib/curses/textpad.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable from _curses import _CursesWindow - +from collections.abc import Callable def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 4678278ec2b5..4ba1bc19f822 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable, Mapping import sys import types +from collections.abc import Callable, Iterable, Mapping from typing import Any, Generic, Protocol, Type, TypeVar, overload if sys.version_info >= (3, 9): diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index b2c16e06b3e4..9ba06751c868 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator, MutableMapping from _typeshed import Self +from collections.abc import Iterator, MutableMapping from types import TracebackType from typing import Type, Union from typing_extensions import Literal diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index c4c89facf255..20584f4719e7 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator, MutableMapping from _typeshed import Self +from collections.abc import Iterator, MutableMapping from types import TracebackType from typing import Type, Union diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 284f4a1e152b..4fab78e91f4a 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -1,6 +1,6 @@ -from collections.abc import Container, Sequence import numbers import sys +from collections.abc import Container, Sequence from types import TracebackType from typing import Any, NamedTuple, Type, TypeVar, Union, overload diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index 371e083ea37d..a1a0884b5a50 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Iterator, Sequence import sys +from collections.abc import Callable, Iterable, Iterator, Sequence from typing import Any, AnyStr, Generic, NamedTuple, TypeVar, Union, overload if sys.version_info >= (3, 9): diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index 832fbfbdf0c3..5897425bd44a 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterator import sys import types +from collections.abc import Callable, Iterator from opcode import ( EXTENDED_ARG as EXTENDED_ARG, HAVE_ARGUMENT as HAVE_ARGUMENT, diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index b2fcd74c69a2..400c2595dda1 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable from abc import abstractmethod +from collections.abc import Callable, Iterable from distutils.dist import Distribution from typing import Any diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index a0fed84fb5cf..8be819ee8094 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Mapping from _typeshed import StrOrBytesPath, SupportsWrite +from collections.abc import Iterable, Mapping from distutils.cmd import Command from typing import IO, Any, Type diff --git a/stdlib/distutils/file_util.pyi b/stdlib/distutils/file_util.pyi index 0ab03496e26b..b3127841bce8 100644 --- a/stdlib/distutils/file_util.pyi +++ b/stdlib/distutils/file_util.pyi @@ -1,6 +1,5 @@ from collections.abc import Sequence - def copy_file( src: str, dst: str, diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index 5afcc7cc203f..bf7db9c8f06b 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -1,7 +1,6 @@ from collections.abc import Mapping from distutils.ccompiler import CCompiler - PREFIX: str EXEC_PREFIX: str diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index b291ff073066..da49d0799dc9 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import types import unittest +from collections.abc import Callable from typing import Any, NamedTuple, Type class TestResults(NamedTuple): diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index 61cf16ed523b..a6edc6e6a35e 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Iterator import sys +from collections.abc import Iterable, Iterator from email.errors import HeaderParseError, MessageDefect from email.policy import Policy from typing import Any, Pattern, Type, TypeVar, Union diff --git a/stdlib/email/iterators.pyi b/stdlib/email/iterators.pyi index 179c1b2190b8..735bbe50b2ff 100644 --- a/stdlib/email/iterators.pyi +++ b/stdlib/email/iterators.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterator from email.message import Message - def body_line_iterator(msg: Message, decode: bool = ...) -> Iterator[str]: ... def typed_subpart_iterator(msg: Message, maintype: str = ..., subtype: str | None = ...) -> Iterator[str]: ... diff --git a/stdlib/email/parser.pyi b/stdlib/email/parser.pyi index e044f458e8ca..0e03ec2f054a 100644 --- a/stdlib/email/parser.pyi +++ b/stdlib/email/parser.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import email.feedparser +from collections.abc import Callable from email.message import Message from email.policy import Policy from typing import BinaryIO, TextIO diff --git a/stdlib/email/policy.pyi b/stdlib/email/policy.pyi index 567573da8028..43604a490cb5 100644 --- a/stdlib/email/policy.pyi +++ b/stdlib/email/policy.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from abc import ABCMeta, abstractmethod +from collections.abc import Callable from email.contentmanager import ContentManager from email.errors import MessageDefect from email.header import Header diff --git a/stdlib/errno.pyi b/stdlib/errno.pyi index fcbe48570af4..28788de740aa 100644 --- a/stdlib/errno.pyi +++ b/stdlib/errno.pyi @@ -1,6 +1,5 @@ from collections.abc import Mapping - errorcode: Mapping[int, str] EPERM: int diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 424994270da6..f4654522f9ed 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable, Sequence import sys from _typeshed import StrOrBytesPath +from collections.abc import Callable, Iterable, Sequence from os import PathLike from typing import Any, AnyStr, Generic diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index c4c7b95ab153..edf0c2d5c9a0 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable, Iterator import sys from _typeshed import Self, StrOrBytesPath +from collections.abc import Callable, Iterable, Iterator from typing import IO, Any, AnyStr, Generic if sys.version_info >= (3, 9): diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index edb39a0b9ada..29e60d441ade 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable, Iterator import sys from _typeshed import Self, SupportsRead, SupportsReadline +from collections.abc import Callable, Iterable, Iterator from socket import socket from ssl import SSLContext from types import TracebackType diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 82f50ccc5124..c89a1e0d1eb6 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Hashable, Iterable, Sequence, Sized import sys import types from _typeshed import SupportsAllComparisons, SupportsItems +from collections.abc import Callable, Hashable, Iterable, Sequence, Sized from typing import Any, Generic, NamedTuple, Type, TypeVar, overload from typing_extensions import final diff --git a/stdlib/genericpath.pyi b/stdlib/genericpath.pyi index 09582d35ea8b..93df41252871 100644 --- a/stdlib/genericpath.pyi +++ b/stdlib/genericpath.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import os from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRichComparisonT +from collections.abc import Sequence from typing import overload from typing_extensions import Literal diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index 5868fd7371b9..e7f6ebef01f0 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -1,6 +1,6 @@ -from collections.abc import Container, Iterable, Sequence import sys from _typeshed import StrPath +from collections.abc import Container, Iterable, Sequence from typing import IO, Any, Type, TypeVar, overload from typing_extensions import Literal diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index b1c72f4191af..e1ee289d6ffb 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterator import sys from _typeshed import StrOrBytesPath +from collections.abc import Iterator from typing import AnyStr def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... diff --git a/stdlib/graphlib.pyi b/stdlib/graphlib.pyi index 583fd8a88fd2..6a1bbeb6be99 100644 --- a/stdlib/graphlib.pyi +++ b/stdlib/graphlib.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable from _typeshed import SupportsItems +from collections.abc import Iterable from typing import Generic, TypeVar _T = TypeVar("_T") diff --git a/stdlib/hashlib.pyi b/stdlib/hashlib.pyi index e39f2f25326e..9583e0be19d9 100644 --- a/stdlib/hashlib.pyi +++ b/stdlib/hashlib.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer, Self -from typing import AbstractSet +from collections.abc import Set as AbstractSet class _Hash(object): @property diff --git a/stdlib/heapq.pyi b/stdlib/heapq.pyi index 8d3c0d5d5fb3..960efa903a54 100644 --- a/stdlib/heapq.pyi +++ b/stdlib/heapq.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable from _typeshed import SupportsRichComparison +from collections.abc import Callable, Iterable from typing import Any, TypeVar _T = TypeVar("_T") diff --git a/stdlib/hmac.pyi b/stdlib/hmac.pyi index c4cc76bc4604..065261a92a80 100644 --- a/stdlib/hmac.pyi +++ b/stdlib/hmac.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer +from collections.abc import Callable from types import ModuleType from typing import Any, AnyStr, Union, overload diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 4a1eb8bcc2da..8bf655b34d7e 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -1,10 +1,10 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping import email.message import io import ssl import sys import types from _typeshed import Self, WriteableBuffer +from collections.abc import Callable, Iterable, Iterator, Mapping from socket import socket from typing import IO, Any, BinaryIO, Protocol, Type, TypeVar, Union, overload diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 3700570b2057..8594744ca11a 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable, Iterator, Sequence import sys from _typeshed import StrPath +from collections.abc import Iterable, Iterator, Sequence from http.client import HTTPResponse from typing import ClassVar, Pattern, TypeVar, overload from urllib.request import Request diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index ee6fc9e3e860..8d0df36d27a1 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Mapping import sys +from collections.abc import Iterable, Mapping from typing import Any, Generic, TypeVar, Union, overload if sys.version_info >= (3, 9): diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index f6b2a66af8ea..0caa23f9e2fc 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -1,9 +1,9 @@ -from collections.abc import Mapping, Sequence import email.message import io import socketserver import sys from _typeshed import StrPath, SupportsRead, SupportsWrite +from collections.abc import Mapping, Sequence from typing import Any, AnyStr, BinaryIO, ClassVar class HTTPServer(socketserver.TCPServer): diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 5d01663533c2..219efb9c7c7e 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable import subprocess import sys import time from _typeshed import Self +from collections.abc import Callable from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType diff --git a/stdlib/imghdr.pyi b/stdlib/imghdr.pyi index 85e475b1fa41..1919b91ee85c 100644 --- a/stdlib/imghdr.pyi +++ b/stdlib/imghdr.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import StrPath +from collections.abc import Callable from typing import Any, BinaryIO, Protocol, overload class _ReadableBinary(Protocol): diff --git a/stdlib/importlib/__init__.pyi b/stdlib/importlib/__init__.pyi index 748f536bdd7e..4df48484520c 100644 --- a/stdlib/importlib/__init__.pyi +++ b/stdlib/importlib/__init__.pyi @@ -2,7 +2,6 @@ from collections.abc import Mapping, Sequence from importlib.abc import Loader from types import ModuleType - # Signature of `builtins.__import__` should be kept identical to `importlib.__import__` def __import__( name: str, diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 6e45f234aabf..bf3fa99a5b78 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -1,4 +1,3 @@ -from collections.abc import Iterator, Mapping, Sequence import sys import types from _typeshed import ( @@ -11,6 +10,7 @@ from _typeshed import ( StrPath, ) from abc import ABCMeta, abstractmethod +from collections.abc import Iterator, Mapping, Sequence from importlib.machinery import ModuleSpec from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from typing import IO, Any, BinaryIO, NoReturn, Protocol, Union, overload, runtime_checkable diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index 4d481c0bf8f8..76280a8364df 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Iterable, Sequence import importlib.abc import sys import types +from collections.abc import Callable, Iterable, Sequence from typing import Any if sys.version_info >= (3, 8): diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index 5b85beb3640f..5cd8078482ca 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -1,9 +1,8 @@ -from collections.abc import Iterable import abc import pathlib import sys from _typeshed import StrPath -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from email.message import Message from importlib.abc import MetaPathFinder from os import PathLike diff --git a/stdlib/importlib/resources.pyi b/stdlib/importlib/resources.pyi index c856196332e3..571730949a8b 100644 --- a/stdlib/importlib/resources.pyi +++ b/stdlib/importlib/resources.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator import sys +from collections.abc import Iterator from typing import Any # This is a >=3.7 module, so we conditionally include its source. diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index 4e09c8cb8010..ad0e0a5515c3 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -1,9 +1,9 @@ -from collections.abc import Callable import importlib.abc import importlib.machinery import sys import types from _typeshed import StrOrBytesPath +from collections.abc import Callable from typing import Any from typing_extensions import ParamSpec diff --git a/stdlib/io.pyi b/stdlib/io.pyi index bc470d8d7c20..8ee492878450 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Iterable, Iterator import builtins import codecs import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer +from collections.abc import Callable, Iterable, Iterator from os import _Opener from types import TracebackType from typing import IO, Any, BinaryIO, TextIO, Type diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index e0b631bc652b..57f3536f5ded 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -1,5 +1,5 @@ -from collections.abc import Container, Iterable, Iterator import sys +from collections.abc import Container, Iterable, Iterator from typing import Any, Generic, SupportsInt, TypeVar, overload # Undocumented length constants diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 8b0a41922526..d1ea298c2e39 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -1,21 +1,7 @@ -from collections.abc import Callable, Iterable, Iterator import sys from _typeshed import _T_co -from typing import ( - Any, - - Generic, - - - SupportsComplex, - SupportsFloat, - SupportsInt, - - Type, - TypeVar, - Union, - overload, -) +from collections.abc import Callable, Iterable, Iterator +from typing import Any, Generic, SupportsComplex, SupportsFloat, SupportsInt, Type, TypeVar, Union, overload from typing_extensions import Literal, SupportsIndex if sys.version_info >= (3, 9): diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index 69871bfba614..9811f5225b89 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import SupportsRead +from collections.abc import Callable from typing import IO, Any, Type from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder diff --git a/stdlib/keyword.pyi b/stdlib/keyword.pyi index e0581663889d..18e386a37352 100644 --- a/stdlib/keyword.pyi +++ b/stdlib/keyword.pyi @@ -1,6 +1,5 @@ -from collections.abc import Sequence import sys - +from collections.abc import Sequence def iskeyword(s: str) -> bool: ... diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index c579cc568acd..40ed6a03790a 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable from _typeshed import StrPath +from collections.abc import Iterable from lib2to3.pgen2.grammar import Grammar from lib2to3.pytree import _NL, _Convert from logging import Logger diff --git a/stdlib/lib2to3/pgen2/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index abb4f8cdebb2..99926e923a18 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Iterator from _typeshed import StrPath +from collections.abc import Iterable, Iterator from lib2to3.pgen2 import grammar from lib2to3.pgen2.tokenize import _TokenInfo from typing import IO, Any, NoReturn diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index 0d920bc8f1e1..452b6246511b 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,7 +1,6 @@ from collections.abc import Callable, Iterable, Iterator from lib2to3.pgen2.token import * # noqa - _Coord = tuple[int, int] _TokenEater = Callable[[int, str, _Coord, _Coord, str], None] _TokenInfo = tuple[int, str, _Coord, _Coord, str] diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index ef4e15980989..3f80c4a924fd 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -1,9 +1,9 @@ -from collections.abc import Callable, Iterable, Mapping, Sequence import sys # This module defines a function "str()", which is why "str" can't be used # as a type annotation or type alias. from builtins import str as _str +from collections.abc import Callable, Iterable, Mapping, Sequence from decimal import Decimal from typing import Any diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index 68a61805614c..f3cc4afffe09 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -1,7 +1,6 @@ -from collections.abc import Sequence import sys from _typeshed import StrOrBytesPath, StrPath -from collections.abc import Callable +from collections.abc import Callable, Sequence from configparser import RawConfigParser from threading import Thread from typing import IO, Any, Pattern diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index 84231d655d5a..37e693120802 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -1,6 +1,6 @@ -from collections.abc import Mapping, Sequence import io from _typeshed import ReadableBuffer, Self, StrOrBytesPath +from collections.abc import Mapping, Sequence from typing import IO, Any, TextIO, Union, overload from typing_extensions import Literal, final diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 3dbf606e2252..37cfdcd1282f 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -1,24 +1,9 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence import email.message import sys from _typeshed import Self, StrOrBytesPath +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from types import TracebackType -from typing import ( - IO, - Any, - AnyStr, - - Generic, - - - - Protocol, - - Type, - TypeVar, - Union, - overload, -) +from typing import IO, Any, AnyStr, Generic, Protocol, Type, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/math.pyi b/stdlib/math.pyi index a7d907fb6464..11c6e6460b63 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable import sys from _typeshed import SupportsTrunc +from collections.abc import Iterable from typing import SupportsFloat, Union, overload from typing_extensions import SupportsIndex diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index e996498eb1a4..a5a23bc60350 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import sys from _typeshed import StrPath +from collections.abc import Sequence from typing import IO if sys.version_info >= (3, 8): diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 1a27d2d091bb..6a049c66ea96 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable, Iterator, Sized import sys from _typeshed import ReadableBuffer +from collections.abc import Iterable, Iterator, Sized from contextlib import AbstractContextManager from typing import NoReturn, overload diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index 25d2fd1c66c4..780796eeb5c8 100644 --- a/stdlib/modulefinder.pyi +++ b/stdlib/modulefinder.pyi @@ -1,5 +1,5 @@ -from collections.abc import Container, Iterable, Iterator, Sequence import sys +from collections.abc import Container, Iterable, Iterator, Sequence from types import CodeType from typing import IO, Any diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index b5f3d023619e..9660dd436c38 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Container, Iterable, Sequence import sys +from collections.abc import Container, Iterable, Sequence from types import ModuleType from typing import Any, Type from typing_extensions import Literal diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index da83213e5784..2825d75416ba 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -1,8 +1,8 @@ -from collections.abc import Iterable import socket import sys import types from _typeshed import Self +from collections.abc import Iterable from typing import Any, Type, Union if sys.version_info >= (3, 8): diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index 80e4403b7a5e..9778741ed6d2 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Iterable, Mapping, Sequence import array import threading import weakref +from collections.abc import Callable, Iterable, Mapping, Sequence from queue import Queue as Queue from typing import Any diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index fafc2cafebd2..240fdac042ed 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -1,9 +1,9 @@ # NOTE: These are incomplete! -from collections.abc import Callable, Iterable, Mapping, Sequence import queue import sys import threading +from collections.abc import Callable, Iterable, Mapping, Sequence from contextlib import AbstractContextManager from typing import Any, AnyStr, Generic, TypeVar diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index b58d871af769..82dbe29158d3 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping import sys from _typeshed import Self +from collections.abc import Callable, Iterable, Iterator, Mapping from contextlib import AbstractContextManager from typing import Any, Generic, TypeVar diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index eb3eb24e8e47..69032bd0d5e8 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Mapping import sys +from collections.abc import Callable, Mapping from typing import Any class BaseProcess: diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index 74cf3dcb98d6..2a75725b2681 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import sys +from collections.abc import Iterable from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 521846e5e06b..36ec97213d01 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import sys import threading +from collections.abc import Callable from contextlib import AbstractContextManager from multiprocessing.context import BaseContext from typing import Any, Union diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index abbc0388fb8c..163e917f4767 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -1,9 +1,9 @@ -from collections.abc import Iterable import datetime import socket import ssl import sys from _typeshed import Self +from collections.abc import Iterable from typing import IO, Any, NamedTuple, Union _File = Union[IO[bytes], bytes, str, None] diff --git a/stdlib/opcode.pyi b/stdlib/opcode.pyi index 3e2fb84b20d5..f9e193d492e9 100644 --- a/stdlib/opcode.pyi +++ b/stdlib/opcode.pyi @@ -1,6 +1,5 @@ -from collections.abc import Sequence import sys - +from collections.abc import Sequence cmp_op: Sequence[str] hasconst: list[int] diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 1d521050948c..742ac52ec1a4 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -1,4 +1,3 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence import sys from _typeshed import ( FileDescriptorLike, @@ -13,30 +12,11 @@ from _typeshed import ( structseq, ) from builtins import OSError +from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence from contextlib import AbstractContextManager from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper as _TextIOWrapper from subprocess import Popen -from typing import ( - IO, - Any, - AnyStr, - BinaryIO, - - Generic, - - - - - - NoReturn, - Protocol, - - - TypeVar, - Union, - overload, - runtime_checkable, -) +from typing import IO, Any, AnyStr, BinaryIO, Generic, NoReturn, Protocol, TypeVar, Union, overload, runtime_checkable from typing_extensions import Literal, final from . import path as _path diff --git a/stdlib/parser.pyi b/stdlib/parser.pyi index 06da2febfe9a..5ffd55cb4804 100644 --- a/stdlib/parser.pyi +++ b/stdlib/parser.pyi @@ -1,5 +1,5 @@ -from collections.abc import Sequence from _typeshed import StrOrBytesPath +from collections.abc import Sequence from types import CodeType from typing import Any diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index d34ec1300a66..f5cececa18e3 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -1,4 +1,3 @@ -from collections.abc import Generator, Sequence import sys from _typeshed import ( OpenBinaryMode, @@ -9,6 +8,7 @@ from _typeshed import ( Self, StrPath, ) +from collections.abc import Generator, Sequence from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from os import PathLike, stat_result from types import TracebackType diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index 82f436a00963..497bc17877ce 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Iterable, Mapping, Sequence import signal import sys from bdb import Bdb from cmd import Cmd +from collections.abc import Callable, Iterable, Mapping, Sequence from inspect import _SourceObjectType from types import CodeType, FrameType, TracebackType from typing import IO, Any, ClassVar, TypeVar diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index d5754420e8cd..92c81e06d696 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping import sys +from collections.abc import Callable, Iterable, Iterator, Mapping from typing import Any, ClassVar, Optional, Protocol, Type, Union from typing_extensions import final diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index 9bf908d77a48..8222903fcef6 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable, Iterator import sys from _typeshed import SupportsRead +from collections.abc import Callable, Iterable, Iterator from importlib.abc import Loader, MetaPathFinder, PathEntryFinder from typing import IO, Any, NamedTuple diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index 5a380ac9583a..cb71ed538f89 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -1,5 +1,5 @@ -from collections.abc import Mapping, MutableMapping import sys +from collections.abc import Mapping, MutableMapping from datetime import datetime from enum import Enum from typing import IO, Any, Type diff --git a/stdlib/posixpath.pyi b/stdlib/posixpath.pyi index 55449b511e84..141835c7afaa 100644 --- a/stdlib/posixpath.pyi +++ b/stdlib/posixpath.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import sys from _typeshed import BytesPath, StrOrBytesPath, StrPath +from collections.abc import Sequence from genericpath import ( commonprefix as commonprefix, exists as exists, diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index 9a8a38a5e75c..58688c7cee7d 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import StrOrBytesPath +from collections.abc import Callable from typing import Any, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index f46ee70dfbc6..12629332998b 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable import sys from _typeshed import StrOrBytesPath +from collections.abc import Iterable from cProfile import Profile as _cProfile from profile import Profile from typing import IO, Any, TypeVar, Union, overload diff --git a/stdlib/pty.pyi b/stdlib/pty.pyi index ecac08809945..3f7c2dddbee4 100644 --- a/stdlib/pty.pyi +++ b/stdlib/pty.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Iterable - _Reader = Callable[[int], bytes] STDIN_FILENO: int diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index aa6f45ecc8cb..1bc4b2c936c4 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -1,6 +1,5 @@ -from collections.abc import Sequence import sys - +from collections.abc import Sequence class Class: module: str diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 07c3e9600891..a7039e8b6cd0 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Container, Mapping, MutableMapping from _typeshed import SupportsWrite +from collections.abc import Callable, Container, Mapping, MutableMapping from reprlib import Repr from types import MethodType, ModuleType, TracebackType from typing import IO, Any, AnyStr, NoReturn, Optional, Type diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 9e5940d4d944..53643e4252a7 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable import pyexpat.errors as errors import pyexpat.model as model from _typeshed import SupportsRead +from collections.abc import Callable from typing import Any, Optional from typing_extensions import final diff --git a/stdlib/re.pyi b/stdlib/re.pyi index a2489760e4f6..7a537229307a 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterator import enum import sys +from collections.abc import Callable, Iterator from sre_constants import error as error from typing import Any, AnyStr, Union, overload diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index a68fbc7d7449..74cf7aedb705 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Sequence from _typeshed import StrOrBytesPath +from collections.abc import Callable, Sequence from typing import Optional _CompleterT = Optional[Callable[[str, int], Optional[str]]] diff --git a/stdlib/reprlib.pyi b/stdlib/reprlib.pyi index 8534dc0b2ba4..4d0214fc1423 100644 --- a/stdlib/reprlib.pyi +++ b/stdlib/reprlib.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable from array import array from collections import deque +from collections.abc import Callable from typing import Any _ReprFunc = Callable[[Any], str] diff --git a/stdlib/select.pyi b/stdlib/select.pyi index 73258991782d..705f7b554f33 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable import sys from _typeshed import FileDescriptorLike, Self +from collections.abc import Iterable from types import TracebackType from typing import Any, Type diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index af35783ef08d..e885cc41441c 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -1,7 +1,7 @@ -from collections.abc import Mapping import sys from _typeshed import FileDescriptor, FileDescriptorLike, Self from abc import ABCMeta, abstractmethod +from collections.abc import Mapping from typing import Any, NamedTuple _EventMask = int diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index 60c8f6e8ffda..23cd66bb21e2 100644 --- a/stdlib/shlex.pyi +++ b/stdlib/shlex.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import sys +from collections.abc import Iterable from typing import Any, TextIO, TypeVar def split(s: str, comments: bool = ..., posix: bool = ...) -> list[str]: ... diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index d28c5308e67c..f3441dd88668 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Iterable, Sequence import os import sys from _typeshed import StrOrBytesPath, StrPath, SupportsRead, SupportsWrite +from collections.abc import Callable, Iterable, Sequence from typing import Any, AnyStr, NamedTuple, TypeVar, Union, overload _PathT = TypeVar("_PathT", str, os.PathLike[str]) diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index 1ed954ca647b..53705553d6a3 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable import sys from _typeshed import structseq +from collections.abc import Callable, Iterable from enum import IntEnum from types import FrameType from typing import Any, Optional, Union diff --git a/stdlib/site.pyi b/stdlib/site.pyi index 787b61222af2..53199db0eaf3 100644 --- a/stdlib/site.pyi +++ b/stdlib/site.pyi @@ -1,6 +1,5 @@ -from collections.abc import Iterable from _typeshed import StrPath - +from collections.abc import Iterable PREFIXES: list[str] ENABLE_USER_SITE: bool | None diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 9480a184b41d..67f692d8b0fd 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import sys from _typeshed import Self +from collections.abc import Sequence from email.message import Message as _Message from socket import socket from ssl import SSLContext diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index ed46f8ea4362..038a01da04cf 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable import sys import types from _typeshed import Self +from collections.abc import Callable from socket import socket as _socket from typing import Any, BinaryIO, ClassVar, Type, TypeVar, Union diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index b3949875ceee..fff0401ae0c6 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Generator, Iterable, Iterator import sys from _typeshed import Self, StrOrBytesPath +from collections.abc import Callable, Generator, Iterable, Iterator from datetime import date, datetime, time from typing import Any, Protocol, Type, TypeVar diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index ea6baa9a167b..1a7d565502ff 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import sys +from collections.abc import Iterable from sre_constants import * from sre_constants import _NamedIntConstant as _NIC, error as _Error from typing import Any, Match, Optional, Pattern as _Pattern, Union, overload diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index a6751ddf6934..4991ccbd5d3b 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Iterable import enum import socket import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer +from collections.abc import Callable, Iterable from typing import Any, ClassVar, NamedTuple, Optional, Type, Union, overload from typing_extensions import Literal, TypedDict diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index eebd972fe8cc..61b56cfbf3f2 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -1,6 +1,6 @@ -from collections.abc import Hashable, Iterable, Sequence import sys from _typeshed import SupportsRichComparisonT +from collections.abc import Hashable, Iterable, Sequence from decimal import Decimal from fractions import Fraction from typing import Any, NamedTuple, SupportsFloat, Type, TypeVar, Union diff --git a/stdlib/string.pyi b/stdlib/string.pyi index df9bbf706f08..9c01cdd27709 100644 --- a/stdlib/string.pyi +++ b/stdlib/string.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Mapping, Sequence import sys +from collections.abc import Iterable, Mapping, Sequence from re import RegexFlag from typing import Any diff --git a/stdlib/struct.pyi b/stdlib/struct.pyi index 937131af9769..70f6ebbe25f9 100644 --- a/stdlib/struct.pyi +++ b/stdlib/struct.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterator import sys from _typeshed import ReadableBuffer, WriteableBuffer +from collections.abc import Iterator from typing import Any class error(Exception): ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 910a8907fbb3..007499145f1f 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable, Mapping, Sequence import sys from _typeshed import Self, StrOrBytesPath +from collections.abc import Callable, Iterable, Mapping, Sequence from types import TracebackType from typing import IO, Any, AnyStr, Generic, Type, TypeVar, Union, overload from typing_extensions import Literal diff --git a/stdlib/symtable.pyi b/stdlib/symtable.pyi index 33a6f286502d..8f1024785fed 100644 --- a/stdlib/symtable.pyi +++ b/stdlib/symtable.pyi @@ -1,5 +1,5 @@ -from collections.abc import Sequence import sys +from collections.abc import Sequence from typing import Any def symtable(code: str, filename: str, compile_type: str) -> SymbolTable: ... diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index 7ff38a8eaa87..f3744fff50d5 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -1,25 +1,11 @@ -from collections.abc import AsyncGenerator, Callable, Sequence import sys from builtins import object as _object +from collections.abc import AsyncGenerator, Callable, Sequence from importlib.abc import PathEntryFinder from importlib.machinery import ModuleSpec from io import TextIOWrapper from types import FrameType, ModuleType, TracebackType -from typing import ( - Any, - - - NoReturn, - Optional, - Protocol, - - TextIO, - - Type, - TypeVar, - Union, - overload, -) +from typing import Any, NoReturn, Optional, Protocol, TextIO, Type, TypeVar, Union, overload from typing_extensions import Literal _T = TypeVar("_T") diff --git a/stdlib/tabnanny.pyi b/stdlib/tabnanny.pyi index fb4103eeafd3..736bcae7013f 100644 --- a/stdlib/tabnanny.pyi +++ b/stdlib/tabnanny.pyi @@ -1,6 +1,5 @@ -from collections.abc import Iterable from _typeshed import StrOrBytesPath - +from collections.abc import Iterable verbose: int filename_only: int diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index 217229a61438..d9f44faf1722 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Sequence import socket from _typeshed import Self +from collections.abc import Callable, Sequence from typing import Any, Match, Pattern DEBUGLEVEL: int diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index b7db68465093..6d290ae5f235 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -1,7 +1,7 @@ -from collections.abc import Iterable, Iterator import os import sys from _typeshed import Self +from collections.abc import Iterable, Iterator from types import TracebackType from typing import IO, Any, AnyStr, Generic, Type, Union, overload from typing_extensions import Literal diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index f7432cf41900..f4b7ab105c83 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Mapping import sys +from collections.abc import Callable, Iterable, Mapping from types import FrameType, TracebackType from typing import Any, Optional, Type, TypeVar diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 4bb0f39b1f55..29ef60bf3e22 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Mapping, Sequence import _tkinter import sys from _typeshed import StrOrBytesPath +from collections.abc import Callable, Mapping, Sequence from enum import Enum from tkinter.constants import * from tkinter.font import _FontDescription diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index d6b38693f07a..a8266d322c11 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable from _typeshed import StrOrBytesPath +from collections.abc import Iterable from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog from typing import IO, Any, ClassVar from typing_extensions import Literal diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 3f6d753dba55..00694f3e29a4 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable import _tkinter import sys import tkinter +from collections.abc import Callable from tkinter.font import _FontDescription from typing import Any, Union, overload from typing_extensions import Literal, TypedDict diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index fa7f92f1a0d5..0714e76f764a 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Generator, Iterable, Sequence import sys from _typeshed import StrOrBytesPath from builtins import open as _builtin_open +from collections.abc import Callable, Generator, Iterable, Sequence from token import * # noqa: F403 from typing import Any, NamedTuple, Pattern, TextIO, Union diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index a88b0f75ffa6..d90c95bd6cdd 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Mapping, Sequence import sys import types from _typeshed import StrPath +from collections.abc import Callable, Mapping, Sequence from typing import Any, Optional, TypeVar from typing_extensions import ParamSpec diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index 5123336ad142..933a1ffc767e 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -1,6 +1,6 @@ -from collections.abc import Generator, Iterable, Iterator, Mapping import sys from _typeshed import SupportsWrite +from collections.abc import Generator, Iterable, Iterator, Mapping from types import FrameType, TracebackType from typing import IO, Any, Optional, Type, overload diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 6e0599ac2688..35ac8782a5ed 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import sys from _tracemalloc import * +from collections.abc import Sequence from typing import Optional, Union, overload from typing_extensions import SupportsIndex diff --git a/stdlib/types.pyi b/stdlib/types.pyi index f38bca93b90a..3a219a11e2ba 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -1,28 +1,22 @@ -from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Generator, ItemsView, Iterable, Iterator, KeysView, Mapping, MutableSequence, ValuesView import sys from _typeshed import SupportsKeysAndGetItem +from collections.abc import ( + AsyncGenerator, + Awaitable, + Callable, + Coroutine, + Generator, + ItemsView, + Iterable, + Iterator, + KeysView, + Mapping, + MutableSequence, + ValuesView, +) from importlib.abc import _LoaderProtocol from importlib.machinery import ModuleSpec -from typing import ( - Any, - - - - - - Generic, - - - - - - - - Type, - TypeVar, - - overload, -) +from typing import Any, Generic, Type, TypeVar, overload from typing_extensions import Literal, ParamSpec, final # Note, all classes "defined" here require special handling. diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 06ae9043eadd..380a61b4a231 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -1,33 +1,29 @@ -from collections.abc import AsyncGenerator as AsyncGenerator, AsyncIterable as AsyncIterable, AsyncIterator as AsyncIterator, Awaitable as Awaitable, Callable, Coroutine as Coroutine, ItemsView, KeysView, Mapping, ValuesView -from collections import ChainMap as ChainMap, Counter as Counter, defaultdict as DefaultDict, deque as Deque import abc import sys +from collections import ChainMap as ChainMap, Counter as Counter, defaultdict as DefaultDict, deque as Deque +from collections.abc import ( + AsyncGenerator as AsyncGenerator, + AsyncIterable as AsyncIterable, + AsyncIterator as AsyncIterator, + Awaitable as Awaitable, + Callable, + Coroutine as Coroutine, + ItemsView, + KeysView, + Mapping, + ValuesView, +) from typing import ( TYPE_CHECKING as TYPE_CHECKING, Any, AsyncContextManager as AsyncContextManager, - - - - - - ClassVar as ClassVar, ContextManager as ContextManager, - - - - - - - NewType as NewType, NoReturn as NoReturn, Text as Text, - Type as Type, TypeVar, - _Alias, overload as overload, ) diff --git a/stdlib/unittest/async_case.pyi b/stdlib/unittest/async_case.pyi index 8912c2c26fbb..7d4c8b28b17c 100644 --- a/stdlib/unittest/async_case.pyi +++ b/stdlib/unittest/async_case.pyi @@ -1,5 +1,5 @@ -from collections.abc import Awaitable, Callable import sys +from collections.abc import Awaitable, Callable from typing import Any from .case import TestCase diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index b3c71066eb13..e87931eb4f75 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -1,30 +1,12 @@ -from collections.abc import Callable, Container, Iterable, Mapping, Sequence import datetime import logging import sys import unittest.result from _typeshed import Self -from collections.abc import Set # equivalent to typing.AbstractSet, not builtins.set +from collections.abc import Callable, Container, Iterable, Mapping, Sequence, Set as AbstractSet from contextlib import AbstractContextManager from types import TracebackType -from typing import ( - Any, - AnyStr, - - ClassVar, - - Generic, - - - NamedTuple, - NoReturn, - Pattern, - - - Type, - TypeVar, - overload, -) +from typing import Any, AnyStr, ClassVar, Generic, NamedTuple, NoReturn, Pattern, Type, TypeVar, overload from warnings import WarningMessage if sys.version_info >= (3, 9): @@ -202,7 +184,7 @@ class TestCase: ) -> None: ... def assertListEqual(self, list1: list[Any], list2: list[Any], msg: Any = ...) -> None: ... def assertTupleEqual(self, tuple1: tuple[Any, ...], tuple2: tuple[Any, ...], msg: Any = ...) -> None: ... - def assertSetEqual(self, set1: Set[object], set2: Set[object], msg: Any = ...) -> None: ... + def assertSetEqual(self, set1: AbstractSet[object], set2: AbstractSet[object], msg: Any = ...) -> None: ... def assertDictEqual(self, d1: Mapping[Any, object], d2: Mapping[Any, object], msg: Any = ...) -> None: ... def fail(self, msg: Any = ...) -> NoReturn: ... def countTestCases(self) -> int: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 07503f5134dc..b4066b8ba756 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Sequence import sys import unittest.case import unittest.result import unittest.suite +from collections.abc import Callable, Sequence from types import ModuleType from typing import Any, Pattern, Type diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 321e68d24d80..37c856d8b5b2 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -1,9 +1,9 @@ -from collections.abc import Iterable import sys import unittest.case import unittest.loader import unittest.result import unittest.suite +from collections.abc import Iterable from types import ModuleType from typing import Any, Protocol, Type diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 1697737af709..0a2c944672ac 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -1,5 +1,5 @@ -from collections.abc import Awaitable, Callable, Iterable, Mapping, Sequence import sys +from collections.abc import Awaitable, Callable, Iterable, Mapping, Sequence from typing import Any, Generic, Type, TypeVar, overload _T = TypeVar("_T") diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 6bf2ba420408..8dc9097fc333 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import unittest.case +from collections.abc import Callable from types import TracebackType from typing import Any, TextIO, Type, TypeVar, Union diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index 53b1ee5fef87..53cba67826b0 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable import unittest.case import unittest.result import unittest.suite +from collections.abc import Callable from typing import TextIO, Type _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] diff --git a/stdlib/unittest/signals.pyi b/stdlib/unittest/signals.pyi index 392cbca90339..7799c17cd96f 100644 --- a/stdlib/unittest/signals.pyi +++ b/stdlib/unittest/signals.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import unittest.result +from collections.abc import Callable from typing import TypeVar, overload from typing_extensions import ParamSpec diff --git a/stdlib/unittest/suite.pyi b/stdlib/unittest/suite.pyi index 43e15533f71c..e4f913d48603 100644 --- a/stdlib/unittest/suite.pyi +++ b/stdlib/unittest/suite.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable, Iterator import unittest.case import unittest.result +from collections.abc import Iterable, Iterator from typing import Union _TestType = Union[unittest.case.TestCase, TestSuite] diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index e1d70a8c68d5..d5ad608266ac 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Mapping, Sequence import sys +from collections.abc import Callable, Mapping, Sequence from typing import Any, AnyStr, Generic, NamedTuple, Union, overload if sys.version_info >= (3, 9): diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 13e7ca309f3d..249832c4f691 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Mapping, Sequence import ssl import sys from _typeshed import StrOrBytesPath +from collections.abc import Callable, Mapping, Sequence from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar diff --git a/stdlib/urllib/response.pyi b/stdlib/urllib/response.pyi index 264c11fe0ab9..5dac1df9e536 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Iterable import sys from _typeshed import Self +from collections.abc import Callable, Iterable from email.message import Message from types import TracebackType from typing import IO, Any, BinaryIO, Type, TypeVar diff --git a/stdlib/urllib/robotparser.pyi b/stdlib/urllib/robotparser.pyi index 8a29d8bda69a..4156a4beff82 100644 --- a/stdlib/urllib/robotparser.pyi +++ b/stdlib/urllib/robotparser.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import sys +from collections.abc import Iterable from typing import NamedTuple class _RequestRate(NamedTuple): diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index d240813e48c8..85a25246c410 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,5 +1,5 @@ -from collections.abc import Sequence from _warnings import warn as warn, warn_explicit as warn_explicit +from collections.abc import Sequence from types import ModuleType, TracebackType from typing import Any, TextIO, Type, overload from typing_extensions import Literal diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index e22924437129..39d07116f2c8 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping from _weakrefset import WeakSet as WeakSet +from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping from typing import Any, Generic, Type, TypeVar, overload from _weakref import ( diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index 6acb72c282da..7abaa8ad6fb7 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable, Sequence import sys - +from collections.abc import Callable, Sequence class Error(Exception): ... diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index 3fe87c57e876..79a033c64712 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, MutableMapping from abc import abstractmethod +from collections.abc import Callable, MutableMapping from types import TracebackType from typing import IO, Optional, Type diff --git a/stdlib/wsgiref/util.pyi b/stdlib/wsgiref/util.pyi index 7484004dfa9f..9eb42deb9dcf 100644 --- a/stdlib/wsgiref/util.pyi +++ b/stdlib/wsgiref/util.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import sys +from collections.abc import Callable from typing import IO, Any from .types import WSGIEnvironment diff --git a/stdlib/wsgiref/validate.pyi b/stdlib/wsgiref/validate.pyi index e3fae57525c4..54d33eb8788e 100644 --- a/stdlib/wsgiref/validate.pyi +++ b/stdlib/wsgiref/validate.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Iterator from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication +from collections.abc import Callable, Iterable, Iterator from typing import Any, NoReturn class WSGIWarning(Warning): ... diff --git a/stdlib/xml/dom/domreg.pyi b/stdlib/xml/dom/domreg.pyi index 1b91c1f01bfd..5a276ae5f561 100644 --- a/stdlib/xml/dom/domreg.pyi +++ b/stdlib/xml/dom/domreg.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable, Iterable from _typeshed.xml import DOMImplementation - +from collections.abc import Callable, Iterable well_known_implementations: dict[str, str] registered: dict[str, Callable[[], DOMImplementation]] diff --git a/stdlib/xml/dom/pulldom.pyi b/stdlib/xml/dom/pulldom.pyi index 2417204cc971..f66815a1c879 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -1,5 +1,5 @@ -from collections.abc import Sequence import sys +from collections.abc import Sequence from typing import IO, Any, Union from typing_extensions import Literal from xml.dom.minidom import Document, DOMImplementation, Element, Text diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 3f09a23c2af6..06a16b9f8095 100644 --- a/stdlib/xml/etree/ElementInclude.pyi +++ b/stdlib/xml/etree/ElementInclude.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable import sys - +from collections.abc import Callable from xml.etree.ElementTree import Element XINCLUDE: str diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index dc1bec89d267..8ac390ebc03c 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -1,23 +1,7 @@ -from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, KeysView, Mapping, MutableSequence, Sequence import sys from _typeshed import FileDescriptor, StrOrBytesPath, SupportsWrite -from typing import ( - IO, - Any, - - - - - - - - - - - TypeVar, - Union, - overload, -) +from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, KeysView, Mapping, MutableSequence, Sequence +from typing import IO, Any, TypeVar, Union, overload from typing_extensions import Literal, SupportsIndex _T = TypeVar("_T") diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index 660be30bc915..8ba286ab5772 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import sys +from collections.abc import Iterable from typing import IO, Any, NoReturn from xml.sax.handler import ContentHandler, ErrorHandler from xml.sax.xmlreader import Locator, XMLReader diff --git a/stdlib/xml/sax/saxutils.pyi b/stdlib/xml/sax/saxutils.pyi index 6d4c5b06a69e..1361949d0c3e 100644 --- a/stdlib/xml/sax/saxutils.pyi +++ b/stdlib/xml/sax/saxutils.pyi @@ -1,8 +1,7 @@ -from collections.abc import Mapping from _typeshed import SupportsWrite from codecs import StreamReaderWriter, StreamWriter +from collections.abc import Mapping from io import RawIOBase, TextIOBase - from xml.sax import handler, xmlreader def escape(data: str, entities: Mapping[str, str] = ...) -> str: ... diff --git a/stdlib/xml/sax/xmlreader.pyi b/stdlib/xml/sax/xmlreader.pyi index a1b4a21fd6a8..d7d4db5b0a16 100644 --- a/stdlib/xml/sax/xmlreader.pyi +++ b/stdlib/xml/sax/xmlreader.pyi @@ -1,6 +1,5 @@ from collections.abc import Mapping - class XMLReader: def __init__(self) -> None: ... def parse(self, source): ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 09fd839b5cc0..05ad10871b51 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -1,9 +1,9 @@ -from collections.abc import Callable, Iterable, Mapping import gzip import http.client import sys import time from _typeshed import Self, SupportsRead, SupportsWrite +from collections.abc import Callable, Iterable, Mapping from datetime import datetime from io import BytesIO from types import TracebackType diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index 2f5e2187c1a3..4e807d9f80ea 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Iterable, Mapping import http.server import pydoc import socketserver import sys +from collections.abc import Callable, Iterable, Mapping from datetime import datetime from typing import Any, Pattern, Protocol, Type, Union from xmlrpc.client import Fault diff --git a/stdlib/zipapp.pyi b/stdlib/zipapp.pyi index 58b765a31869..fe3c36770ee8 100644 --- a/stdlib/zipapp.pyi +++ b/stdlib/zipapp.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import sys +from collections.abc import Callable from pathlib import Path from typing import BinaryIO, Union diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 75608427ee46..00bf8a9a4f65 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -1,7 +1,7 @@ -from collections.abc import Callable, Iterable, Iterator, Sequence import io import sys from _typeshed import Self, StrPath +from collections.abc import Callable, Iterable, Iterator, Sequence from os import PathLike from types import TracebackType from typing import IO, Any, Protocol, Type, overload diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 5d7cd52d728b..5512c5277a6b 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable, Sequence import typing from _typeshed import StrPath +from collections.abc import Iterable, Sequence from datetime import tzinfo from typing import Any, Protocol, Type From 623cf1c6de6ab1c80c1857f2d312cc43c3750381 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Dec 2021 23:03:33 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/venv/__init__.pyi | 1 - .../DateTimeRange/datetimerange/__init__.pyi | 3 +-- stubs/Pillow/PIL/ExifTags.pyi | 1 - stubs/Pillow/PIL/Image.pyi | 3 +-- stubs/Pillow/PIL/ImageDraw.pyi | 3 +-- stubs/Pillow/PIL/ImageFilter.pyi | 2 +- stubs/PyMySQL/pymysql/__init__.pyi | 1 - stubs/Pygments/pygments/token.pyi | 1 - stubs/aiofiles/aiofiles/base.pyi | 2 +- stubs/aiofiles/aiofiles/os.pyi | 2 +- .../aiofiles/aiofiles/threadpool/__init__.pyi | 2 +- stubs/aiofiles/aiofiles/threadpool/binary.pyi | 3 +-- stubs/aiofiles/aiofiles/threadpool/text.pyi | 2 +- stubs/atomicwrites/atomicwrites/__init__.pyi | 2 +- .../aws_xray_sdk/core/recorder.pyi | 2 +- stubs/beautifulsoup4/bs4/__init__.pyi | 2 +- stubs/beautifulsoup4/bs4/element.pyi | 3 +-- stubs/beautifulsoup4/bs4/formatter.pyi | 1 - stubs/boto/boto/utils.pyi | 2 +- stubs/cachetools/cachetools/__init__.pyi | 3 +-- stubs/cachetools/cachetools/func.pyi | 2 +- stubs/cachetools/cachetools/keys.pyi | 1 - stubs/chardet/chardet/langbulgarianmodel.pyi | 2 -- stubs/chardet/chardet/langcyrillicmodel.pyi | 2 -- stubs/chardet/chardet/langgreekmodel.pyi | 2 -- stubs/chardet/chardet/langhebrewmodel.pyi | 2 -- stubs/chardet/chardet/langhungarianmodel.pyi | 2 -- stubs/chardet/chardet/langthaimodel.pyi | 2 -- stubs/chardet/chardet/langturkishmodel.pyi | 2 -- .../click-spinner/click_spinner/__init__.pyi | 2 +- stubs/colorama/colorama/ansitowin32.pyi | 2 +- stubs/colorama/colorama/win32.pyi | 3 +-- stubs/contextvars/contextvars.pyi | 2 +- stubs/croniter/croniter.pyi | 2 +- .../cryptography/x509/__init__.pyi | 2 +- stubs/dataclasses/dataclasses.pyi | 2 +- stubs/dateparser/dateparser/date.pyi | 2 +- .../dateparser/languages/loader.pyi | 2 +- .../dateparser/dateparser/utils/__init__.pyi | 2 +- stubs/decorator/decorator.pyi | 2 +- stubs/editdistance/editdistance.pyi | 1 - stubs/entrypoints/entrypoints.pyi | 2 +- stubs/flake8-2020/flake8_2020.pyi | 2 +- stubs/flake8-bugbear/bugbear.pyi | 2 +- stubs/flake8-builtins/flake8_builtins.pyi | 2 +- stubs/flake8-docstrings/flake8_docstrings.pyi | 2 +- .../flake8_plugin_utils/plugin.pyi | 2 +- stubs/flake8-simplify/flake8_simplify.pyi | 2 +- .../flake8_typing_imports.pyi | 2 +- stubs/frozendict/frozendict.pyi | 2 +- .../google/cloud/ndb/model.pyi | 3 +-- stubs/hdbcli/hdbcli/dbapi.pyi | 2 +- stubs/jsonschema/jsonschema/_types.pyi | 1 - stubs/mypy-extensions/mypy_extensions.pyi | 2 +- stubs/paramiko/paramiko/auth_handler.pyi | 1 - stubs/paramiko/paramiko/hostkeys.pyi | 1 - stubs/paramiko/paramiko/kex_curve25519.pyi | 3 +-- stubs/paramiko/paramiko/kex_ecdh_nist.pyi | 3 +-- stubs/paramiko/paramiko/kex_gex.pyi | 3 +-- stubs/paramiko/paramiko/kex_group1.pyi | 3 +-- stubs/paramiko/paramiko/kex_group14.pyi | 3 +-- stubs/paramiko/paramiko/kex_group16.pyi | 3 +-- stubs/paramiko/paramiko/message.pyi | 2 +- stubs/paramiko/paramiko/packet.pyi | 2 +- stubs/paramiko/paramiko/py3compat.pyi | 2 +- stubs/paramiko/paramiko/server.pyi | 1 - stubs/paramiko/paramiko/ssh_exception.pyi | 3 +-- stubs/paramiko/paramiko/util.pyi | 2 +- stubs/polib/polib.pyi | 2 +- stubs/psutil/psutil/__init__.pyi | 2 +- stubs/psutil/psutil/_common.pyi | 2 +- stubs/pyOpenSSL/OpenSSL/SSL.pyi | 2 +- stubs/python-dateutil/dateutil/rrule.pyi | 2 +- stubs/python-slugify/slugify/slugify.pyi | 1 - stubs/python-slugify/slugify/special.pyi | 1 - stubs/pytz/pytz/__init__.pyi | 2 +- stubs/redis/redis/client.pyi | 19 ++----------------- stubs/requests/requests/cookies.pyi | 2 +- stubs/requests/requests/models.pyi | 2 +- stubs/requests/requests/sessions.pyi | 2 +- stubs/retry/retry/api.pyi | 2 +- stubs/setuptools/pkg_resources/__init__.pyi | 2 +- stubs/setuptools/setuptools/command/test.pyi | 2 +- stubs/toml/toml.pyi | 2 +- stubs/toposort/toposort.pyi | 2 +- stubs/typed-ast/typed_ast/ast27.pyi | 2 +- stubs/typed-ast/typed_ast/ast3.pyi | 2 +- stubs/vobject/vobject/base.pyi | 3 +-- stubs/waitress/waitress/channel.pyi | 1 - stubs/waitress/waitress/task.pyi | 2 +- stubs/waitress/waitress/trigger.pyi | 3 +-- 91 files changed, 71 insertions(+), 131 deletions(-) diff --git a/stdlib/venv/__init__.pyi b/stdlib/venv/__init__.pyi index 96d133c7cdef..b6683beb8244 100644 --- a/stdlib/venv/__init__.pyi +++ b/stdlib/venv/__init__.pyi @@ -3,7 +3,6 @@ import sys from _typeshed import StrOrBytesPath from types import SimpleNamespace - if sys.version_info >= (3, 9): CORE_VENV_DEPS: tuple[str, ...] diff --git a/stubs/DateTimeRange/datetimerange/__init__.pyi b/stubs/DateTimeRange/datetimerange/__init__.pyi index 61ae72eca2d4..15fc8e07336a 100644 --- a/stubs/DateTimeRange/datetimerange/__init__.pyi +++ b/stubs/DateTimeRange/datetimerange/__init__.pyi @@ -1,6 +1,5 @@ -from collections.abc import Iterable import datetime - +from collections.abc import Iterable from dateutil.relativedelta import relativedelta diff --git a/stubs/Pillow/PIL/ExifTags.pyi b/stubs/Pillow/PIL/ExifTags.pyi index 8aad8b764811..ada23d32958d 100644 --- a/stubs/Pillow/PIL/ExifTags.pyi +++ b/stubs/Pillow/PIL/ExifTags.pyi @@ -1,5 +1,4 @@ from collections.abc import Mapping - TAGS: Mapping[int, str] GPSTAGS: Mapping[int, str] diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index a98a3d7e782c..de07e1c81396 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable, Sequence from _typeshed import SupportsRead, SupportsWrite -from collections.abc import Iterable, Iterator, MutableMapping +from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence from pathlib import Path from typing import Any, Protocol, SupportsBytes, Union from typing_extensions import Literal diff --git a/stubs/Pillow/PIL/ImageDraw.pyi b/stubs/Pillow/PIL/ImageDraw.pyi index 63251213730f..d49e94cb9b90 100644 --- a/stubs/Pillow/PIL/ImageDraw.pyi +++ b/stubs/Pillow/PIL/ImageDraw.pyi @@ -1,5 +1,4 @@ -from collections.abc import Sequence -from collections.abc import Container +from collections.abc import Container, Sequence from typing import Any, Union, overload from typing_extensions import Literal diff --git a/stubs/Pillow/PIL/ImageFilter.pyi b/stubs/Pillow/PIL/ImageFilter.pyi index 565e559adb5e..18bdd7a27003 100644 --- a/stubs/Pillow/PIL/ImageFilter.pyi +++ b/stubs/Pillow/PIL/ImageFilter.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Sequence from _typeshed import Self +from collections.abc import Callable, Iterable, Sequence from typing import Any, Type from typing_extensions import Literal diff --git a/stubs/PyMySQL/pymysql/__init__.pyi b/stubs/PyMySQL/pymysql/__init__.pyi index 80966cdddbe7..c501ab39a9a6 100644 --- a/stubs/PyMySQL/pymysql/__init__.pyi +++ b/stubs/PyMySQL/pymysql/__init__.pyi @@ -1,6 +1,5 @@ import sys - from .connections import Connection as Connection from .constants import FIELD_TYPE as FIELD_TYPE from .converters import escape_dict as escape_dict, escape_sequence as escape_sequence, escape_string as escape_string diff --git a/stubs/Pygments/pygments/token.pyi b/stubs/Pygments/pygments/token.pyi index bcc10fd1a771..e3790965a651 100644 --- a/stubs/Pygments/pygments/token.pyi +++ b/stubs/Pygments/pygments/token.pyi @@ -1,6 +1,5 @@ from collections.abc import Mapping - class _TokenType(tuple[str]): # TODO: change to lower-case tuple once new mypy released parent: _TokenType | None def split(self) -> list[_TokenType]: ... diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index 0ab485bb8ebe..71270b46aae0 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -1,5 +1,5 @@ -from collections.abc import Coroutine, Generator, Iterator from _typeshed import Self +from collections.abc import Coroutine, Generator, Iterator from types import CodeType, FrameType, TracebackType, coroutine from typing import Any, Generic, Type, TypeVar diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index 0462a6cbc43a..1e2a7069ad05 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import sys from _typeshed import StrOrBytesPath +from collections.abc import Sequence from os import stat_result from typing import Union, overload diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index 1c9c828461eb..f78795d3c05c 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -1,4 +1,3 @@ -from collections.abc import Callable from _typeshed import ( OpenBinaryMode, OpenBinaryModeReading, @@ -8,6 +7,7 @@ from _typeshed import ( StrOrBytesPath, ) from asyncio import AbstractEventLoop +from collections.abc import Callable from typing import Any, Union, overload from typing_extensions import Literal diff --git a/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/stubs/aiofiles/aiofiles/threadpool/binary.pyi index 1b66fca96c91..2f7730064a5b 100644 --- a/stubs/aiofiles/aiofiles/threadpool/binary.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/binary.pyi @@ -1,8 +1,7 @@ -from collections.abc import Iterable from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer +from collections.abc import Iterable from io import FileIO - from ..base import AsyncBase class _UnknownAsyncBinaryIO(AsyncBase[bytes]): diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index 71d61887cc73..4712e342e266 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable from _typeshed import StrOrBytesPath +from collections.abc import Iterable from typing import BinaryIO from ..base import AsyncBase diff --git a/stubs/atomicwrites/atomicwrites/__init__.pyi b/stubs/atomicwrites/atomicwrites/__init__.pyi index 244f5f60d619..9b95f0665595 100644 --- a/stubs/atomicwrites/atomicwrites/__init__.pyi +++ b/stubs/atomicwrites/atomicwrites/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import StrOrBytesPath +from collections.abc import Callable from typing import IO, Any, AnyStr, ContextManager, Text, Type def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... diff --git a/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi b/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi index 840e2c753113..f8aecde4fe1a 100644 --- a/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi +++ b/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable import time +from collections.abc import Callable, Iterable from logging import Logger from typing import Any diff --git a/stubs/beautifulsoup4/bs4/__init__.pyi b/stubs/beautifulsoup4/bs4/__init__.pyi index 1224020db2ac..b264e9ccdf07 100644 --- a/stubs/beautifulsoup4/bs4/__init__.pyi +++ b/stubs/beautifulsoup4/bs4/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Sequence from _typeshed import Self, SupportsRead +from collections.abc import Sequence from typing import Any, Type from .builder import TreeBuilder diff --git a/stubs/beautifulsoup4/bs4/element.pyi b/stubs/beautifulsoup4/bs4/element.pyi index 84d6f2f53d5a..9f4bda10d22d 100644 --- a/stubs/beautifulsoup4/bs4/element.pyi +++ b/stubs/beautifulsoup4/bs4/element.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable, Iterable, Mapping from _typeshed import Self -from collections.abc import Iterator +from collections.abc import Callable, Iterable, Iterator, Mapping from typing import Any, Generic, Pattern, Type, TypeVar, Union, overload from . import BeautifulSoup diff --git a/stubs/beautifulsoup4/bs4/formatter.pyi b/stubs/beautifulsoup4/bs4/formatter.pyi index 7f39f1b1aab4..9274238cd67e 100644 --- a/stubs/beautifulsoup4/bs4/formatter.pyi +++ b/stubs/beautifulsoup4/bs4/formatter.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable - from .dammit import EntitySubstitution as EntitySubstitution _EntitySubstitution = Callable[[str], str] diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 9e4994eac4d3..54413f1c7ef3 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -1,9 +1,9 @@ -from collections.abc import Callable, Iterable, Mapping, Sequence import datetime import logging.handlers import subprocess import sys import time +from collections.abc import Callable, Iterable, Mapping, Sequence from typing import IO, Any, ContextManager, Type, TypeVar import boto.connection diff --git a/stubs/cachetools/cachetools/__init__.pyi b/stubs/cachetools/cachetools/__init__.pyi index 0f083bd25e01..63c0c75ac010 100644 --- a/stubs/cachetools/cachetools/__init__.pyi +++ b/stubs/cachetools/cachetools/__init__.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable, MutableMapping from _typeshed import IdentityFunction -from collections.abc import Iterator, Sequence +from collections.abc import Callable, Iterator, MutableMapping, Sequence from contextlib import AbstractContextManager from typing import Any, Generic, TypeVar, overload diff --git a/stubs/cachetools/cachetools/func.pyi b/stubs/cachetools/cachetools/func.pyi index 349dde8d6d89..2c5a62d4d966 100644 --- a/stubs/cachetools/cachetools/func.pyi +++ b/stubs/cachetools/cachetools/func.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Sequence from _typeshed import IdentityFunction +from collections.abc import Callable, Sequence from typing import TypeVar _T = TypeVar("_T") diff --git a/stubs/cachetools/cachetools/keys.pyi b/stubs/cachetools/cachetools/keys.pyi index 5a43d2a0b970..507bd0a33e59 100644 --- a/stubs/cachetools/cachetools/keys.pyi +++ b/stubs/cachetools/cachetools/keys.pyi @@ -1,5 +1,4 @@ from collections.abc import Hashable - def hashkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... def typedkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... diff --git a/stubs/chardet/chardet/langbulgarianmodel.pyi b/stubs/chardet/chardet/langbulgarianmodel.pyi index 1ff0ded19c25..07344de5c895 100644 --- a/stubs/chardet/chardet/langbulgarianmodel.pyi +++ b/stubs/chardet/chardet/langbulgarianmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType Latin5_BulgarianCharToOrderMap: tuple[int, ...] diff --git a/stubs/chardet/chardet/langcyrillicmodel.pyi b/stubs/chardet/chardet/langcyrillicmodel.pyi index 8f7997d04099..22e7c52dc20a 100644 --- a/stubs/chardet/chardet/langcyrillicmodel.pyi +++ b/stubs/chardet/chardet/langcyrillicmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType KOI8R_char_to_order_map: tuple[int, ...] diff --git a/stubs/chardet/chardet/langgreekmodel.pyi b/stubs/chardet/chardet/langgreekmodel.pyi index 05c1f4f310a9..ceee125a2341 100644 --- a/stubs/chardet/chardet/langgreekmodel.pyi +++ b/stubs/chardet/chardet/langgreekmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType Latin7_char_to_order_map: tuple[int, ...] diff --git a/stubs/chardet/chardet/langhebrewmodel.pyi b/stubs/chardet/chardet/langhebrewmodel.pyi index a228d9c2aac5..a17e10de3023 100644 --- a/stubs/chardet/chardet/langhebrewmodel.pyi +++ b/stubs/chardet/chardet/langhebrewmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType WIN1255_CHAR_TO_ORDER_MAP: tuple[int, ...] diff --git a/stubs/chardet/chardet/langhungarianmodel.pyi b/stubs/chardet/chardet/langhungarianmodel.pyi index 23875c22ec59..498c7da58a9d 100644 --- a/stubs/chardet/chardet/langhungarianmodel.pyi +++ b/stubs/chardet/chardet/langhungarianmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType Latin2_HungarianCharToOrderMap: tuple[int, ...] diff --git a/stubs/chardet/chardet/langthaimodel.pyi b/stubs/chardet/chardet/langthaimodel.pyi index d52281bb5b9e..eee2356e8ead 100644 --- a/stubs/chardet/chardet/langthaimodel.pyi +++ b/stubs/chardet/chardet/langthaimodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType TIS620CharToOrderMap: tuple[int, ...] diff --git a/stubs/chardet/chardet/langturkishmodel.pyi b/stubs/chardet/chardet/langturkishmodel.pyi index d5f614174a86..6686f262d619 100644 --- a/stubs/chardet/chardet/langturkishmodel.pyi +++ b/stubs/chardet/chardet/langturkishmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType Latin5_TurkishCharToOrderMap: tuple[int, ...] diff --git a/stubs/click-spinner/click_spinner/__init__.pyi b/stubs/click-spinner/click_spinner/__init__.pyi index 01012e37a51c..89857a5bc47a 100644 --- a/stubs/click-spinner/click_spinner/__init__.pyi +++ b/stubs/click-spinner/click_spinner/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator import threading +from collections.abc import Iterator from types import TracebackType from typing import Protocol, Type from typing_extensions import Literal diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index dbdb6315dc7b..66cbf1463dce 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Sequence import sys from _typeshed import SupportsWrite +from collections.abc import Callable, Sequence from typing import Any, Optional, Pattern, TextIO, Union if sys.platform == "win32": diff --git a/stubs/colorama/colorama/win32.pyi b/stubs/colorama/colorama/win32.pyi index a169c6b2d331..c195e45900c7 100644 --- a/stubs/colorama/colorama/win32.pyi +++ b/stubs/colorama/colorama/win32.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable import sys - +from collections.abc import Callable from typing_extensions import Literal STDOUT: Literal[-11] diff --git a/stubs/contextvars/contextvars.pyi b/stubs/contextvars/contextvars.pyi index ffeefc7a326e..dfcff4d0cb66 100644 --- a/stubs/contextvars/contextvars.pyi +++ b/stubs/contextvars/contextvars.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterator, Mapping import sys +from collections.abc import Callable, Iterator, Mapping from typing import Any, ClassVar, Generic, TypeVar if sys.version_info >= (3, 9): diff --git a/stubs/croniter/croniter.pyi b/stubs/croniter/croniter.pyi index b12530a8ee24..1f1d0f1b6f55 100644 --- a/stubs/croniter/croniter.pyi +++ b/stubs/croniter/croniter.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator import datetime +from collections.abc import Iterator from typing import Any, Text, Type, TypeVar, Union from typing_extensions import Literal diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index 6bd125cab935..e820e4f337df 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -1,6 +1,6 @@ -from collections.abc import Generator, Iterable, Sequence import datetime from abc import ABCMeta, abstractmethod +from collections.abc import Generator, Iterable, Sequence from enum import Enum from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network from typing import Any, ClassVar, Generic, Text, Type, TypeVar diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index 65a14506b4a5..a9daeaa9987e 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Mapping import sys +from collections.abc import Callable, Iterable, Mapping from typing import Any, Generic, Type, TypeVar, overload if sys.version_info >= (3, 9): diff --git a/stubs/dateparser/dateparser/date.pyi b/stubs/dateparser/dateparser/date.pyi index 198d3e017c72..e32f49bf61fd 100644 --- a/stubs/dateparser/dateparser/date.pyi +++ b/stubs/dateparser/dateparser/date.pyi @@ -1,7 +1,7 @@ -from collections.abc import Iterable, Iterator import collections import sys from _typeshed import Self as Self +from collections.abc import Iterable, Iterator from datetime import datetime from typing import ClassVar, Type, overload diff --git a/stubs/dateparser/dateparser/languages/loader.pyi b/stubs/dateparser/dateparser/languages/loader.pyi index c8010bec4fd3..87e532b2ccbd 100644 --- a/stubs/dateparser/dateparser/languages/loader.pyi +++ b/stubs/dateparser/dateparser/languages/loader.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator from collections import OrderedDict +from collections.abc import Iterator from typing import Any from .locale import Locale diff --git a/stubs/dateparser/dateparser/utils/__init__.pyi b/stubs/dateparser/dateparser/utils/__init__.pyi index 9d7c636e43aa..769e865ced20 100644 --- a/stubs/dateparser/dateparser/utils/__init__.pyi +++ b/stubs/dateparser/dateparser/utils/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Mapping from collections import OrderedDict +from collections.abc import Mapping from typing import Any def strip_braces(date_string: str) -> str: ... diff --git a/stubs/decorator/decorator.pyi b/stubs/decorator/decorator.pyi index c17ca7f26f5b..35483eddc48c 100644 --- a/stubs/decorator/decorator.pyi +++ b/stubs/decorator/decorator.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterator import sys +from collections.abc import Callable, Iterator from typing import Any, NamedTuple, Pattern, Text, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) diff --git a/stubs/editdistance/editdistance.pyi b/stubs/editdistance/editdistance.pyi index 9ecabaea63c6..360884973e74 100644 --- a/stubs/editdistance/editdistance.pyi +++ b/stubs/editdistance/editdistance.pyi @@ -1,5 +1,4 @@ from collections.abc import Hashable, Iterable - def eval(a: Iterable[Hashable], b: Iterable[Hashable]) -> int: ... def distance(a: Iterable[Hashable], b: Iterable[Hashable]) -> int: ... diff --git a/stubs/entrypoints/entrypoints.pyi b/stubs/entrypoints/entrypoints.pyi index c0adfb883d05..12bc6870d561 100644 --- a/stubs/entrypoints/entrypoints.pyi +++ b/stubs/entrypoints/entrypoints.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterator, Sequence import sys from _typeshed import Self +from collections.abc import Iterator, Sequence from typing import Any, Text, Type if sys.version_info >= (3, 0): diff --git a/stubs/flake8-2020/flake8_2020.pyi b/stubs/flake8-2020/flake8_2020.pyi index b4ec565ef343..99ee592623f8 100644 --- a/stubs/flake8-2020/flake8_2020.pyi +++ b/stubs/flake8-2020/flake8_2020.pyi @@ -2,8 +2,8 @@ # This PEP does not support distributing typing information as part of module-only distributions or single-file modules within namespace packages. # Therefore typeshed is the best place. -from collections.abc import Generator import ast +from collections.abc import Generator from typing import Any, ClassVar, Type class Plugin: diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index bae16350b7a0..dac90d0c14ba 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import argparse import ast +from collections.abc import Sequence from typing import Any class BugBearChecker: diff --git a/stubs/flake8-builtins/flake8_builtins.pyi b/stubs/flake8-builtins/flake8_builtins.pyi index 471841a23139..3d415b5e791d 100644 --- a/stubs/flake8-builtins/flake8_builtins.pyi +++ b/stubs/flake8-builtins/flake8_builtins.pyi @@ -1,5 +1,5 @@ -from collections.abc import Generator import ast +from collections.abc import Generator from typing import Any, ClassVar, Type class BuiltinsChecker: diff --git a/stubs/flake8-docstrings/flake8_docstrings.pyi b/stubs/flake8-docstrings/flake8_docstrings.pyi index 263c9fc6d888..82853430aa27 100644 --- a/stubs/flake8-docstrings/flake8_docstrings.pyi +++ b/stubs/flake8-docstrings/flake8_docstrings.pyi @@ -1,6 +1,6 @@ -from collections.abc import Generator, Iterable import argparse import ast +from collections.abc import Generator, Iterable from typing import Any, ClassVar, Type class pep257Checker: diff --git a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi index 0ba060fef518..6d9492d3f4a2 100644 --- a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi +++ b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable, Iterator import argparse import ast +from collections.abc import Iterable, Iterator from typing import Any, Generic, Type, TypeVar FLAKE8_ERROR = tuple[int, int, str, Type[Any]] diff --git a/stubs/flake8-simplify/flake8_simplify.pyi b/stubs/flake8-simplify/flake8_simplify.pyi index 40f652c1293e..8ffebfe8ecba 100644 --- a/stubs/flake8-simplify/flake8_simplify.pyi +++ b/stubs/flake8-simplify/flake8_simplify.pyi @@ -1,5 +1,5 @@ -from collections.abc import Generator import ast +from collections.abc import Generator from typing import Any, ClassVar, Type class Plugin: diff --git a/stubs/flake8-typing-imports/flake8_typing_imports.pyi b/stubs/flake8-typing-imports/flake8_typing_imports.pyi index b5a0da29047e..8c130878bf34 100644 --- a/stubs/flake8-typing-imports/flake8_typing_imports.pyi +++ b/stubs/flake8-typing-imports/flake8_typing_imports.pyi @@ -1,6 +1,6 @@ -from collections.abc import Generator import argparse import ast +from collections.abc import Generator from typing import Any, ClassVar, Type class Plugin: diff --git a/stubs/frozendict/frozendict.pyi b/stubs/frozendict/frozendict.pyi index 7b5e31001bd6..9f5e7829316e 100644 --- a/stubs/frozendict/frozendict.pyi +++ b/stubs/frozendict/frozendict.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Iterator, Mapping import collections +from collections.abc import Iterable, Iterator, Mapping from typing import Any, Generic, Type, TypeVar, overload _S = TypeVar("_S") diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi index 352f8ad5b3cd..a271f0c90bba 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable import datetime -from collections.abc import Iterable, Sequence +from collections.abc import Callable, Iterable, Sequence from typing import NoReturn, Type from typing_extensions import Literal diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 942335cc1388..6c94f2556b24 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import decimal from _typeshed import ReadableBuffer +from collections.abc import Sequence from datetime import date, datetime, time from typing import Any, Type, overload from typing_extensions import Literal diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi index 17bfd3a17afc..2a3641d327f6 100644 --- a/stubs/jsonschema/jsonschema/_types.pyi +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Iterable, Mapping - def is_array(checker, instance) -> bool: ... def is_bool(checker, instance) -> bool: ... def is_integer(checker, instance) -> bool: ... diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index 459903d6cccf..a922b9fe2d9d 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, ItemsView, KeysView, Mapping, ValuesView import abc import sys +from collections.abc import Callable, ItemsView, KeysView, Mapping, ValuesView from typing import Any, Generic, Type, TypeVar _T = TypeVar("_T") diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index 3001c385ce0c..a48da68a48ab 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -1,7 +1,6 @@ from collections.abc import Callable from threading import Event - from paramiko.pkey import PKey from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/hostkeys.pyi b/stubs/paramiko/paramiko/hostkeys.pyi index ec3da629addb..78378fdc42d7 100644 --- a/stubs/paramiko/paramiko/hostkeys.pyi +++ b/stubs/paramiko/paramiko/hostkeys.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterator, Mapping, MutableMapping - from paramiko.pkey import PKey class _SubDict(MutableMapping[str, PKey]): diff --git a/stubs/paramiko/paramiko/kex_curve25519.pyi b/stubs/paramiko/paramiko/kex_curve25519.pyi index 3965dea60759..1371a66ea5d8 100644 --- a/stubs/paramiko/paramiko/kex_curve25519.pyi +++ b/stubs/paramiko/paramiko/kex_curve25519.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer as ReadableBuffer - +from collections.abc import Callable from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi index e0739e69748f..17ca312a0cc9 100644 --- a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi +++ b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/kex_gex.pyi b/stubs/paramiko/paramiko/kex_gex.pyi index 18a00f28e5bd..b2d3b4062f71 100644 --- a/stubs/paramiko/paramiko/kex_gex.pyi +++ b/stubs/paramiko/paramiko/kex_gex.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from paramiko.message import Message from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/kex_group1.pyi b/stubs/paramiko/paramiko/kex_group1.pyi index b068c49f333a..dadb71716b37 100644 --- a/stubs/paramiko/paramiko/kex_group1.pyi +++ b/stubs/paramiko/paramiko/kex_group1.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from paramiko.message import Message from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/kex_group14.pyi b/stubs/paramiko/paramiko/kex_group14.pyi index 5b45272400e9..75027c2b5fb0 100644 --- a/stubs/paramiko/paramiko/kex_group14.pyi +++ b/stubs/paramiko/paramiko/kex_group14.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from paramiko.kex_group1 import KexGroup1 as KexGroup1 diff --git a/stubs/paramiko/paramiko/kex_group16.pyi b/stubs/paramiko/paramiko/kex_group16.pyi index 38a49ef1a45e..cf660e92daef 100644 --- a/stubs/paramiko/paramiko/kex_group16.pyi +++ b/stubs/paramiko/paramiko/kex_group16.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from paramiko.kex_group1 import KexGroup1 as KexGroup1 diff --git a/stubs/paramiko/paramiko/message.pyi b/stubs/paramiko/paramiko/message.pyi index 49e7eda72f8f..d08945ae20ab 100644 --- a/stubs/paramiko/paramiko/message.pyi +++ b/stubs/paramiko/paramiko/message.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import sys +from collections.abc import Iterable from typing import Any, Text from .common import _LikeBytes diff --git a/stubs/paramiko/paramiko/packet.pyi b/stubs/paramiko/paramiko/packet.pyi index 843c81379256..1c44f79aeb88 100644 --- a/stubs/paramiko/paramiko/packet.pyi +++ b/stubs/paramiko/paramiko/packet.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import sys +from collections.abc import Callable from logging import Logger from socket import socket from typing import Any diff --git a/stubs/paramiko/paramiko/py3compat.pyi b/stubs/paramiko/paramiko/py3compat.pyi index 59898d529518..e805b617614e 100644 --- a/stubs/paramiko/paramiko/py3compat.pyi +++ b/stubs/paramiko/paramiko/py3compat.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Sequence import sys +from collections.abc import Iterable, Sequence from typing import Any, Text, Type, TypeVar _T = TypeVar("_T") diff --git a/stubs/paramiko/paramiko/server.pyi b/stubs/paramiko/paramiko/server.pyi index 74b7d7d83245..5bc25c3d60b8 100644 --- a/stubs/paramiko/paramiko/server.pyi +++ b/stubs/paramiko/paramiko/server.pyi @@ -1,6 +1,5 @@ import threading - from paramiko.channel import Channel from paramiko.message import Message from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/ssh_exception.pyi b/stubs/paramiko/paramiko/ssh_exception.pyi index 940400e67301..9f617e0e3c42 100644 --- a/stubs/paramiko/paramiko/ssh_exception.pyi +++ b/stubs/paramiko/paramiko/ssh_exception.pyi @@ -1,6 +1,5 @@ -from collections.abc import Mapping import socket - +from collections.abc import Mapping from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/util.pyi b/stubs/paramiko/paramiko/util.pyi index 7ea67abfeaa2..f7a2850a0943 100644 --- a/stubs/paramiko/paramiko/util.pyi +++ b/stubs/paramiko/paramiko/util.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import sys +from collections.abc import Callable from logging import Logger, LogRecord from types import TracebackType from typing import IO, AnyStr, Protocol, Type, TypeVar diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index a2007db00314..be9f6fda9aa1 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import textwrap +from collections.abc import Callable from typing import IO, Any, Generic, Text, Type, TypeVar, overload from typing_extensions import SupportsIndex diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index cc197ac1f8b0..1972785cffee 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Iterator import sys +from collections.abc import Callable, Iterable, Iterator from contextlib import AbstractContextManager from typing import Any, TypeVar diff --git a/stubs/psutil/psutil/_common.pyi b/stubs/psutil/psutil/_common.pyi index c8e08d8e4be7..a1b7fc5318c2 100644 --- a/stubs/psutil/psutil/_common.pyi +++ b/stubs/psutil/psutil/_common.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import enum from _typeshed import StrOrBytesPath, SupportsWrite +from collections.abc import Callable from socket import AddressFamily, SocketKind from typing import Any, NamedTuple, TypeVar, overload from typing_extensions import Literal diff --git a/stubs/pyOpenSSL/OpenSSL/SSL.pyi b/stubs/pyOpenSSL/OpenSSL/SSL.pyi index 4298539c857a..643adf42e1ac 100644 --- a/stubs/pyOpenSSL/OpenSSL/SSL.pyi +++ b/stubs/pyOpenSSL/OpenSSL/SSL.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Sequence import socket +from collections.abc import Callable, Sequence from typing import Any from OpenSSL.crypto import X509, PKey diff --git a/stubs/python-dateutil/dateutil/rrule.pyi b/stubs/python-dateutil/dateutil/rrule.pyi index e645d9406289..3c33c04f1dc2 100644 --- a/stubs/python-dateutil/dateutil/rrule.pyi +++ b/stubs/python-dateutil/dateutil/rrule.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import datetime +from collections.abc import Iterable from typing import Any from ._common import weekday as weekdaybase diff --git a/stubs/python-slugify/slugify/slugify.pyi b/stubs/python-slugify/slugify/slugify.pyi index 13924dff255b..0f4800b30d68 100644 --- a/stubs/python-slugify/slugify/slugify.pyi +++ b/stubs/python-slugify/slugify/slugify.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterable - def smart_truncate( string: str, max_length: int = ..., word_boundary: bool = ..., separator: str = ..., save_order: bool = ... ) -> str: ... diff --git a/stubs/python-slugify/slugify/special.pyi b/stubs/python-slugify/slugify/special.pyi index 9a67781467e8..2d1da58e8373 100644 --- a/stubs/python-slugify/slugify/special.pyi +++ b/stubs/python-slugify/slugify/special.pyi @@ -1,6 +1,5 @@ from collections.abc import Sequence - def add_uppercase_char(char_list: Sequence[tuple[str, str]]) -> Sequence[tuple[str, str]]: ... CYRILLIC: Sequence[tuple[str, str]] diff --git a/stubs/pytz/pytz/__init__.pyi b/stubs/pytz/pytz/__init__.pyi index f0fd590901df..6a2f148a62c7 100644 --- a/stubs/pytz/pytz/__init__.pyi +++ b/stubs/pytz/pytz/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Mapping import datetime +from collections.abc import Mapping from typing import ClassVar from .exceptions import ( diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index c68cfb1f9d9a..c2d378059311 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -1,24 +1,9 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence import builtins import threading from _typeshed import Self, SupportsItems +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from datetime import datetime, timedelta -from typing import ( - Any, - - ClassVar, - - Generic, - - - - Pattern, - - Type, - TypeVar, - Union, - overload, -) +from typing import Any, ClassVar, Generic, Pattern, Type, TypeVar, Union, overload from typing_extensions import Literal from .commands import CoreCommands, RedisModuleCommands, SentinelCommands diff --git a/stubs/requests/requests/cookies.pyi b/stubs/requests/requests/cookies.pyi index 94491cd002a1..3f022fa1d8c6 100644 --- a/stubs/requests/requests/cookies.pyi +++ b/stubs/requests/requests/cookies.pyi @@ -1,5 +1,5 @@ -from collections.abc import MutableMapping import sys +from collections.abc import MutableMapping from typing import Any if sys.version_info >= (3, 0): diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 86250f0cb301..dcb7574310f6 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterator import datetime +from collections.abc import Callable, Iterator from json import JSONDecoder from typing import Any, Text, Type diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index 5de0ca210dc6..2a6ea53b8e61 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Mapping, MutableMapping from _typeshed import SupportsItems +from collections.abc import Callable, Iterable, Mapping, MutableMapping from typing import IO, Any, Optional, Text, TypeVar, Union from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, structures, utils diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index f1e6cca9e492..85923518831e 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Sequence from _typeshed import IdentityFunction +from collections.abc import Callable, Sequence from logging import Logger from typing import Any, Type, TypeVar diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index 11203afd0a09..44e548edd53f 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Generator, Iterable, Sequence import importlib.abc import types import zipimport from abc import ABCMeta +from collections.abc import Callable, Generator, Iterable, Sequence from typing import IO, Any, Optional, TypeVar, Union, overload LegacyVersion = Any # from packaging.version diff --git a/stubs/setuptools/setuptools/command/test.pyi b/stubs/setuptools/setuptools/command/test.pyi index a46972b07672..a905fc1c5af1 100644 --- a/stubs/setuptools/setuptools/command/test.pyi +++ b/stubs/setuptools/setuptools/command/test.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import Self +from collections.abc import Callable from types import ModuleType from typing import Any, Generic, TypeVar, overload from unittest import TestLoader, TestSuite diff --git a/stubs/toml/toml.pyi b/stubs/toml/toml.pyi index ba961a439b18..f9e7210b6ccf 100644 --- a/stubs/toml/toml.pyi +++ b/stubs/toml/toml.pyi @@ -1,6 +1,6 @@ -from collections.abc import Mapping, MutableMapping import sys from _typeshed import StrPath, SupportsWrite +from collections.abc import Mapping, MutableMapping from typing import IO, Any, Text, Type, Union if sys.version_info >= (3, 6): diff --git a/stubs/toposort/toposort.pyi b/stubs/toposort/toposort.pyi index 10e0d91b00ca..76af5313428b 100644 --- a/stubs/toposort/toposort.pyi +++ b/stubs/toposort/toposort.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Iterator from _typeshed import SupportsItems +from collections.abc import Iterable, Iterator from typing import Any, Protocol, TypeVar _KT_co = TypeVar("_KT_co", covariant=True) diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index 4bc463f0ba06..c7e7606ff4a2 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator import typing +from collections.abc import Iterator from typing import Any class NodeVisitor: diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 3b8a391c10ed..562d907bd55f 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator import typing +from collections.abc import Iterator from typing import Any class NodeVisitor: diff --git a/stubs/vobject/vobject/base.pyi b/stubs/vobject/vobject/base.pyi index bc0c2523be34..165a608daf14 100644 --- a/stubs/vobject/vobject/base.pyi +++ b/stubs/vobject/vobject/base.pyi @@ -1,6 +1,5 @@ -from collections.abc import Iterator from _typeshed import SupportsWrite -from collections.abc import Iterable +from collections.abc import Iterable, Iterator from typing import Any, TypeVar, overload from typing_extensions import Literal diff --git a/stubs/waitress/waitress/channel.pyi b/stubs/waitress/waitress/channel.pyi index ba96cb4443db..d14dff86932d 100644 --- a/stubs/waitress/waitress/channel.pyi +++ b/stubs/waitress/waitress/channel.pyi @@ -2,7 +2,6 @@ from collections.abc import Mapping, Sequence from socket import socket from threading import Condition, Lock - from waitress.adjustments import Adjustments from waitress.buffers import OverflowableBuffer from waitress.parser import HTTPRequestParser diff --git a/stubs/waitress/waitress/task.pyi b/stubs/waitress/waitress/task.pyi index dd2a6c38afae..cb8e67591219 100644 --- a/stubs/waitress/waitress/task.pyi +++ b/stubs/waitress/waitress/task.pyi @@ -1,5 +1,5 @@ -from collections.abc import Mapping, Sequence from collections import deque +from collections.abc import Mapping, Sequence from logging import Logger from threading import Condition, Lock from typing import Any diff --git a/stubs/waitress/waitress/trigger.pyi b/stubs/waitress/waitress/trigger.pyi index 9ada2ed7f76a..58cf30f23b04 100644 --- a/stubs/waitress/waitress/trigger.pyi +++ b/stubs/waitress/waitress/trigger.pyi @@ -1,8 +1,7 @@ -from collections.abc import Callable, Mapping import sys +from collections.abc import Callable, Mapping from socket import socket from threading import Lock - from typing_extensions import Literal from . import wasyncore as wasyncore From f32afcc23b36a27591e1499811b20a2da104c105 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 23:16:49 +0000 Subject: [PATCH 6/7] csv fix; partially revert changes to typing_extensions --- stdlib/csv.pyi | 2 +- stdlib/typing_extensions.pyi | 23 ++++++++++------------- tests/check_new_syntax.py | 2 ++ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index ae68403ac859..3211e688a309 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -21,7 +21,7 @@ from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence from typing import Any, Generic, Type, TypeVar, overload if sys.version_info >= (3, 8): - _DictReadMapping = dict + from builtins import dict as _DictReadMapping else: from collections import OrderedDict as _DictReadMapping diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 380a61b4a231..8d91e6d8f798 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -1,24 +1,21 @@ import abc import sys -from collections import ChainMap as ChainMap, Counter as Counter, defaultdict as DefaultDict, deque as Deque -from collections.abc import ( - AsyncGenerator as AsyncGenerator, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - Awaitable as Awaitable, - Callable, - Coroutine as Coroutine, - ItemsView, - KeysView, - Mapping, - ValuesView, -) +from collections.abc import Callable, ItemsView, KeysView, Mapping, ValuesView from typing import ( TYPE_CHECKING as TYPE_CHECKING, Any, AsyncContextManager as AsyncContextManager, + AsyncGenerator as AsyncGenerator, + AsyncIterable as AsyncIterable, + AsyncIterator as AsyncIterator, + Awaitable as Awaitable, + ChainMap as ChainMap, ClassVar as ClassVar, ContextManager as ContextManager, + Coroutine as Coroutine, + Counter as Counter, + DefaultDict as DefaultDict, + Deque as Deque, NewType as NewType, NoReturn as NoReturn, Text as Text, diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index fb96f575aaff..c998ac9312da 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -193,6 +193,8 @@ def main() -> None: continue if Path("stubs/protobuf/google/protobuf") in path.parents: # TODO: fix protobuf stubs continue + if path == Path("stdlib/typing_extensions.pyi"): + continue with open(path) as f: tree = ast.parse(f.read()) From c0ad0fec150cc7a637b05c86db4a44c0d3aafe98 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 23:17:43 +0000 Subject: [PATCH 7/7] I've lost track --- .../DateTimeRange/datetimerange/__init__.pyi | 3 +-- stubs/Pillow/PIL/ExifTags.pyi | 1 - stubs/Pillow/PIL/Image.pyi | 3 +-- stubs/Pillow/PIL/ImageDraw.pyi | 3 +-- stubs/Pillow/PIL/ImageFilter.pyi | 2 +- stubs/PyMySQL/pymysql/__init__.pyi | 1 - stubs/Pygments/pygments/style.pyi | 4 ++-- stubs/Pygments/pygments/token.pyi | 1 - stubs/aiofiles/aiofiles/base.pyi | 2 +- stubs/aiofiles/aiofiles/os.pyi | 2 +- .../aiofiles/aiofiles/threadpool/__init__.pyi | 2 +- stubs/aiofiles/aiofiles/threadpool/binary.pyi | 3 +-- stubs/aiofiles/aiofiles/threadpool/text.pyi | 2 +- stubs/atomicwrites/atomicwrites/__init__.pyi | 2 +- .../aws_xray_sdk/core/recorder.pyi | 2 +- stubs/beautifulsoup4/bs4/__init__.pyi | 2 +- stubs/beautifulsoup4/bs4/element.pyi | 3 +-- stubs/beautifulsoup4/bs4/formatter.pyi | 1 - stubs/boto/boto/utils.pyi | 2 +- stubs/cachetools/cachetools/__init__.pyi | 3 +-- stubs/cachetools/cachetools/func.pyi | 2 +- stubs/cachetools/cachetools/keys.pyi | 1 - stubs/chardet/chardet/langbulgarianmodel.pyi | 2 -- stubs/chardet/chardet/langcyrillicmodel.pyi | 2 -- stubs/chardet/chardet/langgreekmodel.pyi | 2 -- stubs/chardet/chardet/langhebrewmodel.pyi | 2 -- stubs/chardet/chardet/langhungarianmodel.pyi | 2 -- stubs/chardet/chardet/langthaimodel.pyi | 2 -- stubs/chardet/chardet/langturkishmodel.pyi | 2 -- .../click-spinner/click_spinner/__init__.pyi | 2 +- stubs/colorama/colorama/ansitowin32.pyi | 2 +- stubs/colorama/colorama/win32.pyi | 3 +-- stubs/contextvars/contextvars.pyi | 2 +- stubs/croniter/croniter.pyi | 2 +- .../cryptography/x509/__init__.pyi | 2 +- stubs/dataclasses/dataclasses.pyi | 2 +- stubs/dateparser/dateparser/date.pyi | 2 +- .../dateparser/languages/loader.pyi | 2 +- .../dateparser/dateparser/search/__init__.pyi | 6 +++--- .../dateparser/dateparser/utils/__init__.pyi | 2 +- stubs/decorator/decorator.pyi | 2 +- stubs/editdistance/editdistance.pyi | 1 - stubs/entrypoints/entrypoints.pyi | 2 +- stubs/flake8-2020/flake8_2020.pyi | 2 +- stubs/flake8-bugbear/bugbear.pyi | 2 +- stubs/flake8-builtins/flake8_builtins.pyi | 2 +- stubs/flake8-docstrings/flake8_docstrings.pyi | 2 +- .../flake8_plugin_utils/plugin.pyi | 2 +- stubs/flake8-simplify/flake8_simplify.pyi | 2 +- .../flake8_typing_imports.pyi | 2 +- stubs/frozendict/frozendict.pyi | 2 +- .../google/cloud/ndb/model.pyi | 3 +-- stubs/hdbcli/hdbcli/dbapi.pyi | 2 +- stubs/jsonschema/jsonschema/_types.pyi | 1 - stubs/mypy-extensions/mypy_extensions.pyi | 2 +- stubs/paramiko/paramiko/auth_handler.pyi | 1 - stubs/paramiko/paramiko/hostkeys.pyi | 1 - stubs/paramiko/paramiko/kex_curve25519.pyi | 3 +-- stubs/paramiko/paramiko/kex_ecdh_nist.pyi | 3 +-- stubs/paramiko/paramiko/kex_gex.pyi | 3 +-- stubs/paramiko/paramiko/kex_group1.pyi | 3 +-- stubs/paramiko/paramiko/kex_group14.pyi | 3 +-- stubs/paramiko/paramiko/kex_group16.pyi | 3 +-- stubs/paramiko/paramiko/message.pyi | 2 +- stubs/paramiko/paramiko/packet.pyi | 2 +- stubs/paramiko/paramiko/py3compat.pyi | 2 +- stubs/paramiko/paramiko/server.pyi | 1 - stubs/paramiko/paramiko/ssh_exception.pyi | 3 +-- stubs/paramiko/paramiko/util.pyi | 2 +- stubs/polib/polib.pyi | 2 +- stubs/psutil/psutil/__init__.pyi | 2 +- stubs/psutil/psutil/_common.pyi | 2 +- stubs/pyOpenSSL/OpenSSL/SSL.pyi | 2 +- stubs/python-dateutil/dateutil/rrule.pyi | 2 +- stubs/python-slugify/slugify/slugify.pyi | 1 - stubs/python-slugify/slugify/special.pyi | 1 - stubs/pytz/pytz/__init__.pyi | 2 +- stubs/redis/redis/client.pyi | 19 ++----------------- stubs/requests/requests/cookies.pyi | 2 +- stubs/requests/requests/models.pyi | 2 +- stubs/requests/requests/sessions.pyi | 2 +- stubs/retry/retry/api.pyi | 2 +- stubs/setuptools/pkg_resources/__init__.pyi | 2 +- stubs/setuptools/setuptools/command/test.pyi | 2 +- stubs/toml/toml.pyi | 2 +- stubs/toposort/toposort.pyi | 2 +- stubs/typed-ast/typed_ast/ast27.pyi | 7 +++---- stubs/typed-ast/typed_ast/ast3.pyi | 7 +++---- stubs/vobject/vobject/base.pyi | 3 +-- stubs/waitress/waitress/channel.pyi | 1 - stubs/waitress/waitress/task.pyi | 2 +- stubs/waitress/waitress/trigger.pyi | 3 +-- 92 files changed, 80 insertions(+), 141 deletions(-) diff --git a/stubs/DateTimeRange/datetimerange/__init__.pyi b/stubs/DateTimeRange/datetimerange/__init__.pyi index 61ae72eca2d4..15fc8e07336a 100644 --- a/stubs/DateTimeRange/datetimerange/__init__.pyi +++ b/stubs/DateTimeRange/datetimerange/__init__.pyi @@ -1,6 +1,5 @@ -from collections.abc import Iterable import datetime - +from collections.abc import Iterable from dateutil.relativedelta import relativedelta diff --git a/stubs/Pillow/PIL/ExifTags.pyi b/stubs/Pillow/PIL/ExifTags.pyi index 8aad8b764811..ada23d32958d 100644 --- a/stubs/Pillow/PIL/ExifTags.pyi +++ b/stubs/Pillow/PIL/ExifTags.pyi @@ -1,5 +1,4 @@ from collections.abc import Mapping - TAGS: Mapping[int, str] GPSTAGS: Mapping[int, str] diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index a98a3d7e782c..de07e1c81396 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable, Sequence from _typeshed import SupportsRead, SupportsWrite -from collections.abc import Iterable, Iterator, MutableMapping +from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence from pathlib import Path from typing import Any, Protocol, SupportsBytes, Union from typing_extensions import Literal diff --git a/stubs/Pillow/PIL/ImageDraw.pyi b/stubs/Pillow/PIL/ImageDraw.pyi index 63251213730f..d49e94cb9b90 100644 --- a/stubs/Pillow/PIL/ImageDraw.pyi +++ b/stubs/Pillow/PIL/ImageDraw.pyi @@ -1,5 +1,4 @@ -from collections.abc import Sequence -from collections.abc import Container +from collections.abc import Container, Sequence from typing import Any, Union, overload from typing_extensions import Literal diff --git a/stubs/Pillow/PIL/ImageFilter.pyi b/stubs/Pillow/PIL/ImageFilter.pyi index 565e559adb5e..18bdd7a27003 100644 --- a/stubs/Pillow/PIL/ImageFilter.pyi +++ b/stubs/Pillow/PIL/ImageFilter.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Sequence from _typeshed import Self +from collections.abc import Callable, Iterable, Sequence from typing import Any, Type from typing_extensions import Literal diff --git a/stubs/PyMySQL/pymysql/__init__.pyi b/stubs/PyMySQL/pymysql/__init__.pyi index 80966cdddbe7..c501ab39a9a6 100644 --- a/stubs/PyMySQL/pymysql/__init__.pyi +++ b/stubs/PyMySQL/pymysql/__init__.pyi @@ -1,6 +1,5 @@ import sys - from .connections import Connection as Connection from .constants import FIELD_TYPE as FIELD_TYPE from .converters import escape_dict as escape_dict, escape_sequence as escape_sequence, escape_string as escape_string diff --git a/stubs/Pygments/pygments/style.pyi b/stubs/Pygments/pygments/style.pyi index f6e0072ee75e..fb02a50ea645 100644 --- a/stubs/Pygments/pygments/style.pyi +++ b/stubs/Pygments/pygments/style.pyi @@ -1,9 +1,9 @@ -from collections.abc import Iterator, Mapping, Set +from collections.abc import Iterator, Mapping, Set as AbstractSet from typing_extensions import TypedDict from pygments.token import _TokenType -ansicolors: Set[str] # not intended to be mutable (== typing.AbstractSet, not builtins.set) +ansicolors: AbstractSet[str] class _StyleDict(TypedDict): color: str | None diff --git a/stubs/Pygments/pygments/token.pyi b/stubs/Pygments/pygments/token.pyi index bcc10fd1a771..e3790965a651 100644 --- a/stubs/Pygments/pygments/token.pyi +++ b/stubs/Pygments/pygments/token.pyi @@ -1,6 +1,5 @@ from collections.abc import Mapping - class _TokenType(tuple[str]): # TODO: change to lower-case tuple once new mypy released parent: _TokenType | None def split(self) -> list[_TokenType]: ... diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index 0ab485bb8ebe..71270b46aae0 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -1,5 +1,5 @@ -from collections.abc import Coroutine, Generator, Iterator from _typeshed import Self +from collections.abc import Coroutine, Generator, Iterator from types import CodeType, FrameType, TracebackType, coroutine from typing import Any, Generic, Type, TypeVar diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index 0462a6cbc43a..1e2a7069ad05 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import sys from _typeshed import StrOrBytesPath +from collections.abc import Sequence from os import stat_result from typing import Union, overload diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index 1c9c828461eb..f78795d3c05c 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -1,4 +1,3 @@ -from collections.abc import Callable from _typeshed import ( OpenBinaryMode, OpenBinaryModeReading, @@ -8,6 +7,7 @@ from _typeshed import ( StrOrBytesPath, ) from asyncio import AbstractEventLoop +from collections.abc import Callable from typing import Any, Union, overload from typing_extensions import Literal diff --git a/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/stubs/aiofiles/aiofiles/threadpool/binary.pyi index 1b66fca96c91..2f7730064a5b 100644 --- a/stubs/aiofiles/aiofiles/threadpool/binary.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/binary.pyi @@ -1,8 +1,7 @@ -from collections.abc import Iterable from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer +from collections.abc import Iterable from io import FileIO - from ..base import AsyncBase class _UnknownAsyncBinaryIO(AsyncBase[bytes]): diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index 71d61887cc73..4712e342e266 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable from _typeshed import StrOrBytesPath +from collections.abc import Iterable from typing import BinaryIO from ..base import AsyncBase diff --git a/stubs/atomicwrites/atomicwrites/__init__.pyi b/stubs/atomicwrites/atomicwrites/__init__.pyi index 244f5f60d619..9b95f0665595 100644 --- a/stubs/atomicwrites/atomicwrites/__init__.pyi +++ b/stubs/atomicwrites/atomicwrites/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import StrOrBytesPath +from collections.abc import Callable from typing import IO, Any, AnyStr, ContextManager, Text, Type def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... diff --git a/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi b/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi index 840e2c753113..f8aecde4fe1a 100644 --- a/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi +++ b/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable import time +from collections.abc import Callable, Iterable from logging import Logger from typing import Any diff --git a/stubs/beautifulsoup4/bs4/__init__.pyi b/stubs/beautifulsoup4/bs4/__init__.pyi index 1224020db2ac..b264e9ccdf07 100644 --- a/stubs/beautifulsoup4/bs4/__init__.pyi +++ b/stubs/beautifulsoup4/bs4/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Sequence from _typeshed import Self, SupportsRead +from collections.abc import Sequence from typing import Any, Type from .builder import TreeBuilder diff --git a/stubs/beautifulsoup4/bs4/element.pyi b/stubs/beautifulsoup4/bs4/element.pyi index 84d6f2f53d5a..9f4bda10d22d 100644 --- a/stubs/beautifulsoup4/bs4/element.pyi +++ b/stubs/beautifulsoup4/bs4/element.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable, Iterable, Mapping from _typeshed import Self -from collections.abc import Iterator +from collections.abc import Callable, Iterable, Iterator, Mapping from typing import Any, Generic, Pattern, Type, TypeVar, Union, overload from . import BeautifulSoup diff --git a/stubs/beautifulsoup4/bs4/formatter.pyi b/stubs/beautifulsoup4/bs4/formatter.pyi index 7f39f1b1aab4..9274238cd67e 100644 --- a/stubs/beautifulsoup4/bs4/formatter.pyi +++ b/stubs/beautifulsoup4/bs4/formatter.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable - from .dammit import EntitySubstitution as EntitySubstitution _EntitySubstitution = Callable[[str], str] diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 9e4994eac4d3..54413f1c7ef3 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -1,9 +1,9 @@ -from collections.abc import Callable, Iterable, Mapping, Sequence import datetime import logging.handlers import subprocess import sys import time +from collections.abc import Callable, Iterable, Mapping, Sequence from typing import IO, Any, ContextManager, Type, TypeVar import boto.connection diff --git a/stubs/cachetools/cachetools/__init__.pyi b/stubs/cachetools/cachetools/__init__.pyi index 0f083bd25e01..63c0c75ac010 100644 --- a/stubs/cachetools/cachetools/__init__.pyi +++ b/stubs/cachetools/cachetools/__init__.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable, MutableMapping from _typeshed import IdentityFunction -from collections.abc import Iterator, Sequence +from collections.abc import Callable, Iterator, MutableMapping, Sequence from contextlib import AbstractContextManager from typing import Any, Generic, TypeVar, overload diff --git a/stubs/cachetools/cachetools/func.pyi b/stubs/cachetools/cachetools/func.pyi index 349dde8d6d89..2c5a62d4d966 100644 --- a/stubs/cachetools/cachetools/func.pyi +++ b/stubs/cachetools/cachetools/func.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Sequence from _typeshed import IdentityFunction +from collections.abc import Callable, Sequence from typing import TypeVar _T = TypeVar("_T") diff --git a/stubs/cachetools/cachetools/keys.pyi b/stubs/cachetools/cachetools/keys.pyi index 5a43d2a0b970..507bd0a33e59 100644 --- a/stubs/cachetools/cachetools/keys.pyi +++ b/stubs/cachetools/cachetools/keys.pyi @@ -1,5 +1,4 @@ from collections.abc import Hashable - def hashkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... def typedkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... diff --git a/stubs/chardet/chardet/langbulgarianmodel.pyi b/stubs/chardet/chardet/langbulgarianmodel.pyi index 1ff0ded19c25..07344de5c895 100644 --- a/stubs/chardet/chardet/langbulgarianmodel.pyi +++ b/stubs/chardet/chardet/langbulgarianmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType Latin5_BulgarianCharToOrderMap: tuple[int, ...] diff --git a/stubs/chardet/chardet/langcyrillicmodel.pyi b/stubs/chardet/chardet/langcyrillicmodel.pyi index 8f7997d04099..22e7c52dc20a 100644 --- a/stubs/chardet/chardet/langcyrillicmodel.pyi +++ b/stubs/chardet/chardet/langcyrillicmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType KOI8R_char_to_order_map: tuple[int, ...] diff --git a/stubs/chardet/chardet/langgreekmodel.pyi b/stubs/chardet/chardet/langgreekmodel.pyi index 05c1f4f310a9..ceee125a2341 100644 --- a/stubs/chardet/chardet/langgreekmodel.pyi +++ b/stubs/chardet/chardet/langgreekmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType Latin7_char_to_order_map: tuple[int, ...] diff --git a/stubs/chardet/chardet/langhebrewmodel.pyi b/stubs/chardet/chardet/langhebrewmodel.pyi index a228d9c2aac5..a17e10de3023 100644 --- a/stubs/chardet/chardet/langhebrewmodel.pyi +++ b/stubs/chardet/chardet/langhebrewmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType WIN1255_CHAR_TO_ORDER_MAP: tuple[int, ...] diff --git a/stubs/chardet/chardet/langhungarianmodel.pyi b/stubs/chardet/chardet/langhungarianmodel.pyi index 23875c22ec59..498c7da58a9d 100644 --- a/stubs/chardet/chardet/langhungarianmodel.pyi +++ b/stubs/chardet/chardet/langhungarianmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType Latin2_HungarianCharToOrderMap: tuple[int, ...] diff --git a/stubs/chardet/chardet/langthaimodel.pyi b/stubs/chardet/chardet/langthaimodel.pyi index d52281bb5b9e..eee2356e8ead 100644 --- a/stubs/chardet/chardet/langthaimodel.pyi +++ b/stubs/chardet/chardet/langthaimodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType TIS620CharToOrderMap: tuple[int, ...] diff --git a/stubs/chardet/chardet/langturkishmodel.pyi b/stubs/chardet/chardet/langturkishmodel.pyi index d5f614174a86..6686f262d619 100644 --- a/stubs/chardet/chardet/langturkishmodel.pyi +++ b/stubs/chardet/chardet/langturkishmodel.pyi @@ -1,5 +1,3 @@ - - from . import _LangModelType Latin5_TurkishCharToOrderMap: tuple[int, ...] diff --git a/stubs/click-spinner/click_spinner/__init__.pyi b/stubs/click-spinner/click_spinner/__init__.pyi index 01012e37a51c..89857a5bc47a 100644 --- a/stubs/click-spinner/click_spinner/__init__.pyi +++ b/stubs/click-spinner/click_spinner/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator import threading +from collections.abc import Iterator from types import TracebackType from typing import Protocol, Type from typing_extensions import Literal diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index dbdb6315dc7b..66cbf1463dce 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, Sequence import sys from _typeshed import SupportsWrite +from collections.abc import Callable, Sequence from typing import Any, Optional, Pattern, TextIO, Union if sys.platform == "win32": diff --git a/stubs/colorama/colorama/win32.pyi b/stubs/colorama/colorama/win32.pyi index a169c6b2d331..c195e45900c7 100644 --- a/stubs/colorama/colorama/win32.pyi +++ b/stubs/colorama/colorama/win32.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable import sys - +from collections.abc import Callable from typing_extensions import Literal STDOUT: Literal[-11] diff --git a/stubs/contextvars/contextvars.pyi b/stubs/contextvars/contextvars.pyi index ffeefc7a326e..dfcff4d0cb66 100644 --- a/stubs/contextvars/contextvars.pyi +++ b/stubs/contextvars/contextvars.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterator, Mapping import sys +from collections.abc import Callable, Iterator, Mapping from typing import Any, ClassVar, Generic, TypeVar if sys.version_info >= (3, 9): diff --git a/stubs/croniter/croniter.pyi b/stubs/croniter/croniter.pyi index b12530a8ee24..1f1d0f1b6f55 100644 --- a/stubs/croniter/croniter.pyi +++ b/stubs/croniter/croniter.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator import datetime +from collections.abc import Iterator from typing import Any, Text, Type, TypeVar, Union from typing_extensions import Literal diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index 6bd125cab935..e820e4f337df 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -1,6 +1,6 @@ -from collections.abc import Generator, Iterable, Sequence import datetime from abc import ABCMeta, abstractmethod +from collections.abc import Generator, Iterable, Sequence from enum import Enum from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network from typing import Any, ClassVar, Generic, Text, Type, TypeVar diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index 65a14506b4a5..a9daeaa9987e 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Mapping import sys +from collections.abc import Callable, Iterable, Mapping from typing import Any, Generic, Type, TypeVar, overload if sys.version_info >= (3, 9): diff --git a/stubs/dateparser/dateparser/date.pyi b/stubs/dateparser/dateparser/date.pyi index 198d3e017c72..e32f49bf61fd 100644 --- a/stubs/dateparser/dateparser/date.pyi +++ b/stubs/dateparser/dateparser/date.pyi @@ -1,7 +1,7 @@ -from collections.abc import Iterable, Iterator import collections import sys from _typeshed import Self as Self +from collections.abc import Iterable, Iterator from datetime import datetime from typing import ClassVar, Type, overload diff --git a/stubs/dateparser/dateparser/languages/loader.pyi b/stubs/dateparser/dateparser/languages/loader.pyi index c8010bec4fd3..87e532b2ccbd 100644 --- a/stubs/dateparser/dateparser/languages/loader.pyi +++ b/stubs/dateparser/dateparser/languages/loader.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterator from collections import OrderedDict +from collections.abc import Iterator from typing import Any from .locale import Locale diff --git a/stubs/dateparser/dateparser/search/__init__.pyi b/stubs/dateparser/dateparser/search/__init__.pyi index 10a2f4c922c3..7116034fc157 100644 --- a/stubs/dateparser/dateparser/search/__init__.pyi +++ b/stubs/dateparser/dateparser/search/__init__.pyi @@ -1,5 +1,5 @@ import sys -from collections.abc import Mapping, Set +from collections.abc import Mapping, Set as AbstractSet from datetime import datetime from typing import Any, overload @@ -11,14 +11,14 @@ else: @overload def search_dates( text: str, - languages: list[str] | tuple[str, ...] | Set[str] | None, + languages: list[str] | tuple[str, ...] | AbstractSet[str] | None, settings: Mapping[Any, Any] | None, add_detected_language: Literal[True], ) -> list[tuple[str, datetime, str]]: ... @overload def search_dates( text: str, - languages: list[str] | tuple[str, ...] | Set[str] | None = ..., + languages: list[str] | tuple[str, ...] | AbstractSet[str] | None = ..., settings: Mapping[Any, Any] | None = ..., add_detected_language: Literal[False] = ..., ) -> list[tuple[str, datetime]]: ... diff --git a/stubs/dateparser/dateparser/utils/__init__.pyi b/stubs/dateparser/dateparser/utils/__init__.pyi index 9d7c636e43aa..769e865ced20 100644 --- a/stubs/dateparser/dateparser/utils/__init__.pyi +++ b/stubs/dateparser/dateparser/utils/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Mapping from collections import OrderedDict +from collections.abc import Mapping from typing import Any def strip_braces(date_string: str) -> str: ... diff --git a/stubs/decorator/decorator.pyi b/stubs/decorator/decorator.pyi index c17ca7f26f5b..35483eddc48c 100644 --- a/stubs/decorator/decorator.pyi +++ b/stubs/decorator/decorator.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterator import sys +from collections.abc import Callable, Iterator from typing import Any, NamedTuple, Pattern, Text, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) diff --git a/stubs/editdistance/editdistance.pyi b/stubs/editdistance/editdistance.pyi index 9ecabaea63c6..360884973e74 100644 --- a/stubs/editdistance/editdistance.pyi +++ b/stubs/editdistance/editdistance.pyi @@ -1,5 +1,4 @@ from collections.abc import Hashable, Iterable - def eval(a: Iterable[Hashable], b: Iterable[Hashable]) -> int: ... def distance(a: Iterable[Hashable], b: Iterable[Hashable]) -> int: ... diff --git a/stubs/entrypoints/entrypoints.pyi b/stubs/entrypoints/entrypoints.pyi index c0adfb883d05..12bc6870d561 100644 --- a/stubs/entrypoints/entrypoints.pyi +++ b/stubs/entrypoints/entrypoints.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterator, Sequence import sys from _typeshed import Self +from collections.abc import Iterator, Sequence from typing import Any, Text, Type if sys.version_info >= (3, 0): diff --git a/stubs/flake8-2020/flake8_2020.pyi b/stubs/flake8-2020/flake8_2020.pyi index b4ec565ef343..99ee592623f8 100644 --- a/stubs/flake8-2020/flake8_2020.pyi +++ b/stubs/flake8-2020/flake8_2020.pyi @@ -2,8 +2,8 @@ # This PEP does not support distributing typing information as part of module-only distributions or single-file modules within namespace packages. # Therefore typeshed is the best place. -from collections.abc import Generator import ast +from collections.abc import Generator from typing import Any, ClassVar, Type class Plugin: diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index bae16350b7a0..dac90d0c14ba 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import argparse import ast +from collections.abc import Sequence from typing import Any class BugBearChecker: diff --git a/stubs/flake8-builtins/flake8_builtins.pyi b/stubs/flake8-builtins/flake8_builtins.pyi index 471841a23139..3d415b5e791d 100644 --- a/stubs/flake8-builtins/flake8_builtins.pyi +++ b/stubs/flake8-builtins/flake8_builtins.pyi @@ -1,5 +1,5 @@ -from collections.abc import Generator import ast +from collections.abc import Generator from typing import Any, ClassVar, Type class BuiltinsChecker: diff --git a/stubs/flake8-docstrings/flake8_docstrings.pyi b/stubs/flake8-docstrings/flake8_docstrings.pyi index 263c9fc6d888..82853430aa27 100644 --- a/stubs/flake8-docstrings/flake8_docstrings.pyi +++ b/stubs/flake8-docstrings/flake8_docstrings.pyi @@ -1,6 +1,6 @@ -from collections.abc import Generator, Iterable import argparse import ast +from collections.abc import Generator, Iterable from typing import Any, ClassVar, Type class pep257Checker: diff --git a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi index 0ba060fef518..6d9492d3f4a2 100644 --- a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi +++ b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi @@ -1,6 +1,6 @@ -from collections.abc import Iterable, Iterator import argparse import ast +from collections.abc import Iterable, Iterator from typing import Any, Generic, Type, TypeVar FLAKE8_ERROR = tuple[int, int, str, Type[Any]] diff --git a/stubs/flake8-simplify/flake8_simplify.pyi b/stubs/flake8-simplify/flake8_simplify.pyi index 40f652c1293e..8ffebfe8ecba 100644 --- a/stubs/flake8-simplify/flake8_simplify.pyi +++ b/stubs/flake8-simplify/flake8_simplify.pyi @@ -1,5 +1,5 @@ -from collections.abc import Generator import ast +from collections.abc import Generator from typing import Any, ClassVar, Type class Plugin: diff --git a/stubs/flake8-typing-imports/flake8_typing_imports.pyi b/stubs/flake8-typing-imports/flake8_typing_imports.pyi index b5a0da29047e..8c130878bf34 100644 --- a/stubs/flake8-typing-imports/flake8_typing_imports.pyi +++ b/stubs/flake8-typing-imports/flake8_typing_imports.pyi @@ -1,6 +1,6 @@ -from collections.abc import Generator import argparse import ast +from collections.abc import Generator from typing import Any, ClassVar, Type class Plugin: diff --git a/stubs/frozendict/frozendict.pyi b/stubs/frozendict/frozendict.pyi index 7b5e31001bd6..9f5e7829316e 100644 --- a/stubs/frozendict/frozendict.pyi +++ b/stubs/frozendict/frozendict.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Iterator, Mapping import collections +from collections.abc import Iterable, Iterator, Mapping from typing import Any, Generic, Type, TypeVar, overload _S = TypeVar("_S") diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi index 352f8ad5b3cd..a271f0c90bba 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -1,6 +1,5 @@ -from collections.abc import Callable import datetime -from collections.abc import Iterable, Sequence +from collections.abc import Callable, Iterable, Sequence from typing import NoReturn, Type from typing_extensions import Literal diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 942335cc1388..6c94f2556b24 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -1,6 +1,6 @@ -from collections.abc import Sequence import decimal from _typeshed import ReadableBuffer +from collections.abc import Sequence from datetime import date, datetime, time from typing import Any, Type, overload from typing_extensions import Literal diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi index 17bfd3a17afc..2a3641d327f6 100644 --- a/stubs/jsonschema/jsonschema/_types.pyi +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Iterable, Mapping - def is_array(checker, instance) -> bool: ... def is_bool(checker, instance) -> bool: ... def is_integer(checker, instance) -> bool: ... diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index 459903d6cccf..a922b9fe2d9d 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable, ItemsView, KeysView, Mapping, ValuesView import abc import sys +from collections.abc import Callable, ItemsView, KeysView, Mapping, ValuesView from typing import Any, Generic, Type, TypeVar _T = TypeVar("_T") diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index 3001c385ce0c..a48da68a48ab 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -1,7 +1,6 @@ from collections.abc import Callable from threading import Event - from paramiko.pkey import PKey from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/hostkeys.pyi b/stubs/paramiko/paramiko/hostkeys.pyi index ec3da629addb..78378fdc42d7 100644 --- a/stubs/paramiko/paramiko/hostkeys.pyi +++ b/stubs/paramiko/paramiko/hostkeys.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterator, Mapping, MutableMapping - from paramiko.pkey import PKey class _SubDict(MutableMapping[str, PKey]): diff --git a/stubs/paramiko/paramiko/kex_curve25519.pyi b/stubs/paramiko/paramiko/kex_curve25519.pyi index 3965dea60759..1371a66ea5d8 100644 --- a/stubs/paramiko/paramiko/kex_curve25519.pyi +++ b/stubs/paramiko/paramiko/kex_curve25519.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer as ReadableBuffer - +from collections.abc import Callable from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi index e0739e69748f..17ca312a0cc9 100644 --- a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi +++ b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/kex_gex.pyi b/stubs/paramiko/paramiko/kex_gex.pyi index 18a00f28e5bd..b2d3b4062f71 100644 --- a/stubs/paramiko/paramiko/kex_gex.pyi +++ b/stubs/paramiko/paramiko/kex_gex.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from paramiko.message import Message from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/kex_group1.pyi b/stubs/paramiko/paramiko/kex_group1.pyi index b068c49f333a..dadb71716b37 100644 --- a/stubs/paramiko/paramiko/kex_group1.pyi +++ b/stubs/paramiko/paramiko/kex_group1.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from paramiko.message import Message from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/kex_group14.pyi b/stubs/paramiko/paramiko/kex_group14.pyi index 5b45272400e9..75027c2b5fb0 100644 --- a/stubs/paramiko/paramiko/kex_group14.pyi +++ b/stubs/paramiko/paramiko/kex_group14.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from paramiko.kex_group1 import KexGroup1 as KexGroup1 diff --git a/stubs/paramiko/paramiko/kex_group16.pyi b/stubs/paramiko/paramiko/kex_group16.pyi index 38a49ef1a45e..cf660e92daef 100644 --- a/stubs/paramiko/paramiko/kex_group16.pyi +++ b/stubs/paramiko/paramiko/kex_group16.pyi @@ -1,7 +1,6 @@ -from collections.abc import Callable import sys from _typeshed import ReadableBuffer - +from collections.abc import Callable from paramiko.kex_group1 import KexGroup1 as KexGroup1 diff --git a/stubs/paramiko/paramiko/message.pyi b/stubs/paramiko/paramiko/message.pyi index 49e7eda72f8f..d08945ae20ab 100644 --- a/stubs/paramiko/paramiko/message.pyi +++ b/stubs/paramiko/paramiko/message.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import sys +from collections.abc import Iterable from typing import Any, Text from .common import _LikeBytes diff --git a/stubs/paramiko/paramiko/packet.pyi b/stubs/paramiko/paramiko/packet.pyi index 843c81379256..1c44f79aeb88 100644 --- a/stubs/paramiko/paramiko/packet.pyi +++ b/stubs/paramiko/paramiko/packet.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import sys +from collections.abc import Callable from logging import Logger from socket import socket from typing import Any diff --git a/stubs/paramiko/paramiko/py3compat.pyi b/stubs/paramiko/paramiko/py3compat.pyi index 59898d529518..e805b617614e 100644 --- a/stubs/paramiko/paramiko/py3compat.pyi +++ b/stubs/paramiko/paramiko/py3compat.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Sequence import sys +from collections.abc import Iterable, Sequence from typing import Any, Text, Type, TypeVar _T = TypeVar("_T") diff --git a/stubs/paramiko/paramiko/server.pyi b/stubs/paramiko/paramiko/server.pyi index 74b7d7d83245..5bc25c3d60b8 100644 --- a/stubs/paramiko/paramiko/server.pyi +++ b/stubs/paramiko/paramiko/server.pyi @@ -1,6 +1,5 @@ import threading - from paramiko.channel import Channel from paramiko.message import Message from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/ssh_exception.pyi b/stubs/paramiko/paramiko/ssh_exception.pyi index 940400e67301..9f617e0e3c42 100644 --- a/stubs/paramiko/paramiko/ssh_exception.pyi +++ b/stubs/paramiko/paramiko/ssh_exception.pyi @@ -1,6 +1,5 @@ -from collections.abc import Mapping import socket - +from collections.abc import Mapping from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/util.pyi b/stubs/paramiko/paramiko/util.pyi index 7ea67abfeaa2..f7a2850a0943 100644 --- a/stubs/paramiko/paramiko/util.pyi +++ b/stubs/paramiko/paramiko/util.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import sys +from collections.abc import Callable from logging import Logger, LogRecord from types import TracebackType from typing import IO, AnyStr, Protocol, Type, TypeVar diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index a2007db00314..be9f6fda9aa1 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable import textwrap +from collections.abc import Callable from typing import IO, Any, Generic, Text, Type, TypeVar, overload from typing_extensions import SupportsIndex diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index cc197ac1f8b0..1972785cffee 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Iterator import sys +from collections.abc import Callable, Iterable, Iterator from contextlib import AbstractContextManager from typing import Any, TypeVar diff --git a/stubs/psutil/psutil/_common.pyi b/stubs/psutil/psutil/_common.pyi index c8e08d8e4be7..a1b7fc5318c2 100644 --- a/stubs/psutil/psutil/_common.pyi +++ b/stubs/psutil/psutil/_common.pyi @@ -1,6 +1,6 @@ -from collections.abc import Callable import enum from _typeshed import StrOrBytesPath, SupportsWrite +from collections.abc import Callable from socket import AddressFamily, SocketKind from typing import Any, NamedTuple, TypeVar, overload from typing_extensions import Literal diff --git a/stubs/pyOpenSSL/OpenSSL/SSL.pyi b/stubs/pyOpenSSL/OpenSSL/SSL.pyi index 4298539c857a..643adf42e1ac 100644 --- a/stubs/pyOpenSSL/OpenSSL/SSL.pyi +++ b/stubs/pyOpenSSL/OpenSSL/SSL.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Sequence import socket +from collections.abc import Callable, Sequence from typing import Any from OpenSSL.crypto import X509, PKey diff --git a/stubs/python-dateutil/dateutil/rrule.pyi b/stubs/python-dateutil/dateutil/rrule.pyi index e645d9406289..3c33c04f1dc2 100644 --- a/stubs/python-dateutil/dateutil/rrule.pyi +++ b/stubs/python-dateutil/dateutil/rrule.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable import datetime +from collections.abc import Iterable from typing import Any from ._common import weekday as weekdaybase diff --git a/stubs/python-slugify/slugify/slugify.pyi b/stubs/python-slugify/slugify/slugify.pyi index 13924dff255b..0f4800b30d68 100644 --- a/stubs/python-slugify/slugify/slugify.pyi +++ b/stubs/python-slugify/slugify/slugify.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterable - def smart_truncate( string: str, max_length: int = ..., word_boundary: bool = ..., separator: str = ..., save_order: bool = ... ) -> str: ... diff --git a/stubs/python-slugify/slugify/special.pyi b/stubs/python-slugify/slugify/special.pyi index 9a67781467e8..2d1da58e8373 100644 --- a/stubs/python-slugify/slugify/special.pyi +++ b/stubs/python-slugify/slugify/special.pyi @@ -1,6 +1,5 @@ from collections.abc import Sequence - def add_uppercase_char(char_list: Sequence[tuple[str, str]]) -> Sequence[tuple[str, str]]: ... CYRILLIC: Sequence[tuple[str, str]] diff --git a/stubs/pytz/pytz/__init__.pyi b/stubs/pytz/pytz/__init__.pyi index f0fd590901df..6a2f148a62c7 100644 --- a/stubs/pytz/pytz/__init__.pyi +++ b/stubs/pytz/pytz/__init__.pyi @@ -1,5 +1,5 @@ -from collections.abc import Mapping import datetime +from collections.abc import Mapping from typing import ClassVar from .exceptions import ( diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index c68cfb1f9d9a..c2d378059311 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -1,24 +1,9 @@ -from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence import builtins import threading from _typeshed import Self, SupportsItems +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from datetime import datetime, timedelta -from typing import ( - Any, - - ClassVar, - - Generic, - - - - Pattern, - - Type, - TypeVar, - Union, - overload, -) +from typing import Any, ClassVar, Generic, Pattern, Type, TypeVar, Union, overload from typing_extensions import Literal from .commands import CoreCommands, RedisModuleCommands, SentinelCommands diff --git a/stubs/requests/requests/cookies.pyi b/stubs/requests/requests/cookies.pyi index 94491cd002a1..3f022fa1d8c6 100644 --- a/stubs/requests/requests/cookies.pyi +++ b/stubs/requests/requests/cookies.pyi @@ -1,5 +1,5 @@ -from collections.abc import MutableMapping import sys +from collections.abc import MutableMapping from typing import Any if sys.version_info >= (3, 0): diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 86250f0cb301..dcb7574310f6 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterator import datetime +from collections.abc import Callable, Iterator from json import JSONDecoder from typing import Any, Text, Type diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index 5de0ca210dc6..2a6ea53b8e61 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Iterable, Mapping, MutableMapping from _typeshed import SupportsItems +from collections.abc import Callable, Iterable, Mapping, MutableMapping from typing import IO, Any, Optional, Text, TypeVar, Union from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, structures, utils diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index f1e6cca9e492..85923518831e 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable, Sequence from _typeshed import IdentityFunction +from collections.abc import Callable, Sequence from logging import Logger from typing import Any, Type, TypeVar diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index 11203afd0a09..44e548edd53f 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -1,8 +1,8 @@ -from collections.abc import Callable, Generator, Iterable, Sequence import importlib.abc import types import zipimport from abc import ABCMeta +from collections.abc import Callable, Generator, Iterable, Sequence from typing import IO, Any, Optional, TypeVar, Union, overload LegacyVersion = Any # from packaging.version diff --git a/stubs/setuptools/setuptools/command/test.pyi b/stubs/setuptools/setuptools/command/test.pyi index a46972b07672..a905fc1c5af1 100644 --- a/stubs/setuptools/setuptools/command/test.pyi +++ b/stubs/setuptools/setuptools/command/test.pyi @@ -1,5 +1,5 @@ -from collections.abc import Callable from _typeshed import Self +from collections.abc import Callable from types import ModuleType from typing import Any, Generic, TypeVar, overload from unittest import TestLoader, TestSuite diff --git a/stubs/toml/toml.pyi b/stubs/toml/toml.pyi index ba961a439b18..f9e7210b6ccf 100644 --- a/stubs/toml/toml.pyi +++ b/stubs/toml/toml.pyi @@ -1,6 +1,6 @@ -from collections.abc import Mapping, MutableMapping import sys from _typeshed import StrPath, SupportsWrite +from collections.abc import Mapping, MutableMapping from typing import IO, Any, Text, Type, Union if sys.version_info >= (3, 6): diff --git a/stubs/toposort/toposort.pyi b/stubs/toposort/toposort.pyi index 10e0d91b00ca..76af5313428b 100644 --- a/stubs/toposort/toposort.pyi +++ b/stubs/toposort/toposort.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable, Iterator from _typeshed import SupportsItems +from collections.abc import Iterable, Iterator from typing import Any, Protocol, TypeVar _KT_co = TypeVar("_KT_co", covariant=True) diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index 4bc463f0ba06..d4422336aa33 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -1,5 +1,4 @@ from collections.abc import Iterator -import typing from typing import Any class NodeVisitor: @@ -16,7 +15,7 @@ def fix_missing_locations(node: AST) -> AST: ... def get_docstring(node: AST, clean: bool = ...) -> bytes | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... -def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... +def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ... def literal_eval(node_or_string: str | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... @@ -27,8 +26,8 @@ PyCF_ONLY_AST: int identifier = str class AST: - _attributes: typing.Tuple[str, ...] - _fields: typing.Tuple[str, ...] + _attributes: tuple[str, ...] + _fields: tuple[str, ...] def __init__(self, *args: Any, **kwargs: Any) -> None: ... class mod(AST): ... diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 3b8a391c10ed..e382de299511 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -1,5 +1,4 @@ from collections.abc import Iterator -import typing from typing import Any class NodeVisitor: @@ -16,7 +15,7 @@ def fix_missing_locations(node: AST) -> AST: ... def get_docstring(node: AST, clean: bool = ...) -> str | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... -def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... +def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ... def literal_eval(node_or_string: str | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... @@ -27,8 +26,8 @@ PyCF_ONLY_AST: int identifier = str class AST: - _attributes: typing.Tuple[str, ...] - _fields: typing.Tuple[str, ...] + _attributes: tuple[str, ...] + _fields: tuple[str, ...] def __init__(self, *args: Any, **kwargs: Any) -> None: ... class mod(AST): ... diff --git a/stubs/vobject/vobject/base.pyi b/stubs/vobject/vobject/base.pyi index bc0c2523be34..165a608daf14 100644 --- a/stubs/vobject/vobject/base.pyi +++ b/stubs/vobject/vobject/base.pyi @@ -1,6 +1,5 @@ -from collections.abc import Iterator from _typeshed import SupportsWrite -from collections.abc import Iterable +from collections.abc import Iterable, Iterator from typing import Any, TypeVar, overload from typing_extensions import Literal diff --git a/stubs/waitress/waitress/channel.pyi b/stubs/waitress/waitress/channel.pyi index ba96cb4443db..d14dff86932d 100644 --- a/stubs/waitress/waitress/channel.pyi +++ b/stubs/waitress/waitress/channel.pyi @@ -2,7 +2,6 @@ from collections.abc import Mapping, Sequence from socket import socket from threading import Condition, Lock - from waitress.adjustments import Adjustments from waitress.buffers import OverflowableBuffer from waitress.parser import HTTPRequestParser diff --git a/stubs/waitress/waitress/task.pyi b/stubs/waitress/waitress/task.pyi index dd2a6c38afae..cb8e67591219 100644 --- a/stubs/waitress/waitress/task.pyi +++ b/stubs/waitress/waitress/task.pyi @@ -1,5 +1,5 @@ -from collections.abc import Mapping, Sequence from collections import deque +from collections.abc import Mapping, Sequence from logging import Logger from threading import Condition, Lock from typing import Any diff --git a/stubs/waitress/waitress/trigger.pyi b/stubs/waitress/waitress/trigger.pyi index 9ada2ed7f76a..58cf30f23b04 100644 --- a/stubs/waitress/waitress/trigger.pyi +++ b/stubs/waitress/waitress/trigger.pyi @@ -1,8 +1,7 @@ -from collections.abc import Callable, Mapping import sys +from collections.abc import Callable, Mapping from socket import socket from threading import Lock - from typing_extensions import Literal from . import wasyncore as wasyncore