From c40a6b4e6eb706de5c1f7f260721c6513efc36a6 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 13:25:24 +0000 Subject: [PATCH 1/5] Add a failing test to `check_new_syntax.py` --- tests/check_new_syntax.py | 113 ++++++++++++++------------------------ 1 file changed, 40 insertions(+), 73 deletions(-) diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index 906160fe79e2..5561e645ad60 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -12,8 +12,13 @@ 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", "Type"}) + +# dataclasses and asyncio.trsock need typing.Type to avoid name clashes with attributes named "type" +CAPITAL_T_TYPE_ALLOWLIST = frozenset({Path("stdlib/dataclasses.pyi"), Path("stdlib/asyncio/trsock.pyi")}) + 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( @@ -21,7 +26,7 @@ ) # The values in the mapping are what these are called in `collections` -IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS = { +IMPORTED_FROM_COLLECTIONS_NOT_TYPING = { "Counter": "Counter", "Deque": "deque", "DefaultDict": "defaultdict", @@ -34,21 +39,23 @@ 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 path in CAPITAL_T_TYPE_ALLOWLIST: + forbidden_builtin_imports = FORBIDDEN_BUILTIN_TYPING_IMPORTS - {"Type"} + else: + forbidden_builtin_imports = FORBIDDEN_BUILTIN_TYPING_IMPORTS + + if object_name in forbidden_builtin_imports: + errors.append(f"{path}:{node.lineno}: Use `builtins.{object_name.lower()}` instead of `typing.{object_name}`") + elif object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING: + errors.append( + f"{path}:{node.lineno}: " + f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING[object_name]}` instead of `typing.{object_name}`" + ) + elif not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST and object_name in CONTEXT_MANAGER_ALIASES: + errors.append(f"{path}:{node.lineno}: Use `contextlib.{CONTEXT_MANAGER_ALIASES[alias]}` instead of `typing.{alias}`") + + 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 +64,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 +71,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: @@ -116,11 +87,11 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: f"Use `collections.abc.{imported_object_name}` or `typing.{imported_object_name}` " f"instead of `typing_extensions.{imported_object_name}`" ) - elif imported_object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS: + elif imported_object_name in IMPORTED_FROM_COLLECTIONS_NOT_TYPING: errors.append( f"{path}:{node.lineno}: " f"Use `collections.{IMPORTED_FROM_COLLECTIONS_NOT_TYPING_EXTENSIONS[imported_object_name]}` " - f"or `typing.{imported_object_name}` instead of `typing_extensions.{imported_object_name}`" + f"instead of `typing_extensions.{imported_object_name}`" ) elif imported_object_name in CONTEXT_MANAGER_ALIASES: if python_2_support_required: @@ -134,36 +105,32 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: f"instead of `typing_extensions.{imported_object_name}`" ) - elif not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST and node.module == "typing": - for imported_class in node.names: - imported_class_name = imported_class.name - if imported_class_name in CONTEXT_MANAGER_ALIASES: - add_contextlib_alias_error(node, imported_class_name) + elif node.module == "typing": + for imported_object in node.names: + check_object_from_typing(node, imported_object.name) self.generic_visit(node) - if not python_2_support_required and path not in CONTEXTLIB_ALIAS_ALLOWLIST: - - def visit_Attribute(self, node: ast.Attribute) -> None: - if isinstance(node.value, ast.Name) and node.value.id == "typing" and node.attr in CONTEXT_MANAGER_ALIASES: - add_contextlib_alias_error(node, node.attr) - self.generic_visit(node) + def visit_Attribute(self, node: ast.Attribute) -> None: + if isinstance(node.value, ast.Name) and node.value.id == "typing": + check_object_from_typing(node, node.attr) + self.generic_visit(node) 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 +143,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 93d23a560d3a8546ddb19e5d9e1df51c12323b5c Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 14:56:25 +0000 Subject: [PATCH 2/5] Use script to apply PEP 585 syntax everywhere --- stdlib/_codecs.pyi | 6 +- stdlib/_compression.pyi | 4 +- stdlib/_csv.pyi | 6 +- stdlib/_dummy_thread.pyi | 4 +- stdlib/_dummy_threading.pyi | 10 +- stdlib/_operator.pyi | 6 +- stdlib/_osx_support.pyi | 6 +- stdlib/_py_abc.pyi | 6 +- stdlib/_random.pyi | 4 +- stdlib/_socket.pyi | 8 +- stdlib/_thread.pyi | 10 +- stdlib/_threading_local.pyi | 4 +- stdlib/_typeshed/__init__.pyi | 4 +- stdlib/_typeshed/wsgi.pyi | 4 +- stdlib/_warnings.pyi | 12 +- stdlib/abc.pyi | 8 +- stdlib/aifc.pyi | 8 +- stdlib/argparse.pyi | 48 +++--- stdlib/asyncio/__init__.pyi | 4 +- stdlib/asyncio/base_events.pyi | 8 +- stdlib/asyncio/base_subprocess.pyi | 4 +- stdlib/asyncio/events.pyi | 6 +- stdlib/asyncio/locks.pyi | 6 +- stdlib/asyncio/proactor_events.pyi | 4 +- stdlib/asyncio/trsock.pyi | 6 +- stdlib/asyncio/unix_events.pyi | 6 +- stdlib/asyncio/windows_events.pyi | 8 +- stdlib/asyncio/windows_utils.pyi | 4 +- stdlib/asyncore.pyi | 8 +- stdlib/audioop.pyi | 6 +- stdlib/bdb.pyi | 4 +- stdlib/binhex.pyi | 4 +- stdlib/builtins.pyi | 122 ++++++------- stdlib/cProfile.pyi | 4 +- stdlib/calendar.pyi | 6 +- stdlib/cgitb.pyi | 6 +- stdlib/codecs.pyi | 12 +- stdlib/collections/__init__.pyi | 20 +-- stdlib/concurrent/futures/_base.pyi | 4 +- stdlib/concurrent/futures/process.pyi | 12 +- stdlib/concurrent/futures/thread.pyi | 8 +- stdlib/configparser.pyi | 8 +- stdlib/contextlib.pyi | 14 +- stdlib/copyreg.pyi | 4 +- stdlib/csv.pyi | 4 +- stdlib/ctypes/__init__.pyi | 60 +++---- stdlib/dataclasses.pyi | 10 +- stdlib/datetime.pyi | 34 ++-- stdlib/dbm/__init__.pyi | 6 +- stdlib/dbm/dumb.pyi | 4 +- stdlib/dbm/gnu.pyi | 4 +- stdlib/dbm/ndbm.pyi | 4 +- stdlib/decimal.pyi | 16 +- stdlib/distutils/ccompiler.pyi | 6 +- stdlib/distutils/command/install.pyi | 4 +- stdlib/distutils/core.pyi | 6 +- stdlib/distutils/dist.pyi | 4 +- stdlib/distutils/fancy_getopt.pyi | 6 +- stdlib/distutils/util.pyi | 4 +- stdlib/distutils/version.pyi | 4 +- stdlib/doctest.pyi | 4 +- stdlib/email/_header_value_parser.pyi | 6 +- stdlib/email/headerregistry.pyi | 16 +- stdlib/email/message.pyi | 8 +- stdlib/email/mime/application.pyi | 4 +- stdlib/email/mime/audio.pyi | 4 +- stdlib/email/mime/base.pyi | 4 +- stdlib/email/mime/image.pyi | 4 +- stdlib/email/mime/multipart.pyi | 4 +- stdlib/email/utils.pyi | 6 +- stdlib/enum.pyi | 44 ++--- stdlib/formatter.pyi | 10 +- stdlib/fractions.pyi | 6 +- stdlib/ftplib.pyi | 6 +- stdlib/functools.pyi | 28 +-- stdlib/genericpath.pyi | 4 +- stdlib/gettext.pyi | 10 +- stdlib/graphlib.pyi | 4 +- stdlib/grp.pyi | 4 +- stdlib/html/parser.pyi | 4 +- stdlib/http/client.pyi | 6 +- stdlib/http/cookiejar.pyi | 6 +- stdlib/http/cookies.pyi | 6 +- stdlib/imaplib.pyi | 14 +- stdlib/importlib/metadata/__init__.pyi | 4 +- stdlib/inspect.pyi | 26 +-- stdlib/io.pyi | 8 +- stdlib/itertools.pyi | 30 ++-- stdlib/json/__init__.pyi | 10 +- stdlib/lib2to3/pgen2/grammar.pyi | 8 +- stdlib/lib2to3/pgen2/tokenize.pyi | 6 +- stdlib/lib2to3/pytree.pyi | 8 +- stdlib/linecache.pyi | 6 +- stdlib/locale.pyi | 4 +- stdlib/logging/__init__.pyi | 14 +- stdlib/mailbox.pyi | 4 +- stdlib/mailcap.pyi | 4 +- stdlib/mimetypes.pyi | 4 +- stdlib/modulefinder.pyi | 4 +- stdlib/msilib/__init__.pyi | 8 +- stdlib/msilib/sequence.pyi | 4 +- stdlib/multiprocessing/connection.pyi | 8 +- stdlib/multiprocessing/context.pyi | 38 ++-- stdlib/multiprocessing/dummy/connection.pyi | 8 +- stdlib/multiprocessing/managers.pyi | 4 +- stdlib/multiprocessing/pool.pyi | 4 +- stdlib/multiprocessing/process.pyi | 6 +- stdlib/multiprocessing/shared_memory.pyi | 4 +- stdlib/multiprocessing/sharedctypes.pyi | 18 +- stdlib/netrc.pyi | 4 +- stdlib/nntplib.pyi | 4 +- stdlib/optparse.pyi | 24 +-- stdlib/os/__init__.pyi | 40 ++--- stdlib/parser.pyi | 6 +- stdlib/pathlib.pyi | 14 +- stdlib/pickle.pyi | 12 +- stdlib/pickletools.pyi | 8 +- stdlib/platform.pyi | 6 +- stdlib/plistlib.pyi | 14 +- stdlib/poplib.pyi | 4 +- stdlib/profile.pyi | 4 +- stdlib/pstats.pyi | 4 +- stdlib/pwd.pyi | 4 +- stdlib/py_compile.pyi | 4 +- stdlib/pydoc.pyi | 12 +- stdlib/pyexpat/__init__.pyi | 4 +- stdlib/random.pyi | 6 +- stdlib/reprlib.pyi | 4 +- stdlib/resource.pyi | 4 +- stdlib/sched.pyi | 8 +- stdlib/select.pyi | 4 +- stdlib/shelve.pyi | 4 +- stdlib/signal.pyi | 4 +- stdlib/smtpd.pyi | 6 +- stdlib/smtplib.pyi | 10 +- stdlib/socketserver.pyi | 8 +- stdlib/spwd.pyi | 4 +- stdlib/sqlite3/dbapi2.pyi | 8 +- stdlib/sre_parse.pyi | 16 +- stdlib/ssl.pyi | 18 +- stdlib/statistics.pyi | 4 +- stdlib/struct.pyi | 14 +- stdlib/subprocess.pyi | 4 +- stdlib/symtable.pyi | 14 +- stdlib/sys.pyi | 24 +-- stdlib/sysconfig.pyi | 6 +- stdlib/tarfile.pyi | 48 +++--- stdlib/tempfile.pyi | 10 +- stdlib/termios.pyi | 4 +- stdlib/threading.pyi | 10 +- stdlib/time.pyi | 4 +- stdlib/tkinter/__init__.pyi | 162 +++++++++--------- stdlib/tkinter/filedialog.pyi | 18 +- stdlib/tkinter/font.pyi | 10 +- stdlib/tkinter/tix.pyi | 10 +- stdlib/tkinter/ttk.pyi | 58 +++---- stdlib/tokenize.pyi | 4 +- stdlib/trace.pyi | 4 +- stdlib/traceback.pyi | 24 +-- stdlib/tracemalloc.pyi | 8 +- stdlib/turtle.pyi | 14 +- stdlib/types.pyi | 84 ++++----- stdlib/typing_extensions.pyi | 4 +- stdlib/unittest/_log.pyi | 4 +- stdlib/unittest/case.pyi | 46 ++--- stdlib/unittest/loader.pyi | 16 +- stdlib/unittest/main.pyi | 4 +- stdlib/unittest/mock.pyi | 14 +- stdlib/unittest/result.pyi | 4 +- stdlib/unittest/runner.pyi | 4 +- stdlib/unittest/util.pyi | 4 +- stdlib/urllib/parse.pyi | 4 +- stdlib/urllib/request.pyi | 6 +- stdlib/urllib/response.pyi | 6 +- stdlib/uuid.pyi | 4 +- stdlib/warnings.pyi | 18 +- stdlib/weakref.pyi | 8 +- stdlib/winreg.pyi | 4 +- stdlib/wsgiref/handlers.pyi | 8 +- stdlib/wsgiref/headers.pyi | 4 +- stdlib/wsgiref/simple_server.pyi | 6 +- stdlib/xml/dom/minicompat.pyi | 10 +- stdlib/xml/dom/pulldom.pyi | 4 +- stdlib/xml/etree/ElementPath.pyi | 6 +- stdlib/xml/etree/ElementTree.pyi | 4 +- stdlib/xmlrpc/client.pyi | 38 ++-- stdlib/xmlrpc/server.pyi | 14 +- stdlib/zipfile.pyi | 6 +- stdlib/zoneinfo/__init__.pyi | 6 +- stubs/Deprecated/deprecated/classic.pyi | 8 +- stubs/Deprecated/deprecated/sphinx.pyi | 8 +- stubs/Markdown/markdown/blockparser.pyi | 4 +- stubs/Pillow/PIL/Image.pyi | 20 +-- stubs/Pillow/PIL/ImageColor.pyi | 6 +- stubs/Pillow/PIL/ImageDraw.pyi | 4 +- stubs/Pillow/PIL/ImageFilter.pyi | 6 +- stubs/Pillow/PIL/PdfParser.pyi | 4 +- stubs/Pillow/PIL/TiffTags.pyi | 4 +- stubs/PyMySQL/pymysql/__init__.pyi | 4 +- stubs/PyMySQL/pymysql/connections.pyi | 8 +- stubs/PyMySQL/pymysql/converters.pyi | 8 +- stubs/PyMySQL/pymysql/cursors.pyi | 20 +-- stubs/PyMySQL/pymysql/err.pyi | 4 +- stubs/PyYAML/yaml/__init__.pyi | 24 +-- stubs/PyYAML/yaml/representer.pyi | 10 +- .../Pygments/pygments/formatters/__init__.pyi | 4 +- stubs/Pygments/pygments/lexer.pyi | 4 +- stubs/Pygments/pygments/lexers/__init__.pyi | 4 +- stubs/Pygments/pygments/token.pyi | 4 +- .../SQLAlchemy/sqlalchemy/engine/default.pyi | 4 +- stubs/aiofiles/aiofiles/base.pyi | 6 +- stubs/aiofiles/aiofiles/threadpool/text.pyi | 4 +- stubs/atomicwrites/atomicwrites/__init__.pyi | 4 +- stubs/babel/babel/messages/plurals.pyi | 4 +- stubs/beautifulsoup4/bs4/__init__.pyi | 6 +- stubs/beautifulsoup4/bs4/dammit.pyi | 4 +- stubs/beautifulsoup4/bs4/element.pyi | 18 +- stubs/bleach/bleach/sanitizer.pyi | 6 +- stubs/boto/boto/kms/layer1.pyi | 4 +- stubs/boto/boto/s3/__init__.pyi | 4 +- stubs/boto/boto/s3/bucket.pyi | 6 +- stubs/boto/boto/s3/connection.pyi | 8 +- stubs/boto/boto/s3/cors.pyi | 4 +- 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 | 10 +- stubs/cachetools/cachetools/keys.pyi | 6 +- stubs/caldav/caldav/lib/error.pyi | 4 +- stubs/caldav/caldav/objects.pyi | 4 +- .../characteristic/__init__.pyi | 4 +- 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 | 4 +- stubs/colorama/colorama/ansitowin32.pyi | 6 +- stubs/croniter/croniter.pyi | 14 +- .../cryptography/x509/__init__.pyi | 8 +- stubs/dataclasses/dataclasses.pyi | 16 +- stubs/dateparser/dateparser/date.pyi | 4 +- .../dateparser/dateparser/search/__init__.pyi | 6 +- stubs/decorator/decorator.pyi | 10 +- stubs/docutils/docutils/__init__.pyi | 12 +- stubs/docutils/docutils/frontend.pyi | 6 +- stubs/docutils/docutils/parsers/__init__.pyi | 4 +- stubs/docutils/docutils/parsers/null.pyi | 4 +- .../docutils/parsers/rst/__init__.pyi | 4 +- stubs/docutils/docutils/parsers/rst/roles.pyi | 6 +- stubs/entrypoints/entrypoints.pyi | 4 +- stubs/filelock/filelock/__init__.pyi | 6 +- stubs/flake8-2020/flake8_2020.pyi | 4 +- stubs/flake8-builtins/flake8_builtins.pyi | 4 +- stubs/flake8-docstrings/flake8_docstrings.pyi | 4 +- .../flake8_plugin_utils/plugin.pyi | 8 +- .../flake8_plugin_utils/utils/assertions.pyi | 6 +- stubs/flake8-simplify/flake8_simplify.pyi | 4 +- .../flake8_typing_imports.pyi | 4 +- stubs/fpdf2/fpdf/image_parsing.pyi | 4 +- stubs/fpdf2/fpdf/syntax.pyi | 4 +- stubs/fpdf2/fpdf/util.pyi | 4 +- stubs/freezegun/freezegun/api.pyi | 6 +- stubs/frozendict/frozendict.pyi | 6 +- .../google/cloud/ndb/model.pyi | 44 ++--- stubs/hdbcli/hdbcli/dbapi.pyi | 20 +-- 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/ldap3/ldap3/__init__.pyi | 10 +- stubs/ldap3/ldap3/core/connection.pyi | 4 +- stubs/ldap3/ldap3/core/exceptions.pyi | 4 +- stubs/mock/mock/mock.pyi | 16 +- stubs/mypy-extensions/mypy_extensions.pyi | 4 +- stubs/mysqlclient/MySQLdb/__init__.pyi | 4 +- stubs/mysqlclient/MySQLdb/_mysql.pyi | 4 +- stubs/oauthlib/oauthlib/common.pyi | 4 +- .../oauthlib/oauth2/rfc6749/tokens.pyi | 4 +- stubs/opentracing/opentracing/scope.pyi | 4 +- stubs/opentracing/opentracing/span.pyi | 4 +- stubs/paramiko/paramiko/_winapi.pyi | 4 +- stubs/paramiko/paramiko/agent.pyi | 4 +- stubs/paramiko/paramiko/auth_handler.pyi | 4 +- stubs/paramiko/paramiko/client.pyi | 4 +- stubs/paramiko/paramiko/config.pyi | 4 +- stubs/paramiko/paramiko/ecdsakey.pyi | 10 +- stubs/paramiko/paramiko/file.pyi | 4 +- stubs/paramiko/paramiko/pkey.pyi | 6 +- stubs/paramiko/paramiko/py3compat.pyi | 10 +- stubs/paramiko/paramiko/server.pyi | 4 +- stubs/paramiko/paramiko/sftp_server.pyi | 4 +- stubs/paramiko/paramiko/ssh_gss.pyi | 4 +- stubs/paramiko/paramiko/transport.pyi | 8 +- stubs/paramiko/paramiko/util.pyi | 6 +- stubs/polib/polib.pyi | 8 +- stubs/psutil/psutil/__init__.pyi | 6 +- stubs/psycopg2/psycopg2/_psycopg.pyi | 8 +- stubs/psycopg2/psycopg2/extras.pyi | 4 +- stubs/pyOpenSSL/OpenSSL/crypto.pyi | 6 +- stubs/pyaudio/pyaudio.pyi | 4 +- stubs/pycurl/pycurl.pyi | 4 +- stubs/pysftp/pysftp/__init__.pyi | 4 +- stubs/python-nmap/nmap/nmap.pyi | 4 +- stubs/pyvmomi/pyVmomi/vim/view.pyi | 4 +- stubs/pyvmomi/pyVmomi/vmodl/query.pyi | 10 +- stubs/redis/redis/client.pyi | 10 +- stubs/redis/redis/connection.pyi | 4 +- stubs/redis/redis/lock.pyi | 4 +- stubs/redis/redis/sentinel.pyi | 6 +- stubs/requests/requests/models.pyi | 4 +- stubs/requests/requests/sessions.pyi | 10 +- stubs/requests/requests/structures.pyi | 4 +- stubs/retry/retry/api.pyi | 6 +- stubs/setuptools/pkg_resources/__init__.pyi | 18 +- stubs/setuptools/setuptools/__init__.pyi | 6 +- .../setuptools/command/easy_install.pyi | 4 +- stubs/six/six/__init__.pyi | 18 +- stubs/stripe/stripe/stripe_object.pyi | 4 +- stubs/tabulate/tabulate.pyi | 6 +- stubs/toml/toml.pyi | 6 +- stubs/vobject/vobject/icalendar.pyi | 12 +- stubs/waitress/waitress/__init__.pyi | 4 +- 327 files changed, 1545 insertions(+), 1545 deletions(-) diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index a44a8a1a7c2a..470722a293a3 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -1,13 +1,13 @@ import codecs import sys -from typing import Any, Callable, Dict, Tuple, Union +from typing import Any, Callable, Union # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap: def size(self) -> int: ... -_MapT = Union[Dict[int, int], _EncodingMap] -_Handler = Callable[[Exception], Tuple[str, int]] +_MapT = Union[dict[int, int], _EncodingMap] +_Handler = Callable[[Exception], tuple[str, int]] def register(__search_function: Callable[[str], Any]) -> None: ... def register_error(__errors: str, __handler: _Handler) -> None: ... diff --git a/stdlib/_compression.pyi b/stdlib/_compression.pyi index 8f81847ff492..15d7074e4448 100644 --- a/stdlib/_compression.pyi +++ b/stdlib/_compression.pyi @@ -1,6 +1,6 @@ from _typeshed import WriteableBuffer from io import BufferedIOBase, RawIOBase -from typing import Any, Callable, Protocol, Tuple, Type +from typing import Any, Callable, Protocol BUFFER_SIZE: Any @@ -16,7 +16,7 @@ class DecompressReader(RawIOBase): self, fp: _Reader, decomp_factory: Callable[..., object], - trailing_error: Type[Exception] | Tuple[Type[Exception], ...] = ..., + trailing_error: type[Exception] | tuple[type[Exception], ...] = ..., **decomp_args: Any, ) -> None: ... def readable(self) -> bool: ... diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index 65f0ca27f0ec..57cf26705b69 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, List, Protocol, Type, Union +from typing import Any, Iterable, Iterator, Protocol, Union QUOTE_ALL: int QUOTE_MINIMAL: int @@ -18,9 +18,9 @@ class Dialect: strict: int def __init__(self) -> None: ... -_DialectLike = Union[str, Dialect, Type[Dialect]] +_DialectLike = Union[str, Dialect, type[Dialect]] -class _reader(Iterator[List[str]]): +class _reader(Iterator[list[str]]): dialect: Dialect line_num: int def __next__(self) -> list[str]: ... diff --git a/stdlib/_dummy_thread.pyi b/stdlib/_dummy_thread.pyi index 886d9d739780..8935c1d71e0b 100644 --- a/stdlib/_dummy_thread.pyi +++ b/stdlib/_dummy_thread.pyi @@ -1,9 +1,9 @@ -from typing import Any, Callable, NoReturn, Tuple +from typing import Any, Callable, NoReturn TIMEOUT_MAX: int error = RuntimeError -def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... +def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... def exit() -> NoReturn: ... def get_ident() -> int: ... def allocate_lock() -> LockType: ... diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index 64998d86bf9f..870366af6fd8 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -1,6 +1,6 @@ import sys from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, Mapping, Optional, Type, TypeVar +from typing import Any, Callable, Iterable, Mapping, Optional, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] @@ -67,7 +67,7 @@ class Lock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -77,7 +77,7 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -88,7 +88,7 @@ class Condition: def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -101,7 +101,7 @@ class Condition: class Semaphore: def __init__(self, value: int = ...) -> None: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index 408ec7ca28dc..ad43a32bc279 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -13,7 +13,7 @@ from typing import ( Protocol, Sequence, SupportsAbs, - Tuple, + TypeVar, overload, ) @@ -99,7 +99,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 +113,7 @@ class itemgetter(Generic[_T_co]): @overload def __new__(cls, item: Any, __item2: Any, __item3: Any, __item4: Any) -> itemgetter[tuple[Any, Any, Any, Any]]: ... @overload - def __new__(cls, item: Any, *items: Any) -> itemgetter[Tuple[Any, ...]]: ... + def __new__(cls, item: Any, *items: Any) -> itemgetter[tuple[Any, ...]]: ... def __call__(self, obj: Any) -> _T_co: ... @final diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index 49ebf93c31b7..ffb25d5a2c0e 100644 --- a/stdlib/_osx_support.pyi +++ b/stdlib/_osx_support.pyi @@ -1,5 +1,5 @@ import sys -from typing import Iterable, Sequence, Tuple, TypeVar +from typing import Iterable, Sequence, TypeVar _T = TypeVar("_T") _K = TypeVar("_K") @@ -7,8 +7,8 @@ _V = TypeVar("_V") __all__: list[str] -_UNIVERSAL_CONFIG_VARS: Tuple[str, ...] # undocumented -_COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented +_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented +_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented _INITPRE: str # undocumented def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented diff --git a/stdlib/_py_abc.pyi b/stdlib/_py_abc.pyi index 8d7938918271..42f36d1b3083 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, 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 register(cls, subclass: Type[_T]) -> Type[_T]: ... + 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/_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..744799f1f66f 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import structseq from threading import Thread from types import TracebackType -from typing import Any, Callable, NoReturn, Optional, Tuple, Type +from typing import Any, Callable, NoReturn, Optional from typing_extensions import final error = RuntimeError @@ -18,10 +18,10 @@ class LockType: def locked(self) -> bool: ... def __enter__(self) -> bool: ... def __exit__( - self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + 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,10 +34,10 @@ 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]: ... + def exc_type(self) -> type[BaseException]: ... @property def exc_value(self) -> BaseException | None: ... @property diff --git a/stdlib/_threading_local.pyi b/stdlib/_threading_local.pyi index bab69a7c2e7d..9e1e3f48d286 100644 --- a/stdlib/_threading_local.pyi +++ b/stdlib/_threading_local.pyi @@ -1,7 +1,7 @@ -from typing import Any, Dict +from typing import Any from weakref import ReferenceType -localdict = Dict[Any, Any] +localdict = dict[Any, Any] class _localimpl: key: str diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index a7f8c5147103..ab1e4791aa32 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -7,7 +7,7 @@ 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, Awaitable, ClassVar, Container, Generic, Iterable, Protocol, TypeVar, Union from typing_extensions import Literal, final _KT = TypeVar("_KT") @@ -215,4 +215,4 @@ class structseq(Generic[_T_co]): # The second parameter will accept a dict of any kind without raising an exception, # but only has any meaning if you supply it a dict where the keys are strings. # https://github.com/python/typeshed/pull/6560#discussion_r767149830 - def __new__(cls: Type[_T], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> _T: ... + def __new__(cls: type[_T], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> _T: ... diff --git a/stdlib/_typeshed/wsgi.pyi b/stdlib/_typeshed/wsgi.pyi index 658b0fed2c6c..031d1472b6c5 100644 --- a/stdlib/_typeshed/wsgi.pyi +++ b/stdlib/_typeshed/wsgi.pyi @@ -3,7 +3,7 @@ # See the README.md file in this directory for more information. from sys import _OptExcInfo -from typing import Any, Callable, Dict, Iterable, Protocol +from typing import Any, Callable, Iterable, Protocol # stable class StartResponse(Protocol): @@ -11,7 +11,7 @@ class StartResponse(Protocol): self, status: str, headers: list[tuple[str, str]], exc_info: _OptExcInfo | None = ... ) -> Callable[[bytes], Any]: ... -WSGIEnvironment = Dict[str, Any] # stable +WSGIEnvironment = dict[str, Any] # stable WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] # stable # WSGI input streams per PEP 3333, stable diff --git a/stdlib/_warnings.pyi b/stdlib/_warnings.pyi index e5b180b14fea..2eb9ae478a5d 100644 --- a/stdlib/_warnings.pyi +++ b/stdlib/_warnings.pyi @@ -1,21 +1,21 @@ -from typing import Any, Type, overload +from typing import Any, overload _defaultaction: str _onceregistry: dict[Any, Any] -filters: list[tuple[str, str | None, Type[Warning], str | None, int]] +filters: list[tuple[str, str | None, type[Warning], str | None, int]] @overload -def warn(message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... +def warn(message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... @overload def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... @overload def warn_explicit( message: str, - category: Type[Warning], + category: type[Warning], filename: str, lineno: int, module: str | None = ..., - registry: dict[str | tuple[str, Type[Warning], int], int] | None = ..., + registry: dict[str | tuple[str, type[Warning], int], int] | None = ..., module_globals: dict[str, Any] | None = ..., source: Any | None = ..., ) -> None: ... @@ -26,7 +26,7 @@ def warn_explicit( filename: str, lineno: int, module: str | None = ..., - registry: dict[str | tuple[str, Type[Warning], int], int] | None = ..., + registry: dict[str | tuple[str, type[Warning], int], int] | None = ..., module_globals: dict[str, Any] | None = ..., source: Any | None = ..., ) -> None: ... diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index c9dbda103ef3..33a53cc74c33 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import SupportsWrite -from typing import Any, Callable, Tuple, Type, TypeVar +from typing import Any, Callable, TypeVar _T = TypeVar("_T") _FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) @@ -8,11 +8,11 @@ _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: ... - def register(cls: ABCMeta, subclass: Type[_T]) -> Type[_T]: ... + def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ... def abstractmethod(funcobj: _FuncT) -> _FuncT: ... @@ -27,4 +27,4 @@ class ABC(metaclass=ABCMeta): ... def get_cache_token() -> object: ... if sys.version_info >= (3, 10): - def update_abstractmethods(cls: Type[_T]) -> Type[_T]: ... + def update_abstractmethods(cls: type[_T]) -> type[_T]: ... diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index 79f470a366bb..f88459befa27 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, Union, overload from typing_extensions import Literal class Error(Exception): ... @@ -15,13 +15,13 @@ 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: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def getfp(self) -> IO[bytes]: ... @@ -45,7 +45,7 @@ class Aifc_write: def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def aiff(self) -> None: ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 8e252ddc75c6..5b4e3142fb7c 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -10,8 +10,8 @@ from typing import ( Pattern, Protocol, Sequence, - Tuple, - Type, + + TypeVar, overload, ) @@ -62,7 +62,7 @@ class _ActionsContainer: def add_argument( self, *name_or_flags: str, - action: str | Type[Action] = ..., + action: str | type[Action] = ..., nargs: int | str = ..., const: Any = ..., default: Any = ..., @@ -70,7 +70,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, @@ -82,7 +82,7 @@ class _ActionsContainer: def _add_container_actions(self, container: _ActionsContainer) -> None: ... def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> dict[str, Any]: ... def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ... - def _pop_action_class(self, kwargs: Any, default: Type[Action] | None = ...) -> Type[Action]: ... + def _pop_action_class(self, kwargs: Any, default: type[Action] | None = ...) -> type[Action]: ... def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ... def _check_conflict(self, action: Action) -> None: ... def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ... @@ -158,7 +158,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): title: str = ..., description: str | None = ..., prog: str = ..., - action: Type[Action] = ..., + action: type[Action] = ..., option_string: str = ..., dest: str | None = ..., required: bool = ..., @@ -172,8 +172,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): title: str = ..., description: str | None = ..., prog: str = ..., - parser_class: Type[_ArgumentParserT] = ..., - action: Type[Action] = ..., + parser_class: type[_ArgumentParserT] = ..., + action: type[Action] = ..., option_string: str = ..., dest: str | None = ..., required: bool = ..., @@ -188,7 +188,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): title: str = ..., description: str | None = ..., prog: str = ..., - action: Type[Action] = ..., + action: type[Action] = ..., option_string: str = ..., dest: str | None = ..., help: str | None = ..., @@ -201,8 +201,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): title: str = ..., description: str | None = ..., prog: str = ..., - parser_class: Type[_ArgumentParserT] = ..., - action: Type[Action] = ..., + parser_class: type[_ArgumentParserT] = ..., + action: type[Action] = ..., option_string: str = ..., dest: str | None = ..., help: str | None = ..., @@ -252,7 +252,7 @@ class HelpFormatter: _current_section: Any _whitespace_matcher: Pattern[str] _long_break_matcher: Pattern[str] - _Section: Type[Any] # Nested class + _Section: type[Any] # Nested class def __init__(self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ...) -> None: ... def _indent(self) -> None: ... def _dedent(self) -> None: ... @@ -274,7 +274,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 +299,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 +311,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 +330,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 +375,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 +403,7 @@ class _AppendConstAction(Action): default: Any = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... # undocumented @@ -425,9 +425,9 @@ class _VersionAction(Action): # undocumented class _SubParsersAction(Action, Generic[_ArgumentParserT]): - _ChoicesPseudoAction: Type[Any] # nested class + _ChoicesPseudoAction: type[Any] # nested class _prog_prefix: str - _parser_class: Type[_ArgumentParserT] + _parser_class: type[_ArgumentParserT] _name_parser_map: dict[str, _ArgumentParserT] choices: dict[str, _ArgumentParserT] _choices_actions: list[Action] @@ -436,21 +436,21 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): self, option_strings: Sequence[str], prog: str, - parser_class: Type[_ArgumentParserT], + parser_class: type[_ArgumentParserT], dest: str = ..., required: bool = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... else: def __init__( self, option_strings: Sequence[str], prog: str, - parser_class: Type[_ArgumentParserT], + parser_class: type[_ArgumentParserT], dest: str = ..., help: str | None = ..., - metavar: str | Tuple[str, ...] | None = ..., + metavar: str | tuple[str, ...] | None = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: str, **kwargs: Any) -> _ArgumentParserT: ... diff --git a/stdlib/asyncio/__init__.pyi b/stdlib/asyncio/__init__.pyi index f2f7c6b0d165..87956fdd08ef 100644 --- a/stdlib/asyncio/__init__.pyi +++ b/stdlib/asyncio/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import Type + from .base_events import BaseEventLoop as BaseEventLoop from .coroutines import iscoroutine as iscoroutine, iscoroutinefunction as iscoroutinefunction @@ -108,7 +108,7 @@ if sys.version_info >= (3, 7): current_task as current_task, ) -DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy] +DefaultEventLoopPolicy: type[AbstractEventLoopPolicy] if sys.platform == "win32": from .windows_events import * diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index e804c2f5d3bd..674baf49ba05 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -9,18 +9,18 @@ from asyncio.tasks import Task from asyncio.transports import BaseTransport from collections.abc import Iterable from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Awaitable, Callable, Dict, Generator, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Awaitable, Callable, Generator, Sequence, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 7): from contextvars import Context _T = TypeVar("_T") -_Context = Dict[str, Any] +_Context = dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] _ProtocolFactory = Callable[[], BaseProtocol] _SSLContext = Union[bool, None, ssl.SSLContext] -_TransProtPair = Tuple[BaseTransport, BaseProtocol] +_TransProtPair = tuple[BaseTransport, BaseProtocol] class Server(AbstractServer): if sys.version_info >= (3, 7): @@ -37,7 +37,7 @@ class Server(AbstractServer): def __init__(self, loop: AbstractEventLoop, sockets: list[socket]) -> None: ... if sys.version_info >= (3, 8): @property - def sockets(self) -> Tuple[socket, ...]: ... + def sockets(self) -> tuple[socket, ...]: ... elif sys.version_info >= (3, 7): @property def sockets(self) -> list[socket]: ... diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index 096bce60f7e3..94c7c01dd1bc 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -1,6 +1,6 @@ import subprocess from collections import deque -from typing import IO, Any, Callable, Optional, Sequence, Tuple, Union +from typing import IO, Any, Callable, Optional, Sequence, Union from . import events, futures, protocols, transports @@ -15,7 +15,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): _pid: int | None # undocumented _returncode: int | None # undocumented _exit_waiters: list[futures.Future[Any]] # undocumented - _pending_calls: deque[tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented + _pending_calls: deque[tuple[Callable[..., Any], tuple[Any, ...]]] # undocumented _pipes: dict[int, _File] # undocumented _finished: bool # undocumented def __init__( diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 6ef9117b6491..81b30b7e0065 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -3,7 +3,7 @@ import sys from _typeshed import FileDescriptorLike, Self from abc import ABCMeta, abstractmethod from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Awaitable, Callable, Dict, Generator, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Awaitable, Callable, Generator, Sequence, TypeVar, Union, overload from typing_extensions import Literal from .base_events import Server @@ -17,11 +17,11 @@ if sys.version_info >= (3, 7): from contextvars import Context _T = TypeVar("_T") -_Context = Dict[str, Any] +_Context = dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] _ProtocolFactory = Callable[[], BaseProtocol] _SSLContext = Union[bool, None, ssl.SSLContext] -_TransProtPair = Tuple[BaseTransport, BaseProtocol] +_TransProtPair = tuple[BaseTransport, BaseProtocol] class Handle: _cancelled = False diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 7c4f40d9e4ca..fa1b9235ae29 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,7 +1,7 @@ import sys from collections import deque from types import TracebackType -from typing import Any, Awaitable, Callable, Generator, Type, TypeVar +from typing import Any, Awaitable, Callable, Generator, TypeVar from .events import AbstractEventLoop from .futures import Future @@ -13,7 +13,7 @@ if sys.version_info >= (3, 9): def __init__(self, lock: Lock | Semaphore) -> None: ... def __aenter__(self) -> Awaitable[None]: ... def __aexit__( - self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> Awaitable[None]: ... else: @@ -30,7 +30,7 @@ else: def __await__(self) -> Generator[Any, None, _ContextManager]: ... def __aenter__(self) -> Awaitable[None]: ... def __aexit__( - self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> Awaitable[None]: ... class Lock(_ContextManagerMixin): diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index 1e9cff1b1dd6..3c5182a39642 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -1,6 +1,6 @@ import sys from socket import socket -from typing import Any, Mapping, Protocol, Type +from typing import Any, Mapping, Protocol from typing_extensions import Literal from . import base_events, constants, events, futures, streams, transports @@ -8,7 +8,7 @@ from . import base_events, constants, events, futures, streams, transports if sys.version_info >= (3, 8): class _WarnCallbackProtocol(Protocol): def __call__( - self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... + self, message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... ) -> None: ... class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 33ec5d67aaf9..55147f4fddd5 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -1,14 +1,14 @@ import socket import sys from types import TracebackType -from typing import Any, BinaryIO, Iterable, NoReturn, Tuple, Type, Union, overload +from typing import Any, BinaryIO, Iterable, NoReturn, Type, Union, overload if sys.version_info >= (3, 8): # These are based in socket, maybe move them out into _typeshed.pyi or such - _Address = Union[Tuple[Any, ...], str] + _Address = Union[tuple[Any, ...], str] _RetAddress = Any _WriteBuffer = Union[bytearray, memoryview] - _CMSG = Tuple[int, int, bytes] + _CMSG = tuple[int, int, bytes] class TransportSocket: def __init__(self, sock: socket.socket) -> None: ... def _na(self, what: str) -> None: ... diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index e8e57a20a765..cd2e7179413a 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -2,7 +2,7 @@ import sys import types from _typeshed import Self from socket import socket -from typing import Any, Callable, Type +from typing import Any, Callable from .base_events import Server from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext @@ -14,7 +14,7 @@ class AbstractChildWatcher: def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... if sys.version_info >= (3, 8): def is_active(self) -> bool: ... @@ -52,7 +52,7 @@ if sys.version_info >= (3, 8): from typing import Protocol class _Warn(Protocol): def __call__( - self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... + self, message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... ) -> None: ... class MultiLoopChildWatcher(AbstractChildWatcher): def __enter__(self: Self) -> Self: ... diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index 6d17bada312f..378d7450b920 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -1,7 +1,7 @@ import socket import sys from _typeshed import WriteableBuffer -from typing import IO, Any, Callable, ClassVar, NoReturn, Type +from typing import IO, Any, Callable, ClassVar, NoReturn from . import events, futures, proactor_events, selector_events, streams, windows_utils @@ -64,17 +64,17 @@ SelectorEventLoop = _WindowsSelectorEventLoop if sys.version_info >= (3, 7): class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[Type[SelectorEventLoop]] + _loop_factory: ClassVar[type[SelectorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[Type[ProactorEventLoop]] + _loop_factory: ClassVar[type[ProactorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy else: class _WindowsDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[Type[SelectorEventLoop]] + _loop_factory: ClassVar[type[SelectorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... DefaultEventLoopPolicy = _WindowsDefaultEventLoopPolicy diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index bf9cdde25a78..db700ebca968 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -1,10 +1,10 @@ import sys from _typeshed import Self from types import TracebackType -from typing import Callable, Protocol, Type +from typing import Callable, Protocol class _WarnFunction(Protocol): - def __call__(self, message: str, category: Type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ...) -> None: ... + def __call__(self, message: str, category: type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ...) -> None: ... BUFSIZE: int PIPE: int diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index e135221134a5..123da2677a7e 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -1,10 +1,10 @@ import sys from _typeshed import FileDescriptorLike from socket import socket -from typing import Any, Dict, Tuple, overload +from typing import Any, overload # cyclic dependence with asynchat -_maptype = Dict[int, Any] +_maptype = dict[int, Any] _socket = socket socket_map: _maptype # undocumented @@ -41,8 +41,8 @@ class dispatcher: def readable(self) -> bool: ... def writable(self) -> bool: ... def listen(self, num: int) -> None: ... - def bind(self, addr: Tuple[Any, ...] | str) -> None: ... - def connect(self, address: Tuple[Any, ...] | str) -> None: ... + def bind(self, addr: tuple[Any, ...] | str) -> None: ... + def connect(self, address: tuple[Any, ...] | str) -> None: ... def accept(self) -> tuple[_socket, Any] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index 321bfe55c4b0..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..993f0c6e2d99 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -1,9 +1,9 @@ from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, Tuple, Type, TypeVar +from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, 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..7180540f8f22 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -49,8 +49,8 @@ from typing import ( SupportsFloat, SupportsInt, SupportsRound, - Tuple, - Type, + + TypeVar, Union, overload, @@ -90,12 +90,12 @@ class object: __module__: str __annotations__: dict[str, Any] @property - def __class__(self: _T) -> Type[_T]: ... + def __class__(self: _T) -> type[_T]: ... # Ignore errors about type mismatch between property getter and setter @__class__.setter - def __class__(self, __type: Type[object]) -> None: ... # type: ignore # noqa: F811 + def __class__(self, __type: type[object]) -> None: ... # type: ignore # noqa: F811 def __init__(self) -> None: ... - def __new__(cls: Type[_T]) -> _T: ... + def __new__(cls: type[_T]) -> _T: ... def __setattr__(self, __name: str, __value: Any) -> None: ... def __eq__(self, __o: object) -> bool: ... def __ne__(self, __o: object) -> bool: ... @@ -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: ... @@ -120,8 +120,8 @@ class staticmethod(Generic[_R]): # Special, only valid as a decorator. __func__: Callable[..., _R] __isabstractmethod__: bool def __init__(self: staticmethod[_R], __f: Callable[..., _R]) -> None: ... - def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, __obj: _T, __type: Type[_T] | None = ...) -> Callable[..., _R]: ... + def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, __obj: _T, __type: type[_T] | None = ...) -> Callable[..., _R]: ... if sys.version_info >= (3, 10): __name__: str __qualname__: str @@ -132,8 +132,8 @@ class classmethod(Generic[_R]): # Special, only valid as a decorator. __func__: Callable[..., _R] __isabstractmethod__: bool def __init__(self: classmethod[_R], __f: Callable[..., _R]) -> None: ... - def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, __obj: _T, __type: Type[_T] | None = ...) -> Callable[..., _R]: ... + def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, __obj: _T, __type: type[_T] | None = ...) -> Callable[..., _R]: ... if sys.version_info >= (3, 10): __name__: str __qualname__: str @@ -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: ... @@ -187,9 +187,9 @@ _NegativeInteger = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -1 class int: @overload - def __new__(cls: Type[_T], __x: str | bytes | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> _T: ... + def __new__(cls: type[_T], __x: str | bytes | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> _T: ... @overload - def __new__(cls: Type[_T], __x: str | bytes | bytearray, base: SupportsIndex) -> _T: ... + def __new__(cls: type[_T], __x: str | bytes | bytearray, base: SupportsIndex) -> _T: ... if sys.version_info >= (3, 8): def as_integer_ratio(self) -> tuple[int, Literal[1]]: ... @property @@ -269,7 +269,7 @@ class int: def __index__(self) -> int: ... class float: - def __new__(cls: Type[_T], x: SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> _T: ... + def __new__(cls: type[_T], x: SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> _T: ... def as_integer_ratio(self) -> tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -327,9 +327,9 @@ class float: class complex: @overload - def __new__(cls: Type[_T], real: float = ..., imag: float = ...) -> _T: ... + def __new__(cls: type[_T], real: float = ..., imag: float = ...) -> _T: ... @overload - def __new__(cls: Type[_T], real: str | SupportsComplex | SupportsIndex | complex) -> _T: ... + def __new__(cls: type[_T], real: str | SupportsComplex | SupportsIndex | complex) -> _T: ... @property def real(self) -> float: ... @property @@ -361,16 +361,16 @@ class _FormatMapMapping(Protocol): class str(Sequence[str]): @overload - def __new__(cls: Type[_T], object: object = ...) -> _T: ... + def __new__(cls: type[_T], object: object = ...) -> _T: ... @overload - def __new__(cls: Type[_T], o: bytes, encoding: str = ..., errors: str = ...) -> _T: ... + def __new__(cls: type[_T], o: bytes, encoding: str = ..., errors: str = ...) -> _T: ... def capitalize(self) -> str: ... def casefold(self) -> str: ... def center(self, __width: SupportsIndex, __fillchar: str = ...) -> 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: ... @@ -447,15 +447,15 @@ class str(Sequence[str]): class bytes(ByteString): @overload - def __new__(cls: Type[_T], __ints: Iterable[SupportsIndex]) -> _T: ... + def __new__(cls: type[_T], __ints: Iterable[SupportsIndex]) -> _T: ... @overload - def __new__(cls: Type[_T], __string: str, encoding: str, errors: str = ...) -> _T: ... + def __new__(cls: type[_T], __string: str, encoding: str, errors: str = ...) -> _T: ... @overload - def __new__(cls: Type[_T], __length: SupportsIndex) -> _T: ... + def __new__(cls: type[_T], __length: SupportsIndex) -> _T: ... @overload - def __new__(cls: Type[_T]) -> _T: ... + def __new__(cls: type[_T]) -> _T: ... @overload - def __new__(cls: Type[_T], __o: SupportsBytes) -> _T: ... + def __new__(cls: type[_T], __o: SupportsBytes) -> _T: ... def capitalize(self) -> bytes: ... def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... def count( @@ -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: ... @@ -519,7 +519,7 @@ class bytes(ByteString): def upper(self) -> bytes: ... def zfill(self, __width: SupportsIndex) -> bytes: ... @classmethod - def fromhex(cls: Type[_T], __s: str) -> _T: ... + def fromhex(cls: type[_T], __s: str) -> _T: ... @staticmethod def maketrans(__frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ... @@ -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 @@ -673,9 +673,9 @@ class memoryview(Sized, Sequence[int]): def __init__(self, obj: ReadableBuffer) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, __exc_type: Type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None + 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 @@ -702,7 +702,7 @@ class memoryview(Sized, Sequence[int]): @final class bool(int): - def __new__(cls: Type[_T], __o: object = ...) -> _T: ... + def __new__(cls: type[_T], __o: object = ...) -> _T: ... @overload def __and__(self, __x: bool) -> bool: ... @overload @@ -742,24 +742,24 @@ class slice(object): def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ... class tuple(Sequence[_T_co], Generic[_T_co]): - def __new__(cls: Type[_T], __iterable: Iterable[_T_co] = ...) -> _T: ... + def __new__(cls: type[_T], __iterable: Iterable[_T_co] = ...) -> _T: ... def __len__(self) -> int: ... def __contains__(self, __x: object) -> bool: ... @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): @@ -833,7 +833,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): # Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error @overload def __init__(self: dict[str, str], __iterable: Iterable[list[str]]) -> None: ... - def __new__(cls: Type[_T1], *args: Any, **kwargs: Any) -> _T1: ... + def __new__(cls: type[_T1], *args: Any, **kwargs: Any) -> _T1: ... def copy(self) -> dict[_KT, _VT]: ... def keys(self) -> dict_keys[_KT, _VT]: ... def values(self) -> dict_values[_KT, _VT]: ... @@ -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/cProfile.pyi b/stdlib/cProfile.pyi index f4a7ab50cc11..e79524aa793e 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from types import CodeType -from typing import Any, Callable, Tuple, TypeVar +from typing import Any, Callable, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( @@ -9,7 +9,7 @@ def runctx( ) -> None: ... _T = TypeVar("_T") -_Label = Tuple[str, int, str] +_Label = tuple[str, int, str] class Profile: stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 26073fb7281b..aa37928b87b1 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -1,9 +1,9 @@ import datetime import sys from time import struct_time -from typing import Any, Iterable, Optional, Sequence, Tuple +from typing import Any, Iterable, Optional, Sequence -_LocaleType = Tuple[Optional[str], Optional[str]] +_LocaleType = tuple[Optional[str], Optional[str]] class IllegalMonthError(ValueError): def __init__(self, month: int) -> None: ... @@ -97,7 +97,7 @@ c: TextCalendar def setfirstweekday(firstweekday: int) -> None: ... def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... -def timegm(tuple: Tuple[int, ...] | struct_time) -> int: ... +def timegm(tuple: tuple[int, ...] | struct_time) -> int: ... # Data attributes day_name: Sequence[str] diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index 7576740fc1c0..3a551e310b81 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -1,8 +1,8 @@ from _typeshed import StrOrBytesPath from types import FrameType, TracebackType -from typing import IO, Any, Callable, Optional, Tuple, Type +from typing import IO, Any, Callable, Optional -_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 @@ -24,7 +24,7 @@ class Hook: # undocumented file: IO[str] | None = ..., format: str = ..., ) -> None: ... - def __call__(self, etype: Type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None) -> None: ... + def __call__(self, etype: type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None) -> None: ... def handle(self, info: _ExcInfo | None = ...) -> None: ... def handler(info: _ExcInfo | None = ...) -> None: ... diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 63de22d99188..229d455b883d 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -2,7 +2,7 @@ import sys import types from _typeshed import Self from abc import abstractmethod -from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, Tuple, Type, TypeVar, overload +from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, TypeVar, overload from typing_extensions import Literal BOM32_BE: bytes @@ -71,7 +71,7 @@ def lookup(__encoding: str) -> CodecInfo: ... def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> tuple[str, int]: ... # undocumented def utf_16_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ... # undocumented -class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): +class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): @property def encode(self) -> _Encoder: ... @property @@ -186,7 +186,7 @@ class StreamWriter(Codec): def writelines(self, list: Iterable[str]) -> None: ... def reset(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... class StreamReader(Codec): @@ -197,7 +197,7 @@ class StreamReader(Codec): def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> list[str]: ... def reset(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __iter__(self) -> Iterator[str]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -219,7 +219,7 @@ class StreamReaderWriter(TextIO): # Same as write() def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str) -> Any: ... # These methods don't actually exist directly, but they are needed to satisfy the TextIO # interface. At runtime, they are delegated through __getattr__. @@ -255,7 +255,7 @@ class StreamRecoder(BinaryIO): def reset(self) -> None: ... def __getattr__(self, name: str) -> Any: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, type: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ... # These methods don't actually exist directly, but they are needed to satisfy the BinaryIO # interface. At runtime, they are delegated through __getattr__. def seek(self, offset: int, whence: int = ...) -> int: ... diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index d4808d326efe..b67f157c3f2b 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, 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: ... @@ -206,7 +206,7 @@ class deque(MutableSequence[_T], Generic[_T]): def __setitem__(self, __i: SupportsIndex, __x: _T) -> None: ... # type: ignore[override] def __delitem__(self, __i: SupportsIndex) -> None: ... # type: ignore[override] def __contains__(self, __o: object) -> bool: ... - def __reduce__(self: Self) -> tuple[Type[Self], tuple[()], None, Iterator[_T]]: ... + def __reduce__(self: Self) -> tuple[type[Self], tuple[()], None, Iterator[_T]]: ... def __iadd__(self: _S, __iterable: Iterable[_T]) -> _S: ... def __add__(self: _S, __other: _S) -> _S: ... def __mul__(self: _S, __other: int) -> _S: ... @@ -214,7 +214,7 @@ class deque(MutableSequence[_T], Generic[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... -class Counter(Dict[_T, int], Generic[_T]): +class Counter(dict[_T, int], Generic[_T]): @overload def __init__(self, __iterable: None = ..., **kwargs: int) -> None: ... @overload @@ -261,14 +261,14 @@ class _OrderedDictKeysView(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # ty def __reversed__(self) -> Iterator[_KT_co]: ... @final -class _OrderedDictItemsView(dict_items[_KT_co, _VT_co], Reversible[Tuple[_KT_co, _VT_co]]): # type: ignore[misc] +class _OrderedDictItemsView(dict_items[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]): # type: ignore[misc] def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... @final class _OrderedDictValuesView(dict_values[_KT_co, _VT_co], Reversible[_VT_co], Generic[_KT_co, _VT_co]): # type: ignore[misc] def __reversed__(self) -> Iterator[_VT_co]: ... -class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): +class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def popitem(self, last: bool = ...) -> tuple[_KT, _VT]: ... def move_to_end(self, key: _KT, last: bool = ...) -> None: ... def copy(self: Self) -> Self: ... @@ -286,7 +286,7 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): @overload def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> OrderedDict[_T, _S]: ... -class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): +class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]): default_factory: Callable[[], _VT] | None @overload def __init__(self, **kwargs: _VT) -> None: ... diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index c1a44c997381..ebc64159e54f 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -4,7 +4,7 @@ from _typeshed import Self from abc import abstractmethod from collections.abc import Container, Iterable, Iterator, Sequence from logging import Logger -from typing import Any, Callable, Generic, Protocol, Set, TypeVar, overload +from typing import Any, Callable, Generic, Protocol, TypeVar, overload from typing_extensions import SupportsIndex if sys.version_info >= (3, 9): @@ -76,7 +76,7 @@ class Executor: def as_completed(fs: Iterable[Future[_T]], timeout: float | None = ...) -> Iterator[Future[_T]]: ... # Ideally this would be a namedtuple, but mypy doesn't support generic tuple types. See #1976 -class DoneAndNotDoneFutures(Sequence[Set[Future[_T]]]): +class DoneAndNotDoneFutures(Sequence[set[Future[_T]]]): done: set[Future[_T]] not_done: set[Future[_T]] def __new__(_cls, done: set[Future[_T]], not_done: set[Future[_T]]) -> DoneAndNotDoneFutures[_T]: ... diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index cc48f48f0023..6435901a8f13 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -5,7 +5,7 @@ from multiprocessing.context import BaseContext, Process from multiprocessing.queues import Queue, SimpleQueue from threading import Lock, Semaphore, Thread from types import TracebackType -from typing import Any, Callable, Generic, Tuple, TypeVar +from typing import Any, Callable, Generic, TypeVar from weakref import ref from ._base import Executor, Future @@ -37,7 +37,7 @@ class _ExceptionWithTraceback: exc: BaseException tb: TracebackType def __init__(self, exc: BaseException, tb: TracebackType) -> None: ... - def __reduce__(self) -> str | Tuple[Any, ...]: ... + def __reduce__(self) -> str | tuple[Any, ...]: ... def _rebuild_exc(exc: Exception, tb: str) -> Exception: ... @@ -84,7 +84,7 @@ if sys.version_info >= (3, 7): ) -> None: ... def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ... -def _get_chunks(*iterables: Any, chunksize: int) -> Generator[Tuple[Any, ...], None, None]: ... +def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...], None, None]: ... def _process_chunk(fn: Callable[..., Any], chunk: tuple[Any, None, None]) -> Generator[Any, None, None]: ... def _sendback_result( result_queue: SimpleQueue[_WorkItem[Any]], work_id: int, result: Any | None = ..., exception: Exception | None = ... @@ -95,7 +95,7 @@ if sys.version_info >= (3, 7): call_queue: Queue[_CallItem], result_queue: SimpleQueue[_ResultItem], initializer: Callable[..., None] | None, - initargs: Tuple[Any, ...], + initargs: tuple[Any, ...], ) -> None: ... else: @@ -139,7 +139,7 @@ else: class ProcessPoolExecutor(Executor): _mp_context: BaseContext | None = ... _initializer: Callable[..., None] | None = ... - _initargs: Tuple[Any, ...] = ... + _initargs: tuple[Any, ...] = ... _executor_manager_thread: _ThreadWakeup _processes: MutableMapping[int, Process] _shutdown_thread: bool @@ -158,7 +158,7 @@ class ProcessPoolExecutor(Executor): max_workers: int | None = ..., mp_context: BaseContext | None = ..., initializer: Callable[..., None] | None = ..., - initargs: Tuple[Any, ...] = ..., + initargs: tuple[Any, ...] = ..., ) -> None: ... else: def __init__(self, max_workers: int | None = ...) -> None: ... diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 5ad5b65d3bec..2c66d7b37155 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -2,7 +2,7 @@ import queue import sys from collections.abc import Iterable, Mapping, Set # 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, Callable, Generic, TypeVar from weakref import ref from ._base import Executor, Future @@ -33,7 +33,7 @@ if sys.version_info >= (3, 7): executor_reference: ref[Any], work_queue: queue.SimpleQueue[Any], initializer: Callable[..., None], - initargs: Tuple[Any, ...], + initargs: tuple[Any, ...], ) -> None: ... else: @@ -52,7 +52,7 @@ class ThreadPoolExecutor(Executor): _shutdown_lock: Lock _thread_name_prefix: str | None = ... _initializer: Callable[..., None] | None = ... - _initargs: Tuple[Any, ...] = ... + _initargs: tuple[Any, ...] = ... if sys.version_info >= (3, 7): _work_queue: queue.SimpleQueue[_WorkItem[Any]] else: @@ -63,7 +63,7 @@ class ThreadPoolExecutor(Executor): max_workers: int | None = ..., thread_name_prefix: str = ..., initializer: Callable[..., None] | None = ..., - initargs: Tuple[Any, ...] = ..., + initargs: tuple[Any, ...] = ..., ) -> None: ... else: def __init__(self, max_workers: int | None = ..., thread_name_prefix: str = ...) -> None: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 83d9d969080a..e27e12ede4c7 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, 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): @@ -47,7 +47,7 @@ class RawConfigParser(_parser): def __init__( self, defaults: Mapping[str, str | None] | None = ..., - dict_type: Type[Mapping[str, str]] = ..., + dict_type: type[Mapping[str, str]] = ..., allow_no_value: Literal[True] = ..., *, delimiters: Sequence[str] = ..., @@ -63,7 +63,7 @@ class RawConfigParser(_parser): def __init__( self, defaults: _section | None = ..., - dict_type: Type[Mapping[str, str]] = ..., + dict_type: type[Mapping[str, str]] = ..., allow_no_value: bool = ..., *, delimiters: Sequence[str] = ..., diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index fe72d6dd42d9..48dbd939cc77 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -12,7 +12,7 @@ from typing import ( Iterator, Optional, Protocol, - Type, + TypeVar, overload, ) @@ -30,7 +30,7 @@ _T_io = TypeVar("_T_io", bound=Optional[IO[str]]) _F = TypeVar("_F", bound=Callable[..., Any]) _P = ParamSpec("_P") -_ExitFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] +_ExitFunc = Callable[[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] _CM_EF = TypeVar("_CM_EF", AbstractContextManager[Any], _ExitFunc) class ContextDecorator: @@ -69,9 +69,9 @@ if sys.version_info >= (3, 10): def __init__(self, thing: _SupportsAcloseT) -> None: ... class suppress(AbstractContextManager[None]): - def __init__(self, *exceptions: Type[BaseException]) -> None: ... + def __init__(self, *exceptions: type[BaseException]) -> None: ... def __exit__( - self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None + self, exctype: type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> bool: ... class redirect_stdout(AbstractContextManager[_T_io]): @@ -89,11 +89,11 @@ class ExitStack(AbstractContextManager[ExitStack]): def close(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None + self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> bool: ... if sys.version_info >= (3, 7): - _ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] + _ExitCoroFunc = Callable[[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] _CallbackCoroFunc = Callable[..., Awaitable[Any]] _ACM_EF = TypeVar("_ACM_EF", AbstractAsyncContextManager[Any], _ExitCoroFunc) class AsyncExitStack(AbstractAsyncContextManager[AsyncExitStack]): @@ -108,7 +108,7 @@ if sys.version_info >= (3, 7): def aclose(self) -> Awaitable[None]: ... def __aenter__(self: Self) -> Awaitable[Self]: ... def __aexit__( - self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None + self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> Awaitable[bool]: ... if sys.version_info >= (3, 10): diff --git a/stdlib/copyreg.pyi b/stdlib/copyreg.pyi index 320097b3a204..6097670833c0 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -1,7 +1,7 @@ -from typing import Any, Callable, Hashable, Optional, SupportsInt, Tuple, TypeVar, Union +from typing import Any, Callable, Hashable, Optional, SupportsInt, TypeVar, Union _TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] +_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Optional[Any]]] __all__: list[str] diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 0b69cb2272d3..512affa88cb8 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -18,7 +18,7 @@ from _csv import ( writer as writer, ) from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence -from typing import Any, Generic, Type, TypeVar, overload +from typing import Any, Generic, TypeVar, overload if sys.version_info >= (3, 8): from typing import Dict as _DictReadMapping @@ -103,5 +103,5 @@ class DictWriter(Generic[_T]): class Sniffer(object): preferred: list[str] def __init__(self) -> None: ... - def sniff(self, sample: str, delimiters: str | None = ...) -> Type[Dialect]: ... + def sniff(self, sample: str, delimiters: str | None = ...) -> type[Dialect]: ... def has_header(self, sample: str) -> bool: ... diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 5cf8ce289148..b0e0f3930a64 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -11,8 +11,8 @@ from typing import ( Mapping, Optional, Sequence, - Tuple, - Type, + + TypeVar, Union as _UnionT, overload, @@ -34,7 +34,7 @@ class CDLL(object): _func_restype_: ClassVar[_CData] _name: str _handle: int - _FuncPtr: Type[_FuncPointer] + _FuncPtr: type[_FuncPointer] if sys.version_info >= (3, 8): def __init__( self, @@ -59,7 +59,7 @@ if sys.platform == "win32": class PyDLL(CDLL): ... class LibraryLoader(Generic[_DLLT]): - def __init__(self, dlltype: Type[_DLLT]) -> None: ... + def __init__(self, dlltype: type[_DLLT]) -> None: ... def __getattr__(self, name: str) -> _DLLT: ... def __getitem__(self, name: str) -> _DLLT: ... def LoadLibrary(self, name: str) -> _DLLT: ... @@ -77,42 +77,42 @@ class _CDataMeta(type): # By default mypy complains about the following two methods, because strictly speaking cls # might not be a Type[_CT]. However this can never actually happen, because the only class that # uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here. - def __mul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore[misc] - def __rmul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore[misc] + def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] + def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] class _CData(metaclass=_CDataMeta): _b_base: int _b_needsfree_: bool _objects: Mapping[Any, int] | None @classmethod - def from_buffer(cls: Type[_CT], source: WriteableBuffer, offset: int = ...) -> _CT: ... + def from_buffer(cls: type[_CT], source: WriteableBuffer, offset: int = ...) -> _CT: ... @classmethod - def from_buffer_copy(cls: Type[_CT], source: ReadableBuffer, offset: int = ...) -> _CT: ... + def from_buffer_copy(cls: type[_CT], source: ReadableBuffer, offset: int = ...) -> _CT: ... @classmethod - def from_address(cls: Type[_CT], address: int) -> _CT: ... + def from_address(cls: type[_CT], address: int) -> _CT: ... @classmethod - def from_param(cls: Type[_CT], obj: Any) -> _CT | _CArgObject: ... + def from_param(cls: type[_CT], obj: Any) -> _CT | _CArgObject: ... @classmethod - def in_dll(cls: Type[_CT], library: CDLL, name: str) -> _CT: ... + def in_dll(cls: type[_CT], library: CDLL, name: str) -> _CT: ... 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 - argtypes: Sequence[Type[_CData]] + restype: type[_CData] | Callable[[int], Any] | None + argtypes: Sequence[type[_CData]] errcheck: _ECT @overload def __init__(self, address: int) -> None: ... @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): @@ -121,15 +121,15 @@ class _NamedFuncPointer(_FuncPointer): class ArgumentError(Exception): ... def CFUNCTYPE( - restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... -) -> Type[_FuncPointer]: ... + restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ... +) -> type[_FuncPointer]: ... if sys.platform == "win32": def WINFUNCTYPE( - restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... - ) -> Type[_FuncPointer]: ... + restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ... + ) -> type[_FuncPointer]: ... -def PYFUNCTYPE(restype: Type[_CData] | None, *argtypes: Type[_CData]) -> Type[_FuncPointer]: ... +def PYFUNCTYPE(restype: type[_CData] | None, *argtypes: type[_CData]) -> type[_FuncPointer]: ... class _CArgObject: ... @@ -143,12 +143,12 @@ _CVoidPLike = _UnionT[_PointerLike, Array[Any], _CArgObject, int] _CVoidConstPLike = _UnionT[_CVoidPLike, bytes] def addressof(obj: _CData) -> int: ... -def alignment(obj_or_type: _CData | Type[_CData]) -> int: ... +def alignment(obj_or_type: _CData | type[_CData]) -> int: ... def byref(obj: _CData, offset: int = ...) -> _CArgObject: ... _CastT = TypeVar("_CastT", bound=_CanCastTo) -def cast(obj: _CData | _CArgObject | int, typ: Type[_CastT]) -> _CastT: ... +def cast(obj: _CData | _CArgObject | int, typ: type[_CastT]) -> _CastT: ... def create_string_buffer(init: int | bytes, size: int | None = ...) -> Array[c_char]: ... c_buffer = create_string_buffer @@ -168,13 +168,13 @@ if sys.platform == "win32": def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> None: ... def memset(dst: _CVoidPLike, c: int, count: int) -> None: ... -def POINTER(type: Type[_CT]) -> Type[pointer[_CT]]: ... +def POINTER(type: type[_CT]) -> type[pointer[_CT]]: ... # The real ctypes.pointer is a function, not a class. The stub version of pointer behaves like # ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer, # it can be instantiated directly (to mimic the behavior of the real pointer function). class pointer(Generic[_CT], _PointerLike, _CData): - _type_: Type[_CT] + _type_: type[_CT] contents: _CT def __init__(self, arg: _CT = ...) -> None: ... @overload @@ -192,7 +192,7 @@ def set_errno(value: int) -> int: ... if sys.platform == "win32": def set_last_error(value: int) -> int: ... -def sizeof(obj_or_type: _CData | Type[_CData]) -> int: ... +def sizeof(obj_or_type: _CData | type[_CData]) -> int: ... def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ... if sys.platform == "win32": @@ -253,7 +253,7 @@ class _CField: size: int class _StructUnionMeta(_CDataMeta): - _fields_: Sequence[tuple[str, Type[_CData]] | tuple[str, Type[_CData], int]] + _fields_: Sequence[tuple[str, type[_CData]] | tuple[str, type[_CData], int]] _pack_: int _anonymous_: Sequence[str] def __getattr__(self, name: str) -> _CField: ... @@ -276,9 +276,9 @@ class Array(Generic[_CT], _CData): def _length_(self, value: int) -> None: ... @property @abstractmethod - def _type_(self) -> Type[_CT]: ... + def _type_(self) -> type[_CT]: ... @_type_.setter - def _type_(self, value: Type[_CT]) -> None: ... + def _type_(self, value: type[_CT]) -> None: ... raw: bytes # Note: only available if _CT == c_char value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise # TODO These methods cannot be annotated correctly at the moment. diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 6dfe83c2d4a8..885facb9c0db 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -1,6 +1,6 @@ import sys import types -from typing import Any, Callable, Generic, Iterable, Mapping, Protocol, Tuple, Type, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Mapping, Protocol, Type, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -20,7 +20,7 @@ def asdict(obj: Any) -> dict[str, Any]: ... @overload def asdict(obj: Any, *, dict_factory: Callable[[list[tuple[str, Any]]], _T]) -> _T: ... @overload -def astuple(obj: Any) -> Tuple[Any, ...]: ... +def astuple(obj: Any) -> tuple[Any, ...]: ... @overload def astuple(obj: Any, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ... @@ -172,7 +172,7 @@ else: metadata: Mapping[Any, Any] | None = ..., ) -> Any: ... -def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... +def fields(class_or_instance: Any) -> tuple[Field[Any], ...]: ... def is_dataclass(obj: Any) -> bool: ... class FrozenInstanceError(AttributeError): ... @@ -191,7 +191,7 @@ if sys.version_info >= (3, 10): cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., @@ -209,7 +209,7 @@ else: cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index e0ce085c2967..6400fb0e6fd6 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -1,6 +1,6 @@ import sys from time import struct_time -from typing import ClassVar, NamedTuple, NoReturn, SupportsAbs, Type, TypeVar, overload +from typing import ClassVar, NamedTuple, NoReturn, SupportsAbs, TypeVar, overload from typing_extensions import final _S = TypeVar("_S") @@ -36,19 +36,19 @@ class date: min: ClassVar[date] max: ClassVar[date] resolution: ClassVar[timedelta] - def __new__(cls: Type[_S], year: int, month: int, day: int) -> _S: ... + def __new__(cls: type[_S], year: int, month: int, day: int) -> _S: ... @classmethod - def fromtimestamp(cls: Type[_S], __timestamp: float) -> _S: ... + def fromtimestamp(cls: type[_S], __timestamp: float) -> _S: ... @classmethod - def today(cls: Type[_S]) -> _S: ... + def today(cls: type[_S]) -> _S: ... @classmethod - def fromordinal(cls: Type[_S], __n: int) -> _S: ... + def fromordinal(cls: type[_S], __n: int) -> _S: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ... + def fromisoformat(cls: type[_S], __date_string: str) -> _S: ... if sys.version_info >= (3, 8): @classmethod - def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ... + def fromisocalendar(cls: type[_S], year: int, week: int, day: int) -> _S: ... @property def year(self) -> int: ... @property @@ -98,7 +98,7 @@ class time: max: ClassVar[time] resolution: ClassVar[timedelta] def __new__( - cls: Type[_S], + cls: type[_S], hour: int = ..., minute: int = ..., second: int = ..., @@ -127,7 +127,7 @@ class time: def isoformat(self, timespec: str = ...) -> str: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls: Type[_S], __time_string: str) -> _S: ... + def fromisoformat(cls: type[_S], __time_string: str) -> _S: ... def strftime(self, __format: str) -> str: ... def __format__(self, __fmt: str) -> str: ... def utcoffset(self) -> timedelta | None: ... @@ -152,7 +152,7 @@ class timedelta(SupportsAbs[timedelta]): max: ClassVar[timedelta] resolution: ClassVar[timedelta] def __new__( - cls: Type[_S], + cls: type[_S], days: float = ..., seconds: float = ..., microseconds: float = ..., @@ -199,7 +199,7 @@ class datetime(date): max: ClassVar[datetime] resolution: ClassVar[timedelta] def __new__( - cls: Type[_S], + cls: type[_S], year: int, month: int, day: int, @@ -227,26 +227,26 @@ class datetime(date): # but it is named "timestamp" in the C implementation and "t" in the Python implementation, # so it is only truly *safe* to pass it as a positional argument. @classmethod - def fromtimestamp(cls: Type[_S], __timestamp: float, tz: _tzinfo | None = ...) -> _S: ... + def fromtimestamp(cls: type[_S], __timestamp: float, tz: _tzinfo | None = ...) -> _S: ... @classmethod - def utcfromtimestamp(cls: Type[_S], __t: float) -> _S: ... + def utcfromtimestamp(cls: type[_S], __t: float) -> _S: ... if sys.version_info >= (3, 8): @classmethod - def now(cls: Type[_S], tz: _tzinfo | None = ...) -> _S: ... + def now(cls: type[_S], tz: _tzinfo | None = ...) -> _S: ... else: @overload @classmethod - def now(cls: Type[_S], tz: None = ...) -> _S: ... + def now(cls: type[_S], tz: None = ...) -> _S: ... @overload @classmethod def now(cls, tz: _tzinfo) -> datetime: ... @classmethod - def utcnow(cls: Type[_S]) -> _S: ... + def utcnow(cls: type[_S]) -> _S: ... @classmethod def combine(cls, date: _date, time: _time, tzinfo: _tzinfo | None = ...) -> datetime: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ... + def fromisoformat(cls: type[_S], __date_string: str) -> _S: ... def timestamp(self) -> float: ... def utctimetuple(self) -> struct_time: ... def date(self) -> _date: ... diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 5ecacd91b4ed..7947e6e20016 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Iterator, MutableMapping, Type, Union +from typing import Iterator, MutableMapping, Union from typing_extensions import Literal _KeyType = Union[str, bytes] @@ -82,12 +82,12 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _error(Exception): ... -error: tuple[Type[_error], Type[OSError]] +error: tuple[type[_error], type[OSError]] def whichdb(filename: str) -> str: ... def open(file: str, flag: _TFlags = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index 0a941b070754..e040f23ce2b0 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Iterator, MutableMapping, Type, Union +from typing import Iterator, MutableMapping, Union _KeyType = Union[str, bytes] _ValueType = Union[str, bytes] @@ -20,7 +20,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index 702f62d11b75..ef4706b97f74 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Type, TypeVar, Union, overload +from typing import TypeVar, Union, overload _T = TypeVar("_T") _KeyType = Union[str, bytes] @@ -24,7 +24,7 @@ class _gdbm: def __len__(self) -> int: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload def get(self, k: _KeyType) -> bytes | None: ... diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index 7b04c5385dbe..c49ad82c53d4 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Type, TypeVar, Union, overload +from typing import TypeVar, Union, overload _T = TypeVar("_T") _KeyType = Union[str, bytes] @@ -20,7 +20,7 @@ class _dbm: def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload def get(self, k: _KeyType) -> bytes | None: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 959af69675c9..6b66c36f8b76 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -1,16 +1,16 @@ import numbers import sys from types import TracebackType -from typing import Any, Container, NamedTuple, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Container, NamedTuple, Sequence, 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 @@ -50,7 +50,7 @@ def getcontext() -> Context: ... def localcontext(ctx: Context | None = ...) -> _ContextManager: ... class Decimal(object): - def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Context | None = ...) -> _DecimalT: ... + def __new__(cls: type[_DecimalT], value: _DecimalNew = ..., context: Context | None = ...) -> _DecimalT: ... @classmethod def from_float(cls, __f: float) -> Decimal: ... def __bool__(self) -> bool: ... @@ -146,7 +146,7 @@ class Decimal(object): def rotate(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def scaleb(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def shift(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __reduce__(self) -> tuple[Type[Decimal], tuple[str]]: ... + def __reduce__(self) -> tuple[type[Decimal], tuple[str]]: ... def __copy__(self) -> Decimal: ... def __deepcopy__(self, __memo: Any) -> Decimal: ... def __format__(self, __specifier: str, __context: Context | None = ...) -> str: ... @@ -156,9 +156,9 @@ class _ContextManager(object): saved_context: Context def __init__(self, new_context: Context) -> None: ... def __enter__(self) -> Context: ... - def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... -_TrapType = Type[DecimalException] +_TrapType = type[DecimalException] class Context(object): prec: int @@ -184,7 +184,7 @@ class Context(object): # __setattr__() only allows to set a specific set of attributes, # already defined above. def __delattr__(self, __name: str) -> None: ... - def __reduce__(self) -> tuple[Type[Context], Tuple[Any, ...]]: ... + def __reduce__(self) -> tuple[type[Context], tuple[Any, ...]]: ... def clear_flags(self) -> None: ... def clear_traps(self) -> None: ... def copy(self) -> Context: ... diff --git a/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index d21de4691503..7c7023ed0b65 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,6 +1,6 @@ -from typing import Any, Callable, Optional, Tuple, Union +from typing import Any, Callable, Optional, Union -_Macro = Union[Tuple[str], Tuple[str, Optional[str]]] +_Macro = Union[tuple[str], tuple[str, Optional[str]]] def gen_lib_options( compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str] @@ -141,7 +141,7 @@ class CCompiler: def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... def object_filenames(self, source_filenames: list[str], strip_dir: int = ..., output_dir: str = ...) -> list[str]: ... def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... + def execute(self, func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... def spawn(self, cmd: list[str]) -> None: ... def mkpath(self, name: str, mode: int = ...) -> None: ... def move_file(self, src: str, dst: str) -> str: ... diff --git a/stdlib/distutils/command/install.pyi b/stdlib/distutils/command/install.pyi index 47fa8b08d1b2..661d256e6f07 100644 --- a/stdlib/distutils/command/install.pyi +++ b/stdlib/distutils/command/install.pyi @@ -1,9 +1,9 @@ -from typing import Any, Tuple +from typing import Any from ..cmd import Command HAS_USER_SITE: bool -SCHEME_KEYS: Tuple[str, ...] +SCHEME_KEYS: tuple[str, ...] INSTALL_SCHEMES: dict[str, dict[Any, Any]] class install(Command): diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index fc4cd81c4752..6564c9a86ded 100644 --- a/stdlib/distutils/core.pyi +++ b/stdlib/distutils/core.pyi @@ -1,7 +1,7 @@ from distutils.cmd import Command as Command from distutils.dist import Distribution as Distribution from distutils.extension import Extension as Extension -from typing import Any, Mapping, Type +from typing import Any, Mapping def setup( *, @@ -20,14 +20,14 @@ def setup( scripts: list[str] = ..., ext_modules: list[Extension] = ..., classifiers: list[str] = ..., - distclass: Type[Distribution] = ..., + distclass: type[Distribution] = ..., script_name: str = ..., script_args: list[str] = ..., options: Mapping[str, Any] = ..., license: str = ..., keywords: list[str] | str = ..., platforms: list[str] | str = ..., - cmdclass: Mapping[str, Type[Command]] = ..., + cmdclass: Mapping[str, type[Command]] = ..., data_files: list[tuple[str, list[str]]] = ..., package_dir: Mapping[str, str] = ..., obsoletes: list[str] = ..., diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 5bb04b049995..c5b3afe7cc3b 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath, SupportsWrite from distutils.cmd import Command -from typing import IO, Any, Iterable, Mapping, Type +from typing import IO, Any, Iterable, Mapping class DistributionMetadata: def __init__(self, path: int | StrOrBytesPath | None = ...) -> None: ... @@ -50,7 +50,7 @@ class DistributionMetadata: def set_obsoletes(self, value: Iterable[str]) -> None: ... class Distribution: - cmdclass: dict[str, Type[Command]] + cmdclass: dict[str, type[Command]] metadata: DistributionMetadata def __init__(self, attrs: Mapping[str, Any] | None = ...) -> None: ... def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index 06a0847e4687..dce8394b6289 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,7 +1,7 @@ -from typing import Any, Iterable, List, Mapping, Optional, Tuple, overload +from typing import Any, Iterable, Mapping, Optional, overload -_Option = Tuple[str, Optional[str], str] -_GR = Tuple[List[str], OptionDummy] +_Option = tuple[str, Optional[str], str] +_GR = tuple[list[str], OptionDummy] def fancy_getopt( options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index 9b0915570ece..03ee0185cac4 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -1,6 +1,6 @@ from _typeshed import StrPath from collections.abc import Callable, Container, Iterable, Mapping -from typing import Any, Tuple +from typing import Any def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... @@ -9,7 +9,7 @@ def check_environ() -> None: ... def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... def split_quoted(s: str) -> list[str]: ... def execute( - func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... + func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... def strtobool(val: str) -> bool: ... def byte_compile( diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 9921dde39af6..1908cdeda97a 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Pattern, Tuple, TypeVar +from typing import Pattern, TypeVar _T = TypeVar("_T", bound=Version) @@ -31,7 +31,7 @@ class StrictVersion(Version): class LooseVersion(Version): component_re: Pattern[str] vstring: str - version: Tuple[str | int, ...] + version: tuple[str | int, ...] def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 9a9f83b0d8fe..31765ae4f80a 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -1,6 +1,6 @@ import types import unittest -from typing import Any, Callable, NamedTuple, Tuple, Type +from typing import Any, Callable, NamedTuple class TestResults(NamedTuple): failed: int @@ -86,7 +86,7 @@ class DocTestFinder: ) -> list[DocTest]: ... _Out = Callable[[str], Any] -_ExcInfo = Tuple[Type[BaseException], BaseException, types.TracebackType] +_ExcInfo = tuple[type[BaseException], BaseException, types.TracebackType] class DocTestRunner: DIVIDER: str diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index a14f5a2d2238..b1389d11e198 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -1,7 +1,7 @@ import sys from email.errors import HeaderParseError, MessageDefect from email.policy import Policy -from typing import Any, Iterable, Iterator, List, Pattern, Type, TypeVar, Union +from typing import Any, Iterable, Iterator, Pattern, TypeVar, Union from typing_extensions import Final _T = TypeVar("_T") @@ -23,7 +23,7 @@ def quote_string(value: Any) -> str: ... if sys.version_info >= (3, 7): rfc2047_matcher: Pattern[str] -class TokenList(List[Union[TokenList, Terminal]]): +class TokenList(list[Union[TokenList, Terminal]]): token_type: str | None syntactic_break: bool ew_combine_allowed: bool @@ -327,7 +327,7 @@ class Terminal(str): syntactic_break: bool token_type: str defects: list[MessageDefect] - def __new__(cls: Type[_T], value: str, token_type: str) -> _T: ... + def __new__(cls: type[_T], value: str, token_type: str) -> _T: ... def pprint(self) -> None: ... @property def all_defects(self) -> list[MessageDefect]: ... diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index 6a3d6ca5b2a7..962571eb7a7a 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 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 @@ -141,10 +141,10 @@ if sys.version_info >= (3, 8): class HeaderRegistry: def __init__( - self, base_class: Type[BaseHeader] = ..., default_class: Type[BaseHeader] = ..., use_default_map: bool = ... + self, base_class: type[BaseHeader] = ..., default_class: type[BaseHeader] = ..., use_default_map: bool = ... ) -> None: ... - def map_to_type(self, name: str, cls: Type[BaseHeader]) -> None: ... - def __getitem__(self, name: str) -> Type[BaseHeader]: ... + def map_to_type(self, name: str, cls: type[BaseHeader]) -> None: ... + def __getitem__(self, name: str) -> type[BaseHeader]: ... def __call__(self, name: str, value: Any) -> BaseHeader: ... class Address: @@ -165,6 +165,6 @@ class Group: @property def display_name(self) -> str | None: ... @property - def addresses(self) -> Tuple[Address, ...]: ... + def addresses(self) -> tuple[Address, ...]: ... def __init__(self, display_name: str | None = ..., addresses: Iterable[Address] | None = ...) -> None: ... def __str__(self) -> str: ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index a1749a4cfc2e..a860f12de9dc 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -2,14 +2,14 @@ from email.charset import Charset from email.contentmanager import ContentManager from email.errors import MessageDefect from email.policy import Policy -from typing import Any, Generator, Iterator, List, Optional, Sequence, Tuple, TypeVar, Union +from typing import Any, Generator, Iterator, Optional, Sequence, TypeVar, Union _T = TypeVar("_T") -_PayloadType = Union[List[Message], str, bytes] +_PayloadType = Union[list[Message], str, bytes] _CharsetType = Union[Charset, str, None] -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] -_ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] +_ParamType = Union[str, tuple[Optional[str], Optional[str], str]] _HeaderType = Any class Message: diff --git a/stdlib/email/mime/application.pyi b/stdlib/email/mime/application.pyi index 11fc470e9dd1..d176cd613e27 100644 --- a/stdlib/email/mime/application.pyi +++ b/stdlib/email/mime/application.pyi @@ -1,8 +1,8 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEApplication(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/audio.pyi b/stdlib/email/mime/audio.pyi index ee6de410bf53..38657c932e2f 100644 --- a/stdlib/email/mime/audio.pyi +++ b/stdlib/email/mime/audio.pyi @@ -1,8 +1,8 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEAudio(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/base.pyi b/stdlib/email/mime/base.pyi index b88dfd492554..cb655607b032 100644 --- a/stdlib/email/mime/base.pyi +++ b/stdlib/email/mime/base.pyi @@ -1,8 +1,8 @@ import email.message from email.policy import Policy -from typing import Optional, Tuple, Union +from typing import Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEBase(email.message.Message): def __init__(self, _maintype: str, _subtype: str, *, policy: Policy | None = ..., **_params: _ParamsType) -> None: ... diff --git a/stdlib/email/mime/image.pyi b/stdlib/email/mime/image.pyi index 886aa74d5fe5..0325d9e594da 100644 --- a/stdlib/email/mime/image.pyi +++ b/stdlib/email/mime/image.pyi @@ -1,8 +1,8 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Optional, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEImage(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/multipart.pyi b/stdlib/email/mime/multipart.pyi index 6259ddf5ab8f..6c316c055329 100644 --- a/stdlib/email/mime/multipart.pyi +++ b/stdlib/email/mime/multipart.pyi @@ -1,9 +1,9 @@ from email.message import Message from email.mime.base import MIMEBase from email.policy import Policy -from typing import Optional, Sequence, Tuple, Union +from typing import Optional, Sequence, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, Optional[str], str]] class MIMEMultipart(MIMEBase): def __init__( diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index 3c07e98079fc..728a5a53f230 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -1,10 +1,10 @@ import datetime import sys from email.charset import Charset -from typing import Optional, Tuple, Union, overload +from typing import Optional, Union, overload -_ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] -_PDTZ = Tuple[int, int, int, int, int, int, int, int, int, Optional[int]] +_ParamType = Union[str, tuple[Optional[str], Optional[str], str]] +_PDTZ = tuple[int, int, int, int, int, int, int, int, int, Optional[int]] def quote(str: str) -> str: ... def unquote(str: str) -> str: ... diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index e8846ba5293e..49f7bda4ee8e 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -3,10 +3,10 @@ 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, TypeVar, Union, overload _T = TypeVar("_T") -_S = TypeVar("_S", bound=Type[Enum]) +_S = TypeVar("_S", bound=type[Enum]) # The following all work: # >>> from enum import 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. @@ -32,9 +32,9 @@ class _EnumDict(Dict[str, Any]): class EnumMeta(ABCMeta): if sys.version_info >= (3, 11): def __new__( - metacls: Type[_T], + metacls: type[_T], cls: str, - bases: Tuple[type, ...], + bases: tuple[type, ...], classdict: _EnumDict, *, boundary: FlagBoundary | None = ..., @@ -42,20 +42,20 @@ 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 __iter__(self: Type[_T]) -> Iterator[_T]: ... - def __reversed__(self: Type[_T]) -> Iterator[_T]: ... - def __contains__(self: Type[Any], member: object) -> bool: ... - def __getitem__(self: Type[_T], name: str) -> _T: ... + 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: ... + def __getitem__(self: type[_T], name: str) -> _T: ... @_builtins_property - def __members__(self: Type[_T]) -> types.MappingProxyType[str, _T]: ... + def __members__(self: type[_T]) -> types.MappingProxyType[str, _T]: ... def __len__(self) -> int: ... if sys.version_info >= (3, 11): # Simple value lookup @overload # type: ignore[override] - def __call__(cls: Type[_T], value: Any, names: None = ...) -> _T: ... + def __call__(cls: type[_T], value: Any, names: None = ...) -> _T: ... # Functional Enum API @overload def __call__( @@ -68,10 +68,10 @@ class EnumMeta(ABCMeta): type: type | None = ..., start: int = ..., boundary: FlagBoundary | None = ..., - ) -> Type[Enum]: ... + ) -> type[Enum]: ... else: @overload # type: ignore[override] - def __call__(cls: Type[_T], value: Any, names: None = ...) -> _T: ... + def __call__(cls: type[_T], value: Any, names: None = ...) -> _T: ... @overload def __call__( cls, @@ -82,7 +82,7 @@ class EnumMeta(ABCMeta): qualname: str | None = ..., type: type | None = ..., start: int = ..., - ) -> Type[Enum]: ... + ) -> type[Enum]: ... _member_names_: list[str] # undocumented _member_map_: dict[str, Enum] # undocumented _value2member_map_: dict[Any, Enum] # undocumented @@ -112,7 +112,7 @@ class Enum(metaclass=EnumMeta): def _missing_(cls, value: object) -> Any: ... @staticmethod def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any: ... - def __new__(cls: Type[_T], value: object) -> _T: ... + def __new__(cls: type[_T], value: object) -> _T: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... def __dir__(self) -> list[str]: ... @@ -128,7 +128,7 @@ class IntEnum(int, Enum): else: @types.DynamicClassAttribute def value(self) -> int: ... - def __new__(cls: Type[_T], value: int | _T) -> _T: ... + def __new__(cls: type[_T], value: int | _T) -> _T: ... def unique(enumeration: _S) -> _S: ... @@ -143,7 +143,7 @@ class auto(IntFlag): else: @types.DynamicClassAttribute def value(self) -> Any: ... - def __new__(cls: Type[_T]) -> _T: ... + def __new__(cls: type[_T]) -> _T: ... class Flag(Enum): _name_: str | None # type: ignore[assignment] @@ -168,7 +168,7 @@ class Flag(Enum): def __invert__(self: _T) -> _T: ... class IntFlag(int, Flag): - def __new__(cls: Type[_T], value: int | _T) -> _T: ... + def __new__(cls: type[_T], value: int | _T) -> _T: ... def __or__(self: _T, other: int | _T) -> _T: ... def __and__(self: _T, other: int | _T) -> _T: ... def __xor__(self: _T, other: int | _T) -> _T: ... @@ -178,7 +178,7 @@ class IntFlag(int, Flag): if sys.version_info >= (3, 11): class StrEnum(str, Enum): - def __new__(cls: Type[_T], value: str | _T) -> _T: ... + def __new__(cls: type[_T], value: str | _T) -> _T: ... _value_: str @property def value(self) -> str: ... @@ -192,7 +192,7 @@ if sys.version_info >= (3, 11): EJECT = FlagBoundary.EJECT KEEP = FlagBoundary.KEEP class property(types.DynamicClassAttribute): - def __set_name__(self, ownerclass: Type[Enum], name: str) -> None: ... + def __set_name__(self, ownerclass: type[Enum], name: str) -> None: ... name: str clsname: str def global_enum(cls: _S) -> _S: ... diff --git a/stdlib/formatter.pyi b/stdlib/formatter.pyi index 7c3b97688dbd..f5d8348d08a1 100644 --- a/stdlib/formatter.pyi +++ b/stdlib/formatter.pyi @@ -1,8 +1,8 @@ -from typing import IO, Any, Iterable, Tuple +from typing import IO, Any, Iterable AS_IS: None -_FontType = Tuple[str, bool, bool, bool] -_StylesType = Tuple[Any, ...] +_FontType = tuple[str, bool, bool, bool] +_StylesType = tuple[Any, ...] class NullFormatter: writer: NullWriter | None @@ -68,7 +68,7 @@ class NullWriter: def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... def new_spacing(self, spacing: str | None) -> None: ... - def new_styles(self, styles: Tuple[Any, ...]) -> None: ... + def new_styles(self, styles: tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... @@ -81,7 +81,7 @@ class AbstractWriter(NullWriter): def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... def new_spacing(self, spacing: str | None) -> None: ... - def new_styles(self, styles: Tuple[Any, ...]) -> None: ... + def new_styles(self, styles: tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index 8de5ae20971c..9536e511ef3c 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -1,7 +1,7 @@ import sys from decimal import Decimal from numbers import Integral, Rational, Real -from typing import Type, TypeVar, Union, overload +from typing import TypeVar, Union, overload from typing_extensions import Literal _ComparableNum = Union[int, float, Decimal, Real] @@ -20,10 +20,10 @@ if sys.version_info < (3, 9): class Fraction(Rational): @overload def __new__( - cls: Type[_T], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ... + cls: type[_T], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ... ) -> _T: ... @overload - def __new__(cls: Type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ... + def __new__(cls: type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ... @classmethod def from_float(cls, f: float) -> Fraction: ... @classmethod diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index 745669ce0f18..62adf300e7b3 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -3,7 +3,7 @@ from _typeshed import Self, SupportsRead, SupportsReadline from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Callable, Iterable, Iterator, TextIO, Tuple, Type +from typing import Any, Callable, Iterable, Iterator, TextIO from typing_extensions import Literal MSG_OOB: int @@ -18,7 +18,7 @@ class error_temp(Error): ... class error_perm(Error): ... class error_proto(Error): ... -all_errors: Tuple[Type[Exception], ...] +all_errors: tuple[type[Exception], ...] class FTP: debugging: int @@ -35,7 +35,7 @@ class FTP: encoding: str def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... source_address: tuple[str, int] | None if sys.version_info >= (3, 9): diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 78ed5992a468..23cdaee7a004 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -1,7 +1,7 @@ import sys import types from _typeshed import SupportsAllComparisons, SupportsItems -from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, Tuple, Type, TypeVar, overload +from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, TypeVar, overload from typing_extensions import final if sys.version_info >= (3, 9): @@ -44,12 +44,12 @@ WRAPPER_UPDATES: Sequence[str] def update_wrapper(wrapper: _T, wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> _T: ... def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]: ... -def total_ordering(cls: Type[_T]) -> Type[_T]: ... +def total_ordering(cls: type[_T]) -> type[_T]: ... def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], SupportsAllComparisons]: ... 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,13 +61,13 @@ _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: ... @overload def __init__(self, __func: _Descriptor, *args: Any, **keywords: Any) -> None: ... - def __get__(self, obj: Any, cls: Type[Any]) -> Callable[..., _T]: ... + def __get__(self, obj: Any, cls: type[Any]) -> Callable[..., _T]: ... @property def __isabstractmethod__(self) -> bool: ... if sys.version_info >= (3, 9): @@ -79,14 +79,14 @@ class _SingleDispatchCallable(Generic[_T]): # @fun.register(complex) # def _(arg, verbose=False): ... @overload - def register(self, cls: Type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... + def register(self, cls: type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... # @fun.register # def _(arg: int, verbose=False): @overload def register(self, cls: Callable[..., _T], func: None = ...) -> Callable[..., _T]: ... # fun.register(int, lambda x: x) @overload - def register(self, cls: Type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ... + def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ... def _clear_cache(self) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> _T: ... @@ -98,21 +98,21 @@ if sys.version_info >= (3, 8): func: Callable[..., _T] def __init__(self, func: Callable[..., _T]) -> None: ... @overload - def register(self, cls: Type[Any], method: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... + def register(self, cls: type[Any], method: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... @overload def register(self, cls: Callable[..., _T], method: None = ...) -> Callable[..., _T]: ... @overload - def register(self, cls: Type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ... + def register(self, cls: type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ... def __call__(self, *args: Any, **kwargs: Any) -> _T: ... class cached_property(Generic[_T]): func: Callable[[Any], _T] attrname: str | None def __init__(self, func: Callable[[Any], _T]) -> None: ... @overload - def __get__(self, instance: None, owner: Type[Any] | None = ...) -> cached_property[_T]: ... + def __get__(self, instance: None, owner: type[Any] | None = ...) -> cached_property[_T]: ... @overload - def __get__(self, instance: object, owner: Type[Any] | None = ...) -> _T: ... - def __set_name__(self, owner: Type[Any], name: str) -> None: ... + def __get__(self, instance: object, owner: type[Any] | None = ...) -> _T: ... + def __set_name__(self, owner: type[Any], name: str) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -120,10 +120,10 @@ if sys.version_info >= (3, 9): def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ... def _make_key( - args: Tuple[Hashable, ...], + args: tuple[Hashable, ...], kwds: SupportsItems[Any, Any], typed: bool, - kwd_mark: Tuple[object, ...] = ..., + kwd_mark: tuple[object, ...] = ..., fasttypes: set[type] = ..., tuple: type = ..., type: Any = ..., diff --git a/stdlib/genericpath.pyi b/stdlib/genericpath.pyi index c9829ae350f1..f9518750d3f1 100644 --- a/stdlib/genericpath.pyi +++ b/stdlib/genericpath.pyi @@ -1,6 +1,6 @@ import os from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRichComparisonT -from typing import Sequence, Tuple, overload +from typing import Sequence, overload from typing_extensions import Literal # All overloads can return empty string. Ideally, Literal[""] would be a valid @@ -13,7 +13,7 @@ def commonprefix(m: Sequence[BytesPath]) -> bytes | Literal[""]: ... @overload def commonprefix(m: Sequence[list[SupportsRichComparisonT]]) -> Sequence[SupportsRichComparisonT]: ... @overload -def commonprefix(m: Sequence[Tuple[SupportsRichComparisonT, ...]]) -> Sequence[SupportsRichComparisonT]: ... +def commonprefix(m: Sequence[tuple[SupportsRichComparisonT, ...]]) -> Sequence[SupportsRichComparisonT]: ... def exists(path: StrOrBytesPath | int) -> bool: ... def getsize(filename: StrOrBytesPath | int) -> int: ... def isfile(path: StrOrBytesPath | int) -> bool: ... diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index 21be9fb1ff29..27a5e442d1b0 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import IO, Any, Container, Iterable, Sequence, Type, TypeVar, overload +from typing import IO, Any, Container, Iterable, Sequence, TypeVar, overload from typing_extensions import Literal class NullTranslations: @@ -45,7 +45,7 @@ if sys.version_info >= (3, 11): domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., - class_: Type[_T] = ..., + class_: type[_T] = ..., fallback: Literal[False] = ..., ) -> _T: ... @overload @@ -53,7 +53,7 @@ if sys.version_info >= (3, 11): domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., - class_: Type[Any] = ..., + class_: type[Any] = ..., fallback: Literal[True] = ..., ) -> Any: ... def install(domain: str, localedir: StrPath | None = ..., names: Container[str] | None = ...) -> None: ... @@ -73,7 +73,7 @@ else: domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., - class_: Type[_T] = ..., + class_: type[_T] = ..., fallback: Literal[False] = ..., codeset: str | None = ..., ) -> _T: ... @@ -82,7 +82,7 @@ else: domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., - class_: Type[Any] = ..., + class_: type[Any] = ..., fallback: Literal[True] = ..., codeset: str | None = ..., ) -> Any: ... diff --git a/stdlib/graphlib.pyi b/stdlib/graphlib.pyi index 0872af4a54a4..96d64cbce18c 100644 --- a/stdlib/graphlib.pyi +++ b/stdlib/graphlib.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsItems -from typing import Generic, Iterable, Tuple, TypeVar +from typing import Generic, Iterable, TypeVar _T = TypeVar("_T") @@ -10,7 +10,7 @@ class TopologicalSorter(Generic[_T]): def is_active(self) -> bool: ... def __bool__(self) -> bool: ... def done(self, *nodes: _T) -> None: ... - def get_ready(self) -> Tuple[_T, ...]: ... + def get_ready(self) -> tuple[_T, ...]: ... def static_order(self) -> Iterable[_T]: ... class CycleError(ValueError): ... diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 33f2a9774be8..52be219f354f 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -1,9 +1,9 @@ from _typeshed import structseq -from typing import Any, List, Optional, Tuple +from typing import Any, Optional from typing_extensions import final @final -class struct_group(structseq[Any], Tuple[str, Optional[str], int, List[str]]): +class struct_group(structseq[Any], tuple[str, Optional[str], int, list[str]]): @property def gr_name(self) -> str: ... @property diff --git a/stdlib/html/parser.pyi b/stdlib/html/parser.pyi index 66515cad03ba..60e0de51d3b8 100644 --- a/stdlib/html/parser.pyi +++ b/stdlib/html/parser.pyi @@ -1,5 +1,5 @@ from _markupbase import ParserBase -from typing import Pattern, Tuple +from typing import Pattern class HTMLParser(ParserBase): def __init__(self, *, convert_charrefs: bool = ...) -> None: ... @@ -18,7 +18,7 @@ class HTMLParser(ParserBase): def handle_decl(self, decl: str) -> None: ... def handle_pi(self, data: str) -> None: ... def unknown_decl(self, data: str) -> None: ... - CDATA_CONTENT_ELEMENTS: Tuple[str, ...] + CDATA_CONTENT_ELEMENTS: tuple[str, ...] def check_for_whole_start_tag(self, i: int) -> int: ... # undocumented def clear_cdata_mode(self) -> None: ... # undocumented def goahead(self, end: bool) -> None: ... # undocumented diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 1558f6ff46e8..ed7f98dd360d 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -5,7 +5,7 @@ import sys import types from _typeshed import Self, WriteableBuffer from socket import socket -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, Type, TypeVar, Union, overload +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, TypeVar, Union, overload _DataType = Union[bytes, IO[Any], Iterable[bytes], str] _T = TypeVar("_T") @@ -107,7 +107,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): def __iter__(self) -> Iterator[bytes]: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> bool | None: ... def info(self) -> email.message.Message: ... def geturl(self) -> str: ... @@ -135,7 +135,7 @@ class HTTPConnection: auto_open: int # undocumented debuglevel: int default_port: int # undocumented - response_class: Type[HTTPResponse] # undocumented + response_class: type[HTTPResponse] # undocumented timeout: float | None host: str port: int diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index f37fb19cebe9..6bfa7f385e69 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrPath from http.client import HTTPResponse -from typing import ClassVar, Iterable, Iterator, Pattern, Sequence, Tuple, TypeVar, overload +from typing import ClassVar, Iterable, Iterator, Pattern, Sequence, TypeVar, overload from urllib.request import Request _T = TypeVar("_T") @@ -102,10 +102,10 @@ class DefaultCookiePolicy(CookiePolicy): strict_ns_set_initial_dollar: bool = ..., strict_ns_set_path: bool = ..., ) -> None: ... - def blocked_domains(self) -> Tuple[str, ...]: ... + def blocked_domains(self) -> tuple[str, ...]: ... def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ... def is_blocked(self, domain: str) -> bool: ... - def allowed_domains(self) -> Tuple[str, ...] | None: ... + def allowed_domains(self) -> tuple[str, ...] | None: ... def set_allowed_domains(self, allowed_domains: Sequence[str] | None) -> None: ... def is_not_allowed(self, domain: str) -> bool: ... def set_ok_version(self, cookie: Cookie, request: Request) -> bool: ... # undocumented diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 4244c0c6aa0d..211fd37662d4 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, Generic, Iterable, Mapping, TypeVar, Union, overload +from typing import Any, Generic, Iterable, Mapping, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -18,7 +18,7 @@ def _unquote(str: str) -> str: ... class CookieError(Exception): ... -class Morsel(Dict[str, Any], Generic[_T]): +class Morsel(dict[str, Any], Generic[_T]): value: str coded_value: _T key: str @@ -40,7 +40,7 @@ class Morsel(Dict[str, Any], Generic[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]): +class BaseCookie(dict[str, Morsel[_T]], Generic[_T]): def __init__(self, input: _DataType | None = ...) -> None: ... def value_decode(self, val: str) -> _T: ... def value_encode(self, val: _T) -> str: ... diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index a9f19048c9ae..33b99239ea85 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -5,21 +5,21 @@ from _typeshed import Self from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Callable, List, Pattern, Tuple, Type, Union +from typing import IO, Any, Callable, Pattern, 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" class IMAP4: - error: Type[Exception] - abort: Type[Exception] - readonly: Type[Exception] + error: type[Exception] + abort: type[Exception] + readonly: type[Exception] mustquote: Pattern[str] debug: int state: str @@ -63,7 +63,7 @@ class IMAP4: def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... def enable(self, capability: str) -> _CommandResults: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... def expunge(self) -> _CommandResults: ... def fetch(self, message_set: str, message_parts: str) -> tuple[str, _AnyResponseData]: ... def getacl(self, mailbox: str) -> _CommandResults: ... diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index c5d9efba9ad6..a9e223149b52 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -7,7 +7,7 @@ from email.message import Message from importlib.abc import MetaPathFinder from os import PathLike from pathlib import Path -from typing import Any, ClassVar, Iterable, NamedTuple, Pattern, Tuple, overload +from typing import Any, ClassVar, Iterable, NamedTuple, Pattern, overload if sys.version_info >= (3, 10): from importlib.metadata._meta import PackageMetadata as PackageMetadata @@ -101,6 +101,6 @@ if sys.version_info >= (3, 8): ) -> Iterable[Distribution]: ... def metadata(distribution_name: str) -> Message: ... def version(distribution_name: str) -> str: ... - def entry_points() -> dict[str, Tuple[EntryPoint, ...]]: ... + def entry_points() -> dict[str, tuple[EntryPoint, ...]]: ... def files(distribution_name: str) -> list[PackagePath] | None: ... def requires(distribution_name: str) -> list[str] | None: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 35c9149c01f0..bb99545af767 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, TypeVar, Union from typing_extensions import Literal, TypeGuard # @@ -58,7 +58,7 @@ modulesbyfile: dict[str, Any] def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> list[tuple[str, Any]]: ... def getmodulename(path: str) -> str | None: ... def ismodule(object: object) -> TypeGuard[ModuleType]: ... -def isclass(object: object) -> TypeGuard[Type[Any]]: ... +def isclass(object: object) -> TypeGuard[type[Any]]: ... def ismethod(object: object) -> TypeGuard[MethodType]: ... def isfunction(object: object) -> TypeGuard[FunctionType]: ... @@ -125,7 +125,7 @@ def isdatadescriptor(object: object) -> TypeGuard[_SupportsSet[Any, Any] | _Supp # # Retrieving source code # -_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] +_SourceObjectType = Union[ModuleType, type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] def findsource(object: _SourceObjectType) -> tuple[list[str], int]: ... def getabsfile(object: _SourceObjectType, _filename: str | None = ...) -> str: ... @@ -172,7 +172,7 @@ class Signature: def bind(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def replace( - self: Self, *, parameters: Sequence[Parameter] | Type[_void] | None = ..., return_annotation: Any = ... + self: Self, *, parameters: Sequence[Parameter] | type[_void] | None = ..., return_annotation: Any = ... ) -> Self: ... if sys.version_info >= (3, 10): @classmethod @@ -191,7 +191,7 @@ class Signature: if sys.version_info >= (3, 10): def get_annotations( - obj: Callable[..., Any] | Type[Any] | ModuleType, + obj: Callable[..., Any] | type[Any] | ModuleType, *, globals: Mapping[str, Any] | None = ..., locals: Mapping[str, Any] | None = ..., @@ -226,15 +226,15 @@ class Parameter: def replace( self: Self, *, - name: str | Type[_void] = ..., - kind: _ParameterKind | Type[_void] = ..., + name: str | type[_void] = ..., + kind: _ParameterKind | type[_void] = ..., default: Any = ..., annotation: Any = ..., ) -> Self: ... 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: ... @@ -248,7 +248,7 @@ class BoundArguments: # seem to be supporting this at the moment: # _ClassTreeItem = list[_ClassTreeItem] | Tuple[type, Tuple[type, ...]] def getclasstree(classes: list[type], unique: bool = ...) -> list[Any]: ... -def walktree(classes: list[type], children: dict[Type[Any], list[type]], parent: Type[Any] | None) -> list[Any]: ... +def walktree(classes: list[type], children: dict[type[Any], list[type]], parent: type[Any] | None) -> list[Any]: ... class Arguments(NamedTuple): args: list[str] @@ -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..e82111585991 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -4,7 +4,7 @@ import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer from os import _Opener from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, TextIO, Tuple, Type +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, TextIO DEFAULT_BUFFER_SIZE: int @@ -26,7 +26,7 @@ class IOBase: def __next__(self) -> bytes: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def close(self) -> None: ... def fileno(self) -> int: ... @@ -119,7 +119,7 @@ class BufferedRWPair(BufferedIOBase): class TextIOBase(IOBase): encoding: str errors: str | None - newlines: str | Tuple[str, ...] | None + newlines: str | tuple[str, ...] | None def __iter__(self) -> Iterator[str]: ... # type: ignore[override] def __next__(self) -> str: ... # type: ignore[override] def detach(self) -> BinaryIO: ... @@ -179,4 +179,4 @@ class IncrementalNewlineDecoder(codecs.IncrementalDecoder): def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ... def decode(self, input: bytes | str, final: bool = ...) -> str: ... @property - def newlines(self) -> str | Tuple[str, ...] | None: ... + def newlines(self) -> str | tuple[str, ...] | None: ... diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 1ff7ffc181ed..7b801a411de9 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -9,8 +9,8 @@ from typing import ( SupportsComplex, SupportsFloat, SupportsInt, - Tuple, - Type, + + TypeVar, Union, overload, @@ -69,7 +69,7 @@ class chain(Iterator[_T], Generic[_T]): def __iter__(self) -> Iterator[_T]: ... @classmethod # We use Type and not Type[_S] to not lose the type inference from __iterable - def from_iterable(cls: Type[Any], __iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ... + def from_iterable(cls: type[Any], __iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... @@ -91,7 +91,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 +117,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 +170,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 +193,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..b9867b55f950 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsRead -from typing import IO, Any, Callable, Type +from typing import IO, Any, Callable from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder from .encoder import JSONEncoder as JSONEncoder @@ -11,7 +11,7 @@ def dumps( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Type[JSONEncoder] | None = ..., + cls: type[JSONEncoder] | None = ..., indent: None | int | str = ..., separators: tuple[str, str] | None = ..., default: Callable[[Any], Any] | None = ..., @@ -26,7 +26,7 @@ def dump( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Type[JSONEncoder] | None = ..., + cls: type[JSONEncoder] | None = ..., indent: None | int | str = ..., separators: tuple[str, str] | None = ..., default: Callable[[Any], Any] | None = ..., @@ -36,7 +36,7 @@ def dump( def loads( s: str | bytes, *, - cls: Type[JSONDecoder] | None = ..., + cls: type[JSONDecoder] | None = ..., object_hook: Callable[[dict[Any, Any]], Any] | None = ..., parse_float: Callable[[str], Any] | None = ..., parse_int: Callable[[str], Any] | None = ..., @@ -47,7 +47,7 @@ def loads( def load( fp: SupportsRead[str | bytes], *, - cls: Type[JSONDecoder] | None = ..., + cls: type[JSONDecoder] | None = ..., object_hook: Callable[[dict[Any, Any]], Any] | None = ..., parse_float: Callable[[str], Any] | None = ..., parse_int: Callable[[str], Any] | None = ..., diff --git a/stdlib/lib2to3/pgen2/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index 48cb4eae916c..77cc6aec3d67 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -1,10 +1,10 @@ from _typeshed import StrPath -from typing import Dict, List, Optional, Tuple, TypeVar +from typing import Optional, TypeVar _P = TypeVar("_P") -_Label = Tuple[int, Optional[str]] -_DFA = List[List[Tuple[int, int]]] -_DFAS = Tuple[_DFA, Dict[int, int]] +_Label = tuple[int, Optional[str]] +_DFA = list[list[tuple[int, int]]] +_DFAS = tuple[_DFA, dict[int, int]] class Grammar: symbol2number: dict[str, int] diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index e96a0d8c8eb3..3679caee9314 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,9 +1,9 @@ from lib2to3.pgen2.token import * # noqa -from typing import Callable, Iterable, Iterator, Tuple +from typing import Callable, Iterable, Iterator -_Coord = Tuple[int, int] +_Coord = tuple[int, int] _TokenEater = Callable[[int, str, _Coord, _Coord, str], None] -_TokenInfo = Tuple[int, str, _Coord, _Coord, str] +_TokenInfo = tuple[int, str, _Coord, _Coord, str] class TokenError(Exception): ... class StopTokenizing(Exception): ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index eab82cbc200d..2ed9a2788d84 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,11 +1,11 @@ from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Iterator, Optional, TypeVar, Union _P = TypeVar("_P") _NL = Union[Node, Leaf] -_Context = Tuple[str, int, int] -_Results = Dict[str, _NL] -_RawNode = Tuple[int, str, _Context, Optional[List[_NL]]] +_Context = tuple[str, int, int] +_Results = dict[str, _NL] +_RawNode = tuple[int, str, _Context, Optional[list[_NL]]] _Convert = Callable[[Grammar, _RawNode], Any] HUGE: int diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index a66614bf6b37..e53d3efea5b2 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,7 +1,7 @@ -from typing import Any, Dict, List, Protocol, Tuple +from typing import Any, Protocol -_ModuleGlobals = Dict[str, Any] -_ModuleMetadata = Tuple[int, float, List[str], str] +_ModuleGlobals = dict[str, Any] +_ModuleMetadata = tuple[int, float, list[str], str] class _SourceLoader(Protocol): def __call__(self) -> str | None: ... diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index c6289f27da2c..f3942102716a 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -4,7 +4,7 @@ import sys # as a type annotation or type alias. from builtins import str as _str from decimal import Decimal -from typing import Any, Callable, Iterable, Mapping, Sequence, Tuple +from typing import Any, Callable, Iterable, Mapping, Sequence CODESET: int D_T_FMT: int @@ -82,7 +82,7 @@ class Error(Exception): ... def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... def localeconv() -> Mapping[_str, int | _str | list[int]]: ... def nl_langinfo(__key: int) -> _str: ... -def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> tuple[_str | None, _str | None]: ... +def getdefaultlocale(envvars: tuple[_str, ...] = ...) -> tuple[_str | None, _str | None]: ... def getlocale(category: int = ...) -> Sequence[_str]: ... def getpreferredencoding(do_setlocale: bool = ...) -> _str: ... def normalize(localename: _str) -> _str: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 7d4fa279155c..f9ab7f6f4d9e 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, 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["%", "{", "$"] @@ -39,11 +39,11 @@ class Manager(object): # undocumented disable: int emittedNoHandlerWarning: bool loggerDict: dict[str, Logger | PlaceHolder] - loggerClass: Type[Logger] | None + loggerClass: type[Logger] | None logRecordFactory: Callable[..., LogRecord] | None def __init__(self, rootnode: RootLogger) -> None: ... def getLogger(self, name: str) -> Logger: ... - def setLoggerClass(self, klass: Type[Logger]) -> None: ... + def setLoggerClass(self, klass: type[Logger]) -> None: ... def setLogRecordFactory(self, factory: Callable[..., LogRecord]) -> None: ... class Logger(Filterer): @@ -546,7 +546,7 @@ class LoggerAdapter(Generic[_L]): def name(self) -> str: ... # undocumented def getLogger(name: str | None = ...) -> Logger: ... -def getLoggerClass() -> Type[Logger]: ... +def getLoggerClass() -> type[Logger]: ... def getLogRecordFactory() -> Callable[..., LogRecord]: ... if sys.version_info >= (3, 8): @@ -703,7 +703,7 @@ else: ) -> None: ... def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented -def setLoggerClass(klass: Type[Logger]) -> None: ... +def setLoggerClass(klass: type[Logger]) -> None: ... def captureWarnings(capture: bool) -> None: ... def setLogRecordFactory(factory: Callable[..., LogRecord]) -> None: ... diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index ffd9c3005cec..ecfe76cf605b 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -13,7 +13,7 @@ from typing import ( Mapping, Protocol, Sequence, - Type, + TypeVar, Union, overload, @@ -184,7 +184,7 @@ class _ProxyFile(Generic[AnyStr]): def seek(self, offset: int, whence: int = ...) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... def seekable(self) -> bool: ... diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index 9eaa771ed3d3..56218d1370fe 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -1,6 +1,6 @@ -from typing import Dict, Mapping, Sequence, Union +from typing import Mapping, Sequence, Union -_Cap = Dict[str, Union[str, int]] +_Cap = dict[str, Union[str, int]] def findmatch( caps: Mapping[str, list[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index 90c87d2cf385..eefd5439ee28 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import IO, Sequence, Tuple +from typing import IO, Sequence if sys.version_info >= (3, 8): def guess_type(url: StrPath, strict: bool = ...) -> tuple[str | None, str | None]: ... @@ -26,7 +26,7 @@ class MimeTypes: encodings_map: dict[str, str] types_map: tuple[dict[str, str], dict[str, str]] types_map_inv: tuple[dict[str, str], dict[str, str]] - def __init__(self, filenames: Tuple[str, ...] = ..., strict: bool = ...) -> None: ... + def __init__(self, filenames: tuple[str, ...] = ..., strict: bool = ...) -> None: ... def guess_extension(self, type: str, strict: bool = ...) -> str | None: ... def guess_type(self, url: str, strict: bool = ...) -> tuple[str | None, str | None]: ... def guess_all_extensions(self, type: str, strict: bool = ...) -> list[str]: ... diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index e77a108e9525..3e7694ccffc9 100644 --- a/stdlib/modulefinder.pyi +++ b/stdlib/modulefinder.pyi @@ -1,6 +1,6 @@ import sys from types import CodeType -from typing import IO, Any, Container, Iterable, Iterator, Sequence, Tuple +from typing import IO, Any, Container, Iterable, Iterator, Sequence LOAD_CONST: int # undocumented IMPORT_NAME: int # undocumented @@ -62,7 +62,7 @@ class ModuleFinder: def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented def import_module(self, partname: str, fqname: str, parent: Module) -> Module | None: ... # undocumented def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: tuple[str, str, str]) -> Module: ... # undocumented - def scan_opcodes(self, co: CodeType) -> Iterator[tuple[str, Tuple[Any, ...]]]: ... # undocumented + def scan_opcodes(self, co: CodeType) -> Iterator[tuple[str, tuple[Any, ...]]]: ... # undocumented def scan_code(self, co: CodeType, m: Module) -> None: ... # undocumented def load_package(self, fqname: str, pathname: str) -> Module: ... # undocumented def add_module(self, fqname: str) -> Module: ... # undocumented diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 4e1a7e6a7c02..5933433ac00c 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -1,6 +1,6 @@ import sys from types import ModuleType -from typing import Any, Container, Iterable, Sequence, Tuple, Type +from typing import Any, Container, Iterable, Sequence from typing_extensions import Literal if sys.platform == "win32": @@ -34,10 +34,10 @@ if sys.platform == "win32": def change_sequence( seq: Sequence[tuple[str, str | None, int]], action: str, - seqno: int | Type[_Unspecified] = ..., - cond: str | Type[_Unspecified] = ..., + 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..40630d66ffad 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -2,13 +2,13 @@ import socket import sys import types from _typeshed import Self -from typing import Any, Iterable, Tuple, Type, Union +from typing import Any, Iterable, 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): @@ -31,7 +31,7 @@ class _ConnectionBase: def poll(self, timeout: float | None = ...) -> bool: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... class Connection(_ConnectionBase): ... @@ -51,7 +51,7 @@ class Listener: def last_accepted(self) -> _Address | None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def deliver_challenge(connection: Connection, authkey: bytes) -> None: ... diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index e65a387819bc..be2203f8e38c 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -8,7 +8,7 @@ from multiprocessing import queues, synchronize from multiprocessing.pool import Pool as _Pool from multiprocessing.process import BaseProcess from multiprocessing.sharedctypes import SynchronizedArray, SynchronizedBase -from typing import Any, Type, TypeVar, Union, overload +from typing import Any, TypeVar, Union, overload from typing_extensions import Literal _LockLike = Union[synchronize.Lock, synchronize.RLock] @@ -20,11 +20,11 @@ class TimeoutError(ProcessError): ... class AuthenticationError(ProcessError): ... class BaseContext(object): - Process: Type[BaseProcess] - ProcessError: Type[Exception] - BufferTooShort: Type[Exception] - TimeoutError: Type[Exception] - AuthenticationError: Type[Exception] + Process: type[BaseProcess] + ProcessError: type[Exception] + BufferTooShort: type[Exception] + TimeoutError: type[Exception] + AuthenticationError: type[Exception] # N.B. The methods below are applied at runtime to generate # multiprocessing.*, so the signatures should be identical (modulo self). @@ -60,26 +60,26 @@ class BaseContext(object): maxtasksperchild: int | None = ..., ) -> _Pool: ... @overload - def RawValue(self, typecode_or_type: Type[_CT], *args: Any) -> _CT: ... + def RawValue(self, typecode_or_type: type[_CT], *args: Any) -> _CT: ... @overload def RawValue(self, typecode_or_type: str, *args: Any) -> Any: ... @overload - def RawArray(self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... + def RawArray(self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... @overload def RawArray(self, typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ... @overload - def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Literal[False]) -> _CT: ... + def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[False]) -> _CT: ... @overload - def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[_CT]: ... + def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[_CT]: ... @overload def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[Any]: ... @overload - def Value(self, typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ... + def Value(self, typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ... @overload - def Array(self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]) -> _CT: ... + def Array(self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]) -> _CT: ... @overload def Array( - self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike + self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike ) -> SynchronizedArray[_CT]: ... @overload def Array( @@ -87,7 +87,7 @@ class BaseContext(object): ) -> SynchronizedArray[Any]: ... @overload def Array( - self, typecode_or_type: str | Type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ... + self, typecode_or_type: str | type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ... ) -> Any: ... def freeze_support(self) -> None: ... def get_logger(self) -> Logger: ... @@ -127,7 +127,7 @@ class Process(BaseProcess): def _Popen(process_obj: BaseProcess) -> DefaultContext: ... class DefaultContext(BaseContext): - Process: Type[multiprocessing.Process] + Process: type[multiprocessing.Process] def __init__(self, context: BaseContext) -> None: ... def set_start_method(self, method: str | None, force: bool = ...) -> None: ... def get_start_method(self, allow_none: bool = ...) -> str: ... @@ -150,13 +150,13 @@ if sys.platform != "win32": def _Popen(process_obj: BaseProcess) -> Any: ... class ForkContext(BaseContext): _name: str - Process: Type[ForkProcess] + Process: type[ForkProcess] class SpawnContext(BaseContext): _name: str - Process: Type[SpawnProcess] + Process: type[SpawnProcess] class ForkServerContext(BaseContext): _name: str - Process: Type[ForkServerProcess] + Process: type[ForkServerProcess] else: class SpawnProcess(BaseProcess): @@ -165,7 +165,7 @@ else: def _Popen(process_obj: BaseProcess) -> Any: ... class SpawnContext(BaseContext): _name: str - Process: Type[SpawnProcess] + Process: type[SpawnProcess] def _force_start_method(method: str) -> None: ... def get_spawning_popen() -> Any | None: ... diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index 4ef3d095911f..6e98f4ed6079 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, Union families: list[None] -_Address = Union[str, Tuple[str, int]] +_Address = Union[str, tuple[str, int]] class Connection(object): _in: Any @@ -16,7 +16,7 @@ class Connection(object): send_bytes: Any def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __init__(self, _in: Any, _out: Any) -> None: ... def close(self) -> None: ... @@ -28,7 +28,7 @@ class Listener(object): def address(self) -> Queue[Any] | None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __init__(self, address: _Address | None = ..., family: int | None = ..., backlog: int = ...) -> None: ... def accept(self) -> Connection: ... diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 6d406bc4e4da..280a0b93e882 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -4,7 +4,7 @@ import queue import sys import threading from contextlib import AbstractContextManager -from typing import Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Tuple, TypeVar +from typing import Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, TypeVar from .connection import Connection from .context import BaseContext @@ -52,7 +52,7 @@ class BaseProxy(object): manager_owned: bool = ..., ) -> None: ... def __deepcopy__(self, memo: Any | None) -> Any: ... - def _callmethod(self, methodname: str, args: Tuple[Any, ...] = ..., kwds: dict[Any, Any] = ...) -> None: ... + def _callmethod(self, methodname: str, args: tuple[Any, ...] = ..., kwds: dict[Any, Any] = ...) -> None: ... def _getvalue(self) -> Any: ... def __reduce__(self) -> tuple[Any, tuple[Any, Any, str, dict[Any, Any]]]: ... diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index 40fb8ef170ab..2e52981a56b7 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self from contextlib import AbstractContextManager -from typing import Any, Callable, Generic, Iterable, Iterator, List, Mapping, TypeVar +from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias @@ -32,7 +32,7 @@ class ApplyResult(Generic[_T]): # alias created during issue #17805 AsyncResult = ApplyResult -class MapResult(ApplyResult[List[_T]]): +class MapResult(ApplyResult[list[_T]]): if sys.version_info >= (3, 8): def __init__( self, diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index 32c22d19f6e5..4746c78b1b4d 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -1,17 +1,17 @@ import sys -from typing import Any, Callable, Mapping, Tuple +from typing import Any, Callable, Mapping class BaseProcess: name: str daemon: bool authkey: bytes - _identity: Tuple[int, ...] # undocumented + _identity: tuple[int, ...] # undocumented def __init__( self, group: None = ..., target: Callable[..., Any] | None = ..., name: str | None = ..., - args: Tuple[Any, ...] = ..., + args: tuple[Any, ...] = ..., kwargs: Mapping[str, Any] = ..., *, daemon: bool | None = ..., diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index 6ffc2542087a..1b51da38bc43 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Generic, Iterable, Tuple, TypeVar +from typing import Any, Generic, Iterable, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias @@ -23,7 +23,7 @@ if sys.version_info >= (3, 8): def __init__(self, sequence: Iterable[_SLT] | None = ..., *, name: str | None = ...) -> None: ... def __getitem__(self, position: int) -> _SLT: ... def __setitem__(self, position: int, value: _SLT) -> None: ... - def __reduce__(self: _S) -> tuple[_S, Tuple[_SLT, ...]]: ... + def __reduce__(self: _S) -> tuple[_S, tuple[_SLT, ...]]: ... def __len__(self) -> int: ... @property def format(self) -> str: ... diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index bd9d8f089875..bbe3c17398d0 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -3,25 +3,25 @@ from collections.abc import Callable, Iterable, Sequence from ctypes import _CData, _SimpleCData, c_char from multiprocessing.context import BaseContext from multiprocessing.synchronize import _LockLike -from typing import Any, Generic, Protocol, Type, TypeVar, overload +from typing import Any, Generic, Protocol, TypeVar, overload from typing_extensions import Literal _T = TypeVar("_T") _CT = TypeVar("_CT", bound=_CData) @overload -def RawValue(typecode_or_type: Type[_CT], *args: Any) -> _CT: ... +def RawValue(typecode_or_type: type[_CT], *args: Any) -> _CT: ... @overload def RawValue(typecode_or_type: str, *args: Any) -> Any: ... @overload -def RawArray(typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... +def RawArray(typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... @overload def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ... @overload -def Value(typecode_or_type: Type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ... +def Value(typecode_or_type: type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ... @overload def Value( - typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ... + typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ... ) -> SynchronizedBase[_CT]: ... @overload def Value( @@ -29,15 +29,15 @@ def Value( ) -> SynchronizedBase[Any]: ... @overload def Value( - typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ... + typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ... ) -> Any: ... @overload def Array( - typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = ... + typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = ... ) -> _CT: ... @overload def Array( - typecode_or_type: Type[_CT], + typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike, @@ -53,7 +53,7 @@ def Array( ) -> SynchronizedArray[Any]: ... @overload def Array( - typecode_or_type: str | Type[_CData], + typecode_or_type: str | type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ..., diff --git a/stdlib/netrc.pyi b/stdlib/netrc.pyi index b8eac307740a..7c1c2068aff6 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import Optional, Tuple +from typing import Optional class NetrcParseError(Exception): filename: str | None @@ -8,7 +8,7 @@ class NetrcParseError(Exception): def __init__(self, msg: str, filename: StrOrBytesPath | None = ..., lineno: int | None = ...) -> None: ... # (login, account, password) tuple -_NetrcTuple = Tuple[str, Optional[str], Optional[str]] +_NetrcTuple = tuple[str, Optional[str], Optional[str]] class netrc: hosts: dict[str, _NetrcTuple] diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 508b5f679bc3..f0a0fb42da5c 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -3,7 +3,7 @@ import socket import ssl import sys from _typeshed import Self -from typing import IO, Any, Iterable, NamedTuple, Tuple, Union +from typing import IO, Any, Iterable, NamedTuple, Union _File = Union[IO[bytes], bytes, str, None] @@ -72,7 +72,7 @@ class _NNTPBase: def xhdr(self, hdr: str, str: Any, *, file: _File = ...) -> tuple[str, _list[str]]: ... def xover(self, start: int, end: int, *, file: _File = ...) -> tuple[str, _list[tuple[int, dict[str, str]]]]: ... def over( - self, message_spec: None | str | _list[Any] | Tuple[Any, ...], *, file: _File = ... + self, message_spec: None | str | _list[Any] | tuple[Any, ...], *, file: _File = ... ) -> tuple[str, _list[tuple[int, dict[str, str]]]]: ... if sys.version_info < (3, 9): def xgtitle(self, group: str, *, file: _File = ...) -> tuple[str, _list[tuple[str, str]]]: ... diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index b8ea9d2fff38..c32a17ceb0e9 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -1,6 +1,6 @@ -from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, Tuple, Type, overload +from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, overload -NO_DEFAULT: Tuple[str, ...] +NO_DEFAULT: tuple[str, ...] SUPPRESS_HELP: str SUPPRESS_USAGE: str @@ -72,14 +72,14 @@ class TitledHelpFormatter(HelpFormatter): def format_usage(self, usage: str) -> str: ... class Option: - ACTIONS: Tuple[str, ...] - ALWAYS_TYPED_ACTIONS: Tuple[str, ...] + ACTIONS: tuple[str, ...] + ALWAYS_TYPED_ACTIONS: tuple[str, ...] ATTRS: list[str] CHECK_METHODS: list[Callable[..., Any]] | None - CONST_ACTIONS: Tuple[str, ...] - STORE_ACTIONS: Tuple[str, ...] - TYPED_ACTIONS: Tuple[str, ...] - TYPES: Tuple[str, ...] + CONST_ACTIONS: tuple[str, ...] + STORE_ACTIONS: tuple[str, ...] + TYPED_ACTIONS: tuple[str, ...] + TYPES: tuple[str, ...] TYPE_CHECKER: dict[str, Callable[..., Any]] _long_opts: list[str] _short_opts: list[str] @@ -89,7 +89,7 @@ class Option: nargs: int type: Any callback: Callable[..., Any] | None - callback_args: Tuple[Any, ...] | None + callback_args: tuple[Any, ...] | None callback_kwargs: dict[str, Any] | None help: str | None metavar: str | None @@ -119,8 +119,8 @@ class OptionContainer: conflict_handler: str defaults: dict[str, Any] description: Any - option_class: Type[Option] - def __init__(self, option_class: Type[Option], conflict_handler: Any, description: Any) -> None: ... + option_class: type[Option] + def __init__(self, option_class: type[Option], conflict_handler: Any, description: Any) -> None: ... def _check_conflict(self, option: Any) -> None: ... def _create_option_mappings(self) -> None: ... def _share_option_mappings(self, parser: OptionParser) -> None: ... @@ -177,7 +177,7 @@ class OptionParser(OptionContainer): self, usage: str | None = ..., option_list: Iterable[Option] | None = ..., - option_class: Type[Option] = ..., + option_class: type[Option] = ..., version: str | None = ..., conflict_handler: str = ..., description: str | None = ..., diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 5d4b6b246662..ad97f8ce81c5 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -24,13 +24,13 @@ from typing import ( Generic, Iterable, Iterator, - List, + Mapping, MutableMapping, NoReturn, Protocol, Sequence, - Tuple, + TypeVar, Union, overload, @@ -284,7 +284,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 +383,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 +409,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 +447,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 +639,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 +813,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 +858,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 +884,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 +912,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 +925,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 +936,7 @@ else: if sys.platform != "win32": @final - class sched_param(structseq[int], Tuple[int]): + class sched_param(structseq[int], tuple[int]): def __new__(cls, sched_priority: int) -> sched_param: ... @property def sched_priority(self) -> int: ... diff --git a/stdlib/parser.pyi b/stdlib/parser.pyi index aecf3244ca8d..ab819a71a15f 100644 --- a/stdlib/parser.pyi +++ b/stdlib/parser.pyi @@ -1,13 +1,13 @@ from _typeshed import StrOrBytesPath from types import CodeType -from typing import Any, Sequence, Tuple +from typing import Any, Sequence def expr(source: str) -> STType: ... def suite(source: str) -> STType: ... def sequence2st(sequence: Sequence[Any]) -> STType: ... def tuple2st(sequence: Sequence[Any]) -> STType: ... def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... -def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any, ...]: ... +def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... def compilest(st: STType, filename: StrOrBytesPath = ...) -> CodeType: ... def isexpr(st: STType) -> bool: ... def issuite(st: STType) -> bool: ... @@ -19,4 +19,4 @@ class STType: def isexpr(self) -> bool: ... def issuite(self) -> bool: ... def tolist(self, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... - def totuple(self, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any, ...]: ... + def totuple(self, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 7d5f7ff2dba8..9db873287a1f 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -11,7 +11,7 @@ from _typeshed import ( from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from os import PathLike, stat_result from types import TracebackType -from typing import IO, Any, BinaryIO, Generator, Sequence, Tuple, Type, TypeVar, overload +from typing import IO, Any, BinaryIO, Generator, Sequence, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -20,7 +20,7 @@ if sys.version_info >= (3, 9): _P = TypeVar("_P", bound=PurePath) class PurePath(PathLike[str]): - parts: Tuple[str, ...] + parts: tuple[str, ...] drive: str root: str anchor: str @@ -28,7 +28,7 @@ class PurePath(PathLike[str]): suffix: str suffixes: list[str] stem: str - def __new__(cls: Type[_P], *args: StrPath) -> _P: ... + def __new__(cls: type[_P], *args: StrPath) -> _P: ... def __hash__(self) -> int: ... def __lt__(self, other: PurePath) -> bool: ... def __le__(self, other: PurePath) -> bool: ... @@ -61,13 +61,13 @@ class PurePosixPath(PurePath): ... class PureWindowsPath(PurePath): ... class Path(PurePath): - def __new__(cls: Type[_P], *args: StrPath, **kwargs: Any) -> _P: ... + def __new__(cls: type[_P], *args: StrPath, **kwargs: Any) -> _P: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... @classmethod - def cwd(cls: Type[_P]) -> _P: ... + def cwd(cls: type[_P]) -> _P: ... if sys.version_info >= (3, 10): def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ... def chmod(self, mode: int, *, follow_symlinks: bool = ...) -> None: ... @@ -166,7 +166,7 @@ class Path(PurePath): else: def unlink(self) -> None: ... @classmethod - def home(cls: Type[_P]) -> _P: ... + def home(cls: type[_P]) -> _P: ... def absolute(self: _P) -> _P: ... def expanduser(self: _P) -> _P: ... def read_bytes(self) -> bytes: ... diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index cef1ffe9eb9b..d165e6e285ef 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -1,11 +1,11 @@ import sys -from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Tuple, Type, Union +from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Union from typing_extensions import final HIGHEST_PROTOCOL: int DEFAULT_PROTOCOL: int -bytes_types: Tuple[Type[Any], ...] # undocumented +bytes_types: tuple[type[Any], ...] # undocumented class _ReadableFileobj(Protocol): def read(self, __n: int) -> bytes: ... @@ -58,10 +58,10 @@ class UnpicklingError(PickleError): ... _reducedtype = Union[ str, - Tuple[Callable[..., Any], Tuple[Any, ...]], - Tuple[Callable[..., Any], Tuple[Any, ...], Any], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]]], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]], + tuple[Callable[..., Any], tuple[Any, ...]], + tuple[Callable[..., Any], tuple[Any, ...], Any], + tuple[Callable[..., Any], tuple[Any, ...], Any, Optional[Iterator[Any]]], + tuple[Callable[..., Any], tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]], ] class Pickler: diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 9fa51a3848ee..2a89685aa5cb 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -1,7 +1,7 @@ -from typing import IO, Any, Callable, Iterator, MutableMapping, Tuple, Type +from typing import IO, Any, Callable, Iterator, MutableMapping _Reader = Callable[[IO[bytes]], Any] -bytes_types: Tuple[Type[Any], ...] +bytes_types: tuple[type[Any], ...] UP_TO_NEWLINE: int TAKEN_FROM_ARGUMENT1: int @@ -108,9 +108,9 @@ long4: ArgumentDescriptor class StackObject(object): name: str - obtype: Type[Any] | Tuple[Type[Any], ...] + obtype: type[Any] | tuple[type[Any], ...] doc: str - def __init__(self, name: str, obtype: Type[Any] | Tuple[Type[Any], ...], doc: str) -> None: ... + def __init__(self, name: str, obtype: type[Any] | tuple[type[Any], ...], doc: str) -> None: ... pyint: StackObject pylong: StackObject diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index aa8cea4dc01a..765a7a5ea5f9 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -4,7 +4,7 @@ if sys.version_info < (3, 8): import os DEV_NULL = os.devnull -from typing import NamedTuple, Tuple +from typing import NamedTuple if sys.version_info >= (3, 8): def libc_ver(executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> tuple[str, str]: ... @@ -17,11 +17,11 @@ if sys.version_info < (3, 8): distname: str = ..., version: str = ..., id: str = ..., - supported_dists: Tuple[str, ...] = ..., + supported_dists: tuple[str, ...] = ..., full_distribution_name: bool = ..., ) -> tuple[str, str, str]: ... def dist( - distname: str = ..., version: str = ..., id: str = ..., supported_dists: Tuple[str, ...] = ... + distname: str = ..., version: str = ..., id: str = ..., supported_dists: tuple[str, ...] = ... ) -> tuple[str, str, str]: ... def win32_ver(release: str = ..., version: str = ..., csd: str = ..., ptype: str = ...) -> tuple[str, str, str, str]: ... diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index 07b6963746be..88bb04609802 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -1,7 +1,7 @@ import sys from datetime import datetime from enum import Enum -from typing import IO, Any, Dict as _Dict, Mapping, MutableMapping, Tuple, Type +from typing import IO, Any, Dict as _Dict, Mapping, MutableMapping class PlistFormat(Enum): FMT_XML: int @@ -11,8 +11,8 @@ FMT_XML = PlistFormat.FMT_XML FMT_BINARY = PlistFormat.FMT_BINARY if sys.version_info >= (3, 9): - def load(fp: IO[bytes], *, fmt: PlistFormat | None = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... - def loads(value: bytes, *, fmt: PlistFormat | None = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... + def load(fp: IO[bytes], *, fmt: PlistFormat | None = ..., dict_type: type[MutableMapping[str, Any]] = ...) -> Any: ... + def loads(value: bytes, *, fmt: PlistFormat | None = ..., dict_type: type[MutableMapping[str, Any]] = ...) -> Any: ... else: def load( @@ -20,18 +20,18 @@ else: *, fmt: PlistFormat | None = ..., use_builtin_types: bool = ..., - dict_type: Type[MutableMapping[str, Any]] = ..., + dict_type: type[MutableMapping[str, Any]] = ..., ) -> Any: ... def loads( value: bytes, *, fmt: PlistFormat | None = ..., use_builtin_types: bool = ..., - dict_type: Type[MutableMapping[str, Any]] = ..., + dict_type: type[MutableMapping[str, Any]] = ..., ) -> Any: ... def dump( - value: Mapping[str, Any] | list[Any] | Tuple[Any, ...] | str | bool | float | bytes | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | datetime, fp: IO[bytes], *, fmt: PlistFormat = ..., @@ -39,7 +39,7 @@ def dump( skipkeys: bool = ..., ) -> None: ... def dumps( - value: Mapping[str, Any] | list[Any] | Tuple[Any, ...] | str | bool | float | bytes | datetime, + value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | datetime, *, fmt: PlistFormat = ..., skipkeys: bool = ..., diff --git a/stdlib/poplib.pyi b/stdlib/poplib.pyi index 28fba4ce951f..028af412847b 100644 --- a/stdlib/poplib.pyi +++ b/stdlib/poplib.pyi @@ -1,8 +1,8 @@ import socket import ssl -from typing import Any, BinaryIO, List, Pattern, Tuple, overload +from typing import Any, BinaryIO, Pattern, overload -_LongResp = Tuple[bytes, List[bytes], int] +_LongResp = tuple[bytes, list[bytes], int] class error_proto(Exception): ... diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index cb0cbf7c9388..7581c0122c9c 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import Any, Callable, Tuple, TypeVar +from typing import Any, Callable, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( @@ -8,7 +8,7 @@ def runctx( _SelfT = TypeVar("_SelfT", bound=Profile) _T = TypeVar("_T") -_Label = Tuple[str, int, str] +_Label = tuple[str, int, str] class Profile: bias: int diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index e8256f9f98ab..6e008c823ff2 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import StrOrBytesPath from cProfile import Profile as _cProfile from profile import Profile -from typing import IO, Any, Iterable, Tuple, TypeVar, Union, overload +from typing import IO, Any, Iterable, TypeVar, Union, overload _Selector = Union[str, float, int] _T = TypeVar("_T", bound=Stats) @@ -33,7 +33,7 @@ class Stats: def get_top_level_stats(self) -> None: ... def add(self: _T, *arg_list: None | str | Profile | _cProfile | _T) -> _T: ... def dump_stats(self, filename: StrOrBytesPath) -> None: ... - def get_sort_arg_defs(self) -> dict[str, tuple[Tuple[tuple[int, int], ...], str]]: ... + def get_sort_arg_defs(self) -> dict[str, tuple[tuple[tuple[int, int], ...], str]]: ... @overload def sort_stats(self: _T, field: int) -> _T: ... @overload diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index a16175879f67..3ed6111bde31 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -1,9 +1,9 @@ from _typeshed import structseq -from typing import Any, Tuple +from typing import Any from typing_extensions import final @final -class struct_passwd(structseq[Any], Tuple[str, str, int, int, str, str, str]): +class struct_passwd(structseq[Any], tuple[str, str, int, int, str, str, str]): @property def pw_name(self) -> str: ... @property diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 1df818509d0e..2c967c221407 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -1,12 +1,12 @@ import sys -from typing import AnyStr, Type +from typing import AnyStr class PyCompileError(Exception): exc_type_name: str exc_value: BaseException file: str msg: str - def __init__(self, exc_type: Type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... + def __init__(self, exc_type: type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... if sys.version_info >= (3, 7): import enum diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index b60ef8f9bcb3..cc656f9b7559 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -1,10 +1,10 @@ from _typeshed import SupportsWrite from reprlib import Repr from types import MethodType, ModuleType, TracebackType -from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, Optional, Tuple, Type +from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, Optional # 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 @@ -28,7 +28,7 @@ def synopsis(filename: str, cache: MutableMapping[str, tuple[int, str]] = ...) - class ErrorDuringImport(Exception): filename: str - exc: Type[BaseException] | None + exc: type[BaseException] | None value: BaseException | None tb: TracebackType | None def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... @@ -96,7 +96,7 @@ class HTMLDoc(Doc): methods: Mapping[str, str] = ..., ) -> str: ... def formattree( - self, tree: list[tuple[type, Tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ... + self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ... ) -> str: ... def docmodule(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... def docclass( @@ -143,7 +143,7 @@ class TextDoc(Doc): def indent(self, text: str, prefix: str = ...) -> str: ... def section(self, title: str, contents: str) -> str: ... def formattree( - self, tree: list[tuple[type, Tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ..., prefix: str = ... + self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ..., prefix: str = ... ) -> str: ... def docmodule(self, object: object, name: str | None = ..., mod: Any | None = ...) -> str: ... # type: ignore[override] def docclass(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... @@ -187,7 +187,7 @@ _list = list # "list" conflicts with method name class Helper: keywords: dict[str, str | tuple[str, str]] symbols: dict[str, str] - topics: dict[str, str | Tuple[str, ...]] + topics: dict[str, str | tuple[str, ...]] def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... input: IO[str] output: IO[str] diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 6a3d6cd56791..37424f20c18d 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,7 +1,7 @@ import pyexpat.errors as errors import pyexpat.model as model from _typeshed import SupportsRead -from typing import Any, Callable, Optional, Tuple +from typing import Any, Callable, Optional from typing_extensions import final EXPAT_VERSION: str # undocumented @@ -20,7 +20,7 @@ XML_PARAM_ENTITY_PARSING_NEVER: int XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int XML_PARAM_ENTITY_PARSING_ALWAYS: int -_Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] +_Model = tuple[int, int, Optional[str], tuple[Any, ...]] @final class XMLParserType(object): diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 4834dab6552e..ffa866ef9aa0 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -3,7 +3,7 @@ import sys from _typeshed import SupportsLenAndGetItem from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set as AbstractSet from fractions import Fraction -from typing import Any, ClassVar, NoReturn, Tuple, TypeVar +from typing import Any, ClassVar, NoReturn, TypeVar _T = TypeVar("_T") @@ -11,8 +11,8 @@ class Random(_random.Random): VERSION: ClassVar[int] def __init__(self, x: Any = ...) -> None: ... def seed(self, a: Any = ..., version: int = ...) -> None: ... - def getstate(self) -> Tuple[Any, ...]: ... - def setstate(self, state: Tuple[Any, ...]) -> None: ... + def getstate(self) -> tuple[Any, ...]: ... + def setstate(self, state: tuple[Any, ...]) -> None: ... def getrandbits(self, __k: int) -> int: ... def randrange(self, start: int, stop: int | None = ..., step: int = ...) -> int: ... def randint(self, a: int, b: int) -> int: ... diff --git a/stdlib/reprlib.pyi b/stdlib/reprlib.pyi index 4d400554a4ff..2095c0af6983 100644 --- a/stdlib/reprlib.pyi +++ b/stdlib/reprlib.pyi @@ -1,6 +1,6 @@ from array import array from collections import deque -from typing import Any, Callable, Tuple +from typing import Any, Callable _ReprFunc = Callable[[Any], str] @@ -21,7 +21,7 @@ class Repr: def __init__(self) -> None: ... def repr(self, x: Any) -> str: ... def repr1(self, x: Any, level: int) -> str: ... - def repr_tuple(self, x: Tuple[Any, ...], level: int) -> str: ... + def repr_tuple(self, x: tuple[Any, ...], level: int) -> str: ... def repr_list(self, x: list[Any], level: int) -> str: ... def repr_array(self, x: array[Any], level: int) -> str: ... def repr_set(self, x: set[Any], level: int) -> str: ... diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index ff6f1d79e483..8e01bc717684 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import structseq -from typing import Tuple, overload +from typing import overload from typing_extensions import final RLIMIT_AS: int @@ -26,7 +26,7 @@ if sys.platform == "linux": RUSAGE_THREAD: int @final -class struct_rusage(structseq[float], Tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int]): +class struct_rusage(structseq[float], tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int]): @property def ru_utime(self) -> float: ... @property diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index cb96dc2bbf4a..71aacc5c2610 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,10 +1,10 @@ -from typing import Any, Callable, NamedTuple, Tuple +from typing import Any, Callable, NamedTuple class Event(NamedTuple): time: float priority: Any action: Callable[..., Any] - argument: Tuple[Any, ...] + argument: tuple[Any, ...] kwargs: dict[str, Any] class scheduler: @@ -14,7 +14,7 @@ class scheduler: time: float, priority: Any, action: Callable[..., Any], - argument: Tuple[Any, ...] = ..., + argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ..., ) -> Event: ... def enter( @@ -22,7 +22,7 @@ class scheduler: delay: float, priority: Any, action: Callable[..., Any], - argument: Tuple[Any, ...] = ..., + argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ..., ) -> Event: ... def run(self, blocking: bool = ...) -> float | None: ... diff --git a/stdlib/select.pyi b/stdlib/select.pyi index 5650ed4c9a2c..231485be541b 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike, Self from types import TracebackType -from typing import Any, Iterable, Type +from typing import Any, Iterable if sys.platform != "win32": PIPE_BUF: int @@ -105,7 +105,7 @@ if sys.platform == "linux": def __enter__(self: Self) -> Self: ... def __exit__( self, - exc_type: Type[BaseException] | None = ..., + exc_type: type[BaseException] | None = ..., exc_val: BaseException | None = ..., exc_tb: TracebackType | None = ..., ) -> None: ... diff --git a/stdlib/shelve.pyi b/stdlib/shelve.pyi index 90b2aafa4f03..10f82b6a2eb3 100644 --- a/stdlib/shelve.pyi +++ b/stdlib/shelve.pyi @@ -1,7 +1,7 @@ from _typeshed import Self from collections.abc import Iterator, MutableMapping from types import TracebackType -from typing import Type, TypeVar, overload +from typing import TypeVar, overload _T = TypeVar("_T") _VT = TypeVar("_VT") @@ -21,7 +21,7 @@ class Shelf(MutableMapping[str, _VT]): def __delitem__(self, key: str) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def close(self) -> None: ... def sync(self) -> None: ... diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index 6c93662fb326..777391662aa3 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import structseq from enum import IntEnum from types import FrameType -from typing import Any, Callable, Iterable, Optional, Tuple, Union +from typing import Any, Callable, Iterable, Optional, Union from typing_extensions import final NSIG: int @@ -132,7 +132,7 @@ else: SIGRTMAX: Signals SIGRTMIN: Signals @final - class struct_siginfo(structseq[int], Tuple[int, int, int, int, int, int, int]): + class struct_siginfo(structseq[int], tuple[int, int, int, int, int, int, int]): @property def si_signo(self) -> int: ... @property diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index ef0ada2c72de..8a532058a2bb 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 -_Address = Tuple[str, int] # (host, port) +_Address = tuple[str, int] # (host, port) class SMTPChannel(asynchat.async_chat): COMMAND: int @@ -56,7 +56,7 @@ class SMTPChannel(asynchat.async_chat): def smtp_EXPN(self, arg: str) -> None: ... class SMTPServer(asyncore.dispatcher): - channel_class: Type[SMTPChannel] + channel_class: type[SMTPChannel] data_size_limit: int enable_SMTPUTF8: bool diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index a6f7d07ee7ec..4e4fb1648832 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -4,12 +4,12 @@ from email.message import Message as _Message from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Dict, Pattern, Protocol, Sequence, Tuple, Type, Union, overload +from typing import Any, Pattern, Protocol, Sequence, 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 @@ -79,7 +79,7 @@ class SMTP: ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None ) -> None: ... def set_debuglevel(self, debuglevel: int) -> None: ... def connect(self, host: str = ..., port: int = ..., source_address: _SourceAddress | None = ...) -> _Reply: ... diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index c64408cfab07..a12c6fdeadd5 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -2,11 +2,11 @@ import sys import types from _typeshed import Self from socket import socket as _socket -from typing import Any, BinaryIO, Callable, ClassVar, Tuple, Type, TypeVar, Union +from typing import Any, BinaryIO, Callable, ClassVar, 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 @@ -33,7 +33,7 @@ class BaseServer: def verify_request(self, request: _RequestType, client_address: _AddressType) -> bool: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def service_actions(self) -> None: ... def shutdown_request(self, request: _RequestType) -> None: ... # undocumented 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..86a5f286134c 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, Type, TypeVar +from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, TypeVar _T = TypeVar("_T") @@ -94,7 +94,7 @@ if sys.version_info >= (3, 7): detect_types: int = ..., isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Type[Connection] | None = ..., + factory: type[Connection] | None = ..., cached_statements: int = ..., uri: bool = ..., ) -> Connection: ... @@ -106,14 +106,14 @@ else: detect_types: int = ..., isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Type[Connection] | None = ..., + factory: type[Connection] | None = ..., cached_statements: int = ..., uri: bool = ..., ) -> Connection: ... def enable_callback_tracebacks(__enable: bool) -> None: ... def enable_shared_cache(enable: int) -> None: ... -def register_adapter(__type: Type[_T], __caster: Callable[[_T], int | float | str | bytes]) -> None: ... +def register_adapter(__type: type[_T], __caster: Callable[[_T], int | float | str | bytes]) -> None: ... def register_converter(__name: str, __converter: Callable[[bytes], Any]) -> None: ... if sys.version_info < (3, 8): diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index 598e61d6a8e0..c4de55bcbf7e 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -1,7 +1,7 @@ import sys from sre_constants import * from sre_constants import _NamedIntConstant as _NIC, error as _Error -from typing import Any, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload +from typing import Any, Iterable, Match, Optional, Pattern as _Pattern, Union, overload SPECIAL_CHARS: str REPEAT_CHARS: str @@ -37,12 +37,12 @@ if sys.version_info >= (3, 8): else: Pattern = _State -_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern] -_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern] -_OpInType = List[Tuple[_NIC, int]] -_OpBranchType = Tuple[None, List[SubPattern]] +_OpSubpatternType = tuple[Optional[int], int, int, SubPattern] +_OpGroupRefExistsType = tuple[int, SubPattern, SubPattern] +_OpInType = list[tuple[_NIC, int]] +_OpBranchType = tuple[None, list[SubPattern]] _AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType] -_CodeType = Tuple[_NIC, _AvType] +_CodeType = tuple[_NIC, _AvType] class SubPattern: data: list[_CodeType] @@ -85,8 +85,8 @@ class Tokenizer: def fix_flags(src: str | bytes, flags: int) -> int: ... -_TemplateType = Tuple[List[Tuple[int, int]], List[Optional[str]]] -_TemplateByteType = Tuple[List[Tuple[int, int]], List[Optional[bytes]]] +_TemplateType = tuple[list[tuple[int, int]], list[Optional[str]]] +_TemplateByteType = tuple[list[tuple[int, int]], list[Optional[bytes]]] if sys.version_info >= (3, 8): def parse(str: str, flags: int = ..., state: State | None = ...) -> SubPattern: ... @overload diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 628139634bac..8851c94efc16 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -2,14 +2,14 @@ import enum import socket import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer -from typing import Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Optional, Set, Tuple, Type, Union, overload +from typing import Any, Callable, ClassVar, Iterable, NamedTuple, Optional, 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]] @@ -294,9 +294,9 @@ class _ASN1Object(NamedTuple): longname: str oid: str @classmethod - def fromnid(cls: Type[Self], nid: int) -> Self: ... + def fromnid(cls: type[Self], nid: int) -> Self: ... @classmethod - def fromname(cls: Type[Self], name: str) -> Self: ... + def fromname(cls: type[Self], name: str) -> Self: ... class Purpose(_ASN1Object, enum.Enum): SERVER_AUTH: _ASN1Object @@ -391,8 +391,8 @@ class SSLContext: maximum_version: TLSVersion minimum_version: TLSVersion sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None - sslobject_class: ClassVar[Type[SSLObject]] - sslsocket_class: ClassVar[Type[SSLSocket]] + sslobject_class: ClassVar[type[SSLObject]] + sslsocket_class: ClassVar[type[SSLSocket]] if sys.version_info >= (3, 8): keylog_filename: str post_handshake_auth: bool diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 908d6adaf45d..b92a05466d05 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -2,7 +2,7 @@ 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, Hashable, Iterable, NamedTuple, Sequence, SupportsFloat, TypeVar, Union _T = TypeVar("_T") # Most functions in this module accept homogeneous collections of one of these types @@ -58,7 +58,7 @@ if sys.version_info >= (3, 8): @property def variance(self) -> float: ... @classmethod - def from_samples(cls: Type[_T], data: Iterable[SupportsFloat]) -> _T: ... + def from_samples(cls: type[_T], data: Iterable[SupportsFloat]) -> _T: ... def samples(self, n: int, *, seed: Any | None = ...) -> list[float]: ... def pdf(self, x: float) -> float: ... def cdf(self, x: float) -> float: ... diff --git a/stdlib/struct.pyi b/stdlib/struct.pyi index d7c9cbef7dce..47af62973259 100644 --- a/stdlib/struct.pyi +++ b/stdlib/struct.pyi @@ -1,14 +1,14 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer -from typing import Any, Iterator, Tuple +from typing import Any, Iterator class error(Exception): ... def pack(fmt: str | bytes, *v: Any) -> bytes: ... def pack_into(fmt: str | bytes, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... -def unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... -def unpack_from(__format: str | bytes, buffer: ReadableBuffer, offset: int = ...) -> Tuple[Any, ...]: ... -def iter_unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Iterator[Tuple[Any, ...]]: ... +def unpack(__format: str | bytes, __buffer: ReadableBuffer) -> tuple[Any, ...]: ... +def unpack_from(__format: str | bytes, buffer: ReadableBuffer, offset: int = ...) -> tuple[Any, ...]: ... +def iter_unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Iterator[tuple[Any, ...]]: ... def calcsize(__format: str | bytes) -> int: ... class Struct: @@ -20,6 +20,6 @@ class Struct: def __init__(self, format: str | bytes) -> None: ... def pack(self, *v: Any) -> bytes: ... def pack_into(self, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... - def unpack(self, __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... - def unpack_from(self, buffer: ReadableBuffer, offset: int = ...) -> Tuple[Any, ...]: ... - def iter_unpack(self, __buffer: ReadableBuffer) -> Iterator[Tuple[Any, ...]]: ... + def unpack(self, __buffer: ReadableBuffer) -> tuple[Any, ...]: ... + def unpack_from(self, buffer: ReadableBuffer, offset: int = ...) -> tuple[Any, ...]: ... + def iter_unpack(self, __buffer: ReadableBuffer) -> Iterator[tuple[Any, ...]]: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index fce517745ee6..b0987f3991fa 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from types import TracebackType -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Type, TypeVar, Union, overload +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -1008,7 +1008,7 @@ class Popen(Generic[AnyStr]): def kill(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/symtable.pyi b/stdlib/symtable.pyi index 2f8961faa5f6..58fb8c8ae69f 100644 --- a/stdlib/symtable.pyi +++ b/stdlib/symtable.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Sequence, Tuple +from typing import Any, Sequence def symtable(code: str, filename: str, compile_type: str) -> SymbolTable: ... @@ -19,15 +19,15 @@ class SymbolTable(object): def get_children(self) -> list[SymbolTable]: ... class Function(SymbolTable): - def get_parameters(self) -> Tuple[str, ...]: ... - def get_locals(self) -> Tuple[str, ...]: ... - def get_globals(self) -> Tuple[str, ...]: ... - def get_frees(self) -> Tuple[str, ...]: ... + def get_parameters(self) -> tuple[str, ...]: ... + def get_locals(self) -> tuple[str, ...]: ... + def get_globals(self) -> tuple[str, ...]: ... + def get_frees(self) -> tuple[str, ...]: ... if sys.version_info >= (3, 8): - def get_nonlocals(self) -> Tuple[str, ...]: ... + def get_nonlocals(self) -> tuple[str, ...]: ... class Class(SymbolTable): - def get_methods(self) -> Tuple[str, ...]: ... + def get_methods(self) -> tuple[str, ...]: ... class Symbol(object): if sys.version_info >= (3, 8): diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index b5829884482a..a953a634bc74 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -13,8 +13,8 @@ from typing import ( Protocol, Sequence, TextIO, - Tuple, - Type, + + TypeVar, Union, overload, @@ -24,8 +24,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): @@ -44,12 +44,12 @@ if sys.platform == "win32": dllhandle: int dont_write_bytecode: bool displayhook: Callable[[object], Any] -excepthook: Callable[[Type[BaseException], BaseException, TracebackType | None], Any] +excepthook: Callable[[type[BaseException], BaseException, TracebackType | None], Any] exec_prefix: str executable: str float_repr_style: str hexversion: int -last_type: Type[BaseException] | None +last_type: type[BaseException] | None last_value: BaseException | None last_traceback: TracebackType | None maxsize: int @@ -146,7 +146,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 @@ -161,7 +161,7 @@ def _current_frames() -> dict[int, FrameType]: ... def _getframe(__depth: int = ...) -> FrameType: ... def _debugmallocstats() -> None: ... def __displayhook__(value: object) -> None: ... -def __excepthook__(type_: Type[BaseException], value: BaseException, traceback: TracebackType | None) -> None: ... +def __excepthook__(type_: type[BaseException], value: BaseException, traceback: TracebackType | None) -> None: ... def exc_info() -> _OptExcInfo: ... # sys.exit() accepts an optional argument of anything printable @@ -192,7 +192,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 @@ -228,18 +228,18 @@ if sys.version_info < (3, 9): if sys.version_info >= (3, 8): # not exported by sys class UnraisableHookArgs: - exc_type: Type[BaseException] + exc_type: type[BaseException] exc_value: BaseException | None exc_traceback: TracebackType | None err_msg: str | None object: _object | None unraisablehook: Callable[[UnraisableHookArgs], Any] - def addaudithook(hook: Callable[[str, Tuple[Any, ...]], Any]) -> None: ... + def addaudithook(hook: Callable[[str, tuple[Any, ...]], Any]) -> None: ... def audit(__event: str, *args: Any) -> None: ... _AsyncgenHook = Optional[Callable[[AsyncGenerator[Any, Any]], None]] -class _asyncgen_hooks(Tuple[_AsyncgenHook, _AsyncgenHook]): +class _asyncgen_hooks(tuple[_AsyncgenHook, _AsyncgenHook]): firstiter: _AsyncgenHook finalizer: _AsyncgenHook diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index ff828d519912..17077144f6e9 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -1,12 +1,12 @@ -from typing import IO, Any, Tuple, overload +from typing import IO, Any, overload def get_config_var(name: str) -> str | None: ... @overload def get_config_vars() -> dict[str, Any]: ... @overload def get_config_vars(arg: str, *args: str) -> list[Any]: ... -def get_scheme_names() -> Tuple[str, ...]: ... -def get_path_names() -> Tuple[str, ...]: ... +def get_scheme_names() -> tuple[str, ...]: ... +def get_path_names() -> tuple[str, ...]: ... def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> str: ... def get_paths(scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> dict[str, str]: ... def get_python_version() -> str: ... diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 0134316d8107..73b50c298294 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, 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] @@ -78,7 +78,7 @@ def open( bufsize: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -100,12 +100,12 @@ class TarFile: mode: Literal["r", "a", "w", "x"] fileobj: _Fileobj | None format: int | None - tarinfo: Type[TarInfo] + tarinfo: type[TarInfo] dereference: bool | None ignore_zeros: bool | None encoding: str | None errors: str - fileobject: Type[ExFileObject] + fileobject: type[ExFileObject] pax_headers: Mapping[str, str] | None debug: int | None errorlevel: int | None @@ -116,7 +116,7 @@ class TarFile: mode: Literal["r", "a", "w", "x"] = ..., fileobj: _Fileobj | None = ..., format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -128,19 +128,19 @@ class TarFile: ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[TarInfo]: ... @classmethod def open( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None = ..., mode: str = ..., fileobj: IO[bytes] | None = ..., # depends on mode bufsize: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -151,14 +151,14 @@ class TarFile: ) -> _TF: ... @classmethod def taropen( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["r", "a", "w", "x"] = ..., fileobj: _Fileobj | None = ..., *, compresslevel: int = ..., format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -169,14 +169,14 @@ class TarFile: @overload @classmethod def gzopen( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["r"] = ..., fileobj: _GzipReadableFileobj | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -187,14 +187,14 @@ class TarFile: @overload @classmethod def gzopen( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["w", "x"], fileobj: _GzipWritableFileobj | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -205,14 +205,14 @@ class TarFile: @overload @classmethod def bz2open( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["w", "x"], fileobj: _Bz2WritableFileobj | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -223,14 +223,14 @@ class TarFile: @overload @classmethod def bz2open( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["r"] = ..., fileobj: _Bz2ReadableFileobj | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -240,14 +240,14 @@ class TarFile: ) -> _TF: ... @classmethod def xzopen( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["r", "w", "x"] = ..., fileobj: IO[bytes] | None = ..., preset: int | None = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 119c111bc4e1..9b5e2bb82539 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -2,7 +2,7 @@ import os import sys from _typeshed import Self from types import TracebackType -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, Tuple, Type, Union, overload +from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -169,7 +169,7 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): delete: bool def __init__(self, file: IO[AnyStr], name: str, delete: bool = ...) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, exc: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> bool | None: ... + def __exit__(self, exc: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> bool | None: ... def __getattr__(self, name: str) -> Any: ... def close(self) -> None: ... # These methods don't exist directly on this object, but @@ -206,7 +206,7 @@ class SpooledTemporaryFile(IO[AnyStr]): @property def encoding(self) -> str: ... # undocumented @property - def newlines(self) -> str | Tuple[str, ...] | None: ... # undocumented + def newlines(self) -> str | tuple[str, ...] | None: ... # undocumented # bytes needs to go first, as default mode is to open as bytes if sys.version_info >= (3, 8): @overload @@ -293,7 +293,7 @@ class SpooledTemporaryFile(IO[AnyStr]): def rollover(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... # These methods are copied from the abstract methods of IO, because # SpooledTemporaryFile implements IO. @@ -346,7 +346,7 @@ class TemporaryDirectory(Generic[AnyStr]): def cleanup(self) -> None: ... def __enter__(self) -> AnyStr: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... 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/threading.pyi b/stdlib/threading.pyi index d6ac9f7251c2..9be50bfdb790 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -1,6 +1,6 @@ import sys from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, Mapping, Optional, Type, TypeVar +from typing import Any, Callable, Iterable, Mapping, Optional, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] @@ -75,7 +75,7 @@ class Lock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -87,7 +87,7 @@ class _RLock: def release(self) -> None: ... __enter__ = acquire def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... RLock = _RLock @@ -96,7 +96,7 @@ class Condition: def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -109,7 +109,7 @@ class Condition: class Semaphore: def __init__(self, value: int = ...) -> None: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... diff --git a/stdlib/time.pyi b/stdlib/time.pyi index fc929b112185..6e23b331d1c8 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -1,10 +1,10 @@ import sys from _typeshed import structseq from types import SimpleNamespace -from typing import Any, Tuple, Union +from typing import Any, Union from typing_extensions import final -_TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] +_TimeTuple = tuple[int, int, int, int, int, int, int, int, int] altzone: int daylight: int diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index a32fe5554157..9d04c74ba39e 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -5,7 +5,7 @@ from enum import Enum from tkinter.constants import * from tkinter.font import _FontDescription from types import TracebackType -from typing import Any, Callable, Generic, List, Mapping, Optional, Protocol, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, Mapping, Optional, Protocol, Sequence, TypeVar, Union, overload from typing_extensions import Literal, TypedDict # Using anything from tkinter.font in this file means that 'import tkinter' @@ -42,18 +42,18 @@ _ButtonCommand = Union[str, Callable[[], Any]] # accepts string of tcl code, re _CanvasItemId = int _Color = str # typically '#rrggbb', '#rgb' or color names. _Compound = Literal["top", "left", "center", "right", "bottom", "none"] # -compound in manual page named 'options' -_Cursor = Union[str, Tuple[str], Tuple[str, str], Tuple[str, str, str], Tuple[str, str, str, str]] # manual page: Tk_GetCursor +_Cursor = Union[str, tuple[str], tuple[str, str], tuple[str, str, str], tuple[str, str, str, str]] # manual page: Tk_GetCursor _EntryValidateCommand = Union[ - Callable[[], bool], str, List[str], Tuple[str, ...] + Callable[[], bool], str, list[str], tuple[str, ...] ] # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P'] _GridIndex = Union[int, str, Literal["all"]] _ImageSpec = Union[_Image, str] # str can be from e.g. tkinter.image_names() _Padding = Union[ _ScreenUnits, - Tuple[_ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits], - Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits], + tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], ] _Relief = Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] # manual page: Tk_GetRelief _ScreenUnits = Union[str, float] # Often the right type instead of int. Manual page: Tk_GetPixels @@ -137,7 +137,7 @@ class Variable: def get(self) -> Any: ... def trace_add(self, mode: _TraceMode, callback: Callable[[str, str, str], Any]) -> str: ... def trace_remove(self, mode: _TraceMode, cbname: str) -> None: ... - def trace_info(self) -> list[tuple[Tuple[_TraceMode, ...], str]]: ... + def trace_info(self) -> list[tuple[tuple[_TraceMode, ...], str]]: ... def trace_variable(self, mode, callback): ... # deprecated def trace_vdelete(self, mode, cbname): ... # deprecated def trace_vinfo(self): ... # deprecated @@ -249,7 +249,7 @@ class Misc: def winfo_geometry(self) -> str: ... def winfo_height(self) -> int: ... def winfo_id(self) -> int: ... - def winfo_interps(self, displayof: Literal[0] | Misc | None = ...) -> Tuple[str, ...]: ... + def winfo_interps(self, displayof: Literal[0] | Misc | None = ...) -> tuple[str, ...]: ... def winfo_ismapped(self) -> bool: ... def winfo_manager(self) -> str: ... def winfo_name(self) -> str: ... @@ -420,9 +420,9 @@ class Misc: x: _ScreenUnits = ..., y: _ScreenUnits = ..., ) -> None: ... - def event_info(self, virtual: str | None = ...) -> Tuple[str, ...]: ... - def image_names(self) -> Tuple[str, ...]: ... - def image_types(self) -> Tuple[str, ...]: ... + def event_info(self, virtual: str | None = ...) -> tuple[str, ...]: ... + def image_names(self) -> tuple[str, ...]: ... + def image_types(self) -> tuple[str, ...]: ... # See #4363 and #4891 def __setitem__(self, key: str, value: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... @@ -468,7 +468,7 @@ class Wm: ) -> tuple[int, int, int, int] | None: ... aspect = wm_aspect @overload - def wm_attributes(self) -> Tuple[Any, ...]: ... + def wm_attributes(self) -> tuple[Any, ...]: ... @overload def wm_attributes(self, __option: str) -> Any: ... @overload @@ -479,7 +479,7 @@ class Wm: @overload def wm_colormapwindows(self) -> list[Misc]: ... @overload - def wm_colormapwindows(self, __wlist: list[Misc] | Tuple[Misc, ...]) -> None: ... + def wm_colormapwindows(self, __wlist: list[Misc] | tuple[Misc, ...]) -> None: ... @overload def wm_colormapwindows(self, __first_wlist_item: Misc, *other_wlist_items: Misc) -> None: ... colormapwindows = wm_colormapwindows @@ -543,7 +543,7 @@ class Wm: @overload def wm_protocol(self, name: str, func: None = ...) -> str: ... @overload - def wm_protocol(self, name: None = ..., func: None = ...) -> Tuple[str, ...]: ... + def wm_protocol(self, name: None = ..., func: None = ...) -> tuple[str, ...]: ... protocol = wm_protocol @overload def wm_resizable(self, width: None = ..., height: None = ...) -> tuple[bool, bool]: ... @@ -571,7 +571,7 @@ class Wm: withdraw = wm_withdraw class _ExceptionReportingCallback(Protocol): - def __call__(self, __exc: Type[BaseException], __val: BaseException, __tb: TracebackType | None) -> Any: ... + def __call__(self, __exc: type[BaseException], __val: BaseException, __tb: TracebackType | None) -> Any: ... class Tk(Misc, Wm): master: None @@ -1043,17 +1043,17 @@ class Canvas(Widget, XView, YView): def addtag_overlapping(self, newtag: str, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: _ScreenUnits) -> None: ... def addtag_withtag(self, newtag: str, tagOrId: str | _CanvasItemId) -> None: ... def find(self, *args): ... # internal method - def find_above(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... - def find_all(self) -> Tuple[_CanvasItemId, ...]: ... - def find_below(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... + def find_above(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... + def find_all(self) -> tuple[_CanvasItemId, ...]: ... + def find_below(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... def find_closest( self, x: _ScreenUnits, y: _ScreenUnits, halo: _ScreenUnits | None = ..., start: str | _CanvasItemId | None = ... - ) -> Tuple[_CanvasItemId, ...]: ... + ) -> tuple[_CanvasItemId, ...]: ... def find_enclosed( self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: _ScreenUnits - ) -> Tuple[_CanvasItemId, ...]: ... - def find_overlapping(self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: float) -> Tuple[_CanvasItemId, ...]: ... - def find_withtag(self, tagOrId: str | _CanvasItemId) -> Tuple[_CanvasItemId, ...]: ... + ) -> tuple[_CanvasItemId, ...]: ... + def find_overlapping(self, x1: _ScreenUnits, y1: _ScreenUnits, x2: _ScreenUnits, y2: float) -> tuple[_CanvasItemId, ...]: ... + def find_withtag(self, tagOrId: str | _CanvasItemId) -> tuple[_CanvasItemId, ...]: ... # Incompatible with Misc.bbox(), tkinter violates LSP def bbox(self, *args: str | _CanvasItemId) -> tuple[int, int, int, int]: ... # type: ignore[override] @overload @@ -1076,7 +1076,7 @@ class Canvas(Widget, XView, YView): @overload def coords(self) -> list[float]: ... @overload - def coords(self, __args: list[int] | list[float] | Tuple[float, ...]) -> None: ... + def coords(self, __args: list[int] | list[float] | tuple[float, ...]) -> None: ... @overload def coords(self, __x1: float, __y1: float, *args: float) -> None: ... # create_foo() methods accept coords as a list, a tuple, or as separate arguments. @@ -1092,16 +1092,16 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., arrow: Literal["first", "last", "both"] = ..., arrowshape: tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledstipple: _Bitmap = ..., disabledwidth: _ScreenUnits = ..., @@ -1112,7 +1112,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1120,16 +1120,16 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., arrow: Literal["first", "last", "both"] = ..., arrowshape: tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledstipple: _Bitmap = ..., disabledwidth: _ScreenUnits = ..., @@ -1140,7 +1140,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1151,15 +1151,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1172,7 +1172,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1180,15 +1180,15 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1201,7 +1201,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1212,15 +1212,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *xy_pairs: float, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1236,23 +1236,23 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload def create_polygon( self, - __coords: Tuple[float, ...] | list[int] | list[float], + __coords: tuple[float, ...] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1268,7 +1268,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1279,15 +1279,15 @@ class Canvas(Widget, XView, YView): __x1: float, __y1: float, *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1300,7 +1300,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1308,15 +1308,15 @@ class Canvas(Widget, XView, YView): self, __coords: tuple[float, float, float, float] | list[int] | list[float], *, - activedash: str | list[int] | Tuple[int, ...] = ..., + activedash: str | list[int] | tuple[int, ...] = ..., activefill: _Color = ..., activeoutline: _Color = ..., activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: str | list[int] | Tuple[int, ...] = ..., + dash: str | list[int] | tuple[int, ...] = ..., dashoffset: _ScreenUnits = ..., - disableddash: str | list[int] | Tuple[int, ...] = ..., + disableddash: str | list[int] | tuple[int, ...] = ..., disabledfill: _Color = ..., disabledoutline: _Color = ..., disabledoutlinestipple: _Color = ..., @@ -1329,7 +1329,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @overload @@ -1349,7 +1349,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1369,7 +1369,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1382,7 +1382,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1394,7 +1394,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1405,7 +1405,7 @@ class Canvas(Widget, XView, YView): @overload def dtag(self, __id: _CanvasItemId, __tag_to_delete: str) -> None: ... def focus(self, *args): ... - def gettags(self, __tagOrId: str | _CanvasItemId) -> Tuple[str, ...]: ... + def gettags(self, __tagOrId: str | _CanvasItemId) -> tuple[str, ...]: ... def icursor(self, *args): ... def index(self, *args): ... def insert(self, *args): ... @@ -2650,7 +2650,7 @@ class Text(Widget, XView, YView): startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., # Literal inside Tuple doesn't actually work - tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., + tabs: _ScreenUnits | str | tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2701,7 +2701,7 @@ class Text(Widget, XView, YView): spacing3: _ScreenUnits = ..., startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., - tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., + tabs: _ScreenUnits | str | tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2780,20 +2780,20 @@ class Text(Widget, XView, YView): def image_create(self, index, cnf=..., **kw): ... def image_names(self): ... def index(self, index: _TextIndex) -> str: ... - def insert(self, index: _TextIndex, chars: str, *args: str | list[str] | Tuple[str, ...]) -> None: ... + def insert(self, index: _TextIndex, chars: str, *args: str | list[str] | tuple[str, ...]) -> None: ... @overload def mark_gravity(self, markName: str, direction: None = ...) -> Literal["left", "right"]: ... @overload def mark_gravity(self, markName: str, direction: Literal["left", "right"]) -> None: ... # actually returns empty string - def mark_names(self) -> Tuple[str, ...]: ... + def mark_names(self) -> tuple[str, ...]: ... def mark_set(self, markName: str, index: _TextIndex) -> None: ... def mark_unset(self, *markNames: str) -> None: ... def mark_next(self, index: _TextIndex) -> str | None: ... def mark_previous(self, index: _TextIndex) -> str | None: ... # **kw of peer_create is same as the kwargs of Text.__init__ def peer_create(self, newPathName: str | Text, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def peer_names(self) -> Tuple[_tkinter.Tcl_Obj, ...]: ... - def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | list[str] | Tuple[str, ...]) -> None: ... + def peer_names(self) -> tuple[_tkinter.Tcl_Obj, ...]: ... + def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | list[str] | tuple[str, ...]) -> None: ... def scan_mark(self, x: int, y: int) -> None: ... def scan_dragto(self, x: int, y: int) -> None: ... def search( @@ -2865,11 +2865,11 @@ class Text(Widget, XView, YView): tag_config = tag_configure def tag_delete(self, __first_tag_name: str, *tagNames: str) -> None: ... # error if no tag names given def tag_lower(self, tagName: str, belowThis: str | None = ...) -> None: ... - def tag_names(self, index: _TextIndex | None = ...) -> Tuple[str, ...]: ... + def tag_names(self, index: _TextIndex | None = ...) -> tuple[str, ...]: ... def tag_nextrange(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> tuple[str, str] | tuple[()]: ... def tag_prevrange(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> tuple[str, str] | tuple[()]: ... def tag_raise(self, tagName: str, aboveThis: str | None = ...) -> None: ... - def tag_ranges(self, tagName: str) -> Tuple[_tkinter.Tcl_Obj, ...]: ... + def tag_ranges(self, tagName: str) -> tuple[_tkinter.Tcl_Obj, ...]: ... # tag_remove and tag_delete are different def tag_remove(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... # TODO: window_* methods @@ -2959,10 +2959,10 @@ class PhotoImage(Image): str | list[str] | list[list[_Color]] - | list[Tuple[_Color, ...]] - | Tuple[str, ...] - | Tuple[list[_Color], ...] - | Tuple[Tuple[_Color, ...], ...] + | list[tuple[_Color, ...]] + | tuple[str, ...] + | tuple[list[_Color], ...] + | tuple[tuple[_Color, ...], ...] ), to: tuple[int, int] | None = ..., ) -> None: ... @@ -2986,8 +2986,8 @@ class BitmapImage(Image): maskfile: StrOrBytesPath = ..., ) -> None: ... -def image_names() -> Tuple[str, ...]: ... -def image_types() -> Tuple[str, ...]: ... +def image_names() -> tuple[str, ...]: ... +def image_types() -> tuple[str, ...]: ... class Spinbox(Widget, XView): def __init__( @@ -3006,7 +3006,7 @@ class Spinbox(Widget, XView): buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., # percent substitutions don't seem to be supported, it's similar to Entry's validation stuff - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3043,7 +3043,7 @@ class Spinbox(Widget, XView): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., vcmd: _EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., @@ -3063,7 +3063,7 @@ class Spinbox(Widget, XView): buttoncursor: _Cursor = ..., buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3099,7 +3099,7 @@ class Spinbox(Widget, XView): validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., vcmd: _EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., @@ -3119,7 +3119,7 @@ class Spinbox(Widget, XView): def scan(self, *args): ... def scan_mark(self, x): ... def scan_dragto(self, x): ... - def selection(self, *args: Any) -> Tuple[int, ...]: ... + def selection(self, *args: Any) -> tuple[int, ...]: ... def selection_adjust(self, index): ... def selection_clear(self): ... def selection_element(self, element: Any | None = ...): ... diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index 0fc7d6e8a3bc..b818d5e8253e 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog -from typing import IO, Any, ClassVar, Iterable, Tuple +from typing import IO, Any, ClassVar, Iterable from typing_extensions import Literal dialogstates: dict[Any, tuple[Any, Any]] @@ -64,7 +64,7 @@ def asksaveasfilename( *, confirmoverwrite: bool | None = ..., defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -74,7 +74,7 @@ def asksaveasfilename( def askopenfilename( *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -84,13 +84,13 @@ def askopenfilename( def askopenfilenames( *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> Literal[""] | Tuple[str, ...]: ... +) -> Literal[""] | tuple[str, ...]: ... def askdirectory( *, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = ..., parent: Misc | None = ..., title: str | None = ... ) -> str: ... # can be empty string @@ -101,7 +101,7 @@ def asksaveasfile( *, confirmoverwrite: bool | None = ..., defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -112,7 +112,7 @@ def askopenfile( mode: str = ..., *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., @@ -123,11 +123,11 @@ def askopenfiles( mode: str = ..., *, defaultextension: str | None = ..., - filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ..., + filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> Tuple[IO[Any], ...]: ... # can be empty tuple +) -> tuple[IO[Any], ...]: ... # can be empty tuple def test() -> None: ... diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index fccc0fbf1f0a..211e8ec9a0be 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,7 +1,7 @@ import _tkinter import sys import tkinter -from typing import Any, List, Tuple, Union, overload +from typing import Any, Union, overload from typing_extensions import Literal, TypedDict NORMAL: Literal["normal"] @@ -15,8 +15,8 @@ _FontDescription = Union[ # A font object constructed in Python Font, # ("Helvetica", 12, BOLD) - List[Any], - Tuple[Any, ...], + list[Any], + tuple[Any, ...], # A font object constructed in Tcl _tkinter.Tcl_Obj, ] @@ -102,8 +102,8 @@ class Font: def metrics(self, *, displayof: tkinter.Misc | None = ...) -> _MetricsDict: ... def measure(self, text: str, displayof: tkinter.Misc | None = ...) -> int: ... -def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> Tuple[str, ...]: ... -def names(root: tkinter.Misc | None = ...) -> Tuple[str, ...]: ... +def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> tuple[str, ...]: ... +def names(root: tkinter.Misc | None = ...) -> tuple[str, ...]: ... if sys.version_info >= (3, 10): def nametofont(name: str, root: tkinter.Misc | None = ...) -> Font: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 4914234c4eed..6842ab7b1108 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -1,5 +1,5 @@ import tkinter -from typing import Any, Tuple +from typing import Any from typing_extensions import Literal WINDOW: Literal["window"] @@ -194,7 +194,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def indicator_size(self, entry: str) -> int: ... def info_anchor(self) -> str: ... def info_bbox(self, entry: str) -> tuple[int, int, int, int]: ... - def info_children(self, entry: str | None = ...) -> Tuple[str, ...]: ... + def info_children(self, entry: str | None = ...) -> tuple[str, ...]: ... def info_data(self, entry: str) -> Any: ... def info_dragsite(self) -> str: ... def info_dropsite(self) -> str: ... @@ -203,7 +203,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def info_next(self, entry: str) -> str: ... def info_parent(self, entry: str) -> str: ... def info_prev(self, entry: str) -> str: ... - def info_selection(self) -> Tuple[str, ...]: ... + def info_selection(self) -> tuple[str, ...]: ... def item_cget(self, entry: str, col: int, opt: Any) -> Any: ... def item_configure(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> Any | None: ... def item_create(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... @@ -224,7 +224,7 @@ class CheckList(TixWidget): def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... def open(self, entrypath: str) -> None: ... - def getselection(self, mode: str = ...) -> Tuple[str, ...]: ... + def getselection(self, mode: str = ...) -> tuple[str, ...]: ... def getstatus(self, entrypath: str) -> str: ... def setstatus(self, entrypath: str, mode: str = ...) -> None: ... @@ -253,7 +253,7 @@ class TList(TixWidget, tkinter.XView, tkinter.YView): def info_down(self, index: int) -> int: ... def info_left(self, index: int) -> int: ... def info_right(self, index: int) -> int: ... - def info_selection(self) -> Tuple[int, ...]: ... + def info_selection(self) -> tuple[int, ...]: ... def info_size(self) -> int: ... def info_up(self, index: int) -> int: ... def nearest(self, x: int, y: int) -> int: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 3ef348d91ab2..f7319291da6d 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -2,7 +2,7 @@ import _tkinter import sys import tkinter from tkinter.font import _FontDescription -from typing import Any, Callable, Tuple, Union, overload +from typing import Any, Callable, Union, overload from typing_extensions import Literal, TypedDict def tclobjs_to_py(adict): ... @@ -24,7 +24,7 @@ class Style: def element_options(self, elementname): ... def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...): ... def theme_settings(self, themename, settings): ... - def theme_names(self) -> Tuple[str, ...]: ... + def theme_names(self) -> tuple[str, ...]: ... @overload def theme_use(self, themename: str) -> None: ... @overload @@ -234,7 +234,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented validatecommand: tkinter._EntryValidateCommand = ..., # undocumented - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented ) -> None: ... @@ -259,7 +259,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -287,7 +287,7 @@ class Combobox(Entry): textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -828,7 +828,7 @@ if sys.version_info >= (3, 7): *, background: tkinter._Color = ..., # undocumented class_: str = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., # undocumented font: _FontDescription = ..., # undocumented @@ -847,7 +847,7 @@ if sys.version_info >= (3, 7): to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., # undocumented wrap: bool = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -858,7 +858,7 @@ if sys.version_info >= (3, 7): cnf: dict[str, Any] | None = ..., *, background: tkinter._Color = ..., - command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., @@ -876,7 +876,7 @@ if sys.version_info >= (3, 7): to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | Tuple[str, ...] = ..., + values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -922,9 +922,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): master: tkinter.Misc | None = ..., *, class_: str = ..., - columns: str | list[str] | Tuple[str, ...] = ..., + columns: str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ..., + displaycolumns: str | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] | Literal["#all"] = ..., height: int = ..., name: str = ..., padding: tkinter._Padding = ..., @@ -933,7 +933,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): # # 'tree headings' is same as ['tree', 'headings'], and I wouldn't be # surprised if someone is using it. - show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ..., + show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -944,13 +944,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): self, cnf: dict[str, Any] | None = ..., *, - columns: str | list[str] | Tuple[str, ...] = ..., + columns: str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ..., + displaycolumns: str | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] | Literal["#all"] = ..., height: int = ..., padding: tkinter._Padding = ..., selectmode: Literal["extended", "browse", "none"] = ..., - show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ..., + show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -960,7 +960,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, item, column: _TreeviewColumnId | None = ...) -> tuple[int, int, int, int] | Literal[""]: ... # type: ignore[override] - def get_children(self, item: str | None = ...) -> Tuple[str, ...]: ... + def get_children(self, item: str | None = ...) -> tuple[str, ...]: ... def set_children(self, item: str, *newchildren: str) -> None: ... @overload def column(self, column: _TreeviewColumnId, option: Literal["width", "minwidth"]) -> int: ... @@ -1027,20 +1027,20 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): id: str = ..., # same as iid text: str = ..., image: tkinter._ImageSpec = ..., - values: list[Any] | Tuple[Any, ...] = ..., + values: list[Any] | tuple[Any, ...] = ..., open: bool = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., ) -> str: ... @overload def item(self, item: str, option: Literal["text"]) -> str: ... @overload def item(self, item: str, option: Literal["image"]) -> tuple[str] | Literal[""]: ... @overload - def item(self, item: str, option: Literal["values"]) -> Tuple[Any, ...] | Literal[""]: ... + def item(self, item: str, option: Literal["values"]) -> tuple[Any, ...] | Literal[""]: ... @overload def item(self, item: str, option: Literal["open"]) -> bool: ... # actually 0 or 1 @overload - def item(self, item: str, option: Literal["tags"]) -> Tuple[str, ...] | Literal[""]: ... + def item(self, item: str, option: Literal["tags"]) -> tuple[str, ...] | Literal[""]: ... @overload def item(self, item: str, option: str) -> Any: ... @overload @@ -1051,9 +1051,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): *, text: str = ..., image: tkinter._ImageSpec = ..., - values: list[Any] | Tuple[Any, ...] | Literal[""] = ..., + values: list[Any] | tuple[Any, ...] | Literal[""] = ..., open: bool = ..., - tags: str | list[str] | Tuple[str, ...] = ..., + tags: str | list[str] | tuple[str, ...] = ..., ) -> _TreeviewItemDict | None: ... def move(self, item: str, parent: str, index: int) -> None: ... reattach = move @@ -1062,13 +1062,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def prev(self, item: str) -> str: ... # returning empty string means first item def see(self, item: str) -> None: ... if sys.version_info >= (3, 8): - def selection(self) -> Tuple[str, ...]: ... + def selection(self) -> tuple[str, ...]: ... else: - def selection(self, selop: Any | None = ..., items: Any | None = ...) -> Tuple[str, ...]: ... - def selection_set(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_add(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_remove(self, items: str | list[str] | Tuple[str, ...]) -> None: ... - def selection_toggle(self, items: str | list[str] | Tuple[str, ...]) -> None: ... + def selection(self, selop: Any | None = ..., items: Any | None = ...) -> tuple[str, ...]: ... + def selection_set(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_add(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_remove(self, items: str | list[str] | tuple[str, ...]) -> None: ... + def selection_toggle(self, items: str | list[str] | tuple[str, ...]) -> None: ... @overload def set(self, item: str, column: None = ..., value: None = ...) -> dict[str, Any]: ... @overload @@ -1104,7 +1104,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): image: tkinter._ImageSpec = ..., ) -> _TreeviewTagDict | Any: ... # can be None but annoying to check @overload - def tag_has(self, tagname: str, item: None = ...) -> Tuple[str, ...]: ... + def tag_has(self, tagname: str, item: None = ...) -> tuple[str, ...]: ... @overload def tag_has(self, tagname: str, item: str) -> bool: ... diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index a8294adb653f..7614ebfe403e 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import StrOrBytesPath from builtins import open as _builtin_open from token import * # noqa: F403 -from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, TextIO, Tuple, Union +from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, TextIO, Union if sys.version_info < (3, 7): COMMENT: int @@ -12,7 +12,7 @@ if sys.version_info < (3, 7): cookie_re: Pattern[str] blank_re: Pattern[bytes] -_Position = Tuple[int, int] +_Position = tuple[int, int] class _TokenInfo(NamedTuple): type: int diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index bab75c9ada8d..e6b8176d8470 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -1,13 +1,13 @@ import sys import types from _typeshed import StrPath -from typing import Any, Callable, Mapping, Optional, Sequence, Tuple, TypeVar +from typing import Any, Callable, Mapping, Optional, Sequence, TypeVar from typing_extensions import ParamSpec _T = TypeVar("_T") _P = ParamSpec("_P") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] -_fileModuleFunction = Tuple[str, Optional[str], str] +_fileModuleFunction = tuple[str, Optional[str], str] class CoverageResults: def __init__( diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index f09a3cc70ade..2256d3a46785 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -1,16 +1,16 @@ import sys from _typeshed import SupportsWrite from types import FrameType, TracebackType -from typing import IO, Any, Generator, Iterable, Iterator, List, Mapping, Optional, Tuple, Type, overload +from typing import IO, Any, Generator, Iterable, Iterator, Mapping, Optional, 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: ... if sys.version_info >= (3, 10): @overload def print_exception( - __exc: Type[BaseException] | None, + __exc: type[BaseException] | None, value: BaseException | None = ..., tb: TracebackType | None = ..., limit: int | None = ..., @@ -23,7 +23,7 @@ if sys.version_info >= (3, 10): ) -> None: ... @overload def format_exception( - __exc: Type[BaseException] | None, + __exc: type[BaseException] | None, value: BaseException | None = ..., tb: TracebackType | None = ..., limit: int | None = ..., @@ -34,7 +34,7 @@ if sys.version_info >= (3, 10): else: def print_exception( - etype: Type[BaseException] | None, + etype: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ..., @@ -42,7 +42,7 @@ else: chain: bool = ..., ) -> None: ... def format_exception( - etype: Type[BaseException] | None, + etype: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ..., @@ -60,10 +60,10 @@ def format_list(extracted_list: list[FrameSummary]) -> list[str]: ... def print_list(extracted_list: list[FrameSummary], file: SupportsWrite[str] | None = ...) -> None: ... if sys.version_info >= (3, 10): - def format_exception_only(__exc: Type[BaseException] | None, value: BaseException | None = ...) -> list[str]: ... + def format_exception_only(__exc: type[BaseException] | None, value: BaseException | None = ...) -> list[str]: ... else: - def format_exception_only(etype: Type[BaseException] | None, value: BaseException | None) -> list[str]: ... + def format_exception_only(etype: type[BaseException] | None, value: BaseException | None) -> list[str]: ... def format_exc(limit: int | None = ..., chain: bool = ...) -> str: ... def format_tb(tb: TracebackType | None, limit: int | None = ...) -> list[str]: ... @@ -77,7 +77,7 @@ class TracebackException: __context__: TracebackException __suppress_context__: bool stack: StackSummary - exc_type: Type[BaseException] + exc_type: type[BaseException] filename: str lineno: int text: str @@ -86,7 +86,7 @@ class TracebackException: if sys.version_info >= (3, 10): def __init__( self, - exc_type: Type[BaseException], + exc_type: type[BaseException], exc_value: BaseException, exc_traceback: TracebackType, *, @@ -109,7 +109,7 @@ class TracebackException: else: def __init__( self, - exc_type: Type[BaseException], + exc_type: type[BaseException], exc_value: BaseException, exc_traceback: TracebackType, *, @@ -146,7 +146,7 @@ class FrameSummary(Iterable[Any]): def __getitem__(self, i: int) -> Any: ... def __iter__(self) -> Iterator[Any]: ... -class StackSummary(List[FrameSummary]): +class StackSummary(list[FrameSummary]): @classmethod def extract( cls, diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 4666bd1565a0..4d7bbb7994a6 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,6 +1,6 @@ import sys from _tracemalloc import * -from typing import Optional, Sequence, Tuple, Union, overload +from typing import Optional, Sequence, Union, overload from typing_extensions import SupportsIndex def get_object_traceback(obj: object) -> Traceback | None: ... @@ -35,7 +35,7 @@ class StatisticDiff: traceback: Traceback def __init__(self, traceback: Traceback, size: int, size_diff: int, count: int, count_diff: int) -> None: ... -_FrameTupleT = Tuple[str, int] +_FrameTupleT = tuple[str, int] class Frame: filename: str @@ -43,9 +43,9 @@ class Frame: def __init__(self, frame: _FrameTupleT) -> None: ... if sys.version_info >= (3, 9): - _TraceTupleT = Union[Tuple[int, int, Sequence[_FrameTupleT], Optional[int]], Tuple[int, int, Sequence[_FrameTupleT]]] + _TraceTupleT = Union[tuple[int, int, Sequence[_FrameTupleT], Optional[int]], tuple[int, int, Sequence[_FrameTupleT]]] else: - _TraceTupleT = Tuple[int, int, Sequence[_FrameTupleT]] + _TraceTupleT = tuple[int, int, Sequence[_FrameTupleT]] class Trace: domain: int diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 8542fc8bfa24..9d20877927c1 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -1,22 +1,22 @@ from tkinter import Canvas, Frame, PhotoImage -from typing import Any, Callable, ClassVar, Dict, Sequence, Tuple, TypeVar, Union, overload +from typing import Any, Callable, ClassVar, Sequence, TypeVar, Union, overload # Note: '_Color' is the alias we use for arguments and _AnyColor is the # alias we use for return types. Really, these two aliases should be the # same, but as per the "no union returns" typeshed policy, we'll return # Any instead. -_Color = Union[str, Tuple[float, float, float]] +_Color = Union[str, tuple[float, float, float]] _AnyColor = Any # TODO: Replace this with a TypedDict once it becomes standardized. -_PenState = Dict[str, Any] +_PenState = dict[str, Any] _Speed = Union[str, float] -_PolygonCoords = Sequence[Tuple[float, float]] +_PolygonCoords = Sequence[tuple[float, float]] # TODO: Type this more accurately # Vec2D is actually a custom subclass of 'tuple'. -Vec2D = Tuple[float, float] +Vec2D = tuple[float, float] class ScrolledCanvas(Frame): ... @@ -251,7 +251,7 @@ class RawTurtle(TPen, TNavigator): # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp(self) -> Any: ... - def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... + def clearstamp(self, stampid: int | tuple[int, ...]) -> None: ... def clearstamps(self, n: int | None = ...) -> None: ... def filling(self) -> bool: ... def begin_fill(self) -> None: ... @@ -516,7 +516,7 @@ def tilt(angle: float) -> None: ... # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp() -> Any: ... -def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... +def clearstamp(stampid: int | tuple[int, ...]) -> None: ... def clearstamps(n: int | None = ...) -> None: ... def filling() -> bool: ... def begin_fill() -> None: ... diff --git a/stdlib/types.pyi b/stdlib/types.pyi index b018d56acd6a..e7cf358631c2 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -16,8 +16,8 @@ from typing import ( KeysView, Mapping, MutableSequence, - Tuple, - Type, + + TypeVar, ValuesView, overload, @@ -42,9 +42,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 +56,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 +76,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 +95,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 +114,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 +136,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 +159,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 = ..., @@ -221,7 +221,7 @@ class GeneratorType(Generator[_T_co, _T_contra, _V_co]): def send(self, __arg: _T_contra) -> _T_co: ... @overload def throw( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> _T_co: ... @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... @@ -237,7 +237,7 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): def asend(self, __val: _T_contra) -> Awaitable[_T_co]: ... @overload def athrow( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> Awaitable[_T_co]: ... @overload def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ... @@ -258,7 +258,7 @@ class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]): def send(self, __arg: _T_contra) -> _T_co: ... @overload def throw( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> _T_co: ... @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... @@ -281,8 +281,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 +385,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 +418,8 @@ if sys.version_info >= (3, 8): if sys.version_info >= (3, 9): class GenericAlias: __origin__: type - __args__: Tuple[Any, ...] - __parameters__: Tuple[Any, ...] + __args__: tuple[Any, ...] + __parameters__: tuple[Any, ...] def __init__(self, origin: type, args: Any) -> None: ... def __getattr__(self, name: str) -> Any: ... # incomplete @@ -433,6 +433,6 @@ if sys.version_info >= (3, 10): NotImplementedType = _NotImplementedType # noqa F811 from builtins @final class UnionType: - __args__: Tuple[Any, ...] + __args__: tuple[Any, ...] def __or__(self, obj: Any) -> UnionType: ... def __ror__(self, obj: Any) -> UnionType: ... diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 3eb41c797f4a..cd6290991d36 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -22,7 +22,7 @@ from typing import ( NewType as NewType, NoReturn as NoReturn, Text as Text, - Tuple, + Type as Type, TypeVar, ValuesView, @@ -87,7 +87,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/_log.pyi b/stdlib/unittest/_log.pyi index f9e406199cd4..947a2158ddff 100644 --- a/stdlib/unittest/_log.pyi +++ b/stdlib/unittest/_log.pyi @@ -1,7 +1,7 @@ import logging import sys from types import TracebackType -from typing import ClassVar, Generic, NamedTuple, Type, TypeVar +from typing import ClassVar, Generic, NamedTuple, TypeVar from unittest.case import TestCase _L = TypeVar("_L", None, _LoggingWatcher) @@ -23,5 +23,5 @@ class _AssertLogsContext(Generic[_L]): def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... def __enter__(self) -> _L: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 602a5020b9d4..06156167da42 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -19,8 +19,8 @@ from typing import ( NoReturn, Pattern, Sequence, - Tuple, - Type, + + TypeVar, overload, ) @@ -56,7 +56,7 @@ else: def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... def __enter__(self) -> _LoggingWatcher: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... if sys.version_info >= (3, 8): @@ -72,7 +72,7 @@ class SkipTest(Exception): def __init__(self, reason: str) -> None: ... class TestCase: - failureException: Type[BaseException] + failureException: type[BaseException] longMessage: bool maxDiff: int | None # undocumented @@ -102,8 +102,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 +111,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 +130,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 +152,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: ... @@ -194,13 +194,13 @@ class TestCase: def assertRegex(self, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... def assertNotRegex(self, text: AnyStr, unexpected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... def assertCountEqual(self, first: Iterable[Any], second: Iterable[Any], msg: Any = ...) -> None: ... - def addTypeEqualityFunc(self, typeobj: Type[Any], function: Callable[..., None]) -> None: ... + def addTypeEqualityFunc(self, typeobj: type[Any], function: Callable[..., None]) -> None: ... def assertMultiLineEqual(self, first: str, second: str, msg: Any = ...) -> None: ... def assertSequenceEqual( - self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: Type[Sequence[Any]] | None = ... + 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 +231,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 +251,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 +260,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]: ... @@ -282,7 +282,7 @@ class _AssertRaisesContext(Generic[_E]): exception: _E def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -294,5 +294,5 @@ class _AssertWarnsContext: warnings: list[WarningMessage] def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 394e9c9166eb..8b3c82233cec 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -3,15 +3,15 @@ import unittest.case import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Callable, List, Pattern, Sequence, Type +from typing import Any, Callable, Pattern, Sequence _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] class TestLoader: - errors: list[Type[BaseException]] + errors: list[type[BaseException]] testMethodPrefix: str sortTestMethodsUsing: _SortComparisonMethod @@ -19,18 +19,18 @@ class TestLoader: testNamePatterns: list[str] | None suiteClass: _SuiteClass - def loadTestsFromTestCase(self, testCaseClass: Type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ... + def loadTestsFromTestCase(self, testCaseClass: type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ... def loadTestsFromModule(self, module: ModuleType, *args: Any, pattern: Any = ...) -> unittest.suite.TestSuite: ... def loadTestsFromName(self, name: str, module: ModuleType | None = ...) -> unittest.suite.TestSuite: ... def loadTestsFromNames(self, names: Sequence[str], module: ModuleType | None = ...) -> unittest.suite.TestSuite: ... - def getTestCaseNames(self, testCaseClass: Type[unittest.case.TestCase]) -> Sequence[str]: ... + def getTestCaseNames(self, testCaseClass: type[unittest.case.TestCase]) -> Sequence[str]: ... def discover(self, start_dir: str, pattern: str = ..., top_level_dir: str | None = ...) -> unittest.suite.TestSuite: ... defaultTestLoader: TestLoader if sys.version_info >= (3, 7): def getTestCaseNames( - testCaseClass: Type[unittest.case.TestCase], + testCaseClass: type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ..., testNamePatterns: list[str] | None = ..., @@ -38,11 +38,11 @@ if sys.version_info >= (3, 7): else: def getTestCaseNames( - testCaseClass: Type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ... + testCaseClass: type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ... ) -> Sequence[str]: ... def makeSuite( - testCaseClass: Type[unittest.case.TestCase], + testCaseClass: type[unittest.case.TestCase], prefix: str = ..., sortUsing: _SortComparisonMethod = ..., suiteClass: _SuiteClass = ..., diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 6d1117ecaf79..16c48ebdd990 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -4,7 +4,7 @@ import unittest.loader import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Iterable, Protocol, Type +from typing import Any, Iterable, Protocol MAIN_EXAMPLES: str MODULE_EXAMPLES: str @@ -30,7 +30,7 @@ class TestProgram: module: None | str | ModuleType = ..., defaultTest: str | Iterable[str] | None = ..., argv: list[str] | None = ..., - testRunner: Type[_TestRunner] | _TestRunner | None = ..., + testRunner: type[_TestRunner] | _TestRunner | None = ..., testLoader: unittest.loader.TestLoader = ..., exit: bool = ..., verbosity: int = ..., diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index a84ab67b49f8..9d2f4f5bf270 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -1,8 +1,8 @@ import sys -from typing import Any, Awaitable, Callable, Generic, Iterable, List, Mapping, Sequence, Tuple, Type, TypeVar, overload +from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, TypeVar, overload _T = TypeVar("_T") -_TT = TypeVar("_TT", bound=Type[Any]) +_TT = TypeVar("_TT", bound=type[Any]) _R = TypeVar("_R") if sys.version_info >= (3, 8): @@ -96,7 +96,7 @@ class _Call(tuple[Any, ...]): call: _Call -class _CallList(List[_Call]): +class _CallList(list[_Call]): def __contains__(self, value: Any) -> bool: ... class Base: @@ -106,10 +106,10 @@ class NonCallableMock(Base, Any): def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ... def __init__( self, - spec: list[str] | object | Type[object] | None = ..., + spec: list[str] | object | type[object] | None = ..., wraps: Any | None = ..., name: str | None = ..., - spec_set: list[str] | object | Type[object] | None = ..., + spec_set: list[str] | object | type[object] | None = ..., parent: NonCallableMock | None = ..., _spec_state: Any | None = ..., _new_name: str = ..., @@ -155,7 +155,7 @@ class NonCallableMock(Base, Any): call_args_list: _CallList mock_calls: _CallList def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ... - def _call_matcher(self, _call: Tuple[_Call, ...]) -> _Call: ... + def _call_matcher(self, _call: tuple[_Call, ...]) -> _Call: ... def _get_child_mock(self, **kw: Any) -> NonCallableMock: ... class CallableMixin(Base): @@ -258,7 +258,7 @@ class _patch_dict: class _patcher: TEST_PREFIX: str - dict: Type[_patch_dict] + dict: type[_patch_dict] if sys.version_info >= (3, 8): # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any]. # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock], diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 0ec4e9170388..1c79f8ab648c 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -1,8 +1,8 @@ import unittest.case from types import TracebackType -from typing import Any, Callable, TextIO, Tuple, Type, TypeVar, Union +from typing import Any, Callable, TextIO, 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..8f628591a0b4 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -1,7 +1,7 @@ import unittest.case import unittest.result import unittest.suite -from typing import Callable, TextIO, Type +from typing import Callable, TextIO _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] @@ -27,7 +27,7 @@ class TextTestRunner(object): failfast: bool = ..., buffer: bool = ..., resultclass: _ResultClassType | None = ..., - warnings: Type[Warning] | None = ..., + warnings: type[Warning] | None = ..., *, tb_locals: bool = ..., ) -> None: ... diff --git a/stdlib/unittest/util.pyi b/stdlib/unittest/util.pyi index ab6ed053a6ff..680ca24b7c33 100644 --- a/stdlib/unittest/util.pyi +++ b/stdlib/unittest/util.pyi @@ -1,7 +1,7 @@ -from typing import Any, Sequence, Tuple, TypeVar +from typing import Any, Sequence, TypeVar _T = TypeVar("_T") -_Mismatch = Tuple[_T, _T, int] +_Mismatch = tuple[_T, _T, int] _MAX_LENGTH: int _PLACEHOLDER_LEN: int diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index a5afbdc26bf2..7404b5382014 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, AnyStr, Callable, Generic, Mapping, NamedTuple, Sequence, Tuple, Union, overload +from typing import Any, AnyStr, Callable, Generic, Mapping, NamedTuple, Sequence, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -35,7 +35,7 @@ class _NetlocResultMixinBase(Generic[AnyStr]): class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ... class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ... -class _DefragResultBase(Tuple[Any, ...], Generic[AnyStr]): +class _DefragResultBase(tuple[Any, ...], Generic[AnyStr]): url: AnyStr fragment: AnyStr diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 3c8a6facde6f..3749d7a390ea 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -4,7 +4,7 @@ from _typeshed import StrOrBytesPath from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar -from typing import IO, Any, Callable, ClassVar, Mapping, NoReturn, Pattern, Sequence, Tuple, TypeVar, overload +from typing import IO, Any, Callable, ClassVar, Mapping, NoReturn, Pattern, Sequence, TypeVar, overload from urllib.error import HTTPError from urllib.response import addclosehook, addinfourl @@ -196,9 +196,9 @@ class HTTPSHandler(AbstractHTTPHandler): def https_request(self, request: Request) -> Request: ... # undocumented class FileHandler(BaseHandler): - names: ClassVar[Tuple[str, ...] | None] # undocumented + names: ClassVar[tuple[str, ...] | None] # undocumented def file_open(self, req: Request) -> addinfourl: ... - def get_names(self) -> Tuple[str, ...]: ... # undocumented + def get_names(self) -> tuple[str, ...]: ... # undocumented def open_local_file(self, req: Request) -> addinfourl: ... # undocumented class DataHandler(BaseHandler): diff --git a/stdlib/urllib/response.pyi b/stdlib/urllib/response.pyi index 647ebf874432..c52b96e0796d 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import Self from email.message import Message from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Tuple, Type, TypeVar +from typing import IO, Any, BinaryIO, Callable, Iterable, TypeVar _AIUT = TypeVar("_AIUT", bound=addbase) @@ -11,7 +11,7 @@ class addbase(BinaryIO): def __init__(self, fp: IO[bytes]) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def __iter__(self: _AIUT) -> _AIUT: ... def __next__(self) -> bytes: ... @@ -37,7 +37,7 @@ class addbase(BinaryIO): class addclosehook(addbase): closehook: Callable[..., object] - hookargs: Tuple[Any, ...] + hookargs: tuple[Any, ...] def __init__(self, fp: IO[bytes], closehook: Callable[..., object], *hookargs: Any) -> None: ... class addinfo(addbase): diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index da13d819fbdf..782c0491ffb2 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -1,10 +1,10 @@ import sys -from typing import Any, Tuple +from typing import Any # Because UUID has properties called int and bytes we need to rename these temporarily. _Int = int _Bytes = bytes -_FieldsType = Tuple[int, int, int, int, int, int] +_FieldsType = tuple[int, int, int, int, int, int] if sys.version_info >= (3, 7): from enum import Enum diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index b1c9f4dda8ed..714356162fde 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,32 +1,32 @@ 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, Sequence, TextIO, overload from typing_extensions import Literal _ActionKind = Literal["default", "error", "ignore", "always", "module", "once"] -filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] # undocumented, do not mutate +filters: Sequence[tuple[str, str | None, type[Warning], str | None, int]] # undocumented, do not mutate def showwarning( - message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... + message: Warning | str, category: type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... ) -> None: ... -def formatwarning(message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ... +def formatwarning(message: Warning | str, category: type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ... def filterwarnings( action: _ActionKind, message: str = ..., - category: Type[Warning] = ..., + category: type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ..., ) -> None: ... -def simplefilter(action: _ActionKind, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ... +def simplefilter(action: _ActionKind, category: type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ... def resetwarnings() -> None: ... class _OptionError(Exception): ... class WarningMessage: message: Warning | str - category: Type[Warning] + category: type[Warning] filename: str lineno: int file: TextIO | None @@ -35,7 +35,7 @@ class WarningMessage: def __init__( self, message: Warning | str, - category: Type[Warning], + category: type[Warning], filename: str, lineno: int, file: TextIO | None = ..., @@ -52,7 +52,7 @@ class catch_warnings: def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... def __enter__(self) -> list[WarningMessage] | None: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _catch_warnings_without_records(catch_warnings): diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 16ebba39ef17..5dc4a1b7cc5a 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -1,5 +1,5 @@ from _weakrefset import WeakSet as WeakSet -from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, Tuple, Type, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, TypeVar, overload from _weakref import ( CallableProxyType as CallableProxyType, @@ -17,7 +17,7 @@ _KT = TypeVar("_KT") _VT = TypeVar("_VT") _CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) -ProxyTypes: Tuple[Type[Any], ...] +ProxyTypes: tuple[type[Any], ...] class WeakMethod(ref[_CallableT], Generic[_CallableT]): def __new__(cls, meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> WeakMethod[_CallableT]: ... @@ -81,7 +81,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): class finalize: def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... def __call__(self, _: Any = ...) -> Any | None: ... - def detach(self) -> tuple[Any, Any, Tuple[Any, ...], dict[str, Any]] | None: ... - def peek(self) -> tuple[Any, Any, Tuple[Any, ...], dict[str, Any]] | None: ... + def detach(self) -> tuple[Any, Any, tuple[Any, ...], dict[str, Any]] | None: ... + def peek(self) -> tuple[Any, Any, tuple[Any, ...], dict[str, Any]] | None: ... alive: bool atexit: bool diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index 5fff1104e246..cbc51b82928e 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Any, Type, Union +from typing import Any, Union from typing_extensions import final _KeyType = Union[HKEYType, int] @@ -95,7 +95,7 @@ class HKEYType: def __int__(self) -> int: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def Close(self) -> None: ... def Detach(self) -> int: ... diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index ac1e56b7664e..11f474660b05 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -1,12 +1,12 @@ from abc import abstractmethod from types import TracebackType -from typing import IO, Callable, MutableMapping, Optional, Tuple, Type +from typing import IO, Callable, MutableMapping, Optional 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]: ... @@ -23,8 +23,8 @@ class BaseHandler: os_environ: MutableMapping[str, str] - wsgi_file_wrapper: Type[FileWrapper] | None - headers_class: Type[Headers] # undocumented + wsgi_file_wrapper: type[FileWrapper] | None + headers_class: type[Headers] # undocumented traceback_limit: int | None error_status: 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/simple_server.pyi b/stdlib/wsgiref/simple_server.pyi index 76d0b269793d..7e746451d380 100644 --- a/stdlib/wsgiref/simple_server.pyi +++ b/stdlib/wsgiref/simple_server.pyi @@ -1,5 +1,5 @@ from http.server import BaseHTTPRequestHandler, HTTPServer -from typing import Type, TypeVar, overload +from typing import TypeVar, overload from .handlers import SimpleHandler from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment @@ -30,8 +30,8 @@ def demo_app(environ: WSGIEnvironment, start_response: StartResponse) -> list[by _S = TypeVar("_S", bound=WSGIServer) @overload -def make_server(host: str, port: int, app: WSGIApplication, *, handler_class: Type[WSGIRequestHandler] = ...) -> WSGIServer: ... +def make_server(host: str, port: int, app: WSGIApplication, *, handler_class: type[WSGIRequestHandler] = ...) -> WSGIServer: ... @overload def make_server( - host: str, port: int, app: WSGIApplication, server_class: Type[_S], handler_class: Type[WSGIRequestHandler] = ... + host: str, port: int, app: WSGIApplication, server_class: type[_S], handler_class: type[WSGIRequestHandler] = ... ) -> _S: ... diff --git a/stdlib/xml/dom/minicompat.pyi b/stdlib/xml/dom/minicompat.pyi index 46d55c666cb0..e37b7cd89176 100644 --- a/stdlib/xml/dom/minicompat.pyi +++ b/stdlib/xml/dom/minicompat.pyi @@ -1,17 +1,17 @@ -from typing import Any, Iterable, List, Tuple, Type, TypeVar +from typing import Any, Iterable, TypeVar _T = TypeVar("_T") -StringTypes: tuple[Type[str]] +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] def __radd__(self, other: Iterable[_T]) -> NodeList[_T]: ... -def defproperty(klass: Type[Any], name: str, doc: str) -> None: ... +def defproperty(klass: type[Any], name: str, doc: str) -> None: ... diff --git a/stdlib/xml/dom/pulldom.pyi b/stdlib/xml/dom/pulldom.pyi index 530c1988e743..c2b7aa0772fa 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, Sequence, Tuple, Union +from typing import IO, Any, Sequence, Union from typing_extensions import Literal from xml.dom.minidom import Document, DOMImplementation, Element, Text from xml.sax.handler import ContentHandler @@ -17,7 +17,7 @@ CHARACTERS: Literal["CHARACTERS"] _DocumentFactory = Union[DOMImplementation, None] _Node = Union[Document, Element, Text] -_Event = Tuple[ +_Event = tuple[ Literal[ Literal["START_ELEMENT"], Literal["END_ELEMENT"], diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index db4bd6a4e958..5a2dd69c1bee 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -1,11 +1,11 @@ -from typing import Callable, Generator, List, Pattern, Tuple, TypeVar +from typing import Callable, Generator, Pattern, TypeVar from xml.etree.ElementTree import Element xpath_tokenizer_re: Pattern[str] -_token = Tuple[str, str] +_token = tuple[str, str] _next = Callable[[], _token] -_callback = Callable[[_SelectorContext, List[Element]], Generator[Element, None, None]] +_callback = Callable[[_SelectorContext, list[Element]], Generator[Element, None, None]] def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = ...) -> Generator[_token, None, None]: ... def get_parent_map(context: _SelectorContext) -> dict[Element, Element]: ... diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 6ee578b9aa81..6db1278de6d1 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -4,7 +4,7 @@ from typing import ( IO, Any, Callable, - Dict, + Generator, ItemsView, Iterable, @@ -257,7 +257,7 @@ def fromstringlist(sequence: Sequence[str | bytes], parser: XMLParser | None = . # TreeBuilder is called by client code (they could pass strs, bytes or whatever); # but we don't want to use a too-broad type, or it would be too hard to write # elementfactories. -_ElementFactory = Callable[[Any, Dict[Any, Any]], Element] +_ElementFactory = Callable[[Any, dict[Any, Any]], Element] class TreeBuilder: if sys.version_info >= (3, 8): diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index b715e8b2928a..03a6ac69f5b7 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -6,16 +6,16 @@ from _typeshed import Self, SupportsRead, SupportsWrite from datetime import datetime from io import BytesIO from types import TracebackType -from typing import Any, Callable, Dict, Iterable, List, Mapping, Protocol, Tuple, Type, Union, overload +from typing import Any, Callable, Iterable, Mapping, Protocol, Union, overload from typing_extensions import Literal class _SupportsTimeTuple(Protocol): def timetuple(self) -> time.struct_time: ... _DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple] -_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime, DateTime, Binary] -_XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time] -_HostType = Union[Tuple[str, Dict[str, str]], str] +_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime, DateTime, Binary] +_XMLDate = Union[int, datetime, tuple[int, ...], time.struct_time] +_HostType = Union[tuple[str, dict[str, str]], str] def escape(s: str) -> str: ... # undocumented @@ -63,7 +63,7 @@ def _strftime(value: _XMLDate) -> str: ... # undocumented class DateTime: value: str # undocumented - def __init__(self, value: int | str | datetime | time.struct_time | Tuple[int, ...] = ...) -> None: ... + def __init__(self, value: int | str | datetime | time.struct_time | tuple[int, ...] = ...) -> None: ... def __lt__(self, other: _DateTimeComparable) -> bool: ... def __le__(self, other: _DateTimeComparable) -> bool: ... def __gt__(self, other: _DateTimeComparable) -> bool: ... @@ -86,7 +86,7 @@ class Binary: def _binary(data: bytes) -> Binary: ... # undocumented -WRAPPERS: tuple[Type[DateTime], Type[Binary]] # undocumented +WRAPPERS: tuple[type[DateTime], type[Binary]] # undocumented class ExpatParser: # undocumented def __init__(self, target: Unmarshaller) -> None: ... @@ -96,7 +96,7 @@ class ExpatParser: # undocumented class Marshaller: dispatch: dict[ - Type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None] + type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None] ] # TODO: Replace 'Any' with some kind of binding memo: dict[Any, None] @@ -135,7 +135,7 @@ class Unmarshaller: _use_datetime: bool _use_builtin_types: bool def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ... - def close(self) -> Tuple[_Marshallable, ...]: ... + def close(self) -> tuple[_Marshallable, ...]: ... def getmethodname(self) -> str | None: ... def xml(self, encoding: str, standalone: Any) -> None: ... # Standalone is ignored def start(self, tag: str, attrs: dict[str, str]) -> None: ... @@ -159,7 +159,7 @@ class Unmarshaller: class _MultiCallMethod: # undocumented - __call_list: list[tuple[str, Tuple[_Marshallable, ...]]] + __call_list: list[tuple[str, tuple[_Marshallable, ...]]] __name: str def __init__(self, call_list: list[tuple[str, _Marshallable]], name: str) -> None: ... def __getattr__(self, name: str) -> _MultiCallMethod: ... @@ -174,7 +174,7 @@ class MultiCallIterator: # undocumented class MultiCall: __server: ServerProxy - __call_list: list[tuple[str, Tuple[_Marshallable, ...]]] + __call_list: list[tuple[str, tuple[_Marshallable, ...]]] def __init__(self, server: ServerProxy) -> None: ... def __getattr__(self, item: str) -> _MultiCallMethod: ... def __call__(self) -> MultiCallIterator: ... @@ -186,13 +186,13 @@ FastUnmarshaller: Unmarshaller | None def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[ExpatParser, Unmarshaller]: ... def dumps( - params: Fault | Tuple[_Marshallable, ...], + params: Fault | tuple[_Marshallable, ...], methodname: str | None = ..., methodresponse: bool | None = ..., encoding: str | None = ..., allow_none: bool = ..., ) -> str: ... -def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[Tuple[_Marshallable, ...], str | None]: ... +def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[tuple[_Marshallable, ...], str | None]: ... def gzip_encode(data: bytes) -> bytes: ... # undocumented def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ... # undocumented @@ -204,9 +204,9 @@ class GzipDecodedResponse(gzip.GzipFile): # undocumented class _Method: # undocumented - __send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable] + __send: Callable[[str, tuple[_Marshallable, ...]], _Marshallable] __name: str - def __init__(self, send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ... + def __init__(self, send: Callable[[str, tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ... def __getattr__(self, name: str) -> _Method: ... def __call__(self, *args: _Marshallable) -> _Marshallable: ... @@ -228,10 +228,10 @@ class Transport: ) -> None: ... else: def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ... - def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> Tuple[_Marshallable, ...]: ... + def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> tuple[_Marshallable, ...]: ... def single_request( self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ... - ) -> Tuple[_Marshallable, ...]: ... + ) -> tuple[_Marshallable, ...]: ... def getparser(self) -> tuple[ExpatParser, Unmarshaller]: ... def get_host_info(self, host: _HostType) -> tuple[str, list[tuple[str, str]], dict[str, str]]: ... def make_connection(self, host: _HostType) -> http.client.HTTPConnection: ... @@ -239,7 +239,7 @@ class Transport: def send_request(self, host: _HostType, handler: str, request_body: bytes, debug: bool) -> http.client.HTTPConnection: ... def send_headers(self, connection: http.client.HTTPConnection, headers: list[tuple[str, str]]) -> None: ... def send_content(self, connection: http.client.HTTPConnection, request_body: bytes) -> None: ... - def parse_response(self, response: http.client.HTTPResponse) -> Tuple[_Marshallable, ...]: ... + def parse_response(self, response: http.client.HTTPResponse) -> tuple[_Marshallable, ...]: ... class SafeTransport(Transport): @@ -301,9 +301,9 @@ class ServerProxy: def __call__(self, attr: str) -> Callable[[], None] | Transport: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + 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..650a659452e0 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -3,11 +3,11 @@ import pydoc import socketserver import sys from datetime import datetime -from typing import Any, Callable, Dict, Iterable, List, Mapping, Pattern, Protocol, Tuple, Type, Union +from typing import Any, Callable, Iterable, Mapping, Pattern, Protocol, Union from xmlrpc.client import Fault # TODO: Recursive type on tuple, list, dict -_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime] +_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime] # The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy class _DispatchArity0(Protocol): @@ -53,7 +53,7 @@ class SimpleXMLRPCDispatcher: # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ..., + dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = ..., path: Any | None = ..., ) -> str: ... # undocumented def system_listMethods(self) -> list[str]: ... # undocumented @@ -81,7 +81,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher): def __init__( self, addr: tuple[str, int], - requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., + requestHandler: type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: str | None = ..., @@ -97,7 +97,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented def __init__( self, addr: tuple[str, int], - requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., + requestHandler: type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: str | None = ..., @@ -109,7 +109,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ..., + dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = ..., path: Any | None = ..., ) -> str: ... @@ -150,7 +150,7 @@ class DocXMLRPCServer(SimpleXMLRPCServer, XMLRPCDocGenerator): def __init__( self, addr: tuple[str, int], - requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., + requestHandler: type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: str | None = ..., diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 710b9b237b4c..4244229a1ad7 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -3,10 +3,10 @@ import sys from _typeshed import Self, StrPath from os import PathLike from types import TracebackType -from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, Tuple, Type, overload +from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, 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"] @@ -145,7 +145,7 @@ class ZipFile: ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def close(self) -> None: ... def getinfo(self, name: str) -> ZipInfo: ... diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 4f924e0cc4bf..1170b354874a 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -1,7 +1,7 @@ import typing from _typeshed import StrPath from datetime import tzinfo -from typing import Any, Iterable, Protocol, Sequence, Type +from typing import Any, Iterable, Protocol, Sequence _T = typing.TypeVar("_T", bound="ZoneInfo") @@ -14,9 +14,9 @@ class ZoneInfo(tzinfo): def key(self) -> str: ... def __init__(self, key: str) -> None: ... @classmethod - def no_cache(cls: Type[_T], key: str) -> _T: ... + def no_cache(cls: type[_T], key: str) -> _T: ... @classmethod - def from_file(cls: Type[_T], __fobj: _IOBytes, key: str | None = ...) -> _T: ... + def from_file(cls: type[_T], __fobj: _IOBytes, key: str | None = ...) -> _T: ... @classmethod def clear_cache(cls, *, only_keys: Iterable[str] = ...) -> None: ... diff --git a/stubs/Deprecated/deprecated/classic.pyi b/stubs/Deprecated/deprecated/classic.pyi index b6f546235047..160968742162 100644 --- a/stubs/Deprecated/deprecated/classic.pyi +++ b/stubs/Deprecated/deprecated/classic.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Type, TypeVar, overload +from typing import Any, Callable, TypeVar, overload from typing_extensions import Literal _F = TypeVar("_F", bound=Callable[..., Any]) @@ -8,9 +8,9 @@ class ClassicAdapter: reason: str version: str action: _Actions | None - category: Type[Warning] + category: type[Warning] def __init__( - self, reason: str = ..., version: str = ..., action: _Actions | None = ..., category: Type[Warning] = ... + self, reason: str = ..., version: str = ..., action: _Actions | None = ..., category: type[Warning] = ... ) -> None: ... def get_deprecated_msg(self, wrapped: Callable[..., Any], instance: object) -> str: ... def __call__(self, wrapped: _F) -> Callable[[_F], _F]: ... @@ -19,5 +19,5 @@ class ClassicAdapter: def deprecated(__wrapped: _F) -> _F: ... @overload def deprecated( - reason: str = ..., *, version: str = ..., action: _Actions | None = ..., category: Type[Warning] | None = ... + reason: str = ..., *, version: str = ..., action: _Actions | None = ..., category: type[Warning] | None = ... ) -> Callable[[_F], _F]: ... diff --git a/stubs/Deprecated/deprecated/sphinx.pyi b/stubs/Deprecated/deprecated/sphinx.pyi index e5acd9406e68..7e619964542c 100644 --- a/stubs/Deprecated/deprecated/sphinx.pyi +++ b/stubs/Deprecated/deprecated/sphinx.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Type, TypeVar +from typing import Any, Callable, TypeVar from typing_extensions import Literal from .classic import ClassicAdapter, _Actions @@ -10,14 +10,14 @@ class SphinxAdapter(ClassicAdapter): reason: str version: str action: _Actions | None - category: Type[Warning] + category: type[Warning] def __init__( self, directive: Literal["versionadded", "versionchanged", "deprecated"], reason: str = ..., version: str = ..., action: _Actions | None = ..., - category: Type[Warning] = ..., + category: type[Warning] = ..., ) -> None: ... def __call__(self, wrapped: _F) -> Callable[[_F], _F]: ... @@ -29,5 +29,5 @@ def deprecated( line_length: int = ..., *, action: _Actions | None = ..., - category: Type[Warning] | None = ..., + category: type[Warning] | None = ..., ) -> Callable[[_F], _F]: ... diff --git a/stubs/Markdown/markdown/blockparser.pyi b/stubs/Markdown/markdown/blockparser.pyi index a747902f718e..e51db23729a2 100644 --- a/stubs/Markdown/markdown/blockparser.pyi +++ b/stubs/Markdown/markdown/blockparser.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, TypeVar +from typing import Any, Iterable, TypeVar from xml.etree.ElementTree import Element, ElementTree from . import Markdown @@ -6,7 +6,7 @@ from .util import Registry _T = TypeVar("_T") -class State(List[_T]): +class State(list[_T]): def set(self, state: _T) -> None: ... def reset(self) -> None: ... def isstate(self, state: _T) -> bool: ... diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 4d7113496b60..ca3fb6ff0cc5 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsRead, SupportsWrite from collections.abc import Iterable, Iterator, MutableMapping from pathlib import Path -from typing import Any, Callable, Dict, Protocol, Sequence, SupportsBytes, Tuple, Union +from typing import Any, Callable, Protocol, Sequence, SupportsBytes, Union from typing_extensions import Literal from ._imaging import ( @@ -16,13 +16,13 @@ from .ImagePalette import ImagePalette _Mode = Literal["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"] _Resample = Literal[0, 1, 2, 3, 4, 5] -_Size = Tuple[int, int] -_Box = Tuple[int, int, int, int] +_Size = tuple[int, int] +_Box = tuple[int, int, int, int] _ConversionMatrix = Union[ - Tuple[float, float, float, float], Tuple[float, float, float, float, float, float, float, float, float, float, float, float], + tuple[float, float, float, float], tuple[float, float, float, float, float, float, float, float, float, float, float, float], ] -_Color = Union[float, Tuple[float, ...]] +_Color = Union[float, tuple[float, ...]] class _Writeable(SupportsWrite[bytes], Protocol): def seek(self, __offset: int) -> Any: ... @@ -88,7 +88,7 @@ MODES: list[_Mode] def getmodebase(mode: _Mode) -> Literal["L", "RGB"]: ... def getmodetype(mode: _Mode) -> Literal["L", "I", "F"]: ... -def getmodebandnames(mode: _Mode) -> Tuple[str, ...]: ... +def getmodebandnames(mode: _Mode) -> tuple[str, ...]: ... def getmodebands(mode: _Mode) -> int: ... def preinit() -> None: ... def init() -> None: ... @@ -99,7 +99,7 @@ class _E: def __add__(self, other) -> _E: ... def __mul__(self, other) -> _E: ... -_ImageState = Tuple[Dict[str, Any], str, Tuple[int, int], Any, bytes] +_ImageState = tuple[dict[str, Any], str, tuple[int, int], Any, bytes] class Image: format: Any @@ -149,7 +149,7 @@ class Image: def crop(self, box: _Box | None = ...) -> Image: ... def draft(self, mode: str, size: _Size) -> None: ... def filter(self, filter: Filter | Callable[[], Filter]) -> Image: ... - def getbands(self) -> Tuple[str, ...]: ... + def getbands(self) -> tuple[str, ...]: ... def getbbox(self) -> tuple[int, int, int, int] | None: ... def getcolors(self, maxcolors: int = ...) -> list[tuple[int, int]]: ... def getdata(self, band: int | None = ...): ... @@ -197,7 +197,7 @@ class Image: ) -> None: ... def seek(self, frame: int) -> None: ... def show(self, title: str | None = ..., command: str | None = ...) -> None: ... - def split(self) -> Tuple[Image, ...]: ... + def split(self) -> tuple[Image, ...]: ... def getchannel(self, channel: int | str) -> Image: ... def tell(self) -> int: ... def thumbnail(self, size: tuple[int, int], resample: _Resample = ..., reducing_gap: float = ...) -> None: ... @@ -218,7 +218,7 @@ class Image: class ImagePointHandler: ... class ImageTransformHandler: ... -def new(mode: _Mode, size: tuple[int, int], color: float | Tuple[float, ...] | str = ...) -> Image: ... +def new(mode: _Mode, size: tuple[int, int], color: float | tuple[float, ...] | str = ...) -> Image: ... def frombytes(mode: _Mode, size: tuple[int, int], data, decoder_name: str = ..., *args) -> Image: ... def frombuffer(mode: _Mode, size: tuple[int, int], data, decoder_name: str = ..., *args) -> Image: ... def fromarray(obj, mode: _Mode | None = ...) -> Image: ... diff --git a/stubs/Pillow/PIL/ImageColor.pyi b/stubs/Pillow/PIL/ImageColor.pyi index 8e0db5292296..79aaba0ba7c1 100644 --- a/stubs/Pillow/PIL/ImageColor.pyi +++ b/stubs/Pillow/PIL/ImageColor.pyi @@ -1,8 +1,8 @@ -from typing import Tuple, Union +from typing import Union -_RGB = Union[Tuple[int, int, int], Tuple[int, int, int, int]] +_RGB = Union[tuple[int, int, int], tuple[int, int, int, int]] _Ink = Union[str, int, _RGB] -_GreyScale = Tuple[int, int] +_GreyScale = tuple[int, int] def getrgb(color: _Ink) -> _RGB: ... def getcolor(color: _Ink, mode: str) -> _RGB | _GreyScale: ... diff --git a/stubs/Pillow/PIL/ImageDraw.pyi b/stubs/Pillow/PIL/ImageDraw.pyi index 5ca32e3b3c8f..15c71b99abfb 100644 --- a/stubs/Pillow/PIL/ImageDraw.pyi +++ b/stubs/Pillow/PIL/ImageDraw.pyi @@ -1,12 +1,12 @@ from collections.abc import Container -from typing import Any, Sequence, Tuple, Union, overload +from typing import Any, Sequence, Union, overload from typing_extensions import Literal from .Image import Image from .ImageColor import _Ink from .ImageFont import _Font -_XY = Sequence[Union[float, Tuple[float, float]]] +_XY = Sequence[Union[float, tuple[float, float]]] _Outline = Any class ImageDraw: diff --git a/stubs/Pillow/PIL/ImageFilter.pyi b/stubs/Pillow/PIL/ImageFilter.pyi index af03bce671dd..6ec69d53bbcb 100644 --- a/stubs/Pillow/PIL/ImageFilter.pyi +++ b/stubs/Pillow/PIL/ImageFilter.pyi @@ -1,10 +1,10 @@ from _typeshed import Self -from typing import Any, Callable, Iterable, Sequence, Tuple, Type +from typing import Any, Callable, Iterable, Sequence 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. @@ -121,7 +121,7 @@ class Color3DLUT(MultibandFilter): ) -> None: ... @classmethod def generate( - cls: Type[Self], + cls: type[Self], size: int | tuple[int, int, int], callback: Callable[[float, float, float], Iterable[float]], channels: int = ..., 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..2ec680f83c55 100644 --- a/stubs/PyMySQL/pymysql/connections.pyi +++ b/stubs/PyMySQL/pymysql/connections.pyi @@ -1,5 +1,5 @@ from socket import socket as _socket -from typing import Any, AnyStr, Generic, Mapping, Tuple, Type, TypeVar, overload +from typing import Any, AnyStr, Generic, Mapping, TypeVar, overload from .charset import charset_by_id as charset_by_id, charset_by_name as charset_by_name from .constants import CLIENT as CLIENT, COMMAND as COMMAND, FIELD_TYPE as FIELD_TYPE, SERVER_STATUS as SERVER_STATUS @@ -35,7 +35,7 @@ class MysqlPacket: def read_uint64(self) -> Any: ... def read_length_encoded_integer(self) -> int: ... def read_length_coded_string(self) -> bytes: ... - def read_struct(self, fmt: str) -> Tuple[Any, ...]: ... + def read_struct(self, fmt: str) -> tuple[Any, ...]: ... def is_ok_packet(self) -> bool: ... def is_eof_packet(self) -> bool: ... def is_auth_switch_request(self) -> bool: ... @@ -133,7 +133,7 @@ class Connection(Generic[_C]): conv=..., use_unicode: bool | None = ..., client_flag: int = ..., - cursorclass: Type[_C] = ..., # different between overloads + cursorclass: type[_C] = ..., # different between overloads init_command: Any | None = ..., connect_timeout: int | None = ..., ssl: Mapping[Any, Any] | None = ..., @@ -178,7 +178,7 @@ class Connection(Generic[_C]): @overload def cursor(self, cursor: None = ...) -> _C: ... @overload - def cursor(self, cursor: Type[_C2]) -> _C2: ... + def cursor(self, cursor: type[_C2]) -> _C2: ... def query(self, sql, unbuffered: bool = ...) -> int: ... def next_result(self, unbuffered: bool = ...) -> int: ... def affected_rows(self): ... diff --git a/stubs/PyMySQL/pymysql/converters.pyi b/stubs/PyMySQL/pymysql/converters.pyi index ee2e4ba89aaa..f3d73fc3ba4d 100644 --- a/stubs/PyMySQL/pymysql/converters.pyi +++ b/stubs/PyMySQL/pymysql/converters.pyi @@ -2,9 +2,9 @@ import datetime import time from collections.abc import Callable, Mapping, Sequence from decimal import Decimal -from typing import Any, Optional, Type, TypeVar +from typing import Any, Optional, TypeVar -_EscaperMapping = Optional[Mapping[Type[object], Callable[..., str]]] +_EscaperMapping = Optional[Mapping[type[object], Callable[..., str]]] _T = TypeVar("_T") def escape_item(val: object, charset: object, mapping: _EscaperMapping = ...) -> str: ... @@ -33,7 +33,7 @@ def through(x: _T) -> _T: ... convert_bit = through -encoders: dict[Type[object], Callable[..., str]] +encoders: dict[type[object], Callable[..., str]] decoders: dict[int, Callable[[str | bytes], Any]] -conversions: dict[Type[object] | int, Callable[..., Any]] +conversions: dict[type[object] | int, Callable[..., Any]] Thing2Literal = escape_str diff --git a/stubs/PyMySQL/pymysql/cursors.pyi b/stubs/PyMySQL/pymysql/cursors.pyi index 45942196111e..be38c5494027 100644 --- a/stubs/PyMySQL/pymysql/cursors.pyi +++ b/stubs/PyMySQL/pymysql/cursors.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, Text, Tuple, TypeVar +from typing import Any, Iterable, Iterator, Text, TypeVar from .connections import Connection @@ -6,7 +6,7 @@ _SelfT = TypeVar("_SelfT") class Cursor: connection: Connection[Any] - description: Tuple[Text, ...] + description: tuple[Text, ...] rownumber: int rowcount: int arraysize: int @@ -27,21 +27,21 @@ class Cursor: def __enter__(self: _SelfT) -> _SelfT: ... def __exit__(self, *exc_info: Any) -> None: ... # Methods returning result tuples are below. - def fetchone(self) -> Tuple[Any, ...] | None: ... - def fetchmany(self, size: int | None = ...) -> Tuple[Tuple[Any, ...], ...]: ... - def fetchall(self) -> Tuple[Tuple[Any, ...], ...]: ... - def __iter__(self) -> Iterator[Tuple[Any, ...]]: ... + def fetchone(self) -> tuple[Any, ...] | None: ... + def fetchmany(self, size: int | None = ...) -> tuple[tuple[Any, ...], ...]: ... + def fetchall(self) -> tuple[tuple[Any, ...], ...]: ... + def __iter__(self) -> Iterator[tuple[Any, ...]]: ... class DictCursorMixin: dict_type: Any # TODO: add support if someone needs this def fetchone(self) -> dict[Text, Any] | None: ... - def fetchmany(self, size: int | None = ...) -> Tuple[dict[Text, Any], ...]: ... - def fetchall(self) -> Tuple[dict[Text, Any], ...]: ... + def fetchmany(self, size: int | None = ...) -> tuple[dict[Text, Any], ...]: ... + def fetchall(self) -> tuple[dict[Text, Any], ...]: ... def __iter__(self) -> Iterator[dict[Text, Any]]: ... class SSCursor(Cursor): - def fetchall(self) -> list[Tuple[Any, ...]]: ... # type: ignore[override] - def fetchall_unbuffered(self) -> Iterator[Tuple[Any, ...]]: ... + def fetchall(self) -> list[tuple[Any, ...]]: ... # type: ignore[override] + def fetchall_unbuffered(self) -> Iterator[tuple[Any, ...]]: ... def scroll(self, value: int, mode: Text = ...) -> None: ... class DictCursor(DictCursorMixin, Cursor): ... # type: ignore[misc] diff --git a/stubs/PyMySQL/pymysql/err.pyi b/stubs/PyMySQL/pymysql/err.pyi index 2a13b1d893df..8aec38f533f2 100644 --- a/stubs/PyMySQL/pymysql/err.pyi +++ b/stubs/PyMySQL/pymysql/err.pyi @@ -1,5 +1,5 @@ import builtins -from typing import NoReturn, Type +from typing import NoReturn from .constants import ER as ER @@ -15,6 +15,6 @@ class InternalError(DatabaseError): ... class ProgrammingError(DatabaseError): ... class NotSupportedError(DatabaseError): ... -error_map: dict[int, Type[DatabaseError]] +error_map: dict[int, type[DatabaseError]] def raise_mysql_exception(data) -> NoReturn: ... diff --git a/stubs/PyYAML/yaml/__init__.pyi b/stubs/PyYAML/yaml/__init__.pyi index 3e202264ea3d..69e2b8ec2a25 100644 --- a/stubs/PyYAML/yaml/__init__.pyi +++ b/stubs/PyYAML/yaml/__init__.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence -from typing import IO, Any, Pattern, Type, TypeVar, overload +from typing import IO, Any, Pattern, TypeVar, overload from . import resolver as resolver # Help mypy a bit; this is implied by loader and dumper from .constructor import BaseConstructor @@ -270,39 +270,39 @@ def add_implicit_resolver( tag: str, regexp: Pattern[str], first: Iterable[Any] | None = ..., - Loader: Type[BaseResolver] | None = ..., - Dumper: Type[BaseResolver] = ..., + Loader: type[BaseResolver] | None = ..., + Dumper: type[BaseResolver] = ..., ) -> None: ... def add_path_resolver( tag: str, path: Iterable[Any], - kind: Type[Any] | None = ..., - Loader: Type[BaseResolver] | None = ..., - Dumper: Type[BaseResolver] = ..., + kind: type[Any] | None = ..., + Loader: type[BaseResolver] | None = ..., + Dumper: type[BaseResolver] = ..., ) -> None: ... @overload def add_constructor( tag: str, constructor: Callable[[Loader | FullLoader | UnsafeLoader, Node], Any], Loader: None = ... ) -> None: ... @overload -def add_constructor(tag: str, constructor: Callable[[_Constructor, Node], Any], Loader: Type[_Constructor]) -> None: ... +def add_constructor(tag: str, constructor: Callable[[_Constructor, Node], Any], Loader: type[_Constructor]) -> None: ... @overload def add_multi_constructor( tag_prefix: str, multi_constructor: Callable[[Loader | FullLoader | UnsafeLoader, str, Node], Any], Loader: None = ... ) -> None: ... @overload def add_multi_constructor( - tag_prefix: str, multi_constructor: Callable[[_Constructor, str, Node], Any], Loader: Type[_Constructor] + tag_prefix: str, multi_constructor: Callable[[_Constructor, str, Node], Any], Loader: type[_Constructor] ) -> None: ... @overload -def add_representer(data_type: Type[_T], representer: Callable[[Dumper, _T], Node]) -> None: ... +def add_representer(data_type: type[_T], representer: Callable[[Dumper, _T], Node]) -> None: ... @overload -def add_representer(data_type: Type[_T], representer: Callable[[_Representer, _T], Node], Dumper: Type[_Representer]) -> None: ... +def add_representer(data_type: type[_T], representer: Callable[[_Representer, _T], Node], Dumper: type[_Representer]) -> None: ... @overload -def add_multi_representer(data_type: Type[_T], multi_representer: Callable[[Dumper, _T], Node]) -> None: ... +def add_multi_representer(data_type: type[_T], multi_representer: Callable[[Dumper, _T], Node]) -> None: ... @overload def add_multi_representer( - data_type: Type[_T], multi_representer: Callable[[_Representer, _T], Node], Dumper: Type[_Representer] + data_type: type[_T], multi_representer: Callable[[_Representer, _T], Node], Dumper: type[_Representer] ) -> None: ... class YAMLObjectMetaclass(type): diff --git a/stubs/PyYAML/yaml/representer.pyi b/stubs/PyYAML/yaml/representer.pyi index 298788a79ea1..f9802d2df7e0 100644 --- a/stubs/PyYAML/yaml/representer.pyi +++ b/stubs/PyYAML/yaml/representer.pyi @@ -2,7 +2,7 @@ import datetime from _typeshed import SupportsItems from collections.abc import Callable, Iterable, Mapping from types import BuiltinFunctionType, FunctionType, ModuleType -from typing import Any, ClassVar, NoReturn, Type, TypeVar +from typing import Any, ClassVar, NoReturn, TypeVar from yaml.error import YAMLError as YAMLError from yaml.nodes import MappingNode as MappingNode, Node as Node, ScalarNode as ScalarNode, SequenceNode as SequenceNode @@ -13,8 +13,8 @@ _R = TypeVar("_R", bound=BaseRepresenter) class RepresenterError(YAMLError): ... class BaseRepresenter: - yaml_representers: ClassVar[dict[Type[Any], Callable[[BaseRepresenter, Any], Node]]] - yaml_multi_representers: ClassVar[dict[Type[Any], Callable[[BaseRepresenter, Any], Node]]] + yaml_representers: ClassVar[dict[type[Any], Callable[[BaseRepresenter, Any], Node]]] + yaml_multi_representers: ClassVar[dict[type[Any], Callable[[BaseRepresenter, Any], Node]]] default_style: str | Any sort_keys: bool default_flow_style: bool @@ -25,9 +25,9 @@ class BaseRepresenter: def represent(self, data) -> None: ... def represent_data(self, data) -> Node: ... @classmethod - def add_representer(cls: Type[_R], data_type: Type[_T], representer: Callable[[_R, _T], Node]) -> None: ... + def add_representer(cls: type[_R], data_type: type[_T], representer: Callable[[_R, _T], Node]) -> None: ... @classmethod - def add_multi_representer(cls: Type[_R], data_type: Type[_T], representer: Callable[[_R, _T], Node]) -> None: ... + def add_multi_representer(cls: type[_R], data_type: type[_T], representer: Callable[[_R, _T], Node]) -> None: ... def represent_scalar(self, tag: str, value, style: str | None = ...) -> ScalarNode: ... def represent_sequence(self, tag: str, sequence: Iterable[Any], flow_style: bool | None = ...) -> SequenceNode: ... def represent_mapping( diff --git a/stubs/Pygments/pygments/formatters/__init__.pyi b/stubs/Pygments/pygments/formatters/__init__.pyi index b77043bb31e1..3e87595b79f1 100644 --- a/stubs/Pygments/pygments/formatters/__init__.pyi +++ b/stubs/Pygments/pygments/formatters/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Generator, Type +from typing import Generator from ..formatter import Formatter from .bbcode import BBCodeFormatter as BBCodeFormatter @@ -18,7 +18,7 @@ from .svg import SvgFormatter as SvgFormatter from .terminal import TerminalFormatter as TerminalFormatter from .terminal256 import Terminal256Formatter as Terminal256Formatter, TerminalTrueColorFormatter as TerminalTrueColorFormatter -def get_all_formatters() -> Generator[Type[Formatter], None, None]: ... +def get_all_formatters() -> Generator[type[Formatter], None, None]: ... def get_formatter_by_name(_alias, **options): ... def load_formatter_from_file(filename, formattername: str = ..., **options): ... def get_formatter_for_filename(fn, **options): ... 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/SQLAlchemy/sqlalchemy/engine/default.pyi b/stubs/SQLAlchemy/sqlalchemy/engine/default.pyi index a461b5f5ac83..4f65bd5a2bb1 100644 --- a/stubs/SQLAlchemy/sqlalchemy/engine/default.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/engine/default.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Type +from typing import Any, ClassVar from .. import types as sqltypes from ..util import memoized_property @@ -13,7 +13,7 @@ NO_CACHE_KEY: Any NO_DIALECT_SUPPORT: Any class DefaultDialect(interfaces.Dialect): - execution_ctx_cls: ClassVar[Type[interfaces.ExecutionContext]] + execution_ctx_cls: ClassVar[type[interfaces.ExecutionContext]] statement_compiler: Any ddl_compiler: Any type_compiler: Any diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index 3859bc5ce660..38c4ae1029b7 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -1,6 +1,6 @@ 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, Coroutine, Generator, Generic, Iterator, TypeVar _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) @@ -15,7 +15,7 @@ class AsyncBase(Generic[_T]): class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]): def __init__(self, coro: Coroutine[_T_co, _T_contra, _V_co]) -> None: ... def send(self, value: _T_contra) -> _T_co: ... - def throw(self, typ: Type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ...) -> _T_co: ... + def throw(self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ...) -> _T_co: ... def close(self) -> None: ... @property def gi_frame(self) -> FrameType: ... @@ -30,5 +30,5 @@ class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]): async def __anext__(self) -> _V_co: ... async def __aenter__(self) -> _V_co: ... async def __aexit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index fd2a90122e2a..8711bddb4d4e 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import BinaryIO, Iterable, Tuple +from typing import BinaryIO, Iterable from ..base import AsyncBase @@ -31,7 +31,7 @@ class AsyncTextIOWrapper(AsyncBase[str]): @property def line_buffering(self) -> bool: ... @property - def newlines(self) -> str | Tuple[str, ...] | None: ... + def newlines(self) -> str | tuple[str, ...] | None: ... @property def name(self) -> StrOrBytesPath | int: ... @property diff --git a/stubs/atomicwrites/atomicwrites/__init__.pyi b/stubs/atomicwrites/atomicwrites/__init__.pyi index 388ac27182fe..e1629cee44af 100644 --- a/stubs/atomicwrites/atomicwrites/__init__.pyi +++ b/stubs/atomicwrites/atomicwrites/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import IO, Any, AnyStr, Callable, ContextManager, Text, Type +from typing import IO, Any, AnyStr, Callable, ContextManager, Text def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... def move_atomic(src: AnyStr, dst: AnyStr) -> None: ... @@ -13,4 +13,4 @@ class AtomicWriter(object): def commit(self, f: IO[Any]) -> None: ... def rollback(self, f: IO[Any]) -> None: ... -def atomic_write(path: StrOrBytesPath, writer_cls: Type[AtomicWriter] = ..., **cls_kwargs: object) -> ContextManager[IO[Any]]: ... +def atomic_write(path: StrOrBytesPath, writer_cls: type[AtomicWriter] = ..., **cls_kwargs: object) -> ContextManager[IO[Any]]: ... 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..f779bd205820 100644 --- a/stubs/beautifulsoup4/bs4/__init__.pyi +++ b/stubs/beautifulsoup4/bs4/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import Self, SupportsRead -from typing import Any, Sequence, Type +from typing import Any, Sequence from .builder import TreeBuilder from .element import PageElement, SoupStrainer, Tag @@ -23,11 +23,11 @@ class BeautifulSoup(Tag): self, markup: str | bytes | SupportsRead[str] | SupportsRead[bytes] = ..., features: str | Sequence[str] | None = ..., - builder: TreeBuilder | Type[TreeBuilder] | None = ..., + builder: TreeBuilder | type[TreeBuilder] | None = ..., parse_only: SoupStrainer | None = ..., from_encoding: str | None = ..., exclude_encodings: Sequence[str] | None = ..., - element_classes: dict[Type[PageElement], Type[Any]] | None = ..., + element_classes: dict[type[PageElement], type[Any]] | None = ..., **kwargs, ) -> None: ... def __copy__(self: Self) -> Self: ... 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..9bffae817585 100644 --- a/stubs/beautifulsoup4/bs4/element.pyi +++ b/stubs/beautifulsoup4/bs4/element.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from collections.abc import Iterator -from typing import Any, Callable, Generic, Iterable, List, Mapping, Pattern, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, Iterable, Mapping, Pattern, TypeVar, Union, overload from . import BeautifulSoup from .builder import TreeBuilder @@ -13,7 +13,7 @@ whitespace_re: Pattern[str] PYTHON_SPECIFIC_ENCODINGS: set[str] class NamespacedAttribute(str): - def __new__(cls: Type[Self], prefix: str, name: str | None = ..., namespace: str | None = ...) -> Self: ... + def __new__(cls: type[Self], prefix: str, name: str | None = ..., namespace: str | None = ...) -> Self: ... class AttributeValueWithCharsetSubstitution(str): ... @@ -53,7 +53,7 @@ class PageElement: previousSibling: PageElement | None @property def stripped_strings(self) -> Iterator[str]: ... - def get_text(self, separator: str = ..., strip: bool = ..., types: Tuple[Type[NavigableString], ...] = ...) -> str: ... + def get_text(self, separator: str = ..., strip: bool = ..., types: tuple[type[NavigableString], ...] = ...) -> str: ... getText = get_text @property def text(self) -> str: ... @@ -182,7 +182,7 @@ class NavigableString(str, PageElement): PREFIX: str SUFFIX: str known_xml: bool | None - def __new__(cls: Type[Self], value: str | bytes) -> Self: ... + def __new__(cls: type[Self], value: str | bytes) -> Self: ... def __copy__(self: Self) -> Self: ... def __getnewargs__(self) -> tuple[str]: ... def output_ready(self, formatter: Formatter | str | None = ...) -> str: ... @@ -227,7 +227,7 @@ class Script(NavigableString): ... class TemplateString(NavigableString): ... class Tag(PageElement): - parser_class: Type[BeautifulSoup] | None + parser_class: type[BeautifulSoup] | None name: str namespace: str | None prefix: str | None @@ -256,9 +256,9 @@ 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 + parserClass: type[BeautifulSoup] | None def __copy__(self: Self) -> Self: ... @property def is_empty_element(self) -> bool: ... @@ -267,7 +267,7 @@ class Tag(PageElement): def string(self) -> str | None: ... @string.setter def string(self, string: str) -> None: ... - DEFAULT_INTERESTING_STRING_TYPES: Tuple[Type[NavigableString], ...] + DEFAULT_INTERESTING_STRING_TYPES: tuple[type[NavigableString], ...] @property def strings(self) -> Iterable[str]: ... def decompose(self) -> None: ... @@ -348,6 +348,6 @@ class SoupStrainer: searchTag = search_tag def search(self, markup: PageElement | Iterable[PageElement]): ... -class ResultSet(List[_PageElementT], Generic[_PageElementT]): +class ResultSet(list[_PageElementT], Generic[_PageElementT]): source: SoupStrainer def __init__(self, source: SoupStrainer, result: Iterable[_PageElementT] = ...) -> None: ... diff --git a/stubs/bleach/bleach/sanitizer.pyi b/stubs/bleach/bleach/sanitizer.pyi index 0966af2096d6..4adf96e47194 100644 --- a/stubs/bleach/bleach/sanitizer.pyi +++ b/stubs/bleach/bleach/sanitizer.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Container, Iterable -from typing import Any, Dict, List, Pattern, Union +from typing import Any, Pattern, Union from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter @@ -39,8 +39,8 @@ class Cleaner(object): def clean(self, text: str) -> str: ... _AttributeFilter = Callable[[str, str, str], bool] -_AttributeDict = Union[Dict[str, Union[List[str], _AttributeFilter]], Dict[str, List[str]], Dict[str, _AttributeFilter]] -_Attributes = Union[_AttributeFilter, _AttributeDict, List[str]] +_AttributeDict = Union[dict[str, Union[list[str], _AttributeFilter]], dict[str, list[str]], dict[str, _AttributeFilter]] +_Attributes = Union[_AttributeFilter, _AttributeDict, list[str]] def attribute_filter_factory(attributes: _Attributes) -> _AttributeFilter: ... diff --git a/stubs/boto/boto/kms/layer1.pyi b/stubs/boto/boto/kms/layer1.pyi index e2755233678d..5a7496ee30bb 100644 --- a/stubs/boto/boto/kms/layer1.pyi +++ b/stubs/boto/boto/kms/layer1.pyi @@ -1,4 +1,4 @@ -from typing import Any, Mapping, Type +from typing import Any, Mapping from boto.connection import AWSQueryConnection @@ -8,7 +8,7 @@ class KMSConnection(AWSQueryConnection): DefaultRegionEndpoint: str ServiceName: str TargetPrefix: str - ResponseError: Type[Exception] + ResponseError: type[Exception] region: Any def __init__(self, **kwargs) -> None: ... def create_alias(self, alias_name: str, target_key_id: str) -> dict[str, Any] | None: ... diff --git a/stubs/boto/boto/s3/__init__.pyi b/stubs/boto/boto/s3/__init__.pyi index fa747956ebbe..c483c9cf498b 100644 --- a/stubs/boto/boto/s3/__init__.pyi +++ b/stubs/boto/boto/s3/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Text, Type +from typing import Text from boto.connection import AWSAuthConnection from boto.regioninfo import RegionInfo @@ -10,7 +10,7 @@ class S3RegionInfo(RegionInfo): self, name: Text | None = ..., endpoint: str | None = ..., - connection_cls: Type[AWSAuthConnection] | None = ..., + connection_cls: type[AWSAuthConnection] | None = ..., **kw_params, ) -> S3Connection: ... diff --git a/stubs/boto/boto/s3/bucket.pyi b/stubs/boto/boto/s3/bucket.pyi index 741772ff3817..196ba4d2e07d 100644 --- a/stubs/boto/boto/s3/bucket.pyi +++ b/stubs/boto/boto/s3/bucket.pyi @@ -1,4 +1,4 @@ -from typing import Any, Text, Type +from typing import Any, Text from .bucketlistresultset import BucketListResultSet from .connection import S3Connection @@ -19,8 +19,8 @@ class Bucket: MFADeleteRE: str name: Text connection: S3Connection - key_class: Type[Key] - def __init__(self, connection: S3Connection | None = ..., name: Text | None = ..., key_class: Type[Key] = ...) -> None: ... + key_class: type[Key] + def __init__(self, connection: S3Connection | None = ..., name: Text | None = ..., key_class: type[Key] = ...) -> None: ... def __iter__(self): ... def __contains__(self, key_name) -> bool: ... def startElement(self, name, attrs, connection): ... diff --git a/stubs/boto/boto/s3/connection.pyi b/stubs/boto/boto/s3/connection.pyi index 96b8d0de134c..b0240e297721 100644 --- a/stubs/boto/boto/s3/connection.pyi +++ b/stubs/boto/boto/s3/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, Text, Type +from typing import Any, Text from boto.connection import AWSAuthConnection from boto.exception import BotoClientError @@ -48,7 +48,7 @@ class S3Connection(AWSAuthConnection): DefaultCallingFormat: Any QueryString: str calling_format: Any - bucket_class: Type[Bucket] + bucket_class: type[Bucket] anon: Any def __init__( self, @@ -66,7 +66,7 @@ class S3Connection(AWSAuthConnection): calling_format: Any = ..., path: str = ..., provider: str = ..., - bucket_class: Type[Bucket] = ..., + bucket_class: type[Bucket] = ..., security_token: Any | None = ..., suppress_consec_slashes: bool = ..., anon: bool = ..., @@ -75,7 +75,7 @@ class S3Connection(AWSAuthConnection): ) -> None: ... def __iter__(self): ... def __contains__(self, bucket_name): ... - def set_bucket_class(self, bucket_class: Type[Bucket]) -> None: ... + def set_bucket_class(self, bucket_class: type[Bucket]) -> None: ... def build_post_policy(self, expiration_time, conditions): ... def build_post_form_args( self, diff --git a/stubs/boto/boto/s3/cors.pyi b/stubs/boto/boto/s3/cors.pyi index f31e612f748d..125587f9ba0e 100644 --- a/stubs/boto/boto/s3/cors.pyi +++ b/stubs/boto/boto/s3/cors.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class CORSRule: allowed_method: Any @@ -20,7 +20,7 @@ class CORSRule: def endElement(self, name, value, connection): ... def to_xml(self) -> str: ... -class CORSConfiguration(List[CORSRule]): +class CORSConfiguration(list[CORSRule]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self) -> str: ... diff --git a/stubs/boto/boto/s3/lifecycle.pyi b/stubs/boto/boto/s3/lifecycle.pyi index bf750bb2e50f..7919bad712df 100644 --- a/stubs/boto/boto/s3/lifecycle.pyi +++ b/stubs/boto/boto/s3/lifecycle.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class Rule: id: Any @@ -33,7 +33,7 @@ class Transition: def __init__(self, days: Any | None = ..., date: Any | None = ..., storage_class: Any | None = ...) -> None: ... def to_xml(self): ... -class Transitions(List[Transition]): +class Transitions(list[Transition]): transition_properties: int current_transition_property: int temp_days: Any @@ -51,7 +51,7 @@ class Transitions(List[Transition]): @property def storage_class(self): ... -class Lifecycle(List[Rule]): +class Lifecycle(list[Rule]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... diff --git a/stubs/boto/boto/s3/tagging.pyi b/stubs/boto/boto/s3/tagging.pyi index ad1bcf8039f4..98a954d5fd8e 100644 --- a/stubs/boto/boto/s3/tagging.pyi +++ b/stubs/boto/boto/s3/tagging.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any class Tag: key: Any @@ -9,13 +9,13 @@ class Tag: def to_xml(self): ... def __eq__(self, other): ... -class TagSet(List[Tag]): +class TagSet(list[Tag]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def add_tag(self, key, value): ... def to_xml(self): ... -class Tags(List[TagSet]): +class Tags(list[TagSet]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... diff --git a/stubs/boto/boto/s3/website.pyi b/stubs/boto/boto/s3/website.pyi index 186afdf1fdd1..e913f6dde791 100644 --- a/stubs/boto/boto/s3/website.pyi +++ b/stubs/boto/boto/s3/website.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any def tag(key, value): ... @@ -33,7 +33,7 @@ class RedirectLocation(_XMLKeyValue): def __init__(self, hostname: Any | None = ..., protocol: Any | None = ...) -> None: ... def to_xml(self): ... -class RoutingRules(List[RoutingRule]): +class RoutingRules(list[RoutingRule]): def add_rule(self, rule: RoutingRule) -> RoutingRules: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 3e650b1fea31..16ed18bd6f5d 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -3,7 +3,7 @@ import logging.handlers import subprocess import sys import time -from typing import IO, Any, Callable, ContextManager, Dict, Iterable, Mapping, Sequence, Type, TypeVar +from typing import IO, Any, Callable, ContextManager, Iterable, Mapping, Sequence, TypeVar import boto.connection @@ -37,7 +37,7 @@ else: _Provider = Any # TODO replace this with boto.provider.Provider once stubs exist _LockType = Any # TODO replace this with _thread.LockType once stubs exist -JSONDecodeError: Type[ValueError] +JSONDecodeError: type[ValueError] qsa_of_interest: list[str] def unquote_v(nv: str) -> str | tuple[str, str]: ... @@ -50,7 +50,7 @@ def merge_meta( def get_aws_metadata(headers: Mapping[str, str], provider: _Provider | None = ...) -> Mapping[str, str]: ... def retry_url(url: str, retry_on_404: bool = ..., num_retries: int = ..., timeout: int | None = ...) -> str: ... -class LazyLoadMetadata(Dict[_KT, _VT]): +class LazyLoadMetadata(dict[_KT, _VT]): def __init__(self, url: str, num_retries: int, timeout: int | None = ...) -> None: ... def get_instance_metadata( @@ -71,7 +71,7 @@ LOCALE_LOCK: _LockType def setlocale(name: str | tuple[str, str]) -> ContextManager[str]: ... def get_ts(ts: time.struct_time | None = ...) -> str: ... def parse_ts(ts: str) -> datetime.datetime: ... -def find_class(module_name: str, class_name: str | None = ...) -> Type[Any] | None: ... +def find_class(module_name: str, class_name: str | None = ...) -> type[Any] | None: ... def update_dme(username: str, password: str, dme_id: str, ip_address: str) -> str: ... def fetch_file( uri: str, file: IO[str] | None = ..., username: str | None = ..., password: str | None = ... @@ -101,7 +101,7 @@ class AuthSMTPHandler(logging.handlers.SMTPHandler): self, mailhost: str, username: str, password: str, fromaddr: str, toaddrs: Sequence[str], subject: str ) -> None: ... -class LRUCache(Dict[_KT, _VT]): +class LRUCache(dict[_KT, _VT]): class _Item: previous: LRUCache._Item | None next: LRUCache._Item | None diff --git a/stubs/cachetools/cachetools/keys.pyi b/stubs/cachetools/cachetools/keys.pyi index 9effbe6e171f..ef3e1120f4f9 100644 --- a/stubs/cachetools/cachetools/keys.pyi +++ b/stubs/cachetools/cachetools/keys.pyi @@ -1,4 +1,4 @@ -from typing import Hashable, Tuple +from typing import Hashable -def hashkey(*args: Hashable, **kwargs: Hashable) -> Tuple[Hashable, ...]: ... -def typedkey(*args: Hashable, **kwargs: Hashable) -> Tuple[Hashable, ...]: ... +def hashkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... +def typedkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... diff --git a/stubs/caldav/caldav/lib/error.pyi b/stubs/caldav/caldav/lib/error.pyi index b088bb8f2623..becaa7bb7799 100644 --- a/stubs/caldav/caldav/lib/error.pyi +++ b/stubs/caldav/caldav/lib/error.pyi @@ -1,4 +1,4 @@ -from typing import Type + def assert_(condition: object) -> None: ... @@ -22,4 +22,4 @@ class NotFoundError(DAVError): ... class ConsistencyError(DAVError): ... class ResponseError(DAVError): ... -exception_by_method: dict[str, Type[DAVError]] +exception_by_method: dict[str, type[DAVError]] diff --git a/stubs/caldav/caldav/objects.pyi b/stubs/caldav/caldav/objects.pyi index 6f2f94ff1dc1..1774ef8c04c0 100644 --- a/stubs/caldav/caldav/objects.pyi +++ b/stubs/caldav/caldav/objects.pyi @@ -1,7 +1,7 @@ import datetime from _typeshed import Self from collections.abc import Iterable, Iterator, Mapping -from typing import Any, Type, TypeVar, overload +from typing import Any, TypeVar, overload from typing_extensions import Literal from urllib.parse import ParseResult, SplitResult @@ -101,7 +101,7 @@ class Calendar(DAVObject): @overload def search(self, xml, comp_class: None = ...) -> list[CalendarObjectResource]: ... @overload - def search(self, xml, comp_class: Type[_CC]) -> list[_CC]: ... + def search(self, xml, comp_class: type[_CC]) -> list[_CC]: ... def freebusy_request(self, start: datetime.datetime, end: datetime.datetime) -> FreeBusy: ... def todos(self, sort_keys: Iterable[str] = ..., include_completed: bool = ..., sort_key: str | None = ...) -> list[Todo]: ... def event_by_url(self, href, data: Any | None = ...) -> Event: ... diff --git a/stubs/characteristic/characteristic/__init__.pyi b/stubs/characteristic/characteristic/__init__.pyi index 08056c3e6c07..d60ff1a35f25 100644 --- a/stubs/characteristic/characteristic/__init__.pyi +++ b/stubs/characteristic/characteristic/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Callable, Sequence, Type, TypeVar +from typing import Any, AnyStr, Callable, Sequence, TypeVar def with_repr(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... def with_cmp(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... @@ -18,7 +18,7 @@ def attributes( apply_immutable: bool = ..., store_attributes: Callable[[type, Attribute], Any] | None = ..., **kw: dict[Any, Any] | None, -) -> Callable[[Type[_T]], Type[_T]]: ... +) -> Callable[[type[_T]], type[_T]]: ... class Attribute: def __init__( 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..8abc4c7f7590 100644 --- a/stubs/click-spinner/click_spinner/__init__.pyi +++ b/stubs/click-spinner/click_spinner/__init__.pyi @@ -1,6 +1,6 @@ import threading from types import TracebackType -from typing import Iterator, Protocol, Type +from typing import Iterator, Protocol from typing_extensions import Literal __version__: str @@ -24,7 +24,7 @@ class Spinner(object): def init_spin(self) -> None: ... def __enter__(self) -> Spinner: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> Literal[False]: ... def spinner(beep: bool, disable: bool, force: bool, stream: _Stream) -> Spinner: ... diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index 117fe8f6265c..9cf3008e86b2 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import SupportsWrite -from typing import Any, Callable, Dict, Optional, Pattern, Sequence, TextIO, Tuple, Union +from typing import Any, Callable, Optional, Pattern, Sequence, TextIO, Union if sys.platform == "win32": from .winterm import WinTerm @@ -20,7 +20,7 @@ class StreamWrapper: def closed(self) -> bool: ... _WinTermCall = Callable[[Optional[int], bool, bool], None] -_WinTermCallDict = Dict[int, Union[Tuple[_WinTermCall], Tuple[_WinTermCall, int], Tuple[_WinTermCall, int, bool]]] +_WinTermCallDict = dict[int, Union[tuple[_WinTermCall], tuple[_WinTermCall, int], tuple[_WinTermCall, int, bool]]] class AnsiToWin32: ANSI_CSI_RE: Pattern[str] = ... @@ -40,6 +40,6 @@ class AnsiToWin32: def write_and_convert(self, text: str) -> None: ... def write_plain_text(self, text: str, start: int, end: int) -> None: ... def convert_ansi(self, paramstring: str, command: str) -> None: ... - def extract_params(self, command: str, paramstring: str) -> Tuple[int, ...]: ... + def extract_params(self, command: str, paramstring: str) -> tuple[int, ...]: ... def call_win32(self, command: str, params: Sequence[int]) -> None: ... def convert_osc(self, text: str) -> str: ... diff --git a/stubs/croniter/croniter.pyi b/stubs/croniter/croniter.pyi index 820e0ee50a42..ea8c5103b401 100644 --- a/stubs/croniter/croniter.pyi +++ b/stubs/croniter/croniter.pyi @@ -1,8 +1,8 @@ import datetime -from typing import Any, Iterator, Text, Tuple, Type, TypeVar, Union +from typing import Any, Iterator, Text, TypeVar, Union from typing_extensions import Literal -_RetType = Union[Type[float], Type[datetime.datetime]] +_RetType = Union[type[float], type[datetime.datetime]] _SelfT = TypeVar("_SelfT", bound=croniter) class CroniterError(ValueError): ... @@ -12,7 +12,7 @@ class CroniterNotAlphaError(CroniterError): ... class croniter(Iterator[Any]): MONTHS_IN_YEAR: Literal[12] - RANGES: Tuple[tuple[int, int], ...] + RANGES: tuple[tuple[int, int], ...] DAYS: tuple[ Literal[31], Literal[28], @@ -27,9 +27,9 @@ class croniter(Iterator[Any]): Literal[30], Literal[31], ] - ALPHACONV: Tuple[dict[str, Any], ...] - LOWMAP: Tuple[dict[int, Any], ...] - LEN_MEANS_ALL: Tuple[int, ...] + ALPHACONV: tuple[dict[str, Any], ...] + LOWMAP: tuple[dict[int, Any], ...] + LEN_MEANS_ALL: tuple[int, ...] bad_length: str tzinfo: datetime.tzinfo | None cur: float @@ -74,5 +74,5 @@ def croniter_range( ret_type: _RetType | None = ..., day_or: bool = ..., exclude_ends: bool = ..., - _croniter: Type[croniter] | None = ..., + _croniter: type[croniter] | None = ..., ) -> Iterator[Any]: ... diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index be3b7bdabd3f..7c58e2a7e2b8 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -2,7 +2,7 @@ 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, Generator, Generic, Iterable, Sequence, Text, TypeVar from cryptography.hazmat.backends.interfaces import X509Backend from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey @@ -293,7 +293,7 @@ class Extensions(object): def __init__(self, general_names: list[Extension[Any]]) -> None: ... def __iter__(self) -> Generator[Extension[Any], None, None]: ... def get_extension_for_oid(self, oid: ObjectIdentifier) -> Extension[Any]: ... - def get_extension_for_class(self, extclass: Type[_T]) -> Extension[_T]: ... + def get_extension_for_class(self, extclass: type[_T]) -> Extension[_T]: ... class DuplicateExtension(Exception): oid: ObjectIdentifier @@ -306,12 +306,12 @@ class ExtensionNotFound(Exception): class IssuerAlternativeName(ExtensionType): def __init__(self, general_names: list[GeneralName]) -> None: ... def __iter__(self) -> Generator[GeneralName, None, None]: ... - def get_values_for_type(self, type: Type[GeneralName]) -> list[Any]: ... + def get_values_for_type(self, type: type[GeneralName]) -> list[Any]: ... class SubjectAlternativeName(ExtensionType): def __init__(self, general_names: list[GeneralName]) -> None: ... def __iter__(self) -> Generator[GeneralName, None, None]: ... - def get_values_for_type(self, type: Type[GeneralName]) -> list[Any]: ... + def get_values_for_type(self, type: type[GeneralName]) -> list[Any]: ... class AuthorityKeyIdentifier(ExtensionType): @property diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index a76db82bd6ac..8f76c6be10aa 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Generic, Iterable, Mapping, Tuple, Type, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Mapping, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -15,21 +15,21 @@ 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 -def dataclass(_cls: Type[_T]) -> Type[_T]: ... +def dataclass(_cls: type[_T]) -> type[_T]: ... @overload -def dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]: ... +def dataclass(_cls: None) -> Callable[[type[_T]], type[_T]]: ... @overload def dataclass( *, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ... -) -> Callable[[Type[_T]], Type[_T]]: ... +) -> Callable[[type[_T]], type[_T]]: ... class Field(Generic[_T]): name: str - type: Type[_T] + type: type[_T] default: _T default_factory: Callable[[], _T] repr: bool @@ -66,7 +66,7 @@ def field( def field( *, init: bool = ..., repr: bool = ..., hash: bool | None = ..., compare: bool = ..., metadata: Mapping[str, Any] | None = ... ) -> Any: ... -def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... +def fields(class_or_instance: Any) -> tuple[Field[Any], ...]: ... def is_dataclass(obj: Any) -> bool: ... class FrozenInstanceError(AttributeError): ... @@ -79,7 +79,7 @@ def make_dataclass( cls_name: str, fields: Iterable[str | tuple[str, type] | tuple[str, type, Field[Any]]], *, - bases: Tuple[type, ...] = ..., + bases: tuple[type, ...] = ..., namespace: dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., diff --git a/stubs/dateparser/dateparser/date.pyi b/stubs/dateparser/dateparser/date.pyi index cc5118dcedb9..468a1fb316cd 100644 --- a/stubs/dateparser/dateparser/date.pyi +++ b/stubs/dateparser/dateparser/date.pyi @@ -2,7 +2,7 @@ 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, Iterable, Iterator, overload from dateparser import _Settings from dateparser.conf import Settings @@ -107,4 +107,4 @@ class DateDataParser: def _get_applicable_locales(self, date_string: str) -> Iterator[Locale]: ... def _is_applicable_locale(self, locale: Locale, date_string: str) -> bool: ... @classmethod - def _get_locale_loader(cls: Type[DateDataParser]) -> LocaleDataLoader: ... + def _get_locale_loader(cls: type[DateDataParser]) -> LocaleDataLoader: ... 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/decorator/decorator.pyi b/stubs/decorator/decorator.pyi index 0d50a5412a1d..622726106b25 100644 --- a/stubs/decorator/decorator.pyi +++ b/stubs/decorator/decorator.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Iterator, NamedTuple, Pattern, Text, Tuple, TypeVar +from typing import Any, Callable, Iterator, NamedTuple, Pattern, Text, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) _Func = TypeVar("_Func", bound=Callable[..., Any]) @@ -14,7 +14,7 @@ else: args: list[str] varargs: str | None varkw: str | None - defaults: Tuple[Any, ...] + defaults: tuple[Any, ...] kwonlyargs: list[str] kwonlydefaults: dict[str, Any] annotations: dict[str, Any] @@ -34,7 +34,7 @@ class FunctionMaker(object): args: list[Text] varargs: Text | None varkw: Text | None - defaults: Tuple[Any, ...] + defaults: tuple[Any, ...] kwonlyargs: list[Text] kwonlydefaults: Text | None shortsignature: Text | None @@ -49,7 +49,7 @@ class FunctionMaker(object): func: Callable[..., Any] | None = ..., name: Text | None = ..., signature: Text | None = ..., - defaults: Tuple[Any, ...] | None = ..., + defaults: tuple[Any, ...] | None = ..., doc: Text | None = ..., module: Text | None = ..., funcdict: _dict[Text, Any] | None = ..., @@ -64,7 +64,7 @@ class FunctionMaker(object): obj: Any, body: Text, evaldict: _dict[Text, Any], - defaults: Tuple[Any, ...] | None = ..., + defaults: tuple[Any, ...] | None = ..., doc: Text | None = ..., module: Text | None = ..., addsource: bool = ..., diff --git a/stubs/docutils/docutils/__init__.pyi b/stubs/docutils/docutils/__init__.pyi index d4477b9624b0..4a113c725fa4 100644 --- a/stubs/docutils/docutils/__init__.pyi +++ b/stubs/docutils/docutils/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, NamedTuple, Tuple +from typing import Any, ClassVar, NamedTuple __docformat__: str __version__: str @@ -23,19 +23,19 @@ class ApplicationError(Exception): ... class DataError(ApplicationError): ... class SettingsSpec: - settings_spec: ClassVar[Tuple[Any, ...]] + settings_spec: ClassVar[tuple[Any, ...]] settings_defaults: ClassVar[dict[Any, Any] | None] settings_default_overrides: ClassVar[dict[Any, Any] | None] - relative_path_settings: ClassVar[Tuple[Any, ...]] + relative_path_settings: ClassVar[tuple[Any, ...]] config_section: ClassVar[str | None] - config_section_dependencies: ClassVar[Tuple[str, ...] | None] + config_section_dependencies: ClassVar[tuple[str, ...] | None] class TransformSpec: def get_transforms(self) -> list[Any]: ... - default_transforms: ClassVar[Tuple[Any, ...]] + default_transforms: ClassVar[tuple[Any, ...]] unknown_reference_resolvers: ClassVar[list[Any]] class Component(SettingsSpec, TransformSpec): component_type: ClassVar[str | None] - supported: ClassVar[Tuple[str, ...]] + supported: ClassVar[tuple[str, ...]] def supports(self, format: str) -> bool: ... diff --git a/stubs/docutils/docutils/frontend.pyi b/stubs/docutils/docutils/frontend.pyi index c32dc44ffb5e..e71907471704 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 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: ... @@ -64,7 +64,7 @@ class OptionParser(optparse.OptionParser, SettingsSpec): version_template: ClassVar[str] def __init__( self, - components: Iterable[Type[Parser]] = ..., + components: Iterable[type[Parser]] = ..., defaults: Mapping[str, Any] | None = ..., read_config_files: bool | None = ..., *args, diff --git a/stubs/docutils/docutils/parsers/__init__.pyi b/stubs/docutils/docutils/parsers/__init__.pyi index a77c183734e0..75fd95c8956e 100644 --- a/stubs/docutils/docutils/parsers/__init__.pyi +++ b/stubs/docutils/docutils/parsers/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Type +from typing import Any, ClassVar from docutils import Component @@ -13,4 +13,4 @@ class Parser(Component): _parser_aliases: dict[str, str] -def get_parser_class(parser_name: str) -> Type[Parser]: ... +def get_parser_class(parser_name: str) -> type[Parser]: ... diff --git a/stubs/docutils/docutils/parsers/null.pyi b/stubs/docutils/docutils/parsers/null.pyi index 1d3629109243..edc977325a1d 100644 --- a/stubs/docutils/docutils/parsers/null.pyi +++ b/stubs/docutils/docutils/parsers/null.pyi @@ -1,6 +1,6 @@ -from typing import ClassVar, Tuple +from typing import ClassVar from docutils import parsers class Parser(parsers.Parser): - config_section_dependencies: ClassVar[Tuple[str, ...]] + config_section_dependencies: ClassVar[tuple[str, ...]] diff --git a/stubs/docutils/docutils/parsers/rst/__init__.pyi b/stubs/docutils/docutils/parsers/rst/__init__.pyi index f605176c4173..b9cc02940ce0 100644 --- a/stubs/docutils/docutils/parsers/rst/__init__.pyi +++ b/stubs/docutils/docutils/parsers/rst/__init__.pyi @@ -1,11 +1,11 @@ -from typing import Any, ClassVar, Tuple +from typing import Any, ClassVar from typing_extensions import Literal from docutils import parsers from docutils.parsers.rst import states class Parser(parsers.Parser): - config_section_dependencies: ClassVar[Tuple[str, ...]] + config_section_dependencies: ClassVar[tuple[str, ...]] initial_state: Literal["Body", "RFC2822Body"] state_classes: Any inliner: Any diff --git a/stubs/docutils/docutils/parsers/rst/roles.pyi b/stubs/docutils/docutils/parsers/rst/roles.pyi index 2c3d65b68c94..4a319e6bbf64 100644 --- a/stubs/docutils/docutils/parsers/rst/roles.pyi +++ b/stubs/docutils/docutils/parsers/rst/roles.pyi @@ -1,11 +1,11 @@ -from typing import Any, Callable, Dict, List, Tuple +from typing import Any, Callable import docutils.nodes import docutils.parsers.rst.states _RoleFn = Callable[ - [str, str, str, int, docutils.parsers.rst.states.Inliner, Dict[str, Any], List[str]], - Tuple[List[docutils.nodes.reference], List[docutils.nodes.reference]], + [str, str, str, int, docutils.parsers.rst.states.Inliner, dict[str, Any], list[str]], + tuple[list[docutils.nodes.reference], list[docutils.nodes.reference]], ] def register_local_role(name: str, role_fn: _RoleFn) -> None: ... diff --git a/stubs/entrypoints/entrypoints.pyi b/stubs/entrypoints/entrypoints.pyi index 8b64db4c78cc..11a716f30159 100644 --- a/stubs/entrypoints/entrypoints.pyi +++ b/stubs/entrypoints/entrypoints.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self -from typing import Any, Iterator, Sequence, Text, Type +from typing import Any, Iterator, Sequence, Text if sys.version_info >= (3, 0): from configparser import ConfigParser @@ -42,7 +42,7 @@ class EntryPoint: ) -> None: ... def load(self) -> Any: ... @classmethod - def from_string(cls: Type[Self], epstr: Text, name: Text, distro: Distribution | None = ...) -> Self: ... + def from_string(cls: type[Self], epstr: Text, name: Text, distro: Distribution | None = ...) -> Self: ... class Distribution: name: Text diff --git a/stubs/filelock/filelock/__init__.pyi b/stubs/filelock/filelock/__init__.pyi index e10860f893ee..f91699ad9daf 100644 --- a/stubs/filelock/filelock/__init__.pyi +++ b/stubs/filelock/filelock/__init__.pyi @@ -1,6 +1,6 @@ import sys from types import TracebackType -from typing import Type + class Timeout(TimeoutError): def __init__(self, lock_file: str) -> None: ... @@ -10,7 +10,7 @@ class _Acquire_ReturnProxy: def __init__(self, lock: str) -> None: ... def __enter__(self) -> str: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None ) -> None: ... class BaseFileLock: @@ -27,7 +27,7 @@ class BaseFileLock: def release(self, force: bool = ...) -> None: ... def __enter__(self) -> BaseFileLock: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None ) -> None: ... def __del__(self) -> None: ... diff --git a/stubs/flake8-2020/flake8_2020.pyi b/stubs/flake8-2020/flake8_2020.pyi index 3577b66a6d12..b46c3d5ed592 100644 --- a/stubs/flake8-2020/flake8_2020.pyi +++ b/stubs/flake8-2020/flake8_2020.pyi @@ -3,12 +3,12 @@ # Therefore typeshed is the best place. import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Generator class Plugin: name: ClassVar[str] version: ClassVar[str] def __init__(self, tree: ast.AST) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... def __getattr__(name: str) -> Any: ... # incomplete (other attributes are normally not accessed) diff --git a/stubs/flake8-builtins/flake8_builtins.pyi b/stubs/flake8-builtins/flake8_builtins.pyi index e5a3d89c5f11..904be75d389a 100644 --- a/stubs/flake8-builtins/flake8_builtins.pyi +++ b/stubs/flake8-builtins/flake8_builtins.pyi @@ -1,10 +1,10 @@ import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Generator class BuiltinsChecker: name: ClassVar[str] version: ClassVar[str] def __init__(self, tree: ast.AST, filename: str) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... def __getattr__(name: str) -> Any: ... # incomplete (other attributes are normally not accessed) diff --git a/stubs/flake8-docstrings/flake8_docstrings.pyi b/stubs/flake8-docstrings/flake8_docstrings.pyi index bd8621cfec95..80c252903982 100644 --- a/stubs/flake8-docstrings/flake8_docstrings.pyi +++ b/stubs/flake8-docstrings/flake8_docstrings.pyi @@ -1,6 +1,6 @@ import argparse import ast -from typing import Any, ClassVar, Generator, Iterable, Type +from typing import Any, ClassVar, Generator, Iterable class pep257Checker: name: ClassVar[str] @@ -14,6 +14,6 @@ class pep257Checker: def add_options(cls, parser: Any) -> None: ... @classmethod def parse_options(cls, options: argparse.Namespace) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... def __getattr__(name: str) -> Any: ... # incomplete diff --git a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi index 066a43e538c5..25f910fc30b9 100644 --- a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi +++ b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi @@ -1,8 +1,8 @@ import argparse import ast -from typing import Any, Generic, Iterable, Iterator, Tuple, Type, TypeVar +from typing import Any, Generic, Iterable, Iterator, TypeVar -FLAKE8_ERROR = Tuple[int, int, str, Type[Any]] +FLAKE8_ERROR = tuple[int, int, str, type[Any]] TConfig = TypeVar("TConfig") # noqa: Y001 class Error: @@ -19,12 +19,12 @@ class Visitor(ast.NodeVisitor, Generic[TConfig]): def __init__(self, config: TConfig | None = ...) -> None: ... @property def config(self) -> TConfig: ... - def error_from_node(self, error: Type[Error], node: ast.AST, **kwargs: Any) -> None: ... + def error_from_node(self, error: type[Error], node: ast.AST, **kwargs: Any) -> None: ... class Plugin(Generic[TConfig]): name: str version: str - visitors: list[Type[Visitor[TConfig]]] + visitors: list[type[Visitor[TConfig]]] config: TConfig def __init__(self, tree: ast.AST) -> None: ... def run(self) -> Iterable[FLAKE8_ERROR]: ... diff --git a/stubs/flake8-plugin-utils/flake8_plugin_utils/utils/assertions.pyi b/stubs/flake8-plugin-utils/flake8_plugin_utils/utils/assertions.pyi index 2bd61dd8409c..d030a527f773 100644 --- a/stubs/flake8-plugin-utils/flake8_plugin_utils/utils/assertions.pyi +++ b/stubs/flake8-plugin-utils/flake8_plugin_utils/utils/assertions.pyi @@ -1,8 +1,8 @@ -from typing import Any, Type +from typing import Any from ..plugin import Error as Error, TConfig as TConfig, Visitor as Visitor def assert_error( - visitor_cls: Type[Visitor[TConfig]], src: str, expected: Type[Error], config: TConfig | None = ..., **kwargs: Any + visitor_cls: type[Visitor[TConfig]], src: str, expected: type[Error], config: TConfig | None = ..., **kwargs: Any ) -> None: ... -def assert_not_error(visitor_cls: Type[Visitor[TConfig]], src: str, config: TConfig | None = ...) -> None: ... +def assert_not_error(visitor_cls: type[Visitor[TConfig]], src: str, config: TConfig | None = ...) -> None: ... diff --git a/stubs/flake8-simplify/flake8_simplify.pyi b/stubs/flake8-simplify/flake8_simplify.pyi index 0d5e35b60672..7296c8a25c7f 100644 --- a/stubs/flake8-simplify/flake8_simplify.pyi +++ b/stubs/flake8-simplify/flake8_simplify.pyi @@ -1,8 +1,8 @@ import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Generator class Plugin: name: ClassVar[str] version: ClassVar[str] def __init__(self, tree: ast.AST) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... diff --git a/stubs/flake8-typing-imports/flake8_typing_imports.pyi b/stubs/flake8-typing-imports/flake8_typing_imports.pyi index 04585966849f..0b3fe50a1fec 100644 --- a/stubs/flake8-typing-imports/flake8_typing_imports.pyi +++ b/stubs/flake8-typing-imports/flake8_typing_imports.pyi @@ -1,6 +1,6 @@ import argparse import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Generator class Plugin: name: ClassVar[str] @@ -10,6 +10,6 @@ class Plugin: @classmethod def parse_options(cls, options: argparse.Namespace) -> None: ... def __init__(self, tree: ast.AST) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... def __getattr__(name: str) -> Any: ... # incomplete (other attributes are normally not accessed) 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/freezegun/freezegun/api.pyi b/stubs/freezegun/freezegun/api.pyi index d2aaaf4a19ea..4287c2f5e66d 100644 --- a/stubs/freezegun/freezegun/api.pyi +++ b/stubs/freezegun/freezegun/api.pyi @@ -1,7 +1,7 @@ from collections.abc import Awaitable, Callable, Iterator, Sequence from datetime import date, datetime, timedelta from numbers import Real -from typing import Any, Type, TypeVar, Union, overload +from typing import Any, TypeVar, Union, overload _T = TypeVar("_T") _Freezable = Union[str, datetime, date, timedelta] @@ -35,7 +35,7 @@ class _freeze_time: auto_tick_seconds: float, ) -> None: ... @overload - def __call__(self, func: Type[_T]) -> Type[_T]: ... + def __call__(self, func: type[_T]) -> type[_T]: ... @overload def __call__(self, func: Callable[..., Awaitable[_T]]) -> Callable[..., Awaitable[_T]]: ... @overload @@ -44,7 +44,7 @@ class _freeze_time: def __exit__(self, *args: Any) -> None: ... def start(self) -> Any: ... def stop(self) -> None: ... - def decorate_class(self, klass: Type[_T]) -> _T: ... + def decorate_class(self, klass: type[_T]) -> _T: ... def decorate_coroutine(self, coroutine: _T) -> _T: ... def decorate_callable(self, func: Callable[..., _T]) -> Callable[..., _T]: ... diff --git a/stubs/frozendict/frozendict.pyi b/stubs/frozendict/frozendict.pyi index 10c78c8e646d..238c665e73af 100644 --- a/stubs/frozendict/frozendict.pyi +++ b/stubs/frozendict/frozendict.pyi @@ -1,5 +1,5 @@ import collections -from typing import Any, Generic, Iterable, Iterator, Mapping, Type, TypeVar, overload +from typing import Any, Generic, Iterable, Iterator, Mapping, TypeVar, overload _S = TypeVar("_S") _KT = TypeVar("_KT") @@ -7,7 +7,7 @@ _VT = TypeVar("_VT") class frozendict(Mapping[_KT, _VT], Generic[_KT, _VT]): - dict_cls: Type[dict[Any, Any]] = ... + dict_cls: type[dict[Any, Any]] = ... @overload def __init__(self, **kwargs: _VT) -> None: ... @overload @@ -24,4 +24,4 @@ class frozendict(Mapping[_KT, _VT], Generic[_KT, _VT]): class FrozenOrderedDict(frozendict[_KT, _VT]): - dict_cls: Type[collections.OrderedDict[Any, Any]] = ... + dict_cls: type[collections.OrderedDict[Any, Any]] = ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi index 08d663f96e97..48093d10688f 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -1,6 +1,6 @@ import datetime from collections.abc import Iterable, Sequence -from typing import Callable, NoReturn, Type +from typing import Callable, NoReturn from typing_extensions import Literal from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module @@ -96,16 +96,16 @@ class Property(ModelAttribute): class ModelKey(Property): def __init__(self) -> None: ... - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> key_module.Key | list[key_module.Key] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> key_module.Key | list[key_module.Key] | None: ... class BooleanProperty(Property): - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bool | list[bool] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> bool | list[bool] | None: ... class IntegerProperty(Property): - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> int | list[int] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> int | list[int] | None: ... class FloatProperty(Property): - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> float | list[float] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> float | list[float] | None: ... class _CompressedValue(bytes): z_val: bytes = ... @@ -127,7 +127,7 @@ class BlobProperty(Property): verbose_name: str | None = ..., write_empty_list: bool | None = ..., ) -> None: ... - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bytes | list[bytes] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> bytes | list[bytes] | None: ... class CompressedTextProperty(BlobProperty): def __init__(self, *args, **kwargs) -> None: ... @@ -135,7 +135,7 @@ class CompressedTextProperty(BlobProperty): class TextProperty(Property): def __new__(cls, *args, **kwargs): ... def __init__(self, *args, **kwargs) -> None: ... - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> str | list[str] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> str | list[str] | None: ... class StringProperty(TextProperty): def __init__(self, *args, **kwargs) -> None: ... @@ -189,7 +189,7 @@ class KeyProperty(Property): def __init__( self, name: str | None = ..., - kind: Type[Model] | str | None = ..., + kind: type[Model] | str | None = ..., indexed: bool | None = ..., repeated: bool | None = ..., required: bool | None = ..., @@ -228,7 +228,7 @@ class StructuredProperty(Property): def IN(self, value: Iterable[object]) -> query_module.DisjunctionNode | query_module.FalseNode: ... class LocalStructuredProperty(BlobProperty): - def __init__(self, model_class: Type[Model], **kwargs) -> None: ... + def __init__(self, model_class: type[Model], **kwargs) -> None: ... class GenericProperty(Property): def __init__(self, name: str | None = ..., compressed: bool = ..., **kwargs) -> None: ... @@ -252,14 +252,14 @@ class Model(_NotEqualMixin, metaclass=MetaModel): def __hash__(self) -> NoReturn: ... def __eq__(self, other: object) -> bool: ... @classmethod - def gql(cls: Type[Model], query_string: str, *args, **kwargs) -> query_module.Query: ... + def gql(cls: type[Model], query_string: str, *args, **kwargs) -> query_module.Query: ... def put(self, **kwargs): ... def put_async(self, **kwargs) -> tasklets_module.Future: ... @classmethod - def query(cls: Type[Model], *args, **kwargs) -> query_module.Query: ... + def query(cls: type[Model], *args, **kwargs) -> query_module.Query: ... @classmethod def allocate_ids( - cls: Type[Model], + cls: type[Model], size: int | None = ..., max: int | None = ..., parent: key_module.Key | None = ..., @@ -278,7 +278,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> tuple[key_module.Key, key_module.Key]: ... @classmethod def allocate_ids_async( - cls: Type[Model], + cls: type[Model], size: int | None = ..., max: int | None = ..., parent: key_module.Key | None = ..., @@ -297,7 +297,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> tasklets_module.Future: ... @classmethod def get_by_id( - cls: Type[Model], + cls: type[Model], id: int | str | None, parent: key_module.Key | None = ..., namespace: str | None = ..., @@ -321,7 +321,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> tasklets_module.Future: ... @classmethod def get_by_id_async( - cls: Type[Model], + cls: type[Model], id: int | str, parent: key_module.Key | None = ..., namespace: str | None = ..., @@ -345,7 +345,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> Model | None: ... @classmethod def get_or_insert( - cls: Type[Model], + cls: type[Model], name: str, parent: key_module.Key | None = ..., namespace: str | None = ..., @@ -370,7 +370,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> Model: ... @classmethod def get_or_insert_async( - cls: Type[Model], + cls: type[Model], name: str, parent: key_module.Key | None = ..., namespace: str | None = ..., @@ -407,7 +407,7 @@ class Expando(Model): def __delattr__(self, name: str) -> None: ... def get_multi_async( - keys: Sequence[Type[key_module.Key]], + keys: Sequence[type[key_module.Key]], read_consistency: Literal["EVENTUAL"] | None = ..., read_policy: Literal["EVENTUAL"] | None = ..., transaction: bytes | None = ..., @@ -423,9 +423,9 @@ def get_multi_async( max_memcache_items: int | None = ..., force_writes: bool | None = ..., _options: object | None = ..., -) -> list[Type[tasklets_module.Future]]: ... +) -> list[type[tasklets_module.Future]]: ... def get_multi( - keys: Sequence[Type[key_module.Key]], + keys: Sequence[type[key_module.Key]], read_consistency: Literal["EVENTUAL"] | None = ..., read_policy: Literal["EVENTUAL"] | None = ..., transaction: bytes | None = ..., @@ -441,9 +441,9 @@ def get_multi( max_memcache_items: int | None = ..., force_writes: bool | None = ..., _options: object | None = ..., -) -> list[Type[Model] | None]: ... +) -> list[type[Model] | None]: ... def put_multi_async( - entities: list[Type[Model]], + entities: list[type[Model]], retries: int | None = ..., timeout: float | None = ..., deadline: float | None = ..., diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 7ab8c8be9f23..4fe4abfd55ab 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -1,14 +1,14 @@ import decimal from _typeshed import ReadableBuffer from datetime import date, datetime, time -from typing import Any, Sequence, Tuple, Type, overload +from typing import Any, Sequence, overload from typing_extensions import Literal from .resultrow import ResultRow apilevel: str threadsafety: int -paramstyle: Tuple[str, ...] +paramstyle: tuple[str, ...] connect = Connection class Connection: @@ -44,19 +44,19 @@ class LOB: def read(self, size: int = ..., position: int = ...) -> str | bytes: ... def write(self, object: str | bytes) -> int: ... -_Parameters = Sequence[Tuple[Any, ...]] +_Parameters = Sequence[tuple[Any, ...]] class Cursor: - description: Tuple[Tuple[Any, ...], ...] + description: tuple[tuple[Any, ...], ...] rowcount: int statementhash: str | None connection: Connection arraysize: int def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def callproc(self, procname: str, parameters: Tuple[Any, ...] = ..., overview: bool = ...) -> Tuple[Any, ...]: ... + def callproc(self, procname: str, parameters: tuple[Any, ...] = ..., overview: bool = ...) -> tuple[Any, ...]: ... def close(self) -> None: ... - def description_ext(self) -> Sequence[Tuple[Any, ...]]: ... - def execute(self, operation: str, parameters: Tuple[Any, ...]) -> bool: ... + def description_ext(self) -> Sequence[tuple[Any, ...]]: ... + def execute(self, operation: str, parameters: tuple[Any, ...]) -> bool: ... def executemany(self, operation: str, parameters: _Parameters) -> Any: ... def executemanyprepared(self, parameters: _Parameters) -> Any: ... def executeprepared(self, parameters: _Parameters = ...) -> Any: ... @@ -67,7 +67,7 @@ class Cursor: def getwarning(self) -> Warning | None: ... def haswarning(self) -> bool: ... def nextset(self) -> None: ... - def parameter_description(self) -> Tuple[str, ...]: ... + def parameter_description(self) -> tuple[str, ...]: ... @overload def prepare(self, operation: str, newcursor: Literal[True]) -> Cursor: ... @overload @@ -108,8 +108,8 @@ def Binary(data: ReadableBuffer) -> memoryview: ... Decimal = decimal.Decimal -NUMBER: Type[int] | Type[float] | Type[complex] -DATETIME: Type[date] | Type[time] | Type[datetime] +NUMBER: type[int] | type[float] | type[complex] +DATETIME: type[date] | type[time] | type[datetime] STRING = str BINARY = memoryview ROWID = int diff --git a/stubs/hdbcli/hdbcli/resultrow.pyi b/stubs/hdbcli/hdbcli/resultrow.pyi index 02a02eca91d4..cf0ee12ecd88 100644 --- a/stubs/hdbcli/hdbcli/resultrow.pyi +++ b/stubs/hdbcli/hdbcli/resultrow.pyi @@ -1,6 +1,6 @@ -from typing import Any, Tuple +from typing import Any class ResultRow: def __init__(self, *args: Any, **kwargs: Any) -> None: ... - column_names: Tuple[str, ...] - column_values: Tuple[Any, ...] + column_names: tuple[str, ...] + column_values: tuple[Any, ...] diff --git a/stubs/html5lib/html5lib/_tokenizer.pyi b/stubs/html5lib/html5lib/_tokenizer.pyi index cf62e2ca65d9..fd9f6dac7caf 100644 --- a/stubs/html5lib/html5lib/_tokenizer.pyi +++ b/stubs/html5lib/html5lib/_tokenizer.pyi @@ -1,10 +1,10 @@ import sys from collections import OrderedDict -from typing import Any, Dict +from typing import Any entitiesTrie: Any if sys.version_info >= (3, 7): - attributeMap = Dict[Any, Any] + attributeMap = dict[Any, Any] else: attributeMap = OrderedDict[Any, Any] diff --git a/stubs/html5lib/html5lib/_utils.pyi b/stubs/html5lib/html5lib/_utils.pyi index c6f85f5a622f..1ea974392438 100644 --- a/stubs/html5lib/html5lib/_utils.pyi +++ b/stubs/html5lib/html5lib/_utils.pyi @@ -1,9 +1,9 @@ from collections.abc import Mapping -from typing import Any, Dict +from typing import Any supports_lone_surrogates: bool -class MethodDispatcher(Dict[Any, Any]): +class MethodDispatcher(dict[Any, Any]): default: Any def __init__(self, items=...) -> None: ... def __getitem__(self, key): ... diff --git a/stubs/html5lib/html5lib/treebuilders/base.pyi b/stubs/html5lib/html5lib/treebuilders/base.pyi index 12e89bb296d4..8c73d5257666 100644 --- a/stubs/html5lib/html5lib/treebuilders/base.pyi +++ b/stubs/html5lib/html5lib/treebuilders/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any Marker: Any listElementsMap: Any @@ -18,7 +18,7 @@ class Node: def cloneNode(self) -> None: ... def hasContent(self) -> None: ... -class ActiveFormattingElements(List[Any]): +class ActiveFormattingElements(list[Any]): def append(self, node) -> None: ... def nodesEqual(self, node1, node2): ... diff --git a/stubs/httplib2/httplib2/__init__.pyi b/stubs/httplib2/httplib2/__init__.pyi index 14bf1dba7af8..f1da1887fee3 100644 --- a/stubs/httplib2/httplib2/__init__.pyi +++ b/stubs/httplib2/httplib2/__init__.pyi @@ -1,6 +1,6 @@ import http.client from collections.abc import Generator -from typing import Any, Dict, TypeVar +from typing import Any, TypeVar from .error import * @@ -175,7 +175,7 @@ class Http: connection_type: Any | None = ..., ): ... -class Response(Dict[str, Any]): +class Response(dict[str, Any]): fromcache: bool version: int status: int diff --git a/stubs/ldap3/ldap3/__init__.pyi b/stubs/ldap3/ldap3/__init__.pyi index 4f72194fa2bd..4e9d2efd2d8f 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 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/ldap3/ldap3/core/connection.pyi b/stubs/ldap3/ldap3/core/connection.pyi index 2b21d779b85f..339bdd4c5968 100644 --- a/stubs/ldap3/ldap3/core/connection.pyi +++ b/stubs/ldap3/ldap3/core/connection.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Any, Type +from typing import Any from typing_extensions import Literal from .server import Server @@ -101,7 +101,7 @@ class Connection: def usage(self): ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> Literal[False] | None: ... def bind(self, read_server_info: bool = ..., controls: Any | None = ...): ... def rebind( diff --git a/stubs/ldap3/ldap3/core/exceptions.pyi b/stubs/ldap3/ldap3/core/exceptions.pyi index 9e1cc81383cf..b7b3d6b30903 100644 --- a/stubs/ldap3/ldap3/core/exceptions.pyi +++ b/stubs/ldap3/ldap3/core/exceptions.pyi @@ -1,5 +1,5 @@ import socket -from typing import Any, Type, TypeVar +from typing import Any, TypeVar _T = TypeVar("_T") @@ -7,7 +7,7 @@ class LDAPException(Exception): ... class LDAPOperationResult(LDAPException): def __new__( - cls: Type[_T], + cls: type[_T], result: Any | None = ..., description: Any | None = ..., dn: Any | None = ..., diff --git a/stubs/mock/mock/mock.pyi b/stubs/mock/mock/mock.pyi index 2b29be0345a5..8aabbd12b5c2 100644 --- a/stubs/mock/mock/mock.pyi +++ b/stubs/mock/mock/mock.pyi @@ -1,9 +1,9 @@ from collections.abc import Callable, Mapping, Sequence -from typing import Any, Generic, List, Tuple, Type, TypeVar, overload +from typing import Any, Generic, TypeVar, overload _F = TypeVar("_F", bound=Callable[..., Any]) _T = TypeVar("_T") -_TT = TypeVar("_TT", bound=Type[Any]) +_TT = TypeVar("_TT", bound=type[Any]) _R = TypeVar("_R") __all__ = [ @@ -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: @@ -76,10 +76,10 @@ class NonCallableMock(Base, Any): def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ... def __init__( self, - spec: list[str] | object | Type[object] | None = ..., + spec: list[str] | object | type[object] | None = ..., wraps: Any | None = ..., name: str | None = ..., - spec_set: list[str] | object | Type[object] | None = ..., + spec_set: list[str] | object | type[object] | None = ..., parent: NonCallableMock | None = ..., _spec_state: Any | None = ..., _new_name: str = ..., @@ -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): @@ -205,7 +205,7 @@ class _patch_dict: class _patcher: TEST_PREFIX: str - dict: Type[_patch_dict] + dict: type[_patch_dict] @overload def __call__( # type: ignore[misc] self, diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index dd182c485177..f5ede45acc06 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -1,6 +1,6 @@ import abc import sys -from typing import Any, Callable, Generic, ItemsView, KeysView, Mapping, Type, TypeVar, ValuesView +from typing import Any, Callable, Generic, ItemsView, KeysView, Mapping, TypeVar, ValuesView _T = TypeVar("_T") _U = TypeVar("_U") @@ -25,7 +25,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): def viewvalues(self) -> ValuesView[object]: ... def __delitem__(self, k: NoReturn) -> None: ... -def TypedDict(typename: str, fields: dict[str, Type[Any]], total: bool = ...) -> Type[dict[str, Any]]: ... +def TypedDict(typename: str, fields: dict[str, type[Any]], total: bool = ...) -> type[dict[str, Any]]: ... def Arg(type: _T = ..., name: str | None = ...) -> _T: ... def DefaultArg(type: _T = ..., name: str | None = ...) -> _T: ... def NamedArg(type: _T = ..., name: str | None = ...) -> _T: ... 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/scope.pyi b/stubs/opentracing/opentracing/scope.pyi index ec2964d5b518..954cd2e0c6c5 100644 --- a/stubs/opentracing/opentracing/scope.pyi +++ b/stubs/opentracing/opentracing/scope.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Type + from .scope_manager import ScopeManager from .span import Span @@ -13,5 +13,5 @@ class Scope: def close(self) -> None: ... def __enter__(self) -> Scope: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stubs/opentracing/opentracing/span.pyi b/stubs/opentracing/opentracing/span.pyi index 847f16bba9f5..3f9685adb733 100644 --- a/stubs/opentracing/opentracing/span.pyi +++ b/stubs/opentracing/opentracing/span.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Any, Type +from typing import Any from .tracer import Tracer @@ -23,7 +23,7 @@ class Span: def get_baggage_item(self, key: str) -> str | None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def log_event(self: Self, event: Any, payload: Any | None = ...) -> Self: ... def log(self: Self, **kwargs: Any) -> Self: ... diff --git a/stubs/paramiko/paramiko/_winapi.pyi b/stubs/paramiko/paramiko/_winapi.pyi index 92517ba6cc45..1a302c03f980 100644 --- a/stubs/paramiko/paramiko/_winapi.pyi +++ b/stubs/paramiko/paramiko/_winapi.pyi @@ -2,7 +2,7 @@ import builtins import ctypes import sys from types import TracebackType -from typing import Any, Type, TypeVar +from typing import Any, TypeVar if sys.platform == "win32": @@ -37,7 +37,7 @@ if sys.platform == "win32": def write(self, msg: bytes) -> None: ... def read(self, n: int) -> bytes: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, tb: TracebackType | None ) -> None: ... READ_CONTROL: int STANDARD_RIGHTS_REQUIRED: int diff --git a/stubs/paramiko/paramiko/agent.pyi b/stubs/paramiko/paramiko/agent.pyi index bad43a1bc15f..24926ac1eb5c 100644 --- a/stubs/paramiko/paramiko/agent.pyi +++ b/stubs/paramiko/paramiko/agent.pyi @@ -1,6 +1,6 @@ from socket import _RetAddress, socket from threading import Thread -from typing import Protocol, Tuple +from typing import Protocol from paramiko.channel import Channel from paramiko.message import Message @@ -18,7 +18,7 @@ SSH2_AGENT_SIGN_RESPONSE: int class AgentSSH: def __init__(self) -> None: ... - def get_keys(self) -> Tuple[AgentKey, ...]: ... + def get_keys(self) -> tuple[AgentKey, ...]: ... class AgentProxyThread(Thread): def __init__(self, agent: _AgentProxy) -> None: ... diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index 6c412620ef19..11721bd2217d 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -1,11 +1,11 @@ from threading import Event -from typing import Callable, List, Tuple +from typing import Callable from paramiko.pkey import PKey from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.transport import Transport -_InteractiveCallback = Callable[[str, str, List[Tuple[str, bool]]], List[str]] +_InteractiveCallback = Callable[[str, str, list[tuple[str, bool]]], list[str]] class AuthHandler: transport: Transport diff --git a/stubs/paramiko/paramiko/client.pyi b/stubs/paramiko/paramiko/client.pyi index f088dbe537cb..4bbf3c2dc4ca 100644 --- a/stubs/paramiko/paramiko/client.pyi +++ b/stubs/paramiko/paramiko/client.pyi @@ -1,5 +1,5 @@ from socket import socket -from typing import Iterable, Mapping, NoReturn, Type +from typing import Iterable, Mapping, NoReturn from paramiko.channel import Channel, ChannelFile, ChannelStderrFile, ChannelStdinFile from paramiko.hostkeys import HostKeys @@ -15,7 +15,7 @@ class SSHClient(ClosingContextManager): def save_host_keys(self, filename: str) -> None: ... def get_host_keys(self) -> HostKeys: ... def set_log_channel(self, name: str) -> None: ... - def set_missing_host_key_policy(self, policy: Type[MissingHostKeyPolicy] | MissingHostKeyPolicy) -> None: ... + def set_missing_host_key_policy(self, policy: type[MissingHostKeyPolicy] | MissingHostKeyPolicy) -> None: ... def connect( self, hostname: str, diff --git a/stubs/paramiko/paramiko/config.pyi b/stubs/paramiko/paramiko/config.pyi index 65bb71f450a8..8a7b74f8b8c0 100644 --- a/stubs/paramiko/paramiko/config.pyi +++ b/stubs/paramiko/paramiko/config.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Dict, Iterable, Pattern +from typing import IO, Any, Iterable, Pattern from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize @@ -25,7 +25,7 @@ class LazyFqdn: host: str | None def __init__(self, config: SSHConfigDict, host: str | None = ...) -> None: ... -class SSHConfigDict(Dict[str, str]): +class SSHConfigDict(dict[str, str]): def __init__(self, *args: Any, **kwargs: Any) -> None: ... def as_bool(self, key: str) -> bool: ... def as_int(self, key: str) -> int: ... diff --git a/stubs/paramiko/paramiko/ecdsakey.pyi b/stubs/paramiko/paramiko/ecdsakey.pyi index 698362879747..b99315194c8f 100644 --- a/stubs/paramiko/paramiko/ecdsakey.pyi +++ b/stubs/paramiko/paramiko/ecdsakey.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Sequence, Type +from typing import IO, Any, Callable, Sequence from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey from cryptography.hazmat.primitives.hashes import HashAlgorithm @@ -9,15 +9,15 @@ class _ECDSACurve: nist_name: str key_length: int key_format_identifier: str - hash_object: Type[HashAlgorithm] - curve_class: Type[EllipticCurve] - def __init__(self, curve_class: Type[EllipticCurve], nist_name: str) -> None: ... + hash_object: type[HashAlgorithm] + curve_class: type[EllipticCurve] + def __init__(self, curve_class: type[EllipticCurve], nist_name: str) -> None: ... class _ECDSACurveSet: ecdsa_curves: Sequence[_ECDSACurve] def __init__(self, ecdsa_curves: Sequence[_ECDSACurve]) -> None: ... def get_key_format_identifier_list(self) -> list[str]: ... - def get_by_curve_class(self, curve_class: Type[Any]) -> _ECDSACurve | None: ... + def get_by_curve_class(self, curve_class: type[Any]) -> _ECDSACurve | None: ... def get_by_key_format_identifier(self, key_format_identifier: str) -> _ECDSACurve | None: ... def get_by_key_length(self, key_length: int) -> _ECDSACurve | None: ... diff --git a/stubs/paramiko/paramiko/file.pyi b/stubs/paramiko/paramiko/file.pyi index dbf35fc39c93..45c4acab12b6 100644 --- a/stubs/paramiko/paramiko/file.pyi +++ b/stubs/paramiko/paramiko/file.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Generic, Iterable, Tuple +from typing import Any, AnyStr, Generic, Iterable from paramiko.util import ClosingContextManager @@ -15,7 +15,7 @@ class BufferedFile(ClosingContextManager, Generic[AnyStr]): FLAG_LINE_BUFFERED: int FLAG_UNIVERSAL_NEWLINE: int - newlines: None | AnyStr | Tuple[AnyStr, ...] + newlines: None | AnyStr | tuple[AnyStr, ...] def __init__(self) -> None: ... def __del__(self) -> None: ... def __iter__(self) -> BufferedFile[Any]: ... diff --git a/stubs/paramiko/paramiko/pkey.pyi b/stubs/paramiko/paramiko/pkey.pyi index 4990501b7384..8d365917590e 100644 --- a/stubs/paramiko/paramiko/pkey.pyi +++ b/stubs/paramiko/paramiko/pkey.pyi @@ -1,4 +1,4 @@ -from typing import IO, Pattern, Type, TypeVar +from typing import IO, Pattern, TypeVar from paramiko.message import Message @@ -24,9 +24,9 @@ class PKey: def sign_ssh_data(self, data: bytes) -> Message: ... def verify_ssh_sig(self, data: bytes, msg: Message) -> bool: ... @classmethod - def from_private_key_file(cls: Type[_PK], filename: str, password: str | None = ...) -> _PK: ... + def from_private_key_file(cls: type[_PK], filename: str, password: str | None = ...) -> _PK: ... @classmethod - def from_private_key(cls: Type[_PK], file_obj: IO[str], password: str | None = ...) -> _PK: ... + def from_private_key(cls: type[_PK], file_obj: IO[str], password: str | None = ...) -> _PK: ... def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ... def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... def load_certificate(self, value: Message | str) -> None: ... diff --git a/stubs/paramiko/paramiko/py3compat.pyi b/stubs/paramiko/paramiko/py3compat.pyi index b41a04ff2f14..7ef9b1cc9341 100644 --- a/stubs/paramiko/paramiko/py3compat.pyi +++ b/stubs/paramiko/paramiko/py3compat.pyi @@ -1,14 +1,14 @@ import sys -from typing import Any, Iterable, Sequence, Text, Type, TypeVar +from typing import Any, Iterable, Sequence, Text, TypeVar _T = TypeVar("_T") PY2: bool -string_types: Type[Any] | Sequence[Type[Any]] -text_type: Type[Any] | Sequence[Type[Any]] -bytes_types: Type[Any] | Sequence[Type[Any]] -integer_types: Type[Any] | Sequence[Type[Any]] +string_types: type[Any] | Sequence[type[Any]] +text_type: type[Any] | Sequence[type[Any]] +bytes_types: type[Any] | Sequence[type[Any]] +integer_types: type[Any] | Sequence[type[Any]] long = int def input(prompt: Any) -> str: ... 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_server.pyi b/stubs/paramiko/paramiko/sftp_server.pyi index 6193ea1cbdb1..8e8dddef16e4 100644 --- a/stubs/paramiko/paramiko/sftp_server.pyi +++ b/stubs/paramiko/paramiko/sftp_server.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import Any, Type +from typing import Any from paramiko.channel import Channel from paramiko.server import ServerInterface, SubsystemHandler @@ -18,7 +18,7 @@ class SFTPServer(BaseSFTP, SubsystemHandler): server: SFTPServerInterface sock: Channel | None def __init__( - self, channel: Channel, name: str, server: ServerInterface, sftp_si: Type[SFTPServerInterface], *largs: Any, **kwargs: Any + self, channel: Channel, name: str, server: ServerInterface, sftp_si: type[SFTPServerInterface], *largs: Any, **kwargs: Any ) -> None: ... def start_subsystem(self, name: str, transport: Transport, channel: Channel) -> None: ... def finish_subsystem(self) -> None: ... diff --git a/stubs/paramiko/paramiko/ssh_gss.pyi b/stubs/paramiko/paramiko/ssh_gss.pyi index aed5ae7672fe..9c0d8bab99b9 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 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..678a47f93918 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -2,7 +2,7 @@ from logging import Logger from socket import socket from threading import Condition, Event, Lock, Thread from types import ModuleType -from typing import Any, Callable, Iterable, Protocol, Sequence, Tuple, Type +from typing import Any, Callable, Iterable, Protocol, Sequence from paramiko.auth_handler import AuthHandler, _InteractiveCallback from paramiko.channel import Channel @@ -14,7 +14,7 @@ from paramiko.sftp_client import SFTPClient from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.util import ClosingContextManager -_Addr = Tuple[str, int] +_Addr = tuple[str, int] class _KexEngine(Protocol): def start_kex(self) -> None: ... @@ -67,7 +67,7 @@ class Transport(Thread, ClosingContextManager): server_key_dict: dict[str, PKey] server_accepts: list[Channel] server_accept_cv: Condition - subsystem_table: dict[str, tuple[Type[SubsystemHandler], Tuple[Any, ...], dict[str, Any]]] + subsystem_table: dict[str, tuple[type[SubsystemHandler], tuple[Any, ...], dict[str, Any]]] sys: ModuleType def __init__( self, @@ -138,7 +138,7 @@ class Transport(Thread, ClosingContextManager): gss_trust_dns: bool = ..., ) -> None: ... def get_exception(self) -> Exception | None: ... - def set_subsystem_handler(self, name: str, handler: Type[SubsystemHandler], *larg: Any, **kwarg: Any) -> None: ... + def set_subsystem_handler(self, name: str, handler: type[SubsystemHandler], *larg: Any, **kwarg: Any) -> None: ... def is_authenticated(self) -> bool: ... def get_username(self) -> str | None: ... def get_banner(self) -> bytes | None: ... diff --git a/stubs/paramiko/paramiko/util.pyi b/stubs/paramiko/paramiko/util.pyi index 05bd5c73ffe8..0b72e6462132 100644 --- a/stubs/paramiko/paramiko/util.pyi +++ b/stubs/paramiko/paramiko/util.pyi @@ -1,7 +1,7 @@ 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, Callable, Protocol, TypeVar from paramiko.config import SSHConfig, SSHConfigDict from paramiko.hostkeys import HostKeys @@ -28,7 +28,7 @@ def format_binary_line(data: bytes) -> str: ... def safe_string(s: bytes) -> bytes: ... def bit_length(n: int) -> int: ... def tb_strings() -> list[str]: ... -def generate_key_bytes(hash_alg: Type[_Hash], salt: bytes, key: bytes | str, nbytes: int) -> bytes: ... +def generate_key_bytes(hash_alg: type[_Hash], salt: bytes, key: bytes | str, nbytes: int) -> bytes: ... def load_host_keys(filename: str) -> HostKeys: ... def parse_ssh_config(file_obj: IO[str]) -> SSHConfig: ... def lookup_ssh_host_config(hostname: str, config: SSHConfig) -> SSHConfigDict: ... @@ -46,7 +46,7 @@ def constant_time_bytes_eq(a: AnyStr, b: AnyStr) -> bool: ... class ClosingContextManager: def __enter__(self: _TC) -> _TC: ... def __exit__( - self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def clamp_value(minimum: int, val: int, maximum: int) -> int: ... diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index c4c361f1836c..4b6d57d9ed78 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -1,5 +1,5 @@ import textwrap -from typing import IO, Any, Callable, Generic, List, Text, Type, TypeVar, overload +from typing import IO, Any, Callable, Generic, Text, TypeVar, overload from typing_extensions import SupportsIndex _TB = TypeVar("_TB", bound="_BaseEntry") @@ -12,18 +12,18 @@ default_encoding: str # encoding: str # check_for_duplicates: bool @overload -def pofile(pofile: Text, *, klass: Type[_TP], **kwargs: Any) -> _TP: ... +def pofile(pofile: Text, *, klass: type[_TP], **kwargs: Any) -> _TP: ... @overload def pofile(pofile: Text, **kwargs: Any) -> POFile: ... @overload -def mofile(mofile: Text, *, klass: Type[_TM], **kwargs: Any) -> _TM: ... +def mofile(mofile: Text, *, klass: type[_TM], **kwargs: Any) -> _TM: ... @overload def mofile(mofile: Text, **kwargs: Any) -> MOFile: ... def detect_encoding(file: bytes | Text, binary_mode: bool = ...) -> str: ... def escape(st: Text) -> Text: ... def unescape(st: Text) -> Text: ... -class _BaseFile(List[_TB]): +class _BaseFile(list[_TB]): fpath: Text wrapwidth: int encoding: Text diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 1eed72c28165..e5a63e88a438 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -1,6 +1,6 @@ import sys from contextlib import AbstractContextManager -from typing import Any, Callable, Iterable, Iterator, Tuple, TypeVar +from typing import Any, Callable, Iterable, Iterator, TypeVar from ._common import ( AIX as AIX, @@ -125,7 +125,7 @@ class Process: def pid(self) -> int: ... def oneshot(self) -> AbstractContextManager[None]: ... def as_dict( - self, attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... + self, attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... ) -> dict[str, Any]: ... def parent(self) -> Process: ... def parents(self) -> list[Process]: ... @@ -188,7 +188,7 @@ class Popen(Process): def pids() -> list[int]: ... def pid_exists(pid: int) -> bool: ... def process_iter( - attrs: list[str] | Tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... + attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... ) -> Iterator[Process]: ... def wait_procs( procs: Iterable[Process], timeout: float | None = ..., callback: Callable[[Process], Any] | None = ... diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi index 149a29f52276..0362445ce1af 100644 --- a/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Tuple, TypeVar, overload +from typing import Any, Callable, TypeVar, overload import psycopg2 import psycopg2.extensions @@ -360,9 +360,9 @@ class cursor: def copy_to(self, file, table, sep=..., null=..., columns=...): ... def execute(self, query, vars=...): ... def executemany(self, query, vars_list): ... - def fetchall(self) -> list[Tuple[Any, ...]]: ... - def fetchmany(self, size=...) -> list[Tuple[Any, ...]]: ... - def fetchone(self) -> Tuple[Any, ...] | Any: ... + def fetchall(self) -> list[tuple[Any, ...]]: ... + def fetchmany(self, size=...) -> list[tuple[Any, ...]]: ... + def fetchone(self) -> tuple[Any, ...] | Any: ... def mogrify(self, *args, **kwargs): ... def nextset(self): ... def scroll(self, value, mode=...): ... diff --git a/stubs/psycopg2/psycopg2/extras.pyi b/stubs/psycopg2/psycopg2/extras.pyi index 364de1a2f85a..fdd7cf429b34 100644 --- a/stubs/psycopg2/psycopg2/extras.pyi +++ b/stubs/psycopg2/psycopg2/extras.pyi @@ -1,5 +1,5 @@ from collections import OrderedDict -from typing import Any, List +from typing import Any from psycopg2._ipaddress import register_ipaddress as register_ipaddress from psycopg2._json import ( @@ -45,7 +45,7 @@ class DictCursor(DictCursorBase): def execute(self, query, vars: Any | None = ...): ... def callproc(self, procname, vars: Any | None = ...): ... -class DictRow(List[Any]): +class DictRow(list[Any]): def __init__(self, cursor) -> None: ... def __getitem__(self, x): ... def __setitem__(self, x, v) -> None: ... diff --git a/stubs/pyOpenSSL/OpenSSL/crypto.pyi b/stubs/pyOpenSSL/OpenSSL/crypto.pyi index abfb1e3ab85d..01e5577853ce 100644 --- a/stubs/pyOpenSSL/OpenSSL/crypto.pyi +++ b/stubs/pyOpenSSL/OpenSSL/crypto.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Callable, Iterable, Sequence, Text, Tuple, Union +from typing import Any, Callable, Iterable, Sequence, Text, Union from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey @@ -118,7 +118,7 @@ class CRL: @classmethod def from_cryptography(cls, crypto_crl: CertificateRevocationList) -> CRL: ... def get_issuer(self) -> X509Name: ... - def get_revoked(self) -> Tuple[Revoked, ...]: ... + def get_revoked(self) -> tuple[Revoked, ...]: ... def set_lastUpdate(self, when: bytes) -> None: ... def set_nextUpdate(self, when: bytes) -> None: ... def set_version(self, version: int) -> None: ... @@ -166,7 +166,7 @@ class PKCS7: class PKCS12: def __init__(self) -> None: ... def export(self, passphrase: bytes | None = ..., iter: int = ..., maciter: int = ...) -> bytes: ... - def get_ca_certificates(self) -> Tuple[X509, ...]: ... + def get_ca_certificates(self) -> tuple[X509, ...]: ... def get_certificate(self) -> X509: ... def get_friendlyname(self) -> bytes | None: ... def get_privatekey(self) -> PKey: ... diff --git a/stubs/pyaudio/pyaudio.pyi b/stubs/pyaudio/pyaudio.pyi index 6849056b1d47..a724d45ffdc2 100644 --- a/stubs/pyaudio/pyaudio.pyi +++ b/stubs/pyaudio/pyaudio.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Mapping, Optional, Sequence, Tuple, Union +from typing import Callable, Mapping, Optional, Sequence, Union from typing_extensions import Final paFloat32: Final[int] = ... @@ -70,7 +70,7 @@ paMacCoreStreamInfo: PaMacCoreStreamInfo _ChannelMap = Sequence[int] _PaHostApiInfo = Mapping[str, Union[str, int]] _PaDeviceInfo = Mapping[str, Union[str, int, float]] -_StreamCallback = Callable[[Optional[bytes], int, Mapping[str, float], int], Tuple[Optional[bytes], int]] +_StreamCallback = Callable[[Optional[bytes], int, Mapping[str, float], int], tuple[Optional[bytes], int]] def get_format_from_width(width: int, unsigned: bool = ...) -> int: ... def get_portaudio_version() -> int: ... diff --git a/stubs/pycurl/pycurl.pyi b/stubs/pycurl/pycurl.pyi index f69b2b6c0060..c3517e112676 100644 --- a/stubs/pycurl/pycurl.pyi +++ b/stubs/pycurl/pycurl.pyi @@ -1,6 +1,6 @@ # TODO(MichalPokorny): more precise types -from typing import Any, Text, Tuple +from typing import Any, Text GLOBAL_ACK_EINTR: int GLOBAL_ALL: int @@ -14,7 +14,7 @@ def global_cleanup() -> None: ... version: str -def version_info() -> tuple[int, str, int, str, int, str, int, str, Tuple[str, ...], Any, int, Any]: ... +def version_info() -> tuple[int, str, int, str, int, str, int, str, tuple[str, ...], Any, int, Any]: ... class error(Exception): ... diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 58e051248fc2..514900a138de 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -1,6 +1,6 @@ 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, Callable, ContextManager, Sequence, Text, Union from typing_extensions import Literal import paramiko @@ -122,5 +122,5 @@ class Connection: def __del__(self) -> None: ... def __enter__(self) -> "Connection": ... def __exit__( - self, etype: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + self, etype: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... diff --git a/stubs/python-nmap/nmap/nmap.pyi b/stubs/python-nmap/nmap/nmap.pyi index a07d4b5e13ba..70be8d261d59 100644 --- a/stubs/python-nmap/nmap/nmap.pyi +++ b/stubs/python-nmap/nmap/nmap.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, Text, TypeVar +from typing import Any, Callable, Iterable, Iterator, Text, TypeVar from typing_extensions import TypedDict _T = TypeVar("_T") @@ -101,7 +101,7 @@ class PortScannerYield(PortScannerAsync): def wait(self, timeout: int | None = ...) -> None: ... def still_scanning(self) -> None: ... # type: ignore[override] -class PortScannerHostDict(Dict[str, Any]): +class PortScannerHostDict(dict[str, Any]): def hostnames(self) -> list[_ResultHostNames]: ... def hostname(self) -> str: ... def state(self) -> str: ... diff --git a/stubs/pyvmomi/pyVmomi/vim/view.pyi b/stubs/pyvmomi/pyVmomi/vim/view.pyi index c00ad51db1c7..114883ba3431 100644 --- a/stubs/pyvmomi/pyVmomi/vim/view.pyi +++ b/stubs/pyvmomi/pyVmomi/vim/view.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type +from typing import Any from pyVmomi.vim import ManagedEntity @@ -12,4 +12,4 @@ class ViewManager: # but in practice it seems to be `list[Type[ManagedEntity]]` # Source: https://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.view.ViewManager.html @staticmethod - def CreateContainerView(container: ManagedEntity, type: list[Type[ManagedEntity]], recursive: bool) -> ContainerView: ... + def CreateContainerView(container: ManagedEntity, type: list[type[ManagedEntity]], recursive: bool) -> ContainerView: ... diff --git a/stubs/pyvmomi/pyVmomi/vmodl/query.pyi b/stubs/pyvmomi/pyVmomi/vmodl/query.pyi index 89f2769c13f8..93e57ff5c8c0 100644 --- a/stubs/pyvmomi/pyVmomi/vmodl/query.pyi +++ b/stubs/pyvmomi/pyVmomi/vmodl/query.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type +from typing import Any from pyVmomi.vim import ManagedEntity from pyVmomi.vim.view import ContainerView @@ -6,17 +6,17 @@ from pyVmomi.vmodl import DynamicProperty class PropertyCollector: class PropertySpec: - def __init__(self, *, all: bool = ..., type: Type[ManagedEntity] = ..., pathSet: list[str] = ...) -> None: ... + def __init__(self, *, all: bool = ..., type: type[ManagedEntity] = ..., pathSet: list[str] = ...) -> None: ... all: bool - type: Type[ManagedEntity] + type: type[ManagedEntity] pathSet: list[str] class TraversalSpec: def __init__( - self, *, path: str = ..., skip: bool = ..., type: Type[ContainerView] = ..., **kwargs: Any # incomplete + self, *, path: str = ..., skip: bool = ..., type: type[ContainerView] = ..., **kwargs: Any # incomplete ) -> None: ... path: str skip: bool - type: Type[ContainerView] + type: type[ContainerView] def __getattr__(self, name: str) -> Any: ... # incomplete class RetrieveOptions: def __init__(self, *, maxObjects: int) -> None: ... diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 90655ab8f910..30ccac6466ae 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -6,14 +6,14 @@ from typing import ( Any, Callable, ClassVar, - Dict, + Generic, Iterable, Iterator, Mapping, Pattern, Sequence, - Type, + TypeVar, Union, overload, @@ -36,7 +36,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 @@ -264,7 +264,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener timeout: float | None, sleep: float, blocking_timeout: float | None, - lock_class: Type[_LockType], + lock_class: type[_LockType], thread_local: bool = ..., ) -> _LockType: ... @overload @@ -275,7 +275,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener sleep: float = ..., blocking_timeout: float | None = ..., *, - lock_class: Type[_LockType], + lock_class: type[_LockType], thread_local: bool = ..., ) -> _LockType: ... def pubsub(self, *, shard_hint: Any = ..., ignore_subscribe_messages: bool = ...) -> PubSub: ... diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index 875068195014..79a2812405ed 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, Mapping, Type +from typing import Any, Mapping from .retry import Retry @@ -84,7 +84,7 @@ class Connection: encoding: str = ..., encoding_errors: str = ..., decode_responses: bool = ..., - parser_class: Type[BaseParser] = ..., + parser_class: type[BaseParser] = ..., socket_read_size: int = ..., health_check_interval: int = ..., client_name: str | None = ..., diff --git a/stubs/redis/redis/lock.pyi b/stubs/redis/redis/lock.pyi index 7d774ccd64e5..db8ae5932276 100644 --- a/stubs/redis/redis/lock.pyi +++ b/stubs/redis/redis/lock.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, ClassVar, Protocol, Type +from typing import Any, ClassVar, Protocol from redis.client import Redis @@ -27,7 +27,7 @@ class Lock: def register_scripts(self) -> None: ... def __enter__(self) -> Lock: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... def acquire( self, blocking: bool | None = ..., blocking_timeout: None | int | float = ..., token: str | bytes | None = ... diff --git a/stubs/redis/redis/sentinel.pyi b/stubs/redis/redis/sentinel.pyi index ef757caf7609..47f3f56841a5 100644 --- a/stubs/redis/redis/sentinel.pyi +++ b/stubs/redis/redis/sentinel.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type, TypeVar, overload +from typing import Any, TypeVar, overload from typing_extensions import Literal from redis.client import Redis @@ -47,9 +47,9 @@ class Sentinel(SentinelCommands): @overload def master_for(self, service_name: str, *, connection_pool_class=..., **kwargs) -> Redis[Any]: ... @overload - def master_for(self, service_name: str, redis_class: Type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... + def master_for(self, service_name: str, redis_class: type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... @overload def slave_for(self, service_name: str, connection_pool_class=..., **kwargs) -> Redis[Any]: ... @overload - def slave_for(self, service_name: str, redis_class: Type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... + def slave_for(self, service_name: str, redis_class: type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... def execute_command(self, *args, **kwargs) -> Literal[True]: ... diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 957a0e074f78..887e8fd46745 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -1,6 +1,6 @@ import datetime from json import JSONDecoder -from typing import Any, Callable, Iterator, Text, Type +from typing import Any, Callable, Iterator, Text from . import auth, cookies, exceptions, hooks, status_codes, structures, utils from .cookies import RequestsCookieJar @@ -126,7 +126,7 @@ class Response: def json( self, *, - cls: Type[JSONDecoder] | None = ..., + cls: type[JSONDecoder] | None = ..., object_hook: Callable[[dict[Any, Any]], Any] | None = ..., parse_float: Callable[[str], Any] | None = ..., parse_int: Callable[[str], Any] | None = ..., diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index 89ba100c02af..645b5df8a330 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsItems -from typing import IO, Any, Callable, Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, TypeVar, Union +from typing import IO, Any, Callable, Iterable, Mapping, MutableMapping, Optional, Text, TypeVar, Union from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, structures, utils from .models import Response @@ -43,18 +43,18 @@ class SessionRedirectMixin: def rebuild_proxies(self, prepared_request, proxies): ... def should_strip_auth(self, old_url, new_url): ... -_Data = Union[None, Text, bytes, Mapping[str, Any], Mapping[Text, Any], Iterable[Tuple[Text, Optional[Text]]], IO[Any]] +_Data = Union[None, Text, bytes, Mapping[str, Any], Mapping[Text, Any], Iterable[tuple[Text, Optional[Text]]], IO[Any]] _Hook = Callable[[Response], Any] -_Hooks = MutableMapping[Text, List[_Hook]] +_Hooks = MutableMapping[Text, list[_Hook]] _HooksInput = MutableMapping[Text, Union[Iterable[_Hook], _Hook]] _ParamsMappingKeyType = Union[Text, bytes, int, float] _ParamsMappingValueType = Union[Text, bytes, int, float, Iterable[Union[Text, bytes, int, float]], None] _Params = Union[ SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType], - Tuple[_ParamsMappingKeyType, _ParamsMappingValueType], - Iterable[Tuple[_ParamsMappingKeyType, _ParamsMappingValueType]], + tuple[_ParamsMappingKeyType, _ParamsMappingValueType], + Iterable[tuple[_ParamsMappingKeyType, _ParamsMappingValueType]], Union[Text, bytes], ] _TextMapping = MutableMapping[Text, Text] diff --git a/stubs/requests/requests/structures.pyi b/stubs/requests/requests/structures.pyi index ed7d9a2f225c..ee342d7d4b4f 100644 --- a/stubs/requests/requests/structures.pyi +++ b/stubs/requests/requests/structures.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, Iterable, Iterator, Mapping, MutableMapping, TypeVar +from typing import Any, Generic, Iterable, Iterator, Mapping, MutableMapping, TypeVar _VT = TypeVar("_VT") @@ -12,7 +12,7 @@ class CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]): def __len__(self) -> int: ... def copy(self) -> CaseInsensitiveDict[_VT]: ... -class LookupDict(Dict[str, _VT]): +class LookupDict(dict[str, _VT]): name: Any def __init__(self, name: Any = ...) -> None: ... def __getitem__(self, key: str) -> _VT | None: ... # type: ignore[override] diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index a0b68c1a6d79..c74e32ee52a8 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -1,6 +1,6 @@ from _typeshed import IdentityFunction from logging import Logger -from typing import Any, Callable, Sequence, Tuple, Type, TypeVar +from typing import Any, Callable, Sequence, TypeVar _R = TypeVar("_R") @@ -8,7 +8,7 @@ def retry_call( f: Callable[..., _R], fargs: Sequence[Any] | None = ..., fkwargs: dict[str, Any] | None = ..., - exceptions: Type[Exception] | Tuple[Type[Exception], ...] = ..., + exceptions: type[Exception] | tuple[type[Exception], ...] = ..., tries: int = ..., delay: float = ..., max_delay: float | None = ..., @@ -17,7 +17,7 @@ def retry_call( logger: Logger | None = ..., ) -> _R: ... def retry( - exceptions: Type[Exception] | Tuple[Type[Exception], ...] = ..., + exceptions: type[Exception] | tuple[type[Exception], ...] = ..., tries: int = ..., delay: float = ..., max_delay: float | None = ..., diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index 9f121f3340fc..a7dba8debab0 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -2,7 +2,7 @@ import importlib.abc import types import zipimport from abc import ABCMeta -from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Callable, Generator, Iterable, Optional, Sequence, TypeVar, Union, overload LegacyVersion = Any # from packaging.version Version = Any # from packaging.version @@ -70,14 +70,14 @@ class Requirement: unsafe_name: str project_name: str key: str - extras: Tuple[str, ...] + extras: tuple[str, ...] specs: list[tuple[str, str]] # TODO: change this to packaging.markers.Marker | None once we can import # packaging.markers marker: Any | None @staticmethod def parse(s: str | Iterable[str]) -> Requirement: ... - def __contains__(self, item: Distribution | str | Tuple[str, ...]) -> bool: ... + def __contains__(self, item: Distribution | str | tuple[str, ...]) -> bool: ... def __eq__(self, other_requirement: Any) -> bool: ... def load_entry_point(dist: _EPDistType, group: str, name: str) -> Any: ... @@ -90,15 +90,15 @@ def get_entry_map(dist: _EPDistType, group: str) -> dict[str, EntryPoint]: ... class EntryPoint: name: str module_name: str - attrs: Tuple[str, ...] - extras: Tuple[str, ...] + attrs: tuple[str, ...] + extras: tuple[str, ...] dist: Distribution | None def __init__( self, name: str, module_name: str, - attrs: Tuple[str, ...] = ..., - extras: Tuple[str, ...] = ..., + attrs: tuple[str, ...] = ..., + extras: tuple[str, ...] = ..., dist: Distribution | None = ..., ) -> None: ... @classmethod @@ -123,7 +123,7 @@ class Distribution(IResourceProvider, IMetadataProvider): key: str extras: list[str] version: str - parsed_version: Tuple[str, ...] + parsed_version: tuple[str, ...] py_version: str platform: str | None precedence: int @@ -145,7 +145,7 @@ class Distribution(IResourceProvider, IMetadataProvider): def from_filename(cls, filename: str, metadata: _MetadataType = ..., **kw: str | None | int) -> Distribution: ... def activate(self, path: list[str] | None = ...) -> None: ... def as_requirement(self) -> Requirement: ... - def requires(self, extras: Tuple[str, ...] = ...) -> list[Requirement]: ... + def requires(self, extras: tuple[str, ...] = ...) -> list[Requirement]: ... def clone(self, **kw: str | int | None) -> Requirement: ... def egg_name(self) -> str: ... def __cmp__(self, other: Any) -> bool: ... diff --git a/stubs/setuptools/setuptools/__init__.pyi b/stubs/setuptools/setuptools/__init__.pyi index 25bd93d13671..4d1048d31193 100644 --- a/stubs/setuptools/setuptools/__init__.pyi +++ b/stubs/setuptools/setuptools/__init__.pyi @@ -1,7 +1,7 @@ from abc import abstractmethod from collections.abc import Iterable, Mapping from distutils.core import Command as _Command -from typing import Any, Type +from typing import Any from setuptools._deprecation_warning import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning from setuptools.depends import Require as Require @@ -36,14 +36,14 @@ def setup( scripts: list[str] = ..., ext_modules: list[Extension] = ..., classifiers: list[str] = ..., - distclass: Type[Distribution] = ..., + distclass: type[Distribution] = ..., script_name: str = ..., script_args: list[str] = ..., options: Mapping[str, Any] = ..., license: str = ..., keywords: list[str] | str = ..., platforms: list[str] | str = ..., - cmdclass: Mapping[str, Type[Command]] = ..., + cmdclass: Mapping[str, type[Command]] = ..., data_files: list[tuple[str, list[str]]] = ..., package_dir: Mapping[str, str] = ..., obsoletes: list[str] = ..., diff --git a/stubs/setuptools/setuptools/command/easy_install.pyi b/stubs/setuptools/setuptools/command/easy_install.pyi index 11f8224e69ad..6d7bc390a8da 100644 --- a/stubs/setuptools/setuptools/command/easy_install.pyi +++ b/stubs/setuptools/setuptools/command/easy_install.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from pkg_resources import Environment from setuptools import Command, SetuptoolsDeprecationWarning @@ -106,7 +106,7 @@ class RewritePthDistributions(PthDistributions): prelude: Any postlude: Any -class CommandSpec(List[str]): +class CommandSpec(list[str]): options: Any split_args: Any @classmethod diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 1f36799d6cfe..cefe85f5ebc4 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, TypeVar, overload from typing_extensions import Literal from . import moves as moves @@ -22,9 +22,9 @@ PY2: Literal[False] PY3: Literal[True] PY34: Literal[True] -string_types: tuple[Type[str]] -integer_types: tuple[Type[int]] -class_types: tuple[Type[Type[Any]]] +string_types: tuple[type[str]] +integer_types: tuple[type[int]] +class_types: tuple[type[type[Any]]] text_type = str binary_type = bytes @@ -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]: ... @@ -72,8 +72,8 @@ def assertRegex( exec_ = exec -def reraise(tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ... -def raise_from(value: BaseException | Type[BaseException], from_value: BaseException | None) -> NoReturn: ... +def reraise(tp: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ... +def raise_from(value: BaseException | type[BaseException], from_value: BaseException | None) -> NoReturn: ... print_ = print @@ -87,7 +87,7 @@ def python_2_unicode_compatible(klass: _T) -> _T: ... class _LazyDescr: name: str def __init__(self, name: str) -> None: ... - def __get__(self, obj: object | None, type: Type[Any] | None = ...) -> Any: ... + def __get__(self, obj: object | None, type: type[Any] | None = ...) -> Any: ... class MovedModule(_LazyDescr): mod: str diff --git a/stubs/stripe/stripe/stripe_object.pyi b/stubs/stripe/stripe/stripe_object.pyi index 25ed72a9de70..5b496bfb631a 100644 --- a/stubs/stripe/stripe/stripe_object.pyi +++ b/stubs/stripe/stripe/stripe_object.pyi @@ -1,9 +1,9 @@ import json -from typing import Any, Dict +from typing import Any from stripe import api_requestor as api_requestor -class StripeObject(Dict[Any, Any]): +class StripeObject(dict[Any, Any]): class ReprJSONEncoder(json.JSONEncoder): def default(self, obj): ... def __init__( diff --git a/stubs/tabulate/tabulate.pyi b/stubs/tabulate/tabulate.pyi index 8b5efde5bf08..1d0daa981c6c 100644 --- a/stubs/tabulate/tabulate.pyi +++ b/stubs/tabulate/tabulate.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Container, Iterable, List, Mapping, NamedTuple, Sequence, Union +from typing import Any, Callable, Container, Iterable, Mapping, NamedTuple, Sequence, Union LATEX_ESCAPE_RULES: dict[str, str] MIN_PADDING: int @@ -18,8 +18,8 @@ class DataRow(NamedTuple): sep: str end: str -_TableFormatLine = Union[None, Line, Callable[[List[int], List[str]], str]] -_TableFormatRow = Union[None, DataRow, Callable[[List[Any], List[int], List[str]], str]] +_TableFormatLine = Union[None, Line, Callable[[list[int], list[str]], str]] +_TableFormatRow = Union[None, DataRow, Callable[[list[Any], list[int], list[str]], str]] class TableFormat(NamedTuple): lineabove: _TableFormatLine diff --git a/stubs/toml/toml.pyi b/stubs/toml/toml.pyi index 3f8580b33376..cc2902e0481d 100644 --- a/stubs/toml/toml.pyi +++ b/stubs/toml/toml.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath, SupportsWrite -from typing import IO, Any, Mapping, MutableMapping, Text, Type, Union +from typing import IO, Any, Mapping, MutableMapping, Text, Union if sys.version_info >= (3, 6): _PathLike = StrPath @@ -13,7 +13,7 @@ else: class TomlDecodeError(Exception): ... -def load(f: _PathLike | list[Text] | IO[str], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... -def loads(s: Text, _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... +def load(f: _PathLike | list[Text] | IO[str], _dict: type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... +def loads(s: Text, _dict: type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... def dump(o: Mapping[str, Any], f: SupportsWrite[str]) -> str: ... def dumps(o: Mapping[str, Any]) -> str: ... 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: ... From 205ec77087ca5cda772a97a8201ebf5d5c26e767 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 15:02:38 +0000 Subject: [PATCH 3/5] Manually fix `csv`, `plistlib`, `SQLAlchemy`, `typed-ast` --- stdlib/csv.pyi | 2 +- stdlib/plistlib.pyi | 4 ++-- stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi | 4 ++-- stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi | 4 ++-- stubs/typed-ast/typed_ast/ast27.pyi | 7 +++---- stubs/typed-ast/typed_ast/ast3.pyi | 7 +++---- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 512affa88cb8..9e1969cb76a7 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, 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/plistlib.pyi b/stdlib/plistlib.pyi index 88bb04609802..6f8157fe502a 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -1,7 +1,7 @@ import sys from datetime import datetime from enum import Enum -from typing import IO, Any, Dict as _Dict, Mapping, MutableMapping +from typing import IO, Any, Mapping, MutableMapping class PlistFormat(Enum): FMT_XML: int @@ -53,7 +53,7 @@ if sys.version_info < (3, 9): def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... if sys.version_info < (3, 7): - class Dict(_Dict[str, Any]): + class Dict(dict[str, Any]): def __getattr__(self, attr: str) -> Any: ... def __setattr__(self, attr: str, value: Any) -> None: ... def __delattr__(self, attr: str) -> None: ... diff --git a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi index f89006949f96..8ec411585dcf 100644 --- a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Any, Type as TypingType +from typing import Any MypyFile = Any # from mypy.nodes AttributeContext = Any # from mypy.plugin @@ -17,4 +17,4 @@ class SQLAlchemyPlugin(Plugin): def get_attribute_hook(self, fullname: str) -> Callable[[AttributeContext], Type] | None: ... def get_additional_deps(self, file: MypyFile) -> list[tuple[int, str, int]]: ... -def plugin(version: str) -> TypingType[SQLAlchemyPlugin]: ... +def plugin(version: str) -> type[SQLAlchemyPlugin]: ... diff --git a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi index 13a6f7e9cd3d..73f16b6b265f 100644 --- a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Iterator -from typing import Any, Type as TypingType, TypeVar, overload +from typing import Any, TypeVar, overload CallExpr = Any # from mypy.nodes Context = Any # from mypy.nodes @@ -42,7 +42,7 @@ def add_global(ctx: ClassDefContext | DynamicClassDefContext, module: str, symbo @overload def get_callexpr_kwarg(callexpr: CallExpr, name: str, *, expr_types: None = ...) -> CallExpr | NameExpr | None: ... @overload -def get_callexpr_kwarg(callexpr: CallExpr, name: str, *, expr_types: tuple[TypingType[_TArgType], ...]) -> _TArgType | None: ... +def get_callexpr_kwarg(callexpr: CallExpr, name: str, *, expr_types: tuple[type[_TArgType], ...]) -> _TArgType | None: ... def flatten_typechecking(stmts: Iterable[Statement]) -> Iterator[Statement]: ... def unbound_to_instance(api: SemanticAnalyzerPluginInterface, typ: Type) -> Type: ... def info_for_cls(cls, api: SemanticAnalyzerPluginInterface) -> TypeInfo | None: ... diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index 93dbae12ee4d..f7758e881506 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -1,4 +1,3 @@ -import typing from typing import Any, Iterator class NodeVisitor: @@ -15,7 +14,7 @@ def fix_missing_locations(node: AST) -> AST: ... def get_docstring(node: AST, clean: bool = ...) -> bytes | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... -def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... +def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ... def literal_eval(node_or_string: str | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... @@ -26,8 +25,8 @@ PyCF_ONLY_AST: int identifier = str class AST: - _attributes: typing.Tuple[str, ...] - _fields: typing.Tuple[str, ...] + _attributes: tuple[str, ...] + _fields: tuple[str, ...] def __init__(self, *args: Any, **kwargs: Any) -> None: ... class mod(AST): ... diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 8d0a830541a9..996b07904e50 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -1,4 +1,3 @@ -import typing from typing import Any, Iterator class NodeVisitor: @@ -15,7 +14,7 @@ def fix_missing_locations(node: AST) -> AST: ... def get_docstring(node: AST, clean: bool = ...) -> str | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... -def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... +def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ... def literal_eval(node_or_string: str | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... @@ -26,8 +25,8 @@ PyCF_ONLY_AST: int identifier = str class AST: - _attributes: typing.Tuple[str, ...] - _fields: typing.Tuple[str, ...] + _attributes: tuple[str, ...] + _fields: tuple[str, ...] def __init__(self, *args: Any, **kwargs: Any) -> None: ... class mod(AST): ... From 691784ce545dd6de1269d17adf103a589e485e3c Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 15:06:45 +0000 Subject: [PATCH 4/5] Add exemption for `typing_extensions` --- tests/check_new_syntax.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index 5561e645ad60..6ca3c9521849 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -105,14 +105,14 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: f"instead of `typing_extensions.{imported_object_name}`" ) - elif node.module == "typing": + 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) self.generic_visit(node) def visit_Attribute(self, node: ast.Attribute) -> None: - if isinstance(node.value, ast.Name) and node.value.id == "typing": + 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) From 1410b51e6870459bb01791141b128b84b2e3f8d9 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Dec 2021 15:07:44 +0000 Subject: [PATCH 5/5] Apply black --- stdlib/_operator.pyi | 1 - stdlib/_random.pyi | 2 -- stdlib/argparse.pyi | 17 +---------------- stdlib/asyncio/__init__.pyi | 1 - stdlib/audioop.pyi | 2 -- stdlib/builtins.pyi | 2 -- stdlib/contextlib.pyi | 1 - stdlib/ctypes/__init__.pyi | 2 -- stdlib/itertools.pyi | 2 -- stdlib/mailbox.pyi | 17 +---------------- stdlib/os/__init__.pyi | 2 -- stdlib/sys.pyi | 16 +--------------- stdlib/types.pyi | 2 -- stdlib/typing_extensions.pyi | 1 - stdlib/unittest/case.pyi | 2 -- stdlib/xml/etree/ElementTree.pyi | 1 - stubs/PyMySQL/pymysql/__init__.pyi | 1 - stubs/Pygments/pygments/token.pyi | 1 - stubs/caldav/caldav/lib/error.pyi | 2 -- 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 -- stubs/filelock/filelock/__init__.pyi | 1 - stubs/opentracing/opentracing/scope.pyi | 1 - stubs/paramiko/paramiko/server.pyi | 1 - stubs/redis/redis/client.pyi | 17 +---------------- 30 files changed, 4 insertions(+), 105 deletions(-) diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index ad43a32bc279..efb2fff20e6b 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -13,7 +13,6 @@ from typing import ( Protocol, Sequence, SupportsAbs, - TypeVar, overload, ) 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/argparse.pyi b/stdlib/argparse.pyi index 5b4e3142fb7c..b0020c1cde46 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -1,20 +1,5 @@ import sys -from typing import ( - IO, - Any, - Callable, - Generator, - Generic, - Iterable, - NoReturn, - Pattern, - Protocol, - Sequence, - - - TypeVar, - overload, -) +from typing import IO, Any, Callable, Generator, Generic, Iterable, NoReturn, Pattern, Protocol, Sequence, TypeVar, overload _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) diff --git a/stdlib/asyncio/__init__.pyi b/stdlib/asyncio/__init__.pyi index 87956fdd08ef..e75874627a30 100644 --- a/stdlib/asyncio/__init__.pyi +++ b/stdlib/asyncio/__init__.pyi @@ -1,6 +1,5 @@ import sys - from .base_events import BaseEventLoop as BaseEventLoop from .coroutines import iscoroutine as iscoroutine, iscoroutinefunction as iscoroutinefunction from .events import ( 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 7180540f8f22..d797f720b280 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -49,8 +49,6 @@ from typing import ( SupportsFloat, SupportsInt, SupportsRound, - - TypeVar, Union, overload, diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 48dbd939cc77..a56b965be905 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -12,7 +12,6 @@ from typing import ( Iterator, Optional, Protocol, - TypeVar, overload, ) diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index b0e0f3930a64..16961ec9f14e 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -11,8 +11,6 @@ from typing import ( Mapping, Optional, Sequence, - - TypeVar, Union as _UnionT, overload, diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 7b801a411de9..30b5897704de 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -9,8 +9,6 @@ from typing import ( SupportsComplex, SupportsFloat, SupportsInt, - - TypeVar, Union, overload, diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index ecfe76cf605b..4ce792300ef4 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -2,22 +2,7 @@ import email.message import sys from _typeshed import Self, StrOrBytesPath from types import TracebackType -from typing import ( - IO, - Any, - AnyStr, - Callable, - Generic, - Iterable, - Iterator, - Mapping, - Protocol, - Sequence, - - TypeVar, - Union, - overload, -) +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Mapping, Protocol, Sequence, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index ad97f8ce81c5..709902e86d0d 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -24,13 +24,11 @@ from typing import ( Generic, Iterable, Iterator, - Mapping, MutableMapping, NoReturn, Protocol, Sequence, - TypeVar, Union, overload, diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index a953a634bc74..d8e6258909d5 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -4,21 +4,7 @@ from importlib.abc import PathEntryFinder from importlib.machinery import ModuleSpec from io import TextIOWrapper from types import FrameType, ModuleType, TracebackType -from typing import ( - Any, - AsyncGenerator, - Callable, - NoReturn, - Optional, - Protocol, - Sequence, - TextIO, - - - TypeVar, - Union, - overload, -) +from typing import Any, AsyncGenerator, Callable, NoReturn, Optional, Protocol, Sequence, TextIO, TypeVar, Union, overload from typing_extensions import Literal _T = TypeVar("_T") diff --git a/stdlib/types.pyi b/stdlib/types.pyi index e7cf358631c2..187dbe51d77a 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -16,8 +16,6 @@ from typing import ( KeysView, Mapping, MutableSequence, - - TypeVar, ValuesView, overload, diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index cd6290991d36..e7f288377b83 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -22,7 +22,6 @@ from typing import ( NewType as NewType, NoReturn as NoReturn, Text as Text, - Type as Type, TypeVar, ValuesView, diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 06156167da42..afcab0e76f44 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -19,8 +19,6 @@ from typing import ( NoReturn, Pattern, Sequence, - - TypeVar, overload, ) diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 6db1278de6d1..c4236cf292bb 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -4,7 +4,6 @@ from typing import ( IO, Any, Callable, - Generator, ItemsView, Iterable, 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/caldav/caldav/lib/error.pyi b/stubs/caldav/caldav/lib/error.pyi index becaa7bb7799..66de08c19f5d 100644 --- a/stubs/caldav/caldav/lib/error.pyi +++ b/stubs/caldav/caldav/lib/error.pyi @@ -1,5 +1,3 @@ - - def assert_(condition: object) -> None: ... ERR_FRAGMENT: str 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/filelock/filelock/__init__.pyi b/stubs/filelock/filelock/__init__.pyi index f91699ad9daf..2cb3fe966257 100644 --- a/stubs/filelock/filelock/__init__.pyi +++ b/stubs/filelock/filelock/__init__.pyi @@ -1,7 +1,6 @@ import sys from types import TracebackType - class Timeout(TimeoutError): def __init__(self, lock_file: str) -> None: ... def __str__(self) -> str: ... diff --git a/stubs/opentracing/opentracing/scope.pyi b/stubs/opentracing/opentracing/scope.pyi index 954cd2e0c6c5..3ab00d387ceb 100644 --- a/stubs/opentracing/opentracing/scope.pyi +++ b/stubs/opentracing/opentracing/scope.pyi @@ -1,6 +1,5 @@ from types import TracebackType - from .scope_manager import ScopeManager from .span import Span 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/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 30ccac6466ae..018f5e939371 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -2,22 +2,7 @@ import builtins import threading from _typeshed import Self, SupportsItems from datetime import datetime, timedelta -from typing import ( - Any, - Callable, - ClassVar, - - Generic, - Iterable, - Iterator, - Mapping, - Pattern, - Sequence, - - TypeVar, - Union, - overload, -) +from typing import Any, Callable, ClassVar, Generic, Iterable, Iterator, Mapping, Pattern, Sequence, TypeVar, Union, overload from typing_extensions import Literal from .commands import CoreCommands, RedisModuleCommands, SentinelCommands