From f49fb1d10cef655b4d32403a24119bd83825d94d Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 9 Feb 2026 14:19:52 +0100 Subject: [PATCH 1/7] Update project.requires-python to >=3.10 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2850ade6988c..d44ad9e7ec43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ # https://github.com/astral-sh/uv/issues/8666 name = "typeshed" version = "0" -requires-python = ">=3.9" # Minimum version to run tests, used by uv run +requires-python = ">=3.10" # Minimum version to run tests, used by uv run [tool.black] line-length = 130 From 9a792666e220744cdc6e54f3fa10ae8114d0e9e9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Feb 2026 13:24:22 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks --- lib/ts_utils/metadata.py | 3 +- lib/ts_utils/utils.py | 3 +- scripts/stubsabot.py | 4 +- stdlib/__future__.pyi | 2 +- stdlib/_ast.pyi | 27 +- stdlib/_asyncio.pyi | 4 +- stdlib/_bisect.pyi | 140 ++-- stdlib/_codecs.pyi | 8 +- stdlib/_collections_abc.pyi | 17 +- stdlib/_csv.pyi | 65 +- stdlib/_ctypes.pyi | 19 +- stdlib/_curses.pyi | 20 +- stdlib/_dbm.pyi | 4 +- stdlib/_decimal.pyi | 3 +- stdlib/_frozen_importlib.pyi | 23 +- stdlib/_frozen_importlib_external.pyi | 62 +- stdlib/_gdbm.pyi | 4 +- stdlib/_hashlib.pyi | 7 +- stdlib/_interpqueues.pyi | 3 +- stdlib/_interpreters.pyi | 4 +- stdlib/_io.pyi | 9 +- stdlib/_lsprof.pyi | 7 +- stdlib/_lzma.pyi | 4 +- stdlib/_markupbase.pyi | 6 - stdlib/_operator.pyi | 4 +- stdlib/_pickle.pyi | 4 +- stdlib/_random.pyi | 10 +- stdlib/_socket.pyi | 7 +- stdlib/_sqlite3.pyi | 15 +- stdlib/_ssl.pyi | 44 +- stdlib/_thread.pyi | 11 +- stdlib/_threading_local.pyi | 4 +- stdlib/_tkinter.pyi | 4 +- stdlib/_typeshed/__init__.pyi | 12 +- stdlib/_typeshed/dbapi.pyi | 3 +- stdlib/_typeshed/wsgi.pyi | 3 +- stdlib/_winapi.pyi | 35 +- stdlib/_zstd.pyi | 4 +- stdlib/abc.pyi | 8 +- stdlib/aifc.pyi | 4 +- stdlib/argparse.pyi | 4 +- stdlib/array.pyi | 10 +- stdlib/ast.pyi | 511 ++++++------- stdlib/asyncio/__init__.pyi | 3 +- stdlib/asyncio/base_events.pyi | 4 +- stdlib/asyncio/base_subprocess.pyi | 3 +- stdlib/asyncio/coroutines.pyi | 4 +- stdlib/asyncio/events.pyi | 6 +- stdlib/asyncio/format_helpers.pyi | 3 +- stdlib/asyncio/locks.pyi | 31 +- stdlib/asyncio/proactor_events.pyi | 32 +- stdlib/asyncio/queues.pyi | 12 +- stdlib/asyncio/sslproto.pyi | 3 +- stdlib/asyncio/streams.pyi | 83 +- stdlib/asyncio/subprocess.pyi | 66 +- stdlib/asyncio/tasks.pyi | 398 +++------- stdlib/asyncio/trsock.pyi | 4 +- stdlib/asyncore.pyi | 3 +- stdlib/audioop.pyi | 3 +- stdlib/base64.pyi | 10 +- stdlib/bdb.pyi | 4 +- stdlib/binascii.pyi | 3 +- stdlib/binhex.pyi | 3 +- stdlib/builtins.pyi | 276 +++---- stdlib/bz2.pyi | 4 +- stdlib/cProfile.pyi | 4 +- stdlib/calendar.pyi | 6 +- stdlib/cmath.pyi | 3 +- stdlib/codecs.pyi | 4 +- stdlib/collections/__init__.pyi | 45 +- stdlib/compileall.pyi | 101 +-- stdlib/compression/zstd/_zstdfile.pyi | 3 +- stdlib/concurrent/futures/interpreter.pyi | 4 +- stdlib/concurrent/futures/thread.pyi | 4 +- .../concurrent/interpreters/_crossinterp.pyi | 4 +- stdlib/configparser.pyi | 4 +- stdlib/contextlib.pyi | 90 +-- stdlib/copyreg.pyi | 3 +- stdlib/csv.pyi | 6 +- stdlib/ctypes/__init__.pyi | 4 +- stdlib/ctypes/wintypes.pyi | 4 +- stdlib/curses/__init__.pyi | 8 +- stdlib/dataclasses.pyi | 108 +-- stdlib/datetime.pyi | 4 +- stdlib/dbm/__init__.pyi | 4 +- stdlib/dbm/dumb.pyi | 3 +- stdlib/dbm/sqlite3.pyi | 4 +- stdlib/decimal.pyi | 4 +- stdlib/dis.pyi | 4 +- stdlib/distutils/ccompiler.pyi | 4 +- stdlib/distutils/command/__init__.pyi | 7 - stdlib/distutils/command/check.pyi | 3 +- stdlib/distutils/command/install.pyi | 4 - stdlib/distutils/dist.pyi | 3 +- stdlib/distutils/fancy_getopt.pyi | 3 +- stdlib/distutils/sysconfig.pyi | 4 - stdlib/doctest.pyi | 4 +- stdlib/email/__init__.pyi | 3 +- stdlib/email/errors.pyi | 6 +- stdlib/email/message.pyi | 4 +- stdlib/email/utils.pyi | 4 +- stdlib/enum.pyi | 8 +- stdlib/fcntl.pyi | 5 +- stdlib/fileinput.pyi | 196 ++--- stdlib/formatter.pyi | 3 +- stdlib/fractions.pyi | 4 +- stdlib/functools.pyi | 4 +- stdlib/gc.pyi | 3 +- stdlib/glob.pyi | 27 +- stdlib/grp.pyi | 3 +- stdlib/gzip.pyi | 4 +- stdlib/hmac.pyi | 3 +- stdlib/http/client.pyi | 4 +- stdlib/http/cookiejar.pyi | 5 +- stdlib/http/cookies.pyi | 3 +- stdlib/imaplib.pyi | 4 +- stdlib/importlib/_abc.pyi | 25 +- stdlib/importlib/abc.pyi | 80 +- stdlib/importlib/metadata/__init__.pyi | 79 +- stdlib/importlib/readers.pyi | 87 ++- stdlib/importlib/resources/__init__.pyi | 9 +- stdlib/importlib/resources/_common.pyi | 4 +- stdlib/inspect.pyi | 16 +- stdlib/ipaddress.pyi | 4 +- stdlib/itertools.pyi | 15 +- stdlib/lib2to3/pgen2/__init__.pyi | 3 +- stdlib/lib2to3/pgen2/grammar.pyi | 3 +- stdlib/lib2to3/pgen2/parse.pyi | 2 +- stdlib/lib2to3/pgen2/tokenize.pyi | 2 +- stdlib/lib2to3/pytree.pyi | 4 +- stdlib/linecache.pyi | 3 +- stdlib/locale.pyi | 5 +- stdlib/logging/__init__.pyi | 43 +- stdlib/logging/config.pyi | 26 +- stdlib/lzma.pyi | 4 +- stdlib/mailbox.pyi | 4 +- stdlib/mailcap.pyi | 2 +- stdlib/marshal.pyi | 3 +- stdlib/math.pyi | 3 +- stdlib/mmap.pyi | 3 +- stdlib/msilib/sequence.pyi | 3 +- stdlib/msvcrt.pyi | 3 +- stdlib/multiprocessing/connection.pyi | 4 +- stdlib/multiprocessing/context.pyi | 3 +- stdlib/multiprocessing/heap.pyi | 3 +- stdlib/multiprocessing/managers.pyi | 10 +- stdlib/multiprocessing/synchronize.pyi | 2 +- stdlib/netrc.pyi | 2 +- stdlib/nntplib.pyi | 4 +- stdlib/os/__init__.pyi | 62 +- stdlib/pathlib/__init__.pyi | 42 +- stdlib/pdb.pyi | 9 +- stdlib/pickletools.pyi | 3 +- stdlib/platform.pyi | 7 +- stdlib/poplib.pyi | 4 +- stdlib/posix.pyi | 32 +- stdlib/pprint.pyi | 134 +--- stdlib/profile.pyi | 4 +- stdlib/pstats.pyi | 4 +- stdlib/pty.pyi | 4 +- stdlib/pwd.pyi | 3 +- stdlib/py_compile.pyi | 8 +- stdlib/pyclbr.pyi | 68 +- stdlib/pydoc.pyi | 4 +- stdlib/pyexpat/__init__.pyi | 12 +- stdlib/random.pyi | 5 +- stdlib/re.pyi | 4 +- stdlib/readline.pyi | 3 +- stdlib/reprlib.pyi | 3 +- stdlib/resource.pyi | 37 +- stdlib/sched.pyi | 31 +- stdlib/selectors.pyi | 4 +- stdlib/shutil.pyi | 4 +- stdlib/signal.pyi | 28 +- stdlib/smtpd.pyi | 4 +- stdlib/smtplib.pyi | 4 +- stdlib/socket.pyi | 10 +- stdlib/socketserver.pyi | 4 +- stdlib/spwd.pyi | 23 +- stdlib/sqlite3/__init__.pyi | 7 +- stdlib/sqlite3/dbapi2.pyi | 17 +- stdlib/sre_parse.pyi | 3 +- stdlib/ssl.pyi | 114 +-- stdlib/statistics.pyi | 28 +- stdlib/subprocess.pyi | 710 ++---------------- stdlib/sunau.pyi | 4 +- stdlib/sys/__init__.pyi | 59 +- stdlib/sysconfig.pyi | 10 +- stdlib/tarfile.pyi | 4 +- stdlib/tempfile.pyi | 14 +- stdlib/termios.pyi | 3 +- stdlib/threading.pyi | 12 +- stdlib/time.pyi | 6 +- stdlib/timeit.pyi | 3 +- stdlib/tkinter/__init__.pyi | 17 +- stdlib/tkinter/font.pyi | 12 +- stdlib/tkinter/ttk.pyi | 4 +- stdlib/token.pyi | 6 +- stdlib/tokenize.pyi | 7 +- stdlib/trace.pyi | 4 +- stdlib/traceback.pyi | 106 +-- stdlib/tracemalloc.pyi | 3 +- stdlib/tty.pyi | 3 +- stdlib/turtle.pyi | 4 +- stdlib/types.pyi | 131 +--- stdlib/typing.pyi | 236 +++--- stdlib/typing_extensions.pyi | 68 +- stdlib/unicodedata.pyi | 7 +- stdlib/unittest/_log.pyi | 8 +- stdlib/unittest/case.pyi | 12 +- stdlib/unittest/loader.pyi | 4 +- stdlib/unittest/mock.pyi | 84 +-- stdlib/unittest/result.pyi | 3 +- stdlib/unittest/runner.pyi | 4 +- stdlib/unittest/suite.pyi | 3 +- stdlib/unittest/util.pyi | 3 +- stdlib/urllib/parse.pyi | 3 +- stdlib/urllib/request.pyi | 4 +- stdlib/uu.pyi | 3 +- stdlib/uuid.pyi | 4 +- stdlib/warnings.pyi | 4 +- stdlib/wave.pyi | 4 +- stdlib/winreg.pyi | 4 +- stdlib/wsgiref/headers.pyi | 3 +- stdlib/wsgiref/types.pyi | 3 +- stdlib/wsgiref/validate.pyi | 3 +- stdlib/xml/dom/expatbuilder.pyi | 3 +- stdlib/xml/dom/minidom.pyi | 4 +- stdlib/xml/dom/pulldom.pyi | 4 +- stdlib/xml/etree/ElementPath.pyi | 3 +- stdlib/xml/etree/ElementTree.pyi | 4 +- stdlib/xml/sax/__init__.pyi | 3 +- stdlib/xml/sax/expatreader.pyi | 21 +- stdlib/xml/sax/handler.pyi | 14 +- stdlib/xml/sax/xmlreader.pyi | 4 +- stdlib/xmlrpc/client.pyi | 4 +- stdlib/xmlrpc/server.pyi | 3 +- stdlib/xxlimited.pyi | 13 +- stdlib/zipapp.pyi | 3 +- stdlib/zipfile/__init__.pyi | 22 +- stdlib/zipimport.pyi | 43 +- stubs/Authlib/authlib/common/urls.pyi | 3 +- .../httpx_client/oauth1_client.pyi | 3 +- .../httpx_client/oauth2_client.pyi | 3 +- stubs/Authlib/authlib/jose/rfc7519/jwt.pyi | 3 +- .../oauth2/rfc6749/authorization_server.pyi | 4 +- .../rfc6749/grants/authorization_code.pyi | 2 +- .../authlib/oauth2/rfc6749/grants/base.pyi | 2 +- .../oauth2/rfc6749/grants/refresh_token.pyi | 2 +- stubs/Deprecated/deprecated/classic.pyi | 3 +- stubs/Flask-Cors/flask_cors/core.pyi | 3 +- .../Flask-Migrate/flask_migrate/__init__.pyi | 4 +- .../flask_socketio/__init__.pyi | 4 +- stubs/Markdown/markdown/treeprocessors.pyi | 3 +- stubs/Markdown/markdown/util.pyi | 9 +- stubs/PyAutoGUI/pyautogui/__init__.pyi | 4 +- stubs/PyMySQL/pymysql/converters.pyi | 4 +- stubs/PyScreeze/pyscreeze/__init__.pyi | 4 +- stubs/PySocks/socks.pyi | 4 +- stubs/PyYAML/yaml/cyaml.pyi | 3 +- stubs/PyYAML/yaml/dumper.pyi | 3 +- stubs/PyYAML/yaml/loader.pyi | 2 +- stubs/PyYAML/yaml/reader.pyi | 3 +- stubs/Pygments/pygments/plugin.pyi | 11 +- stubs/RPi.GPIO/RPi/GPIO/__init__.pyi | 3 +- stubs/WTForms/wtforms/fields/choices.pyi | 4 +- stubs/WTForms/wtforms/fields/core.pyi | 4 +- stubs/WTForms/wtforms/form.pyi | 3 +- stubs/WTForms/wtforms/meta.pyi | 3 +- stubs/WebOb/webob/_types.pyi | 3 +- stubs/WebOb/webob/acceptparse.pyi | 4 +- stubs/WebOb/webob/cookies.pyi | 3 +- stubs/WebOb/webob/dec.pyi | 4 +- stubs/WebOb/webob/descriptors.pyi | 3 +- stubs/WebOb/webob/etag.pyi | 3 +- stubs/WebOb/webob/exc.pyi | 4 +- stubs/WebOb/webob/request.pyi | 4 +- stubs/WebOb/webob/response.pyi | 4 +- .../aiofiles/aiofiles/threadpool/__init__.pyi | 3 +- stubs/assertpy/assertpy/base.pyi | 3 +- stubs/assertpy/assertpy/numeric.pyi | 3 +- stubs/auth0-python/auth0/types.pyi | 2 +- .../aws_xray_sdk/core/models/trace_header.pyi | 4 +- stubs/bleach/bleach/__init__.pyi | 2 +- stubs/bleach/bleach/callbacks.pyi | 3 +- stubs/bleach/bleach/linkifier.pyi | 3 +- stubs/bleach/bleach/sanitizer.pyi | 3 +- stubs/boltons/boltons/dictutils.pyi | 4 +- stubs/boltons/boltons/listutils.pyi | 4 +- stubs/boltons/boltons/queueutils.pyi | 2 +- stubs/braintree/braintree/util/generator.pyi | 2 +- stubs/cffi/_cffi_backend.pyi | 4 +- stubs/cffi/cffi/api.pyi | 3 +- stubs/cffi/cffi/recompiler.pyi | 3 +- stubs/cffi/cffi/verifier.pyi | 3 +- stubs/channels/channels/layers.pyi | 4 +- stubs/channels/channels/testing/live.pyi | 3 +- stubs/channels/channels/testing/websocket.pyi | 4 +- stubs/channels/channels/utils.pyi | 3 +- stubs/click-log/click_log/options.pyi | 3 +- .../click_web/resources/input_fields.pyi | 6 +- stubs/colorama/colorama/ansitowin32.pyi | 3 +- stubs/colorful/colorful/core.pyi | 4 +- stubs/croniter/croniter/croniter.pyi | 4 +- stubs/dateparser/dateparser/__init__.pyi | 3 +- stubs/dateparser/dateparser/date.pyi | 3 +- stubs/dirhash/dirhash/__init__.pyi | 3 +- stubs/django-filter/django_filters/fields.pyi | 3 +- .../rest_framework/backends.pyi | 3 +- .../import_export/admin.pyi | 4 +- .../import_export/formats/base_formats.pyi | 4 +- .../import_export/instance_loaders.pyi | 3 +- .../import_export/mixins.pyi | 4 +- .../import_export/resources.pyi | 4 +- .../import_export/results.pyi | 3 +- stubs/docker/docker/_types.pyi | 4 +- stubs/docker/docker/api/container.pyi | 3 +- stubs/docker/docker/api/network.pyi | 3 +- stubs/docker/docker/models/images.pyi | 3 +- stubs/docker/docker/transport/npipesocket.pyi | 3 +- .../dockerfile_parse/util.pyi | 3 +- stubs/docutils/docutils/examples.pyi | 3 +- stubs/docutils/docutils/nodes.pyi | 4 +- .../docutils/parsers/commonmark_wrapper.pyi | 3 +- .../docutils/parsers/rst/__init__.pyi | 3 +- .../docutils/parsers/rst/directives/body.pyi | 3 +- stubs/docutils/docutils/parsers/rst/roles.pyi | 4 +- .../docutils/docutils/parsers/rst/states.pyi | 3 +- .../docutils/parsers/rst/tableparser.pyi | 3 +- stubs/docutils/docutils/statemachine.pyi | 4 +- .../docutils/docutils/transforms/__init__.pyi | 3 +- stubs/docutils/docutils/utils/__init__.pyi | 4 +- .../docutils/docutils/utils/code_analyzer.pyi | 3 +- stubs/ephem/ephem/_libastro.pyi | 4 +- stubs/fanstatic/fanstatic/core.pyi | 3 +- stubs/flake8-builtins/flake8_builtins.pyi | 3 +- stubs/flake8/flake8/checker.pyi | 3 +- stubs/flake8/flake8/processor.pyi | 3 +- stubs/fpdf2/fpdf/_fonttools_shims.pyi | 3 +- stubs/fpdf2/fpdf/drawing.pyi | 12 +- stubs/fpdf2/fpdf/encryption.pyi | 3 +- stubs/fpdf2/fpdf/enums.pyi | 4 +- stubs/fpdf2/fpdf/fpdf.pyi | 4 +- stubs/fpdf2/fpdf/html.pyi | 3 +- stubs/fpdf2/fpdf/image_datastructures.pyi | 3 +- stubs/fpdf2/fpdf/image_parsing.pyi | 3 +- stubs/fpdf2/fpdf/util.pyi | 3 +- stubs/gdb/gdb/__init__.pyi | 4 +- stubs/gdb/gdb/dap/next.pyi | 3 +- stubs/gdb/gdb/dap/server.pyi | 3 +- stubs/gdb/gdb/dap/sources.pyi | 3 +- stubs/gdb/gdb/dap/startup.pyi | 3 +- stubs/geopandas/geopandas/_decorator.pyi | 3 +- stubs/geopandas/geopandas/array.pyi | 4 +- stubs/geopandas/geopandas/base.pyi | 4 +- stubs/geopandas/geopandas/io/_geoarrow.pyi | 3 +- stubs/geopandas/geopandas/io/sql.pyi | 3 +- stubs/geopandas/geopandas/plotting.pyi | 3 +- stubs/gevent/gevent/_ffi/loop.pyi | 4 +- stubs/gevent/gevent/_types.pyi | 4 +- stubs/gevent/gevent/_waiter.pyi | 3 +- stubs/gevent/gevent/baseserver.pyi | 4 +- stubs/gevent/gevent/event.pyi | 3 +- stubs/gevent/gevent/events.pyi | 3 +- stubs/gevent/gevent/fileobject.pyi | 3 +- stubs/gevent/gevent/libev/watcher.pyi | 3 +- stubs/gevent/gevent/selectors.pyi | 3 +- stubs/gevent/gevent/server.pyi | 3 +- stubs/gevent/gevent/threadpool.pyi | 4 +- .../google/cloud/ndb/model.pyi | 4 +- stubs/greenlet/greenlet/_greenlet.pyi | 4 +- .../grpc_reflection/v1alpha/reflection.pyi | 3 +- stubs/grpcio/grpc/__init__.pyi | 4 +- stubs/grpcio/grpc/aio/__init__.pyi | 4 +- stubs/gunicorn/gunicorn/_types.pyi | 4 +- stubs/gunicorn/gunicorn/config.pyi | 3 +- stubs/gunicorn/gunicorn/glogging.pyi | 3 +- stubs/gunicorn/gunicorn/http/body.pyi | 2 +- stubs/gunicorn/gunicorn/http2/connection.pyi | 3 +- stubs/gunicorn/gunicorn/reloader.pyi | 3 +- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 3 +- stubs/gunicorn/gunicorn/workers/gtornado.pyi | 3 +- stubs/hdbcli/hdbcli/dbapi.pyi | 4 +- stubs/html5lib/html5lib/_inputstream.pyi | 4 +- stubs/icalendar/icalendar/alarms.pyi | 2 +- stubs/icalendar/icalendar/parser_tools.pyi | 3 +- stubs/icalendar/icalendar/prop.pyi | 4 +- stubs/icalendar/icalendar/tools.pyi | 4 +- stubs/inifile/inifile.pyi | 3 +- stubs/jmespath/jmespath/ast.pyi | 4 +- stubs/jsonschema/jsonschema/_format.pyi | 3 +- stubs/jsonschema/jsonschema/_typing.pyi | 3 +- stubs/jsonschema/jsonschema/exceptions.pyi | 4 +- stubs/jsonschema/jsonschema/protocols.pyi | 3 +- stubs/jsonschema/jsonschema/validators.pyi | 4 +- stubs/jwcrypto/jwcrypto/jwk.pyi | 4 +- stubs/keyboard/keyboard/__init__.pyi | 2 +- stubs/keyboard/keyboard/_generic.pyi | 3 +- stubs/keyboard/keyboard/_mouse_event.pyi | 3 +- stubs/keyboard/keyboard/mouse.pyi | 3 +- stubs/ldap3/ldap3/core/connection.pyi | 4 +- stubs/ldap3/ldap3/utils/asn1.pyi | 3 +- stubs/libsass/sass.pyi | 4 +- stubs/lupa/lupa/lua51.pyi | 4 +- stubs/lupa/lupa/lua52.pyi | 4 +- stubs/lupa/lupa/lua53.pyi | 4 +- stubs/lupa/lupa/lua54.pyi | 4 +- stubs/m3u8/m3u8/__init__.pyi | 3 +- stubs/m3u8/m3u8/model.pyi | 3 +- stubs/m3u8/m3u8/parser.pyi | 3 +- stubs/mock/mock/backports.pyi | 7 +- stubs/mysqlclient/MySQLdb/connections.pyi | 4 +- stubs/mysqlclient/MySQLdb/cursors.pyi | 3 +- stubs/nanoid/nanoid/method.pyi | 2 +- stubs/netaddr/netaddr/eui/ieee.pyi | 3 +- stubs/netaddr/netaddr/ip/__init__.pyi | 4 +- stubs/netaddr/netaddr/ip/glob.pyi | 2 +- stubs/netaddr/netaddr/ip/iana.pyi | 3 +- stubs/netaddr/netaddr/ip/sets.pyi | 4 +- stubs/networkx/networkx/_typing.pyi | 18 +- .../algorithms/approximation/density.pyi | 3 +- .../networkx/algorithms/community/local.pyi | 3 +- .../networkx/algorithms/distance_measures.pyi | 2 +- .../algorithms/shortest_paths/weighted.pyi | 3 +- stubs/networkx/networkx/classes/graph.pyi | 4 +- .../networkx/networkx/classes/multigraph.pyi | 4 +- stubs/networkx/networkx/convert_matrix.pyi | 3 +- stubs/networkx/networkx/drawing/layout.pyi | 3 +- stubs/networkx/networkx/drawing/nx_latex.pyi | 3 +- stubs/networkx/networkx/drawing/nx_pylab.pyi | 4 +- stubs/networkx/networkx/utils/configs.pyi | 76 +- stubs/networkx/networkx/utils/misc.pyi | 7 +- stubs/oauthlib/oauthlib/common.pyi | 3 +- .../oauthlib/oauth2/rfc6749/clients/base.pyi | 3 +- .../oauth2/rfc6749/grant_types/base.pyi | 3 +- stubs/objgraph/objgraph.pyi | 3 +- stubs/olefile/olefile/olefile.pyi | 4 +- stubs/openpyxl/openpyxl/__init__.pyi | 3 +- stubs/openpyxl/openpyxl/cell/__init__.pyi | 3 +- stubs/openpyxl/openpyxl/cell/text.pyi | 3 +- stubs/openpyxl/openpyxl/chart/_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/area_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/axis.pyi | 4 +- stubs/openpyxl/openpyxl/chart/bar_chart.pyi | 3 +- .../openpyxl/openpyxl/chart/bubble_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/chartspace.pyi | 3 +- stubs/openpyxl/openpyxl/chart/error_bar.pyi | 3 +- stubs/openpyxl/openpyxl/chart/label.pyi | 3 +- stubs/openpyxl/openpyxl/chart/layout.pyi | 3 +- stubs/openpyxl/openpyxl/chart/legend.pyi | 3 +- stubs/openpyxl/openpyxl/chart/line_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/marker.pyi | 3 +- stubs/openpyxl/openpyxl/chart/picture.pyi | 3 +- stubs/openpyxl/openpyxl/chart/pie_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/radar_chart.pyi | 3 +- .../openpyxl/openpyxl/chart/scatter_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/series.pyi | 3 +- stubs/openpyxl/openpyxl/chart/shapes.pyi | 3 +- stubs/openpyxl/openpyxl/chart/trendline.pyi | 3 +- .../openpyxl/openpyxl/chartsheet/publish.pyi | 3 +- .../openpyxl/comments/comment_sheet.pyi | 3 +- .../openpyxl/comments/shape_writer.pyi | 3 +- stubs/openpyxl/openpyxl/compat/numbers.pyi | 3 +- stubs/openpyxl/openpyxl/descriptors/base.pyi | 3 +- .../openpyxl/openpyxl/descriptors/nested.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/colors.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/effect.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/fill.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/geometry.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/image.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/line.pyi | 3 +- .../openpyxl/openpyxl/drawing/properties.pyi | 3 +- .../openpyxl/drawing/spreadsheet_drawing.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/text.pyi | 3 +- stubs/openpyxl/openpyxl/formatting/rule.pyi | 3 +- stubs/openpyxl/openpyxl/formula/tokenizer.pyi | 3 +- stubs/openpyxl/openpyxl/packaging/custom.pyi | 4 +- .../openpyxl/openpyxl/packaging/workbook.pyi | 3 +- stubs/openpyxl/openpyxl/pivot/cache.pyi | 3 +- stubs/openpyxl/openpyxl/pivot/table.pyi | 3 +- stubs/openpyxl/openpyxl/reader/excel.pyi | 3 +- stubs/openpyxl/openpyxl/styles/alignment.pyi | 3 +- stubs/openpyxl/openpyxl/styles/borders.pyi | 3 +- stubs/openpyxl/openpyxl/styles/fills.pyi | 3 +- stubs/openpyxl/openpyxl/styles/fonts.pyi | 4 +- stubs/openpyxl/openpyxl/styles/numbers.pyi | 3 +- stubs/openpyxl/openpyxl/styles/table.pyi | 3 +- stubs/openpyxl/openpyxl/utils/cell.pyi | 3 +- .../workbook/external_link/external.pyi | 3 +- .../openpyxl/openpyxl/workbook/properties.pyi | 3 +- .../openpyxl/openpyxl/workbook/smart_tags.pyi | 3 +- stubs/openpyxl/openpyxl/workbook/views.pyi | 3 +- stubs/openpyxl/openpyxl/workbook/web.pyi | 3 +- stubs/openpyxl/openpyxl/workbook/workbook.pyi | 4 +- stubs/openpyxl/openpyxl/worksheet/_writer.pyi | 3 +- .../openpyxl/worksheet/datavalidation.pyi | 3 +- stubs/openpyxl/openpyxl/worksheet/filters.pyi | 3 +- stubs/openpyxl/openpyxl/worksheet/ole.pyi | 3 +- stubs/openpyxl/openpyxl/worksheet/page.pyi | 4 +- stubs/openpyxl/openpyxl/worksheet/table.pyi | 4 +- stubs/openpyxl/openpyxl/worksheet/views.pyi | 3 +- .../openpyxl/xml/_functions_overloads.pyi | 3 +- stubs/paramiko/paramiko/auth_handler.pyi | 2 +- stubs/paramiko/paramiko/message.pyi | 3 +- stubs/paramiko/paramiko/sftp_client.pyi | 4 +- stubs/paramiko/paramiko/transport.pyi | 3 +- stubs/paramiko/paramiko/win_pageant.pyi | 3 +- .../parsimonious/parsimonious/expressions.pyi | 4 +- stubs/passlib/passlib/pwd.pyi | 4 +- stubs/peewee/playhouse/flask_utils.pyi | 3 +- stubs/pexpect/pexpect/spawnbase.pyi | 3 +- stubs/pika/pika/compat.pyi | 3 +- stubs/pika/pika/data.pyi | 2 +- stubs/pika/pika/spec.pyi | 4 +- stubs/pony/pony/__init__.pyi | 3 +- stubs/pony/pony/orm/core.pyi | 4 +- stubs/pony/pony/orm/sqlbuilding.pyi | 10 +- stubs/portpicker/portpicker.pyi | 2 +- .../google/protobuf/compiler/plugin_pb2.pyi | 7 +- .../google/protobuf/descriptor_pb2.pyi | 7 +- .../google/protobuf/internal/decoder.pyi | 3 +- .../google/protobuf/internal/encoder.pyi | 2 +- .../protobuf/internal/well_known_types.pyi | 3 +- stubs/protobuf/google/protobuf/struct_pb2.pyi | 7 +- .../protobuf/google/protobuf/text_format.pyi | 3 +- stubs/protobuf/google/protobuf/type_pb2.pyi | 7 +- stubs/psutil/psutil/__init__.pyi | 35 +- stubs/psycopg2/psycopg2/_psycopg.pyi | 4 +- stubs/pyaudio/pyaudio.pyi | 3 +- stubs/pycocotools/pycocotools/coco.pyi | 3 +- stubs/pycocotools/pycocotools/cocoeval.pyi | 3 +- stubs/pycocotools/pycocotools/mask.pyi | 3 +- stubs/pyflakes/pyflakes/checker.pyi | 44 +- stubs/pyinstaller/PyInstaller/__main__.pyi | 2 +- .../PyInstaller/building/__init__.pyi | 2 +- .../pyinstaller/PyInstaller/building/api.pyi | 3 +- .../PyInstaller/building/datastruct.pyi | 4 +- .../PyInstaller/depend/analysis.pyi | 2 +- .../PyInstaller/utils/win32/versioninfo.pyi | 3 +- stubs/pyjks/jks/bks.pyi | 4 +- stubs/pyjks/jks/jks.pyi | 4 +- stubs/pyjks/jks/rfc7292.pyi | 3 +- stubs/pyjks/jks/util.pyi | 4 +- stubs/pyperclip/pyperclip/__init__.pyi | 3 +- stubs/pyserial/serial/win32.pyi | 2 +- stubs/pysftp/pysftp/__init__.pyi | 4 +- stubs/pysftp/pysftp/helpers.pyi | 2 +- stubs/python-crontab/crontab.pyi | 4 +- .../dateutil/parser/_parser.pyi | 4 +- .../dateutil/parser/isoparser.pyi | 2 +- .../dateutil/relativedelta.pyi | 4 +- stubs/python-dateutil/dateutil/rrule.pyi | 4 +- .../dateutil/zoneinfo/__init__.pyi | 4 +- stubs/python-jenkins/jenkins/__init__.pyi | 4 +- stubs/python-nmap/nmap/nmap.pyi | 3 +- stubs/python-xlib/Xlib/_typing.pyi | 3 +- stubs/python-xlib/Xlib/display.pyi | 3 +- stubs/python-xlib/Xlib/ext/composite.pyi | 3 +- stubs/python-xlib/Xlib/ext/randr.pyi | 3 +- stubs/python-xlib/Xlib/protocol/event.pyi | 3 +- stubs/python-xlib/Xlib/protocol/rq.pyi | 4 +- stubs/python-xlib/Xlib/protocol/structs.pyi | 2 +- stubs/python-xlib/Xlib/rdb.pyi | 3 +- .../python-xlib/Xlib/support/unix_connect.pyi | 3 +- stubs/pywin32/_win32typing.pyi | 4 +- stubs/pywin32/pythoncom.pyi | 4 +- stubs/pywin32/win32/lib/ntsecuritycon.pyi | 2 +- stubs/pywin32/win32com/client/__init__.pyi | 3 +- stubs/pywin32/win32com/client/dynamic.pyi | 3 +- stubs/pywin32/win32com/server/dispatcher.pyi | 2 +- stubs/pywin32/win32com/universal.pyi | 2 +- stubs/pywin32/win32comext/adsi/adsi.pyi | 2 +- stubs/pywin32/win32comext/propsys/propsys.pyi | 2 +- stubs/pywin32/win32comext/shell/shell.pyi | 2 +- stubs/pyxdg/xdg/MenuEditor.pyi | 3 +- stubs/pyxdg/xdg/Mime.pyi | 4 +- stubs/qrbill/qrbill/bill.pyi | 4 +- stubs/qrcode/qrcode/_types.pyi | 3 +- stubs/qrcode/qrcode/image/base.pyi | 3 +- stubs/qrcode/qrcode/image/pure.pyi | 3 +- stubs/qrcode/qrcode/main.pyi | 3 +- stubs/qrcode/qrcode/util.pyi | 3 +- stubs/regex/regex/_regex_core.pyi | 3 +- stubs/reportlab/reportlab/graphics/shapes.pyi | 4 +- stubs/reportlab/reportlab/lib/colors.pyi | 4 +- stubs/reportlab/reportlab/lib/fonts.pyi | 3 +- stubs/reportlab/reportlab/lib/styles.pyi | 4 +- .../reportlab/reportlab/pdfgen/textobject.pyi | 3 +- .../reportlab/platypus/doctemplate.pyi | 4 +- .../reportlab/platypus/flowables.pyi | 4 +- stubs/reportlab/reportlab/platypus/para.pyi | 4 +- .../reportlab/platypus/tableofcontents.pyi | 4 +- stubs/reportlab/reportlab/platypus/tables.pyi | 4 +- .../requests_oauthlib/oauth1_session.pyi | 3 +- .../requests_oauthlib/oauth2_session.pyi | 3 +- stubs/requests/requests/api.pyi | 2 +- stubs/requests/requests/compat.pyi | 3 +- stubs/requests/requests/models.pyi | 4 +- stubs/requests/requests/sessions.pyi | 4 +- stubs/requests/requests/utils.pyi | 3 +- .../s2clientprotocol/common_pb2.pyi | 7 +- .../s2clientprotocol/data_pb2.pyi | 7 +- .../s2clientprotocol/debug_pb2.pyi | 7 +- .../s2clientprotocol/error_pb2.pyi | 7 +- .../s2clientprotocol/raw_pb2.pyi | 7 +- .../s2clientprotocol/sc2api_pb2.pyi | 7 +- .../s2clientprotocol/score_pb2.pyi | 7 +- .../s2clientprotocol/spatial_pb2.pyi | 7 +- .../s2clientprotocol/ui_pb2.pyi | 7 +- stubs/seaborn/seaborn/_core/groupby.pyi | 3 +- stubs/seaborn/seaborn/_core/properties.pyi | 3 +- stubs/seaborn/seaborn/_core/scales.pyi | 4 +- stubs/seaborn/seaborn/_core/typing.pyi | 3 +- stubs/seaborn/seaborn/_marks/base.pyi | 3 +- stubs/seaborn/seaborn/axisgrid.pyi | 4 +- stubs/seaborn/seaborn/distributions.pyi | 4 +- stubs/seaborn/seaborn/external/kde.pyi | 3 +- stubs/seaborn/seaborn/matrix.pyi | 4 +- stubs/seaborn/seaborn/palettes.pyi | 4 +- stubs/seaborn/seaborn/regression.pyi | 3 +- stubs/seaborn/seaborn/relational.pyi | 3 +- stubs/seaborn/seaborn/utils.pyi | 4 +- .../_distutils/compilers/C/base.pyi | 4 +- .../setuptools/setuptools/_distutils/dist.pyi | 3 +- stubs/setuptools/setuptools/build_meta.pyi | 3 +- .../setuptools/command/editable_wheel.pyi | 4 +- .../setuptools/setuptools/config/setupcfg.pyi | 3 +- stubs/setuptools/setuptools/warnings.pyi | 2 +- stubs/shapely/shapely/_geometry.pyi | 3 +- stubs/shapely/shapely/_typing.pyi | 3 +- stubs/shapely/shapely/affinity.pyi | 3 +- stubs/shapely/shapely/creation.pyi | 3 +- stubs/shapely/shapely/geometry/linestring.pyi | 4 +- stubs/shapely/shapely/geometry/point.pyi | 4 +- stubs/shapely/shapely/geometry/polygon.pyi | 4 +- stubs/shapely/shapely/io.pyi | 3 +- stubs/shapely/shapely/predicates.pyi | 12 +- stubs/shapely/shapely/strtree.pyi | 3 +- stubs/simplejson/simplejson/__init__.pyi | 3 +- stubs/slumber/slumber/serialize.pyi | 3 +- stubs/tabulate/tabulate/__init__.pyi | 4 +- stubs/tensorflow/tensorflow/_aliases.pyi | 3 +- stubs/tensorflow/tensorflow/bitwise.pyi | 3 +- .../compiler/xla/service/hlo_pb2.pyi | 7 +- .../compiler/xla/service/metrics_pb2.pyi | 7 +- .../xla/tsl/protobuf/test_log_pb2.pyi | 7 +- .../tensorflow/compiler/xla/xla_data_pb2.pyi | 7 +- .../tensorflow/compiler/xla/xla_pb2.pyi | 7 +- .../tensorflow/core/framework/api_def_pb2.pyi | 7 +- .../core/framework/dataset_options_pb2.pyi | 7 +- .../core/framework/full_type_pb2.pyi | 7 +- .../framework/graph_transfer_info_pb2.pyi | 7 +- .../tensorflow/core/framework/model_pb2.pyi | 7 +- .../optimized_function_graph_pb2.pyi | 7 +- .../tensorflow/core/framework/summary_pb2.pyi | 7 +- .../tensorflow/core/framework/types_pb2.pyi | 7 +- .../core/framework/variable_pb2.pyi | 7 +- .../tensorflow/core/protobuf/config_pb2.pyi | 7 +- .../protobuf/core_platform_payloads_pb2.pyi | 7 +- .../core/protobuf/data_service_pb2.pyi | 7 +- .../core/protobuf/debug_event_pb2.pyi | 7 +- .../core/protobuf/rewriter_config_pb2.pyi | 7 +- .../core/protobuf/saved_object_graph_pb2.pyi | 7 +- .../tensorflow/core/protobuf/saver_pb2.pyi | 7 +- .../tensorflow/core/protobuf/struct_pb2.pyi | 7 +- .../core/protobuf/tensor_bundle_pb2.pyi | 7 +- .../protobuf/tpu/compilation_result_pb2.pyi | 7 +- .../tpu/optimization_parameters_pb2.pyi | 7 +- .../core/protobuf/tpu/topology_pb2.pyi | 7 +- .../tpu/tpu_embedding_configuration_pb2.pyi | 7 +- .../core/protobuf/verifier_config_pb2.pyi | 7 +- .../tensorflow/core/util/event_pb2.pyi | 7 +- stubs/tensorflow/tensorflow/io/__init__.pyi | 4 +- .../tensorflow/keras/activations.pyi | 3 +- .../tensorflow/tensorflow/keras/callbacks.pyi | 3 +- .../tensorflow/keras/initializers.pyi | 4 +- .../tensorflow/keras/layers/__init__.pyi | 4 +- stubs/tensorflow/tensorflow/keras/losses.pyi | 4 +- stubs/tensorflow/tensorflow/keras/metrics.pyi | 4 +- stubs/tensorflow/tensorflow/keras/models.pyi | 4 +- .../keras/optimizers/legacy/__init__.pyi | 3 +- .../tensorflow/keras/regularizers.pyi | 4 +- stubs/tensorflow/tensorflow/math.pyi | 3 +- .../feature_column/feature_column_v2.pyi | 4 +- stubs/tensorflow/tensorflow/random.pyi | 3 +- .../tensorflow/saved_model/__init__.pyi | 4 +- stubs/tensorflow/tensorflow/sparse.pyi | 2 +- .../tsl/protobuf/coordination_service_pb2.pyi | 7 +- .../tensorflow/tsl/protobuf/dnn_pb2.pyi | 7 +- .../tsl/protobuf/error_codes_pb2.pyi | 7 +- stubs/toml/toml/decoder.pyi | 3 +- stubs/ttkthemes/ttkthemes/_imgops.pyi | 3 +- stubs/uWSGI/uwsgi.pyi | 4 +- stubs/waitress/waitress/adjustments.pyi | 3 +- stubs/waitress/waitress/wasyncore.pyi | 2 +- stubs/watchpoints/watchpoints/watch.pyi | 3 +- .../watchpoints/watchpoints/watch_element.pyi | 3 +- stubs/workalendar/workalendar/asia/israel.pyi | 3 +- stubs/workalendar/workalendar/usa/florida.pyi | 3 +- stubs/wurlitzer/wurlitzer.pyi | 4 +- stubs/xmldiff/xmldiff/main.pyi | 3 +- stubs/xmltodict/xmltodict.pyi | 3 +- stubs/yt-dlp/yt_dlp/YoutubeDL.pyi | 4 +- stubs/yt-dlp/yt_dlp/downloader/__init__.pyi | 3 +- stubs/yt-dlp/yt_dlp/extractor/common.pyi | 4 +- stubs/yt-dlp/yt_dlp/jsinterp.pyi | 3 +- stubs/yt-dlp/yt_dlp/networking/_helper.pyi | 3 +- stubs/yt-dlp/yt_dlp/networking/common.pyi | 4 +- stubs/yt-dlp/yt_dlp/utils/_utils.pyi | 4 +- stubs/yt-dlp/yt_dlp/utils/traversal.pyi | 3 +- stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi | 2 +- tests/mypy_test.py | 3 +- tests/regr_test.py | 2 +- tests/stubtest_stdlib.py | 4 - tests/typecheck_typeshed.py | 2 +- 715 files changed, 2482 insertions(+), 5215 deletions(-) diff --git a/lib/ts_utils/metadata.py b/lib/ts_utils/metadata.py index 1b700021640c..cd09b7b1d37a 100644 --- a/lib/ts_utils/metadata.py +++ b/lib/ts_utils/metadata.py @@ -13,8 +13,7 @@ from collections.abc import Mapping from dataclasses import dataclass from pathlib import Path -from typing import Annotated, Any, Final, NamedTuple, final -from typing_extensions import TypeGuard +from typing import Annotated, Any, Final, NamedTuple, TypeGuard, final if sys.version_info >= (3, 11): import tomllib diff --git a/lib/ts_utils/utils.py b/lib/ts_utils/utils.py index d7dd6ac0fcba..fda083bfd4aa 100644 --- a/lib/ts_utils/utils.py +++ b/lib/ts_utils/utils.py @@ -9,8 +9,7 @@ from collections.abc import Iterable, Mapping from pathlib import Path from types import MethodType -from typing import TYPE_CHECKING, Any, Final, NamedTuple -from typing_extensions import TypeAlias +from typing import TYPE_CHECKING, Any, Final, NamedTuple, TypeAlias import pathspec from packaging.requirements import Requirement diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 07b66fa21b4f..72cb37a2533f 100755 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -22,8 +22,8 @@ from dataclasses import dataclass, field from http import HTTPStatus from pathlib import Path -from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypedDict, TypeVar -from typing_extensions import Self, TypeAlias +from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypeAlias, TypedDict, TypeVar +from typing_extensions import Self if sys.version_info >= (3, 11): import tomllib diff --git a/stdlib/__future__.pyi b/stdlib/__future__.pyi index a90cf1eddab7..aa445d22bd20 100644 --- a/stdlib/__future__.pyi +++ b/stdlib/__future__.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeAlias +from typing import TypeAlias _VersionInfo: TypeAlias = tuple[int, int, int, str, int] diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index d8d5a1829991..cc2f9d743309 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -122,20 +122,19 @@ if sys.version_info >= (3, 12): if sys.version_info >= (3, 11): from ast import TryStar as TryStar -if sys.version_info >= (3, 10): - from ast import ( - Match as Match, - MatchAs as MatchAs, - MatchClass as MatchClass, - MatchMapping as MatchMapping, - MatchOr as MatchOr, - MatchSequence as MatchSequence, - MatchSingleton as MatchSingleton, - MatchStar as MatchStar, - MatchValue as MatchValue, - match_case as match_case, - pattern as pattern, - ) +from ast import ( + Match as Match, + MatchAs as MatchAs, + MatchClass as MatchClass, + MatchMapping as MatchMapping, + MatchOr as MatchOr, + MatchSequence as MatchSequence, + MatchSingleton as MatchSingleton, + MatchStar as MatchStar, + MatchValue as MatchValue, + match_case as match_case, + pattern as pattern, +) PyCF_ALLOW_TOP_LEVEL_AWAIT: Final = 8192 PyCF_ONLY_AST: Final = 1024 diff --git a/stdlib/_asyncio.pyi b/stdlib/_asyncio.pyi index d663f5d93555..76fd3048f654 100644 --- a/stdlib/_asyncio.pyi +++ b/stdlib/_asyncio.pyi @@ -3,8 +3,8 @@ from asyncio.events import AbstractEventLoop from collections.abc import Awaitable, Callable, Coroutine, Generator from contextvars import Context from types import FrameType, GenericAlias -from typing import Any, Literal, TextIO, TypeVar -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Literal, TextIO, TypeAlias, TypeVar +from typing_extensions import Self, disjoint_base _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) diff --git a/stdlib/_bisect.pyi b/stdlib/_bisect.pyi index 58488e3d15af..9b1d9753b6f3 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -1,84 +1,68 @@ -import sys from _typeshed import SupportsLenAndGetItem, SupportsRichComparisonT from collections.abc import Callable, MutableSequence from typing import TypeVar, overload _T = TypeVar("_T") -if sys.version_info >= (3, 10): - @overload - def bisect_left( - a: SupportsLenAndGetItem[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, - ) -> int: ... - @overload - def bisect_left( - a: SupportsLenAndGetItem[_T], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: Callable[[_T], SupportsRichComparisonT], - ) -> int: ... - @overload - def bisect_right( - a: SupportsLenAndGetItem[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, - ) -> int: ... - @overload - def bisect_right( - a: SupportsLenAndGetItem[_T], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: Callable[[_T], SupportsRichComparisonT], - ) -> int: ... - @overload - def insort_left( - a: MutableSequence[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, - ) -> None: ... - @overload - def insort_left( - a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] - ) -> None: ... - @overload - def insort_right( - a: MutableSequence[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, - ) -> None: ... - @overload - def insort_right( - a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] - ) -> None: ... - -else: - def bisect_left( - a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None - ) -> int: ... - def bisect_right( - a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None - ) -> int: ... - def insort_left( - a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None - ) -> None: ... - def insort_right( - a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None - ) -> None: ... +@overload +def bisect_left( + a: SupportsLenAndGetItem[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, +) -> int: ... +@overload +def bisect_left( + a: SupportsLenAndGetItem[_T], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: Callable[[_T], SupportsRichComparisonT], +) -> int: ... +@overload +def bisect_right( + a: SupportsLenAndGetItem[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, +) -> int: ... +@overload +def bisect_right( + a: SupportsLenAndGetItem[_T], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: Callable[[_T], SupportsRichComparisonT], +) -> int: ... +@overload +def insort_left( + a: MutableSequence[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, +) -> None: ... +@overload +def insort_left( + a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] +) -> None: ... +@overload +def insort_right( + a: MutableSequence[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, +) -> None: ... +@overload +def insort_right( + a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] +) -> None: ... diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 89f97edb9ba8..98cffdb0bd38 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -2,8 +2,7 @@ import codecs import sys from _typeshed import ReadableBuffer from collections.abc import Callable -from typing import Literal, final, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, final, overload, type_check_only # This type is not exposed; it is defined in unicodeobject.c # At runtime it calls itself builtins.EncodingMap @@ -17,10 +16,7 @@ _Handler: TypeAlias = Callable[[UnicodeError], tuple[str | bytes, int]] _SearchFunction: TypeAlias = Callable[[str], codecs.CodecInfo | None] def register(search_function: _SearchFunction, /) -> None: ... - -if sys.version_info >= (3, 10): - def unregister(search_function: _SearchFunction, /) -> None: ... - +def unregister(search_function: _SearchFunction, /) -> None: ... def register_error(errors: str, handler: _Handler, /) -> None: ... def lookup_error(name: str, /) -> _Handler: ... diff --git a/stdlib/_collections_abc.pyi b/stdlib/_collections_abc.pyi index 319577c9284b..62e059da5916 100644 --- a/stdlib/_collections_abc.pyi +++ b/stdlib/_collections_abc.pyi @@ -75,16 +75,15 @@ class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented __hash__: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 13): def isdisjoint(self, other: Iterable[_KT_co], /) -> bool: ... - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented def __reversed__(self) -> Iterator[_VT_co]: ... - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented @@ -93,9 +92,9 @@ class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented __hash__: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 13): def isdisjoint(self, other: Iterable[tuple[_KT_co, _VT_co]], /) -> bool: ... - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... if sys.version_info >= (3, 12): @runtime_checkable diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index ea90766afee6..877b0fb714d6 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -2,8 +2,8 @@ import csv import sys from _typeshed import SupportsWrite from collections.abc import Iterable -from typing import Any, Final, Literal, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Final, Literal, TypeAlias +from typing_extensions import Self, disjoint_base __version__: Final[str] @@ -47,50 +47,31 @@ class Dialect: strict: bool = False, ) -> Self: ... -if sys.version_info >= (3, 10): - # This class calls itself _csv.reader. - @disjoint_base - class Reader: - @property - def dialect(self) -> Dialect: ... - line_num: int - def __iter__(self) -> Self: ... - def __next__(self) -> list[str]: ... - - # This class calls itself _csv.writer. - @disjoint_base - class Writer: - @property - def dialect(self) -> Dialect: ... - if sys.version_info >= (3, 13): - def writerow(self, row: Iterable[Any], /) -> Any: ... - def writerows(self, rows: Iterable[Iterable[Any]], /) -> None: ... - else: - def writerow(self, row: Iterable[Any]) -> Any: ... - def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... - - # For the return types below. - # These aliases can be removed when typeshed drops support for 3.9. - _reader = Reader - _writer = Writer -else: - # This class is not exposed. It calls itself _csv.reader. - @type_check_only - class _reader: - @property - def dialect(self) -> Dialect: ... - line_num: int - def __iter__(self) -> Self: ... - def __next__(self) -> list[str]: ... +@disjoint_base +class Reader: + @property + def dialect(self) -> Dialect: ... + line_num: int + def __iter__(self) -> Self: ... + def __next__(self) -> list[str]: ... - # This class is not exposed. It calls itself _csv.writer. - @type_check_only - class _writer: - @property - def dialect(self) -> Dialect: ... +# This class calls itself _csv.writer. +@disjoint_base +class Writer: + @property + def dialect(self) -> Dialect: ... + if sys.version_info >= (3, 13): + def writerow(self, row: Iterable[Any], /) -> Any: ... + def writerows(self, rows: Iterable[Iterable[Any]], /) -> None: ... + else: def writerow(self, row: Iterable[Any]) -> Any: ... def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... +# For the return types below. +# These aliases can be removed when typeshed drops support for 3.9. +_reader = Reader +_writer = Writer + def writer( fileobj: SupportsWrite[str], /, diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index 3c4308628c8c..ce0ad45f775c 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -6,8 +6,8 @@ from abc import abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p from types import GenericAlias -from typing import Any, ClassVar, Final, Generic, Literal, SupportsIndex, TypeVar, final, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, Final, Generic, Literal, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only +from typing_extensions import Self _T = TypeVar("_T") _CT = TypeVar("_CT", bound=_CData) @@ -223,17 +223,10 @@ else: class _CField(Generic[_CT, _GetT, _SetT]): offset: int size: int - if sys.version_info >= (3, 10): - @overload - def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... - @overload - def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ... - else: - @overload - def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ... - @overload - def __get__(self, instance: Any, owner: type[Any] | None, /) -> _GetT: ... - + @overload + def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... + @overload + def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ... def __set__(self, instance: Any, value: _SetT, /) -> None: ... # This class is not exposed. It calls itself _ctypes.UnionType. diff --git a/stdlib/_curses.pyi b/stdlib/_curses.pyi index d4e4d48f4e20..ed7dfce6de31 100644 --- a/stdlib/_curses.pyi +++ b/stdlib/_curses.pyi @@ -1,8 +1,7 @@ import sys from _typeshed import ReadOnlyBuffer, SupportsRead, SupportsWrite from curses import _ncurses_version -from typing import Any, Final, final, overload -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias, final, overload # NOTE: This module is ordinarily only available on Unix, but the windows-curses # package makes it available on Windows as well with the same contents. @@ -96,13 +95,12 @@ BUTTON4_PRESSED: Final[int] BUTTON4_RELEASED: Final[int] BUTTON4_TRIPLE_CLICKED: Final[int] # Darwin ncurses doesn't provide BUTTON5_* constants prior to 3.12.10 and 3.13.3 -if sys.version_info >= (3, 10): - if sys.version_info >= (3, 12) or sys.platform != "darwin": - BUTTON5_PRESSED: Final[int] - BUTTON5_RELEASED: Final[int] - BUTTON5_CLICKED: Final[int] - BUTTON5_DOUBLE_CLICKED: Final[int] - BUTTON5_TRIPLE_CLICKED: Final[int] +if sys.version_info >= (3, 12) or sys.platform != "darwin": + BUTTON5_PRESSED: Final[int] + BUTTON5_RELEASED: Final[int] + BUTTON5_CLICKED: Final[int] + BUTTON5_DOUBLE_CLICKED: Final[int] + BUTTON5_TRIPLE_CLICKED: Final[int] BUTTON_ALT: Final[int] BUTTON_CTRL: Final[int] BUTTON_SHIFT: Final[int] @@ -300,9 +298,7 @@ def getsyx() -> tuple[int, int]: ... def getwin(file: SupportsRead[bytes], /) -> window: ... def halfdelay(tenths: int, /) -> None: ... def has_colors() -> bool: ... - -if sys.version_info >= (3, 10): - def has_extended_color_support() -> bool: ... +def has_extended_color_support() -> bool: ... if sys.version_info >= (3, 14): def assume_default_colors(fg: int, bg: int, /) -> None: ... diff --git a/stdlib/_dbm.pyi b/stdlib/_dbm.pyi index 222c3ffcb246..615b5272a4f5 100644 --- a/stdlib/_dbm.pyi +++ b/stdlib/_dbm.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ReadOnlyBuffer, StrOrBytesPath from types import TracebackType -from typing import Final, TypeVar, final, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Final, TypeAlias, TypeVar, final, overload, type_check_only +from typing_extensions import Self if sys.platform != "win32": _T = TypeVar("_T") diff --git a/stdlib/_decimal.pyi b/stdlib/_decimal.pyi index 3cfe8944dfaf..ab1acdc74a1b 100644 --- a/stdlib/_decimal.pyi +++ b/stdlib/_decimal.pyi @@ -19,8 +19,7 @@ from decimal import ( Underflow as Underflow, _ContextManager, ) -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias _TrapType: TypeAlias = type[DecimalException] diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 58db64a016f3..172da4522d8f 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -74,16 +74,11 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(module: types.ModuleType) -> str: ... - if sys.version_info >= (3, 10): - @staticmethod - def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... - @staticmethod - def exec_module(module: types.ModuleType) -> None: ... - else: - @classmethod - def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ... - @classmethod - def exec_module(cls, module: types.ModuleType) -> None: ... + + @staticmethod + def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... + @staticmethod + def exec_module(module: types.ModuleType) -> None: ... class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder @@ -113,12 +108,8 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(m: types.ModuleType) -> str: ... - if sys.version_info >= (3, 10): - @staticmethod - def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... - else: - @classmethod - def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ... + @staticmethod + def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... @staticmethod def exec_module(module: types.ModuleType) -> None: ... diff --git a/stdlib/_frozen_importlib_external.pyi b/stdlib/_frozen_importlib_external.pyi index 660cee6e84ec..f5b1045a11f0 100644 --- a/stdlib/_frozen_importlib_external.pyi +++ b/stdlib/_frozen_importlib_external.pyi @@ -1,19 +1,16 @@ import _ast -import _io import importlib.abc import importlib.machinery +import importlib.readers import sys import types from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath from _typeshed.importlib import LoaderProtocol -from collections.abc import Callable, Iterable, Iterator, Mapping, MutableSequence, Sequence +from collections.abc import Callable, Iterable, Mapping, MutableSequence, Sequence from importlib.machinery import ModuleSpec from importlib.metadata import DistributionFinder, PathDistribution from typing import Any, Final, Literal, overload -from typing_extensions import Self, deprecated - -if sys.version_info >= (3, 10): - import importlib.readers +from typing_extensions import deprecated if sys.platform == "win32": path_separators: Literal["\\/"] @@ -58,19 +55,10 @@ class WindowsRegistryFinder(importlib.abc.MetaPathFinder): ) -> ModuleSpec | None: ... class PathFinder(importlib.abc.MetaPathFinder): - if sys.version_info >= (3, 10): - @staticmethod - def invalidate_caches() -> None: ... - else: - @classmethod - def invalidate_caches(cls) -> None: ... - if sys.version_info >= (3, 10): - @staticmethod - def find_distributions(context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... - else: - @classmethod - def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... - + @staticmethod + def invalidate_caches() -> None: ... + @staticmethod + def find_distributions(context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... @classmethod def find_spec( cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None @@ -117,14 +105,7 @@ class FileLoader: def get_data(self, path: str) -> bytes: ... def get_filename(self, fullname: str | None = None) -> str: ... def load_module(self, fullname: str | None = None) -> types.ModuleType: ... - if sys.version_info >= (3, 10): - def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ... - else: - def get_resource_reader(self, name: str | None = None) -> Self | None: ... - def open_resource(self, resource: str) -> _io.FileIO: ... - def resource_path(self, resource: str) -> str: ... - def is_resource(self, name: str) -> bool: ... - def contents(self) -> Iterator[str]: ... + def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ... class SourceFileLoader(importlib.abc.FileLoader, FileLoader, importlib.abc.SourceLoader, SourceLoader): # type: ignore[misc] # incompatible method arguments in base classes def set_data(self, path: str, data: ReadableBuffer, *, _mode: int = 0o666) -> None: ... @@ -183,24 +164,15 @@ else: def get_code(self, fullname: str) -> types.CodeType: ... def create_module(self, spec: ModuleSpec) -> None: ... def exec_module(self, module: types.ModuleType) -> None: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.") - def load_module(self, fullname: str) -> types.ModuleType: ... - @staticmethod - @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. " - "The module spec is now used by the import machinery to generate a module repr." - ) - def module_repr(module: types.ModuleType) -> str: ... - def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... - else: - def load_module(self, fullname: str) -> types.ModuleType: ... - @classmethod - @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. " - "The module spec is now used by the import machinery to generate a module repr." - ) - def module_repr(cls, module: types.ModuleType) -> str: ... + @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.") + def load_module(self, fullname: str) -> types.ModuleType: ... + @staticmethod + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." + ) + def module_repr(module: types.ModuleType) -> str: ... + def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... if sys.version_info >= (3, 13): class AppleFrameworkLoader(ExtensionFileLoader, importlib.abc.ExecutionLoader): ... diff --git a/stdlib/_gdbm.pyi b/stdlib/_gdbm.pyi index 2cb5fba29dfa..98c18f8bf4f0 100644 --- a/stdlib/_gdbm.pyi +++ b/stdlib/_gdbm.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ReadOnlyBuffer, StrOrBytesPath from types import TracebackType -from typing import TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self if sys.platform != "win32": _T = TypeVar("_T") diff --git a/stdlib/_hashlib.pyi b/stdlib/_hashlib.pyi index 03c1eef3be3f..e9e5ec8a2f8a 100644 --- a/stdlib/_hashlib.pyi +++ b/stdlib/_hashlib.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import ReadableBuffer from collections.abc import Callable from types import ModuleType -from typing import AnyStr, Protocol, final, overload, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import AnyStr, Protocol, TypeAlias, final, overload, type_check_only +from typing_extensions import Self, disjoint_base _DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType | None @@ -35,8 +35,7 @@ class HASH: def hexdigest(self) -> str: ... def update(self, obj: ReadableBuffer, /) -> None: ... -if sys.version_info >= (3, 10): - class UnsupportedDigestmodError(ValueError): ... +class UnsupportedDigestmodError(ValueError): ... class HASHXOF(HASH): def digest(self, length: int) -> bytes: ... # type: ignore[override] diff --git a/stdlib/_interpqueues.pyi b/stdlib/_interpqueues.pyi index c9323b106f3d..5586b9bd7b20 100644 --- a/stdlib/_interpqueues.pyi +++ b/stdlib/_interpqueues.pyi @@ -1,5 +1,4 @@ -from typing import Any, Literal, SupportsIndex -from typing_extensions import TypeAlias +from typing import Any, Literal, SupportsIndex, TypeAlias _UnboundOp: TypeAlias = Literal[1, 2, 3] diff --git a/stdlib/_interpreters.pyi b/stdlib/_interpreters.pyi index 8e097efad618..c4cbeccaa571 100644 --- a/stdlib/_interpreters.pyi +++ b/stdlib/_interpreters.pyi @@ -1,7 +1,7 @@ import types from collections.abc import Callable -from typing import Any, Final, Literal, SupportsIndex, TypeVar, overload -from typing_extensions import TypeAlias, disjoint_base +from typing import Any, Final, Literal, SupportsIndex, TypeAlias, TypeVar, overload +from typing_extensions import disjoint_base _R = TypeVar("_R") diff --git a/stdlib/_io.pyi b/stdlib/_io.pyi index 2d2a60e4dddf..a18c82ccf26f 100644 --- a/stdlib/_io.pyi +++ b/stdlib/_io.pyi @@ -294,8 +294,7 @@ class IncrementalNewlineDecoder: def reset(self) -> None: ... def setstate(self, state: tuple[bytes, int], /) -> None: ... -if sys.version_info >= (3, 10): - @overload - def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ... - @overload - def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T: ... +@overload +def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ... +@overload +def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T: ... diff --git a/stdlib/_lsprof.pyi b/stdlib/_lsprof.pyi index 4f6d98b8ffb6..d04c2a74ee07 100644 --- a/stdlib/_lsprof.pyi +++ b/stdlib/_lsprof.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import structseq from collections.abc import Callable from types import CodeType @@ -17,8 +16,7 @@ class Profiler: @final class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, float, list[profiler_subentry]]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls") + __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls") code: CodeType | str callcount: int reccallcount: int @@ -28,8 +26,7 @@ class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, floa @final class profiler_subentry(structseq[Any], tuple[CodeType | str, int, int, float, float]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime") + __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime") code: CodeType | str callcount: int reccallcount: int diff --git a/stdlib/_lzma.pyi b/stdlib/_lzma.pyi index b38dce9faded..83cd8fd756b9 100644 --- a/stdlib/_lzma.pyi +++ b/stdlib/_lzma.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ReadableBuffer from collections.abc import Mapping, Sequence -from typing import Any, Final, final -from typing_extensions import Self, TypeAlias +from typing import Any, Final, TypeAlias, final +from typing_extensions import Self _FilterChain: TypeAlias = Sequence[Mapping[str, Any]] diff --git a/stdlib/_markupbase.pyi b/stdlib/_markupbase.pyi index 597bd09b700b..acc3ccac7188 100644 --- a/stdlib/_markupbase.pyi +++ b/stdlib/_markupbase.pyi @@ -1,6 +1,3 @@ -import sys -from typing import Any - class ParserBase: def reset(self) -> None: ... def getpos(self) -> tuple[int, int]: ... @@ -9,8 +6,5 @@ class ParserBase: def parse_declaration(self, i: int) -> int: ... # undocumented def parse_marked_section(self, i: int, report: bool = True) -> int: ... # undocumented def updatepos(self, i: int, j: int) -> int: ... # undocumented - if sys.version_info < (3, 10): - # Removed from ParserBase: https://bugs.python.org/issue31844 - def error(self, message: str) -> Any: ... # undocumented lineno: int # undocumented offset: int # undocumented diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index e1ef5c4bf067..676f1128349e 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import SupportsGetItem from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller -from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, TypeAlias, TypeIs +from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, TypeIs _R = TypeVar("_R") _T = TypeVar("_T") diff --git a/stdlib/_pickle.pyi b/stdlib/_pickle.pyi index 544f787172d6..40f979c2d654 100644 --- a/stdlib/_pickle.pyi +++ b/stdlib/_pickle.pyi @@ -1,8 +1,8 @@ from _typeshed import ReadableBuffer, SupportsWrite from collections.abc import Callable, Iterable, Iterator, Mapping from pickle import PickleBuffer as PickleBuffer -from typing import Any, Protocol, type_check_only -from typing_extensions import TypeAlias, disjoint_base +from typing import Any, Protocol, TypeAlias, type_check_only +from typing_extensions import disjoint_base @type_check_only class _ReadableFileobj(Protocol): diff --git a/stdlib/_random.pyi b/stdlib/_random.pyi index ac00fdfb7272..e333b00d1084 100644 --- a/stdlib/_random.pyi +++ b/stdlib/_random.pyi @@ -1,16 +1,12 @@ -import sys -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import TypeAlias +from typing_extensions import disjoint_base # Actually Tuple[(int,) * 625] _State: TypeAlias = tuple[int, ...] @disjoint_base class Random: - if sys.version_info >= (3, 10): - def __init__(self, seed: object = ..., /) -> None: ... - else: - def __new__(self, seed: object = ..., /) -> Self: ... - + def __init__(self, seed: object = ..., /) -> None: ... def seed(self, n: object = None, /) -> None: ... def getstate(self) -> _State: ... def setstate(self, state: _State, /) -> None: ... diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 372b35f22f17..638a98fe2728 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Iterable from socket import error as error, gaierror as gaierror, herror as herror, timeout as timeout -from typing import Any, Final, SupportsIndex, overload -from typing_extensions import CapsuleType, TypeAlias, disjoint_base +from typing import Any, Final, SupportsIndex, TypeAlias, overload +from typing_extensions import CapsuleType, disjoint_base _CMSG: TypeAlias = tuple[int, int, bytes] _CMSGArg: TypeAlias = tuple[int, int, ReadableBuffer] @@ -218,8 +218,7 @@ IP_MULTICAST_TTL: Final[int] IP_OPTIONS: Final[int] if sys.platform != "linux": IP_RECVDSTADDR: Final[int] -if sys.version_info >= (3, 10): - IP_RECVTOS: Final[int] +IP_RECVTOS: Final[int] IP_TOS: Final[int] IP_TTL: Final[int] if sys.platform != "win32": diff --git a/stdlib/_sqlite3.pyi b/stdlib/_sqlite3.pyi index 50006dcf4032..d9e7835b8e38 100644 --- a/stdlib/_sqlite3.pyi +++ b/stdlib/_sqlite3.pyi @@ -18,8 +18,7 @@ from sqlite3 import ( Warning as Warning, _IsolationLevel, ) -from typing import Any, Final, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, TypeAlias, TypeVar, overload if sys.version_info >= (3, 11): from sqlite3 import Blob as Blob @@ -301,13 +300,5 @@ if sys.version_info < (3, 12): # takes a pos-or-keyword argument because there is a C wrapper def enable_shared_cache(do_enable: int) -> None: ... -if sys.version_info >= (3, 10): - def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ... - def register_converter(typename: str, converter: _Converter, /) -> None: ... - -else: - def register_adapter(type: type[_T], caster: _Adapter[_T], /) -> None: ... - def register_converter(name: str, converter: _Converter, /) -> None: ... - -if sys.version_info < (3, 10): - OptimizedUnicode = str +def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ... +def register_converter(typename: str, converter: _Converter, /) -> None: ... diff --git a/stdlib/_ssl.pyi b/stdlib/_ssl.pyi index 73a43f29c8c5..05ca94c107f0 100644 --- a/stdlib/_ssl.pyi +++ b/stdlib/_ssl.pyi @@ -12,8 +12,8 @@ from ssl import ( SSLWantWriteError as SSLWantWriteError, SSLZeroReturnError as SSLZeroReturnError, ) -from typing import Any, ClassVar, Final, Literal, TypedDict, final, overload, type_check_only -from typing_extensions import NotRequired, Self, TypeAlias, deprecated, disjoint_base +from typing import Any, ClassVar, Final, Literal, TypeAlias, TypedDict, final, overload, type_check_only +from typing_extensions import NotRequired, Self, deprecated, disjoint_base _PasswordType: TypeAlias = Callable[[], str | bytes | bytearray] | str | bytes | bytearray _PCTRTT: TypeAlias = tuple[tuple[str, str], ...] @@ -54,9 +54,6 @@ if sys.version_info < (3, 12): @deprecated("Deprecated since Python 3.6; removed in Python 3.12. Use `ssl.RAND_bytes()` instead.") def RAND_pseudo_bytes(n: int, /) -> tuple[bytes, bool]: ... -if sys.version_info < (3, 10): - def RAND_egd(path: str) -> None: ... - def RAND_status() -> bool: ... def get_default_verify_paths() -> tuple[str, str, str, str]: ... @@ -77,8 +74,7 @@ class _SSLContext: options: int post_handshake_auth: bool protocol: int - if sys.version_info >= (3, 10): - security_level: int + security_level: int sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None verify_flags: int verify_mode: int @@ -144,18 +140,17 @@ class SSLSession: # # You can find a _ssl._SSLSocket object as the _sslobj attribute of a ssl.SSLSocket object -if sys.version_info >= (3, 10): - @final - class Certificate: - def get_info(self) -> _CertInfo: ... - @overload - def public_bytes(self) -> str: ... - @overload - def public_bytes(self, format: Literal[1] = 1, /) -> str: ... # ENCODING_PEM - @overload - def public_bytes(self, format: Literal[2], /) -> bytes: ... # ENCODING_DER - @overload - def public_bytes(self, format: int, /) -> str | bytes: ... +@final +class Certificate: + def get_info(self) -> _CertInfo: ... + @overload + def public_bytes(self) -> str: ... + @overload + def public_bytes(self, format: Literal[1] = 1, /) -> str: ... # ENCODING_PEM + @overload + def public_bytes(self, format: Literal[2], /) -> bytes: ... # ENCODING_DER + @overload + def public_bytes(self, format: int, /) -> str | bytes: ... if sys.version_info < (3, 12): err_codes_to_names: dict[tuple[int, int], str] @@ -186,9 +181,8 @@ VERIFY_CRL_CHECK_LEAF: Final = 0x4 VERIFY_CRL_CHECK_CHAIN: Final = 0x8 VERIFY_X509_STRICT: Final = 0x20 VERIFY_X509_TRUSTED_FIRST: Final = 0x8000 -if sys.version_info >= (3, 10): - VERIFY_ALLOW_PROXY_CERTS: Final = 0x40 - VERIFY_X509_PARTIAL_CHAIN: Final = 0x80000 +VERIFY_ALLOW_PROXY_CERTS: Final = 0x40 +VERIFY_X509_PARTIAL_CHAIN: Final = 0x80000 # alert descriptions ALERT_DESCRIPTION_CLOSE_NOTIFY: Final = 0 @@ -257,10 +251,8 @@ HOSTFLAG_NO_PARTIAL_WILDCARDS: Final = 0x4 HOSTFLAG_MULTI_LABEL_WILDCARDS: Final = 0x8 HOSTFLAG_SINGLE_LABEL_SUBDOMAINS: Final = 0x10 -if sys.version_info >= (3, 10): - # certificate file types - ENCODING_PEM: Final = 1 - ENCODING_DER: Final = 2 +ENCODING_PEM: Final = 1 +ENCODING_DER: Final = 2 # protocol versions PROTO_MINIMUM_SUPPORTED: Final = -2 diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 6969ae48cae7..7a476a701c99 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -71,13 +71,7 @@ def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwa def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ... @overload def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... - -if sys.version_info >= (3, 10): - def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ... - -else: - def interrupt_main() -> None: ... - +def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ... def exit() -> NoReturn: ... def exit_thread() -> NoReturn: ... # Obsolete synonym for exit() def allocate_lock() -> LockType: ... @@ -90,8 +84,7 @@ TIMEOUT_MAX: Final[float] def get_native_id() -> int: ... # only available on some platforms @final class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | None, TracebackType | None, Thread | None]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread") + __match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread") @property def exc_type(self) -> type[BaseException]: ... diff --git a/stdlib/_threading_local.pyi b/stdlib/_threading_local.pyi index 5f6acaf840aa..7d4e61c6f2ec 100644 --- a/stdlib/_threading_local.pyi +++ b/stdlib/_threading_local.pyi @@ -1,6 +1,6 @@ from threading import RLock -from typing import Any -from typing_extensions import Self, TypeAlias +from typing import Any, TypeAlias +from typing_extensions import Self from weakref import ReferenceType __all__ = ["local"] diff --git a/stdlib/_tkinter.pyi b/stdlib/_tkinter.pyi index 5e46668e08b1..318c35b352c5 100644 --- a/stdlib/_tkinter.pyi +++ b/stdlib/_tkinter.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import FileDescriptorLike, Incomplete from collections.abc import Callable -from typing import Any, ClassVar, Final, Literal, final, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, ClassVar, Final, Literal, TypeAlias, final, overload +from typing_extensions import deprecated # _tkinter is meant to be only used internally by tkinter, but some tkinter # functions e.g. return _tkinter.Tcl_Obj objects. Tcl_Obj represents a Tcl diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 89e93ab02706..8a22051b238c 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -18,11 +18,11 @@ from typing import ( SupportsFloat, SupportsIndex, SupportsInt, + TypeAlias, TypeVar, - final, overload, ) -from typing_extensions import Buffer, LiteralString, Self as _Self, TypeAlias +from typing_extensions import Buffer, LiteralString, Self as _Self _KT = TypeVar("_KT") _KT_co = TypeVar("_KT_co", covariant=True) @@ -318,13 +318,7 @@ ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType] OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None] # stable -if sys.version_info >= (3, 10): - from types import NoneType as NoneType -else: - # Used by type checkers for checks involving None (does not exist at runtime) - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... +from types import NoneType as NoneType # This is an internal CPython type that is like, but subtly different from, a NamedTuple # Subclasses of this type are found in multiple modules. diff --git a/stdlib/_typeshed/dbapi.pyi b/stdlib/_typeshed/dbapi.pyi index d54fbee57042..e08a84553dfc 100644 --- a/stdlib/_typeshed/dbapi.pyi +++ b/stdlib/_typeshed/dbapi.pyi @@ -2,8 +2,7 @@ # https://www.python.org/dev/peps/pep-0249/ from collections.abc import Mapping, Sequence -from typing import Any, Protocol -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias DBAPITypeCode: TypeAlias = Any | None # Strictly speaking, this should be a Sequence, but the type system does diff --git a/stdlib/_typeshed/wsgi.pyi b/stdlib/_typeshed/wsgi.pyi index 63f204eb889b..980a24122252 100644 --- a/stdlib/_typeshed/wsgi.pyi +++ b/stdlib/_typeshed/wsgi.pyi @@ -7,8 +7,7 @@ import sys from _typeshed import OptExcInfo from collections.abc import Callable, Iterable, Iterator -from typing import Any, Protocol -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias class _Readable(Protocol): def read(self, size: int = ..., /) -> bytes: ... diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index 42efce9bed70..253f6af447f6 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -127,22 +127,21 @@ if sys.platform == "win32": WAIT_OBJECT_0: Final = 0 WAIT_TIMEOUT: Final = 258 - if sys.version_info >= (3, 10): - LOCALE_NAME_INVARIANT: Final[str] - LOCALE_NAME_MAX_LENGTH: Final[int] - LOCALE_NAME_SYSTEM_DEFAULT: Final[str] - LOCALE_NAME_USER_DEFAULT: Final[str | None] + LOCALE_NAME_INVARIANT: Final[str] + LOCALE_NAME_MAX_LENGTH: Final[int] + LOCALE_NAME_SYSTEM_DEFAULT: Final[str] + LOCALE_NAME_USER_DEFAULT: Final[str | None] - LCMAP_FULLWIDTH: Final[int] - LCMAP_HALFWIDTH: Final[int] - LCMAP_HIRAGANA: Final[int] - LCMAP_KATAKANA: Final[int] - LCMAP_LINGUISTIC_CASING: Final[int] - LCMAP_LOWERCASE: Final[int] - LCMAP_SIMPLIFIED_CHINESE: Final[int] - LCMAP_TITLECASE: Final[int] - LCMAP_TRADITIONAL_CHINESE: Final[int] - LCMAP_UPPERCASE: Final[int] + LCMAP_FULLWIDTH: Final[int] + LCMAP_HALFWIDTH: Final[int] + LCMAP_HIRAGANA: Final[int] + LCMAP_KATAKANA: Final[int] + LCMAP_LINGUISTIC_CASING: Final[int] + LCMAP_LOWERCASE: Final[int] + LCMAP_SIMPLIFIED_CHINESE: Final[int] + LCMAP_TITLECASE: Final[int] + LCMAP_TRADITIONAL_CHINESE: Final[int] + LCMAP_UPPERCASE: Final[int] if sys.version_info >= (3, 12): COPYFILE2_CALLBACK_CHUNK_STARTED: Final = 1 @@ -243,10 +242,8 @@ if sys.platform == "win32": ) -> int: ... def OpenProcess(desired_access: int, inherit_handle: bool, process_id: int, /) -> int: ... def PeekNamedPipe(handle: int, size: int = 0, /) -> tuple[int, int] | tuple[bytes, int, int]: ... - if sys.version_info >= (3, 10): - def LCMapStringEx(locale: str, flags: int, src: str) -> str: ... - def UnmapViewOfFile(address: int, /) -> None: ... - + def LCMapStringEx(locale: str, flags: int, src: str) -> str: ... + def UnmapViewOfFile(address: int, /) -> None: ... @overload def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> tuple[Overlapped, int]: ... @overload diff --git a/stdlib/_zstd.pyi b/stdlib/_zstd.pyi index e40c7d12b6e7..b4e3d7aaaa09 100644 --- a/stdlib/_zstd.pyi +++ b/stdlib/_zstd.pyi @@ -1,8 +1,8 @@ from _typeshed import ReadableBuffer from collections.abc import Mapping from compression.zstd import CompressionParameter, DecompressionParameter -from typing import Final, Literal, final -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, TypeAlias, final +from typing_extensions import Self ZSTD_CLEVEL_DEFAULT: Final = 3 ZSTD_DStreamOutSize: Final = 131072 diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index c8cd549e30ec..4fc69257eebd 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -2,8 +2,8 @@ import _typeshed import sys from _typeshed import SupportsWrite from collections.abc import Callable -from typing import Any, Literal, TypeVar -from typing_extensions import Concatenate, ParamSpec, deprecated +from typing import Any, Concatenate, Literal, TypeVar +from typing_extensions import ParamSpec, deprecated _T = TypeVar("_T") _R_co = TypeVar("_R_co", covariant=True) @@ -46,6 +46,4 @@ class ABC(metaclass=ABCMeta): __slots__ = () 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 bfe12c6af2b0..afb9029f710e 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,6 +1,6 @@ from types import TracebackType -from typing import IO, Any, Literal, NamedTuple, overload -from typing_extensions import Self, TypeAlias +from typing import IO, Any, Literal, NamedTuple, TypeAlias, overload +from typing_extensions import Self __all__ = ["Error", "open"] diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 066896603914..bbc65a7bb66a 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import SupportsWrite, sentinel from collections.abc import Callable, Generator, Iterable, Sequence from re import Pattern -from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self, deprecated __all__ = [ "ArgumentParser", diff --git a/stdlib/array.pyi b/stdlib/array.pyi index eb679dd50f72..fc277c22f3f9 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Iterable, MutableSequence from types import GenericAlias -from typing import Any, ClassVar, Literal, SupportsIndex, TypeVar, overload -from typing_extensions import Self, TypeAlias, deprecated, disjoint_base +from typing import Any, ClassVar, Literal, SupportsIndex, TypeAlias, TypeVar, overload +from typing_extensions import Self, deprecated, disjoint_base _IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] _FloatTypeCode: TypeAlias = Literal["f", "d"] @@ -61,11 +61,7 @@ class array(MutableSequence[_T]): def fromfile(self, f: SupportsRead[bytes], n: int, /) -> None: ... def fromlist(self, list: list[_T], /) -> None: ... def fromunicode(self, ustr: str, /) -> None: ... - if sys.version_info >= (3, 10): - def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int: ... - else: - def index(self, v: _T, /) -> int: ... # type: ignore[override] - + def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int: ... # type: ignore[override] def insert(self, i: int, v: _T, /) -> None: ... def pop(self, i: int = -1, /) -> _T: ... def remove(self, v: _T, /) -> None: ... diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index e66e609ee664..046e077094a9 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -44,16 +44,14 @@ if sys.version_info >= (3, 12): else: class AST: - if sys.version_info >= (3, 10): - __match_args__ = () + __match_args__ = () _attributes: ClassVar[tuple[str, ...]] _fields: ClassVar[tuple[str, ...]] class mod(AST): ... class Module(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body", "type_ignores") + __match_args__ = ("body", "type_ignores") body: list[stmt] type_ignores: list[TypeIgnore] if sys.version_info >= (3, 13): @@ -65,8 +63,7 @@ class Module(mod): def __replace__(self, *, body: list[stmt] = ..., type_ignores: list[TypeIgnore] = ...) -> Self: ... class Interactive(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body",) + __match_args__ = ("body",) body: list[stmt] if sys.version_info >= (3, 13): def __init__(self, body: list[stmt] = ...) -> None: ... @@ -77,8 +74,7 @@ class Interactive(mod): def __replace__(self, *, body: list[stmt] = ...) -> Self: ... class Expression(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body",) + __match_args__ = ("body",) body: expr def __init__(self, body: expr) -> None: ... @@ -86,8 +82,7 @@ class Expression(mod): def __replace__(self, *, body: expr = ...) -> Self: ... class FunctionType(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("argtypes", "returns") + __match_args__ = ("argtypes", "returns") argtypes: list[expr] returns: expr if sys.version_info >= (3, 13): @@ -114,7 +109,7 @@ class stmt(AST): class FunctionDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params") - elif sys.version_info >= (3, 10): + else: __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") name: str args: arguments @@ -191,7 +186,7 @@ class FunctionDef(stmt): class AsyncFunctionDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params") - elif sys.version_info >= (3, 10): + else: __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") name: str args: arguments @@ -268,7 +263,7 @@ class AsyncFunctionDef(stmt): class ClassDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "bases", "keywords", "body", "decorator_list", "type_params") - elif sys.version_info >= (3, 10): + else: __match_args__ = ("name", "bases", "keywords", "body", "decorator_list") name: str bases: list[expr] @@ -324,8 +319,7 @@ class ClassDef(stmt): ) -> Self: ... class Return(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr | None def __init__(self, value: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -333,8 +327,7 @@ class Return(stmt): def __replace__(self, *, value: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Delete(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("targets",) + __match_args__ = ("targets",) targets: list[expr] if sys.version_info >= (3, 13): def __init__(self, targets: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -345,8 +338,7 @@ class Delete(stmt): def __replace__(self, *, targets: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Assign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("targets", "value", "type_comment") + __match_args__ = ("targets", "value", "type_comment") targets: list[expr] value: expr type_comment: str | None @@ -400,8 +392,7 @@ if sys.version_info >= (3, 12): ) -> Self: ... class AugAssign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "op", "value") + __match_args__ = ("target", "op", "value") target: Name | Attribute | Subscript op: operator value: expr @@ -420,8 +411,7 @@ class AugAssign(stmt): ) -> Self: ... class AnnAssign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "annotation", "value", "simple") + __match_args__ = ("target", "annotation", "value", "simple") target: Name | Attribute | Subscript annotation: expr value: expr | None @@ -458,8 +448,7 @@ class AnnAssign(stmt): ) -> Self: ... class For(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "body", "orelse", "type_comment") + __match_args__ = ("target", "iter", "body", "orelse", "type_comment") target: expr iter: expr body: list[stmt] @@ -499,8 +488,7 @@ class For(stmt): ) -> Self: ... class AsyncFor(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "body", "orelse", "type_comment") + __match_args__ = ("target", "iter", "body", "orelse", "type_comment") target: expr iter: expr body: list[stmt] @@ -540,8 +528,7 @@ class AsyncFor(stmt): ) -> Self: ... class While(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") + __match_args__ = ("test", "body", "orelse") test: expr body: list[stmt] orelse: list[stmt] @@ -558,8 +545,7 @@ class While(stmt): ) -> Self: ... class If(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") + __match_args__ = ("test", "body", "orelse") test: expr body: list[stmt] orelse: list[stmt] @@ -576,8 +562,7 @@ class If(stmt): ) -> Self: ... class With(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("items", "body", "type_comment") + __match_args__ = ("items", "body", "type_comment") items: list[withitem] body: list[stmt] type_comment: str | None @@ -605,8 +590,7 @@ class With(stmt): ) -> Self: ... class AsyncWith(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("items", "body", "type_comment") + __match_args__ = ("items", "body", "type_comment") items: list[withitem] body: list[stmt] type_comment: str | None @@ -634,8 +618,7 @@ class AsyncWith(stmt): ) -> Self: ... class Raise(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("exc", "cause") + __match_args__ = ("exc", "cause") exc: expr | None cause: expr | None def __init__(self, exc: expr | None = None, cause: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -644,8 +627,7 @@ class Raise(stmt): def __replace__(self, *, exc: expr | None = ..., cause: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Try(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("body", "handlers", "orelse", "finalbody") + __match_args__ = ("body", "handlers", "orelse", "finalbody") body: list[stmt] handlers: list[ExceptHandler] orelse: list[stmt] @@ -718,8 +700,7 @@ if sys.version_info >= (3, 11): ) -> Self: ... class Assert(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "msg") + __match_args__ = ("test", "msg") test: expr msg: expr | None def __init__(self, test: expr, msg: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -728,8 +709,7 @@ class Assert(stmt): def __replace__(self, *, test: expr = ..., msg: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Import(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) + __match_args__ = ("names",) names: list[alias] if sys.version_info >= (3, 13): def __init__(self, names: list[alias] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -740,8 +720,7 @@ class Import(stmt): def __replace__(self, *, names: list[alias] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class ImportFrom(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("module", "names", "level") + __match_args__ = ("module", "names", "level") module: str | None names: list[alias] level: int @@ -766,8 +745,7 @@ class ImportFrom(stmt): ) -> Self: ... class Global(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) + __match_args__ = ("names",) names: list[str] if sys.version_info >= (3, 13): def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -778,8 +756,7 @@ class Global(stmt): def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Nonlocal(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) + __match_args__ = ("names",) names: list[str] if sys.version_info >= (3, 13): def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -790,8 +767,7 @@ class Nonlocal(stmt): def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Expr(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -813,8 +789,7 @@ class expr(AST): def __replace__(self, **kwargs: Unpack[_Attributes]) -> Self: ... class BoolOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("op", "values") + __match_args__ = ("op", "values") op: boolop values: list[expr] if sys.version_info >= (3, 13): @@ -826,8 +801,7 @@ class BoolOp(expr): def __replace__(self, *, op: boolop = ..., values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class NamedExpr(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "value") + __match_args__ = ("target", "value") target: Name value: expr def __init__(self, target: Name, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -836,8 +810,7 @@ class NamedExpr(expr): def __replace__(self, *, target: Name = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class BinOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("left", "op", "right") + __match_args__ = ("left", "op", "right") left: expr op: operator right: expr @@ -849,8 +822,7 @@ class BinOp(expr): ) -> Self: ... class UnaryOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("op", "operand") + __match_args__ = ("op", "operand") op: unaryop operand: expr def __init__(self, op: unaryop, operand: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -859,8 +831,7 @@ class UnaryOp(expr): def __replace__(self, *, op: unaryop = ..., operand: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Lambda(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("args", "body") + __match_args__ = ("args", "body") args: arguments body: expr def __init__(self, args: arguments, body: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -869,8 +840,7 @@ class Lambda(expr): def __replace__(self, *, args: arguments = ..., body: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class IfExp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") + __match_args__ = ("test", "body", "orelse") test: expr body: expr orelse: expr @@ -882,8 +852,7 @@ class IfExp(expr): ) -> Self: ... class Dict(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("keys", "values") + __match_args__ = ("keys", "values") keys: list[expr | None] values: list[expr] if sys.version_info >= (3, 13): @@ -897,8 +866,7 @@ class Dict(expr): ) -> Self: ... class Set(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts",) + __match_args__ = ("elts",) elts: list[expr] if sys.version_info >= (3, 13): def __init__(self, elts: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -909,8 +877,7 @@ class Set(expr): def __replace__(self, *, elts: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class ListComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -924,8 +891,7 @@ class ListComp(expr): ) -> Self: ... class SetComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -939,8 +905,7 @@ class SetComp(expr): ) -> Self: ... class DictComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("key", "value", "generators") + __match_args__ = ("key", "value", "generators") key: expr value: expr generators: list[comprehension] @@ -957,8 +922,7 @@ class DictComp(expr): ) -> Self: ... class GeneratorExp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -972,8 +936,7 @@ class GeneratorExp(expr): ) -> Self: ... class Await(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -981,8 +944,7 @@ class Await(expr): def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Yield(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr | None def __init__(self, value: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -990,8 +952,7 @@ class Yield(expr): def __replace__(self, *, value: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class YieldFrom(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -999,8 +960,7 @@ class YieldFrom(expr): def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Compare(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("left", "ops", "comparators") + __match_args__ = ("left", "ops", "comparators") left: expr ops: list[cmpop] comparators: list[expr] @@ -1017,8 +977,7 @@ class Compare(expr): ) -> Self: ... class Call(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("func", "args", "keywords") + __match_args__ = ("func", "args", "keywords") func: expr args: list[expr] keywords: list[keyword] @@ -1035,8 +994,7 @@ class Call(expr): ) -> Self: ... class FormattedValue(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "conversion", "format_spec") + __match_args__ = ("value", "conversion", "format_spec") value: expr conversion: int format_spec: expr | None @@ -1048,8 +1006,7 @@ class FormattedValue(expr): ) -> Self: ... class JoinedStr(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("values",) + __match_args__ = ("values",) values: list[expr] if sys.version_info >= (3, 13): def __init__(self, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1090,17 +1047,12 @@ if sys.version_info >= (3, 14): **kwargs: Unpack[_Attributes], ) -> Self: ... -if sys.version_info >= (3, 10): - from types import EllipsisType +from types import EllipsisType - _ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType -else: - # Rely on builtins.ellipsis - _ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | ellipsis # noqa: F821 +_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType # noqa: F821 class Constant(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "kind") + __match_args__ = ("value", "kind") value: _ConstantValue kind: str | None if sys.version_info < (3, 14): @@ -1124,8 +1076,7 @@ class Constant(expr): def __replace__(self, *, value: _ConstantValue = ..., kind: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Attribute(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "attr", "ctx") + __match_args__ = ("value", "attr", "ctx") value: expr attr: str ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` @@ -1137,8 +1088,7 @@ class Attribute(expr): ) -> Self: ... class Subscript(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "slice", "ctx") + __match_args__ = ("value", "slice", "ctx") value: expr slice: expr ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` @@ -1150,8 +1100,7 @@ class Subscript(expr): ) -> Self: ... class Starred(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "ctx") + __match_args__ = ("value", "ctx") value: expr ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` def __init__(self, value: expr, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1160,8 +1109,7 @@ class Starred(expr): def __replace__(self, *, value: expr = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Name(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("id", "ctx") + __match_args__ = ("id", "ctx") id: str ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` def __init__(self, id: str, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1170,8 +1118,7 @@ class Name(expr): def __replace__(self, *, id: str = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class List(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts", "ctx") + __match_args__ = ("elts", "ctx") elts: list[expr] ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` if sys.version_info >= (3, 13): @@ -1183,8 +1130,7 @@ class List(expr): def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Tuple(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts", "ctx") + __match_args__ = ("elts", "ctx") elts: list[expr] ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` dims: list[expr] @@ -1200,8 +1146,7 @@ class Tuple(expr): class slice(AST): ... class Slice(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("lower", "upper", "step") + __match_args__ = ("lower", "upper", "step") lower: expr | None upper: expr | None step: expr | None @@ -1274,8 +1219,7 @@ class In(cmpop): ... class NotIn(cmpop): ... class comprehension(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "ifs", "is_async") + __match_args__ = ("target", "iter", "ifs", "is_async") target: expr iter: expr ifs: list[expr] @@ -1304,8 +1248,7 @@ class excepthandler(AST): ) -> Self: ... class ExceptHandler(excepthandler): - if sys.version_info >= (3, 10): - __match_args__ = ("type", "name", "body") + __match_args__ = ("type", "name", "body") type: expr | None name: str | None body: list[stmt] @@ -1327,8 +1270,7 @@ class ExceptHandler(excepthandler): ) -> Self: ... class arguments(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults") + __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults") posonlyargs: list[arg] args: list[arg] vararg: arg | None @@ -1402,8 +1344,7 @@ class arg(AST): col_offset: int end_lineno: int | None end_col_offset: int | None - if sys.version_info >= (3, 10): - __match_args__ = ("arg", "annotation", "type_comment") + __match_args__ = ("arg", "annotation", "type_comment") arg: str annotation: expr | None type_comment: str | None @@ -1421,8 +1362,7 @@ class keyword(AST): col_offset: int end_lineno: int | None end_col_offset: int | None - if sys.version_info >= (3, 10): - __match_args__ = ("arg", "value") + __match_args__ = ("arg", "value") arg: str | None value: expr @overload @@ -1436,24 +1376,18 @@ class keyword(AST): class alias(AST): name: str asname: str | None - if sys.version_info >= (3, 10): - lineno: int - col_offset: int - end_lineno: int | None - end_col_offset: int | None - if sys.version_info >= (3, 10): - __match_args__ = ("name", "asname") - if sys.version_info >= (3, 10): - def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... - else: - def __init__(self, name: str, asname: str | None = None) -> None: ... + lineno: int + col_offset: int + end_lineno: int | None + end_col_offset: int | None + __match_args__ = ("name", "asname") + def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... if sys.version_info >= (3, 14): def __replace__(self, *, name: str = ..., asname: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class withitem(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("context_expr", "optional_vars") + __match_args__ = ("context_expr", "optional_vars") context_expr: expr optional_vars: expr | None def __init__(self, context_expr: expr, optional_vars: expr | None = None) -> None: ... @@ -1461,177 +1395,173 @@ class withitem(AST): if sys.version_info >= (3, 14): def __replace__(self, *, context_expr: expr = ..., optional_vars: expr | None = ...) -> Self: ... -if sys.version_info >= (3, 10): - class pattern(AST): - lineno: int - col_offset: int - end_lineno: int - end_col_offset: int - def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ... +class pattern(AST): + lineno: int + col_offset: int + end_lineno: int + end_col_offset: int + def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ... - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ... + ) -> Self: ... - class match_case(AST): - __match_args__ = ("pattern", "guard", "body") - pattern: ast.pattern - guard: expr | None - body: list[stmt] - if sys.version_info >= (3, 13): - def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ... - elif sys.version_info >= (3, 10): - @overload - def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ... - @overload - def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ... +class match_case(AST): + __match_args__ = ("pattern", "guard", "body") + pattern: ast.pattern + guard: expr | None + body: list[stmt] + if sys.version_info >= (3, 13): + def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ... + else: + @overload + def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ... + @overload + def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ... - class Match(stmt): - __match_args__ = ("subject", "cases") - subject: expr - cases: list[match_case] - if sys.version_info >= (3, 13): - def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ... - else: - def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ... +class Match(stmt): + __match_args__ = ("subject", "cases") + subject: expr + cases: list[match_case] + if sys.version_info >= (3, 13): + def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ... + else: + def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes] - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... - class MatchValue(pattern): - __match_args__ = ("value",) - value: expr - def __init__(self, value: expr, **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchValue(pattern): + __match_args__ = ("value",) + value: expr + def __init__(self, value: expr, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... - class MatchSingleton(pattern): - __match_args__ = ("value",) - value: bool | None - def __init__(self, value: bool | None, **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchSingleton(pattern): + __match_args__ = ("value",) + value: bool | None + def __init__(self, value: bool | None, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, value: bool | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, value: bool | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... - class MatchSequence(pattern): - __match_args__ = ("patterns",) - patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... - else: - def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchSequence(pattern): + __match_args__ = ("patterns",) + patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... + else: + def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... - class MatchMapping(pattern): - __match_args__ = ("keys", "patterns", "rest") - keys: list[expr] - patterns: list[pattern] - rest: str | None - if sys.version_info >= (3, 13): - def __init__( - self, - keys: list[expr] = ..., - patterns: list[pattern] = ..., - rest: str | None = None, - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... - else: - def __init__( - self, keys: list[expr], patterns: list[pattern], rest: str | None = None, **kwargs: Unpack[_Attributes[int]] - ) -> None: ... +class MatchMapping(pattern): + __match_args__ = ("keys", "patterns", "rest") + keys: list[expr] + patterns: list[pattern] + rest: str | None + if sys.version_info >= (3, 13): + def __init__( + self, + keys: list[expr] = ..., + patterns: list[pattern] = ..., + rest: str | None = None, + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... + else: + def __init__( + self, keys: list[expr], patterns: list[pattern], rest: str | None = None, **kwargs: Unpack[_Attributes[int]] + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, - *, - keys: list[expr] = ..., - patterns: list[pattern] = ..., - rest: str | None = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, + *, + keys: list[expr] = ..., + patterns: list[pattern] = ..., + rest: str | None = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> Self: ... - class MatchClass(pattern): - __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") - cls: expr - patterns: list[pattern] - kwd_attrs: list[str] - kwd_patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__( - self, - cls: expr, - patterns: list[pattern] = ..., - kwd_attrs: list[str] = ..., - kwd_patterns: list[pattern] = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... - else: - def __init__( - self, - cls: expr, - patterns: list[pattern], - kwd_attrs: list[str], - kwd_patterns: list[pattern], - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... +class MatchClass(pattern): + __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") + cls: expr + patterns: list[pattern] + kwd_attrs: list[str] + kwd_patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__( + self, + cls: expr, + patterns: list[pattern] = ..., + kwd_attrs: list[str] = ..., + kwd_patterns: list[pattern] = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... + else: + def __init__( + self, + cls: expr, + patterns: list[pattern], + kwd_attrs: list[str], + kwd_patterns: list[pattern], + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, - *, - cls: expr = ..., - patterns: list[pattern] = ..., - kwd_attrs: list[str] = ..., - kwd_patterns: list[pattern] = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, + *, + cls: expr = ..., + patterns: list[pattern] = ..., + kwd_attrs: list[str] = ..., + kwd_patterns: list[pattern] = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> Self: ... - class MatchStar(pattern): - __match_args__ = ("name",) - name: str | None - def __init__(self, name: str | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchStar(pattern): + __match_args__ = ("name",) + name: str | None + def __init__(self, name: str | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... - class MatchAs(pattern): - __match_args__ = ("pattern", "name") - pattern: ast.pattern | None - name: str | None - def __init__( - self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]] - ) -> None: ... +class MatchAs(pattern): + __match_args__ = ("pattern", "name") + pattern: ast.pattern | None + name: str | None + def __init__( + self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]] + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]] - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]] + ) -> Self: ... - class MatchOr(pattern): - __match_args__ = ("patterns",) - patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... - else: - def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... +class MatchOr(pattern): + __match_args__ = ("patterns",) + patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... + else: + def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... class type_ignore(AST): ... class TypeIgnore(type_ignore): - if sys.version_info >= (3, 10): - __match_args__ = ("lineno", "tag") + __match_args__ = ("lineno", "tag") lineno: int tag: str def __init__(self, lineno: int, tag: str) -> None: ... @@ -2043,17 +1973,16 @@ class NodeVisitor: def visit_keyword(self, node: keyword) -> Any: ... def visit_alias(self, node: alias) -> Any: ... def visit_withitem(self, node: withitem) -> Any: ... - if sys.version_info >= (3, 10): - def visit_Match(self, node: Match) -> Any: ... - def visit_match_case(self, node: match_case) -> Any: ... - def visit_MatchValue(self, node: MatchValue) -> Any: ... - def visit_MatchSequence(self, node: MatchSequence) -> Any: ... - def visit_MatchSingleton(self, node: MatchSingleton) -> Any: ... - def visit_MatchStar(self, node: MatchStar) -> Any: ... - def visit_MatchMapping(self, node: MatchMapping) -> Any: ... - def visit_MatchClass(self, node: MatchClass) -> Any: ... - def visit_MatchAs(self, node: MatchAs) -> Any: ... - def visit_MatchOr(self, node: MatchOr) -> Any: ... + def visit_Match(self, node: Match) -> Any: ... + def visit_match_case(self, node: match_case) -> Any: ... + def visit_MatchValue(self, node: MatchValue) -> Any: ... + def visit_MatchSequence(self, node: MatchSequence) -> Any: ... + def visit_MatchSingleton(self, node: MatchSingleton) -> Any: ... + def visit_MatchStar(self, node: MatchStar) -> Any: ... + def visit_MatchMapping(self, node: MatchMapping) -> Any: ... + def visit_MatchClass(self, node: MatchClass) -> Any: ... + def visit_MatchAs(self, node: MatchAs) -> Any: ... + def visit_MatchOr(self, node: MatchOr) -> Any: ... if sys.version_info >= (3, 11): def visit_TryStar(self, node: TryStar) -> Any: ... diff --git a/stdlib/asyncio/__init__.pyi b/stdlib/asyncio/__init__.pyi index 23cf57aaac33..5189024f2431 100644 --- a/stdlib/asyncio/__init__.pyi +++ b/stdlib/asyncio/__init__.pyi @@ -2,8 +2,7 @@ # Can't NOQA on a specific line: https://github.com/plinss/flake8-noqa/issues/22 import sys from collections.abc import Awaitable, Coroutine, Generator -from typing import Any, TypeVar -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, TypeVar # As at runtime, this depends on all submodules defining __all__ accurately. from .base_events import * diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 0d8ac2d47491..1aec5847c367 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -11,8 +11,8 @@ from collections.abc import Callable, Iterable, Sequence from concurrent.futures import Executor, ThreadPoolExecutor from contextvars import Context from socket import AddressFamily, AddressInfo, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Literal, TypeVar, overload -from typing_extensions import TypeAlias, TypeVarTuple, Unpack +from typing import IO, Any, Literal, TypeAlias, TypeVar, overload +from typing_extensions import TypeVarTuple, Unpack # Keep asyncio.__all__ updated with any changes to __all__ here __all__ = ("BaseEventLoop", "Server") diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index a5fe24e8768b..36f0f6099cbc 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -1,8 +1,7 @@ import subprocess from collections import deque from collections.abc import Callable, Sequence -from typing import IO, Any -from typing_extensions import TypeAlias +from typing import IO, Any, TypeAlias from . import events, futures, protocols, transports diff --git a/stdlib/asyncio/coroutines.pyi b/stdlib/asyncio/coroutines.pyi index 777961d80441..ba0fe596f9a5 100644 --- a/stdlib/asyncio/coroutines.pyi +++ b/stdlib/asyncio/coroutines.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Awaitable, Callable, Coroutine -from typing import Any, TypeVar, overload -from typing_extensions import ParamSpec, TypeGuard, TypeIs, deprecated +from typing import Any, TypeGuard, TypeVar, overload +from typing_extensions import ParamSpec, TypeIs, deprecated # Keep asyncio.__all__ updated with any changes to __all__ here if sys.version_info >= (3, 11): diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 4f2f45355f5b..a8cbbcd10517 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -12,8 +12,8 @@ from collections.abc import Callable, Sequence from concurrent.futures import Executor from contextvars import Context from socket import AddressFamily, AddressInfo, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack, deprecated +from typing import IO, Any, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeVarTuple, Unpack, deprecated from . import _AwaitableLike, _CoroutineLike from .base_events import Server @@ -467,7 +467,7 @@ class AbstractEventLoop: ssl_handshake_timeout: float | None = None, ssl_shutdown_timeout: float | None = None, ) -> tuple[Transport, _ProtocolT]: ... - elif sys.version_info >= (3, 10): + else: async def connect_accepted_socket( self, protocol_factory: Callable[[], _ProtocolT], diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index 597eb9e56e1a..ff830a3b73d4 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -3,8 +3,7 @@ import sys import traceback from collections.abc import Iterable from types import FrameType, FunctionType -from typing import Any, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, overload, type_check_only @type_check_only class _HasWrapper: diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 17390b0c5a0e..4420d02fcd26 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -7,13 +7,8 @@ from types import TracebackType from typing import Any, Literal, TypeVar from typing_extensions import Self -from .events import AbstractEventLoop from .futures import Future - -if sys.version_info >= (3, 10): - from .mixins import _LoopBoundMixin -else: - _LoopBoundMixin = object +from .mixins import _LoopBoundMixin # Keep asyncio.__all__ updated with any changes to __all__ here if sys.version_info >= (3, 11): @@ -31,22 +26,14 @@ class _ContextManagerMixin: class Lock(_ContextManagerMixin, _LoopBoundMixin): _waiters: deque[Future[Any]] | None - if sys.version_info >= (3, 10): - def __init__(self) -> None: ... - else: - def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... class Event(_LoopBoundMixin): _waiters: deque[Future[Any]] - if sys.version_info >= (3, 10): - def __init__(self) -> None: ... - else: - def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self) -> None: ... def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... @@ -54,11 +41,7 @@ class Event(_LoopBoundMixin): class Condition(_ContextManagerMixin, _LoopBoundMixin): _waiters: deque[Future[Any]] - if sys.version_info >= (3, 10): - def __init__(self, lock: Lock | None = None) -> None: ... - else: - def __init__(self, lock: Lock | None = None, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self, lock: Lock | None = None) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... @@ -70,11 +53,7 @@ class Condition(_ContextManagerMixin, _LoopBoundMixin): class Semaphore(_ContextManagerMixin, _LoopBoundMixin): _value: int _waiters: deque[Future[Any]] | None - if sys.version_info >= (3, 10): - def __init__(self, value: int = 1) -> None: ... - else: - def __init__(self, value: int = 1, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self, value: int = 1) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index 909d671df289..09c096d40f04 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Mapping from socket import socket from typing import Any, ClassVar, Literal @@ -20,27 +19,16 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr def __del__(self) -> None: ... class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport): - if sys.version_info >= (3, 10): - def __init__( - self, - loop: events.AbstractEventLoop, - sock: socket, - protocol: streams.StreamReaderProtocol, - waiter: futures.Future[Any] | None = None, - extra: Mapping[Any, Any] | None = None, - server: events.AbstractServer | None = None, - buffer_size: int = 65536, - ) -> None: ... - else: - def __init__( - self, - loop: events.AbstractEventLoop, - sock: socket, - protocol: streams.StreamReaderProtocol, - waiter: futures.Future[Any] | None = None, - extra: Mapping[Any, Any] | None = None, - server: events.AbstractServer | None = None, - ) -> None: ... + def __init__( + self, + loop: events.AbstractEventLoop, + sock: socket, + protocol: streams.StreamReaderProtocol, + waiter: futures.Future[Any] | None = None, + extra: Mapping[Any, Any] | None = None, + server: events.AbstractServer | None = None, + buffer_size: int = 65536, + ) -> None: ... class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): ... class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): ... diff --git a/stdlib/asyncio/queues.pyi b/stdlib/asyncio/queues.pyi index 2fa2226d0e6a..c6821ac25af9 100644 --- a/stdlib/asyncio/queues.pyi +++ b/stdlib/asyncio/queues.pyi @@ -1,13 +1,9 @@ import sys from _typeshed import SupportsRichComparisonT -from asyncio.events import AbstractEventLoop from types import GenericAlias from typing import Any, Generic, TypeVar -if sys.version_info >= (3, 10): - from .mixins import _LoopBoundMixin -else: - _LoopBoundMixin = object +from .mixins import _LoopBoundMixin class QueueEmpty(Exception): ... class QueueFull(Exception): ... @@ -27,11 +23,7 @@ if sys.version_info >= (3, 13): # If Generic[_T] is last and _LoopBoundMixin is object, pyright is unhappy. # We can remove the noqa pragma when dropping 3.9 support. class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059 - if sys.version_info >= (3, 10): - def __init__(self, maxsize: int = 0) -> None: ... - else: - def __init__(self, maxsize: int = 0, *, loop: AbstractEventLoop | None = None) -> None: ... - + def __init__(self, maxsize: int = 0) -> None: ... def _init(self, maxsize: int) -> None: ... def _get(self) -> _T: ... def _put(self, item: _T) -> None: ... diff --git a/stdlib/asyncio/sslproto.pyi b/stdlib/asyncio/sslproto.pyi index ab102f124c2e..72b4ea449e86 100644 --- a/stdlib/asyncio/sslproto.pyi +++ b/stdlib/asyncio/sslproto.pyi @@ -3,8 +3,7 @@ import sys from collections import deque from collections.abc import Callable from enum import Enum -from typing import Any, ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Final, Literal, TypeAlias from . import constants, events, futures, protocols, transports diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index 33cffb11ed78..db22b9a8e513 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -3,8 +3,8 @@ import sys from _typeshed import ReadableBuffer, StrPath from collections.abc import Awaitable, Callable, Iterable, Sequence, Sized from types import ModuleType -from typing import Any, Protocol, SupportsIndex, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Protocol, SupportsIndex, TypeAlias, type_check_only +from typing_extensions import Self from . import events, protocols, transports from .base_events import Server @@ -28,67 +28,32 @@ _ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awa @type_check_only class _ReaduntilBuffer(ReadableBuffer, Sized, Protocol): ... -if sys.version_info >= (3, 10): - async def open_connection( - host: str | None = None, - port: int | str | None = None, - *, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, - ) -> tuple[StreamReader, StreamWriter]: ... - async def start_server( - client_connected_cb: _ClientConnectedCallback, - host: str | Sequence[str] | None = None, - port: int | str | None = None, - *, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, - ) -> Server: ... +async def open_connection( + host: str | None = None, + port: int | str | None = None, + *, + limit: int = 65536, + ssl_handshake_timeout: float | None = None, + **kwds: Any, +) -> tuple[StreamReader, StreamWriter]: ... +async def start_server( + client_connected_cb: _ClientConnectedCallback, + host: str | Sequence[str] | None = None, + port: int | str | None = None, + *, + limit: int = 65536, + ssl_handshake_timeout: float | None = None, + **kwds: Any, +) -> Server: ... -else: - async def open_connection( - host: str | None = None, - port: int | str | None = None, - *, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, +if sys.platform != "win32": + async def open_unix_connection( + path: StrPath | None = None, *, limit: int = 65536, **kwds: Any ) -> tuple[StreamReader, StreamWriter]: ... - async def start_server( - client_connected_cb: _ClientConnectedCallback, - host: str | None = None, - port: int | str | None = None, - *, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, + async def start_unix_server( + client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any ) -> Server: ... -if sys.platform != "win32": - if sys.version_info >= (3, 10): - async def open_unix_connection( - path: StrPath | None = None, *, limit: int = 65536, **kwds: Any - ) -> tuple[StreamReader, StreamWriter]: ... - async def start_unix_server( - client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any - ) -> Server: ... - else: - async def open_unix_connection( - path: StrPath | None = None, *, loop: events.AbstractEventLoop | None = None, limit: int = 65536, **kwds: Any - ) -> tuple[StreamReader, StreamWriter]: ... - async def start_unix_server( - client_connected_cb: _ClientConnectedCallback, - path: StrPath | None = None, - *, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - **kwds: Any, - ) -> Server: ... - class FlowControlMixin(protocols.Protocol): def __init__(self, loop: events.AbstractEventLoop | None = None) -> None: ... diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index ceee2b5b90a0..6405e5ae1474 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -101,7 +101,7 @@ if sys.version_info >= (3, 11): pipesize: int = -1, ) -> Process: ... -elif sys.version_info >= (3, 10): +else: async def create_subprocess_shell( cmd: str | bytes, stdin: int | IO[Any] | None = None, @@ -164,67 +164,3 @@ elif sys.version_info >= (3, 10): umask: int = -1, pipesize: int = -1, ) -> Process: ... - -else: # >= 3.9 - async def create_subprocess_shell( - cmd: str | bytes, - stdin: int | IO[Any] | None = None, - stdout: int | IO[Any] | None = None, - stderr: int | IO[Any] | None = None, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - *, - # These parameters are forced to these values by BaseEventLoop.subprocess_shell - universal_newlines: Literal[False] = False, - shell: Literal[True] = True, - bufsize: Literal[0] = 0, - encoding: None = None, - errors: None = None, - text: Literal[False] | None = None, - # These parameters are taken by subprocess.Popen, which this ultimately delegates to - executable: StrOrBytesPath | None = None, - preexec_fn: Callable[[], Any] | None = None, - close_fds: bool = True, - cwd: StrOrBytesPath | None = None, - env: subprocess._ENV | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - group: None | str | int = None, - extra_groups: None | Collection[str | int] = None, - user: None | str | int = None, - umask: int = -1, - ) -> Process: ... - async def create_subprocess_exec( - program: StrOrBytesPath, - *args: StrOrBytesPath, - stdin: int | IO[Any] | None = None, - stdout: int | IO[Any] | None = None, - stderr: int | IO[Any] | None = None, - loop: events.AbstractEventLoop | None = None, - limit: int = 65536, - # These parameters are forced to these values by BaseEventLoop.subprocess_exec - universal_newlines: Literal[False] = False, - shell: Literal[False] = False, - bufsize: Literal[0] = 0, - encoding: None = None, - errors: None = None, - text: Literal[False] | None = None, - # These parameters are taken by subprocess.Popen, which this ultimately delegates to - executable: StrOrBytesPath | None = None, - preexec_fn: Callable[[], Any] | None = None, - close_fds: bool = True, - cwd: StrOrBytesPath | None = None, - env: subprocess._ENV | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - group: None | str | int = None, - extra_groups: None | Collection[str | int] = None, - user: None | str | int = None, - umask: int = -1, - ) -> Process: ... diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index be9b60cd36ae..75e91e8442fa 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -8,8 +8,7 @@ from _asyncio import ( _unregister_task as _unregister_task, ) from collections.abc import AsyncIterator, Awaitable, Coroutine, Generator, Iterable, Iterator -from typing import Any, Final, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only from . import _CoroutineLike from .events import AbstractEventLoop @@ -92,13 +91,8 @@ if sys.version_info >= (3, 13): def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[Future[_T]]: ... -elif sys.version_info >= (3, 10): - def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ... - else: - def as_completed( - fs: Iterable[_FutureLike[_T]], *, loop: AbstractEventLoop | None = None, timeout: float | None = None - ) -> Iterator[Future[_T]]: ... + def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ... @overload def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[overload-overlap] @@ -111,262 +105,124 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No # typing PR #1550 for discussion. # # N.B. Having overlapping overloads is the only way to get acceptable type inference in all edge cases. -if sys.version_info >= (3, 10): - @overload - def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap] - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False - ) -> Future[tuple[_T1, _T2]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - /, - *, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... - @overload - def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap] - @overload - def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - /, - *, - return_exceptions: bool, - ) -> Future[ - tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] - ]: ... - @overload - def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - return_exceptions: bool, - ) -> Future[ - tuple[ - _T1 | BaseException, - _T2 | BaseException, - _T3 | BaseException, - _T4 | BaseException, - _T5 | BaseException, - _T6 | BaseException, - ] - ]: ... - @overload - def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ... - -else: - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False - ) -> Future[tuple[_T1]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: Literal[False] = False, - ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... - @overload - def gather( # type: ignore[overload-overlap] - *coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False - ) -> Future[list[_T]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: bool - ) -> Future[tuple[_T1 | BaseException]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: bool, - ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... - @overload - def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - loop: AbstractEventLoop | None = None, - return_exceptions: bool, - ) -> Future[ - tuple[ - _T1 | BaseException, - _T2 | BaseException, - _T3 | BaseException, - _T4 | BaseException, - _T5 | BaseException, - _T6 | BaseException, - ] - ]: ... - @overload - def gather( - *coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: bool - ) -> Future[list[_T | BaseException]]: ... +@overload +def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap] +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False +) -> Future[tuple[_T1, _T2]]: ... +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + /, + *, + return_exceptions: Literal[False] = False, +) -> Future[tuple[_T1, _T2, _T3]]: ... +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + /, + *, + return_exceptions: Literal[False] = False, +) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + /, + *, + return_exceptions: Literal[False] = False, +) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... +@overload +def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + coro_or_future6: _FutureLike[_T6], + /, + *, + return_exceptions: Literal[False] = False, +) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... +@overload +def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap] +@overload +def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool +) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + /, + *, + return_exceptions: bool, +) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + /, + *, + return_exceptions: bool, +) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + /, + *, + return_exceptions: bool, +) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]]: ... +@overload +def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + coro_or_future6: _FutureLike[_T6], + /, + *, + return_exceptions: bool, +) -> Future[ + tuple[ + _T1 | BaseException, + _T2 | BaseException, + _T3 | BaseException, + _T4 | BaseException, + _T5 | BaseException, + _T6 | BaseException, + ] +]: ... +@overload +def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ... # unlike some asyncio apis, This does strict runtime checking of actually being a coroutine, not of any future-like. def run_coroutine_threadsafe(coro: Coroutine[Any, Any, _T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... - -if sys.version_info >= (3, 10): - def shield(arg: _FutureLike[_T]) -> Future[_T]: ... - @overload - async def sleep(delay: float) -> None: ... - @overload - async def sleep(delay: float, result: _T) -> _T: ... - async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ... - -else: - def shield(arg: _FutureLike[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ... - @overload - async def sleep(delay: float, *, loop: AbstractEventLoop | None = None) -> None: ... - @overload - async def sleep(delay: float, result: _T, *, loop: AbstractEventLoop | None = None) -> _T: ... - async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = None) -> _T: ... +def shield(arg: _FutureLike[_T]) -> Future[_T]: ... +@overload +async def sleep(delay: float) -> None: ... +@overload +async def sleep(delay: float, result: _T) -> _T: ... +async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ... if sys.version_info >= (3, 11): @overload @@ -378,7 +234,7 @@ if sys.version_info >= (3, 11): fs: Iterable[Task[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... -elif sys.version_info >= (3, 10): +else: @overload async def wait( # type: ignore[overload-overlap] fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" @@ -388,24 +244,6 @@ elif sys.version_info >= (3, 10): fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... -else: - @overload - async def wait( # type: ignore[overload-overlap] - fs: Iterable[_FT], - *, - loop: AbstractEventLoop | None = None, - timeout: float | None = None, - return_when: str = "ALL_COMPLETED", - ) -> tuple[set[_FT], set[_FT]]: ... - @overload - async def wait( - fs: Iterable[Awaitable[_T]], - *, - loop: AbstractEventLoop | None = None, - timeout: float | None = None, - return_when: str = "ALL_COMPLETED", - ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... - if sys.version_info >= (3, 12): _TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co] else: diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index d3e95559ebef..1249fac4c8b6 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -4,8 +4,8 @@ from _typeshed import ReadableBuffer from builtins import type as Type # alias to avoid name clashes with property named "type" from collections.abc import Iterable from types import TracebackType -from typing import Any, BinaryIO, NoReturn, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, BinaryIO, NoReturn, TypeAlias, overload +from typing_extensions import deprecated # These are based in socket, maybe move them out into _typeshed.pyi or such _Address: TypeAlias = socket._Address diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index 36d1862fdda7..17ed4f11d020 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -1,8 +1,7 @@ import sys from _typeshed import FileDescriptorLike, ReadableBuffer from socket import socket -from typing import Any, overload -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, overload # cyclic dependence with asynchat _MapType: TypeAlias = dict[int, Any] diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index f3ce78ccb7fa..a7d5e8adb7a5 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,4 +1,5 @@ -from typing_extensions import Buffer, TypeAlias +from typing import TypeAlias +from typing_extensions import Buffer _AdpcmState: TypeAlias = tuple[int, int] _RatecvState: TypeAlias = tuple[int, tuple[tuple[int, int], ...]] diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 279d74a94ebe..043137714c0f 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -23,8 +23,7 @@ __all__ = [ "urlsafe_b64decode", ] -if sys.version_info >= (3, 10): - __all__ += ["b32hexencode", "b32hexdecode"] +__all__ += ["b32hexencode", "b32hexdecode"] if sys.version_info >= (3, 13): __all__ += ["z85decode", "z85encode"] @@ -38,11 +37,8 @@ def b32encode(s: ReadableBuffer) -> bytes: ... def b32decode(s: str | ReadableBuffer, casefold: bool = False, map01: str | ReadableBuffer | None = None) -> bytes: ... def b16encode(s: ReadableBuffer) -> bytes: ... def b16decode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... - -if sys.version_info >= (3, 10): - def b32hexencode(s: ReadableBuffer) -> bytes: ... - def b32hexdecode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... - +def b32hexencode(s: ReadableBuffer) -> bytes: ... +def b32hexdecode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... def a85encode( b: ReadableBuffer, *, foldspaces: bool = False, wrapcol: int = 0, pad: bool = False, adobe: bool = False ) -> bytes: ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index b6be2210ffe2..e16444643846 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -3,8 +3,8 @@ from _typeshed import ExcInfo, TraceFunction, Unused from collections.abc import Callable, Iterable, Iterator, Mapping from contextlib import contextmanager from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Final, Literal, SupportsInt, TypeVar -from typing_extensions import ParamSpec, TypeAlias +from typing import IO, Any, Final, Literal, SupportsInt, TypeAlias, TypeVar +from typing_extensions import ParamSpec __all__ = ["BdbQuit", "Bdb", "Breakpoint"] diff --git a/stdlib/binascii.pyi b/stdlib/binascii.pyi index 5606d5cdf74d..f2eddafa5750 100644 --- a/stdlib/binascii.pyi +++ b/stdlib/binascii.pyi @@ -1,6 +1,7 @@ import sys from _typeshed import ReadableBuffer -from typing_extensions import TypeAlias, deprecated +from typing import TypeAlias +from typing_extensions import deprecated # Many functions in binascii accept buffer objects # or ASCII-only strings. diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index bdead928468f..f309f4e026a5 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,6 +1,5 @@ from _typeshed import SizedBuffer -from typing import IO, Any, Final -from typing_extensions import TypeAlias +from typing import IO, Any, Final, TypeAlias __all__ = ["binhex", "hexbin", "Error"] diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index efc51fe257ae..7866a2f1b411 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -42,8 +42,10 @@ from typing import ( # noqa: Y022,UP035 Any, BinaryIO, ClassVar, + Concatenate, Final, Generic, + Literal, Mapping, MutableMapping, MutableSequence, @@ -54,6 +56,8 @@ from typing import ( # noqa: Y022,UP035 SupportsComplex, SupportsFloat, SupportsIndex, + TypeAlias, + TypeGuard, TypeVar, final, overload, @@ -61,19 +65,7 @@ from typing import ( # noqa: Y022,UP035 ) # we can't import `Literal` from typing or mypy crashes: see #11247 -from typing_extensions import ( # noqa: Y023 - Concatenate, - Literal, - LiteralString, - ParamSpec, - Self, - TypeAlias, - TypeGuard, - TypeIs, - TypeVarTuple, - deprecated, - disjoint_base, -) +from typing_extensions import LiteralString, ParamSpec, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023 if sys.version_info >= (3, 14): from _typeshed import AnnotateFunc @@ -152,12 +144,11 @@ class staticmethod(Generic[_P, _R_co]): def __get__(self, instance: None, owner: type, /) -> Callable[_P, _R_co]: ... @overload def __get__(self, instance: _T, owner: type[_T] | None = None, /) -> Callable[_P, _R_co]: ... - if sys.version_info >= (3, 10): - __name__: str - __qualname__: str - @property - def __wrapped__(self) -> Callable[_P, _R_co]: ... - def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: ... + __name__: str + __qualname__: str + @property + def __wrapped__(self) -> Callable[_P, _R_co]: ... + def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: ... if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... __annotate__: AnnotateFunc | None @@ -173,11 +164,10 @@ class classmethod(Generic[_T, _P, _R_co]): def __get__(self, instance: _T, owner: type[_T] | None = None, /) -> Callable[_P, _R_co]: ... @overload def __get__(self, instance: None, owner: type[_T], /) -> Callable[_P, _R_co]: ... - if sys.version_info >= (3, 10): - __name__: str - __qualname__: str - @property - def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... + __name__: str + __qualname__: str + @property + def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... __annotate__: AnnotateFunc | None @@ -227,11 +217,8 @@ class type: def __subclasscheck__(self, subclass: type, /) -> bool: ... @classmethod def __prepare__(metacls, name: str, bases: tuple[type, ...], /, **kwds: Any) -> MutableMapping[str, object]: ... - if sys.version_info >= (3, 10): - # `int | str` produces an instance of `UnionType`, but `int | int` produces an instance of `type`, - # and `abc.ABC | abc.ABC` produces an instance of `abc.ABCMeta`. - def __or__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... - def __ror__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... + def __or__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... + def __ror__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] __annotations__: dict[str, AnnotationForm] @@ -268,8 +255,7 @@ class int: def denominator(self) -> Literal[1]: ... def conjugate(self) -> int: ... def bit_length(self) -> int: ... - if sys.version_info >= (3, 10): - def bit_count(self) -> int: ... + def bit_count(self) -> int: ... if sys.version_info >= (3, 11): def to_bytes( @@ -943,11 +929,7 @@ class memoryview(Sequence[_I]): def __setitem__(self, key: slice[SupportsIndex | None], value: ReadableBuffer, /) -> None: ... @overload def __setitem__(self, key: SupportsIndex | tuple[SupportsIndex, ...], value: _I, /) -> None: ... - if sys.version_info >= (3, 10): - def tobytes(self, order: Literal["C", "F", "A"] | None = "C") -> bytes: ... - else: - def tobytes(self, order: Literal["C", "F", "A"] | None = None) -> bytes: ... - + def tobytes(self, order: Literal["C", "F", "A"] | None = "C") -> bytes: ... def tolist(self) -> list[int]: ... def toreadonly(self) -> memoryview: ... def release(self) -> None: ... @@ -1086,9 +1068,8 @@ class function: if sys.version_info >= (3, 14): __annotate__: AnnotateFunc | None __kwdefaults__: dict[str, Any] | None - if sys.version_info >= (3, 10): - @property - def __builtins__(self) -> dict[str, Any]: ... + @property + def __builtins__(self) -> dict[str, Any]: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] @@ -1389,20 +1370,18 @@ def bin(number: int | SupportsIndex, /) -> str: ... def breakpoint(*args: Any, **kws: Any) -> None: ... def callable(obj: object, /) -> TypeIs[Callable[..., object]]: ... def chr(i: int | SupportsIndex, /) -> str: ... +def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ... +@type_check_only +class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]): + def __anext__(self) -> _AwaitableT_co: ... -if sys.version_info >= (3, 10): - def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ... - @type_check_only - class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]): - def __anext__(self) -> _AwaitableT_co: ... - - @overload - # `anext` is not, in fact, an async function. When default is not provided - # `anext` is just a passthrough for `obj.__anext__` - # See discussion in #7491 and pure-Python implementation of `anext` at https://github.com/python/cpython/blob/ea786a882b9ed4261eafabad6011bc7ef3b5bf94/Lib/test/test_asyncgen.py#L52-L80 - def anext(i: _SupportsSynchronousAnext[_AwaitableT], /) -> _AwaitableT: ... - @overload - async def anext(i: SupportsAnext[_T], default: _VT, /) -> _T | _VT: ... +@overload +# `anext` is not, in fact, an async function. When default is not provided +# `anext` is just a passthrough for `obj.__anext__` +# See discussion in #7491 and pure-Python implementation of `anext` at https://github.com/python/cpython/blob/ea786a882b9ed4261eafabad6011bc7ef3b5bf94/Lib/test/test_asyncgen.py#L52-L80 +def anext(i: _SupportsSynchronousAnext[_AwaitableT], /) -> _AwaitableT: ... +@overload +async def anext(i: SupportsAnext[_T], default: _VT, /) -> _T | _VT: ... # compile() returns a CodeType, unless the flags argument includes PyCF_ONLY_AST (=1024), # in which case it returns ast.AST. We have overloads for flag 0 (the default) and for @@ -1562,10 +1541,7 @@ def iter(object: Callable[[], _T | None], sentinel: None, /) -> Iterator[_T]: .. @overload def iter(object: Callable[[], _T], sentinel: object, /) -> Iterator[_T]: ... -if sys.version_info >= (3, 10): - _ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...] -else: - _ClassInfo: TypeAlias = type | tuple[_ClassInfo, ...] +_ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...] def isinstance(obj: object, class_or_tuple: _ClassInfo, /) -> bool: ... def issubclass(cls: type, class_or_tuple: _ClassInfo, /) -> bool: ... @@ -1947,83 +1923,45 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ... def vars(object: Any = ..., /) -> dict[str, Any]: ... @disjoint_base class zip(Generic[_T_co]): - if sys.version_info >= (3, 10): - @overload - def __new__(cls, *, strict: bool = False) -> zip[Any]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], /, *, strict: bool = False) -> zip[tuple[_T1]]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /, *, strict: bool = False) -> zip[tuple[_T1, _T2]]: ... - @overload - def __new__( - cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /, *, strict: bool = False - ) -> zip[tuple[_T1, _T2, _T3]]: ... - @overload - def __new__( - cls, - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - /, - *, - strict: bool = False, - ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def __new__( - cls, - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - iter5: Iterable[_T5], - /, - *, - strict: bool = False, - ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def __new__( - cls, - iter1: Iterable[Any], - iter2: Iterable[Any], - iter3: Iterable[Any], - iter4: Iterable[Any], - iter5: Iterable[Any], - iter6: Iterable[Any], - /, - *iterables: Iterable[Any], - strict: bool = False, - ) -> zip[tuple[Any, ...]]: ... - else: - @overload - def __new__(cls) -> zip[Any]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], /) -> zip[tuple[_T1]]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /) -> zip[tuple[_T1, _T2]]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /) -> zip[tuple[_T1, _T2, _T3]]: ... - @overload - def __new__( - cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], / - ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def __new__( - cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], iter5: Iterable[_T5], / - ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def __new__( - cls, - iter1: Iterable[Any], - iter2: Iterable[Any], - iter3: Iterable[Any], - iter4: Iterable[Any], - iter5: Iterable[Any], - iter6: Iterable[Any], - /, - *iterables: Iterable[Any], - ) -> zip[tuple[Any, ...]]: ... - + @overload + def __new__(cls, *, strict: bool = False) -> zip[Any]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], /, *, strict: bool = False) -> zip[tuple[_T1]]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /, *, strict: bool = False) -> zip[tuple[_T1, _T2]]: ... + @overload + def __new__( + cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /, *, strict: bool = False + ) -> zip[tuple[_T1, _T2, _T3]]: ... + @overload + def __new__( + cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], /, *, strict: bool = False + ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... + @overload + def __new__( + cls, + iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + iter5: Iterable[_T5], + /, + *, + strict: bool = False, + ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... + @overload + def __new__( + cls, + iter1: Iterable[Any], + iter2: Iterable[Any], + iter3: Iterable[Any], + iter4: Iterable[Any], + iter5: Iterable[Any], + iter6: Iterable[Any], + /, + *iterables: Iterable[Any], + strict: bool = False, + ) -> zip[tuple[Any, ...]]: ... def __iter__(self) -> Self: ... def __next__(self) -> _T_co: ... @@ -2038,29 +1976,14 @@ def __import__( ) -> types.ModuleType: ... def __build_class__(func: Callable[[], CellType | Any], name: str, /, *bases: Any, metaclass: Any = ..., **kwds: Any) -> Any: ... -if sys.version_info >= (3, 10): - from types import EllipsisType, NotImplementedType - - # Backwards compatibility hack for folks who relied on the ellipsis type - # existing in typeshed in Python 3.9 and earlier. - ellipsis = EllipsisType - - Ellipsis: EllipsisType - NotImplemented: NotImplementedType -else: - # Actually the type of Ellipsis is , but since it's - # not exposed anywhere under that name, we make it private here. - @final - @type_check_only - class ellipsis: ... - - Ellipsis: ellipsis +from types import EllipsisType, NotImplementedType - @final - @type_check_only - class _NotImplementedType(Any): ... +# Backwards compatibility hack for folks who relied on the ellipsis type +# existing in typeshed in Python 3.9 and earlier. +ellipsis = EllipsisType - NotImplemented: _NotImplementedType +Ellipsis: EllipsisType +NotImplemented: NotImplementedType @disjoint_base class BaseException: @@ -2113,15 +2036,11 @@ if sys.platform == "win32": class ArithmeticError(Exception): ... class AssertionError(Exception): ... -if sys.version_info >= (3, 10): - @disjoint_base - class AttributeError(Exception): - def __init__(self, *args: object, name: str | None = None, obj: object = None) -> None: ... - name: str | None - obj: object - -else: - class AttributeError(Exception): ... +@disjoint_base +class AttributeError(Exception): + def __init__(self, *args: object, name: str | None = None, obj: object = None) -> None: ... + name: str | None + obj: object class BufferError(Exception): ... class EOFError(Exception): ... @@ -2138,14 +2057,10 @@ class ImportError(Exception): class LookupError(Exception): ... class MemoryError(Exception): ... -if sys.version_info >= (3, 10): - @disjoint_base - class NameError(Exception): - def __init__(self, *args: object, name: str | None = None) -> None: ... - name: str | None - -else: - class NameError(Exception): ... +@disjoint_base +class NameError(Exception): + def __init__(self, *args: object, name: str | None = None) -> None: ... + name: str | None class ReferenceError(Exception): ... class RuntimeError(Exception): ... @@ -2161,9 +2076,8 @@ class SyntaxError(Exception): # Errors are displayed differently if this attribute exists on the exception. # The value is always None. print_file_and_line: None - if sys.version_info >= (3, 10): - end_lineno: int | None - end_offset: int | None + end_lineno: int | None + end_offset: int | None @overload def __init__(self) -> None: ... @@ -2172,12 +2086,10 @@ class SyntaxError(Exception): # Second argument is the tuple (filename, lineno, offset, text) @overload def __init__(self, msg: str, info: tuple[str | None, int | None, int | None, str | None], /) -> None: ... - if sys.version_info >= (3, 10): - # end_lineno and end_offset must both be provided if one is. - @overload - def __init__( - self, msg: str, info: tuple[str | None, int | None, int | None, str | None, int | None, int | None], / - ) -> None: ... + @overload + def __init__( + self, msg: str, info: tuple[str | None, int | None, int | None, str | None, int | None, int | None], / + ) -> None: ... # If you provide more than two arguments, it still creates the SyntaxError, but # the arguments from the info tuple are not parsed. This form is omitted. @@ -2253,9 +2165,7 @@ class ImportWarning(Warning): ... class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... class ResourceWarning(Warning): ... - -if sys.version_info >= (3, 10): - class EncodingWarning(Warning): ... +class EncodingWarning(Warning): ... if sys.version_info >= (3, 11): _BaseExceptionT_co = TypeVar("_BaseExceptionT_co", bound=BaseException, covariant=True, default=BaseException) diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index 7bd829d040cb..9660ffd53fbb 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -3,8 +3,8 @@ from _bz2 import BZ2Compressor as BZ2Compressor, BZ2Decompressor as BZ2Decompres from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from collections.abc import Iterable from io import TextIOWrapper -from typing import IO, Literal, Protocol, SupportsIndex, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import IO, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only +from typing_extensions import Self if sys.version_info >= (3, 14): from compression._common._streams import BaseStream, _Reader diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index e921584d4390..bd4e7a0ca09b 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -2,8 +2,8 @@ import _lsprof from _typeshed import StrOrBytesPath, Unused from collections.abc import Callable, Mapping from types import CodeType -from typing import Any, TypeVar -from typing_extensions import ParamSpec, Self, TypeAlias +from typing import Any, TypeAlias, TypeVar +from typing_extensions import ParamSpec, Self __all__ = ["run", "runctx", "Profile"] diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 0d3a0a7490a3..6d5b23e9f645 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -4,8 +4,7 @@ import sys from _typeshed import Unused from collections.abc import Iterable, Sequence from time import struct_time -from typing import ClassVar, Final -from typing_extensions import TypeAlias +from typing import ClassVar, Final, TypeAlias __all__ = [ "IllegalMonthError", @@ -34,8 +33,7 @@ __all__ = [ "weekheader", ] -if sys.version_info >= (3, 10): - __all__ += ["FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"] +__all__ += ["FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"] if sys.version_info >= (3, 12): __all__ += [ "Day", diff --git a/stdlib/cmath.pyi b/stdlib/cmath.pyi index fdf8ae7bfed8..554eb54e2e4c 100644 --- a/stdlib/cmath.pyi +++ b/stdlib/cmath.pyi @@ -1,5 +1,4 @@ -from typing import Final, SupportsComplex, SupportsFloat, SupportsIndex -from typing_extensions import TypeAlias +from typing import Final, SupportsComplex, SupportsFloat, SupportsIndex, TypeAlias e: Final[float] pi: Final[float] diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 4dfe3fd9e851..26709fa8c3ac 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -4,8 +4,8 @@ from _codecs import * from _typeshed import ReadableBuffer from abc import abstractmethod from collections.abc import Callable, Generator, Iterable -from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated, disjoint_base +from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, TypeAlias, overload, type_check_only +from typing_extensions import Self, deprecated, disjoint_base __all__ = [ "register", diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 95f13b0c8dd2..6e1e143873f8 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,26 +1,22 @@ import sys from _collections_abc import dict_items, dict_keys, dict_values from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT +from collections.abc import ( + Callable, + ItemsView, + Iterable, + Iterator, + KeysView, + Mapping, + MutableMapping, + MutableSequence, + Sequence, + ValuesView, +) from types import GenericAlias from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload, type_check_only from typing_extensions import Self, disjoint_base -if sys.version_info >= (3, 10): - from collections.abc import ( - Callable, - ItemsView, - Iterable, - Iterator, - KeysView, - Mapping, - MutableMapping, - MutableSequence, - Sequence, - ValuesView, - ) -else: - from _collections_abc import * - __all__ = ["ChainMap", "Counter", "OrderedDict", "UserDict", "UserList", "UserString", "defaultdict", "deque", "namedtuple"] _S = TypeVar("_S") @@ -305,10 +301,8 @@ class Counter(dict[_T, int], Generic[_T]): def update(self, iterable: None = None, /, **kwargs: int) -> None: ... def __missing__(self, key: _T) -> int: ... def __delitem__(self, elem: object) -> None: ... - if sys.version_info >= (3, 10): - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... def __add__(self, other: Counter[_S]) -> Counter[_T | _S]: ... def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... def __and__(self, other: Counter[_T]) -> Counter[_T]: ... @@ -320,12 +314,11 @@ class Counter(dict[_T, int], Generic[_T]): def __isub__(self, other: SupportsItems[_T, int]) -> Self: ... def __iand__(self, other: SupportsItems[_T, int]) -> Self: ... def __ior__(self, other: SupportsItems[_T, int]) -> Self: ... # type: ignore[override,misc] - if sys.version_info >= (3, 10): - def total(self) -> int: ... - def __le__(self, other: Counter[Any]) -> bool: ... - def __lt__(self, other: Counter[Any]) -> bool: ... - def __ge__(self, other: Counter[Any]) -> bool: ... - def __gt__(self, other: Counter[Any]) -> bool: ... + def total(self) -> int: ... + def __le__(self, other: Counter[Any]) -> bool: ... + def __lt__(self, other: Counter[Any]) -> bool: ... + def __ge__(self, other: Counter[Any]) -> bool: ... + def __gt__(self, other: Counter[Any]) -> bool: ... # The pure-Python implementations of the "views" classes # These are exposed at runtime in `collections/__init__.py` diff --git a/stdlib/compileall.pyi b/stdlib/compileall.pyi index 8972d50a4a63..49a4c69dd3fb 100644 --- a/stdlib/compileall.pyi +++ b/stdlib/compileall.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import StrPath from py_compile import PycInvalidationMode from typing import Any, Protocol, type_check_only @@ -9,74 +8,38 @@ __all__ = ["compile_dir", "compile_file", "compile_path"] class _SupportsSearch(Protocol): def search(self, string: str, /) -> Any: ... -if sys.version_info >= (3, 10): - def compile_dir( - dir: StrPath, - maxlevels: int | None = None, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - workers: int = 1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: StrPath | None = None, - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, - ) -> bool: ... - def compile_file( - fullname: StrPath, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: StrPath | None = None, - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, - ) -> bool: ... - -else: - def compile_dir( - dir: StrPath, - maxlevels: int | None = None, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - workers: int = 1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: str | None = None, # https://bugs.python.org/issue40447 - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, - ) -> bool: ... - def compile_file( - fullname: StrPath, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: str | None = None, # https://bugs.python.org/issue40447 - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, - ) -> bool: ... - +def compile_dir( + dir: StrPath, + maxlevels: int | None = None, + ddir: StrPath | None = None, + force: bool = False, + rx: _SupportsSearch | None = None, + quiet: int = 0, + legacy: bool = False, + optimize: int = -1, + workers: int = 1, + invalidation_mode: PycInvalidationMode | None = None, + *, + stripdir: StrPath | None = None, + prependdir: StrPath | None = None, + limit_sl_dest: StrPath | None = None, + hardlink_dupes: bool = False, +) -> bool: ... +def compile_file( + fullname: StrPath, + ddir: StrPath | None = None, + force: bool = False, + rx: _SupportsSearch | None = None, + quiet: int = 0, + legacy: bool = False, + optimize: int = -1, + invalidation_mode: PycInvalidationMode | None = None, + *, + stripdir: StrPath | None = None, + prependdir: StrPath | None = None, + limit_sl_dest: StrPath | None = None, + hardlink_dupes: bool = False, +) -> bool: ... def compile_path( skip_curdir: bool = ..., maxlevels: int = 0, diff --git a/stdlib/compression/zstd/_zstdfile.pyi b/stdlib/compression/zstd/_zstdfile.pyi index d37e6b174166..0c42e99e0d16 100644 --- a/stdlib/compression/zstd/_zstdfile.pyi +++ b/stdlib/compression/zstd/_zstdfile.pyi @@ -3,8 +3,7 @@ from collections.abc import Mapping from compression._common import _streams from compression.zstd import ZstdDict from io import TextIOWrapper, _WrappedBuffer -from typing import Literal, Protocol, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Literal, Protocol, TypeAlias, overload, type_check_only from _zstd import ZstdCompressor, _ZstdCompressorFlushBlock, _ZstdCompressorFlushFrame diff --git a/stdlib/concurrent/futures/interpreter.pyi b/stdlib/concurrent/futures/interpreter.pyi index e101022babcb..03c9ad95bd73 100644 --- a/stdlib/concurrent/futures/interpreter.pyi +++ b/stdlib/concurrent/futures/interpreter.pyi @@ -1,8 +1,8 @@ import sys from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor -from typing import Any, Literal, Protocol, overload, type_check_only -from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, TypeVarTuple, Unpack +from typing import Any, Literal, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import ParamSpec, Self, TypeVar, TypeVarTuple, Unpack _Task: TypeAlias = tuple[bytes, Literal["function", "script"]] _Ts = TypeVarTuple("_Ts") diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 50a6a9c6f43e..7e0bdec8bd5d 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -3,8 +3,8 @@ import sys from collections.abc import Callable, Iterable, Mapping, Set as AbstractSet from threading import Lock, Semaphore, Thread from types import GenericAlias -from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack +from typing import Any, Generic, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeVarTuple, Unpack from weakref import ref from ._base import BrokenExecutor, Executor, Future diff --git a/stdlib/concurrent/interpreters/_crossinterp.pyi b/stdlib/concurrent/interpreters/_crossinterp.pyi index 7cf1ea34786e..5bb0c7454765 100644 --- a/stdlib/concurrent/interpreters/_crossinterp.pyi +++ b/stdlib/concurrent/interpreters/_crossinterp.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Callable -from typing import Final, NewType -from typing_extensions import Never, Self, TypeAlias +from typing import Final, NewType, TypeAlias +from typing_extensions import Never, Self if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13 from _interpqueues import _UnboundOp diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 1909d80e3d18..229646907c66 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import MaybeNone, StrOrBytesPath, SupportsWrite from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence from re import Pattern -from typing import Any, ClassVar, Final, Literal, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias, deprecated +from typing import Any, ClassVar, Final, Literal, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import deprecated if sys.version_info >= (3, 14): __all__ = ( diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 8d5902c46912..24c1b6d976b6 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -4,8 +4,8 @@ from _typeshed import FileDescriptorOrPath, Unused from abc import ABC, abstractmethod from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Generator, Iterator from types import TracebackType -from typing import Any, Generic, Protocol, TypeVar, overload, runtime_checkable, type_check_only -from typing_extensions import ParamSpec, Self, TypeAlias, deprecated +from typing import Any, Generic, Protocol, TypeAlias, TypeVar, overload, runtime_checkable, type_check_only +from typing_extensions import ParamSpec, Self, deprecated __all__ = [ "contextmanager", @@ -22,8 +22,7 @@ __all__ = [ "nullcontext", ] -if sys.version_info >= (3, 10): - __all__ += ["aclosing"] +__all__ += ["aclosing"] if sys.version_info >= (3, 11): __all__ += ["chdir"] @@ -94,29 +93,20 @@ def contextmanager(func: Callable[_P, Generator[_T_co, None, object]]) -> Callab ) def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ... -if sys.version_info >= (3, 10): - _AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) - - class AsyncContextDecorator: - def _recreate_cm(self) -> Self: ... - def __call__(self, func: _AF) -> _AF: ... - - class _AsyncGeneratorContextManager( - _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], - AbstractAsyncContextManager[_T_co, bool | None], - AsyncContextDecorator, - ): - async def __aexit__( - self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool | None: ... - -else: - class _AsyncGeneratorContextManager( - _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], AbstractAsyncContextManager[_T_co, bool | None] - ): - async def __aexit__( - self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool | None: ... +_AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) + +class AsyncContextDecorator: + def _recreate_cm(self) -> Self: ... + def __call__(self, func: _AF) -> _AF: ... + +class _AsyncGeneratorContextManager( + _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], + AbstractAsyncContextManager[_T_co, bool | None], + AsyncContextDecorator, +): + async def __aexit__( + self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... @overload def asynccontextmanager(func: Callable[_P, AsyncGenerator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ... @@ -136,16 +126,15 @@ class closing(AbstractContextManager[_SupportsCloseT, None]): def __init__(self, thing: _SupportsCloseT) -> None: ... def __exit__(self, *exc_info: Unused) -> None: ... -if sys.version_info >= (3, 10): - @type_check_only - class _SupportsAclose(Protocol): - def aclose(self) -> Awaitable[object]: ... +@type_check_only +class _SupportsAclose(Protocol): + def aclose(self) -> Awaitable[object]: ... - _SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) +_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) - class aclosing(AbstractAsyncContextManager[_SupportsAcloseT, None]): - def __init__(self, thing: _SupportsAcloseT) -> None: ... - async def __aexit__(self, *exc_info: Unused) -> None: ... +class aclosing(AbstractAsyncContextManager[_SupportsAcloseT, None]): + def __init__(self, thing: _SupportsAcloseT) -> None: ... + async def __aexit__(self, *exc_info: Unused) -> None: ... class suppress(AbstractContextManager[None, bool]): def __init__(self, *exceptions: type[BaseException]) -> None: ... @@ -206,27 +195,16 @@ class AsyncExitStack(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta): self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, / ) -> _ExitT_co: ... -if sys.version_info >= (3, 10): - class nullcontext(AbstractContextManager[_T, None], AbstractAsyncContextManager[_T, None]): - enter_result: _T - @overload - def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... - @overload - def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 - def __enter__(self) -> _T: ... - def __exit__(self, *exctype: Unused) -> None: ... - async def __aenter__(self) -> _T: ... - async def __aexit__(self, *exctype: Unused) -> None: ... - -else: - class nullcontext(AbstractContextManager[_T, None]): - enter_result: _T - @overload - def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... - @overload - def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 - def __enter__(self) -> _T: ... - def __exit__(self, *exctype: Unused) -> None: ... +class nullcontext(AbstractContextManager[_T, None], AbstractAsyncContextManager[_T, None]): + enter_result: _T + @overload + def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... + @overload + def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 + def __enter__(self) -> _T: ... + def __exit__(self, *exctype: Unused) -> None: ... + async def __aenter__(self) -> _T: ... + async def __aexit__(self, *exctype: Unused) -> None: ... if sys.version_info >= (3, 11): _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=FileDescriptorOrPath) diff --git a/stdlib/copyreg.pyi b/stdlib/copyreg.pyi index 8f7fd957fc52..3bfc0de8158f 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Hashable -from typing import Any, SupportsInt, TypeVar -from typing_extensions import TypeAlias +from typing import Any, SupportsInt, TypeAlias, TypeVar _T = TypeVar("_T") _Reduce: TypeAlias = tuple[Callable[..., _T], tuple[Any, ...]] | tuple[Callable[..., _T], tuple[Any, ...], Any | None] diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 2c8e7109cdfc..24c1c54bba5a 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -19,11 +19,7 @@ from _csv import ( if sys.version_info >= (3, 12): from _csv import QUOTE_NOTNULL as QUOTE_NOTNULL, QUOTE_STRINGS as QUOTE_STRINGS -if sys.version_info >= (3, 10): - from _csv import Reader, Writer -else: - from _csv import _reader as Reader, _writer as Writer - +from _csv import Reader, Writer from _typeshed import SupportsWrite from collections.abc import Collection, Iterable, Mapping, Sequence from types import GenericAlias diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 8d048aa97e7d..04809e838c14 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -26,8 +26,8 @@ from _ctypes import ( from _typeshed import StrPath, SupportsBool, SupportsLen from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure from types import GenericAlias -from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, ClassVar, Final, Generic, Literal, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self, deprecated if sys.platform == "win32": from _ctypes import FormatError as FormatError, get_last_error as get_last_error, set_last_error as set_last_error diff --git a/stdlib/ctypes/wintypes.pyi b/stdlib/ctypes/wintypes.pyi index 0f0d61a396d5..b94c5e74148a 100644 --- a/stdlib/ctypes/wintypes.pyi +++ b/stdlib/ctypes/wintypes.pyi @@ -21,8 +21,8 @@ from ctypes import ( c_wchar, c_wchar_p, ) -from typing import Any, Final, TypeVar -from typing_extensions import Self, TypeAlias +from typing import Any, Final, TypeAlias, TypeVar +from typing_extensions import Self if sys.version_info >= (3, 12): from ctypes import c_ubyte diff --git a/stdlib/curses/__init__.pyi b/stdlib/curses/__init__.pyi index 3e32487ad99f..5463baeba091 100644 --- a/stdlib/curses/__init__.pyi +++ b/stdlib/curses/__init__.pyi @@ -1,10 +1,9 @@ -import sys from _curses import * from _curses import window as window from _typeshed import structseq from collections.abc import Callable -from typing import Final, TypeVar, final, type_check_only -from typing_extensions import Concatenate, ParamSpec +from typing import Concatenate, Final, TypeVar, final, type_check_only +from typing_extensions import ParamSpec # NOTE: The _curses module is ordinarily only available on Unix, but the # windows-curses package makes it available on Windows as well with the same @@ -30,8 +29,7 @@ def wrapper(func: Callable[Concatenate[window, _P], _T], /, *arg: _P.args, **kwd @final @type_check_only class _ncurses_version(structseq[int], tuple[int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("major", "minor", "patch") + __match_args__: Final = ("major", "minor", "patch") @property def major(self) -> int: ... diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 3a1c8cb5d62d..841f5d743845 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -26,8 +26,7 @@ __all__ = [ "is_dataclass", ] -if sys.version_info >= (3, 10): - __all__ += ["KW_ONLY"] +__all__ += ["KW_ONLY"] _DataclassT = TypeVar("_DataclassT", bound=DataclassInstance) @@ -60,8 +59,7 @@ class _MISSING_TYPE(enum.Enum): MISSING: Final = _MISSING_TYPE.MISSING -if sys.version_info >= (3, 10): - class KW_ONLY: ... +class KW_ONLY: ... @overload def asdict(obj: DataclassInstance) -> dict[str, Any]: ... @@ -106,7 +104,7 @@ if sys.version_info >= (3, 11): weakref_slot: bool = False, ) -> Callable[[type[_T]], type[_T]]: ... -elif sys.version_info >= (3, 10): +else: @overload def dataclass( cls: type[_T], @@ -138,32 +136,6 @@ elif sys.version_info >= (3, 10): slots: bool = False, ) -> Callable[[type[_T]], type[_T]]: ... -else: - @overload - def dataclass( - cls: type[_T], - /, - *, - init: bool = True, - repr: bool = True, - eq: bool = True, - order: bool = False, - unsafe_hash: bool = False, - frozen: bool = False, - ) -> type[_T]: ... - @overload - def dataclass( - cls: None = None, - /, - *, - init: bool = True, - repr: bool = True, - eq: bool = True, - order: bool = False, - unsafe_hash: bool = False, - frozen: bool = False, - ) -> Callable[[type[_T]], type[_T]]: ... - # See https://github.com/python/mypy/issues/10750 @type_check_only class _DefaultFactory(Protocol[_T_co]): @@ -185,7 +157,7 @@ class Field(Generic[_T]): "doc", "_field_type", ) - elif sys.version_info >= (3, 10): + else: __slots__ = ( "name", "type", @@ -199,8 +171,6 @@ class Field(Generic[_T]): "kw_only", "_field_type", ) - else: - __slots__ = ("name", "type", "default", "default_factory", "repr", "hash", "init", "compare", "metadata", "_field_type") name: str type: Type[_T] | str | Any default: _T | Literal[_MISSING_TYPE.MISSING] @@ -214,8 +184,7 @@ class Field(Generic[_T]): if sys.version_info >= (3, 14): doc: str | None - if sys.version_info >= (3, 10): - kw_only: bool | Literal[_MISSING_TYPE.MISSING] + kw_only: bool | Literal[_MISSING_TYPE.MISSING] if sys.version_info >= (3, 14): def __init__( @@ -230,18 +199,6 @@ class Field(Generic[_T]): kw_only: bool, doc: str | None, ) -> None: ... - elif sys.version_info >= (3, 10): - def __init__( - self, - default: _T, - default_factory: Callable[[], _T], - init: bool, - repr: bool, - hash: bool | None, - compare: bool, - metadata: Mapping[Any, Any], - kw_only: bool, - ) -> None: ... else: def __init__( self, @@ -252,6 +209,7 @@ class Field(Generic[_T]): hash: bool | None, compare: bool, metadata: Mapping[Any, Any], + kw_only: bool, ) -> None: ... def __set_name__(self, owner: Type[Any], name: str) -> None: ... @@ -300,7 +258,7 @@ if sys.version_info >= (3, 14): doc: str | None = None, ) -> Any: ... -elif sys.version_info >= (3, 10): +else: @overload # `default` and `default_factory` are optional and mutually exclusive. def field( *, @@ -338,41 +296,6 @@ elif sys.version_info >= (3, 10): kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ..., ) -> Any: ... -else: - @overload # `default` and `default_factory` are optional and mutually exclusive. - def field( - *, - default: _T, - default_factory: Literal[_MISSING_TYPE.MISSING] = ..., - init: bool = True, - repr: bool = True, - hash: bool | None = None, - compare: bool = True, - metadata: Mapping[Any, Any] | None = None, - ) -> _T: ... - @overload - def field( - *, - default: Literal[_MISSING_TYPE.MISSING] = ..., - default_factory: Callable[[], _T], - init: bool = True, - repr: bool = True, - hash: bool | None = None, - compare: bool = True, - metadata: Mapping[Any, Any] | None = None, - ) -> _T: ... - @overload - def field( - *, - default: Literal[_MISSING_TYPE.MISSING] = ..., - default_factory: Literal[_MISSING_TYPE.MISSING] = ..., - init: bool = True, - repr: bool = True, - hash: bool | None = None, - compare: bool = True, - metadata: Mapping[Any, Any] | None = None, - ) -> Any: ... - def fields(class_or_instance: DataclassInstance | type[DataclassInstance]) -> tuple[Field[Any], ...]: ... # HACK: `obj: Never` typing matches if object argument is using `Any` type. @@ -454,7 +377,7 @@ elif sys.version_info >= (3, 11): weakref_slot: bool = False, ) -> type: ... -elif sys.version_info >= (3, 10): +else: def make_dataclass( cls_name: str, fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]], @@ -472,19 +395,4 @@ elif sys.version_info >= (3, 10): slots: bool = False, ) -> type: ... -else: - def make_dataclass( - cls_name: str, - fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]], - *, - bases: tuple[type, ...] = (), - namespace: dict[str, Any] | None = None, - init: bool = True, - repr: bool = True, - eq: bool = True, - order: bool = False, - unsafe_hash: bool = False, - frozen: bool = False, - ) -> type: ... - def replace(obj: _DataclassT, /, **changes: Any) -> _DataclassT: ... diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 8a0536c006d5..225f95da4f6f 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -1,8 +1,8 @@ import sys from abc import abstractmethod from time import struct_time -from typing import ClassVar, Final, NoReturn, SupportsIndex, final, overload, type_check_only -from typing_extensions import CapsuleType, Self, TypeAlias, deprecated, disjoint_base +from typing import ClassVar, Final, NoReturn, SupportsIndex, TypeAlias, final, overload, type_check_only +from typing_extensions import CapsuleType, Self, deprecated, disjoint_base if sys.version_info >= (3, 11): __all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR", "UTC") diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 7cbb63cf2f06..0871381e8ec0 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import StrOrBytesPath from collections.abc import Iterator, MutableMapping from types import TracebackType -from typing import Literal, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Literal, TypeAlias, type_check_only +from typing_extensions import Self __all__ = ["open", "whichdb", "error"] diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index 1c0b7756f292..fccca484a026 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -2,7 +2,8 @@ import sys from _typeshed import StrOrBytesPath from collections.abc import Iterator, MutableMapping from types import TracebackType -from typing_extensions import Self, TypeAlias +from typing import TypeAlias +from typing_extensions import Self __all__ = ["error", "open"] diff --git a/stdlib/dbm/sqlite3.pyi b/stdlib/dbm/sqlite3.pyi index e2fba93b2001..43d8c96895dd 100644 --- a/stdlib/dbm/sqlite3.pyi +++ b/stdlib/dbm/sqlite3.pyi @@ -1,7 +1,7 @@ from _typeshed import ReadableBuffer, StrOrBytesPath, Unused from collections.abc import Generator, MutableMapping -from typing import Final, Literal -from typing_extensions import LiteralString, Self, TypeAlias +from typing import Final, Literal, TypeAlias +from typing_extensions import LiteralString, Self BUILD_TABLE: Final[LiteralString] GET_SIZE: Final[LiteralString] diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 2e06c2d1b724..e5c9360ada15 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -26,8 +26,8 @@ from _decimal import ( ) from collections.abc import Container, Sequence from types import TracebackType -from typing import Any, ClassVar, Literal, NamedTuple, final, overload, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, ClassVar, Literal, NamedTuple, TypeAlias, final, overload, type_check_only +from typing_extensions import Self, disjoint_base if sys.version_info >= (3, 14): from _decimal import IEEE_CONTEXT_MAX_BITS as IEEE_CONTEXT_MAX_BITS, IEEEContext as IEEEContext diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index 52794a588ca8..984f932e3311 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -2,8 +2,8 @@ import sys import types from collections.abc import Callable, Iterator from opcode import * # `dis` re-exports it as a part of public API -from typing import IO, Any, Final, NamedTuple, overload -from typing_extensions import Self, TypeAlias, deprecated, disjoint_base +from typing import IO, Any, Final, NamedTuple, TypeAlias, overload +from typing_extensions import Self, deprecated, disjoint_base __all__ = [ "code_info", diff --git a/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index 5bff209807ee..ef81e807a5db 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,8 +1,8 @@ from _typeshed import BytesPath, StrPath, Unused from collections.abc import Callable, Iterable, Sequence from distutils.file_util import _BytesPathT, _StrPathT -from typing import Literal, overload -from typing_extensions import TypeAlias, TypeVarTuple, Unpack +from typing import Literal, TypeAlias, overload +from typing_extensions import TypeVarTuple, Unpack _Macro: TypeAlias = tuple[str] | tuple[str, str | None] _Ts = TypeVarTuple("_Ts") diff --git a/stdlib/distutils/command/__init__.pyi b/stdlib/distutils/command/__init__.pyi index 4d7372858af3..856c5eb8b44a 100644 --- a/stdlib/distutils/command/__init__.pyi +++ b/stdlib/distutils/command/__init__.pyi @@ -1,5 +1,3 @@ -import sys - from . import ( bdist, bdist_dumb, @@ -41,8 +39,3 @@ __all__ = [ "check", "upload", ] - -if sys.version_info < (3, 10): - from . import bdist_wininst - - __all__ += ["bdist_wininst"] diff --git a/stdlib/distutils/command/check.pyi b/stdlib/distutils/command/check.pyi index 2c807fd2c439..f2034e6555fc 100644 --- a/stdlib/distutils/command/check.pyi +++ b/stdlib/distutils/command/check.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete -from typing import Any, ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Final, Literal, TypeAlias from ..cmd import Command diff --git a/stdlib/distutils/command/install.pyi b/stdlib/distutils/command/install.pyi index 1714e01a2c28..7e11cf257c2c 100644 --- a/stdlib/distutils/command/install.pyi +++ b/stdlib/distutils/command/install.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import Incomplete from collections.abc import Callable from typing import Any, ClassVar, Final, Literal @@ -10,9 +9,6 @@ HAS_USER_SITE: Final[bool] SCHEME_KEYS: Final[tuple[Literal["purelib"], Literal["platlib"], Literal["headers"], Literal["scripts"], Literal["data"]]] INSTALL_SCHEMES: Final[dict[str, dict[str, str]]] -if sys.version_info < (3, 10): - WINDOWS_SCHEME: Final[dict[str, str]] - class install(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 412b94131b54..b4283c9a013c 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -22,8 +22,7 @@ from distutils.command.register import register from distutils.command.sdist import sdist from distutils.command.upload import upload from re import Pattern -from typing import IO, ClassVar, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import IO, ClassVar, Literal, TypeAlias, TypeVar, overload command_re: Pattern[str] diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index f3fa2a1255a6..29c052365628 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,8 +1,7 @@ from collections.abc import Iterable, Mapping from getopt import _SliceableT, _StrSequenceT_co from re import Pattern -from typing import Any, Final, overload -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias, overload _Option: TypeAlias = tuple[str, str | None, str] diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index 4a9c45eb562a..0ed567b98d74 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Mapping from distutils.ccompiler import CCompiler from typing import Final, Literal, overload @@ -28,6 +27,3 @@ def get_python_lib( plat_specific: bool | Literal[0, 1] = 0, standard_lib: bool | Literal[0, 1] = 0, prefix: str | None = None ) -> str: ... def customize_compiler(compiler: CCompiler) -> None: ... - -if sys.version_info < (3, 10): - def get_python_version() -> str: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 1bb96e1a7786..32c68e3f2c7b 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -3,8 +3,8 @@ import types import unittest from _typeshed import ExcInfo from collections.abc import Callable -from typing import Any, Final, NamedTuple, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Final, NamedTuple, TypeAlias, type_check_only +from typing_extensions import Self __all__ = [ "register_optionflag", diff --git a/stdlib/email/__init__.pyi b/stdlib/email/__init__.pyi index 53f8c350b01e..7aa977709b05 100644 --- a/stdlib/email/__init__.pyi +++ b/stdlib/email/__init__.pyi @@ -2,8 +2,7 @@ from collections.abc import Callable from email._policybase import _MessageT from email.message import Message from email.policy import Policy -from typing import IO, overload -from typing_extensions import TypeAlias +from typing import IO, TypeAlias, overload # At runtime, listing submodules in __all__ without them being imported is # valid, and causes them to be included in a star import. See #6523 diff --git a/stdlib/email/errors.pyi b/stdlib/email/errors.pyi index b501a5866556..4da60250965e 100644 --- a/stdlib/email/errors.pyi +++ b/stdlib/email/errors.pyi @@ -1,5 +1,3 @@ -import sys - class MessageError(Exception): ... class MessageParseError(MessageError): ... class HeaderParseError(MessageParseError): ... @@ -37,6 +35,4 @@ class NonPrintableDefect(HeaderDefect): class ObsoleteHeaderDefect(HeaderDefect): ... class NonASCIILocalPartDefect(HeaderDefect): ... - -if sys.version_info >= (3, 10): - class InvalidDateDefect(HeaderDefect): ... +class InvalidDateDefect(HeaderDefect): ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index 794882b140e6..08fcb121dd07 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -5,8 +5,8 @@ from email.charset import Charset from email.contentmanager import ContentManager from email.errors import MessageDefect from email.policy import Policy -from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self __all__ = ["Message", "EmailMessage"] diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index cece2f2a1119..4b314b9d056c 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -4,8 +4,8 @@ from _typeshed import Unused from collections.abc import Iterable from email import _ParamType from email.charset import Charset -from typing import overload -from typing_extensions import TypeAlias, deprecated +from typing import TypeAlias, overload +from typing_extensions import deprecated __all__ = [ "collapse_rfc2231_value", diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index f9b53e1d45f1..afb6961b9594 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -4,8 +4,8 @@ import types from _typeshed import SupportsKeysAndGetItem, Unused from builtins import property as _builtins_property from collections.abc import Callable, Iterable, Iterator, Mapping -from typing import Any, Final, Generic, Literal, SupportsIndex, TypeVar, overload -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Final, Generic, Literal, SupportsIndex, TypeAlias, TypeVar, overload +from typing_extensions import Self, disjoint_base __all__ = ["EnumMeta", "Enum", "IntEnum", "Flag", "IntFlag", "auto", "unique"] @@ -114,10 +114,8 @@ class EnumMeta(type): def __contains__(self: type[Any], value: object) -> bool: ... elif sys.version_info >= (3, 11): def __contains__(self: type[Any], member: object) -> bool: ... - elif sys.version_info >= (3, 10): - def __contains__(self: type[Any], obj: object) -> bool: ... else: - def __contains__(self: type[Any], member: object) -> bool: ... + def __contains__(self: type[Any], obj: object) -> bool: ... def __getitem__(self: type[_EnumMemberT], name: str) -> _EnumMemberT: ... @_builtins_property diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 5a3e89b0c676..b7f8bbe13f3e 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -46,9 +46,8 @@ if sys.platform != "win32": F_OFD_SETLK: Final[int] F_OFD_SETLKW: Final[int] - if sys.version_info >= (3, 10): - F_GETPIPE_SZ: Final[int] - F_SETPIPE_SZ: Final[int] + F_GETPIPE_SZ: Final[int] + F_SETPIPE_SZ: Final[int] DN_ACCESS: Final[int] DN_ATTRIB: Final[int] diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index 6778b764810b..c022377aff8d 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import AnyStr_co, StrOrBytesPath from collections.abc import Callable, Iterable from types import GenericAlias, TracebackType -from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import Self, deprecated __all__ = [ "input", @@ -30,10 +30,52 @@ class _HasReadlineAndFileno(Protocol[AnyStr_co]): def readline(self) -> AnyStr_co: ... def fileno(self) -> int: ... -if sys.version_info >= (3, 10): - # encoding and errors are added +@overload +def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: _TextMode = "r", + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, + encoding: str | None = None, + errors: str | None = None, +) -> FileInput[str]: ... +@overload +def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: Literal["rb"], + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, + encoding: None = None, + errors: None = None, +) -> FileInput[bytes]: ... +@overload +def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: str, + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, + encoding: str | None = None, + errors: str | None = None, +) -> FileInput[Any]: ... +def close() -> None: ... +def nextfile() -> None: ... +def filename() -> str: ... +def lineno() -> int: ... +def filelineno() -> int: ... +def fileno() -> int: ... +def isfirstline() -> bool: ... +def isstdin() -> bool: ... + +class FileInput(Generic[AnyStr]): @overload - def input( + def __init__( + self: FileInput[str], files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -42,9 +84,10 @@ if sys.version_info >= (3, 10): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, encoding: str | None = None, errors: str | None = None, - ) -> FileInput[str]: ... + ) -> None: ... @overload - def input( + def __init__( + self: FileInput[bytes], files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -53,9 +96,10 @@ if sys.version_info >= (3, 10): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, encoding: None = None, errors: None = None, - ) -> FileInput[bytes]: ... + ) -> None: ... @overload - def input( + def __init__( + self: FileInput[Any], files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -64,120 +108,7 @@ if sys.version_info >= (3, 10): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, encoding: str | None = None, errors: str | None = None, - ) -> FileInput[Any]: ... - -else: - # bufsize is dropped and mode and openhook become keyword-only - @overload - def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: _TextMode = "r", - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, - ) -> FileInput[str]: ... - @overload - def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: Literal["rb"], - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, - ) -> FileInput[bytes]: ... - @overload - def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: str, - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, - ) -> FileInput[Any]: ... - -def close() -> None: ... -def nextfile() -> None: ... -def filename() -> str: ... -def lineno() -> int: ... -def filelineno() -> int: ... -def fileno() -> int: ... -def isfirstline() -> bool: ... -def isstdin() -> bool: ... - -class FileInput(Generic[AnyStr]): - if sys.version_info >= (3, 10): - # encoding and errors are added - @overload - def __init__( - self: FileInput[str], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: _TextMode = "r", - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, - encoding: str | None = None, - errors: str | None = None, - ) -> None: ... - @overload - def __init__( - self: FileInput[bytes], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: Literal["rb"], - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, - encoding: None = None, - errors: None = None, - ) -> None: ... - @overload - def __init__( - self: FileInput[Any], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: str, - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, - encoding: str | None = None, - errors: str | None = None, - ) -> None: ... - - else: - # bufsize is dropped and mode and openhook become keyword-only - @overload - def __init__( - self: FileInput[str], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: _TextMode = "r", - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, - ) -> None: ... - @overload - def __init__( - self: FileInput[bytes], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: Literal["rb"], - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, - ) -> None: ... - @overload - def __init__( - self: FileInput[Any], - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: str, - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, - ) -> None: ... - + ) -> None: ... def __del__(self) -> None: ... def close(self) -> None: ... def __enter__(self) -> Self: ... @@ -199,17 +130,8 @@ class FileInput(Generic[AnyStr]): def isstdin(self) -> bool: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... -if sys.version_info >= (3, 10): - def hook_compressed( - filename: StrOrBytesPath, mode: str, *, encoding: str | None = None, errors: str | None = None - ) -> IO[Any]: ... - -else: - def hook_compressed(filename: StrOrBytesPath, mode: str) -> IO[Any]: ... - -if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10. Use `fileinput.input` or `fileinput.FileInput` instead.") - def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... - -else: - def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... +def hook_compressed( + filename: StrOrBytesPath, mode: str, *, encoding: str | None = None, errors: str | None = None +) -> IO[Any]: ... +@deprecated("Deprecated since Python 3.10. Use `fileinput.input` or `fileinput.FileInput` instead.") +def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... diff --git a/stdlib/formatter.pyi b/stdlib/formatter.pyi index 05c3c8b3dd41..e6401b37a57e 100644 --- a/stdlib/formatter.pyi +++ b/stdlib/formatter.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterable -from typing import IO, Any -from typing_extensions import TypeAlias +from typing import IO, Any, TypeAlias AS_IS: None _FontType: TypeAlias = tuple[str, bool, bool, bool] diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index ef4066aa65b5..ad0a187bb472 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -2,8 +2,8 @@ import sys from collections.abc import Callable from decimal import Decimal from numbers import Rational, Real -from typing import Any, Literal, Protocol, SupportsIndex, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only +from typing_extensions import Self _ComparableNum: TypeAlias = int | float | Decimal | Real diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 57bc3f179f7a..5808cd842553 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -3,8 +3,8 @@ import types from _typeshed import SupportsAllComparisons, SupportsItems from collections.abc import Callable, Hashable, Iterable, Sized from types import GenericAlias -from typing import Any, Final, Generic, Literal, NamedTuple, TypedDict, TypeVar, final, overload, type_check_only -from typing_extensions import ParamSpec, Self, TypeAlias, disjoint_base +from typing import Any, Final, Generic, Literal, NamedTuple, TypeAlias, TypedDict, TypeVar, final, overload, type_check_only +from typing_extensions import ParamSpec, Self, disjoint_base __all__ = [ "update_wrapper", diff --git a/stdlib/gc.pyi b/stdlib/gc.pyi index ec1ed2681c5c..dc20a570cc89 100644 --- a/stdlib/gc.pyi +++ b/stdlib/gc.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Any, Final, Literal -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, TypeAlias DEBUG_COLLECTABLE: Final = 2 DEBUG_LEAK: Final = 38 diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index 942fd7396196..07455acaefc6 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -9,19 +9,14 @@ __all__ = ["escape", "glob", "iglob"] if sys.version_info >= (3, 13): __all__ += ["translate"] -if sys.version_info >= (3, 10): - @deprecated( - "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." - ) - def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... - @deprecated( - "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." - ) - def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... - -else: - def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... - def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... +@deprecated( + "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." +) +def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... +@deprecated( + "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." +) +def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... if sys.version_info >= (3, 11): def glob( @@ -41,7 +36,7 @@ if sys.version_info >= (3, 11): include_hidden: bool = False, ) -> Iterator[AnyStr]: ... -elif sys.version_info >= (3, 10): +else: def glob( pathname: AnyStr, *, root_dir: StrOrBytesPath | None = None, dir_fd: int | None = None, recursive: bool = False ) -> list[AnyStr]: ... @@ -49,10 +44,6 @@ elif sys.version_info >= (3, 10): pathname: AnyStr, *, root_dir: StrOrBytesPath | None = None, dir_fd: int | None = None, recursive: bool = False ) -> Iterator[AnyStr]: ... -else: - def glob(pathname: AnyStr, *, recursive: bool = False) -> list[AnyStr]: ... - def iglob(pathname: AnyStr, *, recursive: bool = False) -> Iterator[AnyStr]: ... - def escape(pathname: AnyStr) -> AnyStr: ... def has_magic(s: str | bytes) -> bool: ... # undocumented diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 965ecece2a56..9f372b4d63dc 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -5,8 +5,7 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_group(structseq[Any], tuple[str, str | None, int, list[str]]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("gr_name", "gr_passwd", "gr_gid", "gr_mem") + __match_args__: Final = ("gr_name", "gr_passwd", "gr_gid", "gr_mem") @property def gr_name(self) -> str: ... diff --git a/stdlib/gzip.pyi b/stdlib/gzip.pyi index b18f76f06e3e..de22625e403f 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -2,8 +2,8 @@ import sys import zlib from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, WriteableBuffer from io import FileIO, TextIOWrapper -from typing import Final, Literal, Protocol, overload, type_check_only -from typing_extensions import TypeAlias, deprecated +from typing import Final, Literal, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import deprecated if sys.version_info >= (3, 14): from compression._common._streams import BaseStream, DecompressReader diff --git a/stdlib/hmac.pyi b/stdlib/hmac.pyi index 070c59b1c166..9beabcc4dd92 100644 --- a/stdlib/hmac.pyi +++ b/stdlib/hmac.pyi @@ -2,8 +2,7 @@ from _hashlib import _HashObject, compare_digest as compare_digest from _typeshed import ReadableBuffer, SizedBuffer from collections.abc import Callable from types import ModuleType -from typing import overload -from typing_extensions import TypeAlias +from typing import TypeAlias, overload _DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 699ef0e4c6d6..2af9769d3c36 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -7,8 +7,8 @@ from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath, SupportsRead, S from collections.abc import Callable, Iterable, Iterator, Mapping from email._policybase import _MessageT from socket import socket -from typing import BinaryIO, Final, TypeVar, overload -from typing_extensions import Self, TypeAlias, deprecated +from typing import BinaryIO, Final, TypeAlias, TypeVar, overload +from typing_extensions import Self, deprecated __all__ = [ "HTTPResponse", diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 31e1d3fc8378..f21c7d6dd832 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import StrPath from collections.abc import Iterator, Sequence from http.client import HTTPResponse @@ -49,9 +48,7 @@ class FileCookieJar(CookieJar): def load(self, filename: str | None = None, ignore_discard: bool = False, ignore_expires: bool = False) -> None: ... def revert(self, filename: str | None = None, ignore_discard: bool = False, ignore_expires: bool = False) -> None: ... -class MozillaCookieJar(FileCookieJar): - if sys.version_info < (3, 10): - header: ClassVar[str] # undocumented +class MozillaCookieJar(FileCookieJar): ... # undocumented class LWPCookieJar(FileCookieJar): def as_lwp_str(self, ignore_discard: bool = True, ignore_expires: bool = True) -> str: ... # undocumented diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index eadf054c3a5f..317cd4fa8518 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,8 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Iterable, Mapping from types import GenericAlias -from typing import Any, Generic, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Generic, TypeAlias, TypeVar, overload __all__ = ["CookieError", "BaseCookie", "SimpleCookie"] diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 94b96f0a1283..5a7443604f0a 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -9,8 +9,8 @@ from re import Pattern from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Literal, SupportsAbs, SupportsInt, overload -from typing_extensions import Self, TypeAlias, deprecated +from typing import IO, Any, Literal, SupportsAbs, SupportsInt, TypeAlias, overload +from typing_extensions import Self, deprecated __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"] diff --git a/stdlib/importlib/_abc.pyi b/stdlib/importlib/_abc.pyi index 90ab34021917..e8c80c0447ae 100644 --- a/stdlib/importlib/_abc.pyi +++ b/stdlib/importlib/_abc.pyi @@ -4,17 +4,16 @@ from abc import ABCMeta from importlib.machinery import ModuleSpec from typing_extensions import deprecated -if sys.version_info >= (3, 10): - class Loader(metaclass=ABCMeta): - def load_module(self, fullname: str) -> types.ModuleType: ... - if sys.version_info < (3, 12): - @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. " - "The module spec is now used by the import machinery to generate a module repr." - ) - def module_repr(self, module: types.ModuleType) -> str: ... +class Loader(metaclass=ABCMeta): + def load_module(self, fullname: str) -> types.ModuleType: ... + if sys.version_info < (3, 12): + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." + ) + def module_repr(self, module: types.ModuleType) -> str: ... - def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... - # Not defined on the actual class for backwards-compatibility reasons, - # but expected in new code. - def exec_module(self, module: types.ModuleType) -> None: ... + def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... + # Not defined on the actual class for backwards-compatibility reasons, + # but expected in new code. + def exec_module(self, module: types.ModuleType) -> None: ... diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index ef7761f7119b..01188c394960 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -25,16 +25,7 @@ if sys.version_info >= (3, 11): if sys.version_info < (3, 12): __all__ += ["Finder", "ResourceReader", "Traversable", "TraversableResources"] -if sys.version_info >= (3, 10): - from importlib._abc import Loader as Loader -else: - class Loader(metaclass=ABCMeta): - def load_module(self, fullname: str) -> types.ModuleType: ... - def module_repr(self, module: types.ModuleType) -> str: ... - def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... - # Not defined on the actual class for backwards-compatibility reasons, - # but expected in new code. - def exec_module(self, module: types.ModuleType) -> None: ... +from importlib._abc import Loader as Loader if sys.version_info < (3, 12): @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use `MetaPathFinder` or `PathEntryFinder` instead.") @@ -68,46 +59,27 @@ class SourceLoader(_bootstrap_external.SourceLoader, ResourceLoader, ExecutionLo def path_stats(self, path: str) -> Mapping[str, Any]: ... # The base classes differ starting in 3.10: -if sys.version_info >= (3, 10): - # Please keep in sync with _typeshed.importlib.MetaPathFinderProtocol - class MetaPathFinder(metaclass=ABCMeta): - if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `MetaPathFinder.find_spec()` instead.") - def find_module(self, fullname: str, path: Sequence[str] | None) -> Loader | None: ... - - def invalidate_caches(self) -> None: ... - # Not defined on the actual class, but expected to exist. - def find_spec( - self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / - ) -> ModuleSpec | None: ... - - class PathEntryFinder(metaclass=ABCMeta): - if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `PathEntryFinder.find_spec()` instead.") - def find_module(self, fullname: str) -> Loader | None: ... - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") - def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[str]]: ... - - def invalidate_caches(self) -> None: ... - # Not defined on the actual class, but expected to exist. - def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... - -else: - # Please keep in sync with _typeshed.importlib.MetaPathFinderProtocol - class MetaPathFinder(Finder): +class MetaPathFinder(metaclass=ABCMeta): + if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `MetaPathFinder.find_spec()` instead.") def find_module(self, fullname: str, path: Sequence[str] | None) -> Loader | None: ... - def invalidate_caches(self) -> None: ... - # Not defined on the actual class, but expected to exist. - def find_spec( - self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / - ) -> ModuleSpec | None: ... - class PathEntryFinder(Finder): + def invalidate_caches(self) -> None: ... + # Not defined on the actual class, but expected to exist. + def find_spec( + self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / + ) -> ModuleSpec | None: ... + +class PathEntryFinder(metaclass=ABCMeta): + if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `PathEntryFinder.find_spec()` instead.") def find_module(self, fullname: str) -> Loader | None: ... + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[str]]: ... - def invalidate_caches(self) -> None: ... - # Not defined on the actual class, but expected to exist. - def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... + + def invalidate_caches(self) -> None: ... + # Not defined on the actual class, but expected to exist. + def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... class FileLoader(_bootstrap_external.FileLoader, ResourceLoader, ExecutionLoader, metaclass=ABCMeta): name: str @@ -123,13 +95,8 @@ if sys.version_info < (3, 11): def open_resource(self, resource: str) -> IO[bytes]: ... @abstractmethod def resource_path(self, resource: str) -> str: ... - if sys.version_info >= (3, 10): - @abstractmethod - def is_resource(self, path: str) -> bool: ... - else: - @abstractmethod - def is_resource(self, name: str) -> bool: ... - + @abstractmethod + def is_resource(self, path: str) -> bool: ... @abstractmethod def contents(self) -> Iterator[str]: ... @@ -160,12 +127,7 @@ if sys.version_info < (3, 11): @property @abstractmethod def name(self) -> str: ... - if sys.version_info >= (3, 10): - def __truediv__(self, child: str, /) -> Traversable: ... - else: - @abstractmethod - def __truediv__(self, child: str, /) -> Traversable: ... - + def __truediv__(self, child: str, /) -> Traversable: ... @abstractmethod def read_bytes(self) -> bytes: ... @abstractmethod diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index 9286e92331c8..d994d68c05fa 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -5,13 +5,11 @@ import types from _collections_abc import dict_keys, dict_values from _typeshed import StrPath from collections.abc import Iterable, Iterator, Mapping -from email.message import Message from importlib.abc import MetaPathFinder from os import PathLike -from pathlib import Path from re import Pattern -from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload -from typing_extensions import Self, TypeAlias, deprecated, disjoint_base +from typing import Any, ClassVar, Generic, NamedTuple, TypeAlias, TypeVar, overload +from typing_extensions import Self, deprecated, disjoint_base _T = TypeVar("_T") _KT = TypeVar("_KT") @@ -30,17 +28,13 @@ __all__ = [ "version", ] -if sys.version_info >= (3, 10): - __all__ += ["PackageMetadata", "packages_distributions"] +__all__ += ["PackageMetadata", "packages_distributions"] -if sys.version_info >= (3, 10): - from importlib.metadata._meta import PackageMetadata as PackageMetadata, SimplePath - def packages_distributions() -> Mapping[str, list[str]]: ... +from importlib.metadata._meta import PackageMetadata as PackageMetadata, SimplePath - _SimplePath: TypeAlias = SimplePath +def packages_distributions() -> Mapping[str, list[str]]: ... -else: - _SimplePath: TypeAlias = Path +_SimplePath: TypeAlias = SimplePath class PackageNotFoundError(ModuleNotFoundError): @property @@ -103,19 +97,17 @@ else: def module(self) -> str: ... @property def attr(self) -> str: ... - if sys.version_info >= (3, 10): - dist: ClassVar[Distribution | None] - def matches( - self, - *, - name: str = ..., - value: str = ..., - group: str = ..., - module: str = ..., - attr: str = ..., - extras: list[str] = ..., - ) -> bool: ... # undocumented - + dist: ClassVar[Distribution | None] + def matches( + self, + *, + name: str = ..., + value: str = ..., + group: str = ..., + module: str = ..., + attr: str = ..., + extras: list[str] = ..., + ) -> bool: ... # undocumented def __hash__(self) -> int: ... def __iter__(self) -> Iterator[Any]: ... # result of iter((str, Self)), really @@ -138,7 +130,7 @@ if sys.version_info >= (3, 12): @property def groups(self) -> set[str]: ... -elif sys.version_info >= (3, 10): +else: class DeprecatedList(list[_T]): __slots__ = () @@ -234,27 +226,18 @@ class Distribution(_distribution_parent): ) -> Iterable[Distribution]: ... @staticmethod def at(path: StrPath) -> PathDistribution: ... - - if sys.version_info >= (3, 10): - @property - def metadata(self) -> PackageMetadata: ... - @property - def entry_points(self) -> EntryPoints: ... - else: - @property - def metadata(self) -> Message: ... - @property - def entry_points(self) -> list[EntryPoint]: ... - + @property + def metadata(self) -> PackageMetadata: ... + @property + def entry_points(self) -> EntryPoints: ... @property def version(self) -> str: ... @property def files(self) -> list[PackagePath] | None: ... @property def requires(self) -> list[str] | None: ... - if sys.version_info >= (3, 10): - @property - def name(self) -> str: ... + @property + def name(self) -> str: ... if sys.version_info >= (3, 13): @property def origin(self) -> types.SimpleNamespace | None: ... @@ -275,7 +258,7 @@ class MetadataPathFinder(DistributionFinder): if sys.version_info >= (3, 11): @classmethod def invalidate_caches(cls) -> None: ... - elif sys.version_info >= (3, 10): + else: # Yes, this is an instance method that has a parameter named "cls" def invalidate_caches(cls) -> None: ... @@ -292,19 +275,14 @@ def distributions(*, context: DistributionFinder.Context) -> Iterable[Distributi def distributions( *, context: None = None, name: str | None = ..., path: list[str] = ..., **kwargs: Any ) -> Iterable[Distribution]: ... - -if sys.version_info >= (3, 10): - def metadata(distribution_name: str) -> PackageMetadata: ... - -else: - def metadata(distribution_name: str) -> Message: ... +def metadata(distribution_name: str) -> PackageMetadata: ... if sys.version_info >= (3, 12): def entry_points( *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... ) -> EntryPoints: ... -elif sys.version_info >= (3, 10): +else: @overload def entry_points() -> SelectableGroups: ... @overload @@ -312,9 +290,6 @@ elif sys.version_info >= (3, 10): *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... ) -> EntryPoints: ... -else: - def entry_points() -> dict[str, list[EntryPoint]]: ... - def version(distribution_name: str) -> str: ... def files(distribution_name: str) -> list[PackagePath] | None: ... def requires(distribution_name: str) -> list[str] | None: ... diff --git a/stdlib/importlib/readers.pyi b/stdlib/importlib/readers.pyi index 0e7f7ce165c3..50f06ea5434d 100644 --- a/stdlib/importlib/readers.pyi +++ b/stdlib/importlib/readers.pyi @@ -7,66 +7,63 @@ import sys import zipfile from _typeshed import StrPath from collections.abc import Iterable, Iterator +from importlib._bootstrap_external import FileLoader from io import BufferedReader from typing import Literal, NoReturn, TypeVar from typing_extensions import Never - -if sys.version_info >= (3, 10): - from importlib._bootstrap_external import FileLoader - from zipimport import zipimporter +from zipimport import zipimporter if sys.version_info >= (3, 11): from importlib.resources import abc else: from importlib import abc -if sys.version_info >= (3, 10): - if sys.version_info >= (3, 11): - __all__ = ["FileReader", "ZipReader", "MultiplexedPath", "NamespaceReader"] +if sys.version_info >= (3, 11): + __all__ = ["FileReader", "ZipReader", "MultiplexedPath", "NamespaceReader"] - if sys.version_info < (3, 11): - _T = TypeVar("_T") +if sys.version_info < (3, 11): + _T = TypeVar("_T") - def remove_duplicates(items: Iterable[_T]) -> Iterator[_T]: ... + def remove_duplicates(items: Iterable[_T]) -> Iterator[_T]: ... - class FileReader(abc.TraversableResources): - path: pathlib.Path - def __init__(self, loader: FileLoader) -> None: ... - def resource_path(self, resource: StrPath) -> str: ... - def files(self) -> pathlib.Path: ... +class FileReader(abc.TraversableResources): + path: pathlib.Path + def __init__(self, loader: FileLoader) -> None: ... + def resource_path(self, resource: StrPath) -> str: ... + def files(self) -> pathlib.Path: ... - class ZipReader(abc.TraversableResources): - prefix: str - archive: str - def __init__(self, loader: zipimporter, module: str) -> None: ... - def open_resource(self, resource: str) -> BufferedReader: ... - def is_resource(self, path: StrPath) -> bool: ... - def files(self) -> zipfile.Path: ... +class ZipReader(abc.TraversableResources): + prefix: str + archive: str + def __init__(self, loader: zipimporter, module: str) -> None: ... + def open_resource(self, resource: str) -> BufferedReader: ... + def is_resource(self, path: StrPath) -> bool: ... + def files(self) -> zipfile.Path: ... - class MultiplexedPath(abc.Traversable): - def __init__(self, *paths: abc.Traversable) -> None: ... - def iterdir(self) -> Iterator[abc.Traversable]: ... - def read_bytes(self) -> NoReturn: ... - def read_text(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] - def is_dir(self) -> Literal[True]: ... - def is_file(self) -> Literal[False]: ... +class MultiplexedPath(abc.Traversable): + def __init__(self, *paths: abc.Traversable) -> None: ... + def iterdir(self) -> Iterator[abc.Traversable]: ... + def read_bytes(self) -> NoReturn: ... + def read_text(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] + def is_dir(self) -> Literal[True]: ... + def is_file(self) -> Literal[False]: ... - if sys.version_info >= (3, 12): - def joinpath(self, *descendants: StrPath) -> abc.Traversable: ... - elif sys.version_info >= (3, 11): - def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override] - else: - def joinpath(self, child: str) -> abc.Traversable: ... + if sys.version_info >= (3, 12): + def joinpath(self, *descendants: StrPath) -> abc.Traversable: ... + elif sys.version_info >= (3, 11): + def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override] + else: + def joinpath(self, child: str) -> abc.Traversable: ... - if sys.version_info < (3, 12): - __truediv__ = joinpath + if sys.version_info < (3, 12): + __truediv__ = joinpath - def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] - @property - def name(self) -> str: ... + def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] + @property + def name(self) -> str: ... - class NamespaceReader(abc.TraversableResources): - path: MultiplexedPath - def __init__(self, namespace_path: Iterable[str]) -> None: ... - def resource_path(self, resource: str) -> str: ... - def files(self) -> MultiplexedPath: ... +class NamespaceReader(abc.TraversableResources): + path: MultiplexedPath + def __init__(self, namespace_path: Iterable[str]) -> None: ... + def resource_path(self, resource: str) -> str: ... + def files(self) -> MultiplexedPath: ... diff --git a/stdlib/importlib/resources/__init__.pyi b/stdlib/importlib/resources/__init__.pyi index 28adc37da4a4..90cf473dc84b 100644 --- a/stdlib/importlib/resources/__init__.pyi +++ b/stdlib/importlib/resources/__init__.pyi @@ -4,8 +4,8 @@ from collections.abc import Iterator from contextlib import AbstractContextManager from pathlib import Path from types import ModuleType -from typing import Any, BinaryIO, Literal, TextIO -from typing_extensions import TypeAlias, deprecated +from typing import Any, BinaryIO, Literal, TextIO, TypeAlias +from typing_extensions import deprecated if sys.version_info >= (3, 11): from importlib.resources.abc import Traversable @@ -30,8 +30,7 @@ __all__ = [ "read_text", ] -if sys.version_info >= (3, 10): - __all__ += ["ResourceReader"] +__all__ += ["ResourceReader"] if sys.version_info < (3, 13): __all__ += ["Resource"] @@ -82,5 +81,5 @@ else: if sys.version_info >= (3, 11): from importlib.resources.abc import ResourceReader as ResourceReader -elif sys.version_info >= (3, 10): +else: from importlib.abc import ResourceReader as ResourceReader diff --git a/stdlib/importlib/resources/_common.pyi b/stdlib/importlib/resources/_common.pyi index 11a93ca82d8d..b430c7ef82a0 100644 --- a/stdlib/importlib/resources/_common.pyi +++ b/stdlib/importlib/resources/_common.pyi @@ -7,8 +7,8 @@ if sys.version_info >= (3, 11): from contextlib import AbstractContextManager from importlib.resources.abc import ResourceReader, Traversable from pathlib import Path - from typing import Literal, overload - from typing_extensions import TypeAlias, deprecated + from typing import Literal, TypeAlias, overload + from typing_extensions import deprecated Package: TypeAlias = str | types.ModuleType diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index c48d63bc4f32..cb3299e2d750 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -25,8 +25,8 @@ from types import ( TracebackType, WrapperDescriptorType, ) -from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, Self, TypeAlias, TypeGuard, TypeIs, deprecated, disjoint_base +from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeAlias, TypeGuard, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, Self, TypeIs, deprecated, disjoint_base if sys.version_info >= (3, 14): from annotationlib import Format @@ -319,7 +319,7 @@ if sys.version_info >= (3, 14): annotation_format: Format = Format.VALUE, # noqa: Y011 ) -> Signature: ... -elif sys.version_info >= (3, 10): +else: def signature( obj: _IntrospectableCallable, *, @@ -329,9 +329,6 @@ elif sys.version_info >= (3, 10): eval_str: bool = False, ) -> Signature: ... -else: - def signature(obj: _IntrospectableCallable, *, follow_wrapped: bool = True) -> Signature: ... - class _void: ... class _empty: ... @@ -361,7 +358,7 @@ class Signature: eval_str: bool = False, annotation_format: Format = Format.VALUE, # noqa: Y011 ) -> Self: ... - elif sys.version_info >= (3, 10): + else: @classmethod def from_callable( cls, @@ -372,9 +369,6 @@ class Signature: locals: Mapping[str, Any] | None = None, eval_str: bool = False, ) -> Self: ... - else: - @classmethod - def from_callable(cls, obj: _IntrospectableCallable, *, follow_wrapped: bool = True) -> Self: ... if sys.version_info >= (3, 14): def format(self, *, max_width: int | None = None, quote_annotation_strings: bool = True) -> str: ... elif sys.version_info >= (3, 13): @@ -385,7 +379,7 @@ class Signature: if sys.version_info >= (3, 14): from annotationlib import get_annotations as get_annotations -elif sys.version_info >= (3, 10): +else: def get_annotations( obj: Callable[..., object] | type[object] | ModuleType, # any callable, class, or module *, diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index d09804cb9342..c503a69aad7b 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Iterable, Iterator -from typing import Any, Final, Generic, Literal, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import Any, Final, Generic, Literal, TypeAlias, TypeVar, overload +from typing_extensions import Self # Undocumented length constants IPV4LENGTH: Final = 32 diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 8a924ad8b1e7..76844c0cc285 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import MaybeNone from collections.abc import Callable, Iterable, Iterator from types import GenericAlias -from typing import Any, Generic, Literal, SupportsComplex, SupportsFloat, SupportsIndex, SupportsInt, TypeVar, overload -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Generic, Literal, SupportsComplex, SupportsFloat, SupportsIndex, SupportsInt, TypeAlias, TypeVar, overload +from typing_extensions import Self, disjoint_base _T = TypeVar("_T") _S = TypeVar("_S") @@ -332,12 +332,11 @@ class combinations_with_replacement(Generic[_T_co]): def __iter__(self) -> Self: ... def __next__(self) -> _T_co: ... -if sys.version_info >= (3, 10): - @disjoint_base - class pairwise(Generic[_T_co]): - def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ... - def __iter__(self) -> Self: ... - def __next__(self) -> _T_co: ... +@disjoint_base +class pairwise(Generic[_T_co]): + def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ... + def __iter__(self) -> Self: ... + def __next__(self) -> _T_co: ... if sys.version_info >= (3, 12): @disjoint_base diff --git a/stdlib/lib2to3/pgen2/__init__.pyi b/stdlib/lib2to3/pgen2/__init__.pyi index de8a874f434d..3b1cbef7727d 100644 --- a/stdlib/lib2to3/pgen2/__init__.pyi +++ b/stdlib/lib2to3/pgen2/__init__.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from ..pytree import _RawNode from .grammar import Grammar diff --git a/stdlib/lib2to3/pgen2/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index bef0a7922683..5093422ae236 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -1,5 +1,6 @@ from _typeshed import StrPath -from typing_extensions import Self, TypeAlias +from typing import TypeAlias +from typing_extensions import Self _Label: TypeAlias = tuple[int, str | None] _DFA: TypeAlias = list[list[tuple[int, int]]] diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index 320c5f018d43..9befe9bf879d 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Sequence -from typing_extensions import TypeAlias +from typing import TypeAlias from ..pytree import _NL, _RawNode from . import _Convert diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index af54de1b51d3..76ff733163af 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Iterable, Iterator -from typing_extensions import TypeAlias +from typing import TypeAlias from .token import * diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 51bdbc75e142..045f7882721a 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, SupportsGetItem, SupportsLenAndGetItem, Unused from abc import abstractmethod from collections.abc import Iterable, Iterator, MutableSequence -from typing import ClassVar, Final -from typing_extensions import Self, TypeAlias +from typing import ClassVar, Final, TypeAlias +from typing_extensions import Self from .fixer_base import BaseFix from .pgen2.grammar import Grammar diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index 5379a21e7d12..f527e7084ced 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias __all__ = ["getline", "clearcache", "checkcache", "lazycache"] diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 80c39a532dc8..44f9315678e0 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -153,10 +153,7 @@ if sys.version_info < (3, 12): def format_string(f: _str, val: Any, grouping: bool = False, monetary: bool = False) -> _str: ... def currency(val: float | Decimal, symbol: bool = True, grouping: bool = False, international: bool = False) -> _str: ... def delocalize(string: _str) -> _str: ... - -if sys.version_info >= (3, 10): - def localize(string: _str, grouping: bool = False, monetary: bool = False) -> _str: ... - +def localize(string: _str, grouping: bool = False, monetary: bool = False) -> _str: ... def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... def str(val: float) -> _str: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 8248f82ea87a..7e56333bbf16 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -7,8 +7,8 @@ from re import Pattern from string import Template from time import struct_time from types import FrameType, GenericAlias, TracebackType -from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self, deprecated __all__ = [ "BASIC_FORMAT", @@ -274,21 +274,15 @@ class Formatter: default_time_format: str default_msec_format: str | None - if sys.version_info >= (3, 10): - def __init__( - self, - fmt: str | None = None, - datefmt: str | None = None, - style: _FormatStyle = "%", - validate: bool = True, - *, - defaults: Mapping[str, Any] | None = None, - ) -> None: ... - else: - def __init__( - self, fmt: str | None = None, datefmt: str | None = None, style: _FormatStyle = "%", validate: bool = True - ) -> None: ... - + def __init__( + self, + fmt: str | None = None, + datefmt: str | None = None, + style: _FormatStyle = "%", + validate: bool = True, + *, + defaults: Mapping[str, Any] | None = None, + ) -> None: ... def format(self, record: LogRecord) -> str: ... def formatTime(self, record: LogRecord, datefmt: str | None = None) -> str: ... def formatException(self, ei: _SysExcInfoType) -> str: ... @@ -365,15 +359,10 @@ class LoggerAdapter(Generic[_L]): if sys.version_info >= (3, 13): def __init__(self, logger: _L, extra: Mapping[str, object] | None = None, merge_extra: bool = False) -> None: ... - elif sys.version_info >= (3, 10): - def __init__(self, logger: _L, extra: Mapping[str, object] | None = None) -> None: ... else: - def __init__(self, logger: _L, extra: Mapping[str, object]) -> None: ... + def __init__(self, logger: _L, extra: Mapping[str, object] | None = None) -> None: ... - if sys.version_info >= (3, 10): - extra: Mapping[str, object] | None - else: - extra: Mapping[str, object] + extra: Mapping[str, object] | None if sys.version_info >= (3, 13): merge_extra: bool @@ -641,11 +630,7 @@ class PercentStyle: # undocumented asctime_search: str validation_pattern: Pattern[str] _fmt: str - if sys.version_info >= (3, 10): - def __init__(self, fmt: str, *, defaults: Mapping[str, Any] | None = None) -> None: ... - else: - def __init__(self, fmt: str) -> None: ... - + def __init__(self, fmt: str, *, defaults: Mapping[str, Any] | None = None) -> None: ... def usesTime(self) -> bool: ... def validate(self) -> None: ... def format(self, record: Any) -> str: ... diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index e36214551600..405d7fb898fc 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -4,8 +4,8 @@ from collections.abc import Callable, Hashable, Iterable, Mapping, Sequence from configparser import RawConfigParser from re import Pattern from threading import Thread -from typing import IO, Any, Final, Literal, SupportsIndex, TypedDict, overload, type_check_only -from typing_extensions import Required, TypeAlias, disjoint_base +from typing import IO, Any, Final, Literal, SupportsIndex, TypeAlias, TypedDict, overload, type_check_only +from typing_extensions import Required, disjoint_base from . import Filter, Filterer, Formatter, Handler, Logger, _FilterType, _FormatStyle, _Level @@ -64,22 +64,12 @@ class _DictConfigArgs(TypedDict, total=False): # Also accept a TypedDict type, to allow callers to use TypedDict # types, and for somewhat stricter type checking of dict literals. def dictConfig(config: _DictConfigArgs | dict[str, Any]) -> None: ... - -if sys.version_info >= (3, 10): - def fileConfig( - fname: StrOrBytesPath | IO[str] | RawConfigParser, - defaults: Mapping[str, str] | None = None, - disable_existing_loggers: bool = True, - encoding: str | None = None, - ) -> None: ... - -else: - def fileConfig( - fname: StrOrBytesPath | IO[str] | RawConfigParser, - defaults: Mapping[str, str] | None = None, - disable_existing_loggers: bool = True, - ) -> None: ... - +def fileConfig( + fname: StrOrBytesPath | IO[str] | RawConfigParser, + defaults: Mapping[str, str] | None = None, + disable_existing_loggers: bool = True, + encoding: str | None = None, +) -> None: ... def valid_ident(s: str) -> Literal[True]: ... # undocumented def listen(port: int = 9030, verify: Callable[[bytes], bytes | None] | None = None) -> Thread: ... def stopListening() -> None: ... diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index b7ef607b75cb..b920f477542e 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -36,8 +36,8 @@ from _lzma import ( ) from _typeshed import ReadableBuffer, StrOrBytesPath from io import TextIOWrapper -from typing import IO, Literal, overload -from typing_extensions import Self, TypeAlias +from typing import IO, Literal, TypeAlias, overload +from typing_extensions import Self if sys.version_info >= (3, 14): from compression._common._streams import BaseStream diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 89bd998b4dfe..1bfd9cc9f7a8 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -6,8 +6,8 @@ from abc import ABCMeta, abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from email._policybase import _MessageT from types import GenericAlias, TracebackType -from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self __all__ = [ "Mailbox", diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index ce549e01f528..74c32694a7f9 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -1,5 +1,5 @@ from collections.abc import Mapping, Sequence -from typing_extensions import TypeAlias +from typing import TypeAlias _Cap: TypeAlias = dict[str, str | int] diff --git a/stdlib/marshal.pyi b/stdlib/marshal.pyi index 46c421e4ce30..ad0c4cb40ded 100644 --- a/stdlib/marshal.pyi +++ b/stdlib/marshal.pyi @@ -2,8 +2,7 @@ import builtins import sys import types from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite -from typing import Any, Final -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias version: Final[int] diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 1903d488f7bb..30858b870f68 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -1,8 +1,7 @@ import sys from _typeshed import SupportsMul, SupportsRMul from collections.abc import Iterable -from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 005020b8b6b3..4e27695f179e 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -15,8 +15,7 @@ ALLOCATIONGRANULARITY: Final[int] if sys.platform == "linux": MAP_DENYWRITE: Final[int] MAP_EXECUTABLE: Final[int] - if sys.version_info >= (3, 10): - MAP_POPULATE: Final[int] + MAP_POPULATE: Final[int] if sys.version_info >= (3, 11) and sys.platform != "win32" and sys.platform != "darwin": MAP_STACK: Final[int] diff --git a/stdlib/msilib/sequence.pyi b/stdlib/msilib/sequence.pyi index a9f5c24717bd..9b01c416f1d6 100644 --- a/stdlib/msilib/sequence.pyi +++ b/stdlib/msilib/sequence.pyi @@ -1,6 +1,5 @@ import sys -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias if sys.platform == "win32": _SequenceType: TypeAlias = list[tuple[str, str | None, int]] diff --git a/stdlib/msvcrt.pyi b/stdlib/msvcrt.pyi index 5feca8eab5c1..1518f7974de7 100644 --- a/stdlib/msvcrt.pyi +++ b/stdlib/msvcrt.pyi @@ -28,5 +28,4 @@ if sys.platform == "win32": def ungetwch(unicode_char: str, /) -> None: ... def heapmin() -> None: ... def SetErrorMode(mode: int, /) -> int: ... - if sys.version_info >= (3, 10): - def GetErrorMode() -> int: ... # undocumented + def GetErrorMode() -> int: ... # undocumented diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index cd4fa102c0f3..b9475c5baa49 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -3,8 +3,8 @@ import sys from _typeshed import Incomplete, ReadableBuffer from collections.abc import Iterable from types import TracebackType -from typing import Any, Generic, SupportsIndex, TypeVar -from typing_extensions import Self, TypeAlias +from typing import Any, Generic, SupportsIndex, TypeAlias, TypeVar +from typing_extensions import Self __all__ = ["Client", "Listener", "Pipe", "wait"] diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index 03d1d2e5c220..960678698648 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -9,8 +9,7 @@ from multiprocessing.managers import SyncManager from multiprocessing.pool import Pool as _Pool from multiprocessing.process import BaseProcess from multiprocessing.sharedctypes import Synchronized, SynchronizedArray, SynchronizedString -from typing import Any, ClassVar, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Literal, TypeAlias, TypeVar, overload if sys.platform != "win32": from multiprocessing.connection import Connection diff --git a/stdlib/multiprocessing/heap.pyi b/stdlib/multiprocessing/heap.pyi index 38191a099f1e..cab9c58dc549 100644 --- a/stdlib/multiprocessing/heap.pyi +++ b/stdlib/multiprocessing/heap.pyi @@ -2,8 +2,7 @@ import sys from _typeshed import Incomplete from collections.abc import Callable from mmap import mmap -from typing import Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Protocol, TypeAlias, type_check_only __all__ = ["BufferWrapper"] diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index bc6b2e6a9d27..04051cf0ba08 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -14,8 +14,8 @@ from collections.abc import ( Set as AbstractSet, ) from types import GenericAlias, TracebackType -from typing import Any, AnyStr, ClassVar, Generic, SupportsIndex, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import Any, AnyStr, ClassVar, Generic, SupportsIndex, TypeAlias, TypeVar, overload +from typing_extensions import Self from . import pool from .connection import Connection, _Address @@ -227,11 +227,7 @@ class Server: ) -> None: ... def serve_forever(self) -> None: ... def accepter(self) -> None: ... - if sys.version_info >= (3, 10): - def handle_request(self, conn: _ServerConnection) -> None: ... - else: - def handle_request(self, c: _ServerConnection) -> None: ... - + def handle_request(self, conn: _ServerConnection) -> None: ... def serve_client(self, conn: _ServerConnection) -> None: ... def fallback_getvalue(self, conn: _ServerConnection, ident: str, obj: _T) -> _T: ... def fallback_str(self, conn: _ServerConnection, ident: str, obj: Any) -> str: ... diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 541e0b05dd8a..889e71c061e1 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -3,7 +3,7 @@ import threading from collections.abc import Callable from multiprocessing.context import BaseContext from types import TracebackType -from typing_extensions import TypeAlias +from typing import TypeAlias __all__ = ["Lock", "RLock", "Semaphore", "BoundedSemaphore", "Condition", "Event"] diff --git a/stdlib/netrc.pyi b/stdlib/netrc.pyi index 480f55a46d64..4b7035c3e565 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrOrBytesPath -from typing_extensions import TypeAlias +from typing import TypeAlias __all__ = ["netrc", "NetrcParseError"] diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 1fb1e79f69a1..50b633ce1ad1 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -4,8 +4,8 @@ import ssl from _typeshed import Unused from builtins import list as _list # conflicts with a method named "list" from collections.abc import Iterable -from typing import IO, Any, Final, NamedTuple -from typing_extensions import Self, TypeAlias +from typing import IO, Any, Final, NamedTuple, TypeAlias +from typing_extensions import Self __all__ = [ "NNTP", diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 9e02fbf9e106..47f76e1ebea9 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -35,13 +35,14 @@ from typing import ( Literal, NoReturn, Protocol, + TypeAlias, TypeVar, final, overload, runtime_checkable, type_check_only, ) -from typing_extensions import LiteralString, Self, TypeAlias, Unpack, deprecated +from typing_extensions import LiteralString, Self, Unpack, deprecated from . import path as _path @@ -802,8 +803,7 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo # st_uid, st_gid, st_size, st_atime, st_mtime, st_ctime. # # More items may be added at the end by some implementations. - if sys.version_info >= (3, 10): - __match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size") + __match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size") @property def st_mode(self) -> int: ... # protection bits, @@ -910,19 +910,18 @@ class DirEntry(Generic[AnyStr]): @final class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ( - "f_bsize", - "f_frsize", - "f_blocks", - "f_bfree", - "f_bavail", - "f_files", - "f_ffree", - "f_favail", - "f_flag", - "f_namemax", - ) + __match_args__: Final = ( + "f_bsize", + "f_frsize", + "f_blocks", + "f_bfree", + "f_bavail", + "f_files", + "f_ffree", + "f_favail", + "f_flag", + "f_namemax", + ) @property def f_bsize(self) -> int: ... @@ -964,8 +963,7 @@ def strerror(code: int, /) -> str: ... def umask(mask: int, /) -> int: ... @final class uname_result(structseq[str], tuple[str, str, str, str, str]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("sysname", "nodename", "release", "version", "machine") + __match_args__: Final = ("sysname", "nodename", "release", "version", "machine") @property def sysname(self) -> str: ... @@ -1153,8 +1151,7 @@ if sys.platform != "win32": def preadv(fd: int, buffers: SupportsLenAndGetItem[WriteableBuffer], offset: int, flags: int = 0, /) -> int: ... def pwritev(fd: int, buffers: SupportsLenAndGetItem[ReadableBuffer], offset: int, flags: int = 0, /) -> int: ... if sys.platform != "darwin": - if sys.version_info >= (3, 10): - RWF_APPEND: Final[int] # docs say available on 3.7+, stubtest says otherwise + RWF_APPEND: Final[int] # docs say available on 3.7+, stubtest says otherwise RWF_DSYNC: Final[int] RWF_SYNC: Final[int] RWF_HIPRI: Final[int] @@ -1181,8 +1178,7 @@ if sys.version_info >= (3, 14): @final class terminal_size(structseq[int], tuple[int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("columns", "lines") + __match_args__: Final = ("columns", "lines") @property def columns(self) -> int: ... @@ -1451,8 +1447,7 @@ else: @final class times_result(structseq[float], tuple[float, float, float, float, float]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("user", "system", "children_user", "children_system", "elapsed") + __match_args__: Final = ("user", "system", "children_user", "children_system", "elapsed") @property def user(self) -> float: ... @@ -1469,16 +1464,9 @@ def times() -> times_result: ... def waitpid(pid: int, options: int, /) -> tuple[int, int]: ... if sys.platform == "win32": - if sys.version_info >= (3, 10): - def startfile( - filepath: StrOrBytesPath, - operation: str = ..., - arguments: str = "", - cwd: StrOrBytesPath | None = None, - show_cmd: int = 1, - ) -> None: ... - else: - def startfile(filepath: StrOrBytesPath, operation: str = ...) -> None: ... + def startfile( + filepath: StrOrBytesPath, operation: str = ..., arguments: str = "", cwd: StrOrBytesPath | None = None, show_cmd: int = 1 + ) -> None: ... else: if sys.version_info >= (3, 14): @@ -1502,8 +1490,7 @@ else: if sys.platform != "darwin" or sys.version_info >= (3, 13): @final class waitid_result(structseq[int], tuple[int, int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("si_pid", "si_uid", "si_signo", "si_status", "si_code") + __match_args__: Final = ("si_pid", "si_uid", "si_signo", "si_status", "si_code") @property def si_pid(self) -> int: ... @@ -1597,8 +1584,7 @@ else: if sys.platform != "win32": @final class sched_param(structseq[int], tuple[int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("sched_priority",) + __match_args__: Final = ("sched_priority",) def __new__(cls, sched_priority: int) -> Self: ... @property diff --git a/stdlib/pathlib/__init__.pyi b/stdlib/pathlib/__init__.pyi index 26dde2accd8d..4338ce1bec5b 100644 --- a/stdlib/pathlib/__init__.pyi +++ b/stdlib/pathlib/__init__.pyi @@ -151,10 +151,8 @@ class PureWindowsPath(PurePath): class Path(PurePath): if sys.version_info >= (3, 14): __slots__ = ("_info",) - elif sys.version_info >= (3, 10): - __slots__ = () else: - __slots__ = ("_accessor",) + __slots__ = () if sys.version_info >= (3, 12): def __new__(cls, *args: StrPath, **kwargs: Unused) -> Self: ... # pyright: ignore[reportInconsistentConstructor] @@ -163,12 +161,8 @@ class Path(PurePath): @classmethod def cwd(cls) -> Self: ... - if sys.version_info >= (3, 10): - def stat(self, *, follow_symlinks: bool = True) -> stat_result: ... - def chmod(self, mode: int, *, follow_symlinks: bool = True) -> None: ... - else: - def stat(self) -> stat_result: ... - def chmod(self, mode: int) -> None: ... + def stat(self, *, follow_symlinks: bool = True) -> stat_result: ... + def chmod(self, mode: int, *, follow_symlinks: bool = True) -> None: ... if sys.version_info >= (3, 13): @classmethod @@ -314,20 +308,12 @@ class Path(PurePath): def is_mount(self) -> bool: ... def readlink(self) -> Self: ... - - if sys.version_info >= (3, 10): - def rename(self, target: StrPath) -> Self: ... - def replace(self, target: StrPath) -> Self: ... - else: - def rename(self, target: str | PurePath) -> Self: ... - def replace(self, target: str | PurePath) -> Self: ... - + def rename(self, target: StrPath) -> Self: ... + def replace(self, target: StrPath) -> Self: ... def resolve(self, strict: bool = False) -> Self: ... def rmdir(self) -> None: ... def symlink_to(self, target: StrOrBytesPath, target_is_directory: bool = False) -> None: ... - if sys.version_info >= (3, 10): - def hardlink_to(self, target: StrOrBytesPath) -> None: ... - + def hardlink_to(self, target: StrOrBytesPath) -> None: ... def touch(self, mode: int = 0o666, exist_ok: bool = True) -> None: ... def unlink(self, missing_ok: bool = False) -> None: ... @classmethod @@ -337,18 +323,12 @@ class Path(PurePath): def read_bytes(self) -> bytes: ... def samefile(self, other_path: StrPath) -> bool: ... def write_bytes(self, data: ReadableBuffer) -> int: ... - if sys.version_info >= (3, 10): - def write_text( - self, data: str, encoding: str | None = None, errors: str | None = None, newline: str | None = None - ) -> int: ... - else: - def write_text(self, data: str, encoding: str | None = None, errors: str | None = None) -> int: ... + def write_text( + self, data: str, encoding: str | None = None, errors: str | None = None, newline: str | None = None + ) -> int: ... if sys.version_info < (3, 12): - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `hardlink_to()` instead.") - def link_to(self, target: StrOrBytesPath) -> None: ... - else: - def link_to(self, target: StrOrBytesPath) -> None: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `hardlink_to()` instead.") + def link_to(self, target: StrOrBytesPath) -> None: ... if sys.version_info >= (3, 12): def walk( self, top_down: bool = True, on_error: Callable[[OSError], object] | None = None, follow_symlinks: bool = False diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index dc1cf3b28086..6584c26e3a77 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -3,12 +3,11 @@ import sys from bdb import Bdb, _Backend from cmd import Cmd from collections.abc import Callable, Iterable, Mapping, Sequence -from inspect import _SourceObjectType from linecache import _ModuleGlobals from rlcompleter import Completer from types import CodeType, FrameType, TracebackType -from typing import IO, Any, ClassVar, Final, Literal, TypeVar -from typing_extensions import ParamSpec, Self, TypeAlias, deprecated +from typing import IO, Any, ClassVar, Final, Literal, TypeAlias, TypeVar +from typing_extensions import ParamSpec, Self, deprecated __all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"] if sys.version_info >= (3, 14): @@ -259,10 +258,6 @@ class Pdb(Bdb, Cmd): def find_function(funcname: str, filename: str) -> tuple[str, str, int] | None: ... def main() -> None: ... def help() -> None: ... - -if sys.version_info < (3, 10): - def getsourcelines(obj: _SourceObjectType) -> tuple[list[str], int]: ... - def lasti2lineno(code: CodeType, lasti: int) -> int: ... class _rstr(str): diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 8bbfaba31b67..98353d960888 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -1,7 +1,6 @@ import sys from collections.abc import Callable, Iterator, MutableMapping -from typing import IO, Any, Final -from typing_extensions import TypeAlias +from typing import IO, Any, Final, TypeAlias __all__ = ["dis", "genops", "optimize"] diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index 69d702bb155c..d9c586d8b143 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -57,8 +57,7 @@ if sys.version_info >= (3, 12): else: @disjoint_base class uname_result(_uname_result_base): - if sys.version_info >= (3, 10): - __match_args__ = ("system", "node", "release", "version", "machine") # pyright: ignore[reportAssignmentType] + __match_args__ = ("system", "node", "release", "version", "machine") # pyright: ignore[reportAssignmentType] def __new__(_cls, system: str, node: str, release: str, version: str, machine: str) -> Self: ... @property @@ -79,9 +78,7 @@ def python_revision() -> str: ... def python_build() -> tuple[str, str]: ... def python_compiler() -> str: ... def platform(aliased: bool = False, terse: bool = False) -> str: ... - -if sys.version_info >= (3, 10): - def freedesktop_os_release() -> dict[str, str]: ... +def freedesktop_os_release() -> dict[str, str]: ... if sys.version_info >= (3, 13): class AndroidVer(NamedTuple): diff --git a/stdlib/poplib.pyi b/stdlib/poplib.pyi index f5669ec87e87..40496ee5286c 100644 --- a/stdlib/poplib.pyi +++ b/stdlib/poplib.pyi @@ -4,8 +4,8 @@ import sys from _typeshed import StrOrBytesPath from builtins import list as _list # conflicts with a method named "list" from re import Pattern -from typing import Any, BinaryIO, Final, NoReturn, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, BinaryIO, Final, NoReturn, TypeAlias, overload +from typing_extensions import deprecated __all__ = ["POP3", "error_proto", "POP3_SSL"] diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 6d0d76ab8217..3259ff239038 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -39,6 +39,7 @@ if sys.platform != "win32": O_DIRECTORY as O_DIRECTORY, O_DSYNC as O_DSYNC, O_EXCL as O_EXCL, + O_FSYNC as O_FSYNC, O_NDELAY as O_NDELAY, O_NOCTTY as O_NOCTTY, O_NOFOLLOW as O_NOFOLLOW, @@ -227,9 +228,6 @@ if sys.platform != "win32": writev as writev, ) - if sys.version_info >= (3, 10): - from os import O_FSYNC as O_FSYNC - if sys.version_info >= (3, 11): from os import login_tty as login_tty @@ -273,6 +271,7 @@ if sys.platform != "win32": POSIX_FADV_RANDOM as POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL as POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED as POSIX_FADV_WILLNEED, + RWF_APPEND as RWF_APPEND, RWF_DSYNC as RWF_DSYNC, RWF_HIPRI as RWF_HIPRI, RWF_NOWAIT as RWF_NOWAIT, @@ -303,14 +302,14 @@ if sys.platform != "win32": setresuid as setresuid, ) - if sys.version_info >= (3, 10): - from os import RWF_APPEND as RWF_APPEND - if sys.platform != "darwin" or sys.version_info >= (3, 13): from os import waitid as waitid, waitid_result as waitid_result if sys.platform == "linux": from os import ( + EFD_CLOEXEC as EFD_CLOEXEC, + EFD_NONBLOCK as EFD_NONBLOCK, + EFD_SEMAPHORE as EFD_SEMAPHORE, GRND_NONBLOCK as GRND_NONBLOCK, GRND_RANDOM as GRND_RANDOM, MFD_ALLOW_SEALING as MFD_ALLOW_SEALING, @@ -341,10 +340,16 @@ if sys.platform != "win32": SCHED_BATCH as SCHED_BATCH, SCHED_IDLE as SCHED_IDLE, SCHED_RESET_ON_FORK as SCHED_RESET_ON_FORK, + SPLICE_F_MORE as SPLICE_F_MORE, + SPLICE_F_MOVE as SPLICE_F_MOVE, + SPLICE_F_NONBLOCK as SPLICE_F_NONBLOCK, XATTR_CREATE as XATTR_CREATE, XATTR_REPLACE as XATTR_REPLACE, XATTR_SIZE_MAX as XATTR_SIZE_MAX, copy_file_range as copy_file_range, + eventfd as eventfd, + eventfd_read as eventfd_read, + eventfd_write as eventfd_write, getrandom as getrandom, getxattr as getxattr, listxattr as listxattr, @@ -352,22 +357,9 @@ if sys.platform != "win32": pidfd_open as pidfd_open, removexattr as removexattr, setxattr as setxattr, + splice as splice, ) - if sys.version_info >= (3, 10): - from os import ( - EFD_CLOEXEC as EFD_CLOEXEC, - EFD_NONBLOCK as EFD_NONBLOCK, - EFD_SEMAPHORE as EFD_SEMAPHORE, - SPLICE_F_MORE as SPLICE_F_MORE, - SPLICE_F_MOVE as SPLICE_F_MOVE, - SPLICE_F_NONBLOCK as SPLICE_F_NONBLOCK, - eventfd as eventfd, - eventfd_read as eventfd_read, - eventfd_write as eventfd_write, - splice as splice, - ) - if sys.version_info >= (3, 12): from os import ( CLONE_FILES as CLONE_FILES, diff --git a/stdlib/pprint.pyi b/stdlib/pprint.pyi index 1e80462e2565..4085731a2a05 100644 --- a/stdlib/pprint.pyi +++ b/stdlib/pprint.pyi @@ -1,112 +1,57 @@ -import sys from _typeshed import SupportsWrite from collections import deque from typing import IO __all__ = ["pprint", "pformat", "isreadable", "isrecursive", "saferepr", "PrettyPrinter", "pp"] -if sys.version_info >= (3, 10): - def pformat( - object: object, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - underscore_numbers: bool = False, - ) -> str: ... - -else: - def pformat( - object: object, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - ) -> str: ... - -if sys.version_info >= (3, 10): - def pp( - object: object, - stream: IO[str] | None = None, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = False, - underscore_numbers: bool = False, - ) -> None: ... +def pformat( + object: object, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + underscore_numbers: bool = False, +) -> str: ... +def pp( + object: object, + stream: IO[str] | None = None, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = False, + underscore_numbers: bool = False, +) -> None: ... +def pprint( + object: object, + stream: IO[str] | None = None, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + underscore_numbers: bool = False, +) -> None: ... +def isreadable(object: object) -> bool: ... +def isrecursive(object: object) -> bool: ... +def saferepr(object: object) -> str: ... -else: - def pp( - object: object, - stream: IO[str] | None = None, +class PrettyPrinter: + def __init__( + self, indent: int = 1, width: int = 80, depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = False, - ) -> None: ... - -if sys.version_info >= (3, 10): - def pprint( - object: object, stream: IO[str] | None = None, - indent: int = 1, - width: int = 80, - depth: int | None = None, *, compact: bool = False, sort_dicts: bool = True, underscore_numbers: bool = False, ) -> None: ... - -else: - def pprint( - object: object, - stream: IO[str] | None = None, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - ) -> None: ... - -def isreadable(object: object) -> bool: ... -def isrecursive(object: object) -> bool: ... -def saferepr(object: object) -> str: ... - -class PrettyPrinter: - if sys.version_info >= (3, 10): - def __init__( - self, - indent: int = 1, - width: int = 80, - depth: int | None = None, - stream: IO[str] | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - underscore_numbers: bool = False, - ) -> None: ... - else: - def __init__( - self, - indent: int = 1, - width: int = 80, - depth: int | None = None, - stream: IO[str] | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - ) -> None: ... - def pformat(self, object: object) -> str: ... def pprint(self, object: object) -> None: ... def isreadable(self, object: object) -> bool: ... @@ -155,5 +100,4 @@ class PrettyPrinter: self, items: list[object], stream: SupportsWrite[str], indent: int, allowance: int, context: dict[int, int], level: int ) -> None: ... def _repr(self, object: object, context: dict[int, int], level: int) -> str: ... - if sys.version_info >= (3, 10): - def _safe_repr(self, object: object, context: dict[int, int], maxlevels: int, level: int) -> tuple[str, bool, bool]: ... + def _safe_repr(self, object: object, context: dict[int, int], maxlevels: int, level: int) -> tuple[str, bool, bool]: ... diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index 696193d9dc16..d1bd18bbcd86 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,7 +1,7 @@ from _typeshed import StrOrBytesPath from collections.abc import Callable, Mapping -from typing import Any, TypeVar -from typing_extensions import ParamSpec, Self, TypeAlias +from typing import Any, TypeAlias, TypeVar +from typing_extensions import ParamSpec, Self __all__ = ["run", "runctx", "Profile"] diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index c1da2aea0fc5..5b22b579c02a 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -4,8 +4,8 @@ from collections.abc import Iterable from cProfile import Profile as _cProfile from dataclasses import dataclass from profile import Profile -from typing import IO, Any, Literal, overload -from typing_extensions import Self, TypeAlias +from typing import IO, Any, Literal, TypeAlias, overload +from typing_extensions import Self if sys.version_info >= (3, 11): from enum import StrEnum diff --git a/stdlib/pty.pyi b/stdlib/pty.pyi index d1c78f9e3dd6..2b7a605e50e0 100644 --- a/stdlib/pty.pyi +++ b/stdlib/pty.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Callable, Iterable -from typing import Final -from typing_extensions import TypeAlias, deprecated +from typing import Final, TypeAlias +from typing_extensions import deprecated if sys.platform != "win32": __all__ = ["openpty", "fork", "spawn"] diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index a84ba324718a..6a7e24f78125 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -5,8 +5,7 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_passwd(structseq[Any], tuple[str, str, int, int, str, str, str]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("pw_name", "pw_passwd", "pw_uid", "pw_gid", "pw_gecos", "pw_dir", "pw_shell") + __match_args__: Final = ("pw_name", "pw_passwd", "pw_uid", "pw_gid", "pw_gecos", "pw_dir", "pw_shell") @property def pw_name(self) -> str: ... diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 334ce79b5dd0..e0ee67c5e93f 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -1,5 +1,4 @@ import enum -import sys from typing import AnyStr __all__ = ["compile", "main", "PyCompileError", "PycInvalidationMode"] @@ -26,9 +25,4 @@ def compile( invalidation_mode: PycInvalidationMode | None = None, quiet: int = 0, ) -> AnyStr | None: ... - -if sys.version_info >= (3, 10): - def main() -> None: ... - -else: - def main(args: list[str] | None = None) -> int: ... +def main() -> None: ... diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index 504a5d5f115a..c950c7f82b0f 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Mapping, Sequence __all__ = ["readmodule", "readmodule_ex", "Class", "Function"] @@ -9,8 +8,7 @@ class _Object: file: int lineno: int - if sys.version_info >= (3, 10): - end_lineno: int | None + end_lineno: int | None parent: _Object | None @@ -18,34 +16,27 @@ class _Object: # avoid variance issues in the subclasses children: Mapping[str, _Object] - if sys.version_info >= (3, 10): - def __init__( - self, module: str, name: str, file: str, lineno: int, end_lineno: int | None, parent: _Object | None - ) -> None: ... - else: - def __init__(self, module: str, name: str, file: str, lineno: int, parent: _Object | None) -> None: ... + def __init__( + self, module: str, name: str, file: str, lineno: int, end_lineno: int | None, parent: _Object | None + ) -> None: ... class Function(_Object): - if sys.version_info >= (3, 10): - is_async: bool + is_async: bool parent: Function | Class | None children: dict[str, Class | Function] - if sys.version_info >= (3, 10): - def __init__( - self, - module: str, - name: str, - file: str, - lineno: int, - parent: Function | Class | None = None, - is_async: bool = False, - *, - end_lineno: int | None = None, - ) -> None: ... - else: - def __init__(self, module: str, name: str, file: str, lineno: int, parent: Function | Class | None = None) -> None: ... + def __init__( + self, + module: str, + name: str, + file: str, + lineno: int, + parent: Function | Class | None = None, + is_async: bool = False, + *, + end_lineno: int | None = None, + ) -> None: ... class Class(_Object): super: list[Class | str] | None @@ -53,22 +44,17 @@ class Class(_Object): parent: Class | None children: dict[str, Class | Function] - if sys.version_info >= (3, 10): - def __init__( - self, - module: str, - name: str, - super_: list[Class | str] | None, - file: str, - lineno: int, - parent: Class | None = None, - *, - end_lineno: int | None = None, - ) -> None: ... - else: - def __init__( - self, module: str, name: str, super: list[Class | str] | None, file: str, lineno: int, parent: Class | None = None - ) -> None: ... + def __init__( + self, + module: str, + name: str, + super_: list[Class | str] | None, + file: str, + lineno: int, + parent: Class | None = None, + *, + end_lineno: int | None = None, + ) -> None: ... def readmodule(module: str, path: Sequence[str] | None = None) -> dict[str, Class]: ... def readmodule_ex(module: str, path: Sequence[str] | None = None) -> dict[str, Class | Function | list[str]]: ... diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index f8129ac20ade..2d68b21466c2 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -5,8 +5,8 @@ from builtins import list as _list # "list" conflicts with method name from collections.abc import Callable, Container, Mapping, MutableMapping from reprlib import Repr from types import MethodType, ModuleType, TracebackType -from typing import IO, Any, AnyStr, Final, NoReturn, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeGuard, deprecated +from typing import IO, Any, AnyStr, Final, NoReturn, Protocol, TypeGuard, TypeVar, overload, type_check_only +from typing_extensions import deprecated __all__ = ["help"] diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index bc522d5f3c92..54e275ad0f9e 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,9 +1,8 @@ -import sys from _typeshed import ReadableBuffer, SupportsRead from collections.abc import Callable from pyexpat import errors as errors, model as model -from typing import Any, Final, final -from typing_extensions import CapsuleType, TypeAlias +from typing import Any, Final, TypeAlias, final +from typing_extensions import CapsuleType from xml.parsers.expat import ExpatError as ExpatError EXPAT_VERSION: Final[str] # undocumented @@ -30,11 +29,8 @@ class XMLParserType: def UseForeignDTD(self, flag: bool = True, /) -> None: ... def GetReparseDeferralEnabled(self) -> bool: ... def SetReparseDeferralEnabled(self, enabled: bool, /) -> None: ... - if sys.version_info >= (3, 10): - # Added in Python 3.10.20, 3.11.15, 3.12.3, 3.13.10, 3.14.1 - def SetAllocTrackerActivationThreshold(self, threshold: int, /) -> None: ... - def SetAllocTrackerMaximumAmplification(self, max_factor: float, /) -> None: ... - + def SetAllocTrackerActivationThreshold(self, threshold: int, /) -> None: ... + def SetAllocTrackerMaximumAmplification(self, max_factor: float, /) -> None: ... @property def intern(self) -> dict[str, str]: ... buffer_size: int diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 08619bf66351..e7911ceeab18 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -4,7 +4,7 @@ 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, TypeVar, overload -from typing_extensions import Self, deprecated +from typing_extensions import deprecated __all__ = [ "Random", @@ -45,9 +45,6 @@ class Random(_random.Random): # Using other `seed` types is deprecated since 3.9 and removed in 3.11 # Ignore Y041, since random.seed doesn't treat int like a float subtype. Having an explicit # int better documents conventional usage of random.seed. - if sys.version_info < (3, 10): - # this is a workaround for pyright correctly flagging an inconsistent inherited constructor, see #14624 - def __new__(cls, x: int | float | str | bytes | bytearray | None = None) -> Self: ... # noqa: Y041 def seed(self, a: int | float | str | bytes | bytearray | None = None, version: int = 2) -> None: ... # type: ignore[override] # noqa: Y041 def getstate(self) -> tuple[Any, ...]: ... diff --git a/stdlib/re.pyi b/stdlib/re.pyi index fb2a06d5e4c8..c83e411c8121 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -5,8 +5,8 @@ import sys from _typeshed import MaybeNone, ReadableBuffer from collections.abc import Callable, Iterator, Mapping from types import GenericAlias -from typing import Any, AnyStr, Final, Generic, Literal, TypeVar, final, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, AnyStr, Final, Generic, Literal, TypeAlias, TypeVar, final, overload +from typing_extensions import deprecated __all__ = [ "match", diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index 7325c267b32c..aff1e504a174 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -1,8 +1,7 @@ import sys from _typeshed import StrOrBytesPath from collections.abc import Callable, Sequence -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias if sys.platform != "win32": _Completer: TypeAlias = Callable[[str, int], str | None] diff --git a/stdlib/reprlib.pyi b/stdlib/reprlib.pyi index 68ada6569348..d990c2708ae9 100644 --- a/stdlib/reprlib.pyi +++ b/stdlib/reprlib.pyi @@ -2,8 +2,7 @@ import sys from array import array from collections import deque from collections.abc import Callable -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias __all__ = ["Repr", "repr", "recursive_repr"] diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index f99cd5b08805..6cd5db48a8c2 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -30,25 +30,24 @@ if sys.platform != "win32": class struct_rusage( structseq[float], tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int] ): - if sys.version_info >= (3, 10): - __match_args__: Final = ( - "ru_utime", - "ru_stime", - "ru_maxrss", - "ru_ixrss", - "ru_idrss", - "ru_isrss", - "ru_minflt", - "ru_majflt", - "ru_nswap", - "ru_inblock", - "ru_oublock", - "ru_msgsnd", - "ru_msgrcv", - "ru_nsignals", - "ru_nvcsw", - "ru_nivcsw", - ) + __match_args__: Final = ( + "ru_utime", + "ru_stime", + "ru_maxrss", + "ru_ixrss", + "ru_idrss", + "ru_isrss", + "ru_minflt", + "ru_majflt", + "ru_nswap", + "ru_inblock", + "ru_oublock", + "ru_msgsnd", + "ru_msgrcv", + "ru_nsignals", + "ru_nvcsw", + "ru_nivcsw", + ) @property def ru_utime(self) -> float: ... diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index 436d9984ee4d..24da5b43bd09 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,33 +1,18 @@ -import sys import time from collections.abc import Callable -from typing import Any, ClassVar, NamedTuple, type_check_only -from typing_extensions import TypeAlias +from typing import Any, NamedTuple, TypeAlias __all__ = ["scheduler"] _ActionCallback: TypeAlias = Callable[..., Any] -if sys.version_info >= (3, 10): - class Event(NamedTuple): - time: float - priority: Any - sequence: int - action: _ActionCallback - argument: tuple[Any, ...] - kwargs: dict[str, Any] - -else: - @type_check_only - class _EventBase(NamedTuple): - time: float - priority: Any - action: _ActionCallback - argument: tuple[Any, ...] - kwargs: dict[str, Any] - - class Event(_EventBase): - __hash__: ClassVar[None] # type: ignore[assignment] +class Event(NamedTuple): + time: float + priority: Any + sequence: int + action: _ActionCallback + argument: tuple[Any, ...] + kwargs: dict[str, Any] # type: ignore[assignment] class scheduler: timefunc: Callable[[], float] diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index bcca4e341b9a..68822c50ece8 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import FileDescriptor, FileDescriptorLike, Unused from abc import ABCMeta, abstractmethod from collections.abc import Mapping -from typing import Any, Final, NamedTuple -from typing_extensions import Self, TypeAlias +from typing import Any, Final, NamedTuple, TypeAlias +from typing_extensions import Self _EventMask: TypeAlias = int diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index cc26cfc556a0..54e7bdc58bfa 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -3,8 +3,8 @@ import sys from _typeshed import BytesPath, ExcInfo, FileDescriptorOrPath, MaybeNone, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite from collections.abc import Callable, Iterable, Sequence from tarfile import _TarfileFilter -from typing import Any, AnyStr, NamedTuple, NoReturn, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias, deprecated +from typing import Any, AnyStr, NamedTuple, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import deprecated __all__ = [ "copyfileobj", diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index c2668bd8b32d..2aafb6630b0b 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -3,8 +3,8 @@ from _typeshed import structseq from collections.abc import Callable, Iterable from enum import IntEnum from types import FrameType -from typing import Any, Final, final -from typing_extensions import Never, TypeAlias +from typing import Any, Final, TypeAlias, final +from typing_extensions import Never NSIG: int @@ -68,14 +68,8 @@ _SIGNUM: TypeAlias = int | Signals _HANDLER: TypeAlias = Callable[[int, FrameType | None], Any] | int | Handlers | None def default_int_handler(signalnum: int, frame: FrameType | None, /) -> Never: ... - -if sys.version_info >= (3, 10): # arguments changed in 3.10.2 - def getsignal(signalnum: _SIGNUM) -> _HANDLER: ... - def signal(signalnum: _SIGNUM, handler: _HANDLER) -> _HANDLER: ... - -else: - def getsignal(signalnum: _SIGNUM, /) -> _HANDLER: ... - def signal(signalnum: _SIGNUM, handler: _HANDLER, /) -> _HANDLER: ... +def getsignal(signalnum: _SIGNUM) -> _HANDLER: ... +def signal(signalnum: _SIGNUM, handler: _HANDLER) -> _HANDLER: ... SIGABRT: Final = Signals.SIGABRT SIGFPE: Final = Signals.SIGFPE @@ -134,18 +128,11 @@ else: def getitimer(which: int, /) -> tuple[float, float]: ... def pause() -> None: ... def pthread_kill(thread_id: int, signalnum: int, /) -> None: ... - if sys.version_info >= (3, 10): # arguments changed in 3.10.2 - def pthread_sigmask(how: int, mask: Iterable[int]) -> set[_SIGNUM]: ... - else: - def pthread_sigmask(how: int, mask: Iterable[int], /) -> set[_SIGNUM]: ... - + def pthread_sigmask(how: int, mask: Iterable[int]) -> set[_SIGNUM]: ... def setitimer(which: int, seconds: float, interval: float = 0.0, /) -> tuple[float, float]: ... def siginterrupt(signalnum: int, flag: bool, /) -> None: ... def sigpending() -> Any: ... - if sys.version_info >= (3, 10): # argument changed in 3.10.2 - def sigwait(sigset: Iterable[int]) -> _SIGNUM: ... - else: - def sigwait(sigset: Iterable[int], /) -> _SIGNUM: ... + def sigwait(sigset: Iterable[int]) -> _SIGNUM: ... if sys.platform != "darwin": SIGCLD: Final = Signals.SIGCHLD # alias SIGPOLL: Final = Signals.SIGIO # alias @@ -157,8 +144,7 @@ else: @final class struct_siginfo(structseq[int], tuple[int, int, int, int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("si_signo", "si_code", "si_errno", "si_pid", "si_uid", "si_status", "si_band") + __match_args__: Final = ("si_signo", "si_code", "si_errno", "si_pid", "si_uid", "si_status", "si_band") @property def si_signo(self) -> int: ... diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index dee7e949f42f..cc9ac391a441 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -3,8 +3,8 @@ import asyncore import socket import sys from collections import defaultdict -from typing import Any -from typing_extensions import TypeAlias, deprecated +from typing import Any, TypeAlias +from typing_extensions import deprecated if sys.version_info >= (3, 11): __all__ = ["SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy"] diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 74b5ea2cb6fc..0567a7a05b8a 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -7,8 +7,8 @@ from re import Pattern from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Final, Protocol, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, Final, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import Self, deprecated __all__ = [ "SMTPException", diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 36a335e13d02..06ed67271aab 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -357,10 +357,9 @@ if sys.platform != "darwin": __all__ += ["TCP_KEEPIDLE", "AF_IRDA", "MSG_ERRQUEUE"] -if sys.version_info >= (3, 10): - from _socket import IP_RECVTOS as IP_RECVTOS +from _socket import IP_RECVTOS as IP_RECVTOS - __all__ += ["IP_RECVTOS"] +__all__ += ["IP_RECVTOS"] if sys.platform != "win32" and sys.platform != "darwin": from _socket import ( @@ -1087,10 +1086,7 @@ error = OSError class herror(error): ... class gaierror(error): ... -if sys.version_info >= (3, 10): - timeout = TimeoutError -else: - class timeout(error): ... +timeout = TimeoutError class AddressFamily(IntEnum): AF_INET = 2 diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index f321d14a792b..05e0025d6a15 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -5,8 +5,8 @@ from _typeshed import ReadableBuffer from collections.abc import Callable from io import BufferedIOBase from socket import socket as _socket -from typing import Any, ClassVar -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, TypeAlias +from typing_extensions import Self __all__ = [ "BaseServer", diff --git a/stdlib/spwd.pyi b/stdlib/spwd.pyi index 3a5d39997dcc..0a06cdfeef64 100644 --- a/stdlib/spwd.pyi +++ b/stdlib/spwd.pyi @@ -5,18 +5,17 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_spwd(structseq[Any], tuple[str, str, int, int, int, int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ( - "sp_namp", - "sp_pwdp", - "sp_lstchg", - "sp_min", - "sp_max", - "sp_warn", - "sp_inact", - "sp_expire", - "sp_flag", - ) + __match_args__: Final = ( + "sp_namp", + "sp_pwdp", + "sp_lstchg", + "sp_min", + "sp_max", + "sp_warn", + "sp_inact", + "sp_expire", + "sp_flag", + ) @property def sp_namp(self) -> str: ... diff --git a/stdlib/sqlite3/__init__.pyi b/stdlib/sqlite3/__init__.pyi index 56bccb56d63a..353cd8ea556f 100644 --- a/stdlib/sqlite3/__init__.pyi +++ b/stdlib/sqlite3/__init__.pyi @@ -62,8 +62,8 @@ from sqlite3.dbapi2 import ( threadsafety as threadsafety, ) from types import TracebackType -from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Literal, Protocol, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only +from typing_extensions import Self, disjoint_base if sys.version_info < (3, 14): from sqlite3.dbapi2 import version_info as version_info @@ -211,9 +211,6 @@ if sys.version_info >= (3, 11): if sys.version_info < (3, 12): from sqlite3.dbapi2 import enable_shared_cache as enable_shared_cache, version as version -if sys.version_info < (3, 10): - from sqlite3.dbapi2 import OptimizedUnicode as OptimizedUnicode - _CursorT = TypeVar("_CursorT", bound=Cursor) _SqliteData: TypeAlias = str | ReadableBuffer | int | float | None # Data that is passed through adapters can be of any type accepted by an adapter. diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 9e170a81243d..bd7facfdd0cb 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -215,18 +215,11 @@ if sys.version_info < (3, 14): version: Final[str] if sys.version_info < (3, 12): - if sys.version_info >= (3, 10): - # deprecation wrapper that has a different name for the argument... - @deprecated( - "Deprecated since Python 3.10; removed in Python 3.12. " - "Open database in URI mode using `cache=shared` parameter instead." - ) - def enable_shared_cache(enable: int) -> None: ... - else: - from _sqlite3 import enable_shared_cache as enable_shared_cache - -if sys.version_info < (3, 10): - from _sqlite3 import OptimizedUnicode as OptimizedUnicode + @deprecated( + "Deprecated since Python 3.10; removed in Python 3.12. " + "Open database in URI mode using `cache=shared` parameter instead." + ) + def enable_shared_cache(enable: int) -> None: ... paramstyle: Final = "qmark" threadsafety: Literal[0, 1, 3] diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index eaacbff312a9..88e2d1ee0e4c 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -3,8 +3,7 @@ from collections.abc import Iterable from re import Match, Pattern as _Pattern from sre_constants import * from sre_constants import _NamedIntConstant as _NIC, error as _Error -from typing import Any, Final, overload -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias, overload SPECIAL_CHARS: Final = ".\\[{()*+?^$|" REPEAT_CHARS: Final = "*+?{" diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 2053005f1ba6..d60232a1d72e 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -27,8 +27,8 @@ from _ssl import ( ) from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from collections.abc import Callable, Iterable -from typing import Any, Final, Literal, NamedTuple, TypedDict, overload, type_check_only -from typing_extensions import Never, Self, TypeAlias, deprecated +from typing import Any, Final, Literal, NamedTuple, TypeAlias, TypedDict, overload, type_check_only +from typing_extensions import Never, Self, deprecated if sys.version_info >= (3, 13): from _ssl import HAS_PSK as HAS_PSK @@ -39,9 +39,6 @@ if sys.version_info >= (3, 14): if sys.version_info < (3, 12): from _ssl import RAND_pseudo_bytes as RAND_pseudo_bytes -if sys.version_info < (3, 10): - from _ssl import RAND_egd as RAND_egd - if sys.platform == "win32": from _ssl import enum_certificates as enum_certificates, enum_crls as enum_crls @@ -108,9 +105,8 @@ class VerifyFlags(enum.IntFlag): VERIFY_CRL_CHECK_CHAIN = 12 VERIFY_X509_STRICT = 32 VERIFY_X509_TRUSTED_FIRST = 32768 - if sys.version_info >= (3, 10): - VERIFY_ALLOW_PROXY_CERTS = 64 - VERIFY_X509_PARTIAL_CHAIN = 524288 + VERIFY_ALLOW_PROXY_CERTS = 64 + VERIFY_X509_PARTIAL_CHAIN = 524288 VERIFY_DEFAULT: Final = VerifyFlags.VERIFY_DEFAULT VERIFY_CRL_CHECK_LEAF: Final = VerifyFlags.VERIFY_CRL_CHECK_LEAF @@ -118,9 +114,8 @@ VERIFY_CRL_CHECK_CHAIN: Final = VerifyFlags.VERIFY_CRL_CHECK_CHAIN VERIFY_X509_STRICT: Final = VerifyFlags.VERIFY_X509_STRICT VERIFY_X509_TRUSTED_FIRST: Final = VerifyFlags.VERIFY_X509_TRUSTED_FIRST -if sys.version_info >= (3, 10): - VERIFY_ALLOW_PROXY_CERTS: Final = VerifyFlags.VERIFY_ALLOW_PROXY_CERTS - VERIFY_X509_PARTIAL_CHAIN: Final = VerifyFlags.VERIFY_X509_PARTIAL_CHAIN +VERIFY_ALLOW_PROXY_CERTS: Final = VerifyFlags.VERIFY_ALLOW_PROXY_CERTS +VERIFY_X509_PARTIAL_CHAIN: Final = VerifyFlags.VERIFY_X509_PARTIAL_CHAIN class _SSLMethod(enum.IntEnum): PROTOCOL_SSLv23 = 2 @@ -307,12 +302,8 @@ class SSLSocket(socket.socket): def compression(self) -> str | None: ... def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ... def selected_alpn_protocol(self) -> str | None: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def selected_npn_protocol(self) -> str | None: ... - else: - def selected_npn_protocol(self) -> str | None: ... - + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def selected_npn_protocol(self) -> str | None: ... def accept(self) -> tuple[SSLSocket, socket._RetAddress]: ... def unwrap(self) -> socket.socket: ... def version(self) -> str | None: ... @@ -346,19 +337,9 @@ if sys.version_info < (3, 12): def cert_time_to_seconds(cert_time: str) -> int: ... def DER_cert_to_PEM_cert(der_cert_bytes: ReadableBuffer) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... - -if sys.version_info >= (3, 10): - def get_server_certificate( - addr: tuple[str, int], - ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, - ca_certs: str | None = None, - timeout: float = ..., - ) -> str: ... - -else: - def get_server_certificate( - addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None - ) -> str: ... +def get_server_certificate( + addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None, timeout: float = ... +) -> str: ... class TLSVersion(enum.IntEnum): MINIMUM_SUPPORTED = -2 @@ -385,17 +366,12 @@ class SSLContext(_SSLContext): sslsocket_class: type[SSLSocket] keylog_filename: str post_handshake_auth: bool - if sys.version_info >= (3, 10): - security_level: int - if sys.version_info >= (3, 10): - @overload - def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ... - @overload - @deprecated("Deprecated since Python 3.10. Use a specific version of the SSL protocol.") - def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ... - else: - def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ... - + security_level: int + @overload + def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ... + @overload + @deprecated("Deprecated since Python 3.10. Use a specific version of the SSL protocol.") + def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ... def load_default_certs(self, purpose: Purpose = Purpose.SERVER_AUTH) -> None: ... def load_verify_locations( self, @@ -413,12 +389,8 @@ class SSLContext(_SSLContext): def set_default_verify_paths(self) -> None: ... def set_ciphers(self, cipherlist: str, /) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - else: - def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... def set_servername_callback(self, server_name_callback: _SrvnmeCbType | None) -> None: ... def load_dh_params(self, path: str, /) -> None: ... def set_ecdh_curve(self, name: str, /) -> None: ... @@ -447,34 +419,18 @@ def create_default_context( capath: StrOrBytesPath | None = None, cadata: str | ReadableBuffer | None = None, ) -> SSLContext: ... - -if sys.version_info >= (3, 10): - def _create_unverified_context( - protocol: int | None = None, - *, - cert_reqs: int = VerifyMode.CERT_NONE, - check_hostname: bool = False, - purpose: Purpose = Purpose.SERVER_AUTH, - certfile: StrOrBytesPath | None = None, - keyfile: StrOrBytesPath | None = None, - cafile: StrOrBytesPath | None = None, - capath: StrOrBytesPath | None = None, - cadata: str | ReadableBuffer | None = None, - ) -> SSLContext: ... - -else: - def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: int = VerifyMode.CERT_NONE, - check_hostname: bool = False, - purpose: Purpose = Purpose.SERVER_AUTH, - certfile: StrOrBytesPath | None = None, - keyfile: StrOrBytesPath | None = None, - cafile: StrOrBytesPath | None = None, - capath: StrOrBytesPath | None = None, - cadata: str | ReadableBuffer | None = None, - ) -> SSLContext: ... +def _create_unverified_context( + protocol: int | None = None, + *, + cert_reqs: int = VerifyMode.CERT_NONE, + check_hostname: bool = False, + purpose: Purpose = Purpose.SERVER_AUTH, + certfile: StrOrBytesPath | None = None, + keyfile: StrOrBytesPath | None = None, + cafile: StrOrBytesPath | None = None, + capath: StrOrBytesPath | None = None, + cadata: str | ReadableBuffer | None = None, +) -> SSLContext: ... _create_default_https_context = create_default_context @@ -497,12 +453,8 @@ class SSLObject: @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... def selected_alpn_protocol(self) -> str | None: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def selected_npn_protocol(self) -> str | None: ... - else: - def selected_npn_protocol(self) -> str | None: ... - + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def selected_npn_protocol(self) -> str | None: ... def cipher(self) -> tuple[str, str, int] | None: ... def shared_ciphers(self) -> list[tuple[str, str, int]] | None: ... def compression(self) -> str | None: ... diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 188bed3375bf..c0f4fb80f2c8 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -3,8 +3,8 @@ from _typeshed import SupportsRichComparisonT from collections.abc import Callable, Hashable, Iterable, Sequence, Sized from decimal import Decimal from fractions import Fraction -from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeVar -from typing_extensions import Self, TypeAlias +from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeAlias, TypeVar +from typing_extensions import Self __all__ = [ "StatisticsError", @@ -26,8 +26,7 @@ __all__ = [ "quantiles", ] -if sys.version_info >= (3, 10): - __all__ += ["covariance", "correlation", "linear_regression"] +__all__ += ["covariance", "correlation", "linear_regression"] if sys.version_info >= (3, 13): __all__ += ["kde", "kde_random"] @@ -55,13 +54,7 @@ else: def geometric_mean(data: Iterable[SupportsFloat]) -> float: ... def mean(data: Iterable[_NumberT]) -> _NumberT: ... - -if sys.version_info >= (3, 10): - def harmonic_mean(data: Iterable[_NumberT], weights: Iterable[_Number] | None = None) -> _NumberT: ... - -else: - def harmonic_mean(data: Iterable[_NumberT]) -> _NumberT: ... - +def harmonic_mean(data: Iterable[_NumberT], weights: Iterable[_Number] | None = None) -> _NumberT: ... def median(data: Iterable[_NumberT]) -> _NumberT: ... def median_low(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ... def median_high(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ... @@ -121,22 +114,21 @@ if sys.version_info >= (3, 12): x: Sequence[_Number], y: Sequence[_Number], /, *, method: Literal["linear", "ranked"] = "linear" ) -> float: ... -elif sys.version_info >= (3, 10): +else: def correlation(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... -if sys.version_info >= (3, 10): - def covariance(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... +def covariance(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... - class LinearRegression(NamedTuple): - slope: float - intercept: float +class LinearRegression(NamedTuple): + slope: float + intercept: float if sys.version_info >= (3, 11): def linear_regression( regressor: _SizedIterable[_Number], dependent_variable: _SizedIterable[_Number], /, *, proportional: bool = False ) -> LinearRegression: ... -elif sys.version_info >= (3, 10): +else: def linear_regression( regressor: _SizedIterable[_Number], dependent_variable: _SizedIterable[_Number], / ) -> LinearRegression: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index f6d7b88193ec..474d32483ce2 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath from collections.abc import Callable, Collection, Iterable, Mapping, Sequence from types import GenericAlias, TracebackType -from typing import IO, Any, AnyStr, Final, Generic, Literal, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import IO, Any, AnyStr, Final, Generic, Literal, TypeAlias, TypeVar, overload +from typing_extensions import Self __all__ = [ "Popen", @@ -294,7 +294,7 @@ if sys.version_info >= (3, 11): process_group: int | None = None, ) -> CompletedProcess[Any]: ... -elif sys.version_info >= (3, 10): +else: # 3.10 adds "pipesize" argument @overload def run( @@ -496,457 +496,15 @@ elif sys.version_info >= (3, 10): pipesize: int = -1, ) -> CompletedProcess[Any]: ... -else: - @overload - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: str | None = None, - errors: str | None = None, - input: str | None = None, - text: Literal[True], - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[str]: ... - @overload - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: str, - errors: str | None = None, - input: str | None = None, - text: bool | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[str]: ... - @overload - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: str | None = None, - errors: str, - input: str | None = None, - text: bool | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[str]: ... - @overload - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - *, - universal_newlines: Literal[True], - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - # where the *real* keyword only args start - capture_output: bool = False, - check: bool = False, - encoding: str | None = None, - errors: str | None = None, - input: str | None = None, - text: bool | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[str]: ... - @overload - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: Literal[False] | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: None = None, - errors: None = None, - input: ReadableBuffer | None = None, - text: Literal[False] | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[bytes]: ... - @overload - def run( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - capture_output: bool = False, - check: bool = False, - encoding: str | None = None, - errors: str | None = None, - input: _InputString | None = None, - text: bool | None = None, - timeout: float | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> CompletedProcess[Any]: ... - # Same args as Popen.__init__ -if sys.version_info >= (3, 11): - # 3.11 adds "process_group" argument - def call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - encoding: str | None = None, - timeout: float | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - process_group: int | None = None, - ) -> int: ... - -elif sys.version_info >= (3, 10): - # 3.10 adds "pipesize" argument - def call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - encoding: str | None = None, - timeout: float | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - ) -> int: ... - -else: - def call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - encoding: str | None = None, - timeout: float | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> int: ... - -# Same args as Popen.__init__ -if sys.version_info >= (3, 11): - # 3.11 adds "process_group" argument - def check_call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - timeout: float | None = None, - *, - encoding: str | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - process_group: int | None = None, - ) -> int: ... - -elif sys.version_info >= (3, 10): - # 3.10 adds "pipesize" argument - def check_call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - timeout: float | None = None, - *, - encoding: str | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - ) -> int: ... - -else: - def check_call( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stdout: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - timeout: float | None = None, - *, - encoding: str | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> int: ... - -if sys.version_info >= (3, 11): - # 3.11 adds "process_group" argument - @overload - def check_output( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - timeout: float | None = None, - input: _InputString | None = None, - encoding: str | None = None, - errors: str | None = None, - text: Literal[True], - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - process_group: int | None = None, - ) -> str: ... - @overload - def check_output( - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE = None, - stderr: _FILE = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - timeout: float | None = None, - input: _InputString | None = None, - encoding: str, - errors: str | None = None, - text: bool | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - process_group: int | None = None, - ) -> str: ... - @overload - def check_output( +if sys.version_info >= (3, 11): + # 3.11 adds "process_group" argument + def call( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, + stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, @@ -960,10 +518,8 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), *, - timeout: float | None = None, - input: _InputString | None = None, encoding: str | None = None, - errors: str, + timeout: float | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, @@ -971,76 +527,80 @@ if sys.version_info >= (3, 11): umask: int = -1, pipesize: int = -1, process_group: int | None = None, - ) -> str: ... - @overload - def check_output( + ) -> int: ... + +else: + # 3.10 adds "pipesize" argument + def call( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, + stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - *, - universal_newlines: Literal[True], + universal_newlines: bool | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - # where the real keyword only ones start - timeout: float | None = None, - input: _InputString | None = None, + *, encoding: str | None = None, - errors: str | None = None, + timeout: float | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, - ) -> str: ... - @overload - def check_output( + ) -> int: ... + +# Same args as Popen.__init__ +if sys.version_info >= (3, 11): + # 3.11 adds "process_group" argument + def check_call( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, + stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False] | None = None, + universal_newlines: bool | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - *, timeout: float | None = None, - input: _InputString | None = None, - encoding: None = None, - errors: None = None, - text: Literal[False] | None = None, + *, + encoding: str | None = None, + text: bool | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, process_group: int | None = None, - ) -> bytes: ... - @overload - def check_output( + ) -> int: ... + +else: + # 3.10 adds "pipesize" argument + def check_call( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, + stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, @@ -1053,22 +613,19 @@ if sys.version_info >= (3, 11): restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - *, timeout: float | None = None, - input: _InputString | None = None, + *, encoding: str | None = None, - errors: str | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, - ) -> Any: ... # morally: -> str | bytes + ) -> int: ... -elif sys.version_info >= (3, 10): - # 3.10 adds "pipesize" argument +if sys.version_info >= (3, 11): + # 3.11 adds "process_group" argument @overload def check_output( args: _CMD, @@ -1098,6 +655,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> str: ... @overload def check_output( @@ -1128,6 +686,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> str: ... @overload def check_output( @@ -1158,6 +717,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> str: ... @overload def check_output( @@ -1189,6 +749,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> str: ... @overload def check_output( @@ -1219,6 +780,7 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> bytes: ... @overload def check_output( @@ -1249,9 +811,11 @@ elif sys.version_info >= (3, 10): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, + process_group: int | None = None, ) -> Any: ... # morally: -> str | bytes else: + # 3.10 adds "pipesize" argument @overload def check_output( args: _CMD, @@ -1280,6 +844,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> str: ... @overload def check_output( @@ -1309,6 +874,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> str: ... @overload def check_output( @@ -1338,6 +904,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> str: ... @overload def check_output( @@ -1368,6 +935,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> str: ... @overload def check_output( @@ -1397,6 +965,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> bytes: ... @overload def check_output( @@ -1426,6 +995,7 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> Any: ... # morally: -> str | bytes PIPE: Final[int] @@ -1658,7 +1228,7 @@ class Popen(Generic[AnyStr]): pipesize: int = -1, process_group: int | None = None, ) -> None: ... - elif sys.version_info >= (3, 10): + else: # pipesize is added in 3.10 @overload def __init__( @@ -1841,182 +1411,6 @@ class Popen(Generic[AnyStr]): umask: int = -1, pipesize: int = -1, ) -> None: ... - else: - @overload - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: bool | None = None, - encoding: str, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: bool | None = None, - encoding: str | None = None, - errors: str, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - *, - universal_newlines: Literal[True], - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - # where the *real* keyword only args start - text: bool | None = None, - encoding: str | None = None, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: Literal[True], - encoding: str | None = None, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload - def __init__( - self: Popen[bytes], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: Literal[False] | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: Literal[False] | None = None, - encoding: None = None, - errors: None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... - @overload - def __init__( - self: Popen[Any], - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: bool | None = None, - encoding: str | None = None, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - ) -> None: ... def poll(self) -> int | None: ... def wait(self, timeout: float | None = None) -> int: ... diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index f83a0a4c520e..1f18c041465e 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,6 +1,6 @@ from _typeshed import Unused -from typing import IO, Any, Final, Literal, NamedTuple, NoReturn, overload -from typing_extensions import Self, TypeAlias +from typing import IO, Any, Final, Literal, NamedTuple, NoReturn, TypeAlias, overload +from typing_extensions import Self _File: TypeAlias = str | IO[bytes] diff --git a/stdlib/sys/__init__.pyi b/stdlib/sys/__init__.pyi index 6abef85dfb7f..734adae57184 100644 --- a/stdlib/sys/__init__.pyi +++ b/stdlib/sys/__init__.pyi @@ -5,8 +5,8 @@ from builtins import object as _object from collections.abc import AsyncGenerator, Callable, Sequence from io import TextIOWrapper from types import FrameType, ModuleType, TracebackType -from typing import Any, Final, Literal, NoReturn, Protocol, TextIO, TypeVar, final, overload, type_check_only -from typing_extensions import LiteralString, TypeAlias, deprecated +from typing import Any, Final, Literal, NoReturn, Protocol, TextIO, TypeAlias, TypeVar, final, overload, type_check_only +from typing_extensions import LiteralString, deprecated _T = TypeVar("_T") @@ -40,8 +40,7 @@ maxsize: int maxunicode: int meta_path: list[MetaPathFinderProtocol] modules: dict[str, ModuleType] -if sys.version_info >= (3, 10): - orig_argv: list[str] +orig_argv: list[str] path: list[str] path_hooks: list[Callable[[str], PathEntryFinderProtocol]] path_importer_cache: dict[str, PathEntryFinderProtocol | None] @@ -66,8 +65,7 @@ stdin: TextIO | MaybeNone stdout: TextIO | MaybeNone stderr: TextIO | MaybeNone -if sys.version_info >= (3, 10): - stdlib_module_names: frozenset[str] +stdlib_module_names: frozenset[str] __stdin__: Final[TextIOWrapper | None] # Contains the original value of stdin __stdout__: Final[TextIOWrapper | None] # Contains the original value of stdout @@ -124,7 +122,7 @@ class _flags(_UninstantiableStructseq, tuple[int, ...]): "safe_path", "int_max_str_digits", ) - elif sys.version_info >= (3, 10): + else: __match_args__: Final = ( "debug", "inspect", @@ -175,9 +173,8 @@ class _flags(_UninstantiableStructseq, tuple[int, ...]): def dev_mode(self) -> bool: ... @property def utf8_mode(self) -> int: ... - if sys.version_info >= (3, 10): - @property - def warn_default_encoding(self) -> int: ... + @property + def warn_default_encoding(self) -> int: ... if sys.version_info >= (3, 11): @property def safe_path(self) -> bool: ... @@ -203,20 +200,19 @@ float_info: _float_info @final @type_check_only class _float_info(structseq[float], tuple[float, int, int, float, int, int, int, int, float, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ( - "max", - "max_exp", - "max_10_exp", - "min", - "min_exp", - "min_10_exp", - "dig", - "mant_dig", - "epsilon", - "radix", - "rounds", - ) + __match_args__: Final = ( + "max", + "max_exp", + "max_10_exp", + "min", + "min_exp", + "min_10_exp", + "dig", + "mant_dig", + "epsilon", + "radix", + "rounds", + ) @property def max(self) -> float: ... # DBL_MAX @@ -247,8 +243,7 @@ hash_info: _hash_info @final @type_check_only class _hash_info(structseq[Any | int], tuple[int, int, int, int, int, str, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("width", "modulus", "inf", "nan", "imag", "algorithm", "hash_bits", "seed_bits", "cutoff") + __match_args__: Final = ("width", "modulus", "inf", "nan", "imag", "algorithm", "hash_bits", "seed_bits", "cutoff") @property def width(self) -> int: ... @@ -290,8 +285,7 @@ int_info: _int_info @final @type_check_only class _int_info(structseq[int], tuple[int, int, int, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("bits_per_digit", "sizeof_digit", "default_max_str_digits", "str_digits_check_threshold") + __match_args__: Final = ("bits_per_digit", "sizeof_digit", "default_max_str_digits", "str_digits_check_threshold") @property def bits_per_digit(self) -> int: ... @@ -309,8 +303,7 @@ _ThreadInfoLock: TypeAlias = Literal["semaphore", "mutex+cond"] | None @final @type_check_only class _thread_info(_UninstantiableStructseq, tuple[_ThreadInfoName, _ThreadInfoLock, str | None]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("name", "lock", "version") + __match_args__: Final = ("name", "lock", "version") @property def name(self) -> _ThreadInfoName: ... @@ -326,8 +319,7 @@ _ReleaseLevel: TypeAlias = Literal["alpha", "beta", "candidate", "final"] @final @type_check_only class _version_info(_UninstantiableStructseq, tuple[int, int, int, _ReleaseLevel, int]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("major", "minor", "micro", "releaselevel", "serial") + __match_args__: Final = ("major", "minor", "micro", "releaselevel", "serial") @property def major(self) -> int: ... @@ -467,8 +459,7 @@ _AsyncgenHook: TypeAlias = Callable[[AsyncGenerator[Any, Any]], None] | None @final @type_check_only class _asyncgen_hooks(structseq[_AsyncgenHook], tuple[_AsyncgenHook, _AsyncgenHook]): - if sys.version_info >= (3, 10): - __match_args__: Final = ("firstiter", "finalizer") + __match_args__: Final = ("firstiter", "finalizer") @property def firstiter(self) -> _AsyncgenHook: ... diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index 8de7ddc4255f..19268ebb33fc 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -26,13 +26,11 @@ 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_default_scheme() -> LiteralString: ... +def get_preferred_scheme(key: Literal["prefix", "home", "user"]) -> LiteralString: ... -if sys.version_info >= (3, 10): - def get_default_scheme() -> LiteralString: ... - def get_preferred_scheme(key: Literal["prefix", "home", "user"]) -> LiteralString: ... - # Documented -- see https://docs.python.org/3/library/sysconfig.html#sysconfig._get_preferred_schemes - def _get_preferred_schemes() -> dict[Literal["prefix", "home", "user"], LiteralString]: ... - +# Documented -- see https://docs.python.org/3/library/sysconfig.html#sysconfig._get_preferred_schemes +def _get_preferred_schemes() -> dict[Literal["prefix", "home", "user"], LiteralString]: ... def get_path_names() -> tuple[str, ...]: ... def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = None, expand: bool = True) -> str: ... def get_paths(scheme: str = ..., vars: dict[str, Any] | None = None, expand: bool = True) -> dict[str, str]: ... diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 6e68c370f3aa..91da5ab4f5b4 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -6,8 +6,8 @@ from builtins import list as _list # aliases to avoid name clashes with fields 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, ClassVar, Final, Literal, Protocol, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import IO, ClassVar, Final, Literal, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import Self, deprecated if sys.version_info >= (3, 14): from compression.zstd import ZstdDict diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 26491074ff71..1e8e8679add5 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -421,7 +421,7 @@ class TemporaryDirectory(Generic[AnyStr]): *, delete: bool = True, ) -> None: ... - elif sys.version_info >= (3, 10): + else: @overload def __init__( self: TemporaryDirectory[str], @@ -438,18 +438,6 @@ class TemporaryDirectory(Generic[AnyStr]): dir: BytesPath | None = None, ignore_cleanup_errors: bool = False, ) -> None: ... - else: - @overload - def __init__( - self: TemporaryDirectory[str], suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None - ) -> None: ... - @overload - def __init__( - self: TemporaryDirectory[bytes], - suffix: bytes | None = None, - prefix: bytes | None = None, - dir: BytesPath | None = None, - ) -> None: ... def cleanup(self) -> None: ... def __enter__(self) -> AnyStr: ... diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index a35be5dfe740..971c9ad46bf4 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -1,7 +1,6 @@ import sys from _typeshed import FileDescriptorLike -from typing import Any, Final -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias # Must be a list of length 7, containing 6 ints and a list of NCCS 1-character bytes or ints. _Attr: TypeAlias = list[int | list[bytes | int]] | list[int | list[bytes]] | list[int | list[int]] diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index abc7fe7e8124..b806ce0ae084 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -37,8 +37,7 @@ __all__ = [ "get_native_id", ] -if sys.version_info >= (3, 10): - __all__ += ["getprofile", "gettrace"] +__all__ += ["getprofile", "gettrace"] if sys.version_info >= (3, 12): __all__ += ["setprofile_all_threads", "settrace_all_threads"] @@ -61,10 +60,8 @@ if sys.version_info >= (3, 12): def setprofile_all_threads(func: ProfileFunction | None) -> None: ... def settrace_all_threads(func: TraceFunction | None) -> None: ... -if sys.version_info >= (3, 10): - def gettrace() -> TraceFunction | None: ... - def getprofile() -> ProfileFunction | None: ... - +def gettrace() -> TraceFunction | None: ... +def getprofile() -> ProfileFunction | None: ... def stack_size(size: int = 0, /) -> int: ... TIMEOUT_MAX: Final[float] @@ -173,8 +170,7 @@ class Event: def wait(self, timeout: float | None = None) -> bool: ... excepthook: Callable[[_ExceptHookArgs], object] -if sys.version_info >= (3, 10): - __excepthook__: Callable[[_ExceptHookArgs], object] +__excepthook__: Callable[[_ExceptHookArgs], object] ExceptHookArgs = _ExceptHookArgs class Timer(Thread): diff --git a/stdlib/time.pyi b/stdlib/time.pyi index 64a009318894..ac53089b8d82 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -1,7 +1,6 @@ import sys from _typeshed import structseq -from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, final, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, final, type_check_only _TimeTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int] @@ -47,8 +46,7 @@ if sys.platform == "linux": # https://github.com/python/typeshed/pull/6560#discussion_r767162532 @final class struct_time(structseq[Any | int], _TimeTuple): - if sys.version_info >= (3, 10): - __match_args__: Final = ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst") + __match_args__: Final = ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst") @property def tm_year(self) -> int: ... diff --git a/stdlib/timeit.pyi b/stdlib/timeit.pyi index 61935815f68b..9ce00952c882 100644 --- a/stdlib/timeit.pyi +++ b/stdlib/timeit.pyi @@ -1,7 +1,6 @@ import time from collections.abc import Callable, Sequence -from typing import IO, Any -from typing_extensions import TypeAlias +from typing import IO, Any, TypeAlias __all__ = ["Timer", "timeit", "repeat", "default_timer"] diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 90225a8a3652..265d6bb98794 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -5,8 +5,21 @@ from collections.abc import Callable, Iterable, Mapping, Sequence from tkinter.constants import * from tkinter.font import _FontDescription from types import GenericAlias, TracebackType -from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, Protocol, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias, TypeVarTuple, Unpack, deprecated, disjoint_base +from typing import ( + Any, + ClassVar, + Final, + Generic, + Literal, + NamedTuple, + Protocol, + TypeAlias, + TypedDict, + TypeVar, + overload, + type_check_only, +) +from typing_extensions import TypeVarTuple, Unpack, deprecated, disjoint_base if sys.version_info >= (3, 11): from enum import StrEnum diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index 327ba7a2432e..5d660c56fe50 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,9 +1,8 @@ import _tkinter import itertools -import sys import tkinter -from typing import Any, ClassVar, Final, Literal, TypedDict, overload, type_check_only -from typing_extensions import TypeAlias, Unpack +from typing import Any, ClassVar, Final, Literal, TypeAlias, TypedDict, overload, type_check_only +from typing_extensions import Unpack __all__ = ["NORMAL", "ROMAN", "BOLD", "ITALIC", "nametofont", "Font", "families", "names"] @@ -112,9 +111,4 @@ class Font: def families(root: tkinter.Misc | None = None, displayof: tkinter.Misc | None = None) -> tuple[str, ...]: ... def names(root: tkinter.Misc | None = None) -> tuple[str, ...]: ... - -if sys.version_info >= (3, 10): - def nametofont(name: str, root: tkinter.Misc | None = None) -> Font: ... - -else: - def nametofont(name: str) -> Font: ... +def nametofont(name: str, root: tkinter.Misc | None = None) -> Font: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 7143c7cce592..c2d79e4c7aa0 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -4,8 +4,8 @@ import tkinter from _typeshed import MaybeNone from collections.abc import Callable, Iterable, Sequence from tkinter.font import _FontDescription -from typing import Any, Literal, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Never, ParamSpec, TypeAlias, Unpack +from typing import Any, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Never, ParamSpec, Unpack __all__ = [ "Button", diff --git a/stdlib/token.pyi b/stdlib/token.pyi index fd1b10da1d12..a9ee3a48b87c 100644 --- a/stdlib/token.pyi +++ b/stdlib/token.pyi @@ -73,8 +73,7 @@ __all__ = [ if sys.version_info < (3, 13): __all__ += ["ASYNC", "AWAIT"] -if sys.version_info >= (3, 10): - __all__ += ["SOFT_KEYWORD"] +__all__ += ["SOFT_KEYWORD"] if sys.version_info >= (3, 12): __all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"] @@ -150,8 +149,7 @@ TYPE_COMMENT: Final[int] TYPE_IGNORE: Final[int] COLONEQUAL: Final[int] EXACT_TOKEN_TYPES: Final[dict[str, int]] -if sys.version_info >= (3, 10): - SOFT_KEYWORD: Final[int] +SOFT_KEYWORD: Final[int] if sys.version_info >= (3, 12): EXCLAMATION: Final[int] diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index 00a24b4eea07..3ea4e7db7248 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -3,8 +3,8 @@ from _typeshed import FileDescriptorOrPath from collections.abc import Callable, Generator, Iterable, Sequence from re import Pattern from token import * -from typing import Any, Final, NamedTuple, TextIO, type_check_only -from typing_extensions import TypeAlias, disjoint_base +from typing import Any, Final, NamedTuple, TextIO, TypeAlias, type_check_only +from typing_extensions import disjoint_base if sys.version_info < (3, 12): # Avoid double assignment to Final name by imports, which pyright objects to. @@ -89,8 +89,7 @@ __all__ = [ if sys.version_info < (3, 13): __all__ += ["ASYNC", "AWAIT"] -if sys.version_info >= (3, 10): - __all__ += ["SOFT_KEYWORD"] +__all__ += ["SOFT_KEYWORD"] if sys.version_info >= (3, 12): __all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"] diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index 7e7cc1e9ac54..20351dd5eccf 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -2,8 +2,8 @@ import sys import types from _typeshed import Incomplete, StrPath, TraceFunction from collections.abc import Callable, Iterable, Mapping, Sequence -from typing import Any, TypeVar -from typing_extensions import ParamSpec, TypeAlias +from typing import Any, TypeAlias, TypeVar +from typing_extensions import ParamSpec __all__ = ["Trace", "CoverageResults"] diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index 4305706afa20..593c13ef5eb4 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import SupportsWrite, Unused from collections.abc import Generator, Iterable, Iterator, Mapping from types import FrameType, TracebackType -from typing import Any, ClassVar, Literal, SupportsIndex, overload -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, ClassVar, Literal, SupportsIndex, TypeAlias, overload +from typing_extensions import Self, deprecated __all__ = [ "extract_stack", @@ -33,51 +33,31 @@ if sys.version_info >= (3, 14): _FrameSummaryTuple: TypeAlias = tuple[str, int, str, str | None] def print_tb(tb: TracebackType | None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ... - -if sys.version_info >= (3, 10): - @overload - def print_exception( - exc: type[BaseException] | None, - /, - value: BaseException | None = ..., - tb: TracebackType | None = ..., - limit: int | None = None, - file: SupportsWrite[str] | None = None, - chain: bool = True, - ) -> None: ... - @overload - def print_exception( - exc: BaseException, /, *, limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True - ) -> None: ... - @overload - def format_exception( - exc: type[BaseException] | None, - /, - value: BaseException | None = ..., - tb: TracebackType | None = ..., - limit: int | None = None, - chain: bool = True, - ) -> list[str]: ... - @overload - def format_exception(exc: BaseException, /, *, limit: int | None = None, chain: bool = True) -> list[str]: ... - -else: - def print_exception( - etype: type[BaseException] | None, - value: BaseException | None, - tb: TracebackType | None, - limit: int | None = None, - file: SupportsWrite[str] | None = None, - chain: bool = True, - ) -> None: ... - def format_exception( - etype: type[BaseException] | None, - value: BaseException | None, - tb: TracebackType | None, - limit: int | None = None, - chain: bool = True, - ) -> list[str]: ... - +@overload +def print_exception( + exc: type[BaseException] | None, + /, + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = None, + file: SupportsWrite[str] | None = None, + chain: bool = True, +) -> None: ... +@overload +def print_exception( + exc: BaseException, /, *, limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True +) -> None: ... +@overload +def format_exception( + exc: type[BaseException] | None, + /, + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = None, + chain: bool = True, +) -> list[str]: ... +@overload +def format_exception(exc: BaseException, /, *, limit: int | None = None, chain: bool = True) -> list[str]: ... def print_exc(limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ... def print_last(limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ... def print_stack(f: FrameType | None = None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ... @@ -92,15 +72,12 @@ if sys.version_info >= (3, 13): @overload def format_exception_only(exc: Unused, /, value: BaseException | None, *, show_group: bool = False) -> list[str]: ... -elif sys.version_info >= (3, 10): +else: @overload def format_exception_only(exc: BaseException | None, /) -> list[str]: ... @overload def format_exception_only(exc: Unused, /, value: BaseException | None) -> list[str]: ... -else: - def format_exception_only(etype: type[BaseException] | None, value: BaseException | None) -> list[str]: ... - def format_exc(limit: int | None = None, chain: bool = True) -> str: ... def format_tb(tb: TracebackType | None, limit: int | None = None) -> list[str]: ... def format_stack(f: FrameType | None = None, limit: int | None = None) -> list[str]: ... @@ -126,12 +103,10 @@ class TracebackException: # These fields only exist for `SyntaxError`s, but there is no way to express that in the type system. filename: str lineno: str | None - if sys.version_info >= (3, 10): - end_lineno: str | None + end_lineno: str | None text: str offset: int - if sys.version_info >= (3, 10): - end_offset: int | None + end_offset: int | None msg: str if sys.version_info >= (3, 13): @@ -173,19 +148,6 @@ class TracebackException: max_group_depth: int = 10, _seen: set[int] | None = None, ) -> None: ... - elif sys.version_info >= (3, 10): - def __init__( - self, - exc_type: type[BaseException], - exc_value: BaseException, - exc_traceback: TracebackType | None, - *, - limit: int | None = None, - lookup_lines: bool = True, - capture_locals: bool = False, - compact: bool = False, - _seen: set[int] | None = None, - ) -> None: ... else: def __init__( self, @@ -196,6 +158,7 @@ class TracebackException: limit: int | None = None, lookup_lines: bool = True, capture_locals: bool = False, + compact: bool = False, _seen: set[int] | None = None, ) -> None: ... @@ -212,7 +175,7 @@ class TracebackException: max_group_width: int = 15, max_group_depth: int = 10, ) -> Self: ... - elif sys.version_info >= (3, 10): + else: @classmethod def from_exception( cls, @@ -223,11 +186,6 @@ class TracebackException: capture_locals: bool = False, compact: bool = False, ) -> Self: ... - else: - @classmethod - def from_exception( - cls, exc: BaseException, *, limit: int | None = None, lookup_lines: bool = True, capture_locals: bool = False - ) -> Self: ... def __eq__(self, other: object) -> bool: ... __hash__: ClassVar[None] # type: ignore[assignment] diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 2a7ee0051af9..042d1ca94ee7 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,8 +1,7 @@ import sys from _tracemalloc import * from collections.abc import Sequence -from typing import Any, SupportsIndex, overload -from typing_extensions import TypeAlias +from typing import Any, SupportsIndex, TypeAlias, overload def get_object_traceback(obj: object) -> Traceback | None: ... def take_snapshot() -> Snapshot: ... diff --git a/stdlib/tty.pyi b/stdlib/tty.pyi index ca3f0013b20e..a0478335a3f3 100644 --- a/stdlib/tty.pyi +++ b/stdlib/tty.pyi @@ -1,7 +1,6 @@ import sys import termios -from typing import IO, Final -from typing_extensions import TypeAlias +from typing import IO, Final, TypeAlias if sys.platform != "win32": __all__ = ["setraw", "setcbreak"] diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index b5f536d0e28e..0667a8d5dbdd 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -3,8 +3,8 @@ from _typeshed import StrPath from collections.abc import Callable, Generator, Sequence from contextlib import contextmanager from tkinter import Canvas, Frame, Misc, PhotoImage, Scrollbar -from typing import Any, ClassVar, Literal, TypedDict, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated, disjoint_base +from typing import Any, ClassVar, Literal, TypeAlias, TypedDict, overload, type_check_only +from typing_extensions import Self, deprecated, disjoint_base __all__ = [ "ScrolledCanvas", diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 568f6ea68d0b..da8da3670f00 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -52,8 +52,7 @@ __all__ = [ "GenericAlias", ] -if sys.version_info >= (3, 10): - __all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"] +__all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"] if sys.version_info >= (3, 12): __all__ += ["get_original_bases"] @@ -84,9 +83,8 @@ class FunctionType: if sys.version_info >= (3, 14): __annotate__: AnnotateFunc | None __kwdefaults__: dict[str, Any] | None - if sys.version_info >= (3, 10): - @property - def __builtins__(self) -> dict[str, Any]: ... + @property + def __builtins__(self) -> dict[str, Any]: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] @@ -149,22 +147,16 @@ class CodeType: def co_name(self) -> str: ... @property def co_firstlineno(self) -> int: ... - if sys.version_info >= (3, 10): - @property - @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `CodeType.co_lines()` instead.") - def co_lnotab(self) -> bytes: ... - else: - @property - def co_lnotab(self) -> bytes: ... - + @property + @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `CodeType.co_lines()` instead.") + def co_lnotab(self) -> bytes: ... @property def co_freevars(self) -> tuple[str, ...]: ... @property def co_cellvars(self) -> tuple[str, ...]: ... - if sys.version_info >= (3, 10): - @property - def co_linetable(self) -> bytes: ... - def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ... + @property + def co_linetable(self) -> bytes: ... + def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ... if sys.version_info >= (3, 11): @property def co_exceptiontable(self) -> bytes: ... @@ -197,27 +189,6 @@ class CodeType: cellvars: tuple[str, ...] = ..., /, ) -> Self: ... - elif sys.version_info >= (3, 10): - def __new__( - cls, - argcount: int, - posonlyargcount: int, - kwonlyargcount: int, - nlocals: int, - stacksize: int, - flags: int, - codestring: bytes, - constants: tuple[object, ...], - names: tuple[str, ...], - varnames: tuple[str, ...], - filename: str, - name: str, - firstlineno: int, - linetable: bytes, - freevars: tuple[str, ...] = ..., - cellvars: tuple[str, ...] = ..., - /, - ) -> Self: ... else: def __new__( cls, @@ -234,7 +205,7 @@ class CodeType: filename: str, name: str, firstlineno: int, - lnotab: bytes, + linetable: bytes, freevars: tuple[str, ...] = ..., cellvars: tuple[str, ...] = ..., /, @@ -262,27 +233,6 @@ class CodeType: co_linetable: bytes = ..., co_exceptiontable: bytes = ..., ) -> Self: ... - elif sys.version_info >= (3, 10): - def replace( - self, - *, - co_argcount: int = -1, - co_posonlyargcount: int = -1, - co_kwonlyargcount: int = -1, - co_nlocals: int = -1, - co_stacksize: int = -1, - co_flags: int = -1, - co_firstlineno: int = -1, - co_code: bytes = ..., - co_consts: tuple[object, ...] = ..., - co_names: tuple[str, ...] = ..., - co_varnames: tuple[str, ...] = ..., - co_freevars: tuple[str, ...] = ..., - co_cellvars: tuple[str, ...] = ..., - co_filename: str = ..., - co_name: str = ..., - co_linetable: bytes = ..., - ) -> Self: ... else: def replace( self, @@ -302,7 +252,7 @@ class CodeType: co_cellvars: tuple[str, ...] = ..., co_filename: str = ..., co_name: str = ..., - co_lnotab: bytes = ..., + co_linetable: bytes = ..., ) -> Self: ... if sys.version_info >= (3, 13): @@ -697,43 +647,42 @@ class GenericAlias: def __unpacked__(self) -> bool: ... @property def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ... - if sys.version_info >= (3, 10): - def __or__(self, value: Any, /) -> UnionType: ... - def __ror__(self, value: Any, /) -> UnionType: ... + + def __or__(self, value: Any, /) -> UnionType: ... + def __ror__(self, value: Any, /) -> UnionType: ... # GenericAlias delegates attr access to `__origin__` def __getattr__(self, name: str) -> Any: ... -if sys.version_info >= (3, 10): - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... +@final +class NoneType: + def __bool__(self) -> Literal[False]: ... - @final - class EllipsisType: ... +@final +class EllipsisType: ... - @final - class NotImplementedType(Any): ... +@final +class NotImplementedType(Any): ... - @final - class UnionType: - @property - def __args__(self) -> tuple[Any, ...]: ... - @property - def __parameters__(self) -> tuple[Any, ...]: ... - # `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`). - # Normally we'd express this using the return type of `_SpecialForm.__ror__`, - # but because `UnionType.__or__` accepts `Any`, type checkers will use - # the return type of `UnionType.__or__` to infer the result of this operation - # rather than `_SpecialForm.__ror__`. To mitigate this, we use `| Any` - # in the return type of `UnionType.__(r)or__`. - def __or__(self, value: Any, /) -> UnionType | Any: ... - def __ror__(self, value: Any, /) -> UnionType | Any: ... - def __eq__(self, value: object, /) -> bool: ... - def __hash__(self) -> int: ... - # you can only subscript a `UnionType` instance if at least one of the elements - # in the union is a generic alias instance that has a non-empty `__parameters__` - def __getitem__(self, parameters: Any) -> object: ... +@final +class UnionType: + @property + def __args__(self) -> tuple[Any, ...]: ... + @property + def __parameters__(self) -> tuple[Any, ...]: ... + # `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`). + # Normally we'd express this using the return type of `_SpecialForm.__ror__`, + # but because `UnionType.__or__` accepts `Any`, type checkers will use + # the return type of `UnionType.__or__` to infer the result of this operation + # rather than `_SpecialForm.__ror__`. To mitigate this, we use `| Any` + # in the return type of `UnionType.__(r)or__`. + def __or__(self, value: Any, /) -> UnionType | Any: ... + def __ror__(self, value: Any, /) -> UnionType | Any: ... + def __eq__(self, value: object, /) -> bool: ... + def __hash__(self) -> int: ... + # you can only subscript a `UnionType` instance if at least one of the elements + # in the union is a generic alias instance that has a non-empty `__parameters__` + def __getitem__(self, parameters: Any) -> object: ... if sys.version_info >= (3, 13): @final diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 369af41a7ad9..6a3532420c40 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -27,8 +27,7 @@ if sys.version_info >= (3, 14): from annotationlib import Format -if sys.version_info >= (3, 10): - from types import UnionType +from types import UnionType __all__ = [ "AbstractSet", @@ -113,8 +112,7 @@ __all__ = [ if sys.version_info >= (3, 14): __all__ += ["evaluate_forward_ref"] -if sys.version_info >= (3, 10): - __all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"] +__all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"] if sys.version_info >= (3, 11): __all__ += [ @@ -206,9 +204,9 @@ class TypeVar: covariant: bool = False, contravariant: bool = False, ) -> None: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm - def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm + + def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm + def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm if sys.version_info >= (3, 11): def __typing_subst__(self, arg: Any, /) -> Any: ... if sys.version_info >= (3, 13): @@ -227,9 +225,8 @@ class TypeVar: class _SpecialForm(_Final): __slots__ = ("_name", "__doc__", "_getitem") def __getitem__(self, parameters: Any) -> object: ... - if sys.version_info >= (3, 10): - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... Union: _SpecialForm Protocol: _SpecialForm @@ -275,122 +272,108 @@ if sys.version_info >= (3, 11): @property def evaluate_default(self) -> EvaluateFunc | None: ... -if sys.version_info >= (3, 10): - @final - class ParamSpecArgs: - @property - def __origin__(self) -> ParamSpec: ... - if sys.version_info >= (3, 12): - def __new__(cls, origin: ParamSpec) -> Self: ... - else: - def __init__(self, origin: ParamSpec) -> None: ... - - def __eq__(self, other: object, /) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] +@final +class ParamSpecArgs: + @property + def __origin__(self) -> ParamSpec: ... + if sys.version_info >= (3, 12): + def __new__(cls, origin: ParamSpec) -> Self: ... + else: + def __init__(self, origin: ParamSpec) -> None: ... - @final - class ParamSpecKwargs: - @property - def __origin__(self) -> ParamSpec: ... - if sys.version_info >= (3, 12): - def __new__(cls, origin: ParamSpec) -> Self: ... - else: - def __init__(self, origin: ParamSpec) -> None: ... + def __eq__(self, other: object, /) -> bool: ... + __hash__: ClassVar[None] # type: ignore[assignment] - def __eq__(self, other: object, /) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] +@final +class ParamSpecKwargs: + @property + def __origin__(self) -> ParamSpec: ... + if sys.version_info >= (3, 12): + def __new__(cls, origin: ParamSpec) -> Self: ... + else: + def __init__(self, origin: ParamSpec) -> None: ... - @final - class ParamSpec: - @property - def __name__(self) -> str: ... - @property - def __bound__(self) -> Any | None: ... # AnnotationForm - @property - def __covariant__(self) -> bool: ... - @property - def __contravariant__(self) -> bool: ... - if sys.version_info >= (3, 12): - @property - def __infer_variance__(self) -> bool: ... - if sys.version_info >= (3, 13): - @property - def __default__(self) -> Any: ... # AnnotationForm - if sys.version_info >= (3, 13): - def __new__( - cls, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - infer_variance: bool = False, - default: Any = ..., # AnnotationForm - ) -> Self: ... - elif sys.version_info >= (3, 12): - def __new__( - cls, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - infer_variance: bool = False, - ) -> Self: ... - elif sys.version_info >= (3, 11): - def __new__( - cls, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - ) -> Self: ... - else: - def __init__( - self, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - ) -> None: ... + def __eq__(self, other: object, /) -> bool: ... + __hash__: ClassVar[None] # type: ignore[assignment] +@final +class ParamSpec: + @property + def __name__(self) -> str: ... + @property + def __bound__(self) -> Any | None: ... # AnnotationForm + @property + def __covariant__(self) -> bool: ... + @property + def __contravariant__(self) -> bool: ... + if sys.version_info >= (3, 12): @property - def args(self) -> ParamSpecArgs: ... + def __infer_variance__(self) -> bool: ... + if sys.version_info >= (3, 13): @property - def kwargs(self) -> ParamSpecKwargs: ... - if sys.version_info >= (3, 11): - def __typing_subst__(self, arg: Any, /) -> Any: ... - def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ... + def __default__(self) -> Any: ... # AnnotationForm + if sys.version_info >= (3, 13): + def __new__( + cls, + name: str, + *, + bound: Any | None = None, # AnnotationForm + contravariant: bool = False, + covariant: bool = False, + infer_variance: bool = False, + default: Any = ..., # AnnotationForm + ) -> Self: ... + elif sys.version_info >= (3, 12): + def __new__( + cls, + name: str, + *, + bound: Any | None = None, # AnnotationForm + contravariant: bool = False, + covariant: bool = False, + infer_variance: bool = False, + ) -> Self: ... + elif sys.version_info >= (3, 11): + def __new__( + cls, name: str, *, bound: Any | None = None, contravariant: bool = False, covariant: bool = False # AnnotationForm + ) -> Self: ... + else: + def __init__( + self, name: str, *, bound: Any | None = None, contravariant: bool = False, covariant: bool = False # AnnotationForm + ) -> None: ... - def __or__(self, right: Any, /) -> _SpecialForm: ... - def __ror__(self, left: Any, /) -> _SpecialForm: ... - if sys.version_info >= (3, 13): - def has_default(self) -> bool: ... - if sys.version_info >= (3, 14): - @property - def evaluate_default(self) -> EvaluateFunc | None: ... + @property + def args(self) -> ParamSpecArgs: ... + @property + def kwargs(self) -> ParamSpecKwargs: ... + if sys.version_info >= (3, 11): + def __typing_subst__(self, arg: Any, /) -> Any: ... + def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ... - Concatenate: _SpecialForm - TypeAlias: _SpecialForm - TypeGuard: _SpecialForm + def __or__(self, right: Any, /) -> _SpecialForm: ... + def __ror__(self, left: Any, /) -> _SpecialForm: ... + if sys.version_info >= (3, 13): + def has_default(self) -> bool: ... + if sys.version_info >= (3, 14): + @property + def evaluate_default(self) -> EvaluateFunc | None: ... - class NewType: - def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm - if sys.version_info >= (3, 11): - @staticmethod - def __call__(x: _T, /) -> _T: ... - else: - def __call__(self, x: _T) -> _T: ... +Concatenate: _SpecialForm +TypeAlias: _SpecialForm +TypeGuard: _SpecialForm - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... - __supertype__: type | NewType - __name__: str +class NewType: + def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm + if sys.version_info >= (3, 11): + @staticmethod + def __call__(x: _T, /) -> _T: ... + else: + def __call__(self, x: _T) -> _T: ... -else: - def NewType(name: str, tp: Any) -> Any: ... + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... + __supertype__: type | NewType + __name__: str _F = TypeVar("_F", bound=Callable[..., Any]) _P = _ParamSpec("_P") @@ -448,12 +431,8 @@ class _Generic: if sys.version_info < (3, 12): __slots__ = () - if sys.version_info >= (3, 10): - @classmethod - def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ... - else: - @classmethod - def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ... + @classmethod + def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ... Generic: type[_Generic] @@ -967,13 +946,10 @@ else: ) -> dict[str, Any]: ... # AnnotationForm def get_args(tp: Any) -> tuple[Any, ...]: ... # AnnotationForm - -if sys.version_info >= (3, 10): - @overload - def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... - @overload - def get_origin(tp: UnionType) -> type[UnionType]: ... - +@overload +def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... +@overload +def get_origin(tp: UnionType) -> type[UnionType]: ... @overload def get_origin(tp: GenericAlias) -> type: ... @overload @@ -1136,9 +1112,7 @@ else: def __or__(self, other: Any) -> _SpecialForm: ... def __ror__(self, other: Any) -> _SpecialForm: ... -if sys.version_info >= (3, 10): - def is_typeddict(tp: object) -> bool: ... - +def is_typeddict(tp: object) -> bool: ... def _type_repr(obj: object) -> str: ... if sys.version_info >= (3, 12): diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 8a9f0f3919ba..495cc4eb3f03 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -29,7 +29,7 @@ from collections.abc import ( ) from contextlib import AbstractAsyncContextManager as AsyncContextManager, AbstractContextManager as ContextManager from re import Match as Match, Pattern as Pattern -from types import GenericAlias, ModuleType +from types import GenericAlias, ModuleType, UnionType from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035 IO as IO, TYPE_CHECKING as TYPE_CHECKING, @@ -67,9 +67,6 @@ from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035 type_check_only, ) -if sys.version_info >= (3, 10): - from types import UnionType - # Please keep order the same as at runtime. __all__ = [ # Super-special typing primitives. @@ -274,11 +271,8 @@ else: ) -> dict[str, AnnotationForm]: ... def get_args(tp: AnnotationForm) -> tuple[AnnotationForm, ...]: ... - -if sys.version_info >= (3, 10): - @overload - def get_origin(tp: UnionType) -> type[UnionType]: ... - +@overload +def get_origin(tp: UnionType) -> type[UnionType]: ... @overload def get_origin(tp: GenericAlias) -> type: ... @overload @@ -290,32 +284,14 @@ Annotated: _SpecialForm _AnnotatedAlias: Any # undocumented # New and changed things in 3.10 -if sys.version_info >= (3, 10): - from typing import ( - Concatenate as Concatenate, - ParamSpecArgs as ParamSpecArgs, - ParamSpecKwargs as ParamSpecKwargs, - TypeAlias as TypeAlias, - TypeGuard as TypeGuard, - is_typeddict as is_typeddict, - ) -else: - @final - class ParamSpecArgs: - @property - def __origin__(self) -> ParamSpec: ... - def __init__(self, origin: ParamSpec) -> None: ... - - @final - class ParamSpecKwargs: - @property - def __origin__(self) -> ParamSpec: ... - def __init__(self, origin: ParamSpec) -> None: ... - - Concatenate: _SpecialForm - TypeAlias: _SpecialForm - TypeGuard: _SpecialForm - def is_typeddict(tp: object) -> bool: ... +from typing import ( + Concatenate as Concatenate, + ParamSpecArgs as ParamSpecArgs, + ParamSpecKwargs as ParamSpecKwargs, + TypeAlias as TypeAlias, + TypeGuard as TypeGuard, + is_typeddict as is_typeddict, +) # New and changed things in 3.11 if sys.version_info >= (3, 11): @@ -377,9 +353,8 @@ else: def __call__(self, obj: _T, /) -> _T: ... __supertype__: type | NewType __name__: str - if sys.version_info >= (3, 10): - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... if sys.version_info >= (3, 12): from collections.abc import Buffer as Buffer @@ -527,9 +502,8 @@ else: ) -> None: ... def has_default(self) -> bool: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any) -> _SpecialForm: ... - def __ror__(self, left: Any) -> _SpecialForm: ... + def __or__(self, right: Any) -> _SpecialForm: ... + def __ror__(self, left: Any) -> _SpecialForm: ... if sys.version_info >= (3, 11): def __typing_subst__(self, arg: Any) -> Any: ... @@ -562,9 +536,8 @@ else: def kwargs(self) -> ParamSpecKwargs: ... def has_default(self) -> bool: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any) -> _SpecialForm: ... - def __ror__(self, left: Any) -> _SpecialForm: ... + def __or__(self, right: Any) -> _SpecialForm: ... + def __ror__(self, left: Any) -> _SpecialForm: ... @final class TypeVarTuple: @@ -605,9 +578,8 @@ else: # Returns typing._GenericAlias, which isn't stubbed. def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> AnnotationForm: ... def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any, /) -> _SpecialForm: ... - def __ror__(self, left: Any, /) -> _SpecialForm: ... + def __or__(self, right: Any, /) -> _SpecialForm: ... + def __ror__(self, left: Any, /) -> _SpecialForm: ... # PEP 727 class Doc: @@ -705,6 +677,6 @@ class Sentinel: if sys.version_info >= (3, 14): def __or__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions def __ror__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions - elif sys.version_info >= (3, 10): + else: def __or__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions def __ror__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions diff --git a/stdlib/unicodedata.pyi b/stdlib/unicodedata.pyi index 9fff042f0b96..20acf0428158 100644 --- a/stdlib/unicodedata.pyi +++ b/stdlib/unicodedata.pyi @@ -1,14 +1,9 @@ -import sys from _typeshed import ReadOnlyBuffer -from typing import Any, Final, Literal, TypeVar, final, overload -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias, TypeVar, final, overload ucd_3_2_0: UCD unidata_version: Final[str] -if sys.version_info < (3, 10): - ucnhash_CAPI: Any - _T = TypeVar("_T") _NormalizationForm: TypeAlias = Literal["NFC", "NFD", "NFKC", "NFKD"] diff --git a/stdlib/unittest/_log.pyi b/stdlib/unittest/_log.pyi index 011a970d8bbc..6c6a63b096c1 100644 --- a/stdlib/unittest/_log.pyi +++ b/stdlib/unittest/_log.pyi @@ -1,5 +1,4 @@ import logging -import sys from types import TracebackType from typing import ClassVar, Generic, NamedTuple, TypeVar from unittest.case import TestCase, _BaseTestCaseContext @@ -15,11 +14,8 @@ class _AssertLogsContext(_BaseTestCaseContext, Generic[_L]): logger_name: str level: int msg: None - if sys.version_info >= (3, 10): - def __init__(self, test_case: TestCase, logger_name: str, level: int, no_logs: bool) -> None: ... - no_logs: bool - else: - def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... + def __init__(self, test_case: TestCase, logger_name: str, level: int, no_logs: bool) -> None: ... + no_logs: bool def __enter__(self) -> _L: ... def __exit__( diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index a602196e73c6..4a7f40bbc556 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -168,11 +168,9 @@ class TestCase: def assertLogs( self, logger: str | logging.Logger | None = None, level: int | str | None = None ) -> _AssertLogsContext[_LoggingWatcher]: ... - if sys.version_info >= (3, 10): - def assertNoLogs( - self, logger: str | logging.Logger | None = None, level: int | str | None = None - ) -> _AssertLogsContext[None]: ... - + def assertNoLogs( + self, logger: str | logging.Logger | None = None, level: int | str | None = None + ) -> _AssertLogsContext[None]: ... @overload def assertAlmostEqual(self, first: _S, second: _S, places: None, msg: Any, delta: _SupportsAbsAndDunderGE) -> None: ... @overload @@ -277,9 +275,7 @@ class TestCase: self, subset: Mapping[Any, Any], dictionary: Mapping[Any, Any], msg: object = None ) -> None: ... - if sys.version_info >= (3, 10): - # Runtime has *args, **kwargs, but will error if any are supplied - def __init_subclass__(cls, *args: Never, **kwargs: Never) -> None: ... + def __init_subclass__(cls, *args: Never, **kwargs: Never) -> None: ... if sys.version_info >= (3, 14): def assertIsSubclass(self, cls: type, superclass: type | tuple[type, ...], msg: Any = None) -> None: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 81de40c89849..251a394585f3 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -4,8 +4,8 @@ import unittest.suite from collections.abc import Callable, Sequence from re import Pattern from types import ModuleType -from typing import Any, Final -from typing_extensions import TypeAlias, deprecated +from typing import Any, Final, TypeAlias +from typing_extensions import deprecated _SortComparisonMethod: TypeAlias = Callable[[str, str], int] _SuiteClass: TypeAlias = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite] diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index ef51d721297a..9993015c144e 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -3,8 +3,8 @@ from _typeshed import MaybeNone from collections.abc import Awaitable, Callable, Coroutine, Iterable, Mapping, Sequence from contextlib import _GeneratorContextManager from types import TracebackType -from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, Self, TypeAlias, disjoint_base +from typing import Any, ClassVar, Final, Generic, Literal, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, Self, disjoint_base _T = TypeVar("_T") _TT = TypeVar("_TT", bound=type[Any]) @@ -244,35 +244,20 @@ class _patch(Generic[_T]): additional_patchers: Any # If new==DEFAULT, self is _patch[Any]. Ideally we'd be able to add an overload for it so that self is _patch[MagicMock], # but that's impossible with the current type system. - if sys.version_info >= (3, 10): - def __init__( - self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 - getter: Callable[[], Any], - attribute: str, - new: _T, - spec: Any | None, - create: bool, - spec_set: Any | None, - autospec: Any | None, - new_callable: Any | None, - kwargs: Mapping[str, Any], - *, - unsafe: bool = False, - ) -> None: ... - else: - def __init__( - self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 - getter: Callable[[], Any], - attribute: str, - new: _T, - spec: Any | None, - create: bool, - spec_set: Any | None, - autospec: Any | None, - new_callable: Any | None, - kwargs: Mapping[str, Any], - ) -> None: ... - + def __init__( + self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 + getter: Callable[[], Any], + attribute: str, + new: _T, + spec: Any | None, + create: bool, + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, + kwargs: Mapping[str, Any], + *, + unsafe: bool = False, + ) -> None: ... def copy(self) -> _patch[_T]: ... @overload def __call__(self, func: _TT) -> _TT: ... @@ -315,10 +300,8 @@ class _patch_dict: clear: Any def __init__(self, in_dict: Any, values: Any = (), clear: Any = False, **kwargs: Any) -> None: ... def __call__(self, f: Any) -> Any: ... - if sys.version_info >= (3, 10): - def decorate_callable(self, f: _F) -> _F: ... - def decorate_async_callable(self, f: _AF) -> _AF: ... - + def decorate_callable(self, f: _F) -> _F: ... + def decorate_async_callable(self, f: _AF) -> _AF: ... def decorate_class(self, klass: Any) -> Any: ... def __enter__(self) -> Any: ... def __exit__(self, *args: object) -> Any: ... @@ -517,27 +500,16 @@ class _ANY(Any): ANY: _ANY -if sys.version_info >= (3, 10): - def create_autospec( - spec: Any, - spec_set: Any = False, - instance: Any = False, - _parent: Any | None = None, - _name: Any | None = None, - *, - unsafe: bool = False, - **kwargs: Any, - ) -> Any: ... - -else: - def create_autospec( - spec: Any, - spec_set: Any = False, - instance: Any = False, - _parent: Any | None = None, - _name: Any | None = None, - **kwargs: Any, - ) -> Any: ... +def create_autospec( + spec: Any, + spec_set: Any = False, + instance: Any = False, + _parent: Any | None = None, + _name: Any | None = None, + *, + unsafe: bool = False, + **kwargs: Any, +) -> Any: ... class _SpecState: spec: Any diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 0761baaa2830..081f6e1328e4 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -2,8 +2,7 @@ import sys import unittest.case from _typeshed import OptExcInfo from collections.abc import Callable -from typing import Any, Final, TextIO, TypeVar -from typing_extensions import TypeAlias +from typing import Any, Final, TextIO, TypeAlias, TypeVar _F = TypeVar("_F", bound=Callable[..., Any]) _DurationsType: TypeAlias = list[tuple[str, float]] diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index f76771f55e13..3a2e08749e9b 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -4,8 +4,8 @@ import unittest.result import unittest.suite from _typeshed import SupportsFlush, SupportsWrite from collections.abc import Callable, Iterable -from typing import Any, Generic, Protocol, TypeVar, type_check_only -from typing_extensions import Never, TypeAlias +from typing import Any, Generic, Protocol, TypeAlias, TypeVar, type_check_only +from typing_extensions import Never from warnings import _ActionKind _ResultClassType: TypeAlias = Callable[[_TextTestStream, bool, int], TextTestResult[Any]] diff --git a/stdlib/unittest/suite.pyi b/stdlib/unittest/suite.pyi index 443396164b6f..b7cf75c68271 100644 --- a/stdlib/unittest/suite.pyi +++ b/stdlib/unittest/suite.pyi @@ -1,8 +1,7 @@ import unittest.case import unittest.result from collections.abc import Iterable, Iterator -from typing import ClassVar -from typing_extensions import TypeAlias +from typing import ClassVar, TypeAlias _TestType: TypeAlias = unittest.case.TestCase | TestSuite diff --git a/stdlib/unittest/util.pyi b/stdlib/unittest/util.pyi index 763c1478f5e6..11a6f903932f 100644 --- a/stdlib/unittest/util.pyi +++ b/stdlib/unittest/util.pyi @@ -1,6 +1,5 @@ from collections.abc import MutableSequence, Sequence -from typing import Any, Final, Literal, Protocol, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, Protocol, TypeAlias, TypeVar, type_check_only @type_check_only class _SupportsDunderLT(Protocol): diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 364892ecdf69..fe1cd6a71567 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,8 +1,7 @@ import sys from collections.abc import Iterable, Mapping, Sequence from types import GenericAlias -from typing import Any, AnyStr, Final, Generic, Literal, NamedTuple, Protocol, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, AnyStr, Final, Generic, Literal, NamedTuple, Protocol, TypeAlias, overload, type_check_only __all__ = [ "urlparse", diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index f7e1f278d3e6..fe790f00cf02 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -6,8 +6,8 @@ from email.message import Message from http.client import HTTPConnection, HTTPMessage, HTTPResponse from http.cookiejar import CookieJar from re import Pattern -from typing import IO, Any, ClassVar, Literal, NoReturn, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias, deprecated +from typing import IO, Any, ClassVar, Literal, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import deprecated from urllib.error import HTTPError as HTTPError from urllib.response import addclosehook, addinfourl diff --git a/stdlib/uu.pyi b/stdlib/uu.pyi index 324053e04337..62bf6cb05f59 100644 --- a/stdlib/uu.pyi +++ b/stdlib/uu.pyi @@ -1,5 +1,4 @@ -from typing import BinaryIO -from typing_extensions import TypeAlias +from typing import BinaryIO, TypeAlias __all__ = ["Error", "encode", "decode"] diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index 055f4def311c..06285e03aea7 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -2,8 +2,8 @@ import builtins import sys from _typeshed import Unused from enum import Enum -from typing import Final, NoReturn -from typing_extensions import LiteralString, TypeAlias +from typing import Final, NoReturn, TypeAlias +from typing_extensions import LiteralString _FieldsType: TypeAlias = tuple[int, int, int, int, int, int] diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index 49c98cb07540..188b6bb6b246 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -3,8 +3,8 @@ import sys from _warnings import warn as warn, warn_explicit as warn_explicit from collections.abc import Sequence from types import ModuleType, TracebackType -from typing import Any, Generic, Literal, TextIO, overload -from typing_extensions import LiteralString, TypeAlias, TypeVar +from typing import Any, Generic, Literal, TextIO, TypeAlias, overload +from typing_extensions import LiteralString, TypeVar __all__ = [ "warn", diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index fd7dbfade884..f0fdef5233e2 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import ReadableBuffer, Unused -from typing import IO, Any, BinaryIO, Final, Literal, NamedTuple, NoReturn, overload -from typing_extensions import Self, TypeAlias, deprecated +from typing import IO, Any, BinaryIO, Final, Literal, NamedTuple, NoReturn, TypeAlias, overload +from typing_extensions import Self, deprecated __all__ = ["open", "Error", "Wave_read", "Wave_write"] diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index a654bbcdfb61..61c591a9b4a5 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ReadableBuffer, Unused from types import TracebackType -from typing import Any, Final, Literal, final, overload -from typing_extensions import Self, TypeAlias +from typing import Any, Final, Literal, TypeAlias, final, overload +from typing_extensions import Self if sys.platform == "win32": _KeyType: TypeAlias = HKEYType | int diff --git a/stdlib/wsgiref/headers.pyi b/stdlib/wsgiref/headers.pyi index 9febad4b3277..f249ffcf0223 100644 --- a/stdlib/wsgiref/headers.pyi +++ b/stdlib/wsgiref/headers.pyi @@ -1,6 +1,5 @@ from re import Pattern -from typing import Final, overload -from typing_extensions import TypeAlias +from typing import Final, TypeAlias, overload _HeaderList: TypeAlias = list[tuple[str, str]] diff --git a/stdlib/wsgiref/types.pyi b/stdlib/wsgiref/types.pyi index 57276fd05ea8..b7fd99809856 100644 --- a/stdlib/wsgiref/types.pyi +++ b/stdlib/wsgiref/types.pyi @@ -1,7 +1,6 @@ from _typeshed import OptExcInfo from collections.abc import Callable, Iterable, Iterator -from typing import Any, Protocol -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias __all__ = ["StartResponse", "WSGIEnvironment", "WSGIApplication", "InputStream", "ErrorStream", "FileWrapper"] diff --git a/stdlib/wsgiref/validate.pyi b/stdlib/wsgiref/validate.pyi index fa8a6bbb8d03..498e03aa3673 100644 --- a/stdlib/wsgiref/validate.pyi +++ b/stdlib/wsgiref/validate.pyi @@ -1,7 +1,6 @@ from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication from collections.abc import Callable, Iterable, Iterator -from typing import Any, NoReturn -from typing_extensions import TypeAlias +from typing import Any, NoReturn, TypeAlias __all__ = ["validator"] diff --git a/stdlib/xml/dom/expatbuilder.pyi b/stdlib/xml/dom/expatbuilder.pyi index 2b9ac8876970..e41067182935 100644 --- a/stdlib/xml/dom/expatbuilder.pyi +++ b/stdlib/xml/dom/expatbuilder.pyi @@ -1,6 +1,5 @@ from _typeshed import ReadableBuffer, SupportsRead -from typing import Any, Final, NoReturn -from typing_extensions import TypeAlias +from typing import Any, Final, NoReturn, TypeAlias from xml.dom.minidom import Document, DocumentFragment, DOMImplementation, Element, Node, TypeInfo from xml.dom.xmlbuilder import DOMBuilderFilter, Options from xml.parsers.expat import XMLParserType diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index e0431417aa3c..fdc35f0de7c1 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -3,8 +3,8 @@ from _collections_abc import dict_keys, dict_values from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Iterable, Sequence from types import TracebackType -from typing import Any, ClassVar, Generic, Literal, NoReturn, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, Generic, Literal, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self from xml.dom.minicompat import EmptyNodeList, NodeList from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS from xml.sax.xmlreader import XMLReader diff --git a/stdlib/xml/dom/pulldom.pyi b/stdlib/xml/dom/pulldom.pyi index df7a3ad0eddb..4ede39015585 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import Incomplete, Unused from collections.abc import MutableSequence, Sequence -from typing import Final, Literal, NoReturn -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, NoReturn, TypeAlias +from typing_extensions import Self from xml.dom.minidom import Comment, Document, DOMImplementation, Element, ProcessingInstruction, Text from xml.sax import _SupportsReadClose from xml.sax.handler import ContentHandler diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index 80f3c55c1489..9eceabda921a 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -1,7 +1,6 @@ from collections.abc import Callable, Generator, Iterable from re import Pattern -from typing import Any, Final, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, TypeAlias, TypeVar, overload from xml.etree.ElementTree import Element xpath_tokenizer_re: Final[Pattern[str]] diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index d728fb975bfb..25faa8dde0b5 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -2,8 +2,8 @@ import sys from _collections_abc import dict_keys from _typeshed import FileDescriptorOrPath, ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, Mapping, Sequence -from typing import Any, Final, Generic, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias, TypeGuard, deprecated, disjoint_base +from typing import Any, Final, Generic, Literal, Protocol, SupportsIndex, TypeAlias, TypeGuard, TypeVar, overload, type_check_only +from typing_extensions import deprecated, disjoint_base from xml.parsers.expat import XMLParserType __all__ = [ diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index 679466fa34d2..9b5c3bf4ddea 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -1,8 +1,7 @@ import sys from _typeshed import ReadableBuffer, StrPath, SupportsRead, _T_co from collections.abc import Iterable -from typing import Final, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Final, Protocol, TypeAlias, type_check_only from xml.sax._exceptions import ( SAXException as SAXException, SAXNotRecognizedException as SAXNotRecognizedException, diff --git a/stdlib/xml/sax/expatreader.pyi b/stdlib/xml/sax/expatreader.pyi index 3f9573a25f9a..dd8762da5137 100644 --- a/stdlib/xml/sax/expatreader.pyi +++ b/stdlib/xml/sax/expatreader.pyi @@ -1,13 +1,8 @@ -import sys from _typeshed import ReadableBuffer from collections.abc import Mapping -from typing import Any, Final, Literal, overload -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, TypeAlias, overload from xml.sax import _Source, xmlreader -from xml.sax.handler import _ContentHandlerProtocol - -if sys.version_info >= (3, 10): - from xml.sax.handler import LexicalHandler +from xml.sax.handler import LexicalHandler, _ContentHandlerProtocol _BoolType: TypeAlias = Literal[0, 1] | bool @@ -33,20 +28,16 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): def setContentHandler(self, handler: _ContentHandlerProtocol) -> None: ... def getFeature(self, name: str) -> _BoolType: ... def setFeature(self, name: str, state: _BoolType) -> None: ... - if sys.version_info >= (3, 10): - @overload - def getProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"]) -> LexicalHandler | None: ... - + @overload + def getProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"]) -> LexicalHandler | None: ... @overload def getProperty(self, name: Literal["http://www.python.org/sax/properties/interning-dict"]) -> dict[str, Any] | None: ... @overload def getProperty(self, name: Literal["http://xml.org/sax/properties/xml-string"]) -> bytes | None: ... @overload def getProperty(self, name: str) -> object: ... - if sys.version_info >= (3, 10): - @overload - def setProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"], value: LexicalHandler) -> None: ... - + @overload + def setProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"], value: LexicalHandler) -> None: ... @overload def setProperty( self, name: Literal["http://www.python.org/sax/properties/interning-dict"], value: dict[str, Any] diff --git a/stdlib/xml/sax/handler.pyi b/stdlib/xml/sax/handler.pyi index 5ecbfa6f1272..e1e080ac2d1a 100644 --- a/stdlib/xml/sax/handler.pyi +++ b/stdlib/xml/sax/handler.pyi @@ -1,4 +1,3 @@ -import sys from typing import Final, NoReturn, Protocol, type_check_only from xml.sax import xmlreader @@ -77,10 +76,9 @@ property_encoding: Final = "http://www.python.org/sax/properties/encoding" property_interning_dict: Final[str] # too long string all_properties: Final[list[str]] -if sys.version_info >= (3, 10): - class LexicalHandler: - def comment(self, content: str) -> None: ... - def startDTD(self, name: str, public_id: str | None, system_id: str | None) -> None: ... - def endDTD(self) -> None: ... - def startCDATA(self) -> None: ... - def endCDATA(self) -> None: ... +class LexicalHandler: + def comment(self, content: str) -> None: ... + def startDTD(self, name: str, public_id: str | None, system_id: str | None) -> None: ... + def endDTD(self) -> None: ... + def startCDATA(self) -> None: ... + def endCDATA(self) -> None: ... diff --git a/stdlib/xml/sax/xmlreader.pyi b/stdlib/xml/sax/xmlreader.pyi index e7d04ddeadb8..bec292f03282 100644 --- a/stdlib/xml/sax/xmlreader.pyi +++ b/stdlib/xml/sax/xmlreader.pyi @@ -1,7 +1,7 @@ from _typeshed import ReadableBuffer from collections.abc import Mapping -from typing import Generic, Literal, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import Generic, Literal, TypeAlias, TypeVar, overload +from typing_extensions import Self from xml.sax import _Source, _SupportsReadClose from xml.sax.handler import _ContentHandlerProtocol, _DTDHandlerProtocol, _EntityResolverProtocol, _ErrorHandlerProtocol diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 42420ee85848..18f8987f78fb 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -6,8 +6,8 @@ from collections.abc import Callable, Iterable, Mapping from datetime import datetime from io import BytesIO from types import TracebackType -from typing import Any, ClassVar, Final, Literal, Protocol, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, Final, Literal, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import Self @type_check_only class _SupportsTimeTuple(Protocol): diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index 286aaf980fbf..7bf397d2b1a4 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -4,8 +4,7 @@ import socketserver from _typeshed import ReadableBuffer from collections.abc import Callable, Iterable, Mapping from re import Pattern -from typing import Any, ClassVar, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Protocol, TypeAlias, type_check_only from xmlrpc.client import Fault, _Marshallable # The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy diff --git a/stdlib/xxlimited.pyi b/stdlib/xxlimited.pyi index 78a50b85f405..503caf0183f3 100644 --- a/stdlib/xxlimited.pyi +++ b/stdlib/xxlimited.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, ClassVar, final +from typing import Any, final class Str(str): ... @@ -12,13 +12,4 @@ class Xxo: def foo(i: int, j: int, /) -> Any: ... def new() -> Xxo: ... -if sys.version_info >= (3, 10): - class Error(Exception): ... - -else: - class error(Exception): ... - - class Null: - __hash__: ClassVar[None] # type: ignore[assignment] - - def roj(b: Any, /) -> None: ... +class Error(Exception): ... diff --git a/stdlib/zipapp.pyi b/stdlib/zipapp.pyi index c7cf1704b135..48713bced892 100644 --- a/stdlib/zipapp.pyi +++ b/stdlib/zipapp.pyi @@ -1,7 +1,6 @@ from collections.abc import Callable from pathlib import Path -from typing import BinaryIO -from typing_extensions import TypeAlias +from typing import BinaryIO, TypeAlias __all__ = ["ZipAppError", "create_archive", "get_interpreter"] diff --git a/stdlib/zipfile/__init__.pyi b/stdlib/zipfile/__init__.pyi index 19d8117a621f..1d9167997bec 100644 --- a/stdlib/zipfile/__init__.pyi +++ b/stdlib/zipfile/__init__.pyi @@ -5,8 +5,8 @@ from collections.abc import Callable, Iterable, Iterator from io import TextIOWrapper from os import PathLike from types import TracebackType -from typing import IO, Final, Literal, Protocol, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import IO, Final, Literal, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import Self __all__ = [ "BadZipFile", @@ -345,9 +345,8 @@ else: def name(self) -> str: ... @property def parent(self) -> PathLike[str]: ... # undocumented - if sys.version_info >= (3, 10): - @property - def filename(self) -> PathLike[str]: ... # undocumented + @property + def filename(self) -> PathLike[str]: ... # undocumented if sys.version_info >= (3, 11): @property def suffix(self) -> str: ... @@ -370,12 +369,7 @@ else: ) -> TextIOWrapper: ... @overload def open(self, mode: Literal["rb", "wb"], *, pwd: bytes | None = None) -> IO[bytes]: ... - - if sys.version_info >= (3, 10): - def iterdir(self) -> Iterator[Self]: ... - else: - def iterdir(self) -> Iterator[Path]: ... - + def iterdir(self) -> Iterator[Self]: ... def is_dir(self) -> bool: ... def is_file(self) -> bool: ... def exists(self) -> bool: ... @@ -388,11 +382,7 @@ else: write_through: bool = False, ) -> str: ... def read_bytes(self) -> bytes: ... - if sys.version_info >= (3, 10): - def joinpath(self, *other: StrPath) -> Path: ... - else: - def joinpath(self, add: StrPath) -> Path: ... # undocumented - + def joinpath(self, *other: StrPath) -> Path: ... # undocumented def __truediv__(self, add: StrPath) -> Path: ... def is_zipfile(filename: StrOrBytesPath | _SupportsReadSeekTell) -> bool: ... diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index 22af3c272759..f660684d351e 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -1,19 +1,11 @@ import sys +from _frozen_importlib_external import _LoaderBasics from _typeshed import StrOrBytesPath from importlib.machinery import ModuleSpec +from importlib.readers import ZipReader from types import CodeType, ModuleType from typing_extensions import deprecated -if sys.version_info >= (3, 10): - from importlib.readers import ZipReader -else: - from importlib.abc import ResourceReader - -if sys.version_info >= (3, 10): - from _frozen_importlib_external import _LoaderBasics -else: - _LoaderBasics = object - __all__ = ["ZipImportError", "zipimporter"] class ZipImportError(ImportError): ... @@ -27,33 +19,24 @@ class zipimporter(_LoaderBasics): def __init__(self, path: StrOrBytesPath) -> None: ... if sys.version_info < (3, 12): - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") - def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") - def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... - else: - def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... - def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") + def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") + def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... def get_code(self, fullname: str) -> CodeType: ... def get_data(self, pathname: str) -> bytes: ... def get_filename(self, fullname: str) -> str: ... if sys.version_info >= (3, 14): def get_resource_reader(self, fullname: str) -> ZipReader: ... # undocumented - elif sys.version_info >= (3, 10): - def get_resource_reader(self, fullname: str) -> ZipReader | None: ... # undocumented else: - def get_resource_reader(self, fullname: str) -> ResourceReader | None: ... # undocumented + def get_resource_reader(self, fullname: str) -> ZipReader | None: ... # undocumented def get_source(self, fullname: str) -> str | None: ... def is_package(self, fullname: str) -> bool: ... - if sys.version_info >= (3, 10): - @deprecated("Deprecated since Python 3.10; removed in Python 3.15. Use `exec_module()` instead.") - def load_module(self, fullname: str) -> ModuleType: ... - def exec_module(self, module: ModuleType) -> None: ... - def create_module(self, spec: ModuleSpec) -> None: ... - def find_spec(self, fullname: str, target: ModuleType | None = None) -> ModuleSpec | None: ... - def invalidate_caches(self) -> None: ... - else: - def load_module(self, fullname: str) -> ModuleType: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.15. Use `exec_module()` instead.") + def load_module(self, fullname: str) -> ModuleType: ... + def exec_module(self, module: ModuleType) -> None: ... + def create_module(self, spec: ModuleSpec) -> None: ... + def find_spec(self, fullname: str, target: ModuleType | None = None) -> ModuleSpec | None: ... + def invalidate_caches(self) -> None: ... diff --git a/stubs/Authlib/authlib/common/urls.pyi b/stubs/Authlib/authlib/common/urls.pyi index a07c2112c9be..969d4bcef05d 100644 --- a/stubs/Authlib/authlib/common/urls.pyi +++ b/stubs/Authlib/authlib/common/urls.pyi @@ -1,6 +1,5 @@ from re import Pattern -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias always_safe: Final[str] urlencoded: Final[set[str]] diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi index 1160db3b44c9..c124cdd6abac 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Generator -from typing import NoReturn -from typing_extensions import TypeAlias +from typing import NoReturn, TypeAlias from authlib.oauth1 import ClientAuth from authlib.oauth1.client import OAuth1Client as _OAuth1Client diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi index 79d45bd3c2af..a2b10260e298 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Generator -from typing import NoReturn -from typing_extensions import TypeAlias +from typing import NoReturn, TypeAlias from authlib.oauth2.auth import ClientAuth, TokenAuth from authlib.oauth2.client import OAuth2Client as _OAuth2Client diff --git a/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi b/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi index b565feae8b3d..8d4ee3b0d012 100644 --- a/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi +++ b/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable from re import Pattern -from typing import Any, Final, Generic, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Final, Generic, TypeAlias, TypedDict, TypeVar, overload, type_check_only from ..rfc7517 import KeySet from .claims import JWTClaims diff --git a/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi b/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi index 5614f93883bc..146fffd4a7e7 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Collection, Mapping -from typing import overload -from typing_extensions import TypeAlias, deprecated +from typing import TypeAlias, overload +from typing_extensions import deprecated from authlib.oauth2 import JsonRequest, OAuth2Error, OAuth2Request from authlib.oauth2.rfc6749 import BaseGrant, ClientMixin diff --git a/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi b/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi index e121a2d0149f..1ee7e57abbb9 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi @@ -1,6 +1,6 @@ from collections.abc import Collection from logging import Logger -from typing_extensions import TypeAlias +from typing import TypeAlias from authlib.oauth2 import OAuth2Request from authlib.oauth2.rfc6749 import AuthorizationEndpointMixin, BaseGrant, ClientMixin, TokenEndpointMixin diff --git a/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi b/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi index 4ff9c136ef1b..82cd47e1c2d3 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Collection -from typing_extensions import TypeAlias +from typing import TypeAlias from authlib.oauth2 import OAuth2Request from authlib.oauth2.rfc6749 import ClientMixin diff --git a/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi b/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi index ed025a1bbdc5..670fc27460b8 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing_extensions import TypeAlias +from typing import TypeAlias from authlib.oauth2.rfc6749 import BaseGrant, TokenEndpointMixin, TokenMixin diff --git a/stubs/Deprecated/deprecated/classic.pyi b/stubs/Deprecated/deprecated/classic.pyi index 3f4a2b87e87d..99d2bd6e9bfa 100644 --- a/stubs/Deprecated/deprecated/classic.pyi +++ b/stubs/Deprecated/deprecated/classic.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Any, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias, TypeVar, overload _F = TypeVar("_F", bound=Callable[..., Any]) _Actions: TypeAlias = Literal["default", "error", "ignore", "always", "module", "once"] diff --git a/stubs/Flask-Cors/flask_cors/core.pyi b/stubs/Flask-Cors/flask_cors/core.pyi index f2ae68861d68..3fe8b4d2bca7 100644 --- a/stubs/Flask-Cors/flask_cors/core.pyi +++ b/stubs/Flask-Cors/flask_cors/core.pyi @@ -2,8 +2,7 @@ from collections.abc import Iterable from datetime import timedelta from logging import Logger from re import Match, Pattern -from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only import flask diff --git a/stubs/Flask-Migrate/flask_migrate/__init__.pyi b/stubs/Flask-Migrate/flask_migrate/__init__.pyi index 41c0f76741fd..ff7aef1bb881 100644 --- a/stubs/Flask-Migrate/flask_migrate/__init__.pyi +++ b/stubs/Flask-Migrate/flask_migrate/__init__.pyi @@ -5,8 +5,8 @@ from _typeshed import StrPath, SupportsFlush, SupportsKeysAndGetItem, SupportsWr from argparse import Namespace from collections.abc import Callable, Iterable, Sequence from logging import Logger -from typing import Any, Protocol, TypeVar, type_check_only -from typing_extensions import ParamSpec, TypeAlias +from typing import Any, Protocol, TypeAlias, TypeVar, type_check_only +from typing_extensions import ParamSpec import flask from flask_sqlalchemy import SQLAlchemy diff --git a/stubs/Flask-SocketIO/flask_socketio/__init__.pyi b/stubs/Flask-SocketIO/flask_socketio/__init__.pyi index 8fa0c25a66fc..7da0298fcc76 100644 --- a/stubs/Flask-SocketIO/flask_socketio/__init__.pyi +++ b/stubs/Flask-SocketIO/flask_socketio/__init__.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from collections.abc import Callable from logging import Logger from threading import Thread -from typing import Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, TypeAlias, Unpack +from typing import Any, Literal, Protocol, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, Unpack from flask import Flask from flask.testing import FlaskClient diff --git a/stubs/Markdown/markdown/treeprocessors.pyi b/stubs/Markdown/markdown/treeprocessors.pyi index 2648d02d213b..343896f9bb62 100644 --- a/stubs/Markdown/markdown/treeprocessors.pyi +++ b/stubs/Markdown/markdown/treeprocessors.pyi @@ -1,6 +1,5 @@ from re import Pattern -from typing import ClassVar -from typing_extensions import TypeGuard +from typing import ClassVar, TypeGuard from xml.etree.ElementTree import Element from markdown import util diff --git a/stubs/Markdown/markdown/util.pyi b/stubs/Markdown/markdown/util.pyi index f30f9e08432c..98b17d79dfdc 100644 --- a/stubs/Markdown/markdown/util.pyi +++ b/stubs/Markdown/markdown/util.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Iterator from re import Pattern from typing import Final, Generic, TypedDict, TypeVar, overload, type_check_only @@ -19,13 +18,9 @@ HTML_PLACEHOLDER_RE: Final[Pattern[str]] TAG_PLACEHOLDER: Final[str] RTL_BIDI_RANGES: Final[tuple[tuple[str, str], tuple[str, str]]] -if sys.version_info >= (3, 10): - from importlib import metadata - def get_installed_extensions() -> metadata.EntryPoints: ... - -else: - def get_installed_extensions(): ... +from importlib import metadata +def get_installed_extensions() -> metadata.EntryPoints: ... def deprecated(message: str, stacklevel: int = 2): ... @overload def parseBoolValue(value: str) -> bool: ... diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi index 08bb2b7b9529..b7e51fe29f27 100644 --- a/stubs/PyAutoGUI/pyautogui/__init__.pyi +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -2,8 +2,8 @@ import contextlib from _typeshed import ConvertibleToInt from collections.abc import Callable, Iterable, Sequence from datetime import datetime -from typing import Final, NamedTuple, SupportsIndex, SupportsInt, TypeVar -from typing_extensions import ParamSpec, TypeAlias +from typing import Final, NamedTuple, SupportsIndex, SupportsInt, TypeAlias, TypeVar +from typing_extensions import ParamSpec from pyscreeze import ( center as center, diff --git a/stubs/PyMySQL/pymysql/converters.pyi b/stubs/PyMySQL/pymysql/converters.pyi index 2a8eaf1c8fe7..e7a80135d612 100644 --- a/stubs/PyMySQL/pymysql/converters.pyi +++ b/stubs/PyMySQL/pymysql/converters.pyi @@ -4,8 +4,8 @@ import time from _typeshed import Unused from collections.abc import Callable, Mapping, Sequence from decimal import Decimal -from typing import Any, NoReturn, TypeVar -from typing_extensions import TypeAlias, deprecated +from typing import Any, NoReturn, TypeAlias, TypeVar +from typing_extensions import deprecated _EscaperMapping: TypeAlias = Mapping[type[object], Callable[..., str]] | None _T = TypeVar("_T") diff --git a/stubs/PyScreeze/pyscreeze/__init__.pyi b/stubs/PyScreeze/pyscreeze/__init__.pyi index 1405bfba0f23..af512a883019 100644 --- a/stubs/PyScreeze/pyscreeze/__init__.pyi +++ b/stubs/PyScreeze/pyscreeze/__init__.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ConvertibleToFloat, Incomplete, StrOrBytesPath, Unused from collections.abc import Callable, Generator -from typing import Final, NamedTuple, TypeVar, overload -from typing_extensions import ParamSpec, TypeAlias +from typing import Final, NamedTuple, TypeAlias, TypeVar, overload +from typing_extensions import ParamSpec from PIL import Image diff --git a/stubs/PySocks/socks.pyi b/stubs/PySocks/socks.pyi index 931a8be77d8e..cee5046615a1 100644 --- a/stubs/PySocks/socks.pyi +++ b/stubs/PySocks/socks.pyi @@ -3,8 +3,8 @@ import socket import types from _typeshed import ReadableBuffer from collections.abc import Callable, Iterable, Mapping -from typing import Final, TypeVar, overload -from typing_extensions import ParamSpec, TypeAlias +from typing import Final, TypeAlias, TypeVar, overload +from typing_extensions import ParamSpec __version__: Final[str] diff --git a/stubs/PyYAML/yaml/cyaml.pyi b/stubs/PyYAML/yaml/cyaml.pyi index f3642b6fa27e..abe297bd4da1 100644 --- a/stubs/PyYAML/yaml/cyaml.pyi +++ b/stubs/PyYAML/yaml/cyaml.pyi @@ -1,7 +1,6 @@ from _typeshed import SupportsRead from collections.abc import Mapping, Sequence -from typing import IO, Any -from typing_extensions import TypeAlias +from typing import IO, Any, TypeAlias from ._yaml import CEmitter, CParser from .constructor import BaseConstructor, FullConstructor, SafeConstructor, UnsafeConstructor diff --git a/stubs/PyYAML/yaml/dumper.pyi b/stubs/PyYAML/yaml/dumper.pyi index f40d9db52e8f..e7b18733101d 100644 --- a/stubs/PyYAML/yaml/dumper.pyi +++ b/stubs/PyYAML/yaml/dumper.pyi @@ -1,6 +1,5 @@ from collections.abc import Mapping -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from yaml.emitter import Emitter from yaml.representer import BaseRepresenter, Representer, SafeRepresenter diff --git a/stubs/PyYAML/yaml/loader.pyi b/stubs/PyYAML/yaml/loader.pyi index c3944411ca29..5f29f390c2e0 100644 --- a/stubs/PyYAML/yaml/loader.pyi +++ b/stubs/PyYAML/yaml/loader.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeAlias +from typing import TypeAlias from yaml.composer import Composer from yaml.constructor import BaseConstructor, Constructor, FullConstructor, SafeConstructor diff --git a/stubs/PyYAML/yaml/reader.pyi b/stubs/PyYAML/yaml/reader.pyi index a642be1b88bc..84a0e36e2bee 100644 --- a/stubs/PyYAML/yaml/reader.pyi +++ b/stubs/PyYAML/yaml/reader.pyi @@ -1,6 +1,5 @@ from _typeshed import SupportsRead -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from yaml.error import YAMLError diff --git a/stubs/Pygments/pygments/plugin.pyi b/stubs/Pygments/pygments/plugin.pyi index 25253818d781..cb4a0f807cda 100644 --- a/stubs/Pygments/pygments/plugin.pyi +++ b/stubs/Pygments/pygments/plugin.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import Incomplete from collections.abc import Generator @@ -12,15 +11,9 @@ FORMATTER_ENTRY_POINT: str STYLE_ENTRY_POINT: str FILTER_ENTRY_POINT: str -if sys.version_info >= (3, 10): - from importlib.metadata import EntryPoints - def iter_entry_points(group_name: str) -> EntryPoints: ... - -else: - from importlib.metadata import EntryPoint - - def iter_entry_points(group_name: str) -> tuple[EntryPoint, ...] | list[EntryPoint]: ... +from importlib.metadata import EntryPoints +def iter_entry_points(group_name: str) -> EntryPoints: ... def find_plugin_lexers() -> Generator[type[Lexer]]: ... def find_plugin_formatters() -> Generator[tuple[str, type[Formatter[Incomplete]]]]: ... def find_plugin_styles() -> Generator[tuple[str, type[Style]]]: ... diff --git a/stubs/RPi.GPIO/RPi/GPIO/__init__.pyi b/stubs/RPi.GPIO/RPi/GPIO/__init__.pyi index 861eb9a170da..649e41573f28 100644 --- a/stubs/RPi.GPIO/RPi/GPIO/__init__.pyi +++ b/stubs/RPi.GPIO/RPi/GPIO/__init__.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Final, Literal, TypedDict -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias, TypedDict class _RPi_Info(TypedDict): P1_REVISION: int diff --git a/stubs/WTForms/wtforms/fields/choices.pyi b/stubs/WTForms/wtforms/fields/choices.pyi index 06f160738fb2..fd7ee6e4fe0e 100644 --- a/stubs/WTForms/wtforms/fields/choices.pyi +++ b/stubs/WTForms/wtforms/fields/choices.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Iterable, Iterator, Sequence -from typing import Any -from typing_extensions import Self, TypeAlias +from typing import Any, TypeAlias +from typing_extensions import Self from wtforms.fields.core import Field, _Filter, _FormT, _Validator, _Widget from wtforms.form import BaseForm diff --git a/stubs/WTForms/wtforms/fields/core.pyi b/stubs/WTForms/wtforms/fields/core.pyi index 49966fe751cb..101f31fc03c6 100644 --- a/stubs/WTForms/wtforms/fields/core.pyi +++ b/stubs/WTForms/wtforms/fields/core.pyi @@ -1,7 +1,7 @@ from builtins import type as _type # type is being shadowed in Field from collections.abc import Callable, Iterable, Sequence -from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Generic, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self from markupsafe import Markup from wtforms.form import BaseForm diff --git a/stubs/WTForms/wtforms/form.pyi b/stubs/WTForms/wtforms/form.pyi index 7c47bfe5644a..a8337d394696 100644 --- a/stubs/WTForms/wtforms/form.pyi +++ b/stubs/WTForms/wtforms/form.pyi @@ -1,7 +1,6 @@ from _typeshed import SupportsItems from collections.abc import Iterable, Iterator, Mapping, Sequence -from typing import Any, ClassVar, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Protocol, TypeAlias, TypeVar, overload, type_check_only from wtforms.fields.core import Field, UnboundField from wtforms.meta import DefaultMeta, _MultiDictLike diff --git a/stubs/WTForms/wtforms/meta.pyi b/stubs/WTForms/wtforms/meta.pyi index e90a6b4fc066..1ab9c382f8ea 100644 --- a/stubs/WTForms/wtforms/meta.pyi +++ b/stubs/WTForms/wtforms/meta.pyi @@ -1,7 +1,6 @@ from _typeshed import SupportsItems from collections.abc import Collection, Iterator, MutableMapping -from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only from markupsafe import Markup from wtforms.fields.core import Field, UnboundField diff --git a/stubs/WebOb/webob/_types.pyi b/stubs/WebOb/webob/_types.pyi index 08fdc54b3dd6..56557e82afcd 100644 --- a/stubs/WebOb/webob/_types.pyi +++ b/stubs/WebOb/webob/_types.pyi @@ -1,5 +1,4 @@ -from typing import Protocol, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Protocol, TypeAlias, TypeVar, overload _T = TypeVar("_T") _GetterReturnType_co = TypeVar("_GetterReturnType_co", covariant=True) diff --git a/stubs/WebOb/webob/acceptparse.pyi b/stubs/WebOb/webob/acceptparse.pyi index 069564e86749..30f6a593c5b1 100644 --- a/stubs/WebOb/webob/acceptparse.pyi +++ b/stubs/WebOb/webob/acceptparse.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsItems from collections.abc import Callable, Iterable, Iterator, Sequence -from typing import Any, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Literal, NamedTuple, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self from webob._types import AsymmetricPropertyWithDelete diff --git a/stubs/WebOb/webob/cookies.pyi b/stubs/WebOb/webob/cookies.pyi index 5846b68d9e14..29db78664067 100644 --- a/stubs/WebOb/webob/cookies.pyi +++ b/stubs/WebOb/webob/cookies.pyi @@ -3,8 +3,7 @@ from _typeshed.wsgi import WSGIEnvironment from collections.abc import Collection, ItemsView, Iterator, KeysView, MutableMapping, ValuesView from datetime import date, datetime, timedelta from time import _TimeTuple, struct_time -from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only from webob._types import AsymmetricProperty from webob.request import BaseRequest diff --git a/stubs/WebOb/webob/dec.pyi b/stubs/WebOb/webob/dec.pyi index 4b5198a46a72..eabac648b73d 100644 --- a/stubs/WebOb/webob/dec.pyi +++ b/stubs/WebOb/webob/dec.pyi @@ -1,7 +1,7 @@ from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment from collections.abc import Callable, Iterable, Mapping -from typing import Any, Generic, overload, type_check_only -from typing_extensions import Concatenate, Never, ParamSpec, Self, TypeAlias, TypeVar +from typing import Any, Concatenate, Generic, TypeAlias, overload, type_check_only +from typing_extensions import Never, ParamSpec, Self, TypeVar from webob.request import BaseRequest, Request from webob.response import Response diff --git a/stubs/WebOb/webob/descriptors.pyi b/stubs/WebOb/webob/descriptors.pyi index b9c3e5aff2ec..e79e5d78d35b 100644 --- a/stubs/WebOb/webob/descriptors.pyi +++ b/stubs/WebOb/webob/descriptors.pyi @@ -1,8 +1,7 @@ from collections.abc import Callable, Iterable from datetime import date, datetime, timedelta from time import _TimeTuple, struct_time -from typing import Any, NamedTuple, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, NamedTuple, TypeAlias, TypeVar, overload from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete from webob.byterange import ContentRange, Range diff --git a/stubs/WebOb/webob/etag.pyi b/stubs/WebOb/webob/etag.pyi index 5f71a2ac1853..f6f5502d55f8 100644 --- a/stubs/WebOb/webob/etag.pyi +++ b/stubs/WebOb/webob/etag.pyi @@ -1,7 +1,6 @@ from collections.abc import Collection from datetime import datetime -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias from webob._types import AsymmetricPropertyWithDelete from webob.response import Response diff --git a/stubs/WebOb/webob/exc.pyi b/stubs/WebOb/webob/exc.pyi index d2cdb2f11ce4..d1671ef356dc 100644 --- a/stubs/WebOb/webob/exc.pyi +++ b/stubs/WebOb/webob/exc.pyi @@ -2,8 +2,8 @@ from _typeshed import SupportsItems, SupportsKeysAndGetItem from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment from collections.abc import Iterable from string import Template -from typing import Any, Literal, Protocol, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Literal, Protocol, TypeAlias, type_check_only +from typing_extensions import Self from webob.response import Response diff --git a/stubs/WebOb/webob/request.pyi b/stubs/WebOb/webob/request.pyi index 310c2101ce98..9cc026a69afe 100644 --- a/stubs/WebOb/webob/request.pyi +++ b/stubs/WebOb/webob/request.pyi @@ -4,8 +4,8 @@ from _typeshed import OptExcInfo, SupportsKeysAndGetItem, SupportsNoArgReadline, from _typeshed.wsgi import WSGIApplication, WSGIEnvironment from collections.abc import Iterable, Mapping from re import Pattern -from typing import IO, Any, ClassVar, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import IO, Any, ClassVar, Literal, Protocol, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Self from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete from webob.acceptparse import _AcceptCharsetProperty, _AcceptEncodingProperty, _AcceptLanguageProperty, _AcceptProperty diff --git a/stubs/WebOb/webob/response.pyi b/stubs/WebOb/webob/response.pyi index 27d1e90dff04..13a308fcc9f3 100644 --- a/stubs/WebOb/webob/response.pyi +++ b/stubs/WebOb/webob/response.pyi @@ -2,8 +2,8 @@ from _typeshed import SupportsItems, SupportsRead from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment from collections.abc import Iterable, Iterator, Sequence from datetime import timedelta -from typing import IO, Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import IO, Any, Literal, Protocol, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Self from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete from webob.byterange import ContentRange diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index 71d2f47024ac..3ad94b0e3be7 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -9,8 +9,7 @@ from _typeshed import ( from asyncio import AbstractEventLoop from collections.abc import Callable from concurrent.futures import Executor -from typing import Literal, overload -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, overload from ..base import AiofilesContextManager from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, AsyncIndirectBufferedIOBase, _UnknownAsyncBinaryIO diff --git a/stubs/assertpy/assertpy/base.pyi b/stubs/assertpy/assertpy/base.pyi index be5db39ff985..56238d4001e3 100644 --- a/stubs/assertpy/assertpy/base.pyi +++ b/stubs/assertpy/assertpy/base.pyi @@ -1,4 +1,5 @@ -from typing_extensions import Self, TypeAlias +from typing import TypeAlias +from typing_extensions import Self __tracebackhide__: bool diff --git a/stubs/assertpy/assertpy/numeric.pyi b/stubs/assertpy/assertpy/numeric.pyi index 725bc4ed4dfb..cb3a0a372531 100644 --- a/stubs/assertpy/assertpy/numeric.pyi +++ b/stubs/assertpy/assertpy/numeric.pyi @@ -1,5 +1,6 @@ from datetime import date -from typing_extensions import Self, TypeAlias +from typing import TypeAlias +from typing_extensions import Self __tracebackhide__: bool diff --git a/stubs/auth0-python/auth0/types.pyi b/stubs/auth0-python/auth0/types.pyi index 385643dc72d0..2d9d79d8cbdb 100644 --- a/stubs/auth0-python/auth0/types.pyi +++ b/stubs/auth0-python/auth0/types.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing_extensions import TypeAlias +from typing import TypeAlias TimeoutType: TypeAlias = float | tuple[float, float] RequestData: TypeAlias = dict[str, Incomplete] | list[Incomplete] diff --git a/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi b/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi index 0105c07dbcd7..d691f30e730f 100644 --- a/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi +++ b/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from logging import Logger -from typing import Final, Literal -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, TypeAlias +from typing_extensions import Self _SampledTrue: TypeAlias = Literal[True, "1", 1] _SampledFalse: TypeAlias = Literal[False, "0", 0] diff --git a/stubs/bleach/bleach/__init__.pyi b/stubs/bleach/bleach/__init__.pyi index 24befbe11fe2..7c31c84d592b 100644 --- a/stubs/bleach/bleach/__init__.pyi +++ b/stubs/bleach/bleach/__init__.pyi @@ -1,5 +1,5 @@ from collections.abc import Container, Iterable -from typing_extensions import TypeAlias +from typing import TypeAlias from .callbacks import _Callback from .css_sanitizer import CSSSanitizer diff --git a/stubs/bleach/bleach/callbacks.pyi b/stubs/bleach/bleach/callbacks.pyi index 2e92a8645cfb..0ea1145fac8f 100644 --- a/stubs/bleach/bleach/callbacks.pyi +++ b/stubs/bleach/bleach/callbacks.pyi @@ -1,6 +1,5 @@ from collections.abc import MutableMapping -from typing import Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Protocol, TypeAlias, type_check_only from bleach import _HTMLAttrKey diff --git a/stubs/bleach/bleach/linkifier.pyi b/stubs/bleach/bleach/linkifier.pyi index e6ec5d0ae35a..35d311f13dd1 100644 --- a/stubs/bleach/bleach/linkifier.pyi +++ b/stubs/bleach/bleach/linkifier.pyi @@ -1,7 +1,6 @@ from collections.abc import Container, Iterable, Iterator, Sequence from re import Pattern -from typing import Any, Final -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias from html5lib.filters.base import Filter from html5lib.treewalkers.base import TreeWalker diff --git a/stubs/bleach/bleach/sanitizer.pyi b/stubs/bleach/bleach/sanitizer.pyi index 897c17f8a27b..8484b419fd4f 100644 --- a/stubs/bleach/bleach/sanitizer.pyi +++ b/stubs/bleach/bleach/sanitizer.pyi @@ -1,7 +1,6 @@ from collections.abc import Callable, Container, Iterable, Iterator from re import Pattern -from typing import Final, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Final, Protocol, TypeAlias, type_check_only from html5lib.filters.base import Filter from html5lib.filters.sanitizer import Filter as SanitizerFilter diff --git a/stubs/boltons/boltons/dictutils.pyi b/stubs/boltons/boltons/dictutils.pyi index 5e609ef9af13..386585975a2b 100644 --- a/stubs/boltons/boltons/dictutils.pyi +++ b/stubs/boltons/boltons/dictutils.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsKeysAndGetItem from collections.abc import Generator, ItemsView, Iterable, KeysView, ValuesView -from typing import NoReturn, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import NoReturn, TypeAlias, TypeVar, overload +from typing_extensions import Self _KT = TypeVar("_KT") _VT = TypeVar("_VT") diff --git a/stubs/boltons/boltons/listutils.pyi b/stubs/boltons/boltons/listutils.pyi index 35b8332ff14f..33be50272087 100644 --- a/stubs/boltons/boltons/listutils.pyi +++ b/stubs/boltons/boltons/listutils.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import SupportsIndex, TypeVar -from typing_extensions import Self, TypeAlias +from typing import SupportsIndex, TypeAlias, TypeVar +from typing_extensions import Self _T = TypeVar("_T") diff --git a/stubs/boltons/boltons/queueutils.pyi b/stubs/boltons/boltons/queueutils.pyi index df8eca210e9d..83c6dd01e8a5 100644 --- a/stubs/boltons/boltons/queueutils.pyi +++ b/stubs/boltons/boltons/queueutils.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeAlias +from typing import TypeAlias class BasePriorityQueue: def __init__(self, **kw) -> None: ... diff --git a/stubs/braintree/braintree/util/generator.pyi b/stubs/braintree/braintree/util/generator.pyi index cfd6c564f19c..03e10a43fede 100644 --- a/stubs/braintree/braintree/util/generator.pyi +++ b/stubs/braintree/braintree/util/generator.pyi @@ -1,7 +1,7 @@ import datetime import decimal from collections.abc import Iterable, Mapping -from typing_extensions import TypeAlias +from typing import TypeAlias integer_types = int text_type = str diff --git a/stubs/cffi/_cffi_backend.pyi b/stubs/cffi/_cffi_backend.pyi index f2856bb90213..e89a2438dc83 100644 --- a/stubs/cffi/_cffi_backend.pyi +++ b/stubs/cffi/_cffi_backend.pyi @@ -2,8 +2,8 @@ import sys import types from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer from collections.abc import Callable, Hashable -from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only +from typing_extensions import Self, disjoint_base _T = TypeVar("_T") diff --git a/stubs/cffi/cffi/api.pyi b/stubs/cffi/cffi/api.pyi index 07e9ffccab35..1772b897ab11 100644 --- a/stubs/cffi/cffi/api.pyi +++ b/stubs/cffi/cffi/api.pyi @@ -2,8 +2,7 @@ import sys import types from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Callable, Hashable -from typing import Any, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias, TypeVar, overload import _cffi_backend from setuptools._distutils.extension import Extension diff --git a/stubs/cffi/cffi/recompiler.pyi b/stubs/cffi/cffi/recompiler.pyi index 729975b862db..f95c84932278 100644 --- a/stubs/cffi/cffi/recompiler.pyi +++ b/stubs/cffi/cffi/recompiler.pyi @@ -1,7 +1,6 @@ import io from _typeshed import Incomplete, StrPath -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias from .cffi_opcode import * from .error import VerificationError as VerificationError diff --git a/stubs/cffi/cffi/verifier.pyi b/stubs/cffi/cffi/verifier.pyi index 6901a0a3ba70..5c8b8d733fbc 100644 --- a/stubs/cffi/cffi/verifier.pyi +++ b/stubs/cffi/cffi/verifier.pyi @@ -1,8 +1,7 @@ import io import os from _typeshed import Incomplete, StrPath -from typing import AnyStr -from typing_extensions import TypeAlias +from typing import AnyStr, TypeAlias NativeIO: TypeAlias = io.StringIO diff --git a/stubs/channels/channels/layers.pyi b/stubs/channels/channels/layers.pyi index 1fae3a125aae..e709d98398c7 100644 --- a/stubs/channels/channels/layers.pyi +++ b/stubs/channels/channels/layers.pyi @@ -1,7 +1,7 @@ import asyncio from re import Pattern -from typing import Any, ClassVar, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, ClassVar, TypeAlias, overload +from typing_extensions import deprecated class ChannelLayerManager: backends: dict[str, BaseChannelLayer] diff --git a/stubs/channels/channels/testing/live.pyi b/stubs/channels/channels/testing/live.pyi index b2cac0ae6260..e9f52d6e5e22 100644 --- a/stubs/channels/channels/testing/live.pyi +++ b/stubs/channels/channels/testing/live.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Any, ClassVar -from typing_extensions import TypeAlias +from typing import Any, ClassVar, TypeAlias from channels.routing import ProtocolTypeRouter from channels.utils import _ChannelApplication diff --git a/stubs/channels/channels/testing/websocket.pyi b/stubs/channels/channels/testing/websocket.pyi index f303e90e5c39..db743bed5d55 100644 --- a/stubs/channels/channels/testing/websocket.pyi +++ b/stubs/channels/channels/testing/websocket.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import Any, Literal, TypedDict, overload, type_check_only -from typing_extensions import NotRequired, TypeAlias +from typing import Any, Literal, TypeAlias, TypedDict, overload, type_check_only +from typing_extensions import NotRequired from asgiref.typing import ASGIVersions from channels.testing.application import ApplicationCommunicator diff --git a/stubs/channels/channels/utils.pyi b/stubs/channels/channels/utils.pyi index 0e0818abbbb6..80b4dff1a902 100644 --- a/stubs/channels/channels/utils.pyi +++ b/stubs/channels/channels/utils.pyi @@ -1,6 +1,5 @@ from collections.abc import Awaitable, Callable -from typing import Any, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, type_check_only from asgiref.typing import ASGIApplication, ASGIReceiveCallable diff --git a/stubs/click-log/click_log/options.pyi b/stubs/click-log/click_log/options.pyi index f5fa67d96eac..cea9e5edd8ea 100644 --- a/stubs/click-log/click_log/options.pyi +++ b/stubs/click-log/click_log/options.pyi @@ -1,7 +1,6 @@ import logging from collections.abc import Callable -from typing import Any, TypeVar -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, TypeVar import click diff --git a/stubs/click-web/click_web/resources/input_fields.pyi b/stubs/click-web/click_web/resources/input_fields.pyi index ec2ede4d14b2..a77853d9f5df 100644 --- a/stubs/click-web/click_web/resources/input_fields.pyi +++ b/stubs/click-web/click_web/resources/input_fields.pyi @@ -1,4 +1,3 @@ -import sys from typing import Any, ClassVar, Final import click @@ -47,10 +46,7 @@ class BaseInput: def _build_name(self, name: str) -> str: ... class ChoiceInput(BaseInput): - if sys.version_info >= (3, 10): - param_type_cls: type[click.Choice[Any]] - else: - param_type_cls: type[click.Choice] + param_type_cls: type[click.Choice[Any]] class FlagInput(BaseInput): param_type_cls: None diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index 284ea97814ca..e32fec9d33c3 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -3,8 +3,7 @@ from _typeshed import SupportsWrite from collections.abc import Callable, Sequence from re import Pattern from types import TracebackType -from typing import Any, ClassVar, TextIO -from typing_extensions import TypeAlias +from typing import Any, ClassVar, TextIO, TypeAlias if sys.platform == "win32": from .winterm import WinTerm diff --git a/stubs/colorful/colorful/core.pyi b/stubs/colorful/colorful/core.pyi index 93bce78dff43..2e79d5015818 100644 --- a/stubs/colorful/colorful/core.pyi +++ b/stubs/colorful/colorful/core.pyi @@ -4,8 +4,8 @@ from _typeshed import SupportsGetItem, SupportsItems, SupportsWrite # as a type annotation or type alias. from builtins import str as _str from collections.abc import Iterator -from typing import Any, Final, Literal -from typing_extensions import LiteralString, Self, TypeAlias +from typing import Any, Final, Literal, TypeAlias +from typing_extensions import LiteralString, Self # Custom type helpers _ColorModeType: TypeAlias = Literal[0, 8, 16, 256, 16777215] diff --git a/stubs/croniter/croniter/croniter.pyi b/stubs/croniter/croniter/croniter.pyi index 7dd721ddbb2a..da32a76d372c 100644 --- a/stubs/croniter/croniter/croniter.pyi +++ b/stubs/croniter/croniter/croniter.pyi @@ -3,8 +3,8 @@ from _typeshed import Unused from collections import OrderedDict from collections.abc import Generator from re import Match, Pattern -from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Never, Self, TypeAlias +from typing import Any, Final, Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Never, Self _R_co = TypeVar("_R_co", float, datetime.datetime, default=float, covariant=True) _R2_co = TypeVar("_R2_co", float, datetime.datetime, covariant=True) diff --git a/stubs/dateparser/dateparser/__init__.pyi b/stubs/dateparser/dateparser/__init__.pyi index cec3cb7b8a26..8f20829b573c 100644 --- a/stubs/dateparser/dateparser/__init__.pyi +++ b/stubs/dateparser/dateparser/__init__.pyi @@ -1,6 +1,5 @@ import datetime -from typing import Literal, TypedDict, type_check_only -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, TypedDict, type_check_only from .date import DateDataParser, _DetectLanguagesFunction diff --git a/stubs/dateparser/dateparser/date.pyi b/stubs/dateparser/dateparser/date.pyi index c26e35566218..35a45429f569 100644 --- a/stubs/dateparser/dateparser/date.pyi +++ b/stubs/dateparser/dateparser/date.pyi @@ -2,8 +2,7 @@ import collections from collections.abc import Callable, Iterable, Iterator from datetime import datetime, tzinfo from re import Pattern -from typing import ClassVar, Final, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias, overload from dateparser import _Settings from dateparser.conf import Settings diff --git a/stubs/dirhash/dirhash/__init__.pyi b/stubs/dirhash/dirhash/__init__.pyi index 5a24f69dc17c..e708f597c636 100644 --- a/stubs/dirhash/dirhash/__init__.pyi +++ b/stubs/dirhash/dirhash/__init__.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator, Iterable from os import PathLike -from typing import TypeVar -from typing_extensions import TypeAlias +from typing import TypeAlias, TypeVar _DirNode: TypeAlias = Incomplete # scantree.DirNode _RecursionPath: TypeAlias = Incomplete # scantree.RecursionPath diff --git a/stubs/django-filter/django_filters/fields.pyi b/stubs/django-filter/django_filters/fields.pyi index 7920f9878c9c..0b72e5ebb10f 100644 --- a/stubs/django-filter/django_filters/fields.pyi +++ b/stubs/django-filter/django_filters/fields.pyi @@ -1,7 +1,6 @@ from _typeshed import Unused from collections.abc import Callable, Iterable, Mapping, Sequence -from typing import Any, NamedTuple -from typing_extensions import TypeAlias +from typing import Any, NamedTuple, TypeAlias from django import forms from django.db.models import Choices diff --git a/stubs/django-filter/django_filters/rest_framework/backends.pyi b/stubs/django-filter/django_filters/rest_framework/backends.pyi index b45372d919af..c58bf4c98260 100644 --- a/stubs/django-filter/django_filters/rest_framework/backends.pyi +++ b/stubs/django-filter/django_filters/rest_framework/backends.pyi @@ -1,5 +1,4 @@ -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from django.db.models import QuerySet from django.http import HttpRequest diff --git a/stubs/django-import-export/import_export/admin.pyi b/stubs/django-import-export/import_export/admin.pyi index 9f02027f90cc..070dbd26720e 100644 --- a/stubs/django-import-export/import_export/admin.pyi +++ b/stubs/django-import-export/import_export/admin.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Sequence from logging import Logger -from typing import Any, Literal, TypeVar -from typing_extensions import TypeAlias, deprecated +from typing import Any, Literal, TypeAlias, TypeVar +from typing_extensions import deprecated from django.contrib import admin from django.contrib.admin.helpers import ActionForm diff --git a/stubs/django-import-export/import_export/formats/base_formats.pyi b/stubs/django-import-export/import_export/formats/base_formats.pyi index a2206683b830..17c7f4a60ad4 100644 --- a/stubs/django-import-export/import_export/formats/base_formats.pyi +++ b/stubs/django-import-export/import_export/formats/base_formats.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, ReadableBuffer from logging import Logger -from typing import IO, Any, ClassVar -from typing_extensions import Self, TypeAlias +from typing import IO, Any, ClassVar, TypeAlias +from typing_extensions import Self Dataset: TypeAlias = Incomplete # tablib.Dataset diff --git a/stubs/django-import-export/import_export/instance_loaders.pyi b/stubs/django-import-export/import_export/instance_loaders.pyi index 433eb9f71796..e2840f83aba9 100644 --- a/stubs/django-import-export/import_export/instance_loaders.pyi +++ b/stubs/django-import-export/import_export/instance_loaders.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from django.db.models import Model, QuerySet diff --git a/stubs/django-import-export/import_export/mixins.pyi b/stubs/django-import-export/import_export/mixins.pyi index 947753288e53..7c5bd003e4f5 100644 --- a/stubs/django-import-export/import_export/mixins.pyi +++ b/stubs/django-import-export/import_export/mixins.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsGetItem from logging import Logger -from typing import Any, Generic, TypeVar -from typing_extensions import TypeAlias, deprecated +from typing import Any, Generic, TypeAlias, TypeVar +from typing_extensions import deprecated from django.db.models import Model, QuerySet from django.forms import BaseForm, Form diff --git a/stubs/django-import-export/import_export/resources.pyi b/stubs/django-import-export/import_export/resources.pyi index 1f62c6b74aa2..e1fa7ca37924 100644 --- a/stubs/django-import-export/import_export/resources.pyi +++ b/stubs/django-import-export/import_export/resources.pyi @@ -3,8 +3,8 @@ from collections import OrderedDict from collections.abc import Iterator, Sequence from functools import partial from logging import Logger -from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeVar, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeAlias, TypeVar, overload +from typing_extensions import deprecated from django.db.models import Field as DjangoField, Model, QuerySet from django.utils.safestring import SafeString diff --git a/stubs/django-import-export/import_export/results.pyi b/stubs/django-import-export/import_export/results.pyi index 509d94436403..5d108fbf6d4e 100644 --- a/stubs/django-import-export/import_export/results.pyi +++ b/stubs/django-import-export/import_export/results.pyi @@ -2,8 +2,7 @@ from _typeshed import Incomplete from collections import OrderedDict from collections.abc import Iterator from functools import cached_property -from typing import Any, ClassVar, Literal -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Literal, TypeAlias from django.core.exceptions import ValidationError from django.db.models import Model diff --git a/stubs/docker/docker/_types.pyi b/stubs/docker/docker/_types.pyi index 21b38dcdb666..5500470c6fa5 100644 --- a/stubs/docker/docker/_types.pyi +++ b/stubs/docker/docker/_types.pyi @@ -2,8 +2,8 @@ # This does not match a module in docker-py. from pathlib import Path -from typing import TypedDict, type_check_only -from typing_extensions import NotRequired, TypeAlias +from typing import TypeAlias, TypedDict, type_check_only +from typing_extensions import NotRequired # Type alias for JSON, explained at: # https://github.com/python/typing/issues/182#issuecomment-1320974824. diff --git a/stubs/docker/docker/api/container.pyi b/stubs/docker/docker/api/container.pyi index fb676cbb3e0c..07f153efad59 100644 --- a/stubs/docker/docker/api/container.pyi +++ b/stubs/docker/docker/api/container.pyi @@ -1,7 +1,6 @@ import datetime from _typeshed import Incomplete -from typing import Any, Literal, TypedDict, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias, TypedDict, overload, type_check_only from docker._types import WaitContainerResponse from docker.types.daemon import CancellableStream diff --git a/stubs/docker/docker/api/network.pyi b/stubs/docker/docker/api/network.pyi index 1441ff496c6d..8443762babe2 100644 --- a/stubs/docker/docker/api/network.pyi +++ b/stubs/docker/docker/api/network.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterable -from typing import Any, Literal, TypedDict, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias, TypedDict, type_check_only from docker.types import IPAMConfig diff --git a/stubs/docker/docker/models/images.pyi b/stubs/docker/docker/models/images.pyi index cf1e54ae0cea..d69e96cf4c0b 100644 --- a/stubs/docker/docker/models/images.pyi +++ b/stubs/docker/docker/models/images.pyi @@ -1,8 +1,7 @@ from _typeshed import SupportsRead from collections.abc import Iterator from io import StringIO -from typing import IO, Any, Literal, TypedDict, overload, type_check_only -from typing_extensions import TypeAlias +from typing import IO, Any, Literal, TypeAlias, TypedDict, overload, type_check_only from docker._types import JSON diff --git a/stubs/docker/docker/transport/npipesocket.pyi b/stubs/docker/docker/transport/npipesocket.pyi index 086bb3346bcc..e7cc2538c8e3 100644 --- a/stubs/docker/docker/transport/npipesocket.pyi +++ b/stubs/docker/docker/transport/npipesocket.pyi @@ -1,7 +1,6 @@ import io from _typeshed import ReadableBuffer -from typing import Any, Literal, NoReturn -from typing_extensions import TypeAlias +from typing import Any, Literal, NoReturn, TypeAlias cERROR_PIPE_BUSY: int cSECURITY_SQOS_PRESENT: int diff --git a/stubs/dockerfile-parse/dockerfile_parse/util.pyi b/stubs/dockerfile-parse/dockerfile_parse/util.pyi index 5ad32c3780b2..ca1f4086b290 100644 --- a/stubs/dockerfile-parse/dockerfile_parse/util.pyi +++ b/stubs/dockerfile-parse/dockerfile_parse/util.pyi @@ -1,7 +1,6 @@ from collections.abc import Generator, Mapping, MutableMapping from io import StringIO -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias def b2u(string: bytes | str) -> str: ... def u2b(string: str | bytes) -> bytes: ... diff --git a/stubs/docutils/docutils/examples.pyi b/stubs/docutils/docutils/examples.pyi index 42dd8c152903..89912cd84d1f 100644 --- a/stubs/docutils/docutils/examples.pyi +++ b/stubs/docutils/docutils/examples.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete, StrPath -from typing import Literal, overload -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, overload from docutils.core import Publisher from docutils.nodes import document diff --git a/stubs/docutils/docutils/nodes.pyi b/stubs/docutils/docutils/nodes.pyi index 82a5fba393a1..ef1b43b34b6d 100644 --- a/stubs/docutils/docutils/nodes.pyi +++ b/stubs/docutils/docutils/nodes.pyi @@ -4,8 +4,8 @@ from _typeshed import Incomplete from abc import abstractmethod from collections import Counter from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence -from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self, deprecated from docutils.frontend import Values from docutils.transforms import Transform, Transformer diff --git a/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi b/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi index c46e90c800b7..a9b7a2c2956e 100644 --- a/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi +++ b/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi @@ -1,5 +1,4 @@ -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias from docutils import parsers diff --git a/stubs/docutils/docutils/parsers/rst/__init__.pyi b/stubs/docutils/docutils/parsers/rst/__init__.pyi index 75f834719d97..2ec7af62d1e1 100644 --- a/stubs/docutils/docutils/parsers/rst/__init__.pyi +++ b/stubs/docutils/docutils/parsers/rst/__init__.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable, Sequence -from typing import Any, ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Final, Literal, TypeAlias from docutils import nodes, parsers from docutils.parsers.rst.states import Inliner, RSTState, RSTStateMachine diff --git a/stubs/docutils/docutils/parsers/rst/directives/body.pyi b/stubs/docutils/docutils/parsers/rst/directives/body.pyi index 75f36f360876..345309e71599 100644 --- a/stubs/docutils/docutils/parsers/rst/directives/body.pyi +++ b/stubs/docutils/docutils/parsers/rst/directives/body.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import ClassVar, Final -from typing_extensions import TypeAlias +from typing import ClassVar, Final, TypeAlias from docutils import nodes from docutils.parsers.rst import Directive diff --git a/stubs/docutils/docutils/parsers/rst/roles.pyi b/stubs/docutils/docutils/parsers/rst/roles.pyi index eb238c6f4905..4697d6982e79 100644 --- a/stubs/docutils/docutils/parsers/rst/roles.pyi +++ b/stubs/docutils/docutils/parsers/rst/roles.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Mapping, Sequence -from typing import Any, Final -from typing_extensions import TypeAlias, deprecated +from typing import Any, Final, TypeAlias +from typing_extensions import deprecated import docutils.parsers.rst.states from docutils import nodes diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index 05e0c556f9f7..d6f7ad79dae4 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -2,8 +2,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable, Sequence from re import Match, Pattern from types import ModuleType, SimpleNamespace as Struct -from typing import Any, ClassVar, Final, NoReturn -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Final, NoReturn, TypeAlias from docutils import ApplicationError, DataError, nodes from docutils.nodes import Node, system_message diff --git a/stubs/docutils/docutils/parsers/rst/tableparser.pyi b/stubs/docutils/docutils/parsers/rst/tableparser.pyi index dfb95bff53f3..ad805b9ccd52 100644 --- a/stubs/docutils/docutils/parsers/rst/tableparser.pyi +++ b/stubs/docutils/docutils/parsers/rst/tableparser.pyi @@ -1,6 +1,5 @@ from re import Pattern -from typing import ClassVar, Final -from typing_extensions import TypeAlias +from typing import ClassVar, Final, TypeAlias from docutils import DataError from docutils.statemachine import StringList diff --git a/stubs/docutils/docutils/statemachine.pyi b/stubs/docutils/docutils/statemachine.pyi index 353b27734915..2a4e88f2879c 100644 --- a/stubs/docutils/docutils/statemachine.pyi +++ b/stubs/docutils/docutils/statemachine.pyi @@ -1,8 +1,8 @@ import sys from collections.abc import Callable, Generator, Iterable, Iterator, Sequence from re import Match, Pattern -from typing import Any, ClassVar, Final, Generic, SupportsIndex, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, Final, Generic, SupportsIndex, TypeAlias, TypeVar, overload +from typing_extensions import Self _T = TypeVar("_T") _Context = TypeVar("_Context") diff --git a/stubs/docutils/docutils/transforms/__init__.pyi b/stubs/docutils/docutils/transforms/__init__.pyi index 3a3732c53e9b..a848d0768f9f 100644 --- a/stubs/docutils/docutils/transforms/__init__.pyi +++ b/stubs/docutils/docutils/transforms/__init__.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterable, Mapping -from typing import Any, ClassVar, Final -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Final, TypeAlias from docutils import ApplicationError, TransformSpec, nodes from docutils.languages import LanguageImporter diff --git a/stubs/docutils/docutils/utils/__init__.pyi b/stubs/docutils/docutils/utils/__init__.pyi index 30b4725712a4..f076c0f2e8d8 100644 --- a/stubs/docutils/docutils/utils/__init__.pyi +++ b/stubs/docutils/docutils/utils/__init__.pyi @@ -2,8 +2,8 @@ import optparse from _typeshed import StrPath, SupportsWrite from collections.abc import Callable, Iterable, Mapping, Sequence from re import Pattern -from typing import Any, Final, Literal, TypeVar -from typing_extensions import TypeAlias, deprecated +from typing import Any, Final, Literal, TypeAlias, TypeVar +from typing_extensions import deprecated from docutils import ApplicationError, DataError, nodes from docutils.frontend import Values diff --git a/stubs/docutils/docutils/utils/code_analyzer.pyi b/stubs/docutils/docutils/utils/code_analyzer.pyi index adbf7b956363..e778c7db6afd 100644 --- a/stubs/docutils/docutils/utils/code_analyzer.pyi +++ b/stubs/docutils/docutils/utils/code_analyzer.pyi @@ -1,6 +1,5 @@ from collections.abc import Generator, Iterable -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias from docutils import ApplicationError diff --git a/stubs/ephem/ephem/_libastro.pyi b/stubs/ephem/ephem/_libastro.pyi index 57f652a23823..e2861e1aacd4 100644 --- a/stubs/ephem/ephem/_libastro.pyi +++ b/stubs/ephem/ephem/_libastro.pyi @@ -1,7 +1,7 @@ from _typeshed import Unused from datetime import datetime as _datetime -from typing import Final, NoReturn, Protocol, TypedDict, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated, disjoint_base +from typing import Final, NoReturn, Protocol, TypeAlias, TypedDict, overload, type_check_only +from typing_extensions import Self, deprecated, disjoint_base _DateInitType: TypeAlias = ( Date diff --git a/stubs/fanstatic/fanstatic/core.pyi b/stubs/fanstatic/fanstatic/core.pyi index c57f58ec8b2a..9197bdd323c2 100644 --- a/stubs/fanstatic/fanstatic/core.pyi +++ b/stubs/fanstatic/fanstatic/core.pyi @@ -2,8 +2,7 @@ from abc import abstractmethod from collections.abc import Callable, Iterable from threading import local from types import ModuleType -from typing import Literal, NewType -from typing_extensions import TypeAlias +from typing import Literal, NewType, TypeAlias from fanstatic.compiler import Compiler, Minifier diff --git a/stubs/flake8-builtins/flake8_builtins.pyi b/stubs/flake8-builtins/flake8_builtins.pyi index 25c003d39648..9e80c36dc14a 100644 --- a/stubs/flake8-builtins/flake8_builtins.pyi +++ b/stubs/flake8-builtins/flake8_builtins.pyi @@ -1,8 +1,7 @@ import ast from argparse import Namespace from collections.abc import Iterator -from typing import ClassVar -from typing_extensions import TypeAlias +from typing import ClassVar, TypeAlias from flake8.options.manager import OptionManager diff --git a/stubs/flake8/flake8/checker.pyi b/stubs/flake8/flake8/checker.pyi index a2e67f9c01cc..d370840cc1b7 100644 --- a/stubs/flake8/flake8/checker.pyi +++ b/stubs/flake8/flake8/checker.pyi @@ -3,8 +3,7 @@ import tokenize from _typeshed import Incomplete from collections.abc import Sequence from logging import Logger -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from .plugins.finder import Checkers, LoadedPlugin from .processor import _LogicalMapping diff --git a/stubs/flake8/flake8/processor.pyi b/stubs/flake8/flake8/processor.pyi index f193a21840be..c2d5c2a58ca2 100644 --- a/stubs/flake8/flake8/processor.pyi +++ b/stubs/flake8/flake8/processor.pyi @@ -4,8 +4,7 @@ from ast import AST from collections.abc import Generator from logging import Logger from tokenize import TokenInfo -from typing import Any, Final -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias from .plugins.finder import LoadedPlugin diff --git a/stubs/fpdf2/fpdf/_fonttools_shims.pyi b/stubs/fpdf2/fpdf/_fonttools_shims.pyi index f68d651014d6..c108a0068ba9 100644 --- a/stubs/fpdf2/fpdf/_fonttools_shims.pyi +++ b/stubs/fpdf2/fpdf/_fonttools_shims.pyi @@ -2,8 +2,7 @@ from abc import ABCMeta, abstractmethod from collections.abc import Mapping from logging import Logger -from typing import Any, Protocol -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias # from fonttools.ttLib.ttGlyphSet class _TTGlyph(Protocol): diff --git a/stubs/fpdf2/fpdf/drawing.pyi b/stubs/fpdf2/fpdf/drawing.pyi index c393f1f7eaa7..73c4c3357068 100644 --- a/stubs/fpdf2/fpdf/drawing.pyi +++ b/stubs/fpdf2/fpdf/drawing.pyi @@ -1,18 +1,12 @@ import decimal -import sys from _typeshed import Incomplete, SupportsWrite from collections import OrderedDict from collections.abc import Callable, Generator, Iterable, Sequence from contextlib import contextmanager from re import Pattern -from typing import Any, ClassVar, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias - -if sys.version_info >= (3, 10): - from types import EllipsisType -else: - # Rely on builtins.ellipsis - from builtins import ellipsis as EllipsisType +from types import EllipsisType +from typing import Any, ClassVar, Literal, NamedTuple, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self from .enums import PathPaintRule from .syntax import Name, Raw diff --git a/stubs/fpdf2/fpdf/encryption.pyi b/stubs/fpdf2/fpdf/encryption.pyi index 3c3edabd53f4..14f133910b61 100644 --- a/stubs/fpdf2/fpdf/encryption.pyi +++ b/stubs/fpdf2/fpdf/encryption.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete, SupportsLenAndGetItem from collections.abc import Generator, Iterable from logging import Logger -from typing import ClassVar, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import ClassVar, Protocol, TypeAlias, TypeVar, overload, type_check_only from .enums import AccessPermission, EncryptionMethod from .fpdf import FPDF diff --git a/stubs/fpdf2/fpdf/enums.pyi b/stubs/fpdf2/fpdf/enums.pyi index 5c11f04e31ce..076d48c0af6b 100644 --- a/stubs/fpdf2/fpdf/enums.pyi +++ b/stubs/fpdf2/fpdf/enums.pyi @@ -2,8 +2,8 @@ from abc import ABC, abstractmethod from collections.abc import Sequence from dataclasses import dataclass from enum import Enum, Flag, IntEnum, IntFlag -from typing import Final, Literal -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, TypeAlias +from typing_extensions import Self from .drawing import DeviceCMYK, DeviceGray, DeviceRGB from .syntax import Name diff --git a/stubs/fpdf2/fpdf/fpdf.pyi b/stubs/fpdf2/fpdf/fpdf.pyi index 820ba83c6b55..9d4f0d8b1f1f 100644 --- a/stubs/fpdf2/fpdf/fpdf.pyi +++ b/stubs/fpdf2/fpdf/fpdf.pyi @@ -5,8 +5,8 @@ from contextlib import _GeneratorContextManager from io import BytesIO from pathlib import PurePath from re import Pattern -from typing import Any, ClassVar, Final, Literal, NamedTuple, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, ClassVar, Final, Literal, NamedTuple, TypeAlias, overload +from typing_extensions import deprecated from fpdf import ViewerPreferences from fpdf.outline import OutlineSection diff --git a/stubs/fpdf2/fpdf/html.pyi b/stubs/fpdf2/fpdf/html.pyi index 8225d7177721..a838697b0d69 100644 --- a/stubs/fpdf2/fpdf/html.pyi +++ b/stubs/fpdf2/fpdf/html.pyi @@ -2,8 +2,7 @@ from _typeshed import Incomplete, SupportsKeysAndGetItem from collections.abc import Callable, Iterable, Mapping from html.parser import HTMLParser from logging import Logger -from typing import ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias from fpdf import FPDF diff --git a/stubs/fpdf2/fpdf/image_datastructures.pyi b/stubs/fpdf2/fpdf/image_datastructures.pyi index 24f3dd65bb7c..a45a50ee8e7b 100644 --- a/stubs/fpdf2/fpdf/image_datastructures.pyi +++ b/stubs/fpdf2/fpdf/image_datastructures.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from dataclasses import dataclass -from typing import Any, Literal -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias from fpdf.enums import Align diff --git a/stubs/fpdf2/fpdf/image_parsing.pyi b/stubs/fpdf2/fpdf/image_parsing.pyi index 67cbe33b7530..0d131c1338b2 100644 --- a/stubs/fpdf2/fpdf/image_parsing.pyi +++ b/stubs/fpdf2/fpdf/image_parsing.pyi @@ -3,8 +3,7 @@ from dataclasses import dataclass from io import BytesIO from logging import Logger from types import TracebackType -from typing import Any, Final, Literal -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, TypeAlias from PIL import Image diff --git a/stubs/fpdf2/fpdf/util.pyi b/stubs/fpdf2/fpdf/util.pyi index f94c5861ad2c..9c98ae361a5f 100644 --- a/stubs/fpdf2/fpdf/util.pyi +++ b/stubs/fpdf2/fpdf/util.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterable -from typing import Any, AnyStr, Final, Literal, NamedTuple -from typing_extensions import TypeAlias +from typing import Any, AnyStr, Final, Literal, NamedTuple, TypeAlias _Unit: TypeAlias = Literal["pt", "mm", "cm", "in"] diff --git a/stubs/gdb/gdb/__init__.pyi b/stubs/gdb/gdb/__init__.pyi index 2c0a12c8b95a..a1b62b9f97a1 100644 --- a/stubs/gdb/gdb/__init__.pyi +++ b/stubs/gdb/gdb/__init__.pyi @@ -6,8 +6,8 @@ import _typeshed import threading from collections.abc import Callable, Iterator, Mapping, Sequence from contextlib import AbstractContextManager -from typing import Any, Final, Generic, Literal, Protocol, TypedDict, TypeVar, final, overload, type_check_only -from typing_extensions import TypeAlias, deprecated, disjoint_base +from typing import Any, Final, Generic, Literal, Protocol, TypeAlias, TypedDict, TypeVar, final, overload, type_check_only +from typing_extensions import deprecated, disjoint_base import gdb.FrameDecorator import gdb.types diff --git a/stubs/gdb/gdb/dap/next.pyi b/stubs/gdb/gdb/dap/next.pyi index c23e4260b950..1418de48f8da 100644 --- a/stubs/gdb/gdb/dap/next.pyi +++ b/stubs/gdb/gdb/dap/next.pyi @@ -1,6 +1,5 @@ from _typeshed import Unused -from typing import Literal, TypedDict, type_check_only -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, TypedDict, type_check_only @type_check_only class _ContinueRequestResult(TypedDict): diff --git a/stubs/gdb/gdb/dap/server.pyi b/stubs/gdb/gdb/dap/server.pyi index 22b8231f7d54..2d74c3cbfef7 100644 --- a/stubs/gdb/gdb/dap/server.pyi +++ b/stubs/gdb/gdb/dap/server.pyi @@ -2,8 +2,7 @@ import threading from _typeshed import Incomplete, SupportsReadline, Unused from collections.abc import Callable from contextlib import AbstractContextManager -from typing import Any, Generic, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Generic, TypeAlias, TypeVar, type_check_only from .io import _SupportsReadAndReadlineBytes, _SupportsWriteAndFlushBytes from .startup import DAPQueue diff --git a/stubs/gdb/gdb/dap/sources.pyi b/stubs/gdb/gdb/dap/sources.pyi index f12bcb3c9ab9..7adee35f2c9b 100644 --- a/stubs/gdb/gdb/dap/sources.pyi +++ b/stubs/gdb/gdb/dap/sources.pyi @@ -1,6 +1,5 @@ from _typeshed import Unused -from typing import TypedDict, type_check_only -from typing_extensions import TypeAlias +from typing import TypeAlias, TypedDict, type_check_only _SourceReferenceID: TypeAlias = int diff --git a/stubs/gdb/gdb/dap/startup.pyi b/stubs/gdb/gdb/dap/startup.pyi index 702f2d8bf77b..107a408901d1 100644 --- a/stubs/gdb/gdb/dap/startup.pyi +++ b/stubs/gdb/gdb/dap/startup.pyi @@ -3,8 +3,7 @@ import io import queue import threading from collections.abc import Callable, Iterable -from typing import Any, ClassVar, TypeVar -from typing_extensions import TypeAlias +from typing import Any, ClassVar, TypeAlias, TypeVar import gdb diff --git a/stubs/geopandas/geopandas/_decorator.pyi b/stubs/geopandas/geopandas/_decorator.pyi index 03f7f23fb12e..6d82bcec9198 100644 --- a/stubs/geopandas/geopandas/_decorator.pyi +++ b/stubs/geopandas/geopandas/_decorator.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import TypeVar, overload -from typing_extensions import TypeAlias +from typing import TypeAlias, TypeVar, overload _AnyCallable: TypeAlias = Callable[..., object] _Func = TypeVar("_Func", bound=_AnyCallable) diff --git a/stubs/geopandas/geopandas/array.pyi b/stubs/geopandas/geopandas/array.pyi index ca9596b43cdf..330174693752 100644 --- a/stubs/geopandas/geopandas/array.pyi +++ b/stubs/geopandas/geopandas/array.pyi @@ -1,8 +1,8 @@ import builtins from _typeshed import Incomplete, Unused from collections.abc import Callable, Collection -from typing import Any, ClassVar, Final, Literal, NoReturn, SupportsIndex, TypeVar, overload -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, ClassVar, Final, Literal, NoReturn, SupportsIndex, TypeAlias, TypeVar, overload +from typing_extensions import Self, deprecated import numpy as np import pandas as pd diff --git a/stubs/geopandas/geopandas/base.pyi b/stubs/geopandas/geopandas/base.pyi index 979c4fcbebef..474ca5e9e3d8 100644 --- a/stubs/geopandas/geopandas/base.pyi +++ b/stubs/geopandas/geopandas/base.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsGetItem from collections.abc import Callable, Collection, Hashable, Iterable, Mapping, Sequence -from typing import Any, Literal, Protocol, SupportsIndex, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only +from typing_extensions import Self, deprecated import numpy as np import pandas as pd diff --git a/stubs/geopandas/geopandas/io/_geoarrow.pyi b/stubs/geopandas/geopandas/io/_geoarrow.pyi index d4a53581cb8b..720cd25f9358 100644 --- a/stubs/geopandas/geopandas/io/_geoarrow.pyi +++ b/stubs/geopandas/geopandas/io/_geoarrow.pyi @@ -7,9 +7,10 @@ from typing import ( Any as _PATable, Literal, Protocol, + TypeAlias, type_check_only, ) -from typing_extensions import CapsuleType, TypeAlias +from typing_extensions import CapsuleType import numpy as np from numpy.typing import NDArray diff --git a/stubs/geopandas/geopandas/io/sql.pyi b/stubs/geopandas/geopandas/io/sql.pyi index d498da5064c9..a68afccb51ed 100644 --- a/stubs/geopandas/geopandas/io/sql.pyi +++ b/stubs/geopandas/geopandas/io/sql.pyi @@ -2,8 +2,7 @@ import sqlite3 from _typeshed import Incomplete, SupportsLenAndGetItem from collections.abc import Container, Iterator, Mapping from contextlib import AbstractContextManager -from typing import Any, Protocol, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, overload, type_check_only from pandas._typing import Scalar diff --git a/stubs/geopandas/geopandas/plotting.pyi b/stubs/geopandas/geopandas/plotting.pyi index 01528e6284e4..7c511859e3e4 100644 --- a/stubs/geopandas/geopandas/plotting.pyi +++ b/stubs/geopandas/geopandas/plotting.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Collection, Hashable, Iterable, Mapping, Sequence -from typing import Literal, overload -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, overload import numpy as np import pandas as pd diff --git a/stubs/gevent/gevent/_ffi/loop.pyi b/stubs/gevent/gevent/_ffi/loop.pyi index 3e3004679223..38222a945d36 100644 --- a/stubs/gevent/gevent/_ffi/loop.pyi +++ b/stubs/gevent/gevent/_ffi/loop.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import FileDescriptor from collections.abc import Callable, Sequence from types import TracebackType -from typing import Protocol, type_check_only -from typing_extensions import TypeAlias, TypeVarTuple, Unpack +from typing import Protocol, TypeAlias, type_check_only +from typing_extensions import TypeVarTuple, Unpack from gevent._types import _AsyncWatcher, _Callback, _ChildWatcher, _IoWatcher, _StatWatcher, _TimerWatcher, _Watcher diff --git a/stubs/gevent/gevent/_types.pyi b/stubs/gevent/gevent/_types.pyi index 16db1f4d497f..a32dfd540140 100644 --- a/stubs/gevent/gevent/_types.pyi +++ b/stubs/gevent/gevent/_types.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import FileDescriptor, StrOrBytesPath from collections.abc import Callable from types import TracebackType -from typing import Any, Literal, Protocol, overload -from typing_extensions import TypeAlias, TypeVarTuple, Unpack +from typing import Any, Literal, Protocol, TypeAlias, overload +from typing_extensions import TypeVarTuple, Unpack _Ts = TypeVarTuple("_Ts") diff --git a/stubs/gevent/gevent/_waiter.pyi b/stubs/gevent/gevent/_waiter.pyi index a240f02585bf..44d6f3e9864e 100644 --- a/stubs/gevent/gevent/_waiter.pyi +++ b/stubs/gevent/gevent/_waiter.pyi @@ -1,6 +1,5 @@ from types import TracebackType -from typing import Generic, TypeVar, final, overload -from typing_extensions import TypeAlias +from typing import Generic, TypeAlias, TypeVar, final, overload from gevent.event import _ValueSource from gevent.hub import Hub diff --git a/stubs/gevent/gevent/baseserver.pyi b/stubs/gevent/gevent/baseserver.pyi index 95cfe0551b5b..3b6c59a54edb 100644 --- a/stubs/gevent/gevent/baseserver.pyi +++ b/stubs/gevent/gevent/baseserver.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Container from types import TracebackType -from typing import Generic, Literal, Protocol, type_check_only -from typing_extensions import ParamSpec, Self, TypeAlias, TypeVarTuple, Unpack +from typing import Generic, Literal, Protocol, TypeAlias, type_check_only +from typing_extensions import ParamSpec, Self, TypeVarTuple, Unpack from gevent._types import _Loop from gevent.pool import Pool diff --git a/stubs/gevent/gevent/event.pyi b/stubs/gevent/gevent/event.pyi index d5570b019301..fa24fe5159d2 100644 --- a/stubs/gevent/gevent/event.pyi +++ b/stubs/gevent/gevent/event.pyi @@ -1,6 +1,5 @@ from types import TracebackType -from typing import Generic, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only from gevent._abstract_linkable import AbstractLinkable diff --git a/stubs/gevent/gevent/events.pyi b/stubs/gevent/gevent/events.pyi index 237d84ba2898..22e0338690e1 100644 --- a/stubs/gevent/gevent/events.pyi +++ b/stubs/gevent/gevent/events.pyi @@ -1,7 +1,6 @@ from collections.abc import Callable, Mapping, Sequence from types import ModuleType -from typing import Any, Protocol, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, TypeVar, type_check_only from gevent.hub import Hub from greenlet import greenlet as greenlet_t diff --git a/stubs/gevent/gevent/fileobject.pyi b/stubs/gevent/gevent/fileobject.pyi index db49e17e084f..86fb43ebfd32 100644 --- a/stubs/gevent/gevent/fileobject.pyi +++ b/stubs/gevent/gevent/fileobject.pyi @@ -1,6 +1,5 @@ import sys -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from gevent._fileobjectcommon import FileObjectBlock as FileObjectBlock, FileObjectThread as FileObjectThread diff --git a/stubs/gevent/gevent/libev/watcher.pyi b/stubs/gevent/gevent/libev/watcher.pyi index 4da07d7f30ee..a0c5d563b88a 100644 --- a/stubs/gevent/gevent/libev/watcher.pyi +++ b/stubs/gevent/gevent/libev/watcher.pyi @@ -1,7 +1,8 @@ import sys from _typeshed import FileDescriptor from collections.abc import Callable -from typing_extensions import ParamSpec, TypeAlias +from typing import TypeAlias +from typing_extensions import ParamSpec from gevent._ffi import watcher as _base from gevent.libev.corecffi import loop as cffi_loop diff --git a/stubs/gevent/gevent/selectors.pyi b/stubs/gevent/gevent/selectors.pyi index dd65f230a885..f25d16cd1f91 100644 --- a/stubs/gevent/gevent/selectors.pyi +++ b/stubs/gevent/gevent/selectors.pyi @@ -1,8 +1,7 @@ from _typeshed import FileDescriptorLike from collections.abc import Mapping from selectors import BaseSelector, SelectorKey -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from gevent._util import Lazy from gevent.hub import Hub diff --git a/stubs/gevent/gevent/server.pyi b/stubs/gevent/gevent/server.pyi index a76b21c2bb6d..0ee394c80c6f 100644 --- a/stubs/gevent/gevent/server.pyi +++ b/stubs/gevent/gevent/server.pyi @@ -1,8 +1,7 @@ from _socket import _Address as _StrictAddress from _typeshed import ReadableBuffer, StrOrBytesPath from collections.abc import Callable -from typing import Any, ClassVar, TypedDict, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, ClassVar, TypeAlias, TypedDict, overload, type_check_only from gevent.baseserver import BaseServer, _Spawner from gevent.socket import socket as _GeventSocket diff --git a/stubs/gevent/gevent/threadpool.pyi b/stubs/gevent/gevent/threadpool.pyi index 3ce23ac79fb6..d4391700d14d 100644 --- a/stubs/gevent/gevent/threadpool.pyi +++ b/stubs/gevent/gevent/threadpool.pyi @@ -1,7 +1,7 @@ import concurrent.futures from collections.abc import Callable -from typing import Any, Generic, TypeVar -from typing_extensions import ParamSpec, TypeAlias +from typing import Any, Generic, TypeAlias, TypeVar +from typing_extensions import ParamSpec from gevent._threading import Queue from gevent._types import _AsyncWatcher, _Watcher diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi index e13a58438c4f..6fd446d432c9 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -1,8 +1,8 @@ import datetime from _typeshed import Unused from collections.abc import Callable, Iterable, Sequence -from typing import Any, Literal, NoReturn -from typing_extensions import Self, TypeAlias +from typing import Any, Literal, NoReturn, TypeAlias +from typing_extensions import Self from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module diff --git a/stubs/greenlet/greenlet/_greenlet.pyi b/stubs/greenlet/greenlet/_greenlet.pyi index 92607c354f82..cc3c255e43da 100644 --- a/stubs/greenlet/greenlet/_greenlet.pyi +++ b/stubs/greenlet/greenlet/_greenlet.pyi @@ -2,8 +2,8 @@ import sys from collections.abc import Callable from contextvars import Context from types import FrameType, TracebackType -from typing import Any, Literal, Protocol, overload, type_check_only -from typing_extensions import TypeAlias, disjoint_base +from typing import Any, Literal, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import disjoint_base _TraceEvent: TypeAlias = Literal["switch", "throw"] _TraceCallback: TypeAlias = Callable[[_TraceEvent, tuple[greenlet, greenlet]], object] diff --git a/stubs/grpcio-reflection/grpc_reflection/v1alpha/reflection.pyi b/stubs/grpcio-reflection/grpc_reflection/v1alpha/reflection.pyi index 8b336b9bee3c..0c00500de3a7 100644 --- a/stubs/grpcio-reflection/grpc_reflection/v1alpha/reflection.pyi +++ b/stubs/grpcio-reflection/grpc_reflection/v1alpha/reflection.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterable -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias import grpc import grpc.aio diff --git a/stubs/grpcio/grpc/__init__.pyi b/stubs/grpcio/grpc/__init__.pyi index 107ab51f33a9..b4e585b08c9b 100644 --- a/stubs/grpcio/grpc/__init__.pyi +++ b/stubs/grpcio/grpc/__init__.pyi @@ -4,8 +4,8 @@ import threading from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from concurrent import futures from types import ModuleType, TracebackType -from typing import Any, Generic, NoReturn, Protocol, TypeVar, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Generic, NoReturn, Protocol, TypeAlias, TypeVar, type_check_only +from typing_extensions import Self from . import aio as aio diff --git a/stubs/grpcio/grpc/aio/__init__.pyi b/stubs/grpcio/grpc/aio/__init__.pyi index 4c8ef012fb29..d05a8c3ddbe5 100644 --- a/stubs/grpcio/grpc/aio/__init__.pyi +++ b/stubs/grpcio/grpc/aio/__init__.pyi @@ -4,8 +4,8 @@ from _typeshed import Incomplete from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable, Generator, Iterable, Iterator, Mapping, Sequence from concurrent import futures from types import TracebackType -from typing import Any, Generic, NoReturn, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Generic, NoReturn, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self from grpc import ( CallCredentials, diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index cbe38ddfd655..815a1179f98c 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,8 +1,8 @@ ### This .pyi file is a helper for centralized storage types that are reused across different runtime modules. ### from _typeshed import FileDescriptor from collections.abc import Awaitable, Callable, Iterable, MutableMapping -from typing import Any -from typing_extensions import LiteralString, TypeAlias +from typing import Any, TypeAlias +from typing_extensions import LiteralString _StatusType: TypeAlias = str _HeadersType: TypeAlias = Iterable[tuple[str, str]] diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index ba1e706db78e..e115582e30e6 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -2,8 +2,7 @@ import argparse from _typeshed import ConvertibleToInt from collections.abc import Callable, Container from ssl import SSLContext, _SSLMethod -from typing import Annotated, Any, ClassVar, Final, overload -from typing_extensions import TypeAlias +from typing import Annotated, Any, ClassVar, Final, TypeAlias, overload from gunicorn.arbiter import Arbiter from gunicorn.glogging import Logger as GLogger diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index f04f94909706..0ee4a9edfb4c 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -4,8 +4,7 @@ from collections.abc import Mapping from datetime import timedelta from logging.config import _DictConfigArgs from socket import SocketKind -from typing import Annotated, Any, ClassVar, Literal, TypedDict, type_check_only -from typing_extensions import TypeAlias +from typing import Annotated, Any, ClassVar, Literal, TypeAlias, TypedDict, type_check_only from gunicorn.http import Request from gunicorn.http.wsgi import Response diff --git a/stubs/gunicorn/gunicorn/http/body.pyi b/stubs/gunicorn/gunicorn/http/body.pyi index cc2735015b6a..10b4d0af94da 100644 --- a/stubs/gunicorn/gunicorn/http/body.pyi +++ b/stubs/gunicorn/gunicorn/http/body.pyi @@ -1,6 +1,6 @@ import io from collections.abc import Callable, Generator, Iterator -from typing_extensions import TypeAlias +from typing import TypeAlias from gunicorn.http.message import Request from gunicorn.http.unreader import Unreader diff --git a/stubs/gunicorn/gunicorn/http2/connection.pyi b/stubs/gunicorn/gunicorn/http2/connection.pyi index ee5f50a0dbaa..5ef587127e7f 100644 --- a/stubs/gunicorn/gunicorn/http2/connection.pyi +++ b/stubs/gunicorn/gunicorn/http2/connection.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable from ssl import SSLSocket -from typing import Any, ClassVar -from typing_extensions import TypeAlias +from typing import Any, ClassVar, TypeAlias from gunicorn.config import Config from gunicorn.http2.request import HTTP2Request diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index 7d729d281949..f6f0ff9cc92d 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -2,8 +2,7 @@ import sys import threading from collections.abc import Callable, Iterable from re import Pattern -from typing import Final, NoReturn, TypedDict, type_check_only -from typing_extensions import TypeAlias +from typing import Final, NoReturn, TypeAlias, TypedDict, type_check_only COMPILED_EXT_RE: Final[Pattern[str]] diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index 481996a13837..c0a53550ceae 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -1,6 +1,5 @@ from types import FrameType -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from gunicorn.workers.base_async import AsyncWorker diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi index cac5ed08e525..25267d4d46bb 100644 --- a/stubs/gunicorn/gunicorn/workers/gtornado.pyi +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -1,6 +1,5 @@ from types import FrameType -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from gunicorn.workers.base import Worker diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 8cccb842afe8..0f12313590cd 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -3,8 +3,8 @@ from _typeshed import Incomplete, ReadableBuffer from collections.abc import Callable, Sequence from datetime import date, datetime, time from types import TracebackType -from typing import Any, Final, Literal, overload -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Final, Literal, TypeAlias, overload +from typing_extensions import Self, disjoint_base from .resultrow import ResultRow diff --git a/stubs/html5lib/html5lib/_inputstream.pyi b/stubs/html5lib/html5lib/_inputstream.pyi index 53a94876db6f..f3d92a878716 100644 --- a/stubs/html5lib/html5lib/_inputstream.pyi +++ b/stubs/html5lib/html5lib/_inputstream.pyi @@ -2,8 +2,8 @@ import re from _io import BytesIO, StringIO from _typeshed import Incomplete, ReadableBuffer, SupportsRead from collections.abc import Callable, Iterable -from typing import Any, AnyStr, Generic, Literal, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import Any, AnyStr, Generic, Literal, TypeAlias, TypeVar, overload +from typing_extensions import Self from webencodings import Encoding diff --git a/stubs/icalendar/icalendar/alarms.pyi b/stubs/icalendar/icalendar/alarms.pyi index 975a413369ce..ec2befb72de1 100644 --- a/stubs/icalendar/icalendar/alarms.pyi +++ b/stubs/icalendar/icalendar/alarms.pyi @@ -1,5 +1,5 @@ import datetime -from typing_extensions import TypeAlias +from typing import TypeAlias from .cal import Alarm, Event, Todo from .error import ( diff --git a/stubs/icalendar/icalendar/parser_tools.pyi b/stubs/icalendar/icalendar/parser_tools.pyi index 6456cc836306..357d5ee6bd00 100644 --- a/stubs/icalendar/icalendar/parser_tools.pyi +++ b/stubs/icalendar/icalendar/parser_tools.pyi @@ -1,5 +1,4 @@ -from typing import Any, Final, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias, TypeVar, overload _T = TypeVar("_T") diff --git a/stubs/icalendar/icalendar/prop.pyi b/stubs/icalendar/icalendar/prop.pyi index 2675ebe82baf..c591282c04b2 100644 --- a/stubs/icalendar/icalendar/prop.pyi +++ b/stubs/icalendar/icalendar/prop.pyi @@ -3,8 +3,8 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Supports from collections.abc import Iterable, Iterator from enum import Enum from re import Pattern -from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only +from typing_extensions import Self from .caselessdict import CaselessDict from .parser import Parameters diff --git a/stubs/icalendar/icalendar/tools.pyi b/stubs/icalendar/icalendar/tools.pyi index d63d649f8041..b5d7c82d16bc 100644 --- a/stubs/icalendar/icalendar/tools.pyi +++ b/stubs/icalendar/icalendar/tools.pyi @@ -1,6 +1,6 @@ import datetime -from typing import Final -from typing_extensions import TypeGuard, TypeIs, deprecated +from typing import Final, TypeGuard +from typing_extensions import TypeIs, deprecated from pytz.tzinfo import BaseTzInfo diff --git a/stubs/inifile/inifile.pyi b/stubs/inifile/inifile.pyi index c64a3168d983..c3ed7c06dbdd 100644 --- a/stubs/inifile/inifile.pyi +++ b/stubs/inifile/inifile.pyi @@ -1,7 +1,6 @@ from _typeshed import StrPath, SupportsKeysAndGetItem from collections.abc import Container, Iterable, Iterator, Mapping, MutableMapping, Sequence -from typing import Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, TypeVar, overload from uuid import UUID _T = TypeVar("_T") diff --git a/stubs/jmespath/jmespath/ast.pyi b/stubs/jmespath/jmespath/ast.pyi index d8c75d0abdde..53d718e084a0 100644 --- a/stubs/jmespath/jmespath/ast.pyi +++ b/stubs/jmespath/jmespath/ast.pyi @@ -1,5 +1,5 @@ -from typing import Literal, TypedDict, type_check_only -from typing_extensions import NotRequired, TypeAlias +from typing import Literal, TypeAlias, TypedDict, type_check_only +from typing_extensions import NotRequired _NodeType: TypeAlias = Literal[ "comparator", diff --git a/stubs/jsonschema/jsonschema/_format.pyi b/stubs/jsonschema/jsonschema/_format.pyi index 8b9912dc59ac..9204059bee6d 100644 --- a/stubs/jsonschema/jsonschema/_format.pyi +++ b/stubs/jsonschema/jsonschema/_format.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Iterable -from typing import TypeVar -from typing_extensions import TypeAlias +from typing import TypeAlias, TypeVar _FormatCheckCallable: TypeAlias = Callable[[object], bool] _F = TypeVar("_F", bound=_FormatCheckCallable) diff --git a/stubs/jsonschema/jsonschema/_typing.pyi b/stubs/jsonschema/jsonschema/_typing.pyi index bf096c3fa078..78e946676d79 100644 --- a/stubs/jsonschema/jsonschema/_typing.pyi +++ b/stubs/jsonschema/jsonschema/_typing.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Iterable -from typing import Any, Protocol -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias from jsonschema.protocols import Validator from referencing.jsonschema import Schema diff --git a/stubs/jsonschema/jsonschema/exceptions.pyi b/stubs/jsonschema/jsonschema/exceptions.pyi index aef0c616e705..937a03e2587a 100644 --- a/stubs/jsonschema/jsonschema/exceptions.pyi +++ b/stubs/jsonschema/jsonschema/exceptions.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, SupportsRichComparison, sentinel from collections import deque from collections.abc import Callable, Container, Iterable, Iterator, Mapping, MutableMapping, Sequence -from typing import Any -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, TypeAlias +from typing_extensions import Self, deprecated from ._types import TypeChecker from ._utils import Unset diff --git a/stubs/jsonschema/jsonschema/protocols.pyi b/stubs/jsonschema/jsonschema/protocols.pyi index 8f523c1ca4a6..5fea709eeaaf 100644 --- a/stubs/jsonschema/jsonschema/protocols.pyi +++ b/stubs/jsonschema/jsonschema/protocols.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterator, Mapping, Sequence -from typing import Any, ClassVar, Protocol -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Protocol, TypeAlias import referencing.jsonschema from jsonschema._format import FormatChecker diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi index 4e93434f1d65..4da9902c8492 100644 --- a/stubs/jsonschema/jsonschema/validators.pyi +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, SupportsKeysAndGetItem from collections.abc import Callable, Generator, Iterable, Iterator, Mapping from contextlib import contextmanager -from typing import Any, ClassVar, overload, type_check_only -from typing_extensions import TypeAlias, deprecated +from typing import Any, ClassVar, TypeAlias, overload, type_check_only +from typing_extensions import deprecated from referencing.jsonschema import Schema, SchemaRegistry from referencing.typing import URI diff --git a/stubs/jwcrypto/jwcrypto/jwk.pyi b/stubs/jwcrypto/jwcrypto/jwk.pyi index 721b4e892e9b..d4408c03b344 100644 --- a/stubs/jwcrypto/jwcrypto/jwk.pyi +++ b/stubs/jwcrypto/jwcrypto/jwk.pyi @@ -1,8 +1,8 @@ from _typeshed import Unused from collections.abc import Callable, Sequence from enum import Enum -from typing import Any, Literal, NamedTuple, TypeVar, overload -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, Literal, NamedTuple, TypeAlias, TypeVar, overload +from typing_extensions import Self, deprecated from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import ec, rsa diff --git a/stubs/keyboard/keyboard/__init__.pyi b/stubs/keyboard/keyboard/__init__.pyi index 432d233660fc..b6b2763fe9b3 100644 --- a/stubs/keyboard/keyboard/__init__.pyi +++ b/stubs/keyboard/keyboard/__init__.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Generator, Iterable, Sequence from queue import Queue from threading import Event as _UninterruptibleEvent -from typing_extensions import TypeAlias +from typing import TypeAlias from ._canonical_names import all_modifiers as all_modifiers, sided_modifiers as sided_modifiers from ._keyboard_event import KEY_DOWN as KEY_DOWN, KEY_UP as KEY_UP, KeyboardEvent as KeyboardEvent diff --git a/stubs/keyboard/keyboard/_generic.pyi b/stubs/keyboard/keyboard/_generic.pyi index 8f61d95c2698..a1784b3d89a8 100644 --- a/stubs/keyboard/keyboard/_generic.pyi +++ b/stubs/keyboard/keyboard/_generic.pyi @@ -1,8 +1,7 @@ from collections.abc import Callable from queue import Queue from threading import Lock, Thread -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from ._keyboard_event import KeyboardEvent from ._mouse_event import _MouseEvent diff --git a/stubs/keyboard/keyboard/_mouse_event.pyi b/stubs/keyboard/keyboard/_mouse_event.pyi index ce8e04af9482..e9e95b80e112 100644 --- a/stubs/keyboard/keyboard/_mouse_event.pyi +++ b/stubs/keyboard/keyboard/_mouse_event.pyi @@ -1,6 +1,5 @@ import sys -from typing import Literal, NamedTuple -from typing_extensions import TypeAlias +from typing import Literal, NamedTuple, TypeAlias _MouseEvent: TypeAlias = ButtonEvent | WheelEvent | MoveEvent # noqa: Y047 # Used outside diff --git a/stubs/keyboard/keyboard/mouse.pyi b/stubs/keyboard/keyboard/mouse.pyi index 16008246893d..6105f85d59a9 100644 --- a/stubs/keyboard/keyboard/mouse.pyi +++ b/stubs/keyboard/keyboard/mouse.pyi @@ -1,8 +1,7 @@ import sys from collections.abc import Callable, Iterable from ctypes import c_long -from typing import Literal, SupportsInt, TypeVar -from typing_extensions import TypeAlias +from typing import Literal, SupportsInt, TypeAlias, TypeVar from ._generic import GenericListener as _GenericListener from ._mouse_event import ( diff --git a/stubs/ldap3/ldap3/core/connection.pyi b/stubs/ldap3/ldap3/core/connection.pyi index 47df86aa6ad8..0ee8700e0902 100644 --- a/stubs/ldap3/ldap3/core/connection.pyi +++ b/stubs/ldap3/ldap3/core/connection.pyi @@ -1,8 +1,8 @@ from _collections_abc import Generator, dict_keys from _typeshed import Incomplete, ReadableBuffer from types import TracebackType -from typing import Literal -from typing_extensions import Self, TypeAlias +from typing import Literal, TypeAlias +from typing_extensions import Self from pyasn1.type.base import Asn1Item diff --git a/stubs/ldap3/ldap3/utils/asn1.pyi b/stubs/ldap3/ldap3/utils/asn1.pyi index 4d4abfcea9ca..0455ffd7cf7a 100644 --- a/stubs/ldap3/ldap3/utils/asn1.pyi +++ b/stubs/ldap3/ldap3/utils/asn1.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete, IndexableBuffer, SliceableBuffer, Unused from collections.abc import Callable, Mapping -from typing import Any, Final, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias, TypeVar, overload from pyasn1.codec.ber.encoder import AbstractItemEncoder from pyasn1.type.tag import TagSet diff --git a/stubs/libsass/sass.pyi b/stubs/libsass/sass.pyi index b81a15213378..8bcb341df18c 100644 --- a/stubs/libsass/sass.pyi +++ b/stubs/libsass/sass.pyi @@ -1,8 +1,8 @@ import enum from _typeshed import ConvertibleToFloat, SupportsKeysAndGetItem from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence, Set as AbstractSet -from typing import Any, Generic, Literal, NamedTuple, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, Self, TypeAlias +from typing import Any, Generic, Literal, NamedTuple, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, Self _T = TypeVar("_T") _KT = TypeVar("_KT") diff --git a/stubs/lupa/lupa/lua51.pyi b/stubs/lupa/lupa/lua51.pyi index 6cc8152115ca..768251730bff 100644 --- a/stubs/lupa/lupa/lua51.pyi +++ b/stubs/lupa/lupa/lua51.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable -from typing import Any, Final, Generic, TypeVar, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Final, Generic, TypeAlias, TypeVar, type_check_only +from typing_extensions import Self, disjoint_base __all__ = [ "LUA_VERSION", diff --git a/stubs/lupa/lupa/lua52.pyi b/stubs/lupa/lupa/lua52.pyi index 6cc8152115ca..768251730bff 100644 --- a/stubs/lupa/lupa/lua52.pyi +++ b/stubs/lupa/lupa/lua52.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable -from typing import Any, Final, Generic, TypeVar, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Final, Generic, TypeAlias, TypeVar, type_check_only +from typing_extensions import Self, disjoint_base __all__ = [ "LUA_VERSION", diff --git a/stubs/lupa/lupa/lua53.pyi b/stubs/lupa/lupa/lua53.pyi index 6cc8152115ca..768251730bff 100644 --- a/stubs/lupa/lupa/lua53.pyi +++ b/stubs/lupa/lupa/lua53.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable -from typing import Any, Final, Generic, TypeVar, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Final, Generic, TypeAlias, TypeVar, type_check_only +from typing_extensions import Self, disjoint_base __all__ = [ "LUA_VERSION", diff --git a/stubs/lupa/lupa/lua54.pyi b/stubs/lupa/lupa/lua54.pyi index 6cc8152115ca..768251730bff 100644 --- a/stubs/lupa/lupa/lua54.pyi +++ b/stubs/lupa/lupa/lua54.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable -from typing import Any, Final, Generic, TypeVar, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Final, Generic, TypeAlias, TypeVar, type_check_only +from typing_extensions import Self, disjoint_base __all__ = [ "LUA_VERSION", diff --git a/stubs/m3u8/m3u8/__init__.pyi b/stubs/m3u8/m3u8/__init__.pyi index 8ce37aeb0b52..6fe32d5edeee 100644 --- a/stubs/m3u8/m3u8/__init__.pyi +++ b/stubs/m3u8/m3u8/__init__.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Mapping -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from m3u8.httpclient import _HTTPClientProtocol from m3u8.model import ( diff --git a/stubs/m3u8/m3u8/model.pyi b/stubs/m3u8/m3u8/model.pyi index 53e31529e23e..e59d19cf1f50 100644 --- a/stubs/m3u8/m3u8/model.pyi +++ b/stubs/m3u8/m3u8/model.pyi @@ -2,8 +2,7 @@ import datetime as dt from _typeshed import Incomplete, StrOrBytesPath, Unused from collections.abc import Callable, Iterable, Mapping from decimal import Decimal -from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only from m3u8.mixins import BasePathMixin, GroupedBasePathMixin from m3u8.protocol import ext_x_map, ext_x_session_key diff --git a/stubs/m3u8/m3u8/parser.pyi b/stubs/m3u8/m3u8/parser.pyi index 4eaf0543ffc8..aeee2b4d6a6d 100644 --- a/stubs/m3u8/m3u8/parser.pyi +++ b/stubs/m3u8/m3u8/parser.pyi @@ -2,8 +2,7 @@ from collections.abc import Callable from datetime import date, datetime, time from itertools import repeat from re import Pattern -from typing import Any, overload -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, overload _CustomTagsParser: TypeAlias = Callable[[str, int, dict[str, Any], dict[str, Any]], object] diff --git a/stubs/mock/mock/backports.pyi b/stubs/mock/mock/backports.pyi index fd968db5d6cb..9cb45af2cd60 100644 --- a/stubs/mock/mock/backports.pyi +++ b/stubs/mock/mock/backports.pyi @@ -1,7 +1,2 @@ -import sys +from inspect import iscoroutinefunction as iscoroutinefunction from unittest import IsolatedAsyncioTestCase as IsolatedAsyncioTestCase - -if sys.version_info >= (3, 10): - from inspect import iscoroutinefunction as iscoroutinefunction -else: - from asyncio import iscoroutinefunction as iscoroutinefunction diff --git a/stubs/mysqlclient/MySQLdb/connections.pyi b/stubs/mysqlclient/MySQLdb/connections.pyi index 0a4f8965fcba..c35ccd31689e 100644 --- a/stubs/mysqlclient/MySQLdb/connections.pyi +++ b/stubs/mysqlclient/MySQLdb/connections.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from re import Pattern from types import TracebackType -from typing import Any -from typing_extensions import LiteralString, Self, TypeAlias +from typing import Any, TypeAlias +from typing_extensions import LiteralString, Self from . import _mysql, cursors from ._exceptions import ( diff --git a/stubs/mysqlclient/MySQLdb/cursors.pyi b/stubs/mysqlclient/MySQLdb/cursors.pyi index e3111af67896..f0dd10ea95d8 100644 --- a/stubs/mysqlclient/MySQLdb/cursors.pyi +++ b/stubs/mysqlclient/MySQLdb/cursors.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete from collections.abc import Iterable from re import Pattern -from typing_extensions import LiteralString, TypeAlias +from typing import TypeAlias +from typing_extensions import LiteralString from .connections import _Literal diff --git a/stubs/nanoid/nanoid/method.pyi b/stubs/nanoid/nanoid/method.pyi index 1a8b33fa9f9a..0e79a8e09215 100644 --- a/stubs/nanoid/nanoid/method.pyi +++ b/stubs/nanoid/nanoid/method.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Sequence -from typing_extensions import TypeAlias +from typing import TypeAlias _Algorithm: TypeAlias = Callable[[int], Sequence[int]] diff --git a/stubs/netaddr/netaddr/eui/ieee.pyi b/stubs/netaddr/netaddr/eui/ieee.pyi index a5f2079af176..560ee2a1eefe 100644 --- a/stubs/netaddr/netaddr/eui/ieee.pyi +++ b/stubs/netaddr/netaddr/eui/ieee.pyi @@ -1,8 +1,7 @@ import _csv from _typeshed import FileDescriptorOrPath, StrOrBytesPath from collections.abc import Iterable -from typing import Any, BinaryIO, TextIO -from typing_extensions import TypeAlias +from typing import Any, BinaryIO, TextIO, TypeAlias from netaddr.core import Publisher, Subscriber diff --git a/stubs/netaddr/netaddr/ip/__init__.pyi b/stubs/netaddr/netaddr/ip/__init__.pyi index 9aa6a680bd43..6c61ff4cc056 100644 --- a/stubs/netaddr/netaddr/ip/__init__.pyi +++ b/stubs/netaddr/netaddr/ip/__init__.pyi @@ -2,8 +2,8 @@ from _typeshed import ConvertibleToInt, Unused from abc import abstractmethod from collections.abc import Iterable, Iterator from types import ModuleType -from typing import Literal, SupportsIndex, SupportsInt, overload -from typing_extensions import Self, TypeAlias +from typing import Literal, SupportsIndex, SupportsInt, TypeAlias, overload +from typing_extensions import Self from netaddr.core import DictDotLookup from netaddr.strategy.ipv6 import ipv6_verbose diff --git a/stubs/netaddr/netaddr/ip/glob.pyi b/stubs/netaddr/netaddr/ip/glob.pyi index e0836fcf3bdd..42f5c8f3e802 100644 --- a/stubs/netaddr/netaddr/ip/glob.pyi +++ b/stubs/netaddr/netaddr/ip/glob.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeGuard +from typing import TypeGuard from netaddr.ip import IPAddress, IPNetwork, IPRange, _IPAddressAddr, _IPNetworkAddr diff --git a/stubs/netaddr/netaddr/ip/iana.pyi b/stubs/netaddr/netaddr/ip/iana.pyi index a689f90cb52c..1d205a275d25 100644 --- a/stubs/netaddr/netaddr/ip/iana.pyi +++ b/stubs/netaddr/netaddr/ip/iana.pyi @@ -1,7 +1,6 @@ from _typeshed import SupportsWrite from collections.abc import Callable, Mapping, MutableMapping -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from xml.sax import _Source, handler from xml.sax.xmlreader import AttributesImpl, InputSource, XMLReader diff --git a/stubs/netaddr/netaddr/ip/sets.pyi b/stubs/netaddr/netaddr/ip/sets.pyi index b512ee720b30..720336f82bfa 100644 --- a/stubs/netaddr/netaddr/ip/sets.pyi +++ b/stubs/netaddr/netaddr/ip/sets.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable, Iterator -from typing import NoReturn -from typing_extensions import Self, TypeAlias +from typing import NoReturn, TypeAlias +from typing_extensions import Self from netaddr.ip import IPAddress, IPNetwork, IPRange, _IPNetworkAddr diff --git a/stubs/networkx/networkx/_typing.pyi b/stubs/networkx/networkx/_typing.pyi index ff530c5ba668..e9c78cbbc497 100644 --- a/stubs/networkx/networkx/_typing.pyi +++ b/stubs/networkx/networkx/_typing.pyi @@ -1,9 +1,8 @@ # Stub-only module, can't be imported at runtime. -import sys from collections.abc import Collection -from typing import Any, Protocol, type_check_only -from typing_extensions import TypeAlias, TypeVar +from typing import Any, Protocol, TypeAlias, type_check_only +from typing_extensions import TypeVar import numpy as np @@ -13,16 +12,11 @@ _GenericT_co = TypeVar("_GenericT_co", bound=np.generic, covariant=True) _ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=Any, covariant=True) # numpy aliases -if sys.version_info >= (3, 10): - @type_check_only - class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]): - def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ... +@type_check_only +class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]): + def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ... - ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]] -else: - # networkx does not support Python 3.9 but pyright still runs on 3.9 in CI - # See https://github.com/python/typeshed/issues/10722 - ArrayLike1D: TypeAlias = Collection[_ScalarT] | np.ndarray[tuple[int], np.dtype[_GenericT]] +ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]] Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_GenericT]] Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_GenericT]] diff --git a/stubs/networkx/networkx/algorithms/approximation/density.pyi b/stubs/networkx/networkx/algorithms/approximation/density.pyi index b5cd3cb16bb6..8d84f8373b39 100644 --- a/stubs/networkx/networkx/algorithms/approximation/density.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/density.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Hashable -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable diff --git a/stubs/networkx/networkx/algorithms/community/local.pyi b/stubs/networkx/networkx/algorithms/community/local.pyi index 4825f964529f..9799724b299b 100644 --- a/stubs/networkx/networkx/algorithms/community/local.pyi +++ b/stubs/networkx/networkx/algorithms/community/local.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Hashable -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi index 8043d3647d19..8b109a2b9f5b 100644 --- a/stubs/networkx/networkx/algorithms/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Mapping -from typing_extensions import TypeAlias +from typing import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index 5eb7445b0065..bee3ecf7470c 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Collection, Generator -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 086c697e26a1..1855ba5228c7 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, MutableMapping from functools import cached_property -from typing import Any, ClassVar, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, TypeAlias, TypeVar, overload +from typing_extensions import Self import numpy from networkx.classes.coreviews import AdjacencyView, AtlasView diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index ce68d24d34e8..72b1a09d453c 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -1,7 +1,7 @@ from collections.abc import Hashable from functools import cached_property -from typing import Any, ClassVar, overload -from typing_extensions import Self, TypeAlias, TypeVar +from typing import Any, ClassVar, TypeAlias, overload +from typing_extensions import Self, TypeVar from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.graph import Graph, _MapFactory, _Node diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 53a0f816c4f5..52f5b16f3e31 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable, Collection, Hashable, Iterable -from typing import Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, TypeVar, overload import numpy from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index 914763eb57ee..0ecb4a6d4289 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -1,6 +1,5 @@ from collections.abc import Collection, Mapping -from typing import Any, Literal -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias import numpy as np from networkx._typing import Array1D, Array2D, ArrayLike1D, Seed diff --git a/stubs/networkx/networkx/drawing/nx_latex.pyi b/stubs/networkx/networkx/drawing/nx_latex.pyi index 353ea573e092..90beba19dd14 100644 --- a/stubs/networkx/networkx/drawing/nx_latex.pyi +++ b/stubs/networkx/networkx/drawing/nx_latex.pyi @@ -1,6 +1,7 @@ from _typeshed import StrPath, SupportsWrite from collections.abc import Collection -from typing_extensions import TypeAlias, TypeVar +from typing import TypeAlias +from typing_extensions import TypeVar from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index 160766f7d884..ee4002b32ed5 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsItems from collections.abc import Callable, Collection, Hashable, Iterable, Mapping, Sequence -from typing import Any, Generic, Literal, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias, Unpack +from typing import Any, Generic, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Unpack import numpy as np from matplotlib.axes import Axes # type: ignore[import-not-found] diff --git a/stubs/networkx/networkx/utils/configs.pyi b/stubs/networkx/networkx/utils/configs.pyi index 780ccf7233a2..edc2908066d4 100644 --- a/stubs/networkx/networkx/utils/configs.pyi +++ b/stubs/networkx/networkx/utils/configs.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import Incomplete from collections.abc import Callable, ItemsView, Iterable, Iterator, KeysView, ValuesView from dataclasses import dataclass @@ -9,57 +8,30 @@ __all__ = ["Config"] # TODO: Our pyright test doesn't understand `requires_python` in METADATA.toml # https://github.com/python/typeshed/issues/14025 -if sys.version_info >= (3, 10): - @dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False) - class Config: - def __init_subclass__(cls, strict: bool = True) -> None: ... - def __new__(cls, **kwargs) -> Self: ... - def __dir__(self) -> Iterable[str]: ... - def __setattr__(self, name: str, value) -> None: ... - def __delattr__(self, name: str) -> None: ... - def __contains__(self, key: object) -> bool: ... - def __iter__(self) -> Iterator[str]: ... - def __len__(self) -> int: ... - def __reversed__(self) -> Iterator[str]: ... - def __getitem__(self, key: str): ... - def __setitem__(self, key: str, value) -> None: ... - def __delitem__(self, key: str) -> None: ... - def get(self, key: str, default=None): ... - def items(self) -> ItemsView[str, Incomplete]: ... - def keys(self) -> KeysView[str]: ... - def values(self) -> ValuesView[Incomplete]: ... - def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... - def __call__(self, **kwargs) -> Self: ... - def __enter__(self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None - ) -> None: ... - -else: - @dataclass(init=False, eq=False) - class Config: - def __init_subclass__(cls, strict: bool = True) -> None: ... - def __new__(cls, **kwargs) -> Self: ... - def __dir__(self) -> Iterable[str]: ... - def __setattr__(self, name: str, value) -> None: ... - def __delattr__(self, name: str) -> None: ... - def __contains__(self, key: object) -> bool: ... - def __iter__(self) -> Iterator[str]: ... - def __len__(self) -> int: ... - def __reversed__(self) -> Iterator[str]: ... - def __getitem__(self, key: str): ... - def __setitem__(self, key: str, value) -> None: ... - def __delitem__(self, key: str) -> None: ... - def get(self, key: str, default=None): ... - def items(self) -> ItemsView[str, Incomplete]: ... - def keys(self) -> KeysView[str]: ... - def values(self) -> ValuesView[Incomplete]: ... - def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... - def __call__(self, **kwargs) -> Self: ... - def __enter__(self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None - ) -> None: ... +@dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False) +class Config: + def __init_subclass__(cls, strict: bool = True) -> None: ... + def __new__(cls, **kwargs) -> Self: ... + def __dir__(self) -> Iterable[str]: ... + def __setattr__(self, name: str, value) -> None: ... + def __delattr__(self, name: str) -> None: ... + def __contains__(self, key: object) -> bool: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... + def __reversed__(self) -> Iterator[str]: ... + def __getitem__(self, key: str): ... + def __setitem__(self, key: str, value) -> None: ... + def __delitem__(self, key: str) -> None: ... + def get(self, key: str, default=None): ... + def items(self) -> ItemsView[str, Incomplete]: ... + def keys(self) -> KeysView[str]: ... + def values(self) -> ValuesView[Incomplete]: ... + def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... + def __call__(self, **kwargs) -> Self: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + ) -> None: ... class NetworkXConfig(Config): backend_priority: list[str] diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi index f925c63d1b8b..b87ff7572956 100644 --- a/stubs/networkx/networkx/utils/misc.pyi +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -1,7 +1,6 @@ import random -import sys from types import ModuleType -from typing_extensions import Self, TypeAlias +from typing import TypeAlias import numpy from networkx.classes.graph import Graph, _Node @@ -38,10 +37,6 @@ def create_random_state(random_state=None): ... class PythonRandomViaNumpyBits(random.Random): def __init__(self, rng: numpy.random.Generator | None = None) -> None: ... - if sys.version_info < (3, 10): - # this is a workaround for pyright correctly flagging an inconsistent inherited constructor, see #14624 - def __new__(cls, rng: numpy.random.Generator | None = None) -> Self: ... - def getrandbits(self, k: int) -> int: ... class PythonRandomInterface: diff --git a/stubs/oauthlib/oauthlib/common.pyi b/stubs/oauthlib/oauthlib/common.pyi index 15112d51863c..73cb190cadbd 100644 --- a/stubs/oauthlib/oauthlib/common.pyi +++ b/stubs/oauthlib/oauthlib/common.pyi @@ -2,8 +2,7 @@ import re from _typeshed import Incomplete, SupportsLenAndGetItem from collections.abc import Iterable, Mapping from logging import Logger -from typing import Any, Final, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Final, Literal, TypeAlias, TypeVar, overload _T = TypeVar("_T") _V = TypeVar("_V") diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/base.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/base.pyi index 2d3a88dbd3e0..aa5cf71e7aa0 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/base.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/base.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete from collections.abc import Callable -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias from oauthlib.common import _HTTPMethod from oauthlib.oauth2.rfc6749.tokens import OAuth2Token diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/grant_types/base.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/grant_types/base.pyi index f8f35c9827fd..ec02b7862aba 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/grant_types/base.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/grant_types/base.pyi @@ -2,8 +2,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable from itertools import chain from logging import Logger -from typing import TypeVar -from typing_extensions import TypeAlias +from typing import TypeAlias, TypeVar from oauthlib.common import Request diff --git a/stubs/objgraph/objgraph.pyi b/stubs/objgraph/objgraph.pyi index 427c6e405126..8278461c3fde 100644 --- a/stubs/objgraph/objgraph.pyi +++ b/stubs/objgraph/objgraph.pyi @@ -2,8 +2,7 @@ from _typeshed import Incomplete, SupportsWrite from collections import defaultdict from collections.abc import Callable, Container, Iterable from types import ModuleType -from typing import Final, Literal -from typing_extensions import TypeAlias, TypeGuard +from typing import Final, Literal, TypeAlias, TypeGuard IS_INTERACTIVE: bool diff --git a/stubs/olefile/olefile/olefile.pyi b/stubs/olefile/olefile/olefile.pyi index bc7d74306ae4..3790921224bb 100644 --- a/stubs/olefile/olefile/olefile.pyi +++ b/stubs/olefile/olefile/olefile.pyi @@ -4,8 +4,8 @@ import io import logging import traceback from collections.abc import Sequence -from typing import IO, AnyStr, Generic -from typing_extensions import Self, TypeAlias +from typing import IO, AnyStr, Generic, TypeAlias +from typing_extensions import Self __date__: str __version__: str diff --git a/stubs/openpyxl/openpyxl/__init__.pyi b/stubs/openpyxl/openpyxl/__init__.pyi index 627a7afc5720..13e79c8bdc1d 100644 --- a/stubs/openpyxl/openpyxl/__init__.pyi +++ b/stubs/openpyxl/openpyxl/__init__.pyi @@ -1,6 +1,5 @@ from _typeshed import StrPath, SupportsRead, SupportsWrite -from typing import IO, Literal, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import IO, Literal, Protocol, TypeAlias, type_check_only from openpyxl.compat.numbers import NUMPY as NUMPY from openpyxl.reader.excel import load_workbook as load_workbook diff --git a/stubs/openpyxl/openpyxl/cell/__init__.pyi b/stubs/openpyxl/openpyxl/cell/__init__.pyi index 5501a28fd6eb..7bd4c41d9494 100644 --- a/stubs/openpyxl/openpyxl/cell/__init__.pyi +++ b/stubs/openpyxl/openpyxl/cell/__init__.pyi @@ -1,7 +1,6 @@ from datetime import date, datetime, time, timedelta from decimal import Decimal -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from openpyxl.cell.rich_text import CellRichText from openpyxl.worksheet.formula import ArrayFormula, DataTableFormula diff --git a/stubs/openpyxl/openpyxl/cell/text.pyi b/stubs/openpyxl/openpyxl/cell/text.pyi index 1a81339267a3..178fc1611059 100644 --- a/stubs/openpyxl/openpyxl/cell/text.pyi +++ b/stubs/openpyxl/openpyxl/cell/text.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Alias, Integer, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.nested import NestedString, NestedText, _NestedNoneSetParam diff --git a/stubs/openpyxl/openpyxl/chart/_chart.pyi b/stubs/openpyxl/openpyxl/chart/_chart.pyi index 0c7220617894..61e472151af8 100644 --- a/stubs/openpyxl/openpyxl/chart/_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/_chart.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.layout import Layout from openpyxl.chart.legend import Legend diff --git a/stubs/openpyxl/openpyxl/chart/area_chart.pyi b/stubs/openpyxl/openpyxl/chart/area_chart.pyi index 2d80d765ccff..25c1336a323a 100644 --- a/stubs/openpyxl/openpyxl/chart/area_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/area_chart.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, SeriesAxis, TextAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/axis.pyi b/stubs/openpyxl/openpyxl/chart/axis.pyi index 068ac588da0d..45292f690c93 100644 --- a/stubs/openpyxl/openpyxl/chart/axis.pyi +++ b/stubs/openpyxl/openpyxl/chart/axis.pyi @@ -1,6 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, overload -from typing_extensions import Self, TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload +from typing_extensions import Self from openpyxl.chart.layout import Layout from openpyxl.chart.shapes import GraphicalProperties diff --git a/stubs/openpyxl/openpyxl/chart/bar_chart.pyi b/stubs/openpyxl/openpyxl/chart/bar_chart.pyi index c5326c40e3cd..eecafc725838 100644 --- a/stubs/openpyxl/openpyxl/chart/bar_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/bar_chart.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, SeriesAxis, TextAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi b/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi index a6585ddd213e..d9e1cd4dc4f8 100644 --- a/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.axis import NumericAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/chartspace.pyi b/stubs/openpyxl/openpyxl/chart/chartspace.pyi index fef551ba034b..6effdd86a89f 100644 --- a/stubs/openpyxl/openpyxl/chart/chartspace.pyi +++ b/stubs/openpyxl/openpyxl/chart/chartspace.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, Incomplete, Unused -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.chart._3d import Surface, View3D from openpyxl.chart.legend import Legend diff --git a/stubs/openpyxl/openpyxl/chart/error_bar.pyi b/stubs/openpyxl/openpyxl/chart/error_bar.pyi index 4eb20316a98e..f39d64fa107f 100644 --- a/stubs/openpyxl/openpyxl/chart/error_bar.pyi +++ b/stubs/openpyxl/openpyxl/chart/error_bar.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.data_source import NumDataSource from openpyxl.chart.shapes import GraphicalProperties diff --git a/stubs/openpyxl/openpyxl/chart/label.pyi b/stubs/openpyxl/openpyxl/chart/label.pyi index a5b11f8b4f45..4c3fe53b3320 100644 --- a/stubs/openpyxl/openpyxl/chart/label.pyi +++ b/stubs/openpyxl/openpyxl/chart/label.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.text import RichText diff --git a/stubs/openpyxl/openpyxl/chart/layout.pyi b/stubs/openpyxl/openpyxl/chart/layout.pyi index 92cd7dd2b317..dde22b10a1d7 100644 --- a/stubs/openpyxl/openpyxl/chart/layout.pyi +++ b/stubs/openpyxl/openpyxl/chart/layout.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Alias, Typed from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/chart/legend.pyi b/stubs/openpyxl/openpyxl/chart/legend.pyi index 341e60026289..ba5fc7d3aa82 100644 --- a/stubs/openpyxl/openpyxl/chart/legend.pyi +++ b/stubs/openpyxl/openpyxl/chart/legend.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.layout import Layout from openpyxl.chart.shapes import GraphicalProperties diff --git a/stubs/openpyxl/openpyxl/chart/line_chart.pyi b/stubs/openpyxl/openpyxl/chart/line_chart.pyi index e03d6c35a397..4bcdc2abd5c8 100644 --- a/stubs/openpyxl/openpyxl/chart/line_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/line_chart.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, _BaseAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/marker.pyi b/stubs/openpyxl/openpyxl/chart/marker.pyi index 2b13a32b17dc..bd526ee90985 100644 --- a/stubs/openpyxl/openpyxl/chart/marker.pyi +++ b/stubs/openpyxl/openpyxl/chart/marker.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.picture import PictureOptions from openpyxl.chart.shapes import GraphicalProperties diff --git a/stubs/openpyxl/openpyxl/chart/picture.pyi b/stubs/openpyxl/openpyxl/chart/picture.pyi index d82a9022eb29..ee14ab6f85cd 100644 --- a/stubs/openpyxl/openpyxl/chart/picture.pyi +++ b/stubs/openpyxl/openpyxl/chart/picture.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import _ConvertibleToBool from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedNoneSet, _NestedNoneSetParam diff --git a/stubs/openpyxl/openpyxl/chart/pie_chart.pyi b/stubs/openpyxl/openpyxl/chart/pie_chart.pyi index f6e1d1fc6f3e..c43e6f1dafe6 100644 --- a/stubs/openpyxl/openpyxl/chart/pie_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/pie_chart.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.axis import ChartLines from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/radar_chart.pyi b/stubs/openpyxl/openpyxl/chart/radar_chart.pyi index c5b8fced041a..bf5cc4ca66ac 100644 --- a/stubs/openpyxl/openpyxl/chart/radar_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/radar_chart.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.axis import NumericAxis, TextAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi b/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi index 03e0ae289ca3..787e5c5e66c5 100644 --- a/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.axis import NumericAxis, TextAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/series.pyi b/stubs/openpyxl/openpyxl/chart/series.pyi index 3cad7ed07012..7feb904e0961 100644 --- a/stubs/openpyxl/openpyxl/chart/series.pyi +++ b/stubs/openpyxl/openpyxl/chart/series.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.data_source import AxDataSource, NumDataSource, StrRef from openpyxl.chart.error_bar import ErrorBars diff --git a/stubs/openpyxl/openpyxl/chart/shapes.pyi b/stubs/openpyxl/openpyxl/chart/shapes.pyi index c285bbe921a0..d2758e4b2cc8 100644 --- a/stubs/openpyxl/openpyxl/chart/shapes.pyi +++ b/stubs/openpyxl/openpyxl/chart/shapes.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Alias, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.nested import EmptyTag diff --git a/stubs/openpyxl/openpyxl/chart/trendline.pyi b/stubs/openpyxl/openpyxl/chart/trendline.pyi index e76da34ef402..9b93515b49b0 100644 --- a/stubs/openpyxl/openpyxl/chart/trendline.pyi +++ b/stubs/openpyxl/openpyxl/chart/trendline.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.chart.data_source import NumFmt from openpyxl.chart.layout import Layout diff --git a/stubs/openpyxl/openpyxl/chartsheet/publish.pyi b/stubs/openpyxl/openpyxl/chartsheet/publish.pyi index 56780bc5ca04..94a0fba4d4b7 100644 --- a/stubs/openpyxl/openpyxl/chartsheet/publish.pyi +++ b/stubs/openpyxl/openpyxl/chartsheet/publish.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors.base import Bool, Integer, Set, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi b/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi index 51799b51ce1f..efda9069f61f 100644 --- a/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi +++ b/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused from collections.abc import Generator -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.cell import _CellOrMergedCell from openpyxl.cell.text import Text diff --git a/stubs/openpyxl/openpyxl/comments/shape_writer.pyi b/stubs/openpyxl/openpyxl/comments/shape_writer.pyi index 22ac968ef82c..b908498d47a5 100644 --- a/stubs/openpyxl/openpyxl/comments/shape_writer.pyi +++ b/stubs/openpyxl/openpyxl/comments/shape_writer.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from ..xml._functions_overloads import _lxml_Element, _ParentElement diff --git a/stubs/openpyxl/openpyxl/compat/numbers.pyi b/stubs/openpyxl/openpyxl/compat/numbers.pyi index 7db010ddb060..060ba461585a 100644 --- a/stubs/openpyxl/openpyxl/compat/numbers.pyi +++ b/stubs/openpyxl/openpyxl/compat/numbers.pyi @@ -1,6 +1,5 @@ from decimal import Decimal -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias # NOTE: Can't specify numpy as a dependency because openpyxl doesn't declare it as one # import numpy diff --git a/stubs/openpyxl/openpyxl/descriptors/base.pyi b/stubs/openpyxl/openpyxl/descriptors/base.pyi index e7f9515bfcd5..e85095f8f2a7 100644 --- a/stubs/openpyxl/openpyxl/descriptors/base.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/base.pyi @@ -2,8 +2,7 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Readable from collections.abc import Iterable, Sized from datetime import datetime from re import Pattern -from typing import Any, Generic, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Generic, Literal, TypeAlias, TypeVar, overload from openpyxl.descriptors import Strict from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/descriptors/nested.pyi b/stubs/openpyxl/openpyxl/descriptors/nested.pyi index c2424b239ca5..e10e546383dc 100644 --- a/stubs/openpyxl/openpyxl/descriptors/nested.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/nested.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Unused from collections.abc import Iterable -from typing import Any, ClassVar, Literal, NoReturn, overload -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Literal, NoReturn, TypeAlias, overload from openpyxl.descriptors import Strict from openpyxl.descriptors.base import Bool, Convertible, Descriptor, Float, Integer, MinMax, NoneSet, Set, String diff --git a/stubs/openpyxl/openpyxl/drawing/colors.pyi b/stubs/openpyxl/openpyxl/drawing/colors.pyi index 00c6a9c5d865..c73200009afd 100644 --- a/stubs/openpyxl/openpyxl/drawing/colors.pyi +++ b/stubs/openpyxl/openpyxl/drawing/colors.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Final, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias, overload from openpyxl.descriptors import Strict, Typed from openpyxl.descriptors.base import Alias, Integer, MinMax, Set, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/drawing/effect.pyi b/stubs/openpyxl/openpyxl/drawing/effect.pyi index 839440db4c7e..550ef04cf892 100644 --- a/stubs/openpyxl/openpyxl/drawing/effect.pyi +++ b/stubs/openpyxl/openpyxl/drawing/effect.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors.base import Bool, Float, Integer, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/drawing/fill.pyi b/stubs/openpyxl/openpyxl/drawing/fill.pyi index 0a4a365244fd..6ee8f5964c6d 100644 --- a/stubs/openpyxl/openpyxl/drawing/fill.pyi +++ b/stubs/openpyxl/openpyxl/drawing/fill.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Alias, Bool, Integer, MinMax, NoneSet, Set, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/drawing/geometry.pyi b/stubs/openpyxl/openpyxl/drawing/geometry.pyi index 4e2241e94ebd..adf70df8d996 100644 --- a/stubs/openpyxl/openpyxl/drawing/geometry.pyi +++ b/stubs/openpyxl/openpyxl/drawing/geometry.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors.base import Alias, Bool, Float, Integer, MinMax, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import Coordinate, ExtensionList, Percentage diff --git a/stubs/openpyxl/openpyxl/drawing/image.pyi b/stubs/openpyxl/openpyxl/drawing/image.pyi index 645600adf025..c3a35a1384b4 100644 --- a/stubs/openpyxl/openpyxl/drawing/image.pyi +++ b/stubs/openpyxl/openpyxl/drawing/image.pyi @@ -1,8 +1,7 @@ from _typeshed import SupportsRead from pathlib import Path from types import ModuleType -from typing import Any, Literal -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias from openpyxl.drawing.spreadsheet_drawing import _AnchorBase diff --git a/stubs/openpyxl/openpyxl/drawing/line.pyi b/stubs/openpyxl/openpyxl/drawing/line.pyi index 130895608758..209d8165ea15 100644 --- a/stubs/openpyxl/openpyxl/drawing/line.pyi +++ b/stubs/openpyxl/openpyxl/drawing/line.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Alias, Integer, MinMax, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/drawing/properties.pyi b/stubs/openpyxl/openpyxl/drawing/properties.pyi index 0444a5321293..f95685c72325 100644 --- a/stubs/openpyxl/openpyxl/drawing/properties.pyi +++ b/stubs/openpyxl/openpyxl/drawing/properties.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors.base import Bool, NoneSet, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi b/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi index df2388c58f95..f675b423b091 100644 --- a/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi +++ b/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Alias, Bool, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.nested import NestedText diff --git a/stubs/openpyxl/openpyxl/drawing/text.pyi b/stubs/openpyxl/openpyxl/drawing/text.pyi index b5ed491d7cc4..3ead43febde6 100644 --- a/stubs/openpyxl/openpyxl/drawing/text.pyi +++ b/stubs/openpyxl/openpyxl/drawing/text.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Alias, Bool, Integer, MinMax, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import Coordinate, ExtensionList diff --git a/stubs/openpyxl/openpyxl/formatting/rule.pyi b/stubs/openpyxl/openpyxl/formatting/rule.pyi index cd5efaae934d..f74d9536a760 100644 --- a/stubs/openpyxl/openpyxl/formatting/rule.pyi +++ b/stubs/openpyxl/openpyxl/formatting/rule.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors import Float, Strict from openpyxl.descriptors.base import Bool, Integer, NoneSet, Set, String, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/formula/tokenizer.pyi b/stubs/openpyxl/openpyxl/formula/tokenizer.pyi index f37992ae87a6..f7b2e270b690 100644 --- a/stubs/openpyxl/openpyxl/formula/tokenizer.pyi +++ b/stubs/openpyxl/openpyxl/formula/tokenizer.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from re import Pattern -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias _TokenTypesNotOperand: TypeAlias = Literal[ "LITERAL", "FUNC", "ARRAY", "PAREN", "SEP", "OPERATOR-PREFIX", "OPERATOR-INFIX", "OPERATOR-POSTFIX", "WHITE-SPACE" diff --git a/stubs/openpyxl/openpyxl/packaging/custom.pyi b/stubs/openpyxl/openpyxl/packaging/custom.pyi index ec95af53f5b9..8721ae124986 100644 --- a/stubs/openpyxl/openpyxl/packaging/custom.pyi +++ b/stubs/openpyxl/openpyxl/packaging/custom.pyi @@ -1,8 +1,8 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete from collections.abc import Iterator from datetime import datetime -from typing import Any, Final, Generic, Literal, TypeVar -from typing_extensions import Self, TypeAlias +from typing import Any, Final, Generic, Literal, TypeAlias, TypeVar +from typing_extensions import Self from openpyxl.descriptors import Sequence, Strict from openpyxl.descriptors.base import Bool, DateTime, Float, Integer, String, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/packaging/workbook.pyi b/stubs/openpyxl/openpyxl/packaging/workbook.pyi index 3734b75e9932..5eeb46b36fea 100644 --- a/stubs/openpyxl/openpyxl/packaging/workbook.pyi +++ b/stubs/openpyxl/openpyxl/packaging/workbook.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl import _VisibilityType from openpyxl.descriptors.base import Alias, Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/pivot/cache.pyi b/stubs/openpyxl/openpyxl/pivot/cache.pyi index d156091b67a9..47a0578ab695 100644 --- a/stubs/openpyxl/openpyxl/pivot/cache.pyi +++ b/stubs/openpyxl/openpyxl/pivot/cache.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused from datetime import datetime -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors.base import Bool, DateTime, Float, Integer, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/pivot/table.pyi b/stubs/openpyxl/openpyxl/pivot/table.pyi index c90e97612c17..8082827be382 100644 --- a/stubs/openpyxl/openpyxl/pivot/table.pyi +++ b/stubs/openpyxl/openpyxl/pivot/table.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors.base import Bool, Integer, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/reader/excel.pyi b/stubs/openpyxl/openpyxl/reader/excel.pyi index 8c5472928e20..da45a60724e6 100644 --- a/stubs/openpyxl/openpyxl/reader/excel.pyi +++ b/stubs/openpyxl/openpyxl/reader/excel.pyi @@ -1,5 +1,4 @@ -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias from zipfile import ZipFile from openpyxl import _ZipFileFileProtocol diff --git a/stubs/openpyxl/openpyxl/styles/alignment.pyi b/stubs/openpyxl/openpyxl/styles/alignment.pyi index f6ec12d50bf3..40f69c4e46cd 100644 --- a/stubs/openpyxl/openpyxl/styles/alignment.pyi +++ b/stubs/openpyxl/openpyxl/styles/alignment.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToFloat from collections.abc import Iterator -from typing import ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias from openpyxl.descriptors.base import Alias, Bool, Min, MinMax, NoneSet, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/styles/borders.pyi b/stubs/openpyxl/openpyxl/styles/borders.pyi index 4c75f3e5ca25..099ce57e7446 100644 --- a/stubs/openpyxl/openpyxl/styles/borders.pyi +++ b/stubs/openpyxl/openpyxl/styles/borders.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterator -from typing import ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias from openpyxl.descriptors.base import Alias, Bool, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/styles/fills.pyi b/stubs/openpyxl/openpyxl/styles/fills.pyi index 85be254a903d..498f9d1a7c15 100644 --- a/stubs/openpyxl/openpyxl/styles/fills.pyi +++ b/stubs/openpyxl/openpyxl/styles/fills.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToFloat, Incomplete, Unused from collections.abc import Iterable, Iterator, Sequence as ABCSequence -from typing import ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias from openpyxl.descriptors import Sequence, Strict from openpyxl.descriptors.base import Alias, Float, MinMax, NoneSet, Set diff --git a/stubs/openpyxl/openpyxl/styles/fonts.pyi b/stubs/openpyxl/openpyxl/styles/fonts.pyi index 91ec30035922..48aeeb27d9b3 100644 --- a/stubs/openpyxl/openpyxl/styles/fonts.pyi +++ b/stubs/openpyxl/openpyxl/styles/fonts.pyi @@ -1,6 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt -from typing import ClassVar, Final, Literal -from typing_extensions import Self, TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias +from typing_extensions import Self from openpyxl.descriptors.base import Alias, _ConvertibleToBool from openpyxl.descriptors.nested import ( diff --git a/stubs/openpyxl/openpyxl/styles/numbers.pyi b/stubs/openpyxl/openpyxl/styles/numbers.pyi index 56ded3062828..92a6ee263689 100644 --- a/stubs/openpyxl/openpyxl/styles/numbers.pyi +++ b/stubs/openpyxl/openpyxl/styles/numbers.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused from re import Pattern -from typing import ClassVar, Final, Literal, SupportsIndex, overload -from typing_extensions import TypeGuard +from typing import ClassVar, Final, Literal, SupportsIndex, TypeGuard, overload from openpyxl.descriptors import Strict, String from openpyxl.descriptors.base import Integer diff --git a/stubs/openpyxl/openpyxl/styles/table.pyi b/stubs/openpyxl/openpyxl/styles/table.pyi index 889b12ea4da3..03e629854e3c 100644 --- a/stubs/openpyxl/openpyxl/styles/table.pyi +++ b/stubs/openpyxl/openpyxl/styles/table.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Bool, Integer, Set, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/utils/cell.pyi b/stubs/openpyxl/openpyxl/utils/cell.pyi index 22a05774e7fc..1c108f435d94 100644 --- a/stubs/openpyxl/openpyxl/utils/cell.pyi +++ b/stubs/openpyxl/openpyxl/utils/cell.pyi @@ -1,7 +1,6 @@ from collections.abc import Generator from re import Pattern -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias # "1:1" | "A1:A1" | "A:A" _RangeBoundariesTuple: TypeAlias = tuple[None, int, None, int] | tuple[int, int, int, int] | tuple[int, None, int, None] diff --git a/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi b/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi index 7e0e72060e2d..32cbcbd7371e 100644 --- a/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi +++ b/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from zipfile import ZipFile from openpyxl.descriptors.base import Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/workbook/properties.pyi b/stubs/openpyxl/openpyxl/workbook/properties.pyi index f95fd2be4505..145df27bd4b5 100644 --- a/stubs/openpyxl/openpyxl/workbook/properties.pyi +++ b/stubs/openpyxl/openpyxl/workbook/properties.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Bool, Float, Integer, NoneSet, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/workbook/smart_tags.pyi b/stubs/openpyxl/openpyxl/workbook/smart_tags.pyi index f6ae41ad7030..6f0baf5e448d 100644 --- a/stubs/openpyxl/openpyxl/workbook/smart_tags.pyi +++ b/stubs/openpyxl/openpyxl/workbook/smart_tags.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Bool, NoneSet, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/workbook/views.pyi b/stubs/openpyxl/openpyxl/workbook/views.pyi index 9c0abeb8872f..cd876c04952e 100644 --- a/stubs/openpyxl/openpyxl/workbook/views.pyi +++ b/stubs/openpyxl/openpyxl/workbook/views.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl import _VisibilityType from openpyxl.descriptors.base import Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/workbook/web.pyi b/stubs/openpyxl/openpyxl/workbook/web.pyi index a83615353cd8..21fcb87987c9 100644 --- a/stubs/openpyxl/openpyxl/workbook/web.pyi +++ b/stubs/openpyxl/openpyxl/workbook/web.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors.base import Bool, Integer, NoneSet, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/workbook/workbook.pyi b/stubs/openpyxl/openpyxl/workbook/workbook.pyi index f93f634796d5..402b82f4d0ed 100644 --- a/stubs/openpyxl/openpyxl/workbook/workbook.pyi +++ b/stubs/openpyxl/openpyxl/workbook/workbook.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, Unused from collections.abc import Iterator from datetime import datetime -from typing import Any, Final, type_check_only -from typing_extensions import TypeAlias, deprecated +from typing import Any, Final, TypeAlias, type_check_only +from typing_extensions import deprecated from zipfile import ZipFile from openpyxl import _Decodable, _ZipFileFileWriteProtocol diff --git a/stubs/openpyxl/openpyxl/worksheet/_writer.pyi b/stubs/openpyxl/openpyxl/worksheet/_writer.pyi index 92ca8dc7b9a6..329d15fc4b26 100644 --- a/stubs/openpyxl/openpyxl/worksheet/_writer.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/_writer.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete, ReadableBuffer, StrPath, Unused from collections.abc import Generator, Iterable -from typing import Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Protocol, TypeAlias, type_check_only from openpyxl.cell import _CellOrMergedCell from openpyxl.worksheet._write_only import WriteOnlyWorksheet diff --git a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi index d1f955ab2ad9..500a40aee250 100644 --- a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, Protocol, TypeAlias, type_check_only from openpyxl.descriptors.base import ( Alias, diff --git a/stubs/openpyxl/openpyxl/worksheet/filters.pyi b/stubs/openpyxl/openpyxl/worksheet/filters.pyi index 530321e49d0e..120a8b4f6a3a 100644 --- a/stubs/openpyxl/openpyxl/worksheet/filters.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/filters.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused from datetime import datetime -from typing import ClassVar, Final, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias, overload from openpyxl.descriptors.base import ( Alias, diff --git a/stubs/openpyxl/openpyxl/worksheet/ole.pyi b/stubs/openpyxl/openpyxl/worksheet/ole.pyi index 2b8d68e78de2..08749e9e3435 100644 --- a/stubs/openpyxl/openpyxl/worksheet/ole.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/ole.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, overload -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias, overload from openpyxl.descriptors.base import Bool, Integer, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/worksheet/page.pyi b/stubs/openpyxl/openpyxl/worksheet/page.pyi index d4c75ea6b259..843caa742464 100644 --- a/stubs/openpyxl/openpyxl/worksheet/page.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/page.pyi @@ -1,6 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Literal -from typing_extensions import Self, TypeAlias +from typing import ClassVar, Literal, TypeAlias +from typing_extensions import Self from openpyxl.descriptors.base import Bool, Float, Integer, NoneSet, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable, _ChildSerialisableTreeElement diff --git a/stubs/openpyxl/openpyxl/worksheet/table.pyi b/stubs/openpyxl/openpyxl/worksheet/table.pyi index 8650bbadec1d..0ab3d5052796 100644 --- a/stubs/openpyxl/openpyxl/worksheet/table.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/table.pyi @@ -1,7 +1,7 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused from collections.abc import Iterator -from typing import ClassVar, Final, Literal, overload -from typing_extensions import Self, TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias, overload +from typing_extensions import Self from openpyxl.descriptors import Strict, String from openpyxl.descriptors.base import Alias, Bool, Integer, NoneSet, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/worksheet/views.pyi b/stubs/openpyxl/openpyxl/worksheet/views.pyi index 72f05ffe0844..70e6420988fd 100644 --- a/stubs/openpyxl/openpyxl/worksheet/views.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/views.pyi @@ -1,6 +1,5 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Literal, TypeAlias from openpyxl.descriptors.base import Bool, Float, Integer, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi b/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi index cbdac51f363c..c08ed1526970 100644 --- a/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi +++ b/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi @@ -2,8 +2,7 @@ from _typeshed import Incomplete, ReadableBuffer from collections.abc import Iterable, Iterator, Mapping, Sequence -from typing import Any, Protocol, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, TypeVar, overload from xml.etree.ElementTree import Element, ElementTree, QName, XMLParser, _FileRead from openpyxl.chart.axis import ChartLines diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index 46e65a286538..cdebe0df4c5e 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable from threading import Event -from typing_extensions import TypeAlias +from typing import TypeAlias from paramiko.message import Message from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/message.pyi b/stubs/paramiko/paramiko/message.pyi index ef87f97b4eb2..88bed87b56a7 100644 --- a/stubs/paramiko/paramiko/message.pyi +++ b/stubs/paramiko/paramiko/message.pyi @@ -1,8 +1,7 @@ from _typeshed import ReadableBuffer from collections.abc import Iterable from io import BytesIO -from typing import Any, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, type_check_only @type_check_only class _SupportsAsBytes(Protocol): diff --git a/stubs/paramiko/paramiko/sftp_client.pyi b/stubs/paramiko/paramiko/sftp_client.pyi index ae59ad2ecb2b..f0bc69af6290 100644 --- a/stubs/paramiko/paramiko/sftp_client.pyi +++ b/stubs/paramiko/paramiko/sftp_client.pyi @@ -1,8 +1,8 @@ from _typeshed import StrOrBytesPath from collections.abc import Callable, Iterator from logging import Logger -from typing import IO -from typing_extensions import Self, TypeAlias +from typing import IO, TypeAlias +from typing_extensions import Self from paramiko.channel import Channel from paramiko.sftp import BaseSFTP diff --git a/stubs/paramiko/paramiko/transport.pyi b/stubs/paramiko/paramiko/transport.pyi index 6b2f2df1c279..1cb5214789db 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -4,8 +4,7 @@ from logging import Logger from socket import socket from threading import Condition, Event, Lock, Thread from types import ModuleType -from typing import Any, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, type_check_only from paramiko.auth_handler import AuthHandler, AuthOnlyHandler, _InteractiveCallback from paramiko.channel import Channel diff --git a/stubs/paramiko/paramiko/win_pageant.pyi b/stubs/paramiko/paramiko/win_pageant.pyi index 3cc870bb0719..1f9edee17eae 100644 --- a/stubs/paramiko/paramiko/win_pageant.pyi +++ b/stubs/paramiko/paramiko/win_pageant.pyi @@ -1,8 +1,7 @@ import ctypes import sys from _typeshed import Incomplete -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias if sys.platform == "win32": win32con_WM_COPYDATA: int diff --git a/stubs/parsimonious/parsimonious/expressions.pyi b/stubs/parsimonious/parsimonious/expressions.pyi index fcc6965fa442..514768f57b5a 100644 --- a/stubs/parsimonious/parsimonious/expressions.pyi +++ b/stubs/parsimonious/parsimonious/expressions.pyi @@ -1,8 +1,8 @@ import collections.abc from collections.abc import Callable, Mapping from re import Pattern -from typing import Any -from typing_extensions import Self, TypeAlias +from typing import Any, TypeAlias +from typing_extensions import Self from parsimonious.exceptions import ParseError from parsimonious.grammar import Grammar diff --git a/stubs/passlib/passlib/pwd.pyi b/stubs/passlib/passlib/pwd.pyi index a1189c161b7d..3b95af327e97 100644 --- a/stubs/passlib/passlib/pwd.pyi +++ b/stubs/passlib/passlib/pwd.pyi @@ -1,8 +1,8 @@ import random from abc import abstractmethod from collections.abc import Callable, Iterator, MutableMapping, Sequence -from typing import Any, Final, Literal, overload -from typing_extensions import Self, TypeAlias +from typing import Any, Final, Literal, TypeAlias, overload +from typing_extensions import Self class SequenceGenerator: length: int | None diff --git a/stubs/peewee/playhouse/flask_utils.pyi b/stubs/peewee/playhouse/flask_utils.pyi index 78c9ce62776e..a774c4eaa2fc 100644 --- a/stubs/peewee/playhouse/flask_utils.pyi +++ b/stubs/peewee/playhouse/flask_utils.pyi @@ -1,7 +1,6 @@ from _typeshed import Unused from collections.abc import Container -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from peewee import Database, ModelBase, Proxy diff --git a/stubs/pexpect/pexpect/spawnbase.pyi b/stubs/pexpect/pexpect/spawnbase.pyi index 116fe3b5f7f1..fc29f065d504 100644 --- a/stubs/pexpect/pexpect/spawnbase.pyi +++ b/stubs/pexpect/pexpect/spawnbase.pyi @@ -1,8 +1,7 @@ from asyncio import ReadTransport from collections.abc import Awaitable, Callable, Iterable from re import Match, Pattern -from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, overload, type_check_only -from typing_extensions import TypeAlias +from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, TypeAlias, overload, type_check_only from ._async import PatternWaiter from .exceptions import EOF, TIMEOUT diff --git a/stubs/pika/pika/compat.pyi b/stubs/pika/pika/compat.pyi index 6d3d68be080f..92494ec7f3f0 100644 --- a/stubs/pika/pika/compat.pyi +++ b/stubs/pika/pika/compat.pyi @@ -2,8 +2,7 @@ from abc import ABCMeta from collections.abc import ItemsView, Mapping, ValuesView from io import StringIO as StringIO from re import Pattern -from typing import Any, Final, SupportsIndex, TypeVar -from typing_extensions import TypeGuard +from typing import Any, Final, SupportsIndex, TypeGuard, TypeVar from urllib.parse import parse_qs, quote, unquote, urlencode as urlencode, urlparse as urlparse _KT = TypeVar("_KT") diff --git a/stubs/pika/pika/data.pyi b/stubs/pika/pika/data.pyi index c32cde389957..3e3b289c22a4 100644 --- a/stubs/pika/pika/data.pyi +++ b/stubs/pika/pika/data.pyi @@ -1,7 +1,7 @@ from collections.abc import Mapping from datetime import datetime from decimal import Decimal -from typing_extensions import TypeAlias +from typing import TypeAlias _Value: TypeAlias = str | bytes | bool | int | Decimal | datetime | _ArgumentMapping | list[_Value] | None _ArgumentMapping: TypeAlias = Mapping[str, _Value] diff --git a/stubs/pika/pika/spec.pyi b/stubs/pika/pika/spec.pyi index 05fd5e8dcaa0..ef1d13c3a69f 100644 --- a/stubs/pika/pika/spec.pyi +++ b/stubs/pika/pika/spec.pyi @@ -3,8 +3,8 @@ from _typeshed import Incomplete from collections.abc import Mapping from datetime import datetime from decimal import Decimal -from typing import ClassVar, Final, Literal -from typing_extensions import Self, TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias +from typing_extensions import Self from pika.amqp_object import Class, Method, Properties from pika.delivery_mode import DeliveryMode diff --git a/stubs/pony/pony/__init__.pyi b/stubs/pony/pony/__init__.pyi index 0bcdbcbd0c60..3a6a1123886a 100644 --- a/stubs/pony/pony/__init__.pyi +++ b/stubs/pony/pony/__init__.pyi @@ -1,5 +1,4 @@ -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias _Mode: TypeAlias = Literal[ "GAE-LOCAL", "GAE-SERVER", "MOD_WSGI", "INTERACTIVE", "FCGI-FLUP", "UWSGI", "FLASK", "CHERRYPY", "BOTTLE", "UNKNOWN" diff --git a/stubs/pony/pony/orm/core.pyi b/stubs/pony/pony/orm/core.pyi index 87c311910ab5..5bee204805bc 100644 --- a/stubs/pony/pony/orm/core.pyi +++ b/stubs/pony/pony/orm/core.pyi @@ -6,8 +6,8 @@ from _typeshed import Incomplete from collections import defaultdict from collections.abc import Callable, Generator from logging import Logger -from typing import Literal, NoReturn, TypeVar -from typing_extensions import Self, TypeAlias, deprecated +from typing import Literal, NoReturn, TypeAlias, TypeVar +from typing_extensions import Self, deprecated import pony as pony from pony.orm.asttranslation import TranslationError as TranslationError diff --git a/stubs/pony/pony/orm/sqlbuilding.pyi b/stubs/pony/pony/orm/sqlbuilding.pyi index abfe2f849511..e123d2be9993 100644 --- a/stubs/pony/pony/orm/sqlbuilding.pyi +++ b/stubs/pony/pony/orm/sqlbuilding.pyi @@ -1,4 +1,3 @@ -import sys import types from _typeshed import Incomplete from collections.abc import Iterable @@ -143,13 +142,8 @@ class SQLBuilder: def RANDOM(builder): ... def RAWSQL(builder, sql): ... def build_json_path(builder, path): ... - if sys.version_info >= (3, 10): - @classmethod - def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ... - else: - @classmethod - def eval_json_path(cls, values: Iterable[int | str | type | slice]) -> str: ... - + @classmethod + def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ... def JSON_QUERY(builder, expr, path) -> None: ... def JSON_VALUE(builder, expr, path, type) -> None: ... def JSON_NONZERO(builder, expr) -> None: ... diff --git a/stubs/portpicker/portpicker.pyi b/stubs/portpicker/portpicker.pyi index cac293cbcf52..9162cfa9874a 100644 --- a/stubs/portpicker/portpicker.pyi +++ b/stubs/portpicker/portpicker.pyi @@ -1,5 +1,5 @@ import socket -from typing_extensions import TypeAlias +from typing import TypeAlias _Port: TypeAlias = int diff --git a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi index a6f744c26074..c392f1f37dbf 100644 --- a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi +++ b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi @@ -17,8 +17,8 @@ flag "--${NAME}_out" is passed to protoc. import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.descriptor_pb2 @@ -26,11 +26,6 @@ import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index d1150c0618d1..69f1c2382d0b 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -12,19 +12,14 @@ without any other information (e.g. without reading its imports). import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Edition: diff --git a/stubs/protobuf/google/protobuf/internal/decoder.pyi b/stubs/protobuf/google/protobuf/internal/decoder.pyi index 94ed7f615360..9024cd2f383d 100644 --- a/stubs/protobuf/google/protobuf/internal/decoder.pyi +++ b/stubs/protobuf/google/protobuf/internal/decoder.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from google.protobuf.descriptor import Descriptor, FieldDescriptor from google.protobuf.message import Message diff --git a/stubs/protobuf/google/protobuf/internal/encoder.pyi b/stubs/protobuf/google/protobuf/internal/encoder.pyi index 278478edb3ed..a4473fb49919 100644 --- a/stubs/protobuf/google/protobuf/internal/encoder.pyi +++ b/stubs/protobuf/google/protobuf/internal/encoder.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing_extensions import TypeAlias +from typing import TypeAlias from google.protobuf.descriptor import FieldDescriptor diff --git a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi index 6527d3f6978e..957e30b9d301 100644 --- a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +++ b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete, SupportsItems from collections.abc import Iterable, Iterator, KeysView, Mapping, Sequence from datetime import datetime, timedelta, tzinfo -from typing import Any as tAny -from typing_extensions import TypeAlias +from typing import Any as tAny, TypeAlias from google.protobuf import struct_pb2 diff --git a/stubs/protobuf/google/protobuf/struct_pb2.pyi b/stubs/protobuf/google/protobuf/struct_pb2.pyi index 8e63dabfc2f1..1308b9475726 100644 --- a/stubs/protobuf/google/protobuf/struct_pb2.pyi +++ b/stubs/protobuf/google/protobuf/struct_pb2.pyi @@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -43,11 +43,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.internal.well_known_types import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _NullValue: diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index c9a9da29a125..e2096d630600 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -1,7 +1,6 @@ from _typeshed import SupportsWrite from collections.abc import Callable, Iterable -from typing import Any, TypeVar -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, TypeVar from .descriptor import FieldDescriptor from .descriptor_pool import DescriptorPool diff --git a/stubs/protobuf/google/protobuf/type_pb2.pyi b/stubs/protobuf/google/protobuf/type_pb2.pyi index a8a7eb07c778..e01d65d565b2 100644 --- a/stubs/protobuf/google/protobuf/type_pb2.pyi +++ b/stubs/protobuf/google/protobuf/type_pb2.pyi @@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -44,11 +44,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import google.protobuf.source_context_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Syntax: diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 7012bf7e8233..c54581f8d668 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -4,8 +4,8 @@ from collections.abc import Callable, Collection, Iterable, Iterator from contextlib import AbstractContextManager from subprocess import _CMD, _ENV, _FILE from types import TracebackType -from typing import Any, Literal, Protocol, overload, type_check_only -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, Literal, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import Self, deprecated from psutil._common import ( AIX as AIX, @@ -237,36 +237,6 @@ class Popen(Process): pipesize: int = -1, process_group: int | None = None, ) -> None: ... - elif sys.version_info >= (3, 10): - def __init__( - self, - args: _CMD, - bufsize: int = -1, - executable: StrOrBytesPath | None = None, - stdin: _FILE | None = None, - stdout: _FILE | None = None, - stderr: _FILE | None = None, - preexec_fn: Callable[[], object] | None = None, - close_fds: bool = True, - shell: bool = False, - cwd: StrOrBytesPath | None = None, - env: _ENV | None = None, - universal_newlines: bool | None = None, - startupinfo: Any | None = None, - creationflags: int = 0, - restore_signals: bool = True, - start_new_session: bool = False, - pass_fds: Collection[int] = (), - *, - text: bool | None = None, - encoding: str | None = None, - errors: str | None = None, - user: str | int | None = None, - group: str | int | None = None, - extra_groups: Iterable[str | int] | None = None, - umask: int = -1, - pipesize: int = -1, - ) -> None: ... else: def __init__( self, @@ -295,6 +265,7 @@ class Popen(Process): group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, + pipesize: int = -1, ) -> None: ... def __enter__(self) -> Self: ... diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi index 8899cb13f8de..aabab424befc 100644 --- a/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -2,8 +2,8 @@ import datetime as dt from _typeshed import ConvertibleToInt, Incomplete, SupportsRead, SupportsReadline, SupportsWrite, Unused from collections.abc import Callable, Iterable, Mapping, Sequence from types import TracebackType -from typing import Any, Literal, NoReturn, Protocol, TextIO, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias, disjoint_base +from typing import Any, Literal, NoReturn, Protocol, TextIO, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self, disjoint_base from psycopg2.extras import ReplicationCursor as extras_ReplicationCursor from psycopg2.sql import Composable diff --git a/stubs/pyaudio/pyaudio.pyi b/stubs/pyaudio/pyaudio.pyi index 214688981ab6..8df1043bb36b 100644 --- a/stubs/pyaudio/pyaudio.pyi +++ b/stubs/pyaudio/pyaudio.pyi @@ -1,7 +1,6 @@ import sys from collections.abc import Callable, Mapping, Sequence -from typing import ClassVar, Final -from typing_extensions import TypeAlias +from typing import ClassVar, Final, TypeAlias __docformat__: str diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index 2dc2f2e35ca4..ff0741ae0dfc 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,7 +1,6 @@ from collections.abc import Collection, Sequence from pathlib import Path -from typing import Generic, Literal, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Generic, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only import numpy as np import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index e402feaf4214..ab763578101a 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -1,5 +1,4 @@ -from typing import Literal, TypedDict, type_check_only -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, TypedDict, type_check_only import numpy as np import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 6f75c9e38f22..dffff2e673db 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -1,5 +1,4 @@ -from typing import Any, overload -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, overload import numpy as np import numpy.typing as npt diff --git a/stubs/pyflakes/pyflakes/checker.pyi b/stubs/pyflakes/pyflakes/checker.pyi index 0b87aa5a84e6..0c2fd601fb9b 100644 --- a/stubs/pyflakes/pyflakes/checker.pyi +++ b/stubs/pyflakes/pyflakes/checker.pyi @@ -4,8 +4,8 @@ from _typeshed import StrOrLiteralStr, Unused from collections.abc import Callable, Generator, Iterable, Iterator, Sequence from contextlib import contextmanager from re import Pattern -from typing import Any, ClassVar, Final, Literal, TypeVar, overload -from typing_extensions import Never, ParamSpec, TypeAlias +from typing import Any, ClassVar, Final, Literal, TypeAlias, TypeVar, overload +from typing_extensions import Never, ParamSpec from pyflakes.messages import Message @@ -19,12 +19,7 @@ builtin_vars: Final[list[str]] def parse_format_string( format_string: StrOrLiteralStr, ) -> Iterable[tuple[StrOrLiteralStr, StrOrLiteralStr | None, StrOrLiteralStr | None, StrOrLiteralStr | None]]: ... - -if sys.version_info >= (3, 10): - def getAlternatives(n: ast.If | ast.Try | ast.Match) -> list[ast.AST]: ... - -else: - def getAlternatives(n: ast.If | ast.Try) -> list[ast.AST]: ... +def getAlternatives(n: ast.If | ast.Try | ast.Match) -> list[ast.AST]: ... FOR_TYPES: Final[tuple[type[ast.For], type[ast.AsyncFor]]] MAPPING_KEY_RE: Final[Pattern[str]] @@ -149,29 +144,16 @@ class AnnotationState: def in_annotation(func: _F) -> _F: ... def in_string_annotation(func: _F) -> _F: ... -if sys.version_info >= (3, 10): - _Match: TypeAlias = ast.Match - _MatchCase: TypeAlias = ast.match_case - _MatchValue: TypeAlias = ast.MatchValue - _MatchSingleton: TypeAlias = ast.MatchSingleton - _MatchSequence: TypeAlias = ast.MatchSequence - _MatchStar: TypeAlias = ast.MatchStar - _MatchMapping: TypeAlias = ast.MatchMapping - _MatchClass: TypeAlias = ast.MatchClass - _MatchAs: TypeAlias = ast.MatchAs - _MatchOr: TypeAlias = ast.MatchOr -else: - # The methods using these should never be called on Python < 3.10. - _Match: TypeAlias = Never - _MatchCase: TypeAlias = Never - _MatchValue: TypeAlias = Never - _MatchSingleton: TypeAlias = Never - _MatchSequence: TypeAlias = Never - _MatchStar: TypeAlias = Never - _MatchMapping: TypeAlias = Never - _MatchClass: TypeAlias = Never - _MatchAs: TypeAlias = Never - _MatchOr: TypeAlias = Never +_Match: TypeAlias = ast.Match +_MatchCase: TypeAlias = ast.match_case +_MatchValue: TypeAlias = ast.MatchValue +_MatchSingleton: TypeAlias = ast.MatchSingleton +_MatchSequence: TypeAlias = ast.MatchSequence +_MatchStar: TypeAlias = ast.MatchStar +_MatchMapping: TypeAlias = ast.MatchMapping +_MatchClass: TypeAlias = ast.MatchClass +_MatchAs: TypeAlias = ast.MatchAs +_MatchOr: TypeAlias = ast.MatchOr if sys.version_info >= (3, 12): _TypeVar: TypeAlias = ast.TypeVar diff --git a/stubs/pyinstaller/PyInstaller/__main__.pyi b/stubs/pyinstaller/PyInstaller/__main__.pyi index 8b295520d59b..9f6397bdab29 100644 --- a/stubs/pyinstaller/PyInstaller/__main__.pyi +++ b/stubs/pyinstaller/PyInstaller/__main__.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsKeysAndGetItem from collections.abc import Iterable -from typing_extensions import TypeAlias +from typing import TypeAlias # Used to update PyInstaller.config.CONF _PyIConfig: TypeAlias = ( diff --git a/stubs/pyinstaller/PyInstaller/building/__init__.pyi b/stubs/pyinstaller/PyInstaller/building/__init__.pyi index 036849a0e51c..bf87a78779b4 100644 --- a/stubs/pyinstaller/PyInstaller/building/__init__.pyi +++ b/stubs/pyinstaller/PyInstaller/building/__init__.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeAlias +from typing import TypeAlias # PyiBlockCipher is deprecated and misleads users into thinking it adds any security. Runtime deprecation warning: # DEPRECATION: Bytecode encryption will be removed in PyInstaller v6. diff --git a/stubs/pyinstaller/PyInstaller/building/api.pyi b/stubs/pyinstaller/PyInstaller/building/api.pyi index 1aa2339ff101..97e2c340c5a9 100644 --- a/stubs/pyinstaller/PyInstaller/building/api.pyi +++ b/stubs/pyinstaller/PyInstaller/building/api.pyi @@ -6,8 +6,7 @@ import sys from _typeshed import FileDescriptorOrPath, StrOrBytesPath, StrPath, Unused from collections.abc import Iterable, Mapping, Sequence from types import CodeType -from typing import ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Final, Literal, TypeAlias from PyInstaller.building import _PyiBlockCipher from PyInstaller.building.build_main import Analysis diff --git a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi index cfb1cf70b6d3..0c3878a0b9ce 100644 --- a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi +++ b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi @@ -1,7 +1,7 @@ # https://pyinstaller.org/en/stable/advanced-topics.html#the-toc-and-tree-classes from collections.abc import Iterable, Sequence -from typing import ClassVar, Literal, SupportsIndex -from typing_extensions import LiteralString, Self, TypeAlias +from typing import ClassVar, Literal, SupportsIndex, TypeAlias +from typing_extensions import LiteralString, Self _TypeCode: TypeAlias = Literal["DEPENDENCY", "SYMLINK", "DATA", "BINARY", "EXECUTABLE", "EXTENSION", "OPTION"] _TOCTuple: TypeAlias = tuple[str, str | None, _TypeCode | None] diff --git a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi index 027d6a54739a..8e6f37c238d3 100644 --- a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi @@ -4,7 +4,7 @@ # However, some PyiModuleGraph typed class attributes are still documented as existing in imphookapi. from _typeshed import Incomplete, StrPath, SupportsKeysAndGetItem from collections.abc import Iterable -from typing_extensions import TypeAlias +from typing import TypeAlias from PyInstaller.lib.modulegraph.modulegraph import Alias, Node diff --git a/stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi b/stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi index f4af6b33c4ac..1e2e7c6425ef 100644 --- a/stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi @@ -1,7 +1,6 @@ from _typeshed import SliceableBuffer, Unused from collections.abc import Sequence -from typing import Any, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, type_check_only _FourIntSequence: TypeAlias = Sequence[int] _TwoIntSequence: TypeAlias = Sequence[int] diff --git a/stubs/pyjks/jks/bks.pyi b/stubs/pyjks/jks/bks.pyi index 0e12e65376ef..d083d6b95d2f 100644 --- a/stubs/pyjks/jks/bks.pyi +++ b/stubs/pyjks/jks/bks.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsKeysAndGetItem, Unused -from typing import Final, Literal -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, TypeAlias +from typing_extensions import Self from .jks import TrustedCertEntry from .util import AbstractKeystore, AbstractKeystoreEntry diff --git a/stubs/pyjks/jks/jks.pyi b/stubs/pyjks/jks/jks.pyi index 9c816cc7bf74..fb1e814864a1 100644 --- a/stubs/pyjks/jks/jks.pyi +++ b/stubs/pyjks/jks/jks.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsKeysAndGetItem, Unused from collections.abc import Iterable -from typing import Final, Literal, NoReturn, overload -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, NoReturn, TypeAlias, overload +from typing_extensions import Self from .util import AbstractKeystore, AbstractKeystoreEntry diff --git a/stubs/pyjks/jks/rfc7292.pyi b/stubs/pyjks/jks/rfc7292.pyi index b57599fc38da..400f6d577568 100644 --- a/stubs/pyjks/jks/rfc7292.pyi +++ b/stubs/pyjks/jks/rfc7292.pyi @@ -1,6 +1,5 @@ from hashlib import _Hash -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias from pyasn1.type.namedtype import NamedTypes from pyasn1.type.univ import Sequence diff --git a/stubs/pyjks/jks/util.pyi b/stubs/pyjks/jks/util.pyi index 84f576dce440..8e913d36654c 100644 --- a/stubs/pyjks/jks/util.pyi +++ b/stubs/pyjks/jks/util.pyi @@ -1,8 +1,8 @@ from _typeshed import FileDescriptorOrPath, SupportsKeysAndGetItem, Unused from collections.abc import Iterable from struct import Struct -from typing import Final, Literal -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, TypeAlias +from typing_extensions import Self from .bks import BksKeyEntry from .jks import PrivateKeyEntry diff --git a/stubs/pyperclip/pyperclip/__init__.pyi b/stubs/pyperclip/pyperclip/__init__.pyi index 4d2947e849f7..28ac5248078d 100644 --- a/stubs/pyperclip/pyperclip/__init__.pyi +++ b/stubs/pyperclip/pyperclip/__init__.pyi @@ -1,8 +1,7 @@ __all__ = ["copy", "paste", "set_clipboard", "determine_clipboard"] from collections.abc import Callable -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias class PyperclipException(RuntimeError): ... diff --git a/stubs/pyserial/serial/win32.pyi b/stubs/pyserial/serial/win32.pyi index be1cb025d166..807f2679c4e5 100644 --- a/stubs/pyserial/serial/win32.pyi +++ b/stubs/pyserial/serial/win32.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import Incomplete from ctypes import Structure, Union, _CField, _NamedFuncPointer, _Pointer, c_int64, c_ulong, c_void_p from ctypes.wintypes import DWORD -from typing_extensions import TypeAlias +from typing import TypeAlias if sys.platform == "win32": def is_64bit() -> bool: ... diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 188e13aff8ac..087bc5695425 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -2,8 +2,8 @@ from collections.abc import Callable, Sequence from contextlib import AbstractContextManager from stat import S_IMODE as S_IMODE from types import TracebackType -from typing import IO, Literal -from typing_extensions import Self, TypeAlias +from typing import IO, Literal, TypeAlias +from typing_extensions import Self import paramiko from paramiko import AuthenticationException as AuthenticationException diff --git a/stubs/pysftp/pysftp/helpers.pyi b/stubs/pysftp/pysftp/helpers.pyi index 96116d13f33f..7967be313ae2 100644 --- a/stubs/pysftp/pysftp/helpers.pyi +++ b/stubs/pysftp/pysftp/helpers.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Iterator from contextlib import AbstractContextManager -from typing_extensions import TypeAlias +from typing import TypeAlias def known_hosts() -> str: ... def st_mode_to_int(val: int) -> int: ... diff --git a/stubs/python-crontab/crontab.pyi b/stubs/python-crontab/crontab.pyi index a33bb1193eb8..c7ca54a2f581 100644 --- a/stubs/python-crontab/crontab.pyi +++ b/stubs/python-crontab/crontab.pyi @@ -7,8 +7,8 @@ from collections.abc import Callable, Generator, Iterable, Iterator from datetime import datetime from logging import Logger from types import TracebackType -from typing import Any, Final, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Final, Literal, Protocol, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self from croniter.croniter import croniter from cronlog import CronLog diff --git a/stubs/python-dateutil/dateutil/parser/_parser.pyi b/stubs/python-dateutil/dateutil/parser/_parser.pyi index 9119ec25d7b7..65f2af983d12 100644 --- a/stubs/python-dateutil/dateutil/parser/_parser.pyi +++ b/stubs/python-dateutil/dateutil/parser/_parser.pyi @@ -3,8 +3,8 @@ from _typeshed import SupportsRead from collections.abc import Callable, Mapping from datetime import _TzInfo, datetime from io import StringIO -from typing import IO, Any -from typing_extensions import Self, TypeAlias +from typing import IO, Any, TypeAlias +from typing_extensions import Self _FileOrStr: TypeAlias = bytes | str | IO[str] | IO[Any] _TzData: TypeAlias = _TzInfo | int | str | None diff --git a/stubs/python-dateutil/dateutil/parser/isoparser.pyi b/stubs/python-dateutil/dateutil/parser/isoparser.pyi index 51a9c153af81..82bdb19b9baf 100644 --- a/stubs/python-dateutil/dateutil/parser/isoparser.pyi +++ b/stubs/python-dateutil/dateutil/parser/isoparser.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsRead from datetime import date, datetime, time, tzinfo -from typing_extensions import TypeAlias +from typing import TypeAlias _Readable: TypeAlias = SupportsRead[str | bytes] _TakesAscii: TypeAlias = str | bytes | _Readable diff --git a/stubs/python-dateutil/dateutil/relativedelta.pyi b/stubs/python-dateutil/dateutil/relativedelta.pyi index 90f155f70717..7214673c2da1 100644 --- a/stubs/python-dateutil/dateutil/relativedelta.pyi +++ b/stubs/python-dateutil/dateutil/relativedelta.pyi @@ -1,6 +1,6 @@ from datetime import date, timedelta -from typing import SupportsFloat, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import SupportsFloat, TypeAlias, TypeVar, overload +from typing_extensions import Self # See #9817 for why we reexport this here from ._common import weekday as weekday diff --git a/stubs/python-dateutil/dateutil/rrule.pyi b/stubs/python-dateutil/dateutil/rrule.pyi index dd712283fd3a..a8f40a7fa616 100644 --- a/stubs/python-dateutil/dateutil/rrule.pyi +++ b/stubs/python-dateutil/dateutil/rrule.pyi @@ -1,7 +1,7 @@ import datetime from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence -from typing import Final, Literal, overload -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, TypeAlias, overload +from typing_extensions import Self from dateutil.parser._parser import _TzInfos diff --git a/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi b/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi index 65627ecdd773..687e3f563a89 100644 --- a/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi +++ b/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from collections.abc import Callable from io import BytesIO from tarfile import _Fileobj -from typing import Final, TypeVar, overload -from typing_extensions import Self, TypeAlias, deprecated +from typing import Final, TypeAlias, TypeVar, overload +from typing_extensions import Self, deprecated from dateutil.tz import tzfile as _tzfile diff --git a/stubs/python-jenkins/jenkins/__init__.pyi b/stubs/python-jenkins/jenkins/__init__.pyi index a605ab5c0ee0..67182d33b61b 100644 --- a/stubs/python-jenkins/jenkins/__init__.pyi +++ b/stubs/python-jenkins/jenkins/__init__.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Mapping, MutableMapping, Sequence from re import Pattern -from typing import Any, Final, Literal, TypedDict, overload, type_check_only -from typing_extensions import Required, TypeAlias, deprecated +from typing import Any, Final, Literal, TypeAlias, TypedDict, overload, type_check_only +from typing_extensions import Required, deprecated import requests from requests.models import Request, Response diff --git a/stubs/python-nmap/nmap/nmap.pyi b/stubs/python-nmap/nmap/nmap.pyi index 884a9b363743..740467d72e55 100644 --- a/stubs/python-nmap/nmap/nmap.pyi +++ b/stubs/python-nmap/nmap/nmap.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Iterable, Iterator -from typing import Any, TypedDict, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, TypedDict, TypeVar, type_check_only _T = TypeVar("_T") _Callback: TypeAlias = Callable[[str, _Result], object] diff --git a/stubs/python-xlib/Xlib/_typing.pyi b/stubs/python-xlib/Xlib/_typing.pyi index 550da8afdc16..90f05ff16109 100644 --- a/stubs/python-xlib/Xlib/_typing.pyi +++ b/stubs/python-xlib/Xlib/_typing.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import TypeVar -from typing_extensions import TypeAlias +from typing import TypeAlias, TypeVar from Xlib.error import XError from Xlib.protocol.rq import Request diff --git a/stubs/python-xlib/Xlib/display.pyi b/stubs/python-xlib/Xlib/display.pyi index 535e3e2e0139..8ee8b6df0c36 100644 --- a/stubs/python-xlib/Xlib/display.pyi +++ b/stubs/python-xlib/Xlib/display.pyi @@ -1,8 +1,7 @@ from collections.abc import Callable, Iterable, Sequence from re import Pattern from types import FunctionType, MethodType -from typing import Any, Literal, TypedDict, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias, TypedDict, overload, type_check_only from Xlib import error from Xlib._typing import ErrorHandler diff --git a/stubs/python-xlib/Xlib/ext/composite.pyi b/stubs/python-xlib/Xlib/ext/composite.pyi index 3d647de0f6b8..9582ae777e6c 100644 --- a/stubs/python-xlib/Xlib/ext/composite.pyi +++ b/stubs/python-xlib/Xlib/ext/composite.pyi @@ -1,7 +1,6 @@ from _typeshed import Unused from collections.abc import Callable -from typing import Any, Final -from typing_extensions import TypeAlias +from typing import Any, Final, TypeAlias from Xlib._typing import ErrorHandler from Xlib.display import Display diff --git a/stubs/python-xlib/Xlib/ext/randr.pyi b/stubs/python-xlib/Xlib/ext/randr.pyi index 0ff95176124f..9aac2eee1301 100644 --- a/stubs/python-xlib/Xlib/ext/randr.pyi +++ b/stubs/python-xlib/Xlib/ext/randr.pyi @@ -1,6 +1,5 @@ from collections.abc import Sequence -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias from Xlib.display import Display from Xlib.protocol import request, rq diff --git a/stubs/python-xlib/Xlib/protocol/event.pyi b/stubs/python-xlib/Xlib/protocol/event.pyi index b4366c8a9c40..f033a985b030 100644 --- a/stubs/python-xlib/Xlib/protocol/event.pyi +++ b/stubs/python-xlib/Xlib/protocol/event.pyi @@ -1,5 +1,4 @@ -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias from Xlib.protocol import rq diff --git a/stubs/python-xlib/Xlib/protocol/rq.pyi b/stubs/python-xlib/Xlib/protocol/rq.pyi index b429499d38a0..689e7cd5dfd7 100644 --- a/stubs/python-xlib/Xlib/protocol/rq.pyi +++ b/stubs/python-xlib/Xlib/protocol/rq.pyi @@ -4,8 +4,8 @@ from array import array # Avoid name collision with List.type from builtins import type as Type from collections.abc import Callable, Iterable, Sequence -from typing import Any, Final, Literal, SupportsIndex, TypeVar, overload, type_check_only -from typing_extensions import LiteralString, TypeAlias +from typing import Any, Final, Literal, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import LiteralString from Xlib._typing import ErrorHandler from Xlib.display import _BaseDisplay, _ResourceBaseClass diff --git a/stubs/python-xlib/Xlib/protocol/structs.pyi b/stubs/python-xlib/Xlib/protocol/structs.pyi index 60e004c478ac..47508e6a636c 100644 --- a/stubs/python-xlib/Xlib/protocol/structs.pyi +++ b/stubs/python-xlib/Xlib/protocol/structs.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Sequence -from typing_extensions import TypeAlias +from typing import TypeAlias from Xlib.protocol import rq diff --git a/stubs/python-xlib/Xlib/rdb.pyi b/stubs/python-xlib/Xlib/rdb.pyi index e330353a01ec..f0ec57c5b656 100644 --- a/stubs/python-xlib/Xlib/rdb.pyi +++ b/stubs/python-xlib/Xlib/rdb.pyi @@ -1,8 +1,7 @@ from _typeshed import SupportsDunderGT, SupportsDunderLT, SupportsRead from collections.abc import Iterable, Mapping, Sequence from re import Pattern -from typing import Any, Final, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Final, Protocol, TypeAlias, TypeVar, overload, type_check_only from Xlib.display import Display from Xlib.support.lock import _DummyLock diff --git a/stubs/python-xlib/Xlib/support/unix_connect.pyi b/stubs/python-xlib/Xlib/support/unix_connect.pyi index 600d3daa76c4..74e6a749ff91 100644 --- a/stubs/python-xlib/Xlib/support/unix_connect.pyi +++ b/stubs/python-xlib/Xlib/support/unix_connect.pyi @@ -4,8 +4,7 @@ from _typeshed import Unused from platform import uname_result from re import Pattern from socket import socket -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias if sys.platform == "darwin": SUPPORTED_PROTOCOLS: Final[tuple[None, Literal["tcp"], Literal["unix"], Literal["darwin"]]] diff --git a/stubs/pywin32/_win32typing.pyi b/stubs/pywin32/_win32typing.pyi index 38d9d578b468..8da571213176 100644 --- a/stubs/pywin32/_win32typing.pyi +++ b/stubs/pywin32/_win32typing.pyi @@ -1,8 +1,8 @@ # Not available at runtime. Contains type definitions that are otherwise not exposed and not part of a specific module. from _typeshed import Incomplete, Unused from collections.abc import Iterable, Sequence -from typing import Literal, NoReturn, SupportsIndex, final, overload -from typing_extensions import Self, TypeAlias, deprecated, disjoint_base +from typing import Literal, NoReturn, SupportsIndex, TypeAlias, final, overload +from typing_extensions import Self, deprecated, disjoint_base from win32.lib.pywintypes import TimeType diff --git a/stubs/pywin32/pythoncom.pyi b/stubs/pywin32/pythoncom.pyi index 6368357725a9..d938fb4ca787 100644 --- a/stubs/pywin32/pythoncom.pyi +++ b/stubs/pywin32/pythoncom.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, Unused from abc import abstractmethod from collections.abc import Sequence -from typing import ClassVar, SupportsInt, overload -from typing_extensions import TypeAlias, deprecated, disjoint_base +from typing import ClassVar, SupportsInt, TypeAlias, overload +from typing_extensions import deprecated, disjoint_base import _win32typing from win32.lib.pywintypes import TimeType, com_error as com_error diff --git a/stubs/pywin32/win32/lib/ntsecuritycon.pyi b/stubs/pywin32/win32/lib/ntsecuritycon.pyi index 19bb7a9d5b8b..7d4d6e8cc02c 100644 --- a/stubs/pywin32/win32/lib/ntsecuritycon.pyi +++ b/stubs/pywin32/win32/lib/ntsecuritycon.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeAlias +from typing import TypeAlias _SixIntTuple: TypeAlias = tuple[int, int, int, int, int, int] diff --git a/stubs/pywin32/win32com/client/__init__.pyi b/stubs/pywin32/win32com/client/__init__.pyi index 987a842edbec..563a0768c21b 100644 --- a/stubs/pywin32/win32com/client/__init__.pyi +++ b/stubs/pywin32/win32com/client/__init__.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete, Unused from collections.abc import Iterator -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias import _win32typing from pythoncom import com_record diff --git a/stubs/pywin32/win32com/client/dynamic.pyi b/stubs/pywin32/win32com/client/dynamic.pyi index 17b3cb620fff..87cd47fb3e34 100644 --- a/stubs/pywin32/win32com/client/dynamic.pyi +++ b/stubs/pywin32/win32com/client/dynamic.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete -from typing import Any, Protocol, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, TypeVar, overload import _win32typing from win32.lib.pywintypes import IIDType diff --git a/stubs/pywin32/win32com/server/dispatcher.pyi b/stubs/pywin32/win32com/server/dispatcher.pyi index 2644262edd5c..6c4c9dd74ace 100644 --- a/stubs/pywin32/win32com/server/dispatcher.pyi +++ b/stubs/pywin32/win32com/server/dispatcher.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing_extensions import TypeAlias +from typing import TypeAlias from win32com.server.policy import BasicWrapPolicy diff --git a/stubs/pywin32/win32com/universal.pyi b/stubs/pywin32/win32com/universal.pyi index fe0e626fc0d3..99e6186e863d 100644 --- a/stubs/pywin32/win32com/universal.pyi +++ b/stubs/pywin32/win32com/universal.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable -from typing_extensions import TypeAlias +from typing import TypeAlias import pythoncom diff --git a/stubs/pywin32/win32comext/adsi/adsi.pyi b/stubs/pywin32/win32comext/adsi/adsi.pyi index b5acc70cb365..69cb550e4fd2 100644 --- a/stubs/pywin32/win32comext/adsi/adsi.pyi +++ b/stubs/pywin32/win32comext/adsi/adsi.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing_extensions import TypeAlias +from typing import TypeAlias import _win32typing from win32.lib.pywintypes import com_error diff --git a/stubs/pywin32/win32comext/propsys/propsys.pyi b/stubs/pywin32/win32comext/propsys/propsys.pyi index 08b4c67826e9..090ef130f25b 100644 --- a/stubs/pywin32/win32comext/propsys/propsys.pyi +++ b/stubs/pywin32/win32comext/propsys/propsys.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeAlias +from typing import TypeAlias import _win32typing from win32.lib.pywintypes import com_error diff --git a/stubs/pywin32/win32comext/shell/shell.pyi b/stubs/pywin32/win32comext/shell/shell.pyi index 8b63eda438ff..357a9b38c11f 100644 --- a/stubs/pywin32/win32comext/shell/shell.pyi +++ b/stubs/pywin32/win32comext/shell/shell.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing_extensions import TypeAlias +from typing import TypeAlias import _win32typing from win32.lib.pywintypes import com_error diff --git a/stubs/pyxdg/xdg/MenuEditor.pyi b/stubs/pyxdg/xdg/MenuEditor.pyi index 5e8c98136df4..48626276a760 100644 --- a/stubs/pyxdg/xdg/MenuEditor.pyi +++ b/stubs/pyxdg/xdg/MenuEditor.pyi @@ -1,6 +1,5 @@ from _typeshed import StrPath, Unused -from typing import Literal, overload -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, overload from xml.etree.ElementTree import ElementTree from .Menu import Menu, MenuEntry, Separator, XMLMenuBuilder diff --git a/stubs/pyxdg/xdg/Mime.pyi b/stubs/pyxdg/xdg/Mime.pyi index f31eec421531..38607506caea 100644 --- a/stubs/pyxdg/xdg/Mime.pyi +++ b/stubs/pyxdg/xdg/Mime.pyi @@ -3,8 +3,8 @@ from _typeshed import StrOrBytesPath, SupportsLenAndGetItem, Unused from collections import defaultdict from collections.abc import Collection, Iterable from io import BytesIO -from typing import Literal -from typing_extensions import Self, TypeAlias +from typing import Literal, TypeAlias +from typing_extensions import Self FREE_NS: str types: dict[str, MIMEtype] diff --git a/stubs/qrbill/qrbill/bill.pyi b/stubs/qrbill/qrbill/bill.pyi index 001175230974..2cabe1fd1af8 100644 --- a/stubs/qrbill/qrbill/bill.pyi +++ b/stubs/qrbill/qrbill/bill.pyi @@ -2,8 +2,8 @@ from _typeshed import SupportsWrite from collections.abc import Iterable, Iterator, Mapping from decimal import Decimal from pathlib import Path -from typing import Any, Final, Literal, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, Final, Literal, TypeAlias, overload +from typing_extensions import deprecated from qrcode.image.svg import SvgPathImage diff --git a/stubs/qrcode/qrcode/_types.pyi b/stubs/qrcode/qrcode/_types.pyi index 2fb145fc4fc0..dac241617872 100644 --- a/stubs/qrcode/qrcode/_types.pyi +++ b/stubs/qrcode/qrcode/_types.pyi @@ -1,7 +1,6 @@ # Type aliases used in this stub package from _typeshed import SupportsWrite -from typing import Any, Protocol -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias Box: TypeAlias = tuple[tuple[int, int], tuple[int, int]] Ink: TypeAlias = tuple[int, int, int] | tuple[int, int, int, int] diff --git a/stubs/qrcode/qrcode/image/base.pyi b/stubs/qrcode/qrcode/image/base.pyi index 0d43f58698d8..03a5133994f4 100644 --- a/stubs/qrcode/qrcode/image/base.pyi +++ b/stubs/qrcode/qrcode/image/base.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import IO, Any -from typing_extensions import TypeAlias +from typing import IO, Any, TypeAlias from ..main import ModulesType, QRCode from .styles.moduledrawers.base import QRModuleDrawer diff --git a/stubs/qrcode/qrcode/image/pure.pyi b/stubs/qrcode/qrcode/image/pure.pyi index ec5df707f02f..45fdfbc3004e 100644 --- a/stubs/qrcode/qrcode/image/pure.pyi +++ b/stubs/qrcode/qrcode/image/pure.pyi @@ -1,7 +1,6 @@ from _typeshed import SupportsWrite from collections.abc import Generator -from typing import Any, Literal -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias from . import base diff --git a/stubs/qrcode/qrcode/main.pyi b/stubs/qrcode/qrcode/main.pyi index 09a7b7a16eca..f7b35f39219f 100644 --- a/stubs/qrcode/qrcode/main.pyi +++ b/stubs/qrcode/qrcode/main.pyi @@ -1,7 +1,6 @@ from _typeshed import ConvertibleToInt from collections.abc import Sequence -from typing import Any, Generic, NamedTuple, Protocol, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Generic, NamedTuple, Protocol, TypeAlias, TypeVar, overload, type_check_only from ._types import ErrorCorrect, MaskPattern from .image.base import BaseImage diff --git a/stubs/qrcode/qrcode/util.pyi b/stubs/qrcode/qrcode/util.pyi index df4832c5d11d..bb1ac696115c 100644 --- a/stubs/qrcode/qrcode/util.pyi +++ b/stubs/qrcode/qrcode/util.pyi @@ -1,7 +1,6 @@ from collections.abc import Callable, Generator from re import Pattern -from typing import Final, Literal, overload -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias, overload from ._types import ErrorCorrect, MaskPattern from .base import RSBlock as RSBlock diff --git a/stubs/regex/regex/_regex_core.pyi b/stubs/regex/regex/_regex_core.pyi index 5778565d5fcc..d8f3014f9a73 100644 --- a/stubs/regex/regex/_regex_core.pyi +++ b/stubs/regex/regex/_regex_core.pyi @@ -1,7 +1,6 @@ import enum from collections.abc import Callable -from typing import Any, AnyStr, Generic -from typing_extensions import TypeAlias +from typing import Any, AnyStr, Generic, TypeAlias from ._main import Pattern diff --git a/stubs/reportlab/reportlab/graphics/shapes.pyi b/stubs/reportlab/reportlab/graphics/shapes.pyi index f9d290b79a2c..253538227f0f 100644 --- a/stubs/reportlab/reportlab/graphics/shapes.pyi +++ b/stubs/reportlab/reportlab/graphics/shapes.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, SupportsItems from abc import abstractmethod from collections.abc import Iterable, Sequence -from typing import Any, Final, Literal, NoReturn, TypedDict, type_check_only -from typing_extensions import Self, TypeAlias, Unpack +from typing import Any, Final, Literal, NoReturn, TypeAlias, TypedDict, type_check_only +from typing_extensions import Self, Unpack from reportlab.lib.colors import Color from reportlab.lib.validators import NoneOr, Validator diff --git a/stubs/reportlab/reportlab/lib/colors.pyi b/stubs/reportlab/reportlab/lib/colors.pyi index 362233967f88..f281d37ced14 100644 --- a/stubs/reportlab/reportlab/lib/colors.pyi +++ b/stubs/reportlab/reportlab/lib/colors.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable, Iterator -from typing import Final, Literal, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Final, Literal, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self _ColorT = TypeVar("_ColorT", bound=Color) # NOTE: Reportlab is very inconsistent and sometimes uses the interpretation diff --git a/stubs/reportlab/reportlab/lib/fonts.pyi b/stubs/reportlab/reportlab/lib/fonts.pyi index 2edeba631d38..665e34909894 100644 --- a/stubs/reportlab/reportlab/lib/fonts.pyi +++ b/stubs/reportlab/reportlab/lib/fonts.pyi @@ -1,5 +1,4 @@ -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias _BoolInt: TypeAlias = Literal[0, 1] diff --git a/stubs/reportlab/reportlab/lib/styles.pyi b/stubs/reportlab/reportlab/lib/styles.pyi index 028d9b0cd5a8..096d8d031a3a 100644 --- a/stubs/reportlab/reportlab/lib/styles.pyi +++ b/stubs/reportlab/reportlab/lib/styles.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from typing import Any, ClassVar, Literal, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, Literal, TypeAlias, TypeVar, overload +from typing_extensions import Self from reportlab.lib.colors import Color diff --git a/stubs/reportlab/reportlab/pdfgen/textobject.pyi b/stubs/reportlab/reportlab/pdfgen/textobject.pyi index e0162746b4d8..ed187f7e9aaa 100644 --- a/stubs/reportlab/reportlab/pdfgen/textobject.pyi +++ b/stubs/reportlab/reportlab/pdfgen/textobject.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete, Unused from collections.abc import Callable -from typing import Final, Literal -from typing_extensions import TypeAlias +from typing import Final, Literal, TypeAlias from reportlab.lib.colors import Color from reportlab.pdfbase.ttfonts import ShapedStr diff --git a/stubs/reportlab/reportlab/platypus/doctemplate.pyi b/stubs/reportlab/reportlab/platypus/doctemplate.pyi index c3ffee40eb39..bdafbd35c529 100644 --- a/stubs/reportlab/reportlab/platypus/doctemplate.pyi +++ b/stubs/reportlab/reportlab/platypus/doctemplate.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from abc import abstractmethod from collections.abc import Callable -from typing import IO, Any, Literal, Protocol, type_check_only -from typing_extensions import Self, TypeAlias +from typing import IO, Any, Literal, Protocol, TypeAlias, type_check_only +from typing_extensions import Self from reportlab.pdfgen.canvas import Canvas from reportlab.platypus.flowables import Flowable diff --git a/stubs/reportlab/reportlab/platypus/flowables.pyi b/stubs/reportlab/reportlab/platypus/flowables.pyi index da28237e3850..b3a433df28f0 100644 --- a/stubs/reportlab/reportlab/platypus/flowables.pyi +++ b/stubs/reportlab/reportlab/platypus/flowables.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsRead, Unused from collections.abc import Callable, Iterable, Sequence -from typing import Any, Literal, NoReturn, Protocol, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Literal, NoReturn, Protocol, TypeAlias, type_check_only +from typing_extensions import Self from reportlab.lib.colors import Color from reportlab.lib.styles import ListStyle, ParagraphStyle, PropertySet diff --git a/stubs/reportlab/reportlab/platypus/para.pyi b/stubs/reportlab/reportlab/platypus/para.pyi index a83dce246445..59ff594b0db7 100644 --- a/stubs/reportlab/reportlab/platypus/para.pyi +++ b/stubs/reportlab/reportlab/platypus/para.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, Unused from collections.abc import Callable, Mapping -from typing import Any, Final, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias, Unpack +from typing import Any, Final, Literal, Protocol, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Unpack from reportlab.lib.colors import Color from reportlab.lib.styles import ParagraphStyle, PropertySet, StyleSheet1 diff --git a/stubs/reportlab/reportlab/platypus/tableofcontents.pyi b/stubs/reportlab/reportlab/platypus/tableofcontents.pyi index 8159bde6ae53..0ae40aa5b850 100644 --- a/stubs/reportlab/reportlab/platypus/tableofcontents.pyi +++ b/stubs/reportlab/reportlab/platypus/tableofcontents.pyi @@ -1,7 +1,7 @@ from _typeshed import Unused from collections.abc import Callable, Iterable, Sequence -from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import TypeAlias, Unpack +from typing import Any, Final, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Unpack from reportlab.lib.styles import ParagraphStyle, PropertySet from reportlab.pdfgen.canvas import Canvas diff --git a/stubs/reportlab/reportlab/platypus/tables.pyi b/stubs/reportlab/reportlab/platypus/tables.pyi index 905b2fd8180c..c8208372970f 100644 --- a/stubs/reportlab/reportlab/platypus/tables.pyi +++ b/stubs/reportlab/reportlab/platypus/tables.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from abc import abstractmethod from collections.abc import Collection, Iterable, Sequence -from typing import Any, Literal, NamedTuple, overload -from typing_extensions import TypeAlias, Unpack +from typing import Any, Literal, NamedTuple, TypeAlias, overload +from typing_extensions import Unpack from reportlab.lib.colors import Color from reportlab.lib.styles import PropertySet diff --git a/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi b/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi index a6e089ec90d7..b9f9b11962b5 100644 --- a/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi +++ b/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from logging import Logger -from typing import TypedDict, type_check_only -from typing_extensions import TypeAlias +from typing import TypeAlias, TypedDict, type_check_only import requests from oauthlib.oauth1 import Client diff --git a/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi b/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi index 1ad322a9f42c..27a21c3e8f48 100644 --- a/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi +++ b/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from logging import Logger -from typing import Any, Literal, Protocol, TypedDict, overload, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Literal, Protocol, TypeAlias, TypedDict, overload, type_check_only import requests from oauthlib.oauth2 import Client diff --git a/stubs/requests/requests/api.pyi b/stubs/requests/requests/api.pyi index 49e0ce247432..c29ff6472fc1 100644 --- a/stubs/requests/requests/api.pyi +++ b/stubs/requests/requests/api.pyi @@ -1,6 +1,6 @@ from collections.abc import Mapping from http.cookiejar import CookieJar -from typing_extensions import TypeAlias +from typing import TypeAlias from .models import _JSON, Response from .sessions import _Auth, _Cert, _Data, _Files, _HooksInput, _Params, _TextMapping, _Timeout, _Verify diff --git a/stubs/requests/requests/compat.pyi b/stubs/requests/requests/compat.pyi index 1d6af41632f9..520f08f4a39c 100644 --- a/stubs/requests/requests/compat.pyi +++ b/stubs/requests/requests/compat.pyi @@ -1,7 +1,6 @@ from builtins import bytes as bytes, str as str from collections import OrderedDict as OrderedDict -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias from urllib.parse import ( quote as quote, quote_plus as quote_plus, diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 2747c9799eed..0e85e09a6a8f 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -2,8 +2,8 @@ import datetime from _typeshed import Incomplete, MaybeNone, Unused from collections.abc import Callable, Iterator from json import JSONDecoder -from typing import Any -from typing_extensions import Self, TypeAlias +from typing import Any, TypeAlias +from typing_extensions import Self from urllib3 import exceptions as urllib3_exceptions, fields, filepost, util from urllib3.response import HTTPResponse diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index 33ee2ae9b8a6..fb9c618b50aa 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsItems, SupportsRead, Unused from collections.abc import Callable, Iterable, Mapping, MutableMapping -from typing import Any, TypedDict, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, TypeAlias, TypedDict, type_check_only +from typing_extensions import Self from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, utils from .models import _JSON, Response diff --git a/stubs/requests/requests/utils.pyi b/stubs/requests/requests/utils.pyi index 3edd7c1038a0..da6798d3c72d 100644 --- a/stubs/requests/requests/utils.pyi +++ b/stubs/requests/requests/utils.pyi @@ -3,8 +3,7 @@ from _typeshed import Incomplete, StrOrBytesPath from collections.abc import Generator, Iterable, Mapping from contextlib import _GeneratorContextManager from io import BufferedWriter -from typing import AnyStr -from typing_extensions import TypeAlias +from typing import AnyStr, TypeAlias from . import compat, cookies, exceptions, structures from .models import PreparedRequest, Request diff --git a/stubs/s2clientprotocol/s2clientprotocol/common_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/common_pb2.pyi index cfa0bec86506..fee537abac78 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/common_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/common_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Race: diff --git a/stubs/s2clientprotocol/s2clientprotocol/data_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/data_pb2.pyi index cd68bb65df02..c6bf7ff7d384 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/data_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/data_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import s2clientprotocol.common_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Attribute: diff --git a/stubs/s2clientprotocol/s2clientprotocol/debug_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/debug_pb2.pyi index eba2ae972064..d49c912f7c15 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/debug_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/debug_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import s2clientprotocol.common_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DebugGameState: diff --git a/stubs/s2clientprotocol/s2clientprotocol/error_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/error_pb2.pyi index 5c14aaba748c..596c8a615935 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/error_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/error_pb2.pyi @@ -4,17 +4,12 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _ActionResult: diff --git a/stubs/s2clientprotocol/s2clientprotocol/raw_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/raw_pb2.pyi index a50167f1e087..93404cc79b66 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/raw_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/raw_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import s2clientprotocol.common_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DisplayType: diff --git a/stubs/s2clientprotocol/s2clientprotocol/sc2api_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/sc2api_pb2.pyi index fbf53b67a613..6de874016424 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/sc2api_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/sc2api_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -22,11 +22,6 @@ import s2clientprotocol.score_pb2 import s2clientprotocol.spatial_pb2 import s2clientprotocol.ui_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Status: diff --git a/stubs/s2clientprotocol/s2clientprotocol/score_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/score_pb2.pyi index 611578a5c889..132d735f0a37 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/score_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/score_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/s2clientprotocol/s2clientprotocol/spatial_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/spatial_pb2.pyi index 5fd2301ac84b..aef910f795fa 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/spatial_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/spatial_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import s2clientprotocol.common_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/s2clientprotocol/s2clientprotocol/ui_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/ui_pb2.pyi index 2608a8aa142c..09d87f173072 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/ui_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/ui_pb2.pyi @@ -5,19 +5,14 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/seaborn/seaborn/_core/groupby.pyi b/stubs/seaborn/seaborn/_core/groupby.pyi index f466aee67341..aabca58d7075 100644 --- a/stubs/seaborn/seaborn/_core/groupby.pyi +++ b/stubs/seaborn/seaborn/_core/groupby.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Hashable, Mapping -from typing_extensions import Concatenate, ParamSpec, TypeAlias +from typing import Concatenate, TypeAlias +from typing_extensions import ParamSpec from numpy import ufunc from pandas import DataFrame diff --git a/stubs/seaborn/seaborn/_core/properties.pyi b/stubs/seaborn/seaborn/_core/properties.pyi index 20cbe28fa0e0..548cc5a9d3ce 100644 --- a/stubs/seaborn/seaborn/_core/properties.pyi +++ b/stubs/seaborn/seaborn/_core/properties.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from matplotlib.markers import MarkerStyle from matplotlib.path import Path diff --git a/stubs/seaborn/seaborn/_core/scales.pyi b/stubs/seaborn/seaborn/_core/scales.pyi index c294169ea554..8e164e265ef0 100644 --- a/stubs/seaborn/seaborn/_core/scales.pyi +++ b/stubs/seaborn/seaborn/_core/scales.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Sequence from dataclasses import dataclass -from typing import Any, ClassVar -from typing_extensions import Self, TypeAlias +from typing import Any, ClassVar, TypeAlias +from typing_extensions import Self from matplotlib.axis import Ticker from matplotlib.scale import ScaleBase diff --git a/stubs/seaborn/seaborn/_core/typing.pyi b/stubs/seaborn/seaborn/_core/typing.pyi index 415f818440ee..c114bdf8f09f 100644 --- a/stubs/seaborn/seaborn/_core/typing.pyi +++ b/stubs/seaborn/seaborn/_core/typing.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable, Mapping from datetime import date, datetime, timedelta -from typing import Any, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, type_check_only from matplotlib.colors import Colormap, Normalize from numpy import ndarray diff --git a/stubs/seaborn/seaborn/_marks/base.pyi b/stubs/seaborn/seaborn/_marks/base.pyi index a1d029ff7547..80989c2f4274 100644 --- a/stubs/seaborn/seaborn/_marks/base.pyi +++ b/stubs/seaborn/seaborn/_marks/base.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from dataclasses import dataclass -from typing import Any, TypeVar -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, TypeVar from numpy.typing import NDArray from pandas import DataFrame diff --git a/stubs/seaborn/seaborn/axisgrid.pyi b/stubs/seaborn/seaborn/axisgrid.pyi index 1f4072570aeb..16ff332d4b74 100644 --- a/stubs/seaborn/seaborn/axisgrid.pyi +++ b/stubs/seaborn/seaborn/axisgrid.pyi @@ -1,8 +1,8 @@ import os from _typeshed import Incomplete from collections.abc import Callable, Generator, Iterable, Mapping -from typing import IO, Any, Literal, TypeVar -from typing_extensions import Concatenate, ParamSpec, Self, TypeAlias, deprecated +from typing import IO, Any, Concatenate, Literal, TypeAlias, TypeVar +from typing_extensions import ParamSpec, Self, deprecated import numpy as np from matplotlib.artist import Artist diff --git a/stubs/seaborn/seaborn/distributions.pyi b/stubs/seaborn/seaborn/distributions.pyi index 06ecfb7197e0..036a0d9d4e43 100644 --- a/stubs/seaborn/seaborn/distributions.pyi +++ b/stubs/seaborn/seaborn/distributions.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import Any, Literal, Protocol, TypeVar, type_check_only -from typing_extensions import TypeAlias, deprecated +from typing import Any, Literal, Protocol, TypeAlias, TypeVar, type_check_only +from typing_extensions import deprecated from matplotlib.axes import Axes from matplotlib.colors import Colormap diff --git a/stubs/seaborn/seaborn/external/kde.pyi b/stubs/seaborn/seaborn/external/kde.pyi index e886570721d1..76769a3fd5f8 100644 --- a/stubs/seaborn/seaborn/external/kde.pyi +++ b/stubs/seaborn/seaborn/external/kde.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Any, Literal, Protocol, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Literal, Protocol, TypeAlias, type_check_only import numpy as np from numpy.typing import ArrayLike, NDArray diff --git a/stubs/seaborn/seaborn/matrix.pyi b/stubs/seaborn/seaborn/matrix.pyi index 34ba5bb99aad..6aae408d9808 100644 --- a/stubs/seaborn/seaborn/matrix.pyi +++ b/stubs/seaborn/seaborn/matrix.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Hashable, Iterable, Mapping, Sequence -from typing import Literal, TypedDict, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Literal, TypeAlias, TypedDict, type_check_only +from typing_extensions import Self import numpy as np import pandas as pd diff --git a/stubs/seaborn/seaborn/palettes.pyi b/stubs/seaborn/seaborn/palettes.pyi index 64ea321d28e5..133ead3504cf 100644 --- a/stubs/seaborn/seaborn/palettes.pyi +++ b/stubs/seaborn/seaborn/palettes.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable, Sequence -from typing import Literal, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import Literal, TypeAlias, TypeVar, overload +from typing_extensions import Self from matplotlib.colors import Colormap, LinearSegmentedColormap, ListedColormap from matplotlib.typing import ColorType diff --git a/stubs/seaborn/seaborn/regression.pyi b/stubs/seaborn/seaborn/regression.pyi index b3e79b0e7aa5..eb4bd4412ad6 100644 --- a/stubs/seaborn/seaborn/regression.pyi +++ b/stubs/seaborn/seaborn/regression.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable -from typing import Any, Literal, overload -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias, overload import pandas as pd from matplotlib.axes import Axes diff --git a/stubs/seaborn/seaborn/relational.pyi b/stubs/seaborn/seaborn/relational.pyi index 7a7bde159a1c..7b4ebc48bf2c 100644 --- a/stubs/seaborn/seaborn/relational.pyi +++ b/stubs/seaborn/seaborn/relational.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterable, Mapping, Sequence -from typing import Any, Literal -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias from matplotlib.axes import Axes from matplotlib.colors import Colormap diff --git a/stubs/seaborn/seaborn/utils.pyi b/stubs/seaborn/seaborn/utils.pyi index a54afc15ccd1..aa57881400d5 100644 --- a/stubs/seaborn/seaborn/utils.pyi +++ b/stubs/seaborn/seaborn/utils.pyi @@ -1,8 +1,8 @@ import datetime as dt from _typeshed import Incomplete, SupportsGetItem from collections.abc import Callable, Iterable, Mapping, Sequence -from typing import Any, Literal, SupportsIndex, TypeVar, overload -from typing_extensions import TypeAlias, deprecated +from typing import Any, Literal, SupportsIndex, TypeAlias, TypeVar, overload +from typing_extensions import deprecated import numpy as np import pandas as pd diff --git a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi index 7ee78dababdc..9648d4f7986f 100644 --- a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi +++ b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi @@ -1,8 +1,8 @@ from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused from collections.abc import Callable, Iterable, MutableSequence, Sequence from subprocess import _ENV -from typing import ClassVar, Final, Literal, TypeVar, overload -from typing_extensions import TypeAlias, TypeVarTuple, Unpack +from typing import ClassVar, Final, Literal, TypeAlias, TypeVar, overload +from typing_extensions import TypeVarTuple, Unpack _Macro: TypeAlias = tuple[str] | tuple[str, str | None] _StrPathT = TypeVar("_StrPathT", bound=StrPath) diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index dcfc826db663..a4085c7ecdf4 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite from collections.abc import Iterable, MutableMapping from re import Pattern -from typing import IO, ClassVar, Literal, TypeVar, overload -from typing_extensions import TypeAlias +from typing import IO, ClassVar, Literal, TypeAlias, TypeVar, overload from .cmd import Command diff --git a/stubs/setuptools/setuptools/build_meta.pyi b/stubs/setuptools/setuptools/build_meta.pyi index 04de70231d33..45a733d1128d 100644 --- a/stubs/setuptools/setuptools/build_meta.pyi +++ b/stubs/setuptools/setuptools/build_meta.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete, StrPath from collections.abc import Mapping from contextlib import _GeneratorContextManager -from typing import NoReturn -from typing_extensions import TypeAlias +from typing import NoReturn, TypeAlias from . import dist diff --git a/stubs/setuptools/setuptools/command/editable_wheel.pyi b/stubs/setuptools/setuptools/command/editable_wheel.pyi index 615c0059db10..d9aececdac84 100644 --- a/stubs/setuptools/setuptools/command/editable_wheel.pyi +++ b/stubs/setuptools/setuptools/command/editable_wheel.pyi @@ -3,8 +3,8 @@ from collections.abc import Iterator, Mapping from enum import Enum from pathlib import Path from types import TracebackType -from typing import ClassVar, Protocol -from typing_extensions import Self, TypeAlias +from typing import ClassVar, Protocol, TypeAlias +from typing_extensions import Self from .. import Command, errors, namespaces from ..dist import Distribution diff --git a/stubs/setuptools/setuptools/config/setupcfg.pyi b/stubs/setuptools/setuptools/config/setupcfg.pyi index 7c78eefd9250..35eb6821565f 100644 --- a/stubs/setuptools/setuptools/config/setupcfg.pyi +++ b/stubs/setuptools/setuptools/config/setupcfg.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete, StrPath from abc import abstractmethod from collections.abc import Callable, Iterable -from typing import Any, ClassVar, Generic, TypeVar -from typing_extensions import TypeAlias +from typing import Any, ClassVar, Generic, TypeAlias, TypeVar from .._distutils.dist import DistributionMetadata from ..dist import Distribution diff --git a/stubs/setuptools/setuptools/warnings.pyi b/stubs/setuptools/setuptools/warnings.pyi index 6bb52b66dc9c..81d3bcfb3922 100644 --- a/stubs/setuptools/setuptools/warnings.pyi +++ b/stubs/setuptools/setuptools/warnings.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeAlias +from typing import TypeAlias _DueDate: TypeAlias = tuple[int, int, int] # time tuple diff --git a/stubs/shapely/shapely/_geometry.pyi b/stubs/shapely/shapely/_geometry.pyi index 3e1a92ca5ab0..381f306867d9 100644 --- a/stubs/shapely/shapely/_geometry.pyi +++ b/stubs/shapely/shapely/_geometry.pyi @@ -1,6 +1,5 @@ from enum import IntEnum -from typing import Any, Literal, SupportsIndex, overload -from typing_extensions import TypeAlias +from typing import Any, Literal, SupportsIndex, TypeAlias, overload import numpy as np from numpy.typing import NDArray diff --git a/stubs/shapely/shapely/_typing.pyi b/stubs/shapely/shapely/_typing.pyi index 224af9553f03..931dc2e7cc59 100644 --- a/stubs/shapely/shapely/_typing.pyi +++ b/stubs/shapely/shapely/_typing.pyi @@ -1,8 +1,7 @@ import sys from _typeshed import SupportsWrite as SupportsWrite from collections.abc import Sequence -from typing import Any, Protocol, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, TypeVar, type_check_only import numpy as np from numpy.typing import NDArray diff --git a/stubs/shapely/shapely/affinity.pyi b/stubs/shapely/shapely/affinity.pyi index aaaaef0c5969..fbca24462789 100644 --- a/stubs/shapely/shapely/affinity.pyi +++ b/stubs/shapely/shapely/affinity.pyi @@ -1,6 +1,5 @@ from collections.abc import Collection -from typing import Literal, overload -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, overload from ._typing import GeoT from .geometry import Point diff --git a/stubs/shapely/shapely/creation.pyi b/stubs/shapely/shapely/creation.pyi index 193100448eaa..d009e3a06a63 100644 --- a/stubs/shapely/shapely/creation.pyi +++ b/stubs/shapely/shapely/creation.pyi @@ -1,6 +1,5 @@ from collections.abc import Sequence -from typing import Literal, SupportsIndex, overload -from typing_extensions import TypeAlias +from typing import Literal, SupportsIndex, TypeAlias, overload import numpy as np from numpy.typing import NDArray diff --git a/stubs/shapely/shapely/geometry/linestring.pyi b/stubs/shapely/shapely/geometry/linestring.pyi index 4c5b37ab4df0..7e0cc926a7ff 100644 --- a/stubs/shapely/shapely/geometry/linestring.pyi +++ b/stubs/shapely/shapely/geometry/linestring.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import Literal, SupportsFloat, SupportsIndex -from typing_extensions import Self, TypeAlias +from typing import Literal, SupportsFloat, SupportsIndex, TypeAlias +from typing_extensions import Self from .._typing import ArrayLikeSeq from ..constructive import BufferJoinStyle diff --git a/stubs/shapely/shapely/geometry/point.pyi b/stubs/shapely/shapely/geometry/point.pyi index f68ae98bc2ed..41b429fc652c 100644 --- a/stubs/shapely/shapely/geometry/point.pyi +++ b/stubs/shapely/shapely/geometry/point.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import overload -from typing_extensions import Self, TypeAlias +from typing import TypeAlias, overload +from typing_extensions import Self from .._typing import ArrayLikeSeq from .base import BaseGeometry diff --git a/stubs/shapely/shapely/geometry/polygon.pyi b/stubs/shapely/shapely/geometry/polygon.pyi index 6d2fd90725a4..ee8feb530ea0 100644 --- a/stubs/shapely/shapely/geometry/polygon.pyi +++ b/stubs/shapely/shapely/geometry/polygon.pyi @@ -1,6 +1,6 @@ from collections.abc import Collection -from typing import NoReturn, overload -from typing_extensions import Self, TypeAlias +from typing import NoReturn, TypeAlias, overload +from typing_extensions import Self from .base import BaseGeometry from .linestring import LineString, _ConvertibleToLineString diff --git a/stubs/shapely/shapely/io.pyi b/stubs/shapely/shapely/io.pyi index 54b17de3fa0d..fba4035f3328 100644 --- a/stubs/shapely/shapely/io.pyi +++ b/stubs/shapely/shapely/io.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete -from typing import Literal, overload -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias, overload import numpy as np from numpy.typing import NDArray diff --git a/stubs/shapely/shapely/predicates.pyi b/stubs/shapely/shapely/predicates.pyi index a9e39dfadead..e6e7466c1fe4 100644 --- a/stubs/shapely/shapely/predicates.pyi +++ b/stubs/shapely/shapely/predicates.pyi @@ -1,6 +1,4 @@ -import sys -from typing import Any, Literal, overload -from typing_extensions import TypeAlias, TypeGuard +from typing import Any, Literal, TypeAlias, TypeGuard, overload import numpy as np from numpy.typing import NDArray @@ -9,12 +7,8 @@ from ._typing import ArrayLike, ArrayLikeSeq, OptGeoArrayLike, OptGeoArrayLikeSe from .geometry.base import BaseGeometry from .lib import Geometry -if sys.version_info >= (3, 10): - _NPTrue: TypeAlias = np.bool_[Literal[True]] - _NPFalse: TypeAlias = np.bool_[Literal[False]] -else: - _NPTrue: TypeAlias = np.bool_ - _NPFalse: TypeAlias = np.bool_ +_NPTrue: TypeAlias = np.bool_[Literal[True]] +_NPFalse: TypeAlias = np.bool_[Literal[False]] __all__ = [ "contains", diff --git a/stubs/shapely/shapely/strtree.pyi b/stubs/shapely/shapely/strtree.pyi index 0e03e3ffc338..fda47412cd7a 100644 --- a/stubs/shapely/shapely/strtree.pyi +++ b/stubs/shapely/shapely/strtree.pyi @@ -1,5 +1,4 @@ -from typing import Any, Literal, SupportsIndex, overload -from typing_extensions import TypeAlias +from typing import Any, Literal, SupportsIndex, TypeAlias, overload import numpy as np from numpy.typing import NDArray diff --git a/stubs/simplejson/simplejson/__init__.pyi b/stubs/simplejson/simplejson/__init__.pyi index 7705280f31ef..7c523a8f603a 100644 --- a/stubs/simplejson/simplejson/__init__.pyi +++ b/stubs/simplejson/simplejson/__init__.pyi @@ -1,8 +1,7 @@ from _typeshed import SupportsRichComparison from collections import OrderedDict from collections.abc import Callable -from typing import IO, Any, TypeVar, overload -from typing_extensions import TypeAlias +from typing import IO, Any, TypeAlias, TypeVar, overload from simplejson.decoder import JSONDecoder as JSONDecoder from simplejson.encoder import JSONEncoder as JSONEncoder, JSONEncoderForHTML as JSONEncoderForHTML diff --git a/stubs/slumber/slumber/serialize.pyi b/stubs/slumber/slumber/serialize.pyi index e806a448e9b8..49a611cc084b 100644 --- a/stubs/slumber/slumber/serialize.pyi +++ b/stubs/slumber/slumber/serialize.pyi @@ -1,5 +1,4 @@ -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias _Data: TypeAlias = str | bytes | bytearray diff --git a/stubs/tabulate/tabulate/__init__.pyi b/stubs/tabulate/tabulate/__init__.pyi index f258717ad56f..28d2ddf55914 100644 --- a/stubs/tabulate/tabulate/__init__.pyi +++ b/stubs/tabulate/tabulate/__init__.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Container, Iterable, Mapping, Sequence -from typing import Any, Final, NamedTuple -from typing_extensions import Self, TypeAlias +from typing import Any, Final, NamedTuple, TypeAlias +from typing_extensions import Self from .version import __version__ as __version__ diff --git a/stubs/tensorflow/tensorflow/_aliases.pyi b/stubs/tensorflow/tensorflow/_aliases.pyi index 6bc6918a6b21..5793cc3a569d 100644 --- a/stubs/tensorflow/tensorflow/_aliases.pyi +++ b/stubs/tensorflow/tensorflow/_aliases.pyi @@ -2,8 +2,7 @@ # Everything in this module is private for stubs. There is no runtime equivalent. from collections.abc import Iterable, Mapping, Sequence -from typing import Any, Protocol, TypeVar -from typing_extensions import TypeAlias +from typing import Any, Protocol, TypeAlias, TypeVar import numpy as np import numpy.typing as npt diff --git a/stubs/tensorflow/tensorflow/bitwise.pyi b/stubs/tensorflow/tensorflow/bitwise.pyi index 2045d9987326..f01e1bbc1a82 100644 --- a/stubs/tensorflow/tensorflow/bitwise.pyi +++ b/stubs/tensorflow/tensorflow/bitwise.pyi @@ -1,5 +1,4 @@ -from typing import Any, overload -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, overload import numpy as np import tensorflow as tf diff --git a/stubs/tensorflow/tensorflow/compiler/xla/service/hlo_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/service/hlo_pb2.pyi index 9057959cc005..48a158aefb60 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/service/hlo_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/service/hlo_pb2.pyi @@ -17,8 +17,8 @@ protos as JSON, which includes the field names in the serialization. import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -27,11 +27,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.compiler.xla.xla_data_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _CustomCallSchedule: diff --git a/stubs/tensorflow/tensorflow/compiler/xla/service/metrics_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/service/metrics_pb2.pyi index 05eaf7379849..fba3dafb4740 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/service/metrics_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/service/metrics_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -16,11 +16,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import google.protobuf.timestamp_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/compiler/xla/tsl/protobuf/test_log_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/tsl/protobuf/test_log_pb2.pyi index a0cd6ef6a44b..efaaa1719332 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/tsl/protobuf/test_log_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/tsl/protobuf/test_log_pb2.pyi @@ -5,8 +5,8 @@ Protocol messages for describing the results of benchmarks and unit tests.""" import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -15,11 +15,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import google.protobuf.wrappers_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/compiler/xla/xla_data_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/xla_data_pb2.pyi index de86f1c8f255..410c871a3792 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/xla_data_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/xla_data_pb2.pyi @@ -19,19 +19,14 @@ limitations under the License. import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _PrimitiveType: diff --git a/stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi index 17820b9e12c0..3dfda71957ea 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi @@ -19,8 +19,8 @@ limitations under the License. import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -30,11 +30,6 @@ import google.protobuf.message import tensorflow.compiler.xla.service.hlo_pb2 import tensorflow.compiler.xla.xla_data_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/framework/api_def_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/api_def_pb2.pyi index b3d8c424234f..33d3e9c582b2 100644 --- a/stubs/tensorflow/tensorflow/core/framework/api_def_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/api_def_pb2.pyi @@ -7,8 +7,8 @@ overrides for client language op code generators. import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -16,11 +16,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.attr_value_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/framework/dataset_options_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/dataset_options_pb2.pyi index 724249f3c540..42235b08f937 100644 --- a/stubs/tensorflow/tensorflow/core/framework/dataset_options_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/dataset_options_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.model_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _AutoShardPolicy: diff --git a/stubs/tensorflow/tensorflow/core/framework/full_type_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/full_type_pb2.pyi index 8025593122d5..f7fe50b8b90b 100644 --- a/stubs/tensorflow/tensorflow/core/framework/full_type_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/full_type_pb2.pyi @@ -5,19 +5,14 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _FullTypeId: diff --git a/stubs/tensorflow/tensorflow/core/framework/graph_transfer_info_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/graph_transfer_info_pb2.pyi index bba887ced518..d215035a107f 100644 --- a/stubs/tensorflow/tensorflow/core/framework/graph_transfer_info_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/graph_transfer_info_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/framework/model_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/model_pb2.pyi index 5f80b951a386..150b7725ee46 100644 --- a/stubs/tensorflow/tensorflow/core/framework/model_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/model_pb2.pyi @@ -5,19 +5,14 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _NodeClass: diff --git a/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi index 152ce34664ac..226880af238a 100644 --- a/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -15,11 +15,6 @@ import google.protobuf.message import tensorflow.core.framework.graph_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/framework/summary_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/summary_pb2.pyi index 848d802496f8..16180facbdad 100644 --- a/stubs/tensorflow/tensorflow/core/framework/summary_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/summary_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.tensor_pb2 import tensorflow.tsl.protobuf.histogram_pb2 - -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions from tensorflow.tsl.protobuf.histogram_pb2 import HistogramProto as HistogramProto DESCRIPTOR: google.protobuf.descriptor.FileDescriptor diff --git a/stubs/tensorflow/tensorflow/core/framework/types_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/types_pb2.pyi index 18c74011593b..e368d062e5d2 100644 --- a/stubs/tensorflow/tensorflow/core/framework/types_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/types_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DataType: diff --git a/stubs/tensorflow/tensorflow/core/framework/variable_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/variable_pb2.pyi index 1341eee711e5..dafb2a02ce36 100644 --- a/stubs/tensorflow/tensorflow/core/framework/variable_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/variable_pb2.pyi @@ -5,19 +5,14 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _VariableSynchronization: diff --git a/stubs/tensorflow/tensorflow/core/protobuf/config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/config_pb2.pyi index 1930db2b79dd..ba33c25c47ec 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/config_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -21,11 +21,6 @@ import tensorflow.core.protobuf.rewriter_config_pb2 import tensorflow.tsl.protobuf.coordination_config_pb2 import tensorflow.tsl.protobuf.rpc_options_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/core_platform_payloads_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/core_platform_payloads_pb2.pyi index 39763f66f4e6..71bf2b685a57 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/core_platform_payloads_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/core_platform_payloads_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/data_service_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/data_service_pb2.pyi index cdafebecf7eb..9db48a907212 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/data_service_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/data_service_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DeploymentMode: diff --git a/stubs/tensorflow/tensorflow/core/protobuf/debug_event_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/debug_event_pb2.pyi index 2906b660d309..8d984ba3d659 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/debug_event_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/debug_event_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -15,11 +15,6 @@ import google.protobuf.message import tensorflow.core.framework.graph_debug_info_pb2 import tensorflow.core.framework.tensor_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _TensorDebugMode: diff --git a/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi index 0779991c7dd3..ce514732ffb8 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -15,11 +15,6 @@ import google.protobuf.message import tensorflow.core.framework.attr_value_pb2 import tensorflow.core.protobuf.verifier_config_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/saved_object_graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/saved_object_graph_pb2.pyi index ddc1f9d6a6ca..a686181a2d54 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/saved_object_graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/saved_object_graph_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -20,11 +20,6 @@ import tensorflow.core.framework.versions_pb2 import tensorflow.core.protobuf.struct_pb2 import tensorflow.core.protobuf.trackable_object_graph_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/saver_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/saver_pb2.pyi index 42159a4dbb60..30b13a3daf67 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/saver_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/saver_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/struct_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/struct_pb2.pyi index 3d3bdfcaf808..2496f696b773 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/struct_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/struct_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -16,11 +16,6 @@ import tensorflow.core.framework.tensor_pb2 import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tensor_bundle_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tensor_bundle_pb2.pyi index 58f69470b734..34ff8bc16b6a 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tensor_bundle_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tensor_bundle_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -17,11 +17,6 @@ import tensorflow.core.framework.tensor_slice_pb2 import tensorflow.core.framework.types_pb2 import tensorflow.core.framework.versions_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/compilation_result_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/compilation_result_pb2.pyi index 1220c78dc5f5..28c70f3cfca0 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/compilation_result_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/compilation_result_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -15,11 +15,6 @@ import google.protobuf.message import tensorflow.compiler.xla.service.hlo_pb2 import tensorflow.tsl.protobuf.error_codes_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/optimization_parameters_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/optimization_parameters_pb2.pyi index 9b914134520d..556c44a4e4e6 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/optimization_parameters_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/optimization_parameters_pb2.pyi @@ -4,8 +4,8 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper @@ -13,11 +13,6 @@ import google.protobuf.message import google.protobuf.wrappers_pb2 import tensorflow.compiler.xla.service.hlo_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/topology_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/topology_pb2.pyi index 574cd7a67e8e..9e13767d0d5e 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/topology_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/topology_pb2.pyi @@ -5,19 +5,14 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/tpu_embedding_configuration_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/tpu_embedding_configuration_pb2.pyi index 32d67050f571..6ac17eba8944 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/tpu_embedding_configuration_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/tpu_embedding_configuration_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.protobuf.tpu.optimization_parameters_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/verifier_config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/verifier_config_pb2.pyi index c65f7c9cdb24..03b90de11f1c 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/verifier_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/verifier_config_pb2.pyi @@ -4,18 +4,13 @@ isort:skip_file """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/util/event_pb2.pyi b/stubs/tensorflow/tensorflow/core/util/event_pb2.pyi index 7a8ac4afd856..4e5edb82484e 100644 --- a/stubs/tensorflow/tensorflow/core/util/event_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/util/event_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.summary_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _WorkerHealth: diff --git a/stubs/tensorflow/tensorflow/io/__init__.pyi b/stubs/tensorflow/tensorflow/io/__init__.pyi index 51f45b5fd315..593131b765b9 100644 --- a/stubs/tensorflow/tensorflow/io/__init__.pyi +++ b/stubs/tensorflow/tensorflow/io/__init__.pyi @@ -1,7 +1,7 @@ from collections.abc import Iterable, Mapping from types import TracebackType -from typing import Literal, NamedTuple -from typing_extensions import Self, TypeAlias +from typing import Literal, NamedTuple, TypeAlias +from typing_extensions import Self from tensorflow._aliases import DTypeLike, ShapeLike, TensorCompatible, TensorLike from tensorflow.io import gfile as gfile diff --git a/stubs/tensorflow/tensorflow/keras/activations.pyi b/stubs/tensorflow/tensorflow/keras/activations.pyi index 262b1f173c94..2cdcf2d43593 100644 --- a/stubs/tensorflow/tensorflow/keras/activations.pyi +++ b/stubs/tensorflow/tensorflow/keras/activations.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias import numpy as np from tensorflow import Tensor diff --git a/stubs/tensorflow/tensorflow/keras/callbacks.pyi b/stubs/tensorflow/tensorflow/keras/callbacks.pyi index 22deff0be2e6..74037b3a6501 100644 --- a/stubs/tensorflow/tensorflow/keras/callbacks.pyi +++ b/stubs/tensorflow/tensorflow/keras/callbacks.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Mapping, Sequence -from typing import Any, Literal -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias import tensorflow as tf from requests.api import _HeadersMapping diff --git a/stubs/tensorflow/tensorflow/keras/initializers.pyi b/stubs/tensorflow/tensorflow/keras/initializers.pyi index f24c31b42ca4..fc6c7669ed70 100644 --- a/stubs/tensorflow/tensorflow/keras/initializers.pyi +++ b/stubs/tensorflow/tensorflow/keras/initializers.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable -from typing import Any, overload -from typing_extensions import Self, TypeAlias +from typing import Any, TypeAlias, overload +from typing_extensions import Self from tensorflow import Tensor from tensorflow._aliases import DTypeLike, ShapeLike, TensorCompatible diff --git a/stubs/tensorflow/tensorflow/keras/layers/__init__.pyi b/stubs/tensorflow/tensorflow/keras/layers/__init__.pyi index 9764b04dbe0e..427dcdc254c8 100644 --- a/stubs/tensorflow/tensorflow/keras/layers/__init__.pyi +++ b/stubs/tensorflow/tensorflow/keras/layers/__init__.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable, Sequence -from typing import Any, Generic, Literal, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Generic, Literal, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self import tensorflow as tf from tensorflow import Tensor, Variable diff --git a/stubs/tensorflow/tensorflow/keras/losses.pyi b/stubs/tensorflow/tensorflow/keras/losses.pyi index ebb96740637e..7b2eecbc9c2a 100644 --- a/stubs/tensorflow/tensorflow/keras/losses.pyi +++ b/stubs/tensorflow/tensorflow/keras/losses.pyi @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod from collections.abc import Callable -from typing import Any, Final, Literal, TypeVar, overload -from typing_extensions import Self, TypeAlias, TypeGuard +from typing import Any, Final, Literal, TypeAlias, TypeGuard, TypeVar, overload +from typing_extensions import Self from tensorflow import Tensor from tensorflow._aliases import KerasSerializable, TensorCompatible diff --git a/stubs/tensorflow/tensorflow/keras/metrics.pyi b/stubs/tensorflow/tensorflow/keras/metrics.pyi index 33b8a3fb623d..e6f12a00c857 100644 --- a/stubs/tensorflow/tensorflow/keras/metrics.pyi +++ b/stubs/tensorflow/tensorflow/keras/metrics.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from abc import ABCMeta, abstractmethod from collections.abc import Callable, Iterable, Sequence from enum import Enum -from typing import Any, Literal, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Literal, TypeAlias, type_check_only +from typing_extensions import Self import tensorflow as tf from tensorflow import Operation, Tensor diff --git a/stubs/tensorflow/tensorflow/keras/models.pyi b/stubs/tensorflow/tensorflow/keras/models.pyi index afbd68461ac5..aaf919a3573d 100644 --- a/stubs/tensorflow/tensorflow/keras/models.pyi +++ b/stubs/tensorflow/tensorflow/keras/models.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Container, Iterator from pathlib import Path -from typing import Any, Literal -from typing_extensions import Self, TypeAlias, deprecated +from typing import Any, Literal, TypeAlias +from typing_extensions import Self, deprecated import numpy as np import numpy.typing as npt diff --git a/stubs/tensorflow/tensorflow/keras/optimizers/legacy/__init__.pyi b/stubs/tensorflow/tensorflow/keras/optimizers/legacy/__init__.pyi index dc69ac7e2d51..15fb8c0f7181 100644 --- a/stubs/tensorflow/tensorflow/keras/optimizers/legacy/__init__.pyi +++ b/stubs/tensorflow/tensorflow/keras/optimizers/legacy/__init__.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Iterable -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias import tensorflow as tf from tensorflow._aliases import Gradients diff --git a/stubs/tensorflow/tensorflow/keras/regularizers.pyi b/stubs/tensorflow/tensorflow/keras/regularizers.pyi index 448fb65870f3..9935bd1c3a1b 100644 --- a/stubs/tensorflow/tensorflow/keras/regularizers.pyi +++ b/stubs/tensorflow/tensorflow/keras/regularizers.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable -from typing import Any, overload -from typing_extensions import Self, TypeAlias +from typing import Any, TypeAlias, overload +from typing_extensions import Self from tensorflow import Tensor diff --git a/stubs/tensorflow/tensorflow/math.pyi b/stubs/tensorflow/tensorflow/math.pyi index b64aeae674b5..a9a6c6c4a6a6 100644 --- a/stubs/tensorflow/tensorflow/math.pyi +++ b/stubs/tensorflow/tensorflow/math.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterable -from typing import TypeVar, overload -from typing_extensions import TypeAlias +from typing import TypeAlias, TypeVar, overload from tensorflow import IndexedSlices, RaggedTensor, Tensor from tensorflow._aliases import DTypeLike, ShapeLike, TensorCompatible diff --git a/stubs/tensorflow/tensorflow/python/feature_column/feature_column_v2.pyi b/stubs/tensorflow/tensorflow/python/feature_column/feature_column_v2.pyi index e2f02fa4b40f..84571bb27921 100644 --- a/stubs/tensorflow/tensorflow/python/feature_column/feature_column_v2.pyi +++ b/stubs/tensorflow/tensorflow/python/feature_column/feature_column_v2.pyi @@ -5,8 +5,8 @@ from _typeshed import Incomplete from abc import ABC, ABCMeta, abstractmethod from collections.abc import Callable, Sequence -from typing import Literal -from typing_extensions import Self, TypeAlias +from typing import Literal, TypeAlias +from typing_extensions import Self import tensorflow as tf from tensorflow._aliases import ShapeLike diff --git a/stubs/tensorflow/tensorflow/random.pyi b/stubs/tensorflow/tensorflow/random.pyi index 85884f19d6cb..984773c69e7d 100644 --- a/stubs/tensorflow/tensorflow/random.pyi +++ b/stubs/tensorflow/tensorflow/random.pyi @@ -1,7 +1,6 @@ from collections.abc import Sequence from enum import Enum -from typing import Literal -from typing_extensions import TypeAlias +from typing import Literal, TypeAlias import numpy as np import numpy.typing as npt diff --git a/stubs/tensorflow/tensorflow/saved_model/__init__.pyi b/stubs/tensorflow/tensorflow/saved_model/__init__.pyi index c8244ba4f50e..96fe2cfeb342 100644 --- a/stubs/tensorflow/tensorflow/saved_model/__init__.pyi +++ b/stubs/tensorflow/tensorflow/saved_model/__init__.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Mapping, Sequence from pathlib import Path -from typing import Any, Generic, Literal, TypeVar -from typing_extensions import ParamSpec, TypeAlias +from typing import Any, Generic, Literal, TypeAlias, TypeVar +from typing_extensions import ParamSpec import tensorflow as tf from tensorflow.python.training.tracking.autotrackable import AutoTrackable diff --git a/stubs/tensorflow/tensorflow/sparse.pyi b/stubs/tensorflow/tensorflow/sparse.pyi index 1cd1da7f361d..d58e57f16a02 100644 --- a/stubs/tensorflow/tensorflow/sparse.pyi +++ b/stubs/tensorflow/tensorflow/sparse.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from abc import ABCMeta -from typing_extensions import TypeAlias +from typing import TypeAlias from tensorflow import Tensor, TensorShape from tensorflow._aliases import TensorCompatible diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_service_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_service_pb2.pyi index 27721cfbefe4..dbb7bf54242e 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_service_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_service_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -14,11 +14,6 @@ import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _CoordinatedTaskState: diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/dnn_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/dnn_pb2.pyi index c8d947994d74..bb9cd376f2ae 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/dnn_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/dnn_pb2.pyi @@ -5,8 +5,8 @@ LINT: LEGACY_NAMES""" import builtins import collections.abc -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,11 +14,6 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import google.protobuf.wrappers_pb2 -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DataType: diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/error_codes_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/error_codes_pb2.pyi index 3b0b8dcf4b37..cc39f9f14eae 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/error_codes_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/error_codes_pb2.pyi @@ -6,17 +6,12 @@ migrate. """ import builtins -import sys import typing +import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Code: diff --git a/stubs/toml/toml/decoder.pyi b/stubs/toml/toml/decoder.pyi index 131e164a34fe..da0217df9391 100644 --- a/stubs/toml/toml/decoder.pyi +++ b/stubs/toml/toml/decoder.pyi @@ -2,8 +2,7 @@ from _typeshed import SupportsRead from collections.abc import Callable, MutableMapping from pathlib import PurePath from re import Pattern -from typing import Any, Generic, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, Generic, TypeAlias, TypeVar, overload _MutableMappingT = TypeVar("_MutableMappingT", bound=MutableMapping[str, Any]) _PathLike: TypeAlias = str | bytes | PurePath diff --git a/stubs/ttkthemes/ttkthemes/_imgops.pyi b/stubs/ttkthemes/ttkthemes/_imgops.pyi index 3322a352372a..5a65a25702a9 100644 --- a/stubs/ttkthemes/ttkthemes/_imgops.pyi +++ b/stubs/ttkthemes/ttkthemes/_imgops.pyi @@ -1,5 +1,4 @@ -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias _Image: TypeAlias = Any # actually PIL.Image, but not worth adding a dependency diff --git a/stubs/uWSGI/uwsgi.pyi b/stubs/uWSGI/uwsgi.pyi index 8d37a83ecf6b..b605b8cf37ac 100644 --- a/stubs/uWSGI/uwsgi.pyi +++ b/stubs/uWSGI/uwsgi.pyi @@ -2,8 +2,8 @@ from _typeshed import HasFileno, OptExcInfo, ReadOnlyBuffer from _typeshed.wsgi import WSGIApplication from collections.abc import Callable from types import ModuleType -from typing import Any, Literal, Protocol, final, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Literal, Protocol, TypeAlias, final, overload, type_check_only +from typing_extensions import Self import uwsgidecorators diff --git a/stubs/waitress/waitress/adjustments.pyi b/stubs/waitress/waitress/adjustments.pyi index cd22f72bf0fb..2c3574a2a855 100644 --- a/stubs/waitress/waitress/adjustments.pyi +++ b/stubs/waitress/waitress/adjustments.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable, Sequence from socket import socket -from typing import Final -from typing_extensions import TypeAlias +from typing import Final, TypeAlias # Really complex, consider unpacking a TypedDict _AdjustmentsParams: TypeAlias = Incomplete diff --git a/stubs/waitress/waitress/wasyncore.pyi b/stubs/waitress/waitress/wasyncore.pyi index b50972143c27..788cbc8d2208 100644 --- a/stubs/waitress/waitress/wasyncore.pyi +++ b/stubs/waitress/waitress/wasyncore.pyi @@ -4,7 +4,7 @@ from collections.abc import Mapping from io import BytesIO from logging import Logger from socket import _RetAddress, socket -from typing_extensions import TypeAlias +from typing import TypeAlias _Socket: TypeAlias = socket _SocketMap: TypeAlias = Mapping[int, socket] diff --git a/stubs/watchpoints/watchpoints/watch.pyi b/stubs/watchpoints/watchpoints/watch.pyi index a10b9c456beb..bc9e9efbc61a 100644 --- a/stubs/watchpoints/watchpoints/watch.pyi +++ b/stubs/watchpoints/watchpoints/watch.pyi @@ -3,8 +3,7 @@ from _typeshed import SupportsWrite, TraceFunction from collections.abc import Callable from pdb import Pdb from types import FrameType -from typing import Any, Literal, Protocol, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing import Any, Literal, Protocol, TypeAlias, TypeVar, type_check_only from .watch_element import WatchElement diff --git a/stubs/watchpoints/watchpoints/watch_element.pyi b/stubs/watchpoints/watchpoints/watch_element.pyi index b99f7e65f1c3..3bb23d966fed 100644 --- a/stubs/watchpoints/watchpoints/watch_element.pyi +++ b/stubs/watchpoints/watchpoints/watch_element.pyi @@ -1,8 +1,7 @@ import ast from collections.abc import Callable, Iterable from types import FrameType -from typing import Any, Literal, TypeVar -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias, TypeVar from .watch_print import WatchPrint diff --git a/stubs/workalendar/workalendar/asia/israel.pyi b/stubs/workalendar/workalendar/asia/israel.pyi index 7b55f6a1ec86..c5de8f97ff0e 100644 --- a/stubs/workalendar/workalendar/asia/israel.pyi +++ b/stubs/workalendar/workalendar/asia/israel.pyi @@ -1,6 +1,5 @@ import datetime -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from ..core import Calendar diff --git a/stubs/workalendar/workalendar/usa/florida.pyi b/stubs/workalendar/workalendar/usa/florida.pyi index 127f679fc4e6..00317912d0e9 100644 --- a/stubs/workalendar/workalendar/usa/florida.pyi +++ b/stubs/workalendar/workalendar/usa/florida.pyi @@ -1,6 +1,5 @@ import datetime -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from .core import UnitedStates diff --git a/stubs/wurlitzer/wurlitzer.pyi b/stubs/wurlitzer/wurlitzer.pyi index 848c6383f04c..eee899a1e1ee 100644 --- a/stubs/wurlitzer/wurlitzer.pyi +++ b/stubs/wurlitzer/wurlitzer.pyi @@ -7,8 +7,8 @@ from _typeshed import SupportsWrite from contextlib import _GeneratorContextManager from threading import Thread from types import TracebackType -from typing import Any, Final, Literal, Protocol, TextIO, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeAlias +from typing import Any, Final, Literal, Protocol, TextIO, TypeAlias, TypeVar, overload, type_check_only +from typing_extensions import Self STDOUT: Final = 2 PIPE: Final = 3 diff --git a/stubs/xmldiff/xmldiff/main.pyi b/stubs/xmldiff/xmldiff/main.pyi index 78fcb4b31af7..46d521b90474 100644 --- a/stubs/xmldiff/xmldiff/main.pyi +++ b/stubs/xmldiff/xmldiff/main.pyi @@ -1,7 +1,6 @@ from argparse import ArgumentParser from collections.abc import Iterable, Mapping, Sequence -from typing import Any, overload -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, overload from xmldiff.actions import ( DeleteAttrib, diff --git a/stubs/xmltodict/xmltodict.pyi b/stubs/xmltodict/xmltodict.pyi index 937db619e499..6edb52a2fae2 100644 --- a/stubs/xmltodict/xmltodict.pyi +++ b/stubs/xmltodict/xmltodict.pyi @@ -1,7 +1,6 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Callable, Container, Generator, Mapping -from typing import Any, overload -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, overload class ParsingInterrupted(Exception): ... diff --git a/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi b/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi index 785d62ddc96c..4648784a5beb 100644 --- a/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi +++ b/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi @@ -2,8 +2,8 @@ import types from collections.abc import Callable, Collection, Iterable, Iterator, Mapping from functools import cached_property from types import TracebackType -from typing import Any -from typing_extensions import Self, TypeAlias +from typing import Any, TypeAlias +from typing_extensions import Self from urllib.request import Request from yt_dlp.cache import Cache diff --git a/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi b/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi index 98ad67c2b7d5..dcffac8ec8dd 100644 --- a/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi +++ b/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi @@ -1,6 +1,5 @@ from collections.abc import Mapping -from typing import Any, Literal -from typing_extensions import TypeAlias +from typing import Any, Literal, TypeAlias from ..extractor.common import _InfoDict from ..utils._utils import NO_DEFAULT diff --git a/stubs/yt-dlp/yt_dlp/extractor/common.pyi b/stubs/yt-dlp/yt_dlp/extractor/common.pyi index d977586c5182..882a504087d5 100644 --- a/stubs/yt-dlp/yt_dlp/extractor/common.pyi +++ b/stubs/yt-dlp/yt_dlp/extractor/common.pyi @@ -3,8 +3,8 @@ from _typeshed import Incomplete, Unused from collections.abc import Callable, Collection, Iterable, Iterator, Mapping, Sequence from functools import cached_property from json.decoder import JSONDecoder -from typing import Any, ClassVar, Literal, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Never, Required, TypeAlias, deprecated +from typing import Any, ClassVar, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Never, Required, deprecated from urllib.request import Request, _DataType from xml.etree import ElementTree as ET diff --git a/stubs/yt-dlp/yt_dlp/jsinterp.pyi b/stubs/yt-dlp/yt_dlp/jsinterp.pyi index 4fbd25299b5c..f12c93d3fc46 100644 --- a/stubs/yt-dlp/yt_dlp/jsinterp.pyi +++ b/stubs/yt-dlp/yt_dlp/jsinterp.pyi @@ -1,8 +1,7 @@ import collections import types from collections.abc import Callable, Collection, Iterable, Mapping -from typing import Any, NoReturn -from typing_extensions import TypeAlias +from typing import Any, NoReturn, TypeAlias from yt_dlp.extractor.common import InfoExtractor from yt_dlp.utils._utils import function_with_repr diff --git a/stubs/yt-dlp/yt_dlp/networking/_helper.pyi b/stubs/yt-dlp/yt_dlp/networking/_helper.pyi index d93a606440ad..d0e48da6604a 100644 --- a/stubs/yt-dlp/yt_dlp/networking/_helper.pyi +++ b/stubs/yt-dlp/yt_dlp/networking/_helper.pyi @@ -3,8 +3,7 @@ from _socket import _Address from _typeshed import StrOrBytesPath from collections.abc import Callable, Iterable, Mapping from socket import AddressFamily, SocketKind -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias from ..socks import sockssocket from ..utils.networking import HTTPHeaderDict diff --git a/stubs/yt-dlp/yt_dlp/networking/common.pyi b/stubs/yt-dlp/yt_dlp/networking/common.pyi index 3c0f077ccb0a..bb600721f6e2 100644 --- a/stubs/yt-dlp/yt_dlp/networking/common.pyi +++ b/stubs/yt-dlp/yt_dlp/networking/common.pyi @@ -5,8 +5,8 @@ from _typeshed import Unused from collections.abc import Callable, Iterable, Mapping from email.message import Message from logging import Logger -from typing import IO, Any, Final -from typing_extensions import Self, TypeAlias +from typing import IO, Any, Final, TypeAlias +from typing_extensions import Self from ..cookies import YoutubeDLCookieJar from ..utils._utils import _YDLLogger diff --git a/stubs/yt-dlp/yt_dlp/utils/_utils.pyi b/stubs/yt-dlp/yt_dlp/utils/_utils.pyi index 73e25f4453da..2d579b230a79 100644 --- a/stubs/yt-dlp/yt_dlp/utils/_utils.pyi +++ b/stubs/yt-dlp/yt_dlp/utils/_utils.pyi @@ -23,8 +23,8 @@ from functools import cache from optparse import Values from os import PathLike from re import Pattern -from typing import IO, Any, AnyStr, BinaryIO, Final, Generic, Literal, NamedTuple, TextIO, TypeVar, overload -from typing_extensions import Self, TypeAlias +from typing import IO, Any, AnyStr, BinaryIO, Final, Generic, Literal, NamedTuple, TextIO, TypeAlias, TypeVar, overload +from typing_extensions import Self from urllib.parse import _QueryType, _QuoteVia from xml.etree import ElementTree as ET diff --git a/stubs/yt-dlp/yt_dlp/utils/traversal.pyi b/stubs/yt-dlp/yt_dlp/utils/traversal.pyi index a59073a2b380..f50ace1d4f80 100644 --- a/stubs/yt-dlp/yt_dlp/utils/traversal.pyi +++ b/stubs/yt-dlp/yt_dlp/utils/traversal.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Collection, Iterable, Mapping -from typing import Any, TypeVar, overload -from typing_extensions import TypeAlias +from typing import Any, TypeAlias, TypeVar, overload from ._utils import NO_DEFAULT, ExtractorError diff --git a/stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi b/stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi index 8b1e8e82331e..260ad8b3b441 100644 --- a/stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi +++ b/stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi @@ -1,4 +1,4 @@ -from typing_extensions import TypeAlias +from typing import TypeAlias _Graph: TypeAlias = dict[str, list[str | None]] diff --git a/tests/mypy_test.py b/tests/mypy_test.py index dfc7adba8062..c9b3993839b9 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -16,8 +16,7 @@ from itertools import product from pathlib import Path from threading import Lock -from typing import Annotated, Any, NamedTuple -from typing_extensions import TypeAlias +from typing import Annotated, Any, NamedTuple, TypeAlias from packaging.requirements import Requirement diff --git a/tests/regr_test.py b/tests/regr_test.py index b37509ad9f83..f942e9d0f238 100755 --- a/tests/regr_test.py +++ b/tests/regr_test.py @@ -19,7 +19,7 @@ from enum import IntEnum from functools import partial from pathlib import Path -from typing_extensions import TypeAlias +from typing import TypeAlias from ts_utils.metadata import get_recursive_requirements, read_metadata from ts_utils.mypy import mypy_configuration_from_distribution, temporary_mypy_config_file diff --git a/tests/stubtest_stdlib.py b/tests/stubtest_stdlib.py index ac794eb4bacd..4522a68691d5 100755 --- a/tests/stubtest_stdlib.py +++ b/tests/stubtest_stdlib.py @@ -32,10 +32,6 @@ def run_stubtest(typeshed_dir: Path) -> int: str(typeshed_dir), *allowlist_stubtest_arguments("stdlib"), ] - if sys.version_info < (3, 10): - # As discussed in https://github.com/python/typeshed/issues/3693, we only aim for - # positional-only arg accuracy for python 3.10 and above. - cmd += ["--ignore-positional-only"] print(" ".join(cmd), file=sys.stderr) try: subprocess.run(cmd, check=True) diff --git a/tests/typecheck_typeshed.py b/tests/typecheck_typeshed.py index 63449e4d4ee3..6ddbb90a8a5b 100755 --- a/tests/typecheck_typeshed.py +++ b/tests/typecheck_typeshed.py @@ -7,7 +7,7 @@ import subprocess import sys from itertools import product -from typing_extensions import TypeAlias +from typing import TypeAlias from ts_utils.utils import colored, print_error From 50a529c15fc7c25f3346f3e16505176a50291554 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 9 Feb 2026 14:31:25 +0100 Subject: [PATCH 3/7] Ignore E402 for now --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index d44ad9e7ec43..6105f7287195 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,6 +147,11 @@ extend-safe-fixes = [ "UP036", # Remove unnecessary `sys.version_info` blocks ] ignore = [ + ### + # TODO: Disabled temporarily, until Python 3.9 branches are removed in + # May 2026. + ### + "E402", # module level import not at top of file ### # Rules that can conflict with the formatter (Black) # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules From 78a410cad235199b014cf4819959e69aa050fc00 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 9 Feb 2026 14:33:35 +0100 Subject: [PATCH 4/7] Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" This reverts commit 9a792666e220744cdc6e54f3fa10ae8114d0e9e9. --- lib/ts_utils/metadata.py | 3 +- lib/ts_utils/utils.py | 3 +- scripts/stubsabot.py | 4 +- stdlib/__future__.pyi | 2 +- stdlib/_ast.pyi | 27 +- stdlib/_asyncio.pyi | 4 +- stdlib/_bisect.pyi | 140 ++-- stdlib/_codecs.pyi | 8 +- stdlib/_collections_abc.pyi | 17 +- stdlib/_csv.pyi | 65 +- stdlib/_ctypes.pyi | 19 +- stdlib/_curses.pyi | 20 +- stdlib/_dbm.pyi | 4 +- stdlib/_decimal.pyi | 3 +- stdlib/_frozen_importlib.pyi | 23 +- stdlib/_frozen_importlib_external.pyi | 62 +- stdlib/_gdbm.pyi | 4 +- stdlib/_hashlib.pyi | 7 +- stdlib/_interpqueues.pyi | 3 +- stdlib/_interpreters.pyi | 4 +- stdlib/_io.pyi | 9 +- stdlib/_lsprof.pyi | 7 +- stdlib/_lzma.pyi | 4 +- stdlib/_markupbase.pyi | 6 + stdlib/_operator.pyi | 4 +- stdlib/_pickle.pyi | 4 +- stdlib/_random.pyi | 10 +- stdlib/_socket.pyi | 7 +- stdlib/_sqlite3.pyi | 15 +- stdlib/_ssl.pyi | 44 +- stdlib/_thread.pyi | 11 +- stdlib/_threading_local.pyi | 4 +- stdlib/_tkinter.pyi | 4 +- stdlib/_typeshed/__init__.pyi | 12 +- stdlib/_typeshed/dbapi.pyi | 3 +- stdlib/_typeshed/wsgi.pyi | 3 +- stdlib/_winapi.pyi | 35 +- stdlib/_zstd.pyi | 4 +- stdlib/abc.pyi | 8 +- stdlib/aifc.pyi | 4 +- stdlib/argparse.pyi | 4 +- stdlib/array.pyi | 10 +- stdlib/ast.pyi | 511 +++++++------ stdlib/asyncio/__init__.pyi | 3 +- stdlib/asyncio/base_events.pyi | 4 +- stdlib/asyncio/base_subprocess.pyi | 3 +- stdlib/asyncio/coroutines.pyi | 4 +- stdlib/asyncio/events.pyi | 6 +- stdlib/asyncio/format_helpers.pyi | 3 +- stdlib/asyncio/locks.pyi | 31 +- stdlib/asyncio/proactor_events.pyi | 32 +- stdlib/asyncio/queues.pyi | 12 +- stdlib/asyncio/sslproto.pyi | 3 +- stdlib/asyncio/streams.pyi | 83 ++- stdlib/asyncio/subprocess.pyi | 66 +- stdlib/asyncio/tasks.pyi | 398 +++++++--- stdlib/asyncio/trsock.pyi | 4 +- stdlib/asyncore.pyi | 3 +- stdlib/audioop.pyi | 3 +- stdlib/base64.pyi | 10 +- stdlib/bdb.pyi | 4 +- stdlib/binascii.pyi | 3 +- stdlib/binhex.pyi | 3 +- stdlib/builtins.pyi | 276 ++++--- stdlib/bz2.pyi | 4 +- stdlib/cProfile.pyi | 4 +- stdlib/calendar.pyi | 6 +- stdlib/cmath.pyi | 3 +- stdlib/codecs.pyi | 4 +- stdlib/collections/__init__.pyi | 45 +- stdlib/compileall.pyi | 101 ++- stdlib/compression/zstd/_zstdfile.pyi | 3 +- stdlib/concurrent/futures/interpreter.pyi | 4 +- stdlib/concurrent/futures/thread.pyi | 4 +- .../concurrent/interpreters/_crossinterp.pyi | 4 +- stdlib/configparser.pyi | 4 +- stdlib/contextlib.pyi | 90 ++- stdlib/copyreg.pyi | 3 +- stdlib/csv.pyi | 6 +- stdlib/ctypes/__init__.pyi | 4 +- stdlib/ctypes/wintypes.pyi | 4 +- stdlib/curses/__init__.pyi | 8 +- stdlib/dataclasses.pyi | 108 ++- stdlib/datetime.pyi | 4 +- stdlib/dbm/__init__.pyi | 4 +- stdlib/dbm/dumb.pyi | 3 +- stdlib/dbm/sqlite3.pyi | 4 +- stdlib/decimal.pyi | 4 +- stdlib/dis.pyi | 4 +- stdlib/distutils/ccompiler.pyi | 4 +- stdlib/distutils/command/__init__.pyi | 7 + stdlib/distutils/command/check.pyi | 3 +- stdlib/distutils/command/install.pyi | 4 + stdlib/distutils/dist.pyi | 3 +- stdlib/distutils/fancy_getopt.pyi | 3 +- stdlib/distutils/sysconfig.pyi | 4 + stdlib/doctest.pyi | 4 +- stdlib/email/__init__.pyi | 3 +- stdlib/email/errors.pyi | 6 +- stdlib/email/message.pyi | 4 +- stdlib/email/utils.pyi | 4 +- stdlib/enum.pyi | 8 +- stdlib/fcntl.pyi | 5 +- stdlib/fileinput.pyi | 196 +++-- stdlib/formatter.pyi | 3 +- stdlib/fractions.pyi | 4 +- stdlib/functools.pyi | 4 +- stdlib/gc.pyi | 3 +- stdlib/glob.pyi | 27 +- stdlib/grp.pyi | 3 +- stdlib/gzip.pyi | 4 +- stdlib/hmac.pyi | 3 +- stdlib/http/client.pyi | 4 +- stdlib/http/cookiejar.pyi | 5 +- stdlib/http/cookies.pyi | 3 +- stdlib/imaplib.pyi | 4 +- stdlib/importlib/_abc.pyi | 25 +- stdlib/importlib/abc.pyi | 80 +- stdlib/importlib/metadata/__init__.pyi | 79 +- stdlib/importlib/readers.pyi | 87 +-- stdlib/importlib/resources/__init__.pyi | 9 +- stdlib/importlib/resources/_common.pyi | 4 +- stdlib/inspect.pyi | 16 +- stdlib/ipaddress.pyi | 4 +- stdlib/itertools.pyi | 15 +- stdlib/lib2to3/pgen2/__init__.pyi | 3 +- stdlib/lib2to3/pgen2/grammar.pyi | 3 +- stdlib/lib2to3/pgen2/parse.pyi | 2 +- stdlib/lib2to3/pgen2/tokenize.pyi | 2 +- stdlib/lib2to3/pytree.pyi | 4 +- stdlib/linecache.pyi | 3 +- stdlib/locale.pyi | 5 +- stdlib/logging/__init__.pyi | 43 +- stdlib/logging/config.pyi | 26 +- stdlib/lzma.pyi | 4 +- stdlib/mailbox.pyi | 4 +- stdlib/mailcap.pyi | 2 +- stdlib/marshal.pyi | 3 +- stdlib/math.pyi | 3 +- stdlib/mmap.pyi | 3 +- stdlib/msilib/sequence.pyi | 3 +- stdlib/msvcrt.pyi | 3 +- stdlib/multiprocessing/connection.pyi | 4 +- stdlib/multiprocessing/context.pyi | 3 +- stdlib/multiprocessing/heap.pyi | 3 +- stdlib/multiprocessing/managers.pyi | 10 +- stdlib/multiprocessing/synchronize.pyi | 2 +- stdlib/netrc.pyi | 2 +- stdlib/nntplib.pyi | 4 +- stdlib/os/__init__.pyi | 62 +- stdlib/pathlib/__init__.pyi | 42 +- stdlib/pdb.pyi | 9 +- stdlib/pickletools.pyi | 3 +- stdlib/platform.pyi | 7 +- stdlib/poplib.pyi | 4 +- stdlib/posix.pyi | 32 +- stdlib/pprint.pyi | 134 +++- stdlib/profile.pyi | 4 +- stdlib/pstats.pyi | 4 +- stdlib/pty.pyi | 4 +- stdlib/pwd.pyi | 3 +- stdlib/py_compile.pyi | 8 +- stdlib/pyclbr.pyi | 68 +- stdlib/pydoc.pyi | 4 +- stdlib/pyexpat/__init__.pyi | 12 +- stdlib/random.pyi | 5 +- stdlib/re.pyi | 4 +- stdlib/readline.pyi | 3 +- stdlib/reprlib.pyi | 3 +- stdlib/resource.pyi | 37 +- stdlib/sched.pyi | 31 +- stdlib/selectors.pyi | 4 +- stdlib/shutil.pyi | 4 +- stdlib/signal.pyi | 28 +- stdlib/smtpd.pyi | 4 +- stdlib/smtplib.pyi | 4 +- stdlib/socket.pyi | 10 +- stdlib/socketserver.pyi | 4 +- stdlib/spwd.pyi | 23 +- stdlib/sqlite3/__init__.pyi | 7 +- stdlib/sqlite3/dbapi2.pyi | 17 +- stdlib/sre_parse.pyi | 3 +- stdlib/ssl.pyi | 114 ++- stdlib/statistics.pyi | 28 +- stdlib/subprocess.pyi | 704 ++++++++++++++++-- stdlib/sunau.pyi | 4 +- stdlib/sys/__init__.pyi | 59 +- stdlib/sysconfig.pyi | 10 +- stdlib/tarfile.pyi | 4 +- stdlib/tempfile.pyi | 14 +- stdlib/termios.pyi | 3 +- stdlib/threading.pyi | 12 +- stdlib/time.pyi | 6 +- stdlib/timeit.pyi | 3 +- stdlib/tkinter/__init__.pyi | 17 +- stdlib/tkinter/font.pyi | 12 +- stdlib/tkinter/ttk.pyi | 4 +- stdlib/token.pyi | 6 +- stdlib/tokenize.pyi | 7 +- stdlib/trace.pyi | 4 +- stdlib/traceback.pyi | 106 ++- stdlib/tracemalloc.pyi | 3 +- stdlib/tty.pyi | 3 +- stdlib/turtle.pyi | 4 +- stdlib/types.pyi | 131 +++- stdlib/typing.pyi | 236 +++--- stdlib/typing_extensions.pyi | 68 +- stdlib/unicodedata.pyi | 7 +- stdlib/unittest/_log.pyi | 8 +- stdlib/unittest/case.pyi | 12 +- stdlib/unittest/loader.pyi | 4 +- stdlib/unittest/mock.pyi | 84 ++- stdlib/unittest/result.pyi | 3 +- stdlib/unittest/runner.pyi | 4 +- stdlib/unittest/suite.pyi | 3 +- stdlib/unittest/util.pyi | 3 +- stdlib/urllib/parse.pyi | 3 +- stdlib/urllib/request.pyi | 4 +- stdlib/uu.pyi | 3 +- stdlib/uuid.pyi | 4 +- stdlib/warnings.pyi | 4 +- stdlib/wave.pyi | 4 +- stdlib/winreg.pyi | 4 +- stdlib/wsgiref/headers.pyi | 3 +- stdlib/wsgiref/types.pyi | 3 +- stdlib/wsgiref/validate.pyi | 3 +- stdlib/xml/dom/expatbuilder.pyi | 3 +- stdlib/xml/dom/minidom.pyi | 4 +- stdlib/xml/dom/pulldom.pyi | 4 +- stdlib/xml/etree/ElementPath.pyi | 3 +- stdlib/xml/etree/ElementTree.pyi | 4 +- stdlib/xml/sax/__init__.pyi | 3 +- stdlib/xml/sax/expatreader.pyi | 21 +- stdlib/xml/sax/handler.pyi | 14 +- stdlib/xml/sax/xmlreader.pyi | 4 +- stdlib/xmlrpc/client.pyi | 4 +- stdlib/xmlrpc/server.pyi | 3 +- stdlib/xxlimited.pyi | 13 +- stdlib/zipapp.pyi | 3 +- stdlib/zipfile/__init__.pyi | 22 +- stdlib/zipimport.pyi | 43 +- stubs/Authlib/authlib/common/urls.pyi | 3 +- .../httpx_client/oauth1_client.pyi | 3 +- .../httpx_client/oauth2_client.pyi | 3 +- stubs/Authlib/authlib/jose/rfc7519/jwt.pyi | 3 +- .../oauth2/rfc6749/authorization_server.pyi | 4 +- .../rfc6749/grants/authorization_code.pyi | 2 +- .../authlib/oauth2/rfc6749/grants/base.pyi | 2 +- .../oauth2/rfc6749/grants/refresh_token.pyi | 2 +- stubs/Deprecated/deprecated/classic.pyi | 3 +- stubs/Flask-Cors/flask_cors/core.pyi | 3 +- .../Flask-Migrate/flask_migrate/__init__.pyi | 4 +- .../flask_socketio/__init__.pyi | 4 +- stubs/Markdown/markdown/treeprocessors.pyi | 3 +- stubs/Markdown/markdown/util.pyi | 9 +- stubs/PyAutoGUI/pyautogui/__init__.pyi | 4 +- stubs/PyMySQL/pymysql/converters.pyi | 4 +- stubs/PyScreeze/pyscreeze/__init__.pyi | 4 +- stubs/PySocks/socks.pyi | 4 +- stubs/PyYAML/yaml/cyaml.pyi | 3 +- stubs/PyYAML/yaml/dumper.pyi | 3 +- stubs/PyYAML/yaml/loader.pyi | 2 +- stubs/PyYAML/yaml/reader.pyi | 3 +- stubs/Pygments/pygments/plugin.pyi | 11 +- stubs/RPi.GPIO/RPi/GPIO/__init__.pyi | 3 +- stubs/WTForms/wtforms/fields/choices.pyi | 4 +- stubs/WTForms/wtforms/fields/core.pyi | 4 +- stubs/WTForms/wtforms/form.pyi | 3 +- stubs/WTForms/wtforms/meta.pyi | 3 +- stubs/WebOb/webob/_types.pyi | 3 +- stubs/WebOb/webob/acceptparse.pyi | 4 +- stubs/WebOb/webob/cookies.pyi | 3 +- stubs/WebOb/webob/dec.pyi | 4 +- stubs/WebOb/webob/descriptors.pyi | 3 +- stubs/WebOb/webob/etag.pyi | 3 +- stubs/WebOb/webob/exc.pyi | 4 +- stubs/WebOb/webob/request.pyi | 4 +- stubs/WebOb/webob/response.pyi | 4 +- .../aiofiles/aiofiles/threadpool/__init__.pyi | 3 +- stubs/assertpy/assertpy/base.pyi | 3 +- stubs/assertpy/assertpy/numeric.pyi | 3 +- stubs/auth0-python/auth0/types.pyi | 2 +- .../aws_xray_sdk/core/models/trace_header.pyi | 4 +- stubs/bleach/bleach/__init__.pyi | 2 +- stubs/bleach/bleach/callbacks.pyi | 3 +- stubs/bleach/bleach/linkifier.pyi | 3 +- stubs/bleach/bleach/sanitizer.pyi | 3 +- stubs/boltons/boltons/dictutils.pyi | 4 +- stubs/boltons/boltons/listutils.pyi | 4 +- stubs/boltons/boltons/queueutils.pyi | 2 +- stubs/braintree/braintree/util/generator.pyi | 2 +- stubs/cffi/_cffi_backend.pyi | 4 +- stubs/cffi/cffi/api.pyi | 3 +- stubs/cffi/cffi/recompiler.pyi | 3 +- stubs/cffi/cffi/verifier.pyi | 3 +- stubs/channels/channels/layers.pyi | 4 +- stubs/channels/channels/testing/live.pyi | 3 +- stubs/channels/channels/testing/websocket.pyi | 4 +- stubs/channels/channels/utils.pyi | 3 +- stubs/click-log/click_log/options.pyi | 3 +- .../click_web/resources/input_fields.pyi | 6 +- stubs/colorama/colorama/ansitowin32.pyi | 3 +- stubs/colorful/colorful/core.pyi | 4 +- stubs/croniter/croniter/croniter.pyi | 4 +- stubs/dateparser/dateparser/__init__.pyi | 3 +- stubs/dateparser/dateparser/date.pyi | 3 +- stubs/dirhash/dirhash/__init__.pyi | 3 +- stubs/django-filter/django_filters/fields.pyi | 3 +- .../rest_framework/backends.pyi | 3 +- .../import_export/admin.pyi | 4 +- .../import_export/formats/base_formats.pyi | 4 +- .../import_export/instance_loaders.pyi | 3 +- .../import_export/mixins.pyi | 4 +- .../import_export/resources.pyi | 4 +- .../import_export/results.pyi | 3 +- stubs/docker/docker/_types.pyi | 4 +- stubs/docker/docker/api/container.pyi | 3 +- stubs/docker/docker/api/network.pyi | 3 +- stubs/docker/docker/models/images.pyi | 3 +- stubs/docker/docker/transport/npipesocket.pyi | 3 +- .../dockerfile_parse/util.pyi | 3 +- stubs/docutils/docutils/examples.pyi | 3 +- stubs/docutils/docutils/nodes.pyi | 4 +- .../docutils/parsers/commonmark_wrapper.pyi | 3 +- .../docutils/parsers/rst/__init__.pyi | 3 +- .../docutils/parsers/rst/directives/body.pyi | 3 +- stubs/docutils/docutils/parsers/rst/roles.pyi | 4 +- .../docutils/docutils/parsers/rst/states.pyi | 3 +- .../docutils/parsers/rst/tableparser.pyi | 3 +- stubs/docutils/docutils/statemachine.pyi | 4 +- .../docutils/docutils/transforms/__init__.pyi | 3 +- stubs/docutils/docutils/utils/__init__.pyi | 4 +- .../docutils/docutils/utils/code_analyzer.pyi | 3 +- stubs/ephem/ephem/_libastro.pyi | 4 +- stubs/fanstatic/fanstatic/core.pyi | 3 +- stubs/flake8-builtins/flake8_builtins.pyi | 3 +- stubs/flake8/flake8/checker.pyi | 3 +- stubs/flake8/flake8/processor.pyi | 3 +- stubs/fpdf2/fpdf/_fonttools_shims.pyi | 3 +- stubs/fpdf2/fpdf/drawing.pyi | 12 +- stubs/fpdf2/fpdf/encryption.pyi | 3 +- stubs/fpdf2/fpdf/enums.pyi | 4 +- stubs/fpdf2/fpdf/fpdf.pyi | 4 +- stubs/fpdf2/fpdf/html.pyi | 3 +- stubs/fpdf2/fpdf/image_datastructures.pyi | 3 +- stubs/fpdf2/fpdf/image_parsing.pyi | 3 +- stubs/fpdf2/fpdf/util.pyi | 3 +- stubs/gdb/gdb/__init__.pyi | 4 +- stubs/gdb/gdb/dap/next.pyi | 3 +- stubs/gdb/gdb/dap/server.pyi | 3 +- stubs/gdb/gdb/dap/sources.pyi | 3 +- stubs/gdb/gdb/dap/startup.pyi | 3 +- stubs/geopandas/geopandas/_decorator.pyi | 3 +- stubs/geopandas/geopandas/array.pyi | 4 +- stubs/geopandas/geopandas/base.pyi | 4 +- stubs/geopandas/geopandas/io/_geoarrow.pyi | 3 +- stubs/geopandas/geopandas/io/sql.pyi | 3 +- stubs/geopandas/geopandas/plotting.pyi | 3 +- stubs/gevent/gevent/_ffi/loop.pyi | 4 +- stubs/gevent/gevent/_types.pyi | 4 +- stubs/gevent/gevent/_waiter.pyi | 3 +- stubs/gevent/gevent/baseserver.pyi | 4 +- stubs/gevent/gevent/event.pyi | 3 +- stubs/gevent/gevent/events.pyi | 3 +- stubs/gevent/gevent/fileobject.pyi | 3 +- stubs/gevent/gevent/libev/watcher.pyi | 3 +- stubs/gevent/gevent/selectors.pyi | 3 +- stubs/gevent/gevent/server.pyi | 3 +- stubs/gevent/gevent/threadpool.pyi | 4 +- .../google/cloud/ndb/model.pyi | 4 +- stubs/greenlet/greenlet/_greenlet.pyi | 4 +- .../grpc_reflection/v1alpha/reflection.pyi | 3 +- stubs/grpcio/grpc/__init__.pyi | 4 +- stubs/grpcio/grpc/aio/__init__.pyi | 4 +- stubs/gunicorn/gunicorn/_types.pyi | 4 +- stubs/gunicorn/gunicorn/config.pyi | 3 +- stubs/gunicorn/gunicorn/glogging.pyi | 3 +- stubs/gunicorn/gunicorn/http/body.pyi | 2 +- stubs/gunicorn/gunicorn/http2/connection.pyi | 3 +- stubs/gunicorn/gunicorn/reloader.pyi | 3 +- stubs/gunicorn/gunicorn/workers/geventlet.pyi | 3 +- stubs/gunicorn/gunicorn/workers/gtornado.pyi | 3 +- stubs/hdbcli/hdbcli/dbapi.pyi | 4 +- stubs/html5lib/html5lib/_inputstream.pyi | 4 +- stubs/icalendar/icalendar/alarms.pyi | 2 +- stubs/icalendar/icalendar/parser_tools.pyi | 3 +- stubs/icalendar/icalendar/prop.pyi | 4 +- stubs/icalendar/icalendar/tools.pyi | 4 +- stubs/inifile/inifile.pyi | 3 +- stubs/jmespath/jmespath/ast.pyi | 4 +- stubs/jsonschema/jsonschema/_format.pyi | 3 +- stubs/jsonschema/jsonschema/_typing.pyi | 3 +- stubs/jsonschema/jsonschema/exceptions.pyi | 4 +- stubs/jsonschema/jsonschema/protocols.pyi | 3 +- stubs/jsonschema/jsonschema/validators.pyi | 4 +- stubs/jwcrypto/jwcrypto/jwk.pyi | 4 +- stubs/keyboard/keyboard/__init__.pyi | 2 +- stubs/keyboard/keyboard/_generic.pyi | 3 +- stubs/keyboard/keyboard/_mouse_event.pyi | 3 +- stubs/keyboard/keyboard/mouse.pyi | 3 +- stubs/ldap3/ldap3/core/connection.pyi | 4 +- stubs/ldap3/ldap3/utils/asn1.pyi | 3 +- stubs/libsass/sass.pyi | 4 +- stubs/lupa/lupa/lua51.pyi | 4 +- stubs/lupa/lupa/lua52.pyi | 4 +- stubs/lupa/lupa/lua53.pyi | 4 +- stubs/lupa/lupa/lua54.pyi | 4 +- stubs/m3u8/m3u8/__init__.pyi | 3 +- stubs/m3u8/m3u8/model.pyi | 3 +- stubs/m3u8/m3u8/parser.pyi | 3 +- stubs/mock/mock/backports.pyi | 7 +- stubs/mysqlclient/MySQLdb/connections.pyi | 4 +- stubs/mysqlclient/MySQLdb/cursors.pyi | 3 +- stubs/nanoid/nanoid/method.pyi | 2 +- stubs/netaddr/netaddr/eui/ieee.pyi | 3 +- stubs/netaddr/netaddr/ip/__init__.pyi | 4 +- stubs/netaddr/netaddr/ip/glob.pyi | 2 +- stubs/netaddr/netaddr/ip/iana.pyi | 3 +- stubs/netaddr/netaddr/ip/sets.pyi | 4 +- stubs/networkx/networkx/_typing.pyi | 18 +- .../algorithms/approximation/density.pyi | 3 +- .../networkx/algorithms/community/local.pyi | 3 +- .../networkx/algorithms/distance_measures.pyi | 2 +- .../algorithms/shortest_paths/weighted.pyi | 3 +- stubs/networkx/networkx/classes/graph.pyi | 4 +- .../networkx/networkx/classes/multigraph.pyi | 4 +- stubs/networkx/networkx/convert_matrix.pyi | 3 +- stubs/networkx/networkx/drawing/layout.pyi | 3 +- stubs/networkx/networkx/drawing/nx_latex.pyi | 3 +- stubs/networkx/networkx/drawing/nx_pylab.pyi | 4 +- stubs/networkx/networkx/utils/configs.pyi | 76 +- stubs/networkx/networkx/utils/misc.pyi | 7 +- stubs/oauthlib/oauthlib/common.pyi | 3 +- .../oauthlib/oauth2/rfc6749/clients/base.pyi | 3 +- .../oauth2/rfc6749/grant_types/base.pyi | 3 +- stubs/objgraph/objgraph.pyi | 3 +- stubs/olefile/olefile/olefile.pyi | 4 +- stubs/openpyxl/openpyxl/__init__.pyi | 3 +- stubs/openpyxl/openpyxl/cell/__init__.pyi | 3 +- stubs/openpyxl/openpyxl/cell/text.pyi | 3 +- stubs/openpyxl/openpyxl/chart/_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/area_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/axis.pyi | 4 +- stubs/openpyxl/openpyxl/chart/bar_chart.pyi | 3 +- .../openpyxl/openpyxl/chart/bubble_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/chartspace.pyi | 3 +- stubs/openpyxl/openpyxl/chart/error_bar.pyi | 3 +- stubs/openpyxl/openpyxl/chart/label.pyi | 3 +- stubs/openpyxl/openpyxl/chart/layout.pyi | 3 +- stubs/openpyxl/openpyxl/chart/legend.pyi | 3 +- stubs/openpyxl/openpyxl/chart/line_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/marker.pyi | 3 +- stubs/openpyxl/openpyxl/chart/picture.pyi | 3 +- stubs/openpyxl/openpyxl/chart/pie_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/radar_chart.pyi | 3 +- .../openpyxl/openpyxl/chart/scatter_chart.pyi | 3 +- stubs/openpyxl/openpyxl/chart/series.pyi | 3 +- stubs/openpyxl/openpyxl/chart/shapes.pyi | 3 +- stubs/openpyxl/openpyxl/chart/trendline.pyi | 3 +- .../openpyxl/openpyxl/chartsheet/publish.pyi | 3 +- .../openpyxl/comments/comment_sheet.pyi | 3 +- .../openpyxl/comments/shape_writer.pyi | 3 +- stubs/openpyxl/openpyxl/compat/numbers.pyi | 3 +- stubs/openpyxl/openpyxl/descriptors/base.pyi | 3 +- .../openpyxl/openpyxl/descriptors/nested.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/colors.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/effect.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/fill.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/geometry.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/image.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/line.pyi | 3 +- .../openpyxl/openpyxl/drawing/properties.pyi | 3 +- .../openpyxl/drawing/spreadsheet_drawing.pyi | 3 +- stubs/openpyxl/openpyxl/drawing/text.pyi | 3 +- stubs/openpyxl/openpyxl/formatting/rule.pyi | 3 +- stubs/openpyxl/openpyxl/formula/tokenizer.pyi | 3 +- stubs/openpyxl/openpyxl/packaging/custom.pyi | 4 +- .../openpyxl/openpyxl/packaging/workbook.pyi | 3 +- stubs/openpyxl/openpyxl/pivot/cache.pyi | 3 +- stubs/openpyxl/openpyxl/pivot/table.pyi | 3 +- stubs/openpyxl/openpyxl/reader/excel.pyi | 3 +- stubs/openpyxl/openpyxl/styles/alignment.pyi | 3 +- stubs/openpyxl/openpyxl/styles/borders.pyi | 3 +- stubs/openpyxl/openpyxl/styles/fills.pyi | 3 +- stubs/openpyxl/openpyxl/styles/fonts.pyi | 4 +- stubs/openpyxl/openpyxl/styles/numbers.pyi | 3 +- stubs/openpyxl/openpyxl/styles/table.pyi | 3 +- stubs/openpyxl/openpyxl/utils/cell.pyi | 3 +- .../workbook/external_link/external.pyi | 3 +- .../openpyxl/openpyxl/workbook/properties.pyi | 3 +- .../openpyxl/openpyxl/workbook/smart_tags.pyi | 3 +- stubs/openpyxl/openpyxl/workbook/views.pyi | 3 +- stubs/openpyxl/openpyxl/workbook/web.pyi | 3 +- stubs/openpyxl/openpyxl/workbook/workbook.pyi | 4 +- stubs/openpyxl/openpyxl/worksheet/_writer.pyi | 3 +- .../openpyxl/worksheet/datavalidation.pyi | 3 +- stubs/openpyxl/openpyxl/worksheet/filters.pyi | 3 +- stubs/openpyxl/openpyxl/worksheet/ole.pyi | 3 +- stubs/openpyxl/openpyxl/worksheet/page.pyi | 4 +- stubs/openpyxl/openpyxl/worksheet/table.pyi | 4 +- stubs/openpyxl/openpyxl/worksheet/views.pyi | 3 +- .../openpyxl/xml/_functions_overloads.pyi | 3 +- stubs/paramiko/paramiko/auth_handler.pyi | 2 +- stubs/paramiko/paramiko/message.pyi | 3 +- stubs/paramiko/paramiko/sftp_client.pyi | 4 +- stubs/paramiko/paramiko/transport.pyi | 3 +- stubs/paramiko/paramiko/win_pageant.pyi | 3 +- .../parsimonious/parsimonious/expressions.pyi | 4 +- stubs/passlib/passlib/pwd.pyi | 4 +- stubs/peewee/playhouse/flask_utils.pyi | 3 +- stubs/pexpect/pexpect/spawnbase.pyi | 3 +- stubs/pika/pika/compat.pyi | 3 +- stubs/pika/pika/data.pyi | 2 +- stubs/pika/pika/spec.pyi | 4 +- stubs/pony/pony/__init__.pyi | 3 +- stubs/pony/pony/orm/core.pyi | 4 +- stubs/pony/pony/orm/sqlbuilding.pyi | 10 +- stubs/portpicker/portpicker.pyi | 2 +- .../google/protobuf/compiler/plugin_pb2.pyi | 7 +- .../google/protobuf/descriptor_pb2.pyi | 7 +- .../google/protobuf/internal/decoder.pyi | 3 +- .../google/protobuf/internal/encoder.pyi | 2 +- .../protobuf/internal/well_known_types.pyi | 3 +- stubs/protobuf/google/protobuf/struct_pb2.pyi | 7 +- .../protobuf/google/protobuf/text_format.pyi | 3 +- stubs/protobuf/google/protobuf/type_pb2.pyi | 7 +- stubs/psutil/psutil/__init__.pyi | 35 +- stubs/psycopg2/psycopg2/_psycopg.pyi | 4 +- stubs/pyaudio/pyaudio.pyi | 3 +- stubs/pycocotools/pycocotools/coco.pyi | 3 +- stubs/pycocotools/pycocotools/cocoeval.pyi | 3 +- stubs/pycocotools/pycocotools/mask.pyi | 3 +- stubs/pyflakes/pyflakes/checker.pyi | 44 +- stubs/pyinstaller/PyInstaller/__main__.pyi | 2 +- .../PyInstaller/building/__init__.pyi | 2 +- .../pyinstaller/PyInstaller/building/api.pyi | 3 +- .../PyInstaller/building/datastruct.pyi | 4 +- .../PyInstaller/depend/analysis.pyi | 2 +- .../PyInstaller/utils/win32/versioninfo.pyi | 3 +- stubs/pyjks/jks/bks.pyi | 4 +- stubs/pyjks/jks/jks.pyi | 4 +- stubs/pyjks/jks/rfc7292.pyi | 3 +- stubs/pyjks/jks/util.pyi | 4 +- stubs/pyperclip/pyperclip/__init__.pyi | 3 +- stubs/pyserial/serial/win32.pyi | 2 +- stubs/pysftp/pysftp/__init__.pyi | 4 +- stubs/pysftp/pysftp/helpers.pyi | 2 +- stubs/python-crontab/crontab.pyi | 4 +- .../dateutil/parser/_parser.pyi | 4 +- .../dateutil/parser/isoparser.pyi | 2 +- .../dateutil/relativedelta.pyi | 4 +- stubs/python-dateutil/dateutil/rrule.pyi | 4 +- .../dateutil/zoneinfo/__init__.pyi | 4 +- stubs/python-jenkins/jenkins/__init__.pyi | 4 +- stubs/python-nmap/nmap/nmap.pyi | 3 +- stubs/python-xlib/Xlib/_typing.pyi | 3 +- stubs/python-xlib/Xlib/display.pyi | 3 +- stubs/python-xlib/Xlib/ext/composite.pyi | 3 +- stubs/python-xlib/Xlib/ext/randr.pyi | 3 +- stubs/python-xlib/Xlib/protocol/event.pyi | 3 +- stubs/python-xlib/Xlib/protocol/rq.pyi | 4 +- stubs/python-xlib/Xlib/protocol/structs.pyi | 2 +- stubs/python-xlib/Xlib/rdb.pyi | 3 +- .../python-xlib/Xlib/support/unix_connect.pyi | 3 +- stubs/pywin32/_win32typing.pyi | 4 +- stubs/pywin32/pythoncom.pyi | 4 +- stubs/pywin32/win32/lib/ntsecuritycon.pyi | 2 +- stubs/pywin32/win32com/client/__init__.pyi | 3 +- stubs/pywin32/win32com/client/dynamic.pyi | 3 +- stubs/pywin32/win32com/server/dispatcher.pyi | 2 +- stubs/pywin32/win32com/universal.pyi | 2 +- stubs/pywin32/win32comext/adsi/adsi.pyi | 2 +- stubs/pywin32/win32comext/propsys/propsys.pyi | 2 +- stubs/pywin32/win32comext/shell/shell.pyi | 2 +- stubs/pyxdg/xdg/MenuEditor.pyi | 3 +- stubs/pyxdg/xdg/Mime.pyi | 4 +- stubs/qrbill/qrbill/bill.pyi | 4 +- stubs/qrcode/qrcode/_types.pyi | 3 +- stubs/qrcode/qrcode/image/base.pyi | 3 +- stubs/qrcode/qrcode/image/pure.pyi | 3 +- stubs/qrcode/qrcode/main.pyi | 3 +- stubs/qrcode/qrcode/util.pyi | 3 +- stubs/regex/regex/_regex_core.pyi | 3 +- stubs/reportlab/reportlab/graphics/shapes.pyi | 4 +- stubs/reportlab/reportlab/lib/colors.pyi | 4 +- stubs/reportlab/reportlab/lib/fonts.pyi | 3 +- stubs/reportlab/reportlab/lib/styles.pyi | 4 +- .../reportlab/reportlab/pdfgen/textobject.pyi | 3 +- .../reportlab/platypus/doctemplate.pyi | 4 +- .../reportlab/platypus/flowables.pyi | 4 +- stubs/reportlab/reportlab/platypus/para.pyi | 4 +- .../reportlab/platypus/tableofcontents.pyi | 4 +- stubs/reportlab/reportlab/platypus/tables.pyi | 4 +- .../requests_oauthlib/oauth1_session.pyi | 3 +- .../requests_oauthlib/oauth2_session.pyi | 3 +- stubs/requests/requests/api.pyi | 2 +- stubs/requests/requests/compat.pyi | 3 +- stubs/requests/requests/models.pyi | 4 +- stubs/requests/requests/sessions.pyi | 4 +- stubs/requests/requests/utils.pyi | 3 +- .../s2clientprotocol/common_pb2.pyi | 7 +- .../s2clientprotocol/data_pb2.pyi | 7 +- .../s2clientprotocol/debug_pb2.pyi | 7 +- .../s2clientprotocol/error_pb2.pyi | 7 +- .../s2clientprotocol/raw_pb2.pyi | 7 +- .../s2clientprotocol/sc2api_pb2.pyi | 7 +- .../s2clientprotocol/score_pb2.pyi | 7 +- .../s2clientprotocol/spatial_pb2.pyi | 7 +- .../s2clientprotocol/ui_pb2.pyi | 7 +- stubs/seaborn/seaborn/_core/groupby.pyi | 3 +- stubs/seaborn/seaborn/_core/properties.pyi | 3 +- stubs/seaborn/seaborn/_core/scales.pyi | 4 +- stubs/seaborn/seaborn/_core/typing.pyi | 3 +- stubs/seaborn/seaborn/_marks/base.pyi | 3 +- stubs/seaborn/seaborn/axisgrid.pyi | 4 +- stubs/seaborn/seaborn/distributions.pyi | 4 +- stubs/seaborn/seaborn/external/kde.pyi | 3 +- stubs/seaborn/seaborn/matrix.pyi | 4 +- stubs/seaborn/seaborn/palettes.pyi | 4 +- stubs/seaborn/seaborn/regression.pyi | 3 +- stubs/seaborn/seaborn/relational.pyi | 3 +- stubs/seaborn/seaborn/utils.pyi | 4 +- .../_distutils/compilers/C/base.pyi | 4 +- .../setuptools/setuptools/_distutils/dist.pyi | 3 +- stubs/setuptools/setuptools/build_meta.pyi | 3 +- .../setuptools/command/editable_wheel.pyi | 4 +- .../setuptools/setuptools/config/setupcfg.pyi | 3 +- stubs/setuptools/setuptools/warnings.pyi | 2 +- stubs/shapely/shapely/_geometry.pyi | 3 +- stubs/shapely/shapely/_typing.pyi | 3 +- stubs/shapely/shapely/affinity.pyi | 3 +- stubs/shapely/shapely/creation.pyi | 3 +- stubs/shapely/shapely/geometry/linestring.pyi | 4 +- stubs/shapely/shapely/geometry/point.pyi | 4 +- stubs/shapely/shapely/geometry/polygon.pyi | 4 +- stubs/shapely/shapely/io.pyi | 3 +- stubs/shapely/shapely/predicates.pyi | 12 +- stubs/shapely/shapely/strtree.pyi | 3 +- stubs/simplejson/simplejson/__init__.pyi | 3 +- stubs/slumber/slumber/serialize.pyi | 3 +- stubs/tabulate/tabulate/__init__.pyi | 4 +- stubs/tensorflow/tensorflow/_aliases.pyi | 3 +- stubs/tensorflow/tensorflow/bitwise.pyi | 3 +- .../compiler/xla/service/hlo_pb2.pyi | 7 +- .../compiler/xla/service/metrics_pb2.pyi | 7 +- .../xla/tsl/protobuf/test_log_pb2.pyi | 7 +- .../tensorflow/compiler/xla/xla_data_pb2.pyi | 7 +- .../tensorflow/compiler/xla/xla_pb2.pyi | 7 +- .../tensorflow/core/framework/api_def_pb2.pyi | 7 +- .../core/framework/dataset_options_pb2.pyi | 7 +- .../core/framework/full_type_pb2.pyi | 7 +- .../framework/graph_transfer_info_pb2.pyi | 7 +- .../tensorflow/core/framework/model_pb2.pyi | 7 +- .../optimized_function_graph_pb2.pyi | 7 +- .../tensorflow/core/framework/summary_pb2.pyi | 7 +- .../tensorflow/core/framework/types_pb2.pyi | 7 +- .../core/framework/variable_pb2.pyi | 7 +- .../tensorflow/core/protobuf/config_pb2.pyi | 7 +- .../protobuf/core_platform_payloads_pb2.pyi | 7 +- .../core/protobuf/data_service_pb2.pyi | 7 +- .../core/protobuf/debug_event_pb2.pyi | 7 +- .../core/protobuf/rewriter_config_pb2.pyi | 7 +- .../core/protobuf/saved_object_graph_pb2.pyi | 7 +- .../tensorflow/core/protobuf/saver_pb2.pyi | 7 +- .../tensorflow/core/protobuf/struct_pb2.pyi | 7 +- .../core/protobuf/tensor_bundle_pb2.pyi | 7 +- .../protobuf/tpu/compilation_result_pb2.pyi | 7 +- .../tpu/optimization_parameters_pb2.pyi | 7 +- .../core/protobuf/tpu/topology_pb2.pyi | 7 +- .../tpu/tpu_embedding_configuration_pb2.pyi | 7 +- .../core/protobuf/verifier_config_pb2.pyi | 7 +- .../tensorflow/core/util/event_pb2.pyi | 7 +- stubs/tensorflow/tensorflow/io/__init__.pyi | 4 +- .../tensorflow/keras/activations.pyi | 3 +- .../tensorflow/tensorflow/keras/callbacks.pyi | 3 +- .../tensorflow/keras/initializers.pyi | 4 +- .../tensorflow/keras/layers/__init__.pyi | 4 +- stubs/tensorflow/tensorflow/keras/losses.pyi | 4 +- stubs/tensorflow/tensorflow/keras/metrics.pyi | 4 +- stubs/tensorflow/tensorflow/keras/models.pyi | 4 +- .../keras/optimizers/legacy/__init__.pyi | 3 +- .../tensorflow/keras/regularizers.pyi | 4 +- stubs/tensorflow/tensorflow/math.pyi | 3 +- .../feature_column/feature_column_v2.pyi | 4 +- stubs/tensorflow/tensorflow/random.pyi | 3 +- .../tensorflow/saved_model/__init__.pyi | 4 +- stubs/tensorflow/tensorflow/sparse.pyi | 2 +- .../tsl/protobuf/coordination_service_pb2.pyi | 7 +- .../tensorflow/tsl/protobuf/dnn_pb2.pyi | 7 +- .../tsl/protobuf/error_codes_pb2.pyi | 7 +- stubs/toml/toml/decoder.pyi | 3 +- stubs/ttkthemes/ttkthemes/_imgops.pyi | 3 +- stubs/uWSGI/uwsgi.pyi | 4 +- stubs/waitress/waitress/adjustments.pyi | 3 +- stubs/waitress/waitress/wasyncore.pyi | 2 +- stubs/watchpoints/watchpoints/watch.pyi | 3 +- .../watchpoints/watchpoints/watch_element.pyi | 3 +- stubs/workalendar/workalendar/asia/israel.pyi | 3 +- stubs/workalendar/workalendar/usa/florida.pyi | 3 +- stubs/wurlitzer/wurlitzer.pyi | 4 +- stubs/xmldiff/xmldiff/main.pyi | 3 +- stubs/xmltodict/xmltodict.pyi | 3 +- stubs/yt-dlp/yt_dlp/YoutubeDL.pyi | 4 +- stubs/yt-dlp/yt_dlp/downloader/__init__.pyi | 3 +- stubs/yt-dlp/yt_dlp/extractor/common.pyi | 4 +- stubs/yt-dlp/yt_dlp/jsinterp.pyi | 3 +- stubs/yt-dlp/yt_dlp/networking/_helper.pyi | 3 +- stubs/yt-dlp/yt_dlp/networking/common.pyi | 4 +- stubs/yt-dlp/yt_dlp/utils/_utils.pyi | 4 +- stubs/yt-dlp/yt_dlp/utils/traversal.pyi | 3 +- stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi | 2 +- tests/mypy_test.py | 3 +- tests/regr_test.py | 2 +- tests/stubtest_stdlib.py | 4 + tests/typecheck_typeshed.py | 2 +- 715 files changed, 5212 insertions(+), 2479 deletions(-) diff --git a/lib/ts_utils/metadata.py b/lib/ts_utils/metadata.py index cd09b7b1d37a..1b700021640c 100644 --- a/lib/ts_utils/metadata.py +++ b/lib/ts_utils/metadata.py @@ -13,7 +13,8 @@ from collections.abc import Mapping from dataclasses import dataclass from pathlib import Path -from typing import Annotated, Any, Final, NamedTuple, TypeGuard, final +from typing import Annotated, Any, Final, NamedTuple, final +from typing_extensions import TypeGuard if sys.version_info >= (3, 11): import tomllib diff --git a/lib/ts_utils/utils.py b/lib/ts_utils/utils.py index fda083bfd4aa..d7dd6ac0fcba 100644 --- a/lib/ts_utils/utils.py +++ b/lib/ts_utils/utils.py @@ -9,7 +9,8 @@ from collections.abc import Iterable, Mapping from pathlib import Path from types import MethodType -from typing import TYPE_CHECKING, Any, Final, NamedTuple, TypeAlias +from typing import TYPE_CHECKING, Any, Final, NamedTuple +from typing_extensions import TypeAlias import pathspec from packaging.requirements import Requirement diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 72cb37a2533f..07b66fa21b4f 100755 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -22,8 +22,8 @@ from dataclasses import dataclass, field from http import HTTPStatus from pathlib import Path -from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypeAlias, TypedDict, TypeVar -from typing_extensions import Self +from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypedDict, TypeVar +from typing_extensions import Self, TypeAlias if sys.version_info >= (3, 11): import tomllib diff --git a/stdlib/__future__.pyi b/stdlib/__future__.pyi index aa445d22bd20..a90cf1eddab7 100644 --- a/stdlib/__future__.pyi +++ b/stdlib/__future__.pyi @@ -1,4 +1,4 @@ -from typing import TypeAlias +from typing_extensions import TypeAlias _VersionInfo: TypeAlias = tuple[int, int, int, str, int] diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index cc2f9d743309..d8d5a1829991 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -122,19 +122,20 @@ if sys.version_info >= (3, 12): if sys.version_info >= (3, 11): from ast import TryStar as TryStar -from ast import ( - Match as Match, - MatchAs as MatchAs, - MatchClass as MatchClass, - MatchMapping as MatchMapping, - MatchOr as MatchOr, - MatchSequence as MatchSequence, - MatchSingleton as MatchSingleton, - MatchStar as MatchStar, - MatchValue as MatchValue, - match_case as match_case, - pattern as pattern, -) +if sys.version_info >= (3, 10): + from ast import ( + Match as Match, + MatchAs as MatchAs, + MatchClass as MatchClass, + MatchMapping as MatchMapping, + MatchOr as MatchOr, + MatchSequence as MatchSequence, + MatchSingleton as MatchSingleton, + MatchStar as MatchStar, + MatchValue as MatchValue, + match_case as match_case, + pattern as pattern, + ) PyCF_ALLOW_TOP_LEVEL_AWAIT: Final = 8192 PyCF_ONLY_AST: Final = 1024 diff --git a/stdlib/_asyncio.pyi b/stdlib/_asyncio.pyi index 76fd3048f654..d663f5d93555 100644 --- a/stdlib/_asyncio.pyi +++ b/stdlib/_asyncio.pyi @@ -3,8 +3,8 @@ from asyncio.events import AbstractEventLoop from collections.abc import Awaitable, Callable, Coroutine, Generator from contextvars import Context from types import FrameType, GenericAlias -from typing import Any, Literal, TextIO, TypeAlias, TypeVar -from typing_extensions import Self, disjoint_base +from typing import Any, Literal, TextIO, TypeVar +from typing_extensions import Self, TypeAlias, disjoint_base _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) diff --git a/stdlib/_bisect.pyi b/stdlib/_bisect.pyi index 9b1d9753b6f3..58488e3d15af 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -1,68 +1,84 @@ +import sys from _typeshed import SupportsLenAndGetItem, SupportsRichComparisonT from collections.abc import Callable, MutableSequence from typing import TypeVar, overload _T = TypeVar("_T") -@overload -def bisect_left( - a: SupportsLenAndGetItem[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, -) -> int: ... -@overload -def bisect_left( - a: SupportsLenAndGetItem[_T], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: Callable[[_T], SupportsRichComparisonT], -) -> int: ... -@overload -def bisect_right( - a: SupportsLenAndGetItem[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, -) -> int: ... -@overload -def bisect_right( - a: SupportsLenAndGetItem[_T], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: Callable[[_T], SupportsRichComparisonT], -) -> int: ... -@overload -def insort_left( - a: MutableSequence[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, -) -> None: ... -@overload -def insort_left( - a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] -) -> None: ... -@overload -def insort_right( - a: MutableSequence[SupportsRichComparisonT], - x: SupportsRichComparisonT, - lo: int = 0, - hi: int | None = None, - *, - key: None = None, -) -> None: ... -@overload -def insort_right( - a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] -) -> None: ... +if sys.version_info >= (3, 10): + @overload + def bisect_left( + a: SupportsLenAndGetItem[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, + ) -> int: ... + @overload + def bisect_left( + a: SupportsLenAndGetItem[_T], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: Callable[[_T], SupportsRichComparisonT], + ) -> int: ... + @overload + def bisect_right( + a: SupportsLenAndGetItem[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, + ) -> int: ... + @overload + def bisect_right( + a: SupportsLenAndGetItem[_T], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: Callable[[_T], SupportsRichComparisonT], + ) -> int: ... + @overload + def insort_left( + a: MutableSequence[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, + ) -> None: ... + @overload + def insort_left( + a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] + ) -> None: ... + @overload + def insort_right( + a: MutableSequence[SupportsRichComparisonT], + x: SupportsRichComparisonT, + lo: int = 0, + hi: int | None = None, + *, + key: None = None, + ) -> None: ... + @overload + def insort_right( + a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT] + ) -> None: ... + +else: + def bisect_left( + a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None + ) -> int: ... + def bisect_right( + a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None + ) -> int: ... + def insort_left( + a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None + ) -> None: ... + def insort_right( + a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None + ) -> None: ... diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 98cffdb0bd38..89f97edb9ba8 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -2,7 +2,8 @@ import codecs import sys from _typeshed import ReadableBuffer from collections.abc import Callable -from typing import Literal, TypeAlias, final, overload, type_check_only +from typing import Literal, final, overload, type_check_only +from typing_extensions import TypeAlias # This type is not exposed; it is defined in unicodeobject.c # At runtime it calls itself builtins.EncodingMap @@ -16,7 +17,10 @@ _Handler: TypeAlias = Callable[[UnicodeError], tuple[str | bytes, int]] _SearchFunction: TypeAlias = Callable[[str], codecs.CodecInfo | None] def register(search_function: _SearchFunction, /) -> None: ... -def unregister(search_function: _SearchFunction, /) -> None: ... + +if sys.version_info >= (3, 10): + def unregister(search_function: _SearchFunction, /) -> None: ... + def register_error(errors: str, handler: _Handler, /) -> None: ... def lookup_error(name: str, /) -> _Handler: ... diff --git a/stdlib/_collections_abc.pyi b/stdlib/_collections_abc.pyi index 62e059da5916..319577c9284b 100644 --- a/stdlib/_collections_abc.pyi +++ b/stdlib/_collections_abc.pyi @@ -75,15 +75,16 @@ class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented __hash__: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 13): def isdisjoint(self, other: Iterable[_KT_co], /) -> bool: ... - - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + if sys.version_info >= (3, 10): + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented def __reversed__(self) -> Iterator[_VT_co]: ... - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + if sys.version_info >= (3, 10): + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented @@ -92,9 +93,9 @@ class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented __hash__: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 13): def isdisjoint(self, other: Iterable[tuple[_KT_co, _VT_co]], /) -> bool: ... - - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + if sys.version_info >= (3, 10): + @property + def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... if sys.version_info >= (3, 12): @runtime_checkable diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index 877b0fb714d6..ea90766afee6 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -2,8 +2,8 @@ import csv import sys from _typeshed import SupportsWrite from collections.abc import Iterable -from typing import Any, Final, Literal, TypeAlias -from typing_extensions import Self, disjoint_base +from typing import Any, Final, Literal, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base __version__: Final[str] @@ -47,31 +47,50 @@ class Dialect: strict: bool = False, ) -> Self: ... -@disjoint_base -class Reader: - @property - def dialect(self) -> Dialect: ... - line_num: int - def __iter__(self) -> Self: ... - def __next__(self) -> list[str]: ... +if sys.version_info >= (3, 10): + # This class calls itself _csv.reader. + @disjoint_base + class Reader: + @property + def dialect(self) -> Dialect: ... + line_num: int + def __iter__(self) -> Self: ... + def __next__(self) -> list[str]: ... -# This class calls itself _csv.writer. -@disjoint_base -class Writer: - @property - def dialect(self) -> Dialect: ... - if sys.version_info >= (3, 13): - def writerow(self, row: Iterable[Any], /) -> Any: ... - def writerows(self, rows: Iterable[Iterable[Any]], /) -> None: ... - else: + # This class calls itself _csv.writer. + @disjoint_base + class Writer: + @property + def dialect(self) -> Dialect: ... + if sys.version_info >= (3, 13): + def writerow(self, row: Iterable[Any], /) -> Any: ... + def writerows(self, rows: Iterable[Iterable[Any]], /) -> None: ... + else: + def writerow(self, row: Iterable[Any]) -> Any: ... + def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... + + # For the return types below. + # These aliases can be removed when typeshed drops support for 3.9. + _reader = Reader + _writer = Writer +else: + # This class is not exposed. It calls itself _csv.reader. + @type_check_only + class _reader: + @property + def dialect(self) -> Dialect: ... + line_num: int + def __iter__(self) -> Self: ... + def __next__(self) -> list[str]: ... + + # This class is not exposed. It calls itself _csv.writer. + @type_check_only + class _writer: + @property + def dialect(self) -> Dialect: ... def writerow(self, row: Iterable[Any]) -> Any: ... def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... -# For the return types below. -# These aliases can be removed when typeshed drops support for 3.9. -_reader = Reader -_writer = Writer - def writer( fileobj: SupportsWrite[str], /, diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index ce0ad45f775c..3c4308628c8c 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -6,8 +6,8 @@ from abc import abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p from types import GenericAlias -from typing import Any, ClassVar, Final, Generic, Literal, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only -from typing_extensions import Self +from typing import Any, ClassVar, Final, Generic, Literal, SupportsIndex, TypeVar, final, overload, type_check_only +from typing_extensions import Self, TypeAlias _T = TypeVar("_T") _CT = TypeVar("_CT", bound=_CData) @@ -223,10 +223,17 @@ else: class _CField(Generic[_CT, _GetT, _SetT]): offset: int size: int - @overload - def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... - @overload - def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ... + if sys.version_info >= (3, 10): + @overload + def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... + @overload + def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ... + else: + @overload + def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ... + @overload + def __get__(self, instance: Any, owner: type[Any] | None, /) -> _GetT: ... + def __set__(self, instance: Any, value: _SetT, /) -> None: ... # This class is not exposed. It calls itself _ctypes.UnionType. diff --git a/stdlib/_curses.pyi b/stdlib/_curses.pyi index ed7dfce6de31..d4e4d48f4e20 100644 --- a/stdlib/_curses.pyi +++ b/stdlib/_curses.pyi @@ -1,7 +1,8 @@ import sys from _typeshed import ReadOnlyBuffer, SupportsRead, SupportsWrite from curses import _ncurses_version -from typing import Any, Final, TypeAlias, final, overload +from typing import Any, Final, final, overload +from typing_extensions import TypeAlias # NOTE: This module is ordinarily only available on Unix, but the windows-curses # package makes it available on Windows as well with the same contents. @@ -95,12 +96,13 @@ BUTTON4_PRESSED: Final[int] BUTTON4_RELEASED: Final[int] BUTTON4_TRIPLE_CLICKED: Final[int] # Darwin ncurses doesn't provide BUTTON5_* constants prior to 3.12.10 and 3.13.3 -if sys.version_info >= (3, 12) or sys.platform != "darwin": - BUTTON5_PRESSED: Final[int] - BUTTON5_RELEASED: Final[int] - BUTTON5_CLICKED: Final[int] - BUTTON5_DOUBLE_CLICKED: Final[int] - BUTTON5_TRIPLE_CLICKED: Final[int] +if sys.version_info >= (3, 10): + if sys.version_info >= (3, 12) or sys.platform != "darwin": + BUTTON5_PRESSED: Final[int] + BUTTON5_RELEASED: Final[int] + BUTTON5_CLICKED: Final[int] + BUTTON5_DOUBLE_CLICKED: Final[int] + BUTTON5_TRIPLE_CLICKED: Final[int] BUTTON_ALT: Final[int] BUTTON_CTRL: Final[int] BUTTON_SHIFT: Final[int] @@ -298,7 +300,9 @@ def getsyx() -> tuple[int, int]: ... def getwin(file: SupportsRead[bytes], /) -> window: ... def halfdelay(tenths: int, /) -> None: ... def has_colors() -> bool: ... -def has_extended_color_support() -> bool: ... + +if sys.version_info >= (3, 10): + def has_extended_color_support() -> bool: ... if sys.version_info >= (3, 14): def assume_default_colors(fg: int, bg: int, /) -> None: ... diff --git a/stdlib/_dbm.pyi b/stdlib/_dbm.pyi index 615b5272a4f5..222c3ffcb246 100644 --- a/stdlib/_dbm.pyi +++ b/stdlib/_dbm.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ReadOnlyBuffer, StrOrBytesPath from types import TracebackType -from typing import Final, TypeAlias, TypeVar, final, overload, type_check_only -from typing_extensions import Self +from typing import Final, TypeVar, final, overload, type_check_only +from typing_extensions import Self, TypeAlias if sys.platform != "win32": _T = TypeVar("_T") diff --git a/stdlib/_decimal.pyi b/stdlib/_decimal.pyi index ab1acdc74a1b..3cfe8944dfaf 100644 --- a/stdlib/_decimal.pyi +++ b/stdlib/_decimal.pyi @@ -19,7 +19,8 @@ from decimal import ( Underflow as Underflow, _ContextManager, ) -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias _TrapType: TypeAlias = type[DecimalException] diff --git a/stdlib/_frozen_importlib.pyi b/stdlib/_frozen_importlib.pyi index 172da4522d8f..58db64a016f3 100644 --- a/stdlib/_frozen_importlib.pyi +++ b/stdlib/_frozen_importlib.pyi @@ -74,11 +74,16 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(module: types.ModuleType) -> str: ... - - @staticmethod - def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... - @staticmethod - def exec_module(module: types.ModuleType) -> None: ... + if sys.version_info >= (3, 10): + @staticmethod + def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... + @staticmethod + def exec_module(module: types.ModuleType) -> None: ... + else: + @classmethod + def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ... + @classmethod + def exec_module(cls, module: types.ModuleType) -> None: ... class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder @@ -108,8 +113,12 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): "The module spec is now used by the import machinery to generate a module repr." ) def module_repr(m: types.ModuleType) -> str: ... + if sys.version_info >= (3, 10): + @staticmethod + def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... + else: + @classmethod + def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ... - @staticmethod - def create_module(spec: ModuleSpec) -> types.ModuleType | None: ... @staticmethod def exec_module(module: types.ModuleType) -> None: ... diff --git a/stdlib/_frozen_importlib_external.pyi b/stdlib/_frozen_importlib_external.pyi index f5b1045a11f0..660cee6e84ec 100644 --- a/stdlib/_frozen_importlib_external.pyi +++ b/stdlib/_frozen_importlib_external.pyi @@ -1,16 +1,19 @@ import _ast +import _io import importlib.abc import importlib.machinery -import importlib.readers import sys import types from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath from _typeshed.importlib import LoaderProtocol -from collections.abc import Callable, Iterable, Mapping, MutableSequence, Sequence +from collections.abc import Callable, Iterable, Iterator, Mapping, MutableSequence, Sequence from importlib.machinery import ModuleSpec from importlib.metadata import DistributionFinder, PathDistribution from typing import Any, Final, Literal, overload -from typing_extensions import deprecated +from typing_extensions import Self, deprecated + +if sys.version_info >= (3, 10): + import importlib.readers if sys.platform == "win32": path_separators: Literal["\\/"] @@ -55,10 +58,19 @@ class WindowsRegistryFinder(importlib.abc.MetaPathFinder): ) -> ModuleSpec | None: ... class PathFinder(importlib.abc.MetaPathFinder): - @staticmethod - def invalidate_caches() -> None: ... - @staticmethod - def find_distributions(context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... + if sys.version_info >= (3, 10): + @staticmethod + def invalidate_caches() -> None: ... + else: + @classmethod + def invalidate_caches(cls) -> None: ... + if sys.version_info >= (3, 10): + @staticmethod + def find_distributions(context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... + else: + @classmethod + def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... + @classmethod def find_spec( cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None @@ -105,7 +117,14 @@ class FileLoader: def get_data(self, path: str) -> bytes: ... def get_filename(self, fullname: str | None = None) -> str: ... def load_module(self, fullname: str | None = None) -> types.ModuleType: ... - def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ... + if sys.version_info >= (3, 10): + def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ... + else: + def get_resource_reader(self, name: str | None = None) -> Self | None: ... + def open_resource(self, resource: str) -> _io.FileIO: ... + def resource_path(self, resource: str) -> str: ... + def is_resource(self, name: str) -> bool: ... + def contents(self) -> Iterator[str]: ... class SourceFileLoader(importlib.abc.FileLoader, FileLoader, importlib.abc.SourceLoader, SourceLoader): # type: ignore[misc] # incompatible method arguments in base classes def set_data(self, path: str, data: ReadableBuffer, *, _mode: int = 0o666) -> None: ... @@ -164,15 +183,24 @@ else: def get_code(self, fullname: str) -> types.CodeType: ... def create_module(self, spec: ModuleSpec) -> None: ... def exec_module(self, module: types.ModuleType) -> None: ... - @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.") - def load_module(self, fullname: str) -> types.ModuleType: ... - @staticmethod - @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. " - "The module spec is now used by the import machinery to generate a module repr." - ) - def module_repr(module: types.ModuleType) -> str: ... - def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.") + def load_module(self, fullname: str) -> types.ModuleType: ... + @staticmethod + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." + ) + def module_repr(module: types.ModuleType) -> str: ... + def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ... + else: + def load_module(self, fullname: str) -> types.ModuleType: ... + @classmethod + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." + ) + def module_repr(cls, module: types.ModuleType) -> str: ... if sys.version_info >= (3, 13): class AppleFrameworkLoader(ExtensionFileLoader, importlib.abc.ExecutionLoader): ... diff --git a/stdlib/_gdbm.pyi b/stdlib/_gdbm.pyi index 98c18f8bf4f0..2cb5fba29dfa 100644 --- a/stdlib/_gdbm.pyi +++ b/stdlib/_gdbm.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ReadOnlyBuffer, StrOrBytesPath from types import TracebackType -from typing import TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias if sys.platform != "win32": _T = TypeVar("_T") diff --git a/stdlib/_hashlib.pyi b/stdlib/_hashlib.pyi index e9e5ec8a2f8a..03c1eef3be3f 100644 --- a/stdlib/_hashlib.pyi +++ b/stdlib/_hashlib.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import ReadableBuffer from collections.abc import Callable from types import ModuleType -from typing import AnyStr, Protocol, TypeAlias, final, overload, type_check_only -from typing_extensions import Self, disjoint_base +from typing import AnyStr, Protocol, final, overload, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base _DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType | None @@ -35,7 +35,8 @@ class HASH: def hexdigest(self) -> str: ... def update(self, obj: ReadableBuffer, /) -> None: ... -class UnsupportedDigestmodError(ValueError): ... +if sys.version_info >= (3, 10): + class UnsupportedDigestmodError(ValueError): ... class HASHXOF(HASH): def digest(self, length: int) -> bytes: ... # type: ignore[override] diff --git a/stdlib/_interpqueues.pyi b/stdlib/_interpqueues.pyi index 5586b9bd7b20..c9323b106f3d 100644 --- a/stdlib/_interpqueues.pyi +++ b/stdlib/_interpqueues.pyi @@ -1,4 +1,5 @@ -from typing import Any, Literal, SupportsIndex, TypeAlias +from typing import Any, Literal, SupportsIndex +from typing_extensions import TypeAlias _UnboundOp: TypeAlias = Literal[1, 2, 3] diff --git a/stdlib/_interpreters.pyi b/stdlib/_interpreters.pyi index c4cbeccaa571..8e097efad618 100644 --- a/stdlib/_interpreters.pyi +++ b/stdlib/_interpreters.pyi @@ -1,7 +1,7 @@ import types from collections.abc import Callable -from typing import Any, Final, Literal, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import disjoint_base +from typing import Any, Final, Literal, SupportsIndex, TypeVar, overload +from typing_extensions import TypeAlias, disjoint_base _R = TypeVar("_R") diff --git a/stdlib/_io.pyi b/stdlib/_io.pyi index a18c82ccf26f..2d2a60e4dddf 100644 --- a/stdlib/_io.pyi +++ b/stdlib/_io.pyi @@ -294,7 +294,8 @@ class IncrementalNewlineDecoder: def reset(self) -> None: ... def setstate(self, state: tuple[bytes, int], /) -> None: ... -@overload -def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ... -@overload -def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T: ... +if sys.version_info >= (3, 10): + @overload + def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ... + @overload + def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T: ... diff --git a/stdlib/_lsprof.pyi b/stdlib/_lsprof.pyi index d04c2a74ee07..4f6d98b8ffb6 100644 --- a/stdlib/_lsprof.pyi +++ b/stdlib/_lsprof.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import structseq from collections.abc import Callable from types import CodeType @@ -16,7 +17,8 @@ class Profiler: @final class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, float, list[profiler_subentry]]): - __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls") + if sys.version_info >= (3, 10): + __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls") code: CodeType | str callcount: int reccallcount: int @@ -26,7 +28,8 @@ class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, floa @final class profiler_subentry(structseq[Any], tuple[CodeType | str, int, int, float, float]): - __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime") + if sys.version_info >= (3, 10): + __match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime") code: CodeType | str callcount: int reccallcount: int diff --git a/stdlib/_lzma.pyi b/stdlib/_lzma.pyi index 83cd8fd756b9..b38dce9faded 100644 --- a/stdlib/_lzma.pyi +++ b/stdlib/_lzma.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ReadableBuffer from collections.abc import Mapping, Sequence -from typing import Any, Final, TypeAlias, final -from typing_extensions import Self +from typing import Any, Final, final +from typing_extensions import Self, TypeAlias _FilterChain: TypeAlias = Sequence[Mapping[str, Any]] diff --git a/stdlib/_markupbase.pyi b/stdlib/_markupbase.pyi index acc3ccac7188..597bd09b700b 100644 --- a/stdlib/_markupbase.pyi +++ b/stdlib/_markupbase.pyi @@ -1,3 +1,6 @@ +import sys +from typing import Any + class ParserBase: def reset(self) -> None: ... def getpos(self) -> tuple[int, int]: ... @@ -6,5 +9,8 @@ class ParserBase: def parse_declaration(self, i: int) -> int: ... # undocumented def parse_marked_section(self, i: int, report: bool = True) -> int: ... # undocumented def updatepos(self, i: int, j: int) -> int: ... # undocumented + if sys.version_info < (3, 10): + # Removed from ParserBase: https://bugs.python.org/issue31844 + def error(self, message: str) -> Any: ... # undocumented lineno: int # undocumented offset: int # undocumented diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index 676f1128349e..e1ef5c4bf067 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import SupportsGetItem from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller -from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, TypeIs +from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, TypeAlias, TypeIs _R = TypeVar("_R") _T = TypeVar("_T") diff --git a/stdlib/_pickle.pyi b/stdlib/_pickle.pyi index 40f979c2d654..544f787172d6 100644 --- a/stdlib/_pickle.pyi +++ b/stdlib/_pickle.pyi @@ -1,8 +1,8 @@ from _typeshed import ReadableBuffer, SupportsWrite from collections.abc import Callable, Iterable, Iterator, Mapping from pickle import PickleBuffer as PickleBuffer -from typing import Any, Protocol, TypeAlias, type_check_only -from typing_extensions import disjoint_base +from typing import Any, Protocol, type_check_only +from typing_extensions import TypeAlias, disjoint_base @type_check_only class _ReadableFileobj(Protocol): diff --git a/stdlib/_random.pyi b/stdlib/_random.pyi index e333b00d1084..ac00fdfb7272 100644 --- a/stdlib/_random.pyi +++ b/stdlib/_random.pyi @@ -1,12 +1,16 @@ -from typing import TypeAlias -from typing_extensions import disjoint_base +import sys +from typing_extensions import Self, TypeAlias, disjoint_base # Actually Tuple[(int,) * 625] _State: TypeAlias = tuple[int, ...] @disjoint_base class Random: - def __init__(self, seed: object = ..., /) -> None: ... + if sys.version_info >= (3, 10): + def __init__(self, seed: object = ..., /) -> None: ... + else: + def __new__(self, seed: object = ..., /) -> Self: ... + def seed(self, n: object = None, /) -> None: ... def getstate(self) -> _State: ... def setstate(self, state: _State, /) -> None: ... diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 638a98fe2728..372b35f22f17 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Iterable from socket import error as error, gaierror as gaierror, herror as herror, timeout as timeout -from typing import Any, Final, SupportsIndex, TypeAlias, overload -from typing_extensions import CapsuleType, disjoint_base +from typing import Any, Final, SupportsIndex, overload +from typing_extensions import CapsuleType, TypeAlias, disjoint_base _CMSG: TypeAlias = tuple[int, int, bytes] _CMSGArg: TypeAlias = tuple[int, int, ReadableBuffer] @@ -218,7 +218,8 @@ IP_MULTICAST_TTL: Final[int] IP_OPTIONS: Final[int] if sys.platform != "linux": IP_RECVDSTADDR: Final[int] -IP_RECVTOS: Final[int] +if sys.version_info >= (3, 10): + IP_RECVTOS: Final[int] IP_TOS: Final[int] IP_TTL: Final[int] if sys.platform != "win32": diff --git a/stdlib/_sqlite3.pyi b/stdlib/_sqlite3.pyi index d9e7835b8e38..50006dcf4032 100644 --- a/stdlib/_sqlite3.pyi +++ b/stdlib/_sqlite3.pyi @@ -18,7 +18,8 @@ from sqlite3 import ( Warning as Warning, _IsolationLevel, ) -from typing import Any, Final, Literal, TypeAlias, TypeVar, overload +from typing import Any, Final, Literal, TypeVar, overload +from typing_extensions import TypeAlias if sys.version_info >= (3, 11): from sqlite3 import Blob as Blob @@ -300,5 +301,13 @@ if sys.version_info < (3, 12): # takes a pos-or-keyword argument because there is a C wrapper def enable_shared_cache(do_enable: int) -> None: ... -def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ... -def register_converter(typename: str, converter: _Converter, /) -> None: ... +if sys.version_info >= (3, 10): + def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ... + def register_converter(typename: str, converter: _Converter, /) -> None: ... + +else: + def register_adapter(type: type[_T], caster: _Adapter[_T], /) -> None: ... + def register_converter(name: str, converter: _Converter, /) -> None: ... + +if sys.version_info < (3, 10): + OptimizedUnicode = str diff --git a/stdlib/_ssl.pyi b/stdlib/_ssl.pyi index 05ca94c107f0..73a43f29c8c5 100644 --- a/stdlib/_ssl.pyi +++ b/stdlib/_ssl.pyi @@ -12,8 +12,8 @@ from ssl import ( SSLWantWriteError as SSLWantWriteError, SSLZeroReturnError as SSLZeroReturnError, ) -from typing import Any, ClassVar, Final, Literal, TypeAlias, TypedDict, final, overload, type_check_only -from typing_extensions import NotRequired, Self, deprecated, disjoint_base +from typing import Any, ClassVar, Final, Literal, TypedDict, final, overload, type_check_only +from typing_extensions import NotRequired, Self, TypeAlias, deprecated, disjoint_base _PasswordType: TypeAlias = Callable[[], str | bytes | bytearray] | str | bytes | bytearray _PCTRTT: TypeAlias = tuple[tuple[str, str], ...] @@ -54,6 +54,9 @@ if sys.version_info < (3, 12): @deprecated("Deprecated since Python 3.6; removed in Python 3.12. Use `ssl.RAND_bytes()` instead.") def RAND_pseudo_bytes(n: int, /) -> tuple[bytes, bool]: ... +if sys.version_info < (3, 10): + def RAND_egd(path: str) -> None: ... + def RAND_status() -> bool: ... def get_default_verify_paths() -> tuple[str, str, str, str]: ... @@ -74,7 +77,8 @@ class _SSLContext: options: int post_handshake_auth: bool protocol: int - security_level: int + if sys.version_info >= (3, 10): + security_level: int sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None verify_flags: int verify_mode: int @@ -140,17 +144,18 @@ class SSLSession: # # You can find a _ssl._SSLSocket object as the _sslobj attribute of a ssl.SSLSocket object -@final -class Certificate: - def get_info(self) -> _CertInfo: ... - @overload - def public_bytes(self) -> str: ... - @overload - def public_bytes(self, format: Literal[1] = 1, /) -> str: ... # ENCODING_PEM - @overload - def public_bytes(self, format: Literal[2], /) -> bytes: ... # ENCODING_DER - @overload - def public_bytes(self, format: int, /) -> str | bytes: ... +if sys.version_info >= (3, 10): + @final + class Certificate: + def get_info(self) -> _CertInfo: ... + @overload + def public_bytes(self) -> str: ... + @overload + def public_bytes(self, format: Literal[1] = 1, /) -> str: ... # ENCODING_PEM + @overload + def public_bytes(self, format: Literal[2], /) -> bytes: ... # ENCODING_DER + @overload + def public_bytes(self, format: int, /) -> str | bytes: ... if sys.version_info < (3, 12): err_codes_to_names: dict[tuple[int, int], str] @@ -181,8 +186,9 @@ VERIFY_CRL_CHECK_LEAF: Final = 0x4 VERIFY_CRL_CHECK_CHAIN: Final = 0x8 VERIFY_X509_STRICT: Final = 0x20 VERIFY_X509_TRUSTED_FIRST: Final = 0x8000 -VERIFY_ALLOW_PROXY_CERTS: Final = 0x40 -VERIFY_X509_PARTIAL_CHAIN: Final = 0x80000 +if sys.version_info >= (3, 10): + VERIFY_ALLOW_PROXY_CERTS: Final = 0x40 + VERIFY_X509_PARTIAL_CHAIN: Final = 0x80000 # alert descriptions ALERT_DESCRIPTION_CLOSE_NOTIFY: Final = 0 @@ -251,8 +257,10 @@ HOSTFLAG_NO_PARTIAL_WILDCARDS: Final = 0x4 HOSTFLAG_MULTI_LABEL_WILDCARDS: Final = 0x8 HOSTFLAG_SINGLE_LABEL_SUBDOMAINS: Final = 0x10 -ENCODING_PEM: Final = 1 -ENCODING_DER: Final = 2 +if sys.version_info >= (3, 10): + # certificate file types + ENCODING_PEM: Final = 1 + ENCODING_DER: Final = 2 # protocol versions PROTO_MINIMUM_SUPPORTED: Final = -2 diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 7a476a701c99..6969ae48cae7 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -71,7 +71,13 @@ def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwa def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ... @overload def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... -def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ... + +if sys.version_info >= (3, 10): + def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ... + +else: + def interrupt_main() -> None: ... + def exit() -> NoReturn: ... def exit_thread() -> NoReturn: ... # Obsolete synonym for exit() def allocate_lock() -> LockType: ... @@ -84,7 +90,8 @@ TIMEOUT_MAX: Final[float] def get_native_id() -> int: ... # only available on some platforms @final class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | None, TracebackType | None, Thread | None]): - __match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread") + if sys.version_info >= (3, 10): + __match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread") @property def exc_type(self) -> type[BaseException]: ... diff --git a/stdlib/_threading_local.pyi b/stdlib/_threading_local.pyi index 7d4e61c6f2ec..5f6acaf840aa 100644 --- a/stdlib/_threading_local.pyi +++ b/stdlib/_threading_local.pyi @@ -1,6 +1,6 @@ from threading import RLock -from typing import Any, TypeAlias -from typing_extensions import Self +from typing import Any +from typing_extensions import Self, TypeAlias from weakref import ReferenceType __all__ = ["local"] diff --git a/stdlib/_tkinter.pyi b/stdlib/_tkinter.pyi index 318c35b352c5..5e46668e08b1 100644 --- a/stdlib/_tkinter.pyi +++ b/stdlib/_tkinter.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import FileDescriptorLike, Incomplete from collections.abc import Callable -from typing import Any, ClassVar, Final, Literal, TypeAlias, final, overload -from typing_extensions import deprecated +from typing import Any, ClassVar, Final, Literal, final, overload +from typing_extensions import TypeAlias, deprecated # _tkinter is meant to be only used internally by tkinter, but some tkinter # functions e.g. return _tkinter.Tcl_Obj objects. Tcl_Obj represents a Tcl diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 8a22051b238c..89e93ab02706 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -18,11 +18,11 @@ from typing import ( SupportsFloat, SupportsIndex, SupportsInt, - TypeAlias, TypeVar, + final, overload, ) -from typing_extensions import Buffer, LiteralString, Self as _Self +from typing_extensions import Buffer, LiteralString, Self as _Self, TypeAlias _KT = TypeVar("_KT") _KT_co = TypeVar("_KT_co", covariant=True) @@ -318,7 +318,13 @@ ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType] OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None] # stable -from types import NoneType as NoneType +if sys.version_info >= (3, 10): + from types import NoneType as NoneType +else: + # Used by type checkers for checks involving None (does not exist at runtime) + @final + class NoneType: + def __bool__(self) -> Literal[False]: ... # This is an internal CPython type that is like, but subtly different from, a NamedTuple # Subclasses of this type are found in multiple modules. diff --git a/stdlib/_typeshed/dbapi.pyi b/stdlib/_typeshed/dbapi.pyi index e08a84553dfc..d54fbee57042 100644 --- a/stdlib/_typeshed/dbapi.pyi +++ b/stdlib/_typeshed/dbapi.pyi @@ -2,7 +2,8 @@ # https://www.python.org/dev/peps/pep-0249/ from collections.abc import Mapping, Sequence -from typing import Any, Protocol, TypeAlias +from typing import Any, Protocol +from typing_extensions import TypeAlias DBAPITypeCode: TypeAlias = Any | None # Strictly speaking, this should be a Sequence, but the type system does diff --git a/stdlib/_typeshed/wsgi.pyi b/stdlib/_typeshed/wsgi.pyi index 980a24122252..63f204eb889b 100644 --- a/stdlib/_typeshed/wsgi.pyi +++ b/stdlib/_typeshed/wsgi.pyi @@ -7,7 +7,8 @@ import sys from _typeshed import OptExcInfo from collections.abc import Callable, Iterable, Iterator -from typing import Any, Protocol, TypeAlias +from typing import Any, Protocol +from typing_extensions import TypeAlias class _Readable(Protocol): def read(self, size: int = ..., /) -> bytes: ... diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index 253f6af447f6..42efce9bed70 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -127,21 +127,22 @@ if sys.platform == "win32": WAIT_OBJECT_0: Final = 0 WAIT_TIMEOUT: Final = 258 - LOCALE_NAME_INVARIANT: Final[str] - LOCALE_NAME_MAX_LENGTH: Final[int] - LOCALE_NAME_SYSTEM_DEFAULT: Final[str] - LOCALE_NAME_USER_DEFAULT: Final[str | None] + if sys.version_info >= (3, 10): + LOCALE_NAME_INVARIANT: Final[str] + LOCALE_NAME_MAX_LENGTH: Final[int] + LOCALE_NAME_SYSTEM_DEFAULT: Final[str] + LOCALE_NAME_USER_DEFAULT: Final[str | None] - LCMAP_FULLWIDTH: Final[int] - LCMAP_HALFWIDTH: Final[int] - LCMAP_HIRAGANA: Final[int] - LCMAP_KATAKANA: Final[int] - LCMAP_LINGUISTIC_CASING: Final[int] - LCMAP_LOWERCASE: Final[int] - LCMAP_SIMPLIFIED_CHINESE: Final[int] - LCMAP_TITLECASE: Final[int] - LCMAP_TRADITIONAL_CHINESE: Final[int] - LCMAP_UPPERCASE: Final[int] + LCMAP_FULLWIDTH: Final[int] + LCMAP_HALFWIDTH: Final[int] + LCMAP_HIRAGANA: Final[int] + LCMAP_KATAKANA: Final[int] + LCMAP_LINGUISTIC_CASING: Final[int] + LCMAP_LOWERCASE: Final[int] + LCMAP_SIMPLIFIED_CHINESE: Final[int] + LCMAP_TITLECASE: Final[int] + LCMAP_TRADITIONAL_CHINESE: Final[int] + LCMAP_UPPERCASE: Final[int] if sys.version_info >= (3, 12): COPYFILE2_CALLBACK_CHUNK_STARTED: Final = 1 @@ -242,8 +243,10 @@ if sys.platform == "win32": ) -> int: ... def OpenProcess(desired_access: int, inherit_handle: bool, process_id: int, /) -> int: ... def PeekNamedPipe(handle: int, size: int = 0, /) -> tuple[int, int] | tuple[bytes, int, int]: ... - def LCMapStringEx(locale: str, flags: int, src: str) -> str: ... - def UnmapViewOfFile(address: int, /) -> None: ... + if sys.version_info >= (3, 10): + def LCMapStringEx(locale: str, flags: int, src: str) -> str: ... + def UnmapViewOfFile(address: int, /) -> None: ... + @overload def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> tuple[Overlapped, int]: ... @overload diff --git a/stdlib/_zstd.pyi b/stdlib/_zstd.pyi index b4e3d7aaaa09..e40c7d12b6e7 100644 --- a/stdlib/_zstd.pyi +++ b/stdlib/_zstd.pyi @@ -1,8 +1,8 @@ from _typeshed import ReadableBuffer from collections.abc import Mapping from compression.zstd import CompressionParameter, DecompressionParameter -from typing import Final, Literal, TypeAlias, final -from typing_extensions import Self +from typing import Final, Literal, final +from typing_extensions import Self, TypeAlias ZSTD_CLEVEL_DEFAULT: Final = 3 ZSTD_DStreamOutSize: Final = 131072 diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 4fc69257eebd..c8cd549e30ec 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -2,8 +2,8 @@ import _typeshed import sys from _typeshed import SupportsWrite from collections.abc import Callable -from typing import Any, Concatenate, Literal, TypeVar -from typing_extensions import ParamSpec, deprecated +from typing import Any, Literal, TypeVar +from typing_extensions import Concatenate, ParamSpec, deprecated _T = TypeVar("_T") _R_co = TypeVar("_R_co", covariant=True) @@ -46,4 +46,6 @@ class ABC(metaclass=ABCMeta): __slots__ = () def get_cache_token() -> object: ... -def update_abstractmethods(cls: type[_T]) -> type[_T]: ... + +if sys.version_info >= (3, 10): + def update_abstractmethods(cls: type[_T]) -> type[_T]: ... diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index afb9029f710e..bfe12c6af2b0 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,6 +1,6 @@ from types import TracebackType -from typing import IO, Any, Literal, NamedTuple, TypeAlias, overload -from typing_extensions import Self +from typing import IO, Any, Literal, NamedTuple, overload +from typing_extensions import Self, TypeAlias __all__ = ["Error", "open"] diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index bbc65a7bb66a..066896603914 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import SupportsWrite, sentinel from collections.abc import Callable, Generator, Iterable, Sequence from re import Pattern -from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated __all__ = [ "ArgumentParser", diff --git a/stdlib/array.pyi b/stdlib/array.pyi index fc277c22f3f9..eb679dd50f72 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Iterable, MutableSequence from types import GenericAlias -from typing import Any, ClassVar, Literal, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import Self, deprecated, disjoint_base +from typing import Any, ClassVar, Literal, SupportsIndex, TypeVar, overload +from typing_extensions import Self, TypeAlias, deprecated, disjoint_base _IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] _FloatTypeCode: TypeAlias = Literal["f", "d"] @@ -61,7 +61,11 @@ class array(MutableSequence[_T]): def fromfile(self, f: SupportsRead[bytes], n: int, /) -> None: ... def fromlist(self, list: list[_T], /) -> None: ... def fromunicode(self, ustr: str, /) -> None: ... - def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int: ... # type: ignore[override] + if sys.version_info >= (3, 10): + def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int: ... + else: + def index(self, v: _T, /) -> int: ... # type: ignore[override] + def insert(self, i: int, v: _T, /) -> None: ... def pop(self, i: int = -1, /) -> _T: ... def remove(self, v: _T, /) -> None: ... diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 046e077094a9..e66e609ee664 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -44,14 +44,16 @@ if sys.version_info >= (3, 12): else: class AST: - __match_args__ = () + if sys.version_info >= (3, 10): + __match_args__ = () _attributes: ClassVar[tuple[str, ...]] _fields: ClassVar[tuple[str, ...]] class mod(AST): ... class Module(mod): - __match_args__ = ("body", "type_ignores") + if sys.version_info >= (3, 10): + __match_args__ = ("body", "type_ignores") body: list[stmt] type_ignores: list[TypeIgnore] if sys.version_info >= (3, 13): @@ -63,7 +65,8 @@ class Module(mod): def __replace__(self, *, body: list[stmt] = ..., type_ignores: list[TypeIgnore] = ...) -> Self: ... class Interactive(mod): - __match_args__ = ("body",) + if sys.version_info >= (3, 10): + __match_args__ = ("body",) body: list[stmt] if sys.version_info >= (3, 13): def __init__(self, body: list[stmt] = ...) -> None: ... @@ -74,7 +77,8 @@ class Interactive(mod): def __replace__(self, *, body: list[stmt] = ...) -> Self: ... class Expression(mod): - __match_args__ = ("body",) + if sys.version_info >= (3, 10): + __match_args__ = ("body",) body: expr def __init__(self, body: expr) -> None: ... @@ -82,7 +86,8 @@ class Expression(mod): def __replace__(self, *, body: expr = ...) -> Self: ... class FunctionType(mod): - __match_args__ = ("argtypes", "returns") + if sys.version_info >= (3, 10): + __match_args__ = ("argtypes", "returns") argtypes: list[expr] returns: expr if sys.version_info >= (3, 13): @@ -109,7 +114,7 @@ class stmt(AST): class FunctionDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params") - else: + elif sys.version_info >= (3, 10): __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") name: str args: arguments @@ -186,7 +191,7 @@ class FunctionDef(stmt): class AsyncFunctionDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params") - else: + elif sys.version_info >= (3, 10): __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") name: str args: arguments @@ -263,7 +268,7 @@ class AsyncFunctionDef(stmt): class ClassDef(stmt): if sys.version_info >= (3, 12): __match_args__ = ("name", "bases", "keywords", "body", "decorator_list", "type_params") - else: + elif sys.version_info >= (3, 10): __match_args__ = ("name", "bases", "keywords", "body", "decorator_list") name: str bases: list[expr] @@ -319,7 +324,8 @@ class ClassDef(stmt): ) -> Self: ... class Return(stmt): - __match_args__ = ("value",) + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr | None def __init__(self, value: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -327,7 +333,8 @@ class Return(stmt): def __replace__(self, *, value: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Delete(stmt): - __match_args__ = ("targets",) + if sys.version_info >= (3, 10): + __match_args__ = ("targets",) targets: list[expr] if sys.version_info >= (3, 13): def __init__(self, targets: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -338,7 +345,8 @@ class Delete(stmt): def __replace__(self, *, targets: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Assign(stmt): - __match_args__ = ("targets", "value", "type_comment") + if sys.version_info >= (3, 10): + __match_args__ = ("targets", "value", "type_comment") targets: list[expr] value: expr type_comment: str | None @@ -392,7 +400,8 @@ if sys.version_info >= (3, 12): ) -> Self: ... class AugAssign(stmt): - __match_args__ = ("target", "op", "value") + if sys.version_info >= (3, 10): + __match_args__ = ("target", "op", "value") target: Name | Attribute | Subscript op: operator value: expr @@ -411,7 +420,8 @@ class AugAssign(stmt): ) -> Self: ... class AnnAssign(stmt): - __match_args__ = ("target", "annotation", "value", "simple") + if sys.version_info >= (3, 10): + __match_args__ = ("target", "annotation", "value", "simple") target: Name | Attribute | Subscript annotation: expr value: expr | None @@ -448,7 +458,8 @@ class AnnAssign(stmt): ) -> Self: ... class For(stmt): - __match_args__ = ("target", "iter", "body", "orelse", "type_comment") + if sys.version_info >= (3, 10): + __match_args__ = ("target", "iter", "body", "orelse", "type_comment") target: expr iter: expr body: list[stmt] @@ -488,7 +499,8 @@ class For(stmt): ) -> Self: ... class AsyncFor(stmt): - __match_args__ = ("target", "iter", "body", "orelse", "type_comment") + if sys.version_info >= (3, 10): + __match_args__ = ("target", "iter", "body", "orelse", "type_comment") target: expr iter: expr body: list[stmt] @@ -528,7 +540,8 @@ class AsyncFor(stmt): ) -> Self: ... class While(stmt): - __match_args__ = ("test", "body", "orelse") + if sys.version_info >= (3, 10): + __match_args__ = ("test", "body", "orelse") test: expr body: list[stmt] orelse: list[stmt] @@ -545,7 +558,8 @@ class While(stmt): ) -> Self: ... class If(stmt): - __match_args__ = ("test", "body", "orelse") + if sys.version_info >= (3, 10): + __match_args__ = ("test", "body", "orelse") test: expr body: list[stmt] orelse: list[stmt] @@ -562,7 +576,8 @@ class If(stmt): ) -> Self: ... class With(stmt): - __match_args__ = ("items", "body", "type_comment") + if sys.version_info >= (3, 10): + __match_args__ = ("items", "body", "type_comment") items: list[withitem] body: list[stmt] type_comment: str | None @@ -590,7 +605,8 @@ class With(stmt): ) -> Self: ... class AsyncWith(stmt): - __match_args__ = ("items", "body", "type_comment") + if sys.version_info >= (3, 10): + __match_args__ = ("items", "body", "type_comment") items: list[withitem] body: list[stmt] type_comment: str | None @@ -618,7 +634,8 @@ class AsyncWith(stmt): ) -> Self: ... class Raise(stmt): - __match_args__ = ("exc", "cause") + if sys.version_info >= (3, 10): + __match_args__ = ("exc", "cause") exc: expr | None cause: expr | None def __init__(self, exc: expr | None = None, cause: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -627,7 +644,8 @@ class Raise(stmt): def __replace__(self, *, exc: expr | None = ..., cause: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Try(stmt): - __match_args__ = ("body", "handlers", "orelse", "finalbody") + if sys.version_info >= (3, 10): + __match_args__ = ("body", "handlers", "orelse", "finalbody") body: list[stmt] handlers: list[ExceptHandler] orelse: list[stmt] @@ -700,7 +718,8 @@ if sys.version_info >= (3, 11): ) -> Self: ... class Assert(stmt): - __match_args__ = ("test", "msg") + if sys.version_info >= (3, 10): + __match_args__ = ("test", "msg") test: expr msg: expr | None def __init__(self, test: expr, msg: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -709,7 +728,8 @@ class Assert(stmt): def __replace__(self, *, test: expr = ..., msg: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Import(stmt): - __match_args__ = ("names",) + if sys.version_info >= (3, 10): + __match_args__ = ("names",) names: list[alias] if sys.version_info >= (3, 13): def __init__(self, names: list[alias] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -720,7 +740,8 @@ class Import(stmt): def __replace__(self, *, names: list[alias] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class ImportFrom(stmt): - __match_args__ = ("module", "names", "level") + if sys.version_info >= (3, 10): + __match_args__ = ("module", "names", "level") module: str | None names: list[alias] level: int @@ -745,7 +766,8 @@ class ImportFrom(stmt): ) -> Self: ... class Global(stmt): - __match_args__ = ("names",) + if sys.version_info >= (3, 10): + __match_args__ = ("names",) names: list[str] if sys.version_info >= (3, 13): def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -756,7 +778,8 @@ class Global(stmt): def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Nonlocal(stmt): - __match_args__ = ("names",) + if sys.version_info >= (3, 10): + __match_args__ = ("names",) names: list[str] if sys.version_info >= (3, 13): def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -767,7 +790,8 @@ class Nonlocal(stmt): def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Expr(stmt): - __match_args__ = ("value",) + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -789,7 +813,8 @@ class expr(AST): def __replace__(self, **kwargs: Unpack[_Attributes]) -> Self: ... class BoolOp(expr): - __match_args__ = ("op", "values") + if sys.version_info >= (3, 10): + __match_args__ = ("op", "values") op: boolop values: list[expr] if sys.version_info >= (3, 13): @@ -801,7 +826,8 @@ class BoolOp(expr): def __replace__(self, *, op: boolop = ..., values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class NamedExpr(expr): - __match_args__ = ("target", "value") + if sys.version_info >= (3, 10): + __match_args__ = ("target", "value") target: Name value: expr def __init__(self, target: Name, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -810,7 +836,8 @@ class NamedExpr(expr): def __replace__(self, *, target: Name = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class BinOp(expr): - __match_args__ = ("left", "op", "right") + if sys.version_info >= (3, 10): + __match_args__ = ("left", "op", "right") left: expr op: operator right: expr @@ -822,7 +849,8 @@ class BinOp(expr): ) -> Self: ... class UnaryOp(expr): - __match_args__ = ("op", "operand") + if sys.version_info >= (3, 10): + __match_args__ = ("op", "operand") op: unaryop operand: expr def __init__(self, op: unaryop, operand: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -831,7 +859,8 @@ class UnaryOp(expr): def __replace__(self, *, op: unaryop = ..., operand: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Lambda(expr): - __match_args__ = ("args", "body") + if sys.version_info >= (3, 10): + __match_args__ = ("args", "body") args: arguments body: expr def __init__(self, args: arguments, body: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -840,7 +869,8 @@ class Lambda(expr): def __replace__(self, *, args: arguments = ..., body: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class IfExp(expr): - __match_args__ = ("test", "body", "orelse") + if sys.version_info >= (3, 10): + __match_args__ = ("test", "body", "orelse") test: expr body: expr orelse: expr @@ -852,7 +882,8 @@ class IfExp(expr): ) -> Self: ... class Dict(expr): - __match_args__ = ("keys", "values") + if sys.version_info >= (3, 10): + __match_args__ = ("keys", "values") keys: list[expr | None] values: list[expr] if sys.version_info >= (3, 13): @@ -866,7 +897,8 @@ class Dict(expr): ) -> Self: ... class Set(expr): - __match_args__ = ("elts",) + if sys.version_info >= (3, 10): + __match_args__ = ("elts",) elts: list[expr] if sys.version_info >= (3, 13): def __init__(self, elts: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -877,7 +909,8 @@ class Set(expr): def __replace__(self, *, elts: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class ListComp(expr): - __match_args__ = ("elt", "generators") + if sys.version_info >= (3, 10): + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -891,7 +924,8 @@ class ListComp(expr): ) -> Self: ... class SetComp(expr): - __match_args__ = ("elt", "generators") + if sys.version_info >= (3, 10): + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -905,7 +939,8 @@ class SetComp(expr): ) -> Self: ... class DictComp(expr): - __match_args__ = ("key", "value", "generators") + if sys.version_info >= (3, 10): + __match_args__ = ("key", "value", "generators") key: expr value: expr generators: list[comprehension] @@ -922,7 +957,8 @@ class DictComp(expr): ) -> Self: ... class GeneratorExp(expr): - __match_args__ = ("elt", "generators") + if sys.version_info >= (3, 10): + __match_args__ = ("elt", "generators") elt: expr generators: list[comprehension] if sys.version_info >= (3, 13): @@ -936,7 +972,8 @@ class GeneratorExp(expr): ) -> Self: ... class Await(expr): - __match_args__ = ("value",) + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -944,7 +981,8 @@ class Await(expr): def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Yield(expr): - __match_args__ = ("value",) + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr | None def __init__(self, value: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ... @@ -952,7 +990,8 @@ class Yield(expr): def __replace__(self, *, value: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class YieldFrom(expr): - __match_args__ = ("value",) + if sys.version_info >= (3, 10): + __match_args__ = ("value",) value: expr def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ... @@ -960,7 +999,8 @@ class YieldFrom(expr): def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Compare(expr): - __match_args__ = ("left", "ops", "comparators") + if sys.version_info >= (3, 10): + __match_args__ = ("left", "ops", "comparators") left: expr ops: list[cmpop] comparators: list[expr] @@ -977,7 +1017,8 @@ class Compare(expr): ) -> Self: ... class Call(expr): - __match_args__ = ("func", "args", "keywords") + if sys.version_info >= (3, 10): + __match_args__ = ("func", "args", "keywords") func: expr args: list[expr] keywords: list[keyword] @@ -994,7 +1035,8 @@ class Call(expr): ) -> Self: ... class FormattedValue(expr): - __match_args__ = ("value", "conversion", "format_spec") + if sys.version_info >= (3, 10): + __match_args__ = ("value", "conversion", "format_spec") value: expr conversion: int format_spec: expr | None @@ -1006,7 +1048,8 @@ class FormattedValue(expr): ) -> Self: ... class JoinedStr(expr): - __match_args__ = ("values",) + if sys.version_info >= (3, 10): + __match_args__ = ("values",) values: list[expr] if sys.version_info >= (3, 13): def __init__(self, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1047,12 +1090,17 @@ if sys.version_info >= (3, 14): **kwargs: Unpack[_Attributes], ) -> Self: ... -from types import EllipsisType +if sys.version_info >= (3, 10): + from types import EllipsisType -_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType # noqa: F821 + _ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType +else: + # Rely on builtins.ellipsis + _ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | ellipsis # noqa: F821 class Constant(expr): - __match_args__ = ("value", "kind") + if sys.version_info >= (3, 10): + __match_args__ = ("value", "kind") value: _ConstantValue kind: str | None if sys.version_info < (3, 14): @@ -1076,7 +1124,8 @@ class Constant(expr): def __replace__(self, *, value: _ConstantValue = ..., kind: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Attribute(expr): - __match_args__ = ("value", "attr", "ctx") + if sys.version_info >= (3, 10): + __match_args__ = ("value", "attr", "ctx") value: expr attr: str ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` @@ -1088,7 +1137,8 @@ class Attribute(expr): ) -> Self: ... class Subscript(expr): - __match_args__ = ("value", "slice", "ctx") + if sys.version_info >= (3, 10): + __match_args__ = ("value", "slice", "ctx") value: expr slice: expr ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` @@ -1100,7 +1150,8 @@ class Subscript(expr): ) -> Self: ... class Starred(expr): - __match_args__ = ("value", "ctx") + if sys.version_info >= (3, 10): + __match_args__ = ("value", "ctx") value: expr ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` def __init__(self, value: expr, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1109,7 +1160,8 @@ class Starred(expr): def __replace__(self, *, value: expr = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Name(expr): - __match_args__ = ("id", "ctx") + if sys.version_info >= (3, 10): + __match_args__ = ("id", "ctx") id: str ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` def __init__(self, id: str, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... @@ -1118,7 +1170,8 @@ class Name(expr): def __replace__(self, *, id: str = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class List(expr): - __match_args__ = ("elts", "ctx") + if sys.version_info >= (3, 10): + __match_args__ = ("elts", "ctx") elts: list[expr] ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` if sys.version_info >= (3, 13): @@ -1130,7 +1183,8 @@ class List(expr): def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class Tuple(expr): - __match_args__ = ("elts", "ctx") + if sys.version_info >= (3, 10): + __match_args__ = ("elts", "ctx") elts: list[expr] ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` dims: list[expr] @@ -1146,7 +1200,8 @@ class Tuple(expr): class slice(AST): ... class Slice(expr): - __match_args__ = ("lower", "upper", "step") + if sys.version_info >= (3, 10): + __match_args__ = ("lower", "upper", "step") lower: expr | None upper: expr | None step: expr | None @@ -1219,7 +1274,8 @@ class In(cmpop): ... class NotIn(cmpop): ... class comprehension(AST): - __match_args__ = ("target", "iter", "ifs", "is_async") + if sys.version_info >= (3, 10): + __match_args__ = ("target", "iter", "ifs", "is_async") target: expr iter: expr ifs: list[expr] @@ -1248,7 +1304,8 @@ class excepthandler(AST): ) -> Self: ... class ExceptHandler(excepthandler): - __match_args__ = ("type", "name", "body") + if sys.version_info >= (3, 10): + __match_args__ = ("type", "name", "body") type: expr | None name: str | None body: list[stmt] @@ -1270,7 +1327,8 @@ class ExceptHandler(excepthandler): ) -> Self: ... class arguments(AST): - __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults") + if sys.version_info >= (3, 10): + __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults") posonlyargs: list[arg] args: list[arg] vararg: arg | None @@ -1344,7 +1402,8 @@ class arg(AST): col_offset: int end_lineno: int | None end_col_offset: int | None - __match_args__ = ("arg", "annotation", "type_comment") + if sys.version_info >= (3, 10): + __match_args__ = ("arg", "annotation", "type_comment") arg: str annotation: expr | None type_comment: str | None @@ -1362,7 +1421,8 @@ class keyword(AST): col_offset: int end_lineno: int | None end_col_offset: int | None - __match_args__ = ("arg", "value") + if sys.version_info >= (3, 10): + __match_args__ = ("arg", "value") arg: str | None value: expr @overload @@ -1376,18 +1436,24 @@ class keyword(AST): class alias(AST): name: str asname: str | None - lineno: int - col_offset: int - end_lineno: int | None - end_col_offset: int | None - __match_args__ = ("name", "asname") - def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... + if sys.version_info >= (3, 10): + lineno: int + col_offset: int + end_lineno: int | None + end_col_offset: int | None + if sys.version_info >= (3, 10): + __match_args__ = ("name", "asname") + if sys.version_info >= (3, 10): + def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... + else: + def __init__(self, name: str, asname: str | None = None) -> None: ... if sys.version_info >= (3, 14): def __replace__(self, *, name: str = ..., asname: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ... class withitem(AST): - __match_args__ = ("context_expr", "optional_vars") + if sys.version_info >= (3, 10): + __match_args__ = ("context_expr", "optional_vars") context_expr: expr optional_vars: expr | None def __init__(self, context_expr: expr, optional_vars: expr | None = None) -> None: ... @@ -1395,173 +1461,177 @@ class withitem(AST): if sys.version_info >= (3, 14): def __replace__(self, *, context_expr: expr = ..., optional_vars: expr | None = ...) -> Self: ... -class pattern(AST): - lineno: int - col_offset: int - end_lineno: int - end_col_offset: int - def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ... +if sys.version_info >= (3, 10): + class pattern(AST): + lineno: int + col_offset: int + end_lineno: int + end_col_offset: int + def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ... - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ... + ) -> Self: ... -class match_case(AST): - __match_args__ = ("pattern", "guard", "body") - pattern: ast.pattern - guard: expr | None - body: list[stmt] - if sys.version_info >= (3, 13): - def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ... - else: - @overload - def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ... - @overload - def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ... + class match_case(AST): + __match_args__ = ("pattern", "guard", "body") + pattern: ast.pattern + guard: expr | None + body: list[stmt] + if sys.version_info >= (3, 13): + def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ... + elif sys.version_info >= (3, 10): + @overload + def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ... + @overload + def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ... -class Match(stmt): - __match_args__ = ("subject", "cases") - subject: expr - cases: list[match_case] - if sys.version_info >= (3, 13): - def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ... - else: - def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ... + class Match(stmt): + __match_args__ = ("subject", "cases") + subject: expr + cases: list[match_case] + if sys.version_info >= (3, 13): + def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ... + else: + def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes] + ) -> Self: ... -class MatchValue(pattern): - __match_args__ = ("value",) - value: expr - def __init__(self, value: expr, **kwargs: Unpack[_Attributes[int]]) -> None: ... + class MatchValue(pattern): + __match_args__ = ("value",) + value: expr + def __init__(self, value: expr, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... -class MatchSingleton(pattern): - __match_args__ = ("value",) - value: bool | None - def __init__(self, value: bool | None, **kwargs: Unpack[_Attributes[int]]) -> None: ... + class MatchSingleton(pattern): + __match_args__ = ("value",) + value: bool | None + def __init__(self, value: bool | None, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, value: bool | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, value: bool | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... -class MatchSequence(pattern): - __match_args__ = ("patterns",) - patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... - else: - def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... + class MatchSequence(pattern): + __match_args__ = ("patterns",) + patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... + else: + def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... -class MatchMapping(pattern): - __match_args__ = ("keys", "patterns", "rest") - keys: list[expr] - patterns: list[pattern] - rest: str | None - if sys.version_info >= (3, 13): - def __init__( - self, - keys: list[expr] = ..., - patterns: list[pattern] = ..., - rest: str | None = None, - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... - else: - def __init__( - self, keys: list[expr], patterns: list[pattern], rest: str | None = None, **kwargs: Unpack[_Attributes[int]] - ) -> None: ... + class MatchMapping(pattern): + __match_args__ = ("keys", "patterns", "rest") + keys: list[expr] + patterns: list[pattern] + rest: str | None + if sys.version_info >= (3, 13): + def __init__( + self, + keys: list[expr] = ..., + patterns: list[pattern] = ..., + rest: str | None = None, + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... + else: + def __init__( + self, keys: list[expr], patterns: list[pattern], rest: str | None = None, **kwargs: Unpack[_Attributes[int]] + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, - *, - keys: list[expr] = ..., - patterns: list[pattern] = ..., - rest: str | None = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, + *, + keys: list[expr] = ..., + patterns: list[pattern] = ..., + rest: str | None = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> Self: ... -class MatchClass(pattern): - __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") - cls: expr - patterns: list[pattern] - kwd_attrs: list[str] - kwd_patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__( - self, - cls: expr, - patterns: list[pattern] = ..., - kwd_attrs: list[str] = ..., - kwd_patterns: list[pattern] = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... - else: - def __init__( - self, - cls: expr, - patterns: list[pattern], - kwd_attrs: list[str], - kwd_patterns: list[pattern], - **kwargs: Unpack[_Attributes[int]], - ) -> None: ... + class MatchClass(pattern): + __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") + cls: expr + patterns: list[pattern] + kwd_attrs: list[str] + kwd_patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__( + self, + cls: expr, + patterns: list[pattern] = ..., + kwd_attrs: list[str] = ..., + kwd_patterns: list[pattern] = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... + else: + def __init__( + self, + cls: expr, + patterns: list[pattern], + kwd_attrs: list[str], + kwd_patterns: list[pattern], + **kwargs: Unpack[_Attributes[int]], + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, - *, - cls: expr = ..., - patterns: list[pattern] = ..., - kwd_attrs: list[str] = ..., - kwd_patterns: list[pattern] = ..., - **kwargs: Unpack[_Attributes[int]], - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, + *, + cls: expr = ..., + patterns: list[pattern] = ..., + kwd_attrs: list[str] = ..., + kwd_patterns: list[pattern] = ..., + **kwargs: Unpack[_Attributes[int]], + ) -> Self: ... -class MatchStar(pattern): - __match_args__ = ("name",) - name: str | None - def __init__(self, name: str | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ... + class MatchStar(pattern): + __match_args__ = ("name",) + name: str | None + def __init__(self, name: str | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... -class MatchAs(pattern): - __match_args__ = ("pattern", "name") - pattern: ast.pattern | None - name: str | None - def __init__( - self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]] - ) -> None: ... + class MatchAs(pattern): + __match_args__ = ("pattern", "name") + pattern: ast.pattern | None + name: str | None + def __init__( + self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]] + ) -> None: ... - if sys.version_info >= (3, 14): - def __replace__( - self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]] - ) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__( + self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]] + ) -> Self: ... -class MatchOr(pattern): - __match_args__ = ("patterns",) - patterns: list[pattern] - if sys.version_info >= (3, 13): - def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... - else: - def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... + class MatchOr(pattern): + __match_args__ = ("patterns",) + patterns: list[pattern] + if sys.version_info >= (3, 13): + def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ... + else: + def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ... - if sys.version_info >= (3, 14): - def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... + if sys.version_info >= (3, 14): + def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ... class type_ignore(AST): ... class TypeIgnore(type_ignore): - __match_args__ = ("lineno", "tag") + if sys.version_info >= (3, 10): + __match_args__ = ("lineno", "tag") lineno: int tag: str def __init__(self, lineno: int, tag: str) -> None: ... @@ -1973,16 +2043,17 @@ class NodeVisitor: def visit_keyword(self, node: keyword) -> Any: ... def visit_alias(self, node: alias) -> Any: ... def visit_withitem(self, node: withitem) -> Any: ... - def visit_Match(self, node: Match) -> Any: ... - def visit_match_case(self, node: match_case) -> Any: ... - def visit_MatchValue(self, node: MatchValue) -> Any: ... - def visit_MatchSequence(self, node: MatchSequence) -> Any: ... - def visit_MatchSingleton(self, node: MatchSingleton) -> Any: ... - def visit_MatchStar(self, node: MatchStar) -> Any: ... - def visit_MatchMapping(self, node: MatchMapping) -> Any: ... - def visit_MatchClass(self, node: MatchClass) -> Any: ... - def visit_MatchAs(self, node: MatchAs) -> Any: ... - def visit_MatchOr(self, node: MatchOr) -> Any: ... + if sys.version_info >= (3, 10): + def visit_Match(self, node: Match) -> Any: ... + def visit_match_case(self, node: match_case) -> Any: ... + def visit_MatchValue(self, node: MatchValue) -> Any: ... + def visit_MatchSequence(self, node: MatchSequence) -> Any: ... + def visit_MatchSingleton(self, node: MatchSingleton) -> Any: ... + def visit_MatchStar(self, node: MatchStar) -> Any: ... + def visit_MatchMapping(self, node: MatchMapping) -> Any: ... + def visit_MatchClass(self, node: MatchClass) -> Any: ... + def visit_MatchAs(self, node: MatchAs) -> Any: ... + def visit_MatchOr(self, node: MatchOr) -> Any: ... if sys.version_info >= (3, 11): def visit_TryStar(self, node: TryStar) -> Any: ... diff --git a/stdlib/asyncio/__init__.pyi b/stdlib/asyncio/__init__.pyi index 5189024f2431..23cf57aaac33 100644 --- a/stdlib/asyncio/__init__.pyi +++ b/stdlib/asyncio/__init__.pyi @@ -2,7 +2,8 @@ # Can't NOQA on a specific line: https://github.com/plinss/flake8-noqa/issues/22 import sys from collections.abc import Awaitable, Coroutine, Generator -from typing import Any, TypeAlias, TypeVar +from typing import Any, TypeVar +from typing_extensions import TypeAlias # As at runtime, this depends on all submodules defining __all__ accurately. from .base_events import * diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 1aec5847c367..0d8ac2d47491 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -11,8 +11,8 @@ from collections.abc import Callable, Iterable, Sequence from concurrent.futures import Executor, ThreadPoolExecutor from contextvars import Context from socket import AddressFamily, AddressInfo, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Literal, TypeAlias, TypeVar, overload -from typing_extensions import TypeVarTuple, Unpack +from typing import IO, Any, Literal, TypeVar, overload +from typing_extensions import TypeAlias, TypeVarTuple, Unpack # Keep asyncio.__all__ updated with any changes to __all__ here __all__ = ("BaseEventLoop", "Server") diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index 36f0f6099cbc..a5fe24e8768b 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -1,7 +1,8 @@ import subprocess from collections import deque from collections.abc import Callable, Sequence -from typing import IO, Any, TypeAlias +from typing import IO, Any +from typing_extensions import TypeAlias from . import events, futures, protocols, transports diff --git a/stdlib/asyncio/coroutines.pyi b/stdlib/asyncio/coroutines.pyi index ba0fe596f9a5..777961d80441 100644 --- a/stdlib/asyncio/coroutines.pyi +++ b/stdlib/asyncio/coroutines.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Awaitable, Callable, Coroutine -from typing import Any, TypeGuard, TypeVar, overload -from typing_extensions import ParamSpec, TypeIs, deprecated +from typing import Any, TypeVar, overload +from typing_extensions import ParamSpec, TypeGuard, TypeIs, deprecated # Keep asyncio.__all__ updated with any changes to __all__ here if sys.version_info >= (3, 11): diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index a8cbbcd10517..4f2f45355f5b 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -12,8 +12,8 @@ from collections.abc import Callable, Sequence from concurrent.futures import Executor from contextvars import Context from socket import AddressFamily, AddressInfo, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeVarTuple, Unpack, deprecated +from typing import IO, Any, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack, deprecated from . import _AwaitableLike, _CoroutineLike from .base_events import Server @@ -467,7 +467,7 @@ class AbstractEventLoop: ssl_handshake_timeout: float | None = None, ssl_shutdown_timeout: float | None = None, ) -> tuple[Transport, _ProtocolT]: ... - else: + elif sys.version_info >= (3, 10): async def connect_accepted_socket( self, protocol_factory: Callable[[], _ProtocolT], diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index ff830a3b73d4..597eb9e56e1a 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -3,7 +3,8 @@ import sys import traceback from collections.abc import Iterable from types import FrameType, FunctionType -from typing import Any, TypeAlias, overload, type_check_only +from typing import Any, overload, type_check_only +from typing_extensions import TypeAlias @type_check_only class _HasWrapper: diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 4420d02fcd26..17390b0c5a0e 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -7,8 +7,13 @@ from types import TracebackType from typing import Any, Literal, TypeVar from typing_extensions import Self +from .events import AbstractEventLoop from .futures import Future -from .mixins import _LoopBoundMixin + +if sys.version_info >= (3, 10): + from .mixins import _LoopBoundMixin +else: + _LoopBoundMixin = object # Keep asyncio.__all__ updated with any changes to __all__ here if sys.version_info >= (3, 11): @@ -26,14 +31,22 @@ class _ContextManagerMixin: class Lock(_ContextManagerMixin, _LoopBoundMixin): _waiters: deque[Future[Any]] | None - def __init__(self) -> None: ... + if sys.version_info >= (3, 10): + def __init__(self) -> None: ... + else: + def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ... + def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... class Event(_LoopBoundMixin): _waiters: deque[Future[Any]] - def __init__(self) -> None: ... + if sys.version_info >= (3, 10): + def __init__(self) -> None: ... + else: + def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ... + def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... @@ -41,7 +54,11 @@ class Event(_LoopBoundMixin): class Condition(_ContextManagerMixin, _LoopBoundMixin): _waiters: deque[Future[Any]] - def __init__(self, lock: Lock | None = None) -> None: ... + if sys.version_info >= (3, 10): + def __init__(self, lock: Lock | None = None) -> None: ... + else: + def __init__(self, lock: Lock | None = None, *, loop: AbstractEventLoop | None = None) -> None: ... + def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... @@ -53,7 +70,11 @@ class Condition(_ContextManagerMixin, _LoopBoundMixin): class Semaphore(_ContextManagerMixin, _LoopBoundMixin): _value: int _waiters: deque[Future[Any]] | None - def __init__(self, value: int = 1) -> None: ... + if sys.version_info >= (3, 10): + def __init__(self, value: int = 1) -> None: ... + else: + def __init__(self, value: int = 1, *, loop: AbstractEventLoop | None = None) -> None: ... + def locked(self) -> bool: ... async def acquire(self) -> Literal[True]: ... def release(self) -> None: ... diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index 09c096d40f04..909d671df289 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -1,3 +1,4 @@ +import sys from collections.abc import Mapping from socket import socket from typing import Any, ClassVar, Literal @@ -19,16 +20,27 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr def __del__(self) -> None: ... class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport): - def __init__( - self, - loop: events.AbstractEventLoop, - sock: socket, - protocol: streams.StreamReaderProtocol, - waiter: futures.Future[Any] | None = None, - extra: Mapping[Any, Any] | None = None, - server: events.AbstractServer | None = None, - buffer_size: int = 65536, - ) -> None: ... + if sys.version_info >= (3, 10): + def __init__( + self, + loop: events.AbstractEventLoop, + sock: socket, + protocol: streams.StreamReaderProtocol, + waiter: futures.Future[Any] | None = None, + extra: Mapping[Any, Any] | None = None, + server: events.AbstractServer | None = None, + buffer_size: int = 65536, + ) -> None: ... + else: + def __init__( + self, + loop: events.AbstractEventLoop, + sock: socket, + protocol: streams.StreamReaderProtocol, + waiter: futures.Future[Any] | None = None, + extra: Mapping[Any, Any] | None = None, + server: events.AbstractServer | None = None, + ) -> None: ... class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): ... class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): ... diff --git a/stdlib/asyncio/queues.pyi b/stdlib/asyncio/queues.pyi index c6821ac25af9..2fa2226d0e6a 100644 --- a/stdlib/asyncio/queues.pyi +++ b/stdlib/asyncio/queues.pyi @@ -1,9 +1,13 @@ import sys from _typeshed import SupportsRichComparisonT +from asyncio.events import AbstractEventLoop from types import GenericAlias from typing import Any, Generic, TypeVar -from .mixins import _LoopBoundMixin +if sys.version_info >= (3, 10): + from .mixins import _LoopBoundMixin +else: + _LoopBoundMixin = object class QueueEmpty(Exception): ... class QueueFull(Exception): ... @@ -23,7 +27,11 @@ if sys.version_info >= (3, 13): # If Generic[_T] is last and _LoopBoundMixin is object, pyright is unhappy. # We can remove the noqa pragma when dropping 3.9 support. class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059 - def __init__(self, maxsize: int = 0) -> None: ... + if sys.version_info >= (3, 10): + def __init__(self, maxsize: int = 0) -> None: ... + else: + def __init__(self, maxsize: int = 0, *, loop: AbstractEventLoop | None = None) -> None: ... + def _init(self, maxsize: int) -> None: ... def _get(self) -> _T: ... def _put(self, item: _T) -> None: ... diff --git a/stdlib/asyncio/sslproto.pyi b/stdlib/asyncio/sslproto.pyi index 72b4ea449e86..ab102f124c2e 100644 --- a/stdlib/asyncio/sslproto.pyi +++ b/stdlib/asyncio/sslproto.pyi @@ -3,7 +3,8 @@ import sys from collections import deque from collections.abc import Callable from enum import Enum -from typing import Any, ClassVar, Final, Literal, TypeAlias +from typing import Any, ClassVar, Final, Literal +from typing_extensions import TypeAlias from . import constants, events, futures, protocols, transports diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index db22b9a8e513..33cffb11ed78 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -3,8 +3,8 @@ import sys from _typeshed import ReadableBuffer, StrPath from collections.abc import Awaitable, Callable, Iterable, Sequence, Sized from types import ModuleType -from typing import Any, Protocol, SupportsIndex, TypeAlias, type_check_only -from typing_extensions import Self +from typing import Any, Protocol, SupportsIndex, type_check_only +from typing_extensions import Self, TypeAlias from . import events, protocols, transports from .base_events import Server @@ -28,32 +28,67 @@ _ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awa @type_check_only class _ReaduntilBuffer(ReadableBuffer, Sized, Protocol): ... -async def open_connection( - host: str | None = None, - port: int | str | None = None, - *, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, -) -> tuple[StreamReader, StreamWriter]: ... -async def start_server( - client_connected_cb: _ClientConnectedCallback, - host: str | Sequence[str] | None = None, - port: int | str | None = None, - *, - limit: int = 65536, - ssl_handshake_timeout: float | None = None, - **kwds: Any, -) -> Server: ... +if sys.version_info >= (3, 10): + async def open_connection( + host: str | None = None, + port: int | str | None = None, + *, + limit: int = 65536, + ssl_handshake_timeout: float | None = None, + **kwds: Any, + ) -> tuple[StreamReader, StreamWriter]: ... + async def start_server( + client_connected_cb: _ClientConnectedCallback, + host: str | Sequence[str] | None = None, + port: int | str | None = None, + *, + limit: int = 65536, + ssl_handshake_timeout: float | None = None, + **kwds: Any, + ) -> Server: ... -if sys.platform != "win32": - async def open_unix_connection( - path: StrPath | None = None, *, limit: int = 65536, **kwds: Any +else: + async def open_connection( + host: str | None = None, + port: int | str | None = None, + *, + loop: events.AbstractEventLoop | None = None, + limit: int = 65536, + ssl_handshake_timeout: float | None = None, + **kwds: Any, ) -> tuple[StreamReader, StreamWriter]: ... - async def start_unix_server( - client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any + async def start_server( + client_connected_cb: _ClientConnectedCallback, + host: str | None = None, + port: int | str | None = None, + *, + loop: events.AbstractEventLoop | None = None, + limit: int = 65536, + ssl_handshake_timeout: float | None = None, + **kwds: Any, ) -> Server: ... +if sys.platform != "win32": + if sys.version_info >= (3, 10): + async def open_unix_connection( + path: StrPath | None = None, *, limit: int = 65536, **kwds: Any + ) -> tuple[StreamReader, StreamWriter]: ... + async def start_unix_server( + client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any + ) -> Server: ... + else: + async def open_unix_connection( + path: StrPath | None = None, *, loop: events.AbstractEventLoop | None = None, limit: int = 65536, **kwds: Any + ) -> tuple[StreamReader, StreamWriter]: ... + async def start_unix_server( + client_connected_cb: _ClientConnectedCallback, + path: StrPath | None = None, + *, + loop: events.AbstractEventLoop | None = None, + limit: int = 65536, + **kwds: Any, + ) -> Server: ... + class FlowControlMixin(protocols.Protocol): def __init__(self, loop: events.AbstractEventLoop | None = None) -> None: ... diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index 6405e5ae1474..ceee2b5b90a0 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -101,7 +101,7 @@ if sys.version_info >= (3, 11): pipesize: int = -1, ) -> Process: ... -else: +elif sys.version_info >= (3, 10): async def create_subprocess_shell( cmd: str | bytes, stdin: int | IO[Any] | None = None, @@ -164,3 +164,67 @@ else: umask: int = -1, pipesize: int = -1, ) -> Process: ... + +else: # >= 3.9 + async def create_subprocess_shell( + cmd: str | bytes, + stdin: int | IO[Any] | None = None, + stdout: int | IO[Any] | None = None, + stderr: int | IO[Any] | None = None, + loop: events.AbstractEventLoop | None = None, + limit: int = 65536, + *, + # These parameters are forced to these values by BaseEventLoop.subprocess_shell + universal_newlines: Literal[False] = False, + shell: Literal[True] = True, + bufsize: Literal[0] = 0, + encoding: None = None, + errors: None = None, + text: Literal[False] | None = None, + # These parameters are taken by subprocess.Popen, which this ultimately delegates to + executable: StrOrBytesPath | None = None, + preexec_fn: Callable[[], Any] | None = None, + close_fds: bool = True, + cwd: StrOrBytesPath | None = None, + env: subprocess._ENV | None = None, + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + group: None | str | int = None, + extra_groups: None | Collection[str | int] = None, + user: None | str | int = None, + umask: int = -1, + ) -> Process: ... + async def create_subprocess_exec( + program: StrOrBytesPath, + *args: StrOrBytesPath, + stdin: int | IO[Any] | None = None, + stdout: int | IO[Any] | None = None, + stderr: int | IO[Any] | None = None, + loop: events.AbstractEventLoop | None = None, + limit: int = 65536, + # These parameters are forced to these values by BaseEventLoop.subprocess_exec + universal_newlines: Literal[False] = False, + shell: Literal[False] = False, + bufsize: Literal[0] = 0, + encoding: None = None, + errors: None = None, + text: Literal[False] | None = None, + # These parameters are taken by subprocess.Popen, which this ultimately delegates to + executable: StrOrBytesPath | None = None, + preexec_fn: Callable[[], Any] | None = None, + close_fds: bool = True, + cwd: StrOrBytesPath | None = None, + env: subprocess._ENV | None = None, + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + group: None | str | int = None, + extra_groups: None | Collection[str | int] = None, + user: None | str | int = None, + umask: int = -1, + ) -> Process: ... diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 75e91e8442fa..be9b60cd36ae 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -8,7 +8,8 @@ from _asyncio import ( _unregister_task as _unregister_task, ) from collections.abc import AsyncIterator, Awaitable, Coroutine, Generator, Iterable, Iterator -from typing import Any, Final, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, Final, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from . import _CoroutineLike from .events import AbstractEventLoop @@ -91,9 +92,14 @@ if sys.version_info >= (3, 13): def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[Future[_T]]: ... -else: +elif sys.version_info >= (3, 10): def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ... +else: + def as_completed( + fs: Iterable[_FutureLike[_T]], *, loop: AbstractEventLoop | None = None, timeout: float | None = None + ) -> Iterator[Future[_T]]: ... + @overload def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[overload-overlap] @overload @@ -105,124 +111,262 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No # typing PR #1550 for discussion. # # N.B. Having overlapping overloads is the only way to get acceptable type inference in all edge cases. -@overload -def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap] -@overload -def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False -) -> Future[tuple[_T1, _T2]]: ... -@overload -def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - return_exceptions: Literal[False] = False, -) -> Future[tuple[_T1, _T2, _T3]]: ... -@overload -def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - return_exceptions: Literal[False] = False, -) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... -@overload -def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - /, - *, - return_exceptions: Literal[False] = False, -) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... -@overload -def gather( # type: ignore[overload-overlap] - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - return_exceptions: Literal[False] = False, -) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... -@overload -def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap] -@overload -def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... -@overload -def gather( - coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool -) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... -@overload -def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - /, - *, - return_exceptions: bool, -) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... -@overload -def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - /, - *, - return_exceptions: bool, -) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... -@overload -def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - /, - *, - return_exceptions: bool, -) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]]: ... -@overload -def gather( - coro_or_future1: _FutureLike[_T1], - coro_or_future2: _FutureLike[_T2], - coro_or_future3: _FutureLike[_T3], - coro_or_future4: _FutureLike[_T4], - coro_or_future5: _FutureLike[_T5], - coro_or_future6: _FutureLike[_T6], - /, - *, - return_exceptions: bool, -) -> Future[ - tuple[ - _T1 | BaseException, - _T2 | BaseException, - _T3 | BaseException, - _T4 | BaseException, - _T5 | BaseException, - _T6 | BaseException, - ] -]: ... -@overload -def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ... +if sys.version_info >= (3, 10): + @overload + def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap] + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False + ) -> Future[tuple[_T1, _T2]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + /, + *, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2, _T3]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + /, + *, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + /, + *, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + coro_or_future6: _FutureLike[_T6], + /, + *, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... + @overload + def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap] + @overload + def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... + @overload + def gather( + coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... + @overload + def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + /, + *, + return_exceptions: bool, + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... + @overload + def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + /, + *, + return_exceptions: bool, + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... + @overload + def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + /, + *, + return_exceptions: bool, + ) -> Future[ + tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] + ]: ... + @overload + def gather( + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + coro_or_future6: _FutureLike[_T6], + /, + *, + return_exceptions: bool, + ) -> Future[ + tuple[ + _T1 | BaseException, + _T2 | BaseException, + _T3 | BaseException, + _T4 | BaseException, + _T5 | BaseException, + _T6 | BaseException, + ] + ]: ... + @overload + def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ... + +else: + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False + ) -> Future[tuple[_T1]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2, _T3]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + coro_or_future6: _FutureLike[_T6], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: Literal[False] = False, + ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... + @overload + def gather( # type: ignore[overload-overlap] + *coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False + ) -> Future[list[_T]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: bool + ) -> Future[tuple[_T1 | BaseException]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: bool, + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: bool, + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: bool, + ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... + @overload + def gather( # type: ignore[overload-overlap] + coro_or_future1: _FutureLike[_T1], + coro_or_future2: _FutureLike[_T2], + coro_or_future3: _FutureLike[_T3], + coro_or_future4: _FutureLike[_T4], + coro_or_future5: _FutureLike[_T5], + coro_or_future6: _FutureLike[_T6], + /, + *, + loop: AbstractEventLoop | None = None, + return_exceptions: bool, + ) -> Future[ + tuple[ + _T1 | BaseException, + _T2 | BaseException, + _T3 | BaseException, + _T4 | BaseException, + _T5 | BaseException, + _T6 | BaseException, + ] + ]: ... + @overload + def gather( + *coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: bool + ) -> Future[list[_T | BaseException]]: ... # unlike some asyncio apis, This does strict runtime checking of actually being a coroutine, not of any future-like. def run_coroutine_threadsafe(coro: Coroutine[Any, Any, _T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... -def shield(arg: _FutureLike[_T]) -> Future[_T]: ... -@overload -async def sleep(delay: float) -> None: ... -@overload -async def sleep(delay: float, result: _T) -> _T: ... -async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ... + +if sys.version_info >= (3, 10): + def shield(arg: _FutureLike[_T]) -> Future[_T]: ... + @overload + async def sleep(delay: float) -> None: ... + @overload + async def sleep(delay: float, result: _T) -> _T: ... + async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ... + +else: + def shield(arg: _FutureLike[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ... + @overload + async def sleep(delay: float, *, loop: AbstractEventLoop | None = None) -> None: ... + @overload + async def sleep(delay: float, result: _T, *, loop: AbstractEventLoop | None = None) -> _T: ... + async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = None) -> _T: ... if sys.version_info >= (3, 11): @overload @@ -234,7 +378,7 @@ if sys.version_info >= (3, 11): fs: Iterable[Task[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... -else: +elif sys.version_info >= (3, 10): @overload async def wait( # type: ignore[overload-overlap] fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" @@ -244,6 +388,24 @@ else: fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... +else: + @overload + async def wait( # type: ignore[overload-overlap] + fs: Iterable[_FT], + *, + loop: AbstractEventLoop | None = None, + timeout: float | None = None, + return_when: str = "ALL_COMPLETED", + ) -> tuple[set[_FT], set[_FT]]: ... + @overload + async def wait( + fs: Iterable[Awaitable[_T]], + *, + loop: AbstractEventLoop | None = None, + timeout: float | None = None, + return_when: str = "ALL_COMPLETED", + ) -> tuple[set[Task[_T]], set[Task[_T]]]: ... + if sys.version_info >= (3, 12): _TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co] else: diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 1249fac4c8b6..d3e95559ebef 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -4,8 +4,8 @@ from _typeshed import ReadableBuffer from builtins import type as Type # alias to avoid name clashes with property named "type" from collections.abc import Iterable from types import TracebackType -from typing import Any, BinaryIO, NoReturn, TypeAlias, overload -from typing_extensions import deprecated +from typing import Any, BinaryIO, NoReturn, overload +from typing_extensions import TypeAlias, deprecated # These are based in socket, maybe move them out into _typeshed.pyi or such _Address: TypeAlias = socket._Address diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index 17ed4f11d020..36d1862fdda7 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -1,7 +1,8 @@ import sys from _typeshed import FileDescriptorLike, ReadableBuffer from socket import socket -from typing import Any, TypeAlias, overload +from typing import Any, overload +from typing_extensions import TypeAlias # cyclic dependence with asynchat _MapType: TypeAlias = dict[int, Any] diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index a7d5e8adb7a5..f3ce78ccb7fa 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,5 +1,4 @@ -from typing import TypeAlias -from typing_extensions import Buffer +from typing_extensions import Buffer, TypeAlias _AdpcmState: TypeAlias = tuple[int, int] _RatecvState: TypeAlias = tuple[int, tuple[tuple[int, int], ...]] diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 043137714c0f..279d74a94ebe 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -23,7 +23,8 @@ __all__ = [ "urlsafe_b64decode", ] -__all__ += ["b32hexencode", "b32hexdecode"] +if sys.version_info >= (3, 10): + __all__ += ["b32hexencode", "b32hexdecode"] if sys.version_info >= (3, 13): __all__ += ["z85decode", "z85encode"] @@ -37,8 +38,11 @@ def b32encode(s: ReadableBuffer) -> bytes: ... def b32decode(s: str | ReadableBuffer, casefold: bool = False, map01: str | ReadableBuffer | None = None) -> bytes: ... def b16encode(s: ReadableBuffer) -> bytes: ... def b16decode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... -def b32hexencode(s: ReadableBuffer) -> bytes: ... -def b32hexdecode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... + +if sys.version_info >= (3, 10): + def b32hexencode(s: ReadableBuffer) -> bytes: ... + def b32hexdecode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ... + def a85encode( b: ReadableBuffer, *, foldspaces: bool = False, wrapcol: int = 0, pad: bool = False, adobe: bool = False ) -> bytes: ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index e16444643846..b6be2210ffe2 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -3,8 +3,8 @@ from _typeshed import ExcInfo, TraceFunction, Unused from collections.abc import Callable, Iterable, Iterator, Mapping from contextlib import contextmanager from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Final, Literal, SupportsInt, TypeAlias, TypeVar -from typing_extensions import ParamSpec +from typing import IO, Any, Final, Literal, SupportsInt, TypeVar +from typing_extensions import ParamSpec, TypeAlias __all__ = ["BdbQuit", "Bdb", "Breakpoint"] diff --git a/stdlib/binascii.pyi b/stdlib/binascii.pyi index f2eddafa5750..5606d5cdf74d 100644 --- a/stdlib/binascii.pyi +++ b/stdlib/binascii.pyi @@ -1,7 +1,6 @@ import sys from _typeshed import ReadableBuffer -from typing import TypeAlias -from typing_extensions import deprecated +from typing_extensions import TypeAlias, deprecated # Many functions in binascii accept buffer objects # or ASCII-only strings. diff --git a/stdlib/binhex.pyi b/stdlib/binhex.pyi index f309f4e026a5..bdead928468f 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,5 +1,6 @@ from _typeshed import SizedBuffer -from typing import IO, Any, Final, TypeAlias +from typing import IO, Any, Final +from typing_extensions import TypeAlias __all__ = ["binhex", "hexbin", "Error"] diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 7866a2f1b411..efc51fe257ae 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -42,10 +42,8 @@ from typing import ( # noqa: Y022,UP035 Any, BinaryIO, ClassVar, - Concatenate, Final, Generic, - Literal, Mapping, MutableMapping, MutableSequence, @@ -56,8 +54,6 @@ from typing import ( # noqa: Y022,UP035 SupportsComplex, SupportsFloat, SupportsIndex, - TypeAlias, - TypeGuard, TypeVar, final, overload, @@ -65,7 +61,19 @@ from typing import ( # noqa: Y022,UP035 ) # we can't import `Literal` from typing or mypy crashes: see #11247 -from typing_extensions import LiteralString, ParamSpec, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023 +from typing_extensions import ( # noqa: Y023 + Concatenate, + Literal, + LiteralString, + ParamSpec, + Self, + TypeAlias, + TypeGuard, + TypeIs, + TypeVarTuple, + deprecated, + disjoint_base, +) if sys.version_info >= (3, 14): from _typeshed import AnnotateFunc @@ -144,11 +152,12 @@ class staticmethod(Generic[_P, _R_co]): def __get__(self, instance: None, owner: type, /) -> Callable[_P, _R_co]: ... @overload def __get__(self, instance: _T, owner: type[_T] | None = None, /) -> Callable[_P, _R_co]: ... - __name__: str - __qualname__: str - @property - def __wrapped__(self) -> Callable[_P, _R_co]: ... - def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: ... + if sys.version_info >= (3, 10): + __name__: str + __qualname__: str + @property + def __wrapped__(self) -> Callable[_P, _R_co]: ... + def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: ... if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... __annotate__: AnnotateFunc | None @@ -164,10 +173,11 @@ class classmethod(Generic[_T, _P, _R_co]): def __get__(self, instance: _T, owner: type[_T] | None = None, /) -> Callable[_P, _R_co]: ... @overload def __get__(self, instance: None, owner: type[_T], /) -> Callable[_P, _R_co]: ... - __name__: str - __qualname__: str - @property - def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... + if sys.version_info >= (3, 10): + __name__: str + __qualname__: str + @property + def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... __annotate__: AnnotateFunc | None @@ -217,8 +227,11 @@ class type: def __subclasscheck__(self, subclass: type, /) -> bool: ... @classmethod def __prepare__(metacls, name: str, bases: tuple[type, ...], /, **kwds: Any) -> MutableMapping[str, object]: ... - def __or__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... - def __ror__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... + if sys.version_info >= (3, 10): + # `int | str` produces an instance of `UnionType`, but `int | int` produces an instance of `type`, + # and `abc.ABC | abc.ABC` produces an instance of `abc.ABCMeta`. + def __or__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... + def __ror__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] __annotations__: dict[str, AnnotationForm] @@ -255,7 +268,8 @@ class int: def denominator(self) -> Literal[1]: ... def conjugate(self) -> int: ... def bit_length(self) -> int: ... - def bit_count(self) -> int: ... + if sys.version_info >= (3, 10): + def bit_count(self) -> int: ... if sys.version_info >= (3, 11): def to_bytes( @@ -929,7 +943,11 @@ class memoryview(Sequence[_I]): def __setitem__(self, key: slice[SupportsIndex | None], value: ReadableBuffer, /) -> None: ... @overload def __setitem__(self, key: SupportsIndex | tuple[SupportsIndex, ...], value: _I, /) -> None: ... - def tobytes(self, order: Literal["C", "F", "A"] | None = "C") -> bytes: ... + if sys.version_info >= (3, 10): + def tobytes(self, order: Literal["C", "F", "A"] | None = "C") -> bytes: ... + else: + def tobytes(self, order: Literal["C", "F", "A"] | None = None) -> bytes: ... + def tolist(self) -> list[int]: ... def toreadonly(self) -> memoryview: ... def release(self) -> None: ... @@ -1068,8 +1086,9 @@ class function: if sys.version_info >= (3, 14): __annotate__: AnnotateFunc | None __kwdefaults__: dict[str, Any] | None - @property - def __builtins__(self) -> dict[str, Any]: ... + if sys.version_info >= (3, 10): + @property + def __builtins__(self) -> dict[str, Any]: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] @@ -1370,18 +1389,20 @@ def bin(number: int | SupportsIndex, /) -> str: ... def breakpoint(*args: Any, **kws: Any) -> None: ... def callable(obj: object, /) -> TypeIs[Callable[..., object]]: ... def chr(i: int | SupportsIndex, /) -> str: ... -def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ... -@type_check_only -class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]): - def __anext__(self) -> _AwaitableT_co: ... -@overload -# `anext` is not, in fact, an async function. When default is not provided -# `anext` is just a passthrough for `obj.__anext__` -# See discussion in #7491 and pure-Python implementation of `anext` at https://github.com/python/cpython/blob/ea786a882b9ed4261eafabad6011bc7ef3b5bf94/Lib/test/test_asyncgen.py#L52-L80 -def anext(i: _SupportsSynchronousAnext[_AwaitableT], /) -> _AwaitableT: ... -@overload -async def anext(i: SupportsAnext[_T], default: _VT, /) -> _T | _VT: ... +if sys.version_info >= (3, 10): + def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ... + @type_check_only + class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]): + def __anext__(self) -> _AwaitableT_co: ... + + @overload + # `anext` is not, in fact, an async function. When default is not provided + # `anext` is just a passthrough for `obj.__anext__` + # See discussion in #7491 and pure-Python implementation of `anext` at https://github.com/python/cpython/blob/ea786a882b9ed4261eafabad6011bc7ef3b5bf94/Lib/test/test_asyncgen.py#L52-L80 + def anext(i: _SupportsSynchronousAnext[_AwaitableT], /) -> _AwaitableT: ... + @overload + async def anext(i: SupportsAnext[_T], default: _VT, /) -> _T | _VT: ... # compile() returns a CodeType, unless the flags argument includes PyCF_ONLY_AST (=1024), # in which case it returns ast.AST. We have overloads for flag 0 (the default) and for @@ -1541,7 +1562,10 @@ def iter(object: Callable[[], _T | None], sentinel: None, /) -> Iterator[_T]: .. @overload def iter(object: Callable[[], _T], sentinel: object, /) -> Iterator[_T]: ... -_ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...] +if sys.version_info >= (3, 10): + _ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...] +else: + _ClassInfo: TypeAlias = type | tuple[_ClassInfo, ...] def isinstance(obj: object, class_or_tuple: _ClassInfo, /) -> bool: ... def issubclass(cls: type, class_or_tuple: _ClassInfo, /) -> bool: ... @@ -1923,45 +1947,83 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ... def vars(object: Any = ..., /) -> dict[str, Any]: ... @disjoint_base class zip(Generic[_T_co]): - @overload - def __new__(cls, *, strict: bool = False) -> zip[Any]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], /, *, strict: bool = False) -> zip[tuple[_T1]]: ... - @overload - def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /, *, strict: bool = False) -> zip[tuple[_T1, _T2]]: ... - @overload - def __new__( - cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /, *, strict: bool = False - ) -> zip[tuple[_T1, _T2, _T3]]: ... - @overload - def __new__( - cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], /, *, strict: bool = False - ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def __new__( - cls, - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - iter5: Iterable[_T5], - /, - *, - strict: bool = False, - ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def __new__( - cls, - iter1: Iterable[Any], - iter2: Iterable[Any], - iter3: Iterable[Any], - iter4: Iterable[Any], - iter5: Iterable[Any], - iter6: Iterable[Any], - /, - *iterables: Iterable[Any], - strict: bool = False, - ) -> zip[tuple[Any, ...]]: ... + if sys.version_info >= (3, 10): + @overload + def __new__(cls, *, strict: bool = False) -> zip[Any]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], /, *, strict: bool = False) -> zip[tuple[_T1]]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /, *, strict: bool = False) -> zip[tuple[_T1, _T2]]: ... + @overload + def __new__( + cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /, *, strict: bool = False + ) -> zip[tuple[_T1, _T2, _T3]]: ... + @overload + def __new__( + cls, + iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + /, + *, + strict: bool = False, + ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... + @overload + def __new__( + cls, + iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + iter5: Iterable[_T5], + /, + *, + strict: bool = False, + ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... + @overload + def __new__( + cls, + iter1: Iterable[Any], + iter2: Iterable[Any], + iter3: Iterable[Any], + iter4: Iterable[Any], + iter5: Iterable[Any], + iter6: Iterable[Any], + /, + *iterables: Iterable[Any], + strict: bool = False, + ) -> zip[tuple[Any, ...]]: ... + else: + @overload + def __new__(cls) -> zip[Any]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], /) -> zip[tuple[_T1]]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], /) -> zip[tuple[_T1, _T2]]: ... + @overload + def __new__(cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], /) -> zip[tuple[_T1, _T2, _T3]]: ... + @overload + def __new__( + cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], / + ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... + @overload + def __new__( + cls, iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], iter5: Iterable[_T5], / + ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... + @overload + def __new__( + cls, + iter1: Iterable[Any], + iter2: Iterable[Any], + iter3: Iterable[Any], + iter4: Iterable[Any], + iter5: Iterable[Any], + iter6: Iterable[Any], + /, + *iterables: Iterable[Any], + ) -> zip[tuple[Any, ...]]: ... + def __iter__(self) -> Self: ... def __next__(self) -> _T_co: ... @@ -1976,14 +2038,29 @@ def __import__( ) -> types.ModuleType: ... def __build_class__(func: Callable[[], CellType | Any], name: str, /, *bases: Any, metaclass: Any = ..., **kwds: Any) -> Any: ... -from types import EllipsisType, NotImplementedType +if sys.version_info >= (3, 10): + from types import EllipsisType, NotImplementedType + + # Backwards compatibility hack for folks who relied on the ellipsis type + # existing in typeshed in Python 3.9 and earlier. + ellipsis = EllipsisType + + Ellipsis: EllipsisType + NotImplemented: NotImplementedType +else: + # Actually the type of Ellipsis is , but since it's + # not exposed anywhere under that name, we make it private here. + @final + @type_check_only + class ellipsis: ... + + Ellipsis: ellipsis -# Backwards compatibility hack for folks who relied on the ellipsis type -# existing in typeshed in Python 3.9 and earlier. -ellipsis = EllipsisType + @final + @type_check_only + class _NotImplementedType(Any): ... -Ellipsis: EllipsisType -NotImplemented: NotImplementedType + NotImplemented: _NotImplementedType @disjoint_base class BaseException: @@ -2036,11 +2113,15 @@ if sys.platform == "win32": class ArithmeticError(Exception): ... class AssertionError(Exception): ... -@disjoint_base -class AttributeError(Exception): - def __init__(self, *args: object, name: str | None = None, obj: object = None) -> None: ... - name: str | None - obj: object +if sys.version_info >= (3, 10): + @disjoint_base + class AttributeError(Exception): + def __init__(self, *args: object, name: str | None = None, obj: object = None) -> None: ... + name: str | None + obj: object + +else: + class AttributeError(Exception): ... class BufferError(Exception): ... class EOFError(Exception): ... @@ -2057,10 +2138,14 @@ class ImportError(Exception): class LookupError(Exception): ... class MemoryError(Exception): ... -@disjoint_base -class NameError(Exception): - def __init__(self, *args: object, name: str | None = None) -> None: ... - name: str | None +if sys.version_info >= (3, 10): + @disjoint_base + class NameError(Exception): + def __init__(self, *args: object, name: str | None = None) -> None: ... + name: str | None + +else: + class NameError(Exception): ... class ReferenceError(Exception): ... class RuntimeError(Exception): ... @@ -2076,8 +2161,9 @@ class SyntaxError(Exception): # Errors are displayed differently if this attribute exists on the exception. # The value is always None. print_file_and_line: None - end_lineno: int | None - end_offset: int | None + if sys.version_info >= (3, 10): + end_lineno: int | None + end_offset: int | None @overload def __init__(self) -> None: ... @@ -2086,10 +2172,12 @@ class SyntaxError(Exception): # Second argument is the tuple (filename, lineno, offset, text) @overload def __init__(self, msg: str, info: tuple[str | None, int | None, int | None, str | None], /) -> None: ... - @overload - def __init__( - self, msg: str, info: tuple[str | None, int | None, int | None, str | None, int | None, int | None], / - ) -> None: ... + if sys.version_info >= (3, 10): + # end_lineno and end_offset must both be provided if one is. + @overload + def __init__( + self, msg: str, info: tuple[str | None, int | None, int | None, str | None, int | None, int | None], / + ) -> None: ... # If you provide more than two arguments, it still creates the SyntaxError, but # the arguments from the info tuple are not parsed. This form is omitted. @@ -2165,7 +2253,9 @@ class ImportWarning(Warning): ... class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... class ResourceWarning(Warning): ... -class EncodingWarning(Warning): ... + +if sys.version_info >= (3, 10): + class EncodingWarning(Warning): ... if sys.version_info >= (3, 11): _BaseExceptionT_co = TypeVar("_BaseExceptionT_co", bound=BaseException, covariant=True, default=BaseException) diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index 9660ffd53fbb..7bd829d040cb 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -3,8 +3,8 @@ from _bz2 import BZ2Compressor as BZ2Compressor, BZ2Decompressor as BZ2Decompres from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from collections.abc import Iterable from io import TextIOWrapper -from typing import IO, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only -from typing_extensions import Self +from typing import IO, Literal, Protocol, SupportsIndex, overload, type_check_only +from typing_extensions import Self, TypeAlias if sys.version_info >= (3, 14): from compression._common._streams import BaseStream, _Reader diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index bd4e7a0ca09b..e921584d4390 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -2,8 +2,8 @@ import _lsprof from _typeshed import StrOrBytesPath, Unused from collections.abc import Callable, Mapping from types import CodeType -from typing import Any, TypeAlias, TypeVar -from typing_extensions import ParamSpec, Self +from typing import Any, TypeVar +from typing_extensions import ParamSpec, Self, TypeAlias __all__ = ["run", "runctx", "Profile"] diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 6d5b23e9f645..0d3a0a7490a3 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -4,7 +4,8 @@ import sys from _typeshed import Unused from collections.abc import Iterable, Sequence from time import struct_time -from typing import ClassVar, Final, TypeAlias +from typing import ClassVar, Final +from typing_extensions import TypeAlias __all__ = [ "IllegalMonthError", @@ -33,7 +34,8 @@ __all__ = [ "weekheader", ] -__all__ += ["FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"] +if sys.version_info >= (3, 10): + __all__ += ["FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"] if sys.version_info >= (3, 12): __all__ += [ "Day", diff --git a/stdlib/cmath.pyi b/stdlib/cmath.pyi index 554eb54e2e4c..fdf8ae7bfed8 100644 --- a/stdlib/cmath.pyi +++ b/stdlib/cmath.pyi @@ -1,4 +1,5 @@ -from typing import Final, SupportsComplex, SupportsFloat, SupportsIndex, TypeAlias +from typing import Final, SupportsComplex, SupportsFloat, SupportsIndex +from typing_extensions import TypeAlias e: Final[float] pi: Final[float] diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 26709fa8c3ac..4dfe3fd9e851 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -4,8 +4,8 @@ from _codecs import * from _typeshed import ReadableBuffer from abc import abstractmethod from collections.abc import Callable, Generator, Iterable -from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, TypeAlias, overload, type_check_only -from typing_extensions import Self, deprecated, disjoint_base +from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated, disjoint_base __all__ = [ "register", diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 6e1e143873f8..95f13b0c8dd2 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,22 +1,26 @@ import sys from _collections_abc import dict_items, dict_keys, dict_values from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT -from collections.abc import ( - Callable, - ItemsView, - Iterable, - Iterator, - KeysView, - Mapping, - MutableMapping, - MutableSequence, - Sequence, - ValuesView, -) from types import GenericAlias from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload, type_check_only from typing_extensions import Self, disjoint_base +if sys.version_info >= (3, 10): + from collections.abc import ( + Callable, + ItemsView, + Iterable, + Iterator, + KeysView, + Mapping, + MutableMapping, + MutableSequence, + Sequence, + ValuesView, + ) +else: + from _collections_abc import * + __all__ = ["ChainMap", "Counter", "OrderedDict", "UserDict", "UserList", "UserString", "defaultdict", "deque", "namedtuple"] _S = TypeVar("_S") @@ -301,8 +305,10 @@ class Counter(dict[_T, int], Generic[_T]): def update(self, iterable: None = None, /, **kwargs: int) -> None: ... def __missing__(self, key: _T) -> int: ... def __delitem__(self, elem: object) -> None: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... + if sys.version_info >= (3, 10): + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + def __add__(self, other: Counter[_S]) -> Counter[_T | _S]: ... def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... def __and__(self, other: Counter[_T]) -> Counter[_T]: ... @@ -314,11 +320,12 @@ class Counter(dict[_T, int], Generic[_T]): def __isub__(self, other: SupportsItems[_T, int]) -> Self: ... def __iand__(self, other: SupportsItems[_T, int]) -> Self: ... def __ior__(self, other: SupportsItems[_T, int]) -> Self: ... # type: ignore[override,misc] - def total(self) -> int: ... - def __le__(self, other: Counter[Any]) -> bool: ... - def __lt__(self, other: Counter[Any]) -> bool: ... - def __ge__(self, other: Counter[Any]) -> bool: ... - def __gt__(self, other: Counter[Any]) -> bool: ... + if sys.version_info >= (3, 10): + def total(self) -> int: ... + def __le__(self, other: Counter[Any]) -> bool: ... + def __lt__(self, other: Counter[Any]) -> bool: ... + def __ge__(self, other: Counter[Any]) -> bool: ... + def __gt__(self, other: Counter[Any]) -> bool: ... # The pure-Python implementations of the "views" classes # These are exposed at runtime in `collections/__init__.py` diff --git a/stdlib/compileall.pyi b/stdlib/compileall.pyi index 49a4c69dd3fb..8972d50a4a63 100644 --- a/stdlib/compileall.pyi +++ b/stdlib/compileall.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import StrPath from py_compile import PycInvalidationMode from typing import Any, Protocol, type_check_only @@ -8,38 +9,74 @@ __all__ = ["compile_dir", "compile_file", "compile_path"] class _SupportsSearch(Protocol): def search(self, string: str, /) -> Any: ... -def compile_dir( - dir: StrPath, - maxlevels: int | None = None, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - workers: int = 1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: StrPath | None = None, - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, -) -> bool: ... -def compile_file( - fullname: StrPath, - ddir: StrPath | None = None, - force: bool = False, - rx: _SupportsSearch | None = None, - quiet: int = 0, - legacy: bool = False, - optimize: int = -1, - invalidation_mode: PycInvalidationMode | None = None, - *, - stripdir: StrPath | None = None, - prependdir: StrPath | None = None, - limit_sl_dest: StrPath | None = None, - hardlink_dupes: bool = False, -) -> bool: ... +if sys.version_info >= (3, 10): + def compile_dir( + dir: StrPath, + maxlevels: int | None = None, + ddir: StrPath | None = None, + force: bool = False, + rx: _SupportsSearch | None = None, + quiet: int = 0, + legacy: bool = False, + optimize: int = -1, + workers: int = 1, + invalidation_mode: PycInvalidationMode | None = None, + *, + stripdir: StrPath | None = None, + prependdir: StrPath | None = None, + limit_sl_dest: StrPath | None = None, + hardlink_dupes: bool = False, + ) -> bool: ... + def compile_file( + fullname: StrPath, + ddir: StrPath | None = None, + force: bool = False, + rx: _SupportsSearch | None = None, + quiet: int = 0, + legacy: bool = False, + optimize: int = -1, + invalidation_mode: PycInvalidationMode | None = None, + *, + stripdir: StrPath | None = None, + prependdir: StrPath | None = None, + limit_sl_dest: StrPath | None = None, + hardlink_dupes: bool = False, + ) -> bool: ... + +else: + def compile_dir( + dir: StrPath, + maxlevels: int | None = None, + ddir: StrPath | None = None, + force: bool = False, + rx: _SupportsSearch | None = None, + quiet: int = 0, + legacy: bool = False, + optimize: int = -1, + workers: int = 1, + invalidation_mode: PycInvalidationMode | None = None, + *, + stripdir: str | None = None, # https://bugs.python.org/issue40447 + prependdir: StrPath | None = None, + limit_sl_dest: StrPath | None = None, + hardlink_dupes: bool = False, + ) -> bool: ... + def compile_file( + fullname: StrPath, + ddir: StrPath | None = None, + force: bool = False, + rx: _SupportsSearch | None = None, + quiet: int = 0, + legacy: bool = False, + optimize: int = -1, + invalidation_mode: PycInvalidationMode | None = None, + *, + stripdir: str | None = None, # https://bugs.python.org/issue40447 + prependdir: StrPath | None = None, + limit_sl_dest: StrPath | None = None, + hardlink_dupes: bool = False, + ) -> bool: ... + def compile_path( skip_curdir: bool = ..., maxlevels: int = 0, diff --git a/stdlib/compression/zstd/_zstdfile.pyi b/stdlib/compression/zstd/_zstdfile.pyi index 0c42e99e0d16..d37e6b174166 100644 --- a/stdlib/compression/zstd/_zstdfile.pyi +++ b/stdlib/compression/zstd/_zstdfile.pyi @@ -3,7 +3,8 @@ from collections.abc import Mapping from compression._common import _streams from compression.zstd import ZstdDict from io import TextIOWrapper, _WrappedBuffer -from typing import Literal, Protocol, TypeAlias, overload, type_check_only +from typing import Literal, Protocol, overload, type_check_only +from typing_extensions import TypeAlias from _zstd import ZstdCompressor, _ZstdCompressorFlushBlock, _ZstdCompressorFlushFrame diff --git a/stdlib/concurrent/futures/interpreter.pyi b/stdlib/concurrent/futures/interpreter.pyi index 03c9ad95bd73..e101022babcb 100644 --- a/stdlib/concurrent/futures/interpreter.pyi +++ b/stdlib/concurrent/futures/interpreter.pyi @@ -1,8 +1,8 @@ import sys from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor -from typing import Any, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import ParamSpec, Self, TypeVar, TypeVarTuple, Unpack +from typing import Any, Literal, Protocol, overload, type_check_only +from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, TypeVarTuple, Unpack _Task: TypeAlias = tuple[bytes, Literal["function", "script"]] _Ts = TypeVarTuple("_Ts") diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 7e0bdec8bd5d..50a6a9c6f43e 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -3,8 +3,8 @@ import sys from collections.abc import Callable, Iterable, Mapping, Set as AbstractSet from threading import Lock, Semaphore, Thread from types import GenericAlias -from typing import Any, Generic, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeVarTuple, Unpack +from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack from weakref import ref from ._base import BrokenExecutor, Executor, Future diff --git a/stdlib/concurrent/interpreters/_crossinterp.pyi b/stdlib/concurrent/interpreters/_crossinterp.pyi index 5bb0c7454765..7cf1ea34786e 100644 --- a/stdlib/concurrent/interpreters/_crossinterp.pyi +++ b/stdlib/concurrent/interpreters/_crossinterp.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Callable -from typing import Final, NewType, TypeAlias -from typing_extensions import Never, Self +from typing import Final, NewType +from typing_extensions import Never, Self, TypeAlias if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13 from _interpqueues import _UnboundOp diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 229646907c66..1909d80e3d18 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import MaybeNone, StrOrBytesPath, SupportsWrite from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence from re import Pattern -from typing import Any, ClassVar, Final, Literal, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import deprecated +from typing import Any, ClassVar, Final, Literal, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias, deprecated if sys.version_info >= (3, 14): __all__ = ( diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 24c1b6d976b6..8d5902c46912 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -4,8 +4,8 @@ from _typeshed import FileDescriptorOrPath, Unused from abc import ABC, abstractmethod from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Generator, Iterator from types import TracebackType -from typing import Any, Generic, Protocol, TypeAlias, TypeVar, overload, runtime_checkable, type_check_only -from typing_extensions import ParamSpec, Self, deprecated +from typing import Any, Generic, Protocol, TypeVar, overload, runtime_checkable, type_check_only +from typing_extensions import ParamSpec, Self, TypeAlias, deprecated __all__ = [ "contextmanager", @@ -22,7 +22,8 @@ __all__ = [ "nullcontext", ] -__all__ += ["aclosing"] +if sys.version_info >= (3, 10): + __all__ += ["aclosing"] if sys.version_info >= (3, 11): __all__ += ["chdir"] @@ -93,20 +94,29 @@ def contextmanager(func: Callable[_P, Generator[_T_co, None, object]]) -> Callab ) def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ... -_AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) - -class AsyncContextDecorator: - def _recreate_cm(self) -> Self: ... - def __call__(self, func: _AF) -> _AF: ... - -class _AsyncGeneratorContextManager( - _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], - AbstractAsyncContextManager[_T_co, bool | None], - AsyncContextDecorator, -): - async def __aexit__( - self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool | None: ... +if sys.version_info >= (3, 10): + _AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) + + class AsyncContextDecorator: + def _recreate_cm(self) -> Self: ... + def __call__(self, func: _AF) -> _AF: ... + + class _AsyncGeneratorContextManager( + _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], + AbstractAsyncContextManager[_T_co, bool | None], + AsyncContextDecorator, + ): + async def __aexit__( + self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... + +else: + class _AsyncGeneratorContextManager( + _GeneratorContextManagerBase[AsyncGenerator[_T_co, _SendT_contra]], AbstractAsyncContextManager[_T_co, bool | None] + ): + async def __aexit__( + self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... @overload def asynccontextmanager(func: Callable[_P, AsyncGenerator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ... @@ -126,15 +136,16 @@ class closing(AbstractContextManager[_SupportsCloseT, None]): def __init__(self, thing: _SupportsCloseT) -> None: ... def __exit__(self, *exc_info: Unused) -> None: ... -@type_check_only -class _SupportsAclose(Protocol): - def aclose(self) -> Awaitable[object]: ... +if sys.version_info >= (3, 10): + @type_check_only + class _SupportsAclose(Protocol): + def aclose(self) -> Awaitable[object]: ... -_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) + _SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) -class aclosing(AbstractAsyncContextManager[_SupportsAcloseT, None]): - def __init__(self, thing: _SupportsAcloseT) -> None: ... - async def __aexit__(self, *exc_info: Unused) -> None: ... + class aclosing(AbstractAsyncContextManager[_SupportsAcloseT, None]): + def __init__(self, thing: _SupportsAcloseT) -> None: ... + async def __aexit__(self, *exc_info: Unused) -> None: ... class suppress(AbstractContextManager[None, bool]): def __init__(self, *exceptions: type[BaseException]) -> None: ... @@ -195,16 +206,27 @@ class AsyncExitStack(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta): self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, / ) -> _ExitT_co: ... -class nullcontext(AbstractContextManager[_T, None], AbstractAsyncContextManager[_T, None]): - enter_result: _T - @overload - def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... - @overload - def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 - def __enter__(self) -> _T: ... - def __exit__(self, *exctype: Unused) -> None: ... - async def __aenter__(self) -> _T: ... - async def __aexit__(self, *exctype: Unused) -> None: ... +if sys.version_info >= (3, 10): + class nullcontext(AbstractContextManager[_T, None], AbstractAsyncContextManager[_T, None]): + enter_result: _T + @overload + def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... + @overload + def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 + def __enter__(self) -> _T: ... + def __exit__(self, *exctype: Unused) -> None: ... + async def __aenter__(self) -> _T: ... + async def __aexit__(self, *exctype: Unused) -> None: ... + +else: + class nullcontext(AbstractContextManager[_T, None]): + enter_result: _T + @overload + def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... + @overload + def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 + def __enter__(self) -> _T: ... + def __exit__(self, *exctype: Unused) -> None: ... if sys.version_info >= (3, 11): _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=FileDescriptorOrPath) diff --git a/stdlib/copyreg.pyi b/stdlib/copyreg.pyi index 3bfc0de8158f..8f7fd957fc52 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Hashable -from typing import Any, SupportsInt, TypeAlias, TypeVar +from typing import Any, SupportsInt, TypeVar +from typing_extensions import TypeAlias _T = TypeVar("_T") _Reduce: TypeAlias = tuple[Callable[..., _T], tuple[Any, ...]] | tuple[Callable[..., _T], tuple[Any, ...], Any | None] diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 24c1c54bba5a..2c8e7109cdfc 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -19,7 +19,11 @@ from _csv import ( if sys.version_info >= (3, 12): from _csv import QUOTE_NOTNULL as QUOTE_NOTNULL, QUOTE_STRINGS as QUOTE_STRINGS -from _csv import Reader, Writer +if sys.version_info >= (3, 10): + from _csv import Reader, Writer +else: + from _csv import _reader as Reader, _writer as Writer + from _typeshed import SupportsWrite from collections.abc import Collection, Iterable, Mapping, Sequence from types import GenericAlias diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 04809e838c14..8d048aa97e7d 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -26,8 +26,8 @@ from _ctypes import ( from _typeshed import StrPath, SupportsBool, SupportsLen from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure from types import GenericAlias -from typing import Any, ClassVar, Final, Generic, Literal, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated if sys.platform == "win32": from _ctypes import FormatError as FormatError, get_last_error as get_last_error, set_last_error as set_last_error diff --git a/stdlib/ctypes/wintypes.pyi b/stdlib/ctypes/wintypes.pyi index b94c5e74148a..0f0d61a396d5 100644 --- a/stdlib/ctypes/wintypes.pyi +++ b/stdlib/ctypes/wintypes.pyi @@ -21,8 +21,8 @@ from ctypes import ( c_wchar, c_wchar_p, ) -from typing import Any, Final, TypeAlias, TypeVar -from typing_extensions import Self +from typing import Any, Final, TypeVar +from typing_extensions import Self, TypeAlias if sys.version_info >= (3, 12): from ctypes import c_ubyte diff --git a/stdlib/curses/__init__.pyi b/stdlib/curses/__init__.pyi index 5463baeba091..3e32487ad99f 100644 --- a/stdlib/curses/__init__.pyi +++ b/stdlib/curses/__init__.pyi @@ -1,9 +1,10 @@ +import sys from _curses import * from _curses import window as window from _typeshed import structseq from collections.abc import Callable -from typing import Concatenate, Final, TypeVar, final, type_check_only -from typing_extensions import ParamSpec +from typing import Final, TypeVar, final, type_check_only +from typing_extensions import Concatenate, ParamSpec # NOTE: The _curses module is ordinarily only available on Unix, but the # windows-curses package makes it available on Windows as well with the same @@ -29,7 +30,8 @@ def wrapper(func: Callable[Concatenate[window, _P], _T], /, *arg: _P.args, **kwd @final @type_check_only class _ncurses_version(structseq[int], tuple[int, int, int]): - __match_args__: Final = ("major", "minor", "patch") + if sys.version_info >= (3, 10): + __match_args__: Final = ("major", "minor", "patch") @property def major(self) -> int: ... diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 841f5d743845..3a1c8cb5d62d 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -26,7 +26,8 @@ __all__ = [ "is_dataclass", ] -__all__ += ["KW_ONLY"] +if sys.version_info >= (3, 10): + __all__ += ["KW_ONLY"] _DataclassT = TypeVar("_DataclassT", bound=DataclassInstance) @@ -59,7 +60,8 @@ class _MISSING_TYPE(enum.Enum): MISSING: Final = _MISSING_TYPE.MISSING -class KW_ONLY: ... +if sys.version_info >= (3, 10): + class KW_ONLY: ... @overload def asdict(obj: DataclassInstance) -> dict[str, Any]: ... @@ -104,7 +106,7 @@ if sys.version_info >= (3, 11): weakref_slot: bool = False, ) -> Callable[[type[_T]], type[_T]]: ... -else: +elif sys.version_info >= (3, 10): @overload def dataclass( cls: type[_T], @@ -136,6 +138,32 @@ else: slots: bool = False, ) -> Callable[[type[_T]], type[_T]]: ... +else: + @overload + def dataclass( + cls: type[_T], + /, + *, + init: bool = True, + repr: bool = True, + eq: bool = True, + order: bool = False, + unsafe_hash: bool = False, + frozen: bool = False, + ) -> type[_T]: ... + @overload + def dataclass( + cls: None = None, + /, + *, + init: bool = True, + repr: bool = True, + eq: bool = True, + order: bool = False, + unsafe_hash: bool = False, + frozen: bool = False, + ) -> Callable[[type[_T]], type[_T]]: ... + # See https://github.com/python/mypy/issues/10750 @type_check_only class _DefaultFactory(Protocol[_T_co]): @@ -157,7 +185,7 @@ class Field(Generic[_T]): "doc", "_field_type", ) - else: + elif sys.version_info >= (3, 10): __slots__ = ( "name", "type", @@ -171,6 +199,8 @@ class Field(Generic[_T]): "kw_only", "_field_type", ) + else: + __slots__ = ("name", "type", "default", "default_factory", "repr", "hash", "init", "compare", "metadata", "_field_type") name: str type: Type[_T] | str | Any default: _T | Literal[_MISSING_TYPE.MISSING] @@ -184,7 +214,8 @@ class Field(Generic[_T]): if sys.version_info >= (3, 14): doc: str | None - kw_only: bool | Literal[_MISSING_TYPE.MISSING] + if sys.version_info >= (3, 10): + kw_only: bool | Literal[_MISSING_TYPE.MISSING] if sys.version_info >= (3, 14): def __init__( @@ -199,7 +230,7 @@ class Field(Generic[_T]): kw_only: bool, doc: str | None, ) -> None: ... - else: + elif sys.version_info >= (3, 10): def __init__( self, default: _T, @@ -211,6 +242,17 @@ class Field(Generic[_T]): metadata: Mapping[Any, Any], kw_only: bool, ) -> None: ... + else: + def __init__( + self, + default: _T, + default_factory: Callable[[], _T], + init: bool, + repr: bool, + hash: bool | None, + compare: bool, + metadata: Mapping[Any, Any], + ) -> None: ... def __set_name__(self, owner: Type[Any], name: str) -> None: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... @@ -258,7 +300,7 @@ if sys.version_info >= (3, 14): doc: str | None = None, ) -> Any: ... -else: +elif sys.version_info >= (3, 10): @overload # `default` and `default_factory` are optional and mutually exclusive. def field( *, @@ -296,6 +338,41 @@ else: kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ..., ) -> Any: ... +else: + @overload # `default` and `default_factory` are optional and mutually exclusive. + def field( + *, + default: _T, + default_factory: Literal[_MISSING_TYPE.MISSING] = ..., + init: bool = True, + repr: bool = True, + hash: bool | None = None, + compare: bool = True, + metadata: Mapping[Any, Any] | None = None, + ) -> _T: ... + @overload + def field( + *, + default: Literal[_MISSING_TYPE.MISSING] = ..., + default_factory: Callable[[], _T], + init: bool = True, + repr: bool = True, + hash: bool | None = None, + compare: bool = True, + metadata: Mapping[Any, Any] | None = None, + ) -> _T: ... + @overload + def field( + *, + default: Literal[_MISSING_TYPE.MISSING] = ..., + default_factory: Literal[_MISSING_TYPE.MISSING] = ..., + init: bool = True, + repr: bool = True, + hash: bool | None = None, + compare: bool = True, + metadata: Mapping[Any, Any] | None = None, + ) -> Any: ... + def fields(class_or_instance: DataclassInstance | type[DataclassInstance]) -> tuple[Field[Any], ...]: ... # HACK: `obj: Never` typing matches if object argument is using `Any` type. @@ -377,7 +454,7 @@ elif sys.version_info >= (3, 11): weakref_slot: bool = False, ) -> type: ... -else: +elif sys.version_info >= (3, 10): def make_dataclass( cls_name: str, fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]], @@ -395,4 +472,19 @@ else: slots: bool = False, ) -> type: ... +else: + def make_dataclass( + cls_name: str, + fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]], + *, + bases: tuple[type, ...] = (), + namespace: dict[str, Any] | None = None, + init: bool = True, + repr: bool = True, + eq: bool = True, + order: bool = False, + unsafe_hash: bool = False, + frozen: bool = False, + ) -> type: ... + def replace(obj: _DataclassT, /, **changes: Any) -> _DataclassT: ... diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 225f95da4f6f..8a0536c006d5 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -1,8 +1,8 @@ import sys from abc import abstractmethod from time import struct_time -from typing import ClassVar, Final, NoReturn, SupportsIndex, TypeAlias, final, overload, type_check_only -from typing_extensions import CapsuleType, Self, deprecated, disjoint_base +from typing import ClassVar, Final, NoReturn, SupportsIndex, final, overload, type_check_only +from typing_extensions import CapsuleType, Self, TypeAlias, deprecated, disjoint_base if sys.version_info >= (3, 11): __all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR", "UTC") diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 0871381e8ec0..7cbb63cf2f06 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import StrOrBytesPath from collections.abc import Iterator, MutableMapping from types import TracebackType -from typing import Literal, TypeAlias, type_check_only -from typing_extensions import Self +from typing import Literal, type_check_only +from typing_extensions import Self, TypeAlias __all__ = ["open", "whichdb", "error"] diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index fccca484a026..1c0b7756f292 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -2,8 +2,7 @@ import sys from _typeshed import StrOrBytesPath from collections.abc import Iterator, MutableMapping from types import TracebackType -from typing import TypeAlias -from typing_extensions import Self +from typing_extensions import Self, TypeAlias __all__ = ["error", "open"] diff --git a/stdlib/dbm/sqlite3.pyi b/stdlib/dbm/sqlite3.pyi index 43d8c96895dd..e2fba93b2001 100644 --- a/stdlib/dbm/sqlite3.pyi +++ b/stdlib/dbm/sqlite3.pyi @@ -1,7 +1,7 @@ from _typeshed import ReadableBuffer, StrOrBytesPath, Unused from collections.abc import Generator, MutableMapping -from typing import Final, Literal, TypeAlias -from typing_extensions import LiteralString, Self +from typing import Final, Literal +from typing_extensions import LiteralString, Self, TypeAlias BUILD_TABLE: Final[LiteralString] GET_SIZE: Final[LiteralString] diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index e5c9360ada15..2e06c2d1b724 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -26,8 +26,8 @@ from _decimal import ( ) from collections.abc import Container, Sequence from types import TracebackType -from typing import Any, ClassVar, Literal, NamedTuple, TypeAlias, final, overload, type_check_only -from typing_extensions import Self, disjoint_base +from typing import Any, ClassVar, Literal, NamedTuple, final, overload, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base if sys.version_info >= (3, 14): from _decimal import IEEE_CONTEXT_MAX_BITS as IEEE_CONTEXT_MAX_BITS, IEEEContext as IEEEContext diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index 984f932e3311..52794a588ca8 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -2,8 +2,8 @@ import sys import types from collections.abc import Callable, Iterator from opcode import * # `dis` re-exports it as a part of public API -from typing import IO, Any, Final, NamedTuple, TypeAlias, overload -from typing_extensions import Self, deprecated, disjoint_base +from typing import IO, Any, Final, NamedTuple, overload +from typing_extensions import Self, TypeAlias, deprecated, disjoint_base __all__ = [ "code_info", diff --git a/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index ef81e807a5db..5bff209807ee 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,8 +1,8 @@ from _typeshed import BytesPath, StrPath, Unused from collections.abc import Callable, Iterable, Sequence from distutils.file_util import _BytesPathT, _StrPathT -from typing import Literal, TypeAlias, overload -from typing_extensions import TypeVarTuple, Unpack +from typing import Literal, overload +from typing_extensions import TypeAlias, TypeVarTuple, Unpack _Macro: TypeAlias = tuple[str] | tuple[str, str | None] _Ts = TypeVarTuple("_Ts") diff --git a/stdlib/distutils/command/__init__.pyi b/stdlib/distutils/command/__init__.pyi index 856c5eb8b44a..4d7372858af3 100644 --- a/stdlib/distutils/command/__init__.pyi +++ b/stdlib/distutils/command/__init__.pyi @@ -1,3 +1,5 @@ +import sys + from . import ( bdist, bdist_dumb, @@ -39,3 +41,8 @@ __all__ = [ "check", "upload", ] + +if sys.version_info < (3, 10): + from . import bdist_wininst + + __all__ += ["bdist_wininst"] diff --git a/stdlib/distutils/command/check.pyi b/stdlib/distutils/command/check.pyi index f2034e6555fc..2c807fd2c439 100644 --- a/stdlib/distutils/command/check.pyi +++ b/stdlib/distutils/command/check.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete -from typing import Any, ClassVar, Final, Literal, TypeAlias +from typing import Any, ClassVar, Final, Literal +from typing_extensions import TypeAlias from ..cmd import Command diff --git a/stdlib/distutils/command/install.pyi b/stdlib/distutils/command/install.pyi index 7e11cf257c2c..1714e01a2c28 100644 --- a/stdlib/distutils/command/install.pyi +++ b/stdlib/distutils/command/install.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import Incomplete from collections.abc import Callable from typing import Any, ClassVar, Final, Literal @@ -9,6 +10,9 @@ HAS_USER_SITE: Final[bool] SCHEME_KEYS: Final[tuple[Literal["purelib"], Literal["platlib"], Literal["headers"], Literal["scripts"], Literal["data"]]] INSTALL_SCHEMES: Final[dict[str, dict[str, str]]] +if sys.version_info < (3, 10): + WINDOWS_SCHEME: Final[dict[str, str]] + class install(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index b4283c9a013c..412b94131b54 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -22,7 +22,8 @@ from distutils.command.register import register from distutils.command.sdist import sdist from distutils.command.upload import upload from re import Pattern -from typing import IO, ClassVar, Literal, TypeAlias, TypeVar, overload +from typing import IO, ClassVar, Literal, TypeVar, overload +from typing_extensions import TypeAlias command_re: Pattern[str] diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index 29c052365628..f3fa2a1255a6 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,7 +1,8 @@ from collections.abc import Iterable, Mapping from getopt import _SliceableT, _StrSequenceT_co from re import Pattern -from typing import Any, Final, TypeAlias, overload +from typing import Any, Final, overload +from typing_extensions import TypeAlias _Option: TypeAlias = tuple[str, str | None, str] diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index 0ed567b98d74..4a9c45eb562a 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -1,3 +1,4 @@ +import sys from collections.abc import Mapping from distutils.ccompiler import CCompiler from typing import Final, Literal, overload @@ -27,3 +28,6 @@ def get_python_lib( plat_specific: bool | Literal[0, 1] = 0, standard_lib: bool | Literal[0, 1] = 0, prefix: str | None = None ) -> str: ... def customize_compiler(compiler: CCompiler) -> None: ... + +if sys.version_info < (3, 10): + def get_python_version() -> str: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 32c68e3f2c7b..1bb96e1a7786 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -3,8 +3,8 @@ import types import unittest from _typeshed import ExcInfo from collections.abc import Callable -from typing import Any, Final, NamedTuple, TypeAlias, type_check_only -from typing_extensions import Self +from typing import Any, Final, NamedTuple, type_check_only +from typing_extensions import Self, TypeAlias __all__ = [ "register_optionflag", diff --git a/stdlib/email/__init__.pyi b/stdlib/email/__init__.pyi index 7aa977709b05..53f8c350b01e 100644 --- a/stdlib/email/__init__.pyi +++ b/stdlib/email/__init__.pyi @@ -2,7 +2,8 @@ from collections.abc import Callable from email._policybase import _MessageT from email.message import Message from email.policy import Policy -from typing import IO, TypeAlias, overload +from typing import IO, overload +from typing_extensions import TypeAlias # At runtime, listing submodules in __all__ without them being imported is # valid, and causes them to be included in a star import. See #6523 diff --git a/stdlib/email/errors.pyi b/stdlib/email/errors.pyi index 4da60250965e..b501a5866556 100644 --- a/stdlib/email/errors.pyi +++ b/stdlib/email/errors.pyi @@ -1,3 +1,5 @@ +import sys + class MessageError(Exception): ... class MessageParseError(MessageError): ... class HeaderParseError(MessageParseError): ... @@ -35,4 +37,6 @@ class NonPrintableDefect(HeaderDefect): class ObsoleteHeaderDefect(HeaderDefect): ... class NonASCIILocalPartDefect(HeaderDefect): ... -class InvalidDateDefect(HeaderDefect): ... + +if sys.version_info >= (3, 10): + class InvalidDateDefect(HeaderDefect): ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index 08fcb121dd07..794882b140e6 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -5,8 +5,8 @@ from email.charset import Charset from email.contentmanager import ContentManager from email.errors import MessageDefect from email.policy import Policy -from typing import Any, Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias __all__ = ["Message", "EmailMessage"] diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index 4b314b9d056c..cece2f2a1119 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -4,8 +4,8 @@ from _typeshed import Unused from collections.abc import Iterable from email import _ParamType from email.charset import Charset -from typing import TypeAlias, overload -from typing_extensions import deprecated +from typing import overload +from typing_extensions import TypeAlias, deprecated __all__ = [ "collapse_rfc2231_value", diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index afb6961b9594..f9b53e1d45f1 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -4,8 +4,8 @@ import types from _typeshed import SupportsKeysAndGetItem, Unused from builtins import property as _builtins_property from collections.abc import Callable, Iterable, Iterator, Mapping -from typing import Any, Final, Generic, Literal, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import Self, disjoint_base +from typing import Any, Final, Generic, Literal, SupportsIndex, TypeVar, overload +from typing_extensions import Self, TypeAlias, disjoint_base __all__ = ["EnumMeta", "Enum", "IntEnum", "Flag", "IntFlag", "auto", "unique"] @@ -114,8 +114,10 @@ class EnumMeta(type): def __contains__(self: type[Any], value: object) -> bool: ... elif sys.version_info >= (3, 11): def __contains__(self: type[Any], member: object) -> bool: ... - else: + elif sys.version_info >= (3, 10): def __contains__(self: type[Any], obj: object) -> bool: ... + else: + def __contains__(self: type[Any], member: object) -> bool: ... def __getitem__(self: type[_EnumMemberT], name: str) -> _EnumMemberT: ... @_builtins_property diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index b7f8bbe13f3e..5a3e89b0c676 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -46,8 +46,9 @@ if sys.platform != "win32": F_OFD_SETLK: Final[int] F_OFD_SETLKW: Final[int] - F_GETPIPE_SZ: Final[int] - F_SETPIPE_SZ: Final[int] + if sys.version_info >= (3, 10): + F_GETPIPE_SZ: Final[int] + F_SETPIPE_SZ: Final[int] DN_ACCESS: Final[int] DN_ATTRIB: Final[int] diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index c022377aff8d..6778b764810b 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import AnyStr_co, StrOrBytesPath from collections.abc import Callable, Iterable from types import GenericAlias, TracebackType -from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated __all__ = [ "input", @@ -30,52 +30,10 @@ class _HasReadlineAndFileno(Protocol[AnyStr_co]): def readline(self) -> AnyStr_co: ... def fileno(self) -> int: ... -@overload -def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: _TextMode = "r", - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, - encoding: str | None = None, - errors: str | None = None, -) -> FileInput[str]: ... -@overload -def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: Literal["rb"], - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, - encoding: None = None, - errors: None = None, -) -> FileInput[bytes]: ... -@overload -def input( - files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, - inplace: bool = False, - backup: str = "", - *, - mode: str, - openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, - encoding: str | None = None, - errors: str | None = None, -) -> FileInput[Any]: ... -def close() -> None: ... -def nextfile() -> None: ... -def filename() -> str: ... -def lineno() -> int: ... -def filelineno() -> int: ... -def fileno() -> int: ... -def isfirstline() -> bool: ... -def isstdin() -> bool: ... - -class FileInput(Generic[AnyStr]): +if sys.version_info >= (3, 10): + # encoding and errors are added @overload - def __init__( - self: FileInput[str], + def input( files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -84,10 +42,9 @@ class FileInput(Generic[AnyStr]): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, encoding: str | None = None, errors: str | None = None, - ) -> None: ... + ) -> FileInput[str]: ... @overload - def __init__( - self: FileInput[bytes], + def input( files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -96,10 +53,9 @@ class FileInput(Generic[AnyStr]): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, encoding: None = None, errors: None = None, - ) -> None: ... + ) -> FileInput[bytes]: ... @overload - def __init__( - self: FileInput[Any], + def input( files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, inplace: bool = False, backup: str = "", @@ -108,7 +64,120 @@ class FileInput(Generic[AnyStr]): openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, encoding: str | None = None, errors: str | None = None, - ) -> None: ... + ) -> FileInput[Any]: ... + +else: + # bufsize is dropped and mode and openhook become keyword-only + @overload + def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: _TextMode = "r", + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, + ) -> FileInput[str]: ... + @overload + def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: Literal["rb"], + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, + ) -> FileInput[bytes]: ... + @overload + def input( + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: str, + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, + ) -> FileInput[Any]: ... + +def close() -> None: ... +def nextfile() -> None: ... +def filename() -> str: ... +def lineno() -> int: ... +def filelineno() -> int: ... +def fileno() -> int: ... +def isfirstline() -> bool: ... +def isstdin() -> bool: ... + +class FileInput(Generic[AnyStr]): + if sys.version_info >= (3, 10): + # encoding and errors are added + @overload + def __init__( + self: FileInput[str], + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: _TextMode = "r", + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, + encoding: str | None = None, + errors: str | None = None, + ) -> None: ... + @overload + def __init__( + self: FileInput[bytes], + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: Literal["rb"], + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, + encoding: None = None, + errors: None = None, + ) -> None: ... + @overload + def __init__( + self: FileInput[Any], + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: str, + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, + encoding: str | None = None, + errors: str | None = None, + ) -> None: ... + + else: + # bufsize is dropped and mode and openhook become keyword-only + @overload + def __init__( + self: FileInput[str], + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: _TextMode = "r", + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None, + ) -> None: ... + @overload + def __init__( + self: FileInput[bytes], + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: Literal["rb"], + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None, + ) -> None: ... + @overload + def __init__( + self: FileInput[Any], + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None, + inplace: bool = False, + backup: str = "", + *, + mode: str, + openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None, + ) -> None: ... + def __del__(self) -> None: ... def close(self) -> None: ... def __enter__(self) -> Self: ... @@ -130,8 +199,17 @@ class FileInput(Generic[AnyStr]): def isstdin(self) -> bool: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... -def hook_compressed( - filename: StrOrBytesPath, mode: str, *, encoding: str | None = None, errors: str | None = None -) -> IO[Any]: ... -@deprecated("Deprecated since Python 3.10. Use `fileinput.input` or `fileinput.FileInput` instead.") -def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... +if sys.version_info >= (3, 10): + def hook_compressed( + filename: StrOrBytesPath, mode: str, *, encoding: str | None = None, errors: str | None = None + ) -> IO[Any]: ... + +else: + def hook_compressed(filename: StrOrBytesPath, mode: str) -> IO[Any]: ... + +if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10. Use `fileinput.input` or `fileinput.FileInput` instead.") + def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... + +else: + def hook_encoded(encoding: str, errors: str | None = None) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... diff --git a/stdlib/formatter.pyi b/stdlib/formatter.pyi index e6401b37a57e..05c3c8b3dd41 100644 --- a/stdlib/formatter.pyi +++ b/stdlib/formatter.pyi @@ -1,5 +1,6 @@ from collections.abc import Iterable -from typing import IO, Any, TypeAlias +from typing import IO, Any +from typing_extensions import TypeAlias AS_IS: None _FontType: TypeAlias = tuple[str, bool, bool, bool] diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index ad0a187bb472..ef4066aa65b5 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -2,8 +2,8 @@ import sys from collections.abc import Callable from decimal import Decimal from numbers import Rational, Real -from typing import Any, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only -from typing_extensions import Self +from typing import Any, Literal, Protocol, SupportsIndex, overload, type_check_only +from typing_extensions import Self, TypeAlias _ComparableNum: TypeAlias = int | float | Decimal | Real diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 5808cd842553..57bc3f179f7a 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -3,8 +3,8 @@ import types from _typeshed import SupportsAllComparisons, SupportsItems from collections.abc import Callable, Hashable, Iterable, Sized from types import GenericAlias -from typing import Any, Final, Generic, Literal, NamedTuple, TypeAlias, TypedDict, TypeVar, final, overload, type_check_only -from typing_extensions import ParamSpec, Self, disjoint_base +from typing import Any, Final, Generic, Literal, NamedTuple, TypedDict, TypeVar, final, overload, type_check_only +from typing_extensions import ParamSpec, Self, TypeAlias, disjoint_base __all__ = [ "update_wrapper", diff --git a/stdlib/gc.pyi b/stdlib/gc.pyi index dc20a570cc89..ec1ed2681c5c 100644 --- a/stdlib/gc.pyi +++ b/stdlib/gc.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Any, Final, Literal, TypeAlias +from typing import Any, Final, Literal +from typing_extensions import TypeAlias DEBUG_COLLECTABLE: Final = 2 DEBUG_LEAK: Final = 38 diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index 07455acaefc6..942fd7396196 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -9,14 +9,19 @@ __all__ = ["escape", "glob", "iglob"] if sys.version_info >= (3, 13): __all__ += ["translate"] -@deprecated( - "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." -) -def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... -@deprecated( - "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." -) -def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... +if sys.version_info >= (3, 10): + @deprecated( + "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." + ) + def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... + @deprecated( + "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead." + ) + def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... + +else: + def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... + def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ... if sys.version_info >= (3, 11): def glob( @@ -36,7 +41,7 @@ if sys.version_info >= (3, 11): include_hidden: bool = False, ) -> Iterator[AnyStr]: ... -else: +elif sys.version_info >= (3, 10): def glob( pathname: AnyStr, *, root_dir: StrOrBytesPath | None = None, dir_fd: int | None = None, recursive: bool = False ) -> list[AnyStr]: ... @@ -44,6 +49,10 @@ else: pathname: AnyStr, *, root_dir: StrOrBytesPath | None = None, dir_fd: int | None = None, recursive: bool = False ) -> Iterator[AnyStr]: ... +else: + def glob(pathname: AnyStr, *, recursive: bool = False) -> list[AnyStr]: ... + def iglob(pathname: AnyStr, *, recursive: bool = False) -> Iterator[AnyStr]: ... + def escape(pathname: AnyStr) -> AnyStr: ... def has_magic(s: str | bytes) -> bool: ... # undocumented diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 9f372b4d63dc..965ecece2a56 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -5,7 +5,8 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_group(structseq[Any], tuple[str, str | None, int, list[str]]): - __match_args__: Final = ("gr_name", "gr_passwd", "gr_gid", "gr_mem") + if sys.version_info >= (3, 10): + __match_args__: Final = ("gr_name", "gr_passwd", "gr_gid", "gr_mem") @property def gr_name(self) -> str: ... diff --git a/stdlib/gzip.pyi b/stdlib/gzip.pyi index de22625e403f..b18f76f06e3e 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -2,8 +2,8 @@ import sys import zlib from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, WriteableBuffer from io import FileIO, TextIOWrapper -from typing import Final, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import deprecated +from typing import Final, Literal, Protocol, overload, type_check_only +from typing_extensions import TypeAlias, deprecated if sys.version_info >= (3, 14): from compression._common._streams import BaseStream, DecompressReader diff --git a/stdlib/hmac.pyi b/stdlib/hmac.pyi index 9beabcc4dd92..070c59b1c166 100644 --- a/stdlib/hmac.pyi +++ b/stdlib/hmac.pyi @@ -2,7 +2,8 @@ from _hashlib import _HashObject, compare_digest as compare_digest from _typeshed import ReadableBuffer, SizedBuffer from collections.abc import Callable from types import ModuleType -from typing import TypeAlias, overload +from typing import overload +from typing_extensions import TypeAlias _DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 2af9769d3c36..699ef0e4c6d6 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -7,8 +7,8 @@ from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath, SupportsRead, S from collections.abc import Callable, Iterable, Iterator, Mapping from email._policybase import _MessageT from socket import socket -from typing import BinaryIO, Final, TypeAlias, TypeVar, overload -from typing_extensions import Self, deprecated +from typing import BinaryIO, Final, TypeVar, overload +from typing_extensions import Self, TypeAlias, deprecated __all__ = [ "HTTPResponse", diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index f21c7d6dd832..31e1d3fc8378 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import StrPath from collections.abc import Iterator, Sequence from http.client import HTTPResponse @@ -48,7 +49,9 @@ class FileCookieJar(CookieJar): def load(self, filename: str | None = None, ignore_discard: bool = False, ignore_expires: bool = False) -> None: ... def revert(self, filename: str | None = None, ignore_discard: bool = False, ignore_expires: bool = False) -> None: ... -class MozillaCookieJar(FileCookieJar): ... # undocumented +class MozillaCookieJar(FileCookieJar): + if sys.version_info < (3, 10): + header: ClassVar[str] # undocumented class LWPCookieJar(FileCookieJar): def as_lwp_str(self, ignore_discard: bool = True, ignore_expires: bool = True) -> str: ... # undocumented diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 317cd4fa8518..eadf054c3a5f 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,7 +1,8 @@ from _typeshed import MaybeNone from collections.abc import Iterable, Mapping from types import GenericAlias -from typing import Any, Generic, TypeAlias, TypeVar, overload +from typing import Any, Generic, TypeVar, overload +from typing_extensions import TypeAlias __all__ = ["CookieError", "BaseCookie", "SimpleCookie"] diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 5a7443604f0a..94b96f0a1283 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -9,8 +9,8 @@ from re import Pattern from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Literal, SupportsAbs, SupportsInt, TypeAlias, overload -from typing_extensions import Self, deprecated +from typing import IO, Any, Literal, SupportsAbs, SupportsInt, overload +from typing_extensions import Self, TypeAlias, deprecated __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"] diff --git a/stdlib/importlib/_abc.pyi b/stdlib/importlib/_abc.pyi index e8c80c0447ae..90ab34021917 100644 --- a/stdlib/importlib/_abc.pyi +++ b/stdlib/importlib/_abc.pyi @@ -4,16 +4,17 @@ from abc import ABCMeta from importlib.machinery import ModuleSpec from typing_extensions import deprecated -class Loader(metaclass=ABCMeta): - def load_module(self, fullname: str) -> types.ModuleType: ... - if sys.version_info < (3, 12): - @deprecated( - "Deprecated since Python 3.4; removed in Python 3.12. " - "The module spec is now used by the import machinery to generate a module repr." - ) - def module_repr(self, module: types.ModuleType) -> str: ... +if sys.version_info >= (3, 10): + class Loader(metaclass=ABCMeta): + def load_module(self, fullname: str) -> types.ModuleType: ... + if sys.version_info < (3, 12): + @deprecated( + "Deprecated since Python 3.4; removed in Python 3.12. " + "The module spec is now used by the import machinery to generate a module repr." + ) + def module_repr(self, module: types.ModuleType) -> str: ... - def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... - # Not defined on the actual class for backwards-compatibility reasons, - # but expected in new code. - def exec_module(self, module: types.ModuleType) -> None: ... + def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... + # Not defined on the actual class for backwards-compatibility reasons, + # but expected in new code. + def exec_module(self, module: types.ModuleType) -> None: ... diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 01188c394960..ef7761f7119b 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -25,7 +25,16 @@ if sys.version_info >= (3, 11): if sys.version_info < (3, 12): __all__ += ["Finder", "ResourceReader", "Traversable", "TraversableResources"] -from importlib._abc import Loader as Loader +if sys.version_info >= (3, 10): + from importlib._abc import Loader as Loader +else: + class Loader(metaclass=ABCMeta): + def load_module(self, fullname: str) -> types.ModuleType: ... + def module_repr(self, module: types.ModuleType) -> str: ... + def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... + # Not defined on the actual class for backwards-compatibility reasons, + # but expected in new code. + def exec_module(self, module: types.ModuleType) -> None: ... if sys.version_info < (3, 12): @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use `MetaPathFinder` or `PathEntryFinder` instead.") @@ -59,27 +68,46 @@ class SourceLoader(_bootstrap_external.SourceLoader, ResourceLoader, ExecutionLo def path_stats(self, path: str) -> Mapping[str, Any]: ... # The base classes differ starting in 3.10: -class MetaPathFinder(metaclass=ABCMeta): - if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `MetaPathFinder.find_spec()` instead.") +if sys.version_info >= (3, 10): + # Please keep in sync with _typeshed.importlib.MetaPathFinderProtocol + class MetaPathFinder(metaclass=ABCMeta): + if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `MetaPathFinder.find_spec()` instead.") + def find_module(self, fullname: str, path: Sequence[str] | None) -> Loader | None: ... + + def invalidate_caches(self) -> None: ... + # Not defined on the actual class, but expected to exist. + def find_spec( + self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / + ) -> ModuleSpec | None: ... + + class PathEntryFinder(metaclass=ABCMeta): + if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `PathEntryFinder.find_spec()` instead.") + def find_module(self, fullname: str) -> Loader | None: ... + @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") + def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[str]]: ... + + def invalidate_caches(self) -> None: ... + # Not defined on the actual class, but expected to exist. + def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... + +else: + # Please keep in sync with _typeshed.importlib.MetaPathFinderProtocol + class MetaPathFinder(Finder): def find_module(self, fullname: str, path: Sequence[str] | None) -> Loader | None: ... + def invalidate_caches(self) -> None: ... + # Not defined on the actual class, but expected to exist. + def find_spec( + self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / + ) -> ModuleSpec | None: ... - def invalidate_caches(self) -> None: ... - # Not defined on the actual class, but expected to exist. - def find_spec( - self, fullname: str, path: Sequence[str] | None, target: types.ModuleType | None = ..., / - ) -> ModuleSpec | None: ... - -class PathEntryFinder(metaclass=ABCMeta): - if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `PathEntryFinder.find_spec()` instead.") + class PathEntryFinder(Finder): def find_module(self, fullname: str) -> Loader | None: ... - @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.") def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[str]]: ... - - def invalidate_caches(self) -> None: ... - # Not defined on the actual class, but expected to exist. - def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... + def invalidate_caches(self) -> None: ... + # Not defined on the actual class, but expected to exist. + def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... class FileLoader(_bootstrap_external.FileLoader, ResourceLoader, ExecutionLoader, metaclass=ABCMeta): name: str @@ -95,8 +123,13 @@ if sys.version_info < (3, 11): def open_resource(self, resource: str) -> IO[bytes]: ... @abstractmethod def resource_path(self, resource: str) -> str: ... - @abstractmethod - def is_resource(self, path: str) -> bool: ... + if sys.version_info >= (3, 10): + @abstractmethod + def is_resource(self, path: str) -> bool: ... + else: + @abstractmethod + def is_resource(self, name: str) -> bool: ... + @abstractmethod def contents(self) -> Iterator[str]: ... @@ -127,7 +160,12 @@ if sys.version_info < (3, 11): @property @abstractmethod def name(self) -> str: ... - def __truediv__(self, child: str, /) -> Traversable: ... + if sys.version_info >= (3, 10): + def __truediv__(self, child: str, /) -> Traversable: ... + else: + @abstractmethod + def __truediv__(self, child: str, /) -> Traversable: ... + @abstractmethod def read_bytes(self) -> bytes: ... @abstractmethod diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index d994d68c05fa..9286e92331c8 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -5,11 +5,13 @@ import types from _collections_abc import dict_keys, dict_values from _typeshed import StrPath from collections.abc import Iterable, Iterator, Mapping +from email.message import Message from importlib.abc import MetaPathFinder from os import PathLike +from pathlib import Path from re import Pattern -from typing import Any, ClassVar, Generic, NamedTuple, TypeAlias, TypeVar, overload -from typing_extensions import Self, deprecated, disjoint_base +from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload +from typing_extensions import Self, TypeAlias, deprecated, disjoint_base _T = TypeVar("_T") _KT = TypeVar("_KT") @@ -28,13 +30,17 @@ __all__ = [ "version", ] -__all__ += ["PackageMetadata", "packages_distributions"] +if sys.version_info >= (3, 10): + __all__ += ["PackageMetadata", "packages_distributions"] -from importlib.metadata._meta import PackageMetadata as PackageMetadata, SimplePath +if sys.version_info >= (3, 10): + from importlib.metadata._meta import PackageMetadata as PackageMetadata, SimplePath + def packages_distributions() -> Mapping[str, list[str]]: ... -def packages_distributions() -> Mapping[str, list[str]]: ... + _SimplePath: TypeAlias = SimplePath -_SimplePath: TypeAlias = SimplePath +else: + _SimplePath: TypeAlias = Path class PackageNotFoundError(ModuleNotFoundError): @property @@ -97,17 +103,19 @@ else: def module(self) -> str: ... @property def attr(self) -> str: ... - dist: ClassVar[Distribution | None] - def matches( - self, - *, - name: str = ..., - value: str = ..., - group: str = ..., - module: str = ..., - attr: str = ..., - extras: list[str] = ..., - ) -> bool: ... # undocumented + if sys.version_info >= (3, 10): + dist: ClassVar[Distribution | None] + def matches( + self, + *, + name: str = ..., + value: str = ..., + group: str = ..., + module: str = ..., + attr: str = ..., + extras: list[str] = ..., + ) -> bool: ... # undocumented + def __hash__(self) -> int: ... def __iter__(self) -> Iterator[Any]: ... # result of iter((str, Self)), really @@ -130,7 +138,7 @@ if sys.version_info >= (3, 12): @property def groups(self) -> set[str]: ... -else: +elif sys.version_info >= (3, 10): class DeprecatedList(list[_T]): __slots__ = () @@ -226,18 +234,27 @@ class Distribution(_distribution_parent): ) -> Iterable[Distribution]: ... @staticmethod def at(path: StrPath) -> PathDistribution: ... - @property - def metadata(self) -> PackageMetadata: ... - @property - def entry_points(self) -> EntryPoints: ... + + if sys.version_info >= (3, 10): + @property + def metadata(self) -> PackageMetadata: ... + @property + def entry_points(self) -> EntryPoints: ... + else: + @property + def metadata(self) -> Message: ... + @property + def entry_points(self) -> list[EntryPoint]: ... + @property def version(self) -> str: ... @property def files(self) -> list[PackagePath] | None: ... @property def requires(self) -> list[str] | None: ... - @property - def name(self) -> str: ... + if sys.version_info >= (3, 10): + @property + def name(self) -> str: ... if sys.version_info >= (3, 13): @property def origin(self) -> types.SimpleNamespace | None: ... @@ -258,7 +275,7 @@ class MetadataPathFinder(DistributionFinder): if sys.version_info >= (3, 11): @classmethod def invalidate_caches(cls) -> None: ... - else: + elif sys.version_info >= (3, 10): # Yes, this is an instance method that has a parameter named "cls" def invalidate_caches(cls) -> None: ... @@ -275,14 +292,19 @@ def distributions(*, context: DistributionFinder.Context) -> Iterable[Distributi def distributions( *, context: None = None, name: str | None = ..., path: list[str] = ..., **kwargs: Any ) -> Iterable[Distribution]: ... -def metadata(distribution_name: str) -> PackageMetadata: ... + +if sys.version_info >= (3, 10): + def metadata(distribution_name: str) -> PackageMetadata: ... + +else: + def metadata(distribution_name: str) -> Message: ... if sys.version_info >= (3, 12): def entry_points( *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... ) -> EntryPoints: ... -else: +elif sys.version_info >= (3, 10): @overload def entry_points() -> SelectableGroups: ... @overload @@ -290,6 +312,9 @@ else: *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... ) -> EntryPoints: ... +else: + def entry_points() -> dict[str, list[EntryPoint]]: ... + def version(distribution_name: str) -> str: ... def files(distribution_name: str) -> list[PackagePath] | None: ... def requires(distribution_name: str) -> list[str] | None: ... diff --git a/stdlib/importlib/readers.pyi b/stdlib/importlib/readers.pyi index 50f06ea5434d..0e7f7ce165c3 100644 --- a/stdlib/importlib/readers.pyi +++ b/stdlib/importlib/readers.pyi @@ -7,63 +7,66 @@ import sys import zipfile from _typeshed import StrPath from collections.abc import Iterable, Iterator -from importlib._bootstrap_external import FileLoader from io import BufferedReader from typing import Literal, NoReturn, TypeVar from typing_extensions import Never -from zipimport import zipimporter + +if sys.version_info >= (3, 10): + from importlib._bootstrap_external import FileLoader + from zipimport import zipimporter if sys.version_info >= (3, 11): from importlib.resources import abc else: from importlib import abc -if sys.version_info >= (3, 11): - __all__ = ["FileReader", "ZipReader", "MultiplexedPath", "NamespaceReader"] +if sys.version_info >= (3, 10): + if sys.version_info >= (3, 11): + __all__ = ["FileReader", "ZipReader", "MultiplexedPath", "NamespaceReader"] -if sys.version_info < (3, 11): - _T = TypeVar("_T") + if sys.version_info < (3, 11): + _T = TypeVar("_T") - def remove_duplicates(items: Iterable[_T]) -> Iterator[_T]: ... + def remove_duplicates(items: Iterable[_T]) -> Iterator[_T]: ... -class FileReader(abc.TraversableResources): - path: pathlib.Path - def __init__(self, loader: FileLoader) -> None: ... - def resource_path(self, resource: StrPath) -> str: ... - def files(self) -> pathlib.Path: ... + class FileReader(abc.TraversableResources): + path: pathlib.Path + def __init__(self, loader: FileLoader) -> None: ... + def resource_path(self, resource: StrPath) -> str: ... + def files(self) -> pathlib.Path: ... -class ZipReader(abc.TraversableResources): - prefix: str - archive: str - def __init__(self, loader: zipimporter, module: str) -> None: ... - def open_resource(self, resource: str) -> BufferedReader: ... - def is_resource(self, path: StrPath) -> bool: ... - def files(self) -> zipfile.Path: ... + class ZipReader(abc.TraversableResources): + prefix: str + archive: str + def __init__(self, loader: zipimporter, module: str) -> None: ... + def open_resource(self, resource: str) -> BufferedReader: ... + def is_resource(self, path: StrPath) -> bool: ... + def files(self) -> zipfile.Path: ... -class MultiplexedPath(abc.Traversable): - def __init__(self, *paths: abc.Traversable) -> None: ... - def iterdir(self) -> Iterator[abc.Traversable]: ... - def read_bytes(self) -> NoReturn: ... - def read_text(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] - def is_dir(self) -> Literal[True]: ... - def is_file(self) -> Literal[False]: ... + class MultiplexedPath(abc.Traversable): + def __init__(self, *paths: abc.Traversable) -> None: ... + def iterdir(self) -> Iterator[abc.Traversable]: ... + def read_bytes(self) -> NoReturn: ... + def read_text(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] + def is_dir(self) -> Literal[True]: ... + def is_file(self) -> Literal[False]: ... - if sys.version_info >= (3, 12): - def joinpath(self, *descendants: StrPath) -> abc.Traversable: ... - elif sys.version_info >= (3, 11): - def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override] - else: - def joinpath(self, child: str) -> abc.Traversable: ... + if sys.version_info >= (3, 12): + def joinpath(self, *descendants: StrPath) -> abc.Traversable: ... + elif sys.version_info >= (3, 11): + def joinpath(self, child: StrPath) -> abc.Traversable: ... # type: ignore[override] + else: + def joinpath(self, child: str) -> abc.Traversable: ... - if sys.version_info < (3, 12): - __truediv__ = joinpath + if sys.version_info < (3, 12): + __truediv__ = joinpath - def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] - @property - def name(self) -> str: ... + def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] + @property + def name(self) -> str: ... -class NamespaceReader(abc.TraversableResources): - path: MultiplexedPath - def __init__(self, namespace_path: Iterable[str]) -> None: ... - def resource_path(self, resource: str) -> str: ... - def files(self) -> MultiplexedPath: ... + class NamespaceReader(abc.TraversableResources): + path: MultiplexedPath + def __init__(self, namespace_path: Iterable[str]) -> None: ... + def resource_path(self, resource: str) -> str: ... + def files(self) -> MultiplexedPath: ... diff --git a/stdlib/importlib/resources/__init__.pyi b/stdlib/importlib/resources/__init__.pyi index 90cf473dc84b..28adc37da4a4 100644 --- a/stdlib/importlib/resources/__init__.pyi +++ b/stdlib/importlib/resources/__init__.pyi @@ -4,8 +4,8 @@ from collections.abc import Iterator from contextlib import AbstractContextManager from pathlib import Path from types import ModuleType -from typing import Any, BinaryIO, Literal, TextIO, TypeAlias -from typing_extensions import deprecated +from typing import Any, BinaryIO, Literal, TextIO +from typing_extensions import TypeAlias, deprecated if sys.version_info >= (3, 11): from importlib.resources.abc import Traversable @@ -30,7 +30,8 @@ __all__ = [ "read_text", ] -__all__ += ["ResourceReader"] +if sys.version_info >= (3, 10): + __all__ += ["ResourceReader"] if sys.version_info < (3, 13): __all__ += ["Resource"] @@ -81,5 +82,5 @@ else: if sys.version_info >= (3, 11): from importlib.resources.abc import ResourceReader as ResourceReader -else: +elif sys.version_info >= (3, 10): from importlib.abc import ResourceReader as ResourceReader diff --git a/stdlib/importlib/resources/_common.pyi b/stdlib/importlib/resources/_common.pyi index b430c7ef82a0..11a93ca82d8d 100644 --- a/stdlib/importlib/resources/_common.pyi +++ b/stdlib/importlib/resources/_common.pyi @@ -7,8 +7,8 @@ if sys.version_info >= (3, 11): from contextlib import AbstractContextManager from importlib.resources.abc import ResourceReader, Traversable from pathlib import Path - from typing import Literal, TypeAlias, overload - from typing_extensions import deprecated + from typing import Literal, overload + from typing_extensions import TypeAlias, deprecated Package: TypeAlias = str | types.ModuleType diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index cb3299e2d750..c48d63bc4f32 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -25,8 +25,8 @@ from types import ( TracebackType, WrapperDescriptorType, ) -from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeAlias, TypeGuard, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, Self, TypeIs, deprecated, disjoint_base +from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, Self, TypeAlias, TypeGuard, TypeIs, deprecated, disjoint_base if sys.version_info >= (3, 14): from annotationlib import Format @@ -319,7 +319,7 @@ if sys.version_info >= (3, 14): annotation_format: Format = Format.VALUE, # noqa: Y011 ) -> Signature: ... -else: +elif sys.version_info >= (3, 10): def signature( obj: _IntrospectableCallable, *, @@ -329,6 +329,9 @@ else: eval_str: bool = False, ) -> Signature: ... +else: + def signature(obj: _IntrospectableCallable, *, follow_wrapped: bool = True) -> Signature: ... + class _void: ... class _empty: ... @@ -358,7 +361,7 @@ class Signature: eval_str: bool = False, annotation_format: Format = Format.VALUE, # noqa: Y011 ) -> Self: ... - else: + elif sys.version_info >= (3, 10): @classmethod def from_callable( cls, @@ -369,6 +372,9 @@ class Signature: locals: Mapping[str, Any] | None = None, eval_str: bool = False, ) -> Self: ... + else: + @classmethod + def from_callable(cls, obj: _IntrospectableCallable, *, follow_wrapped: bool = True) -> Self: ... if sys.version_info >= (3, 14): def format(self, *, max_width: int | None = None, quote_annotation_strings: bool = True) -> str: ... elif sys.version_info >= (3, 13): @@ -379,7 +385,7 @@ class Signature: if sys.version_info >= (3, 14): from annotationlib import get_annotations as get_annotations -else: +elif sys.version_info >= (3, 10): def get_annotations( obj: Callable[..., object] | type[object] | ModuleType, # any callable, class, or module *, diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index c503a69aad7b..d09804cb9342 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Iterable, Iterator -from typing import Any, Final, Generic, Literal, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import Any, Final, Generic, Literal, TypeVar, overload +from typing_extensions import Self, TypeAlias # Undocumented length constants IPV4LENGTH: Final = 32 diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 76844c0cc285..8a924ad8b1e7 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import MaybeNone from collections.abc import Callable, Iterable, Iterator from types import GenericAlias -from typing import Any, Generic, Literal, SupportsComplex, SupportsFloat, SupportsIndex, SupportsInt, TypeAlias, TypeVar, overload -from typing_extensions import Self, disjoint_base +from typing import Any, Generic, Literal, SupportsComplex, SupportsFloat, SupportsIndex, SupportsInt, TypeVar, overload +from typing_extensions import Self, TypeAlias, disjoint_base _T = TypeVar("_T") _S = TypeVar("_S") @@ -332,11 +332,12 @@ class combinations_with_replacement(Generic[_T_co]): def __iter__(self) -> Self: ... def __next__(self) -> _T_co: ... -@disjoint_base -class pairwise(Generic[_T_co]): - def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ... - def __iter__(self) -> Self: ... - def __next__(self) -> _T_co: ... +if sys.version_info >= (3, 10): + @disjoint_base + class pairwise(Generic[_T_co]): + def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ... + def __iter__(self) -> Self: ... + def __next__(self) -> _T_co: ... if sys.version_info >= (3, 12): @disjoint_base diff --git a/stdlib/lib2to3/pgen2/__init__.pyi b/stdlib/lib2to3/pgen2/__init__.pyi index 3b1cbef7727d..de8a874f434d 100644 --- a/stdlib/lib2to3/pgen2/__init__.pyi +++ b/stdlib/lib2to3/pgen2/__init__.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from ..pytree import _RawNode from .grammar import Grammar diff --git a/stdlib/lib2to3/pgen2/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index 5093422ae236..bef0a7922683 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -1,6 +1,5 @@ from _typeshed import StrPath -from typing import TypeAlias -from typing_extensions import Self +from typing_extensions import Self, TypeAlias _Label: TypeAlias = tuple[int, str | None] _DFA: TypeAlias = list[list[tuple[int, int]]] diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index 9befe9bf879d..320c5f018d43 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Sequence -from typing import TypeAlias +from typing_extensions import TypeAlias from ..pytree import _NL, _RawNode from . import _Convert diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index 76ff733163af..af54de1b51d3 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Iterable, Iterator -from typing import TypeAlias +from typing_extensions import TypeAlias from .token import * diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 045f7882721a..51bdbc75e142 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, SupportsGetItem, SupportsLenAndGetItem, Unused from abc import abstractmethod from collections.abc import Iterable, Iterator, MutableSequence -from typing import ClassVar, Final, TypeAlias -from typing_extensions import Self +from typing import ClassVar, Final +from typing_extensions import Self, TypeAlias from .fixer_base import BaseFix from .pgen2.grammar import Grammar diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index f527e7084ced..5379a21e7d12 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias __all__ = ["getline", "clearcache", "checkcache", "lazycache"] diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 44f9315678e0..80c39a532dc8 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -153,7 +153,10 @@ if sys.version_info < (3, 12): def format_string(f: _str, val: Any, grouping: bool = False, monetary: bool = False) -> _str: ... def currency(val: float | Decimal, symbol: bool = True, grouping: bool = False, international: bool = False) -> _str: ... def delocalize(string: _str) -> _str: ... -def localize(string: _str, grouping: bool = False, monetary: bool = False) -> _str: ... + +if sys.version_info >= (3, 10): + def localize(string: _str, grouping: bool = False, monetary: bool = False) -> _str: ... + def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... def str(val: float) -> _str: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 7e56333bbf16..8248f82ea87a 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -7,8 +7,8 @@ from re import Pattern from string import Template from time import struct_time from types import FrameType, GenericAlias, TracebackType -from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated __all__ = [ "BASIC_FORMAT", @@ -274,15 +274,21 @@ class Formatter: default_time_format: str default_msec_format: str | None - def __init__( - self, - fmt: str | None = None, - datefmt: str | None = None, - style: _FormatStyle = "%", - validate: bool = True, - *, - defaults: Mapping[str, Any] | None = None, - ) -> None: ... + if sys.version_info >= (3, 10): + def __init__( + self, + fmt: str | None = None, + datefmt: str | None = None, + style: _FormatStyle = "%", + validate: bool = True, + *, + defaults: Mapping[str, Any] | None = None, + ) -> None: ... + else: + def __init__( + self, fmt: str | None = None, datefmt: str | None = None, style: _FormatStyle = "%", validate: bool = True + ) -> None: ... + def format(self, record: LogRecord) -> str: ... def formatTime(self, record: LogRecord, datefmt: str | None = None) -> str: ... def formatException(self, ei: _SysExcInfoType) -> str: ... @@ -359,10 +365,15 @@ class LoggerAdapter(Generic[_L]): if sys.version_info >= (3, 13): def __init__(self, logger: _L, extra: Mapping[str, object] | None = None, merge_extra: bool = False) -> None: ... - else: + elif sys.version_info >= (3, 10): def __init__(self, logger: _L, extra: Mapping[str, object] | None = None) -> None: ... + else: + def __init__(self, logger: _L, extra: Mapping[str, object]) -> None: ... - extra: Mapping[str, object] | None + if sys.version_info >= (3, 10): + extra: Mapping[str, object] | None + else: + extra: Mapping[str, object] if sys.version_info >= (3, 13): merge_extra: bool @@ -630,7 +641,11 @@ class PercentStyle: # undocumented asctime_search: str validation_pattern: Pattern[str] _fmt: str - def __init__(self, fmt: str, *, defaults: Mapping[str, Any] | None = None) -> None: ... + if sys.version_info >= (3, 10): + def __init__(self, fmt: str, *, defaults: Mapping[str, Any] | None = None) -> None: ... + else: + def __init__(self, fmt: str) -> None: ... + def usesTime(self) -> bool: ... def validate(self) -> None: ... def format(self, record: Any) -> str: ... diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index 405d7fb898fc..e36214551600 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -4,8 +4,8 @@ from collections.abc import Callable, Hashable, Iterable, Mapping, Sequence from configparser import RawConfigParser from re import Pattern from threading import Thread -from typing import IO, Any, Final, Literal, SupportsIndex, TypeAlias, TypedDict, overload, type_check_only -from typing_extensions import Required, disjoint_base +from typing import IO, Any, Final, Literal, SupportsIndex, TypedDict, overload, type_check_only +from typing_extensions import Required, TypeAlias, disjoint_base from . import Filter, Filterer, Formatter, Handler, Logger, _FilterType, _FormatStyle, _Level @@ -64,12 +64,22 @@ class _DictConfigArgs(TypedDict, total=False): # Also accept a TypedDict type, to allow callers to use TypedDict # types, and for somewhat stricter type checking of dict literals. def dictConfig(config: _DictConfigArgs | dict[str, Any]) -> None: ... -def fileConfig( - fname: StrOrBytesPath | IO[str] | RawConfigParser, - defaults: Mapping[str, str] | None = None, - disable_existing_loggers: bool = True, - encoding: str | None = None, -) -> None: ... + +if sys.version_info >= (3, 10): + def fileConfig( + fname: StrOrBytesPath | IO[str] | RawConfigParser, + defaults: Mapping[str, str] | None = None, + disable_existing_loggers: bool = True, + encoding: str | None = None, + ) -> None: ... + +else: + def fileConfig( + fname: StrOrBytesPath | IO[str] | RawConfigParser, + defaults: Mapping[str, str] | None = None, + disable_existing_loggers: bool = True, + ) -> None: ... + def valid_ident(s: str) -> Literal[True]: ... # undocumented def listen(port: int = 9030, verify: Callable[[bytes], bytes | None] | None = None) -> Thread: ... def stopListening() -> None: ... diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index b920f477542e..b7ef607b75cb 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -36,8 +36,8 @@ from _lzma import ( ) from _typeshed import ReadableBuffer, StrOrBytesPath from io import TextIOWrapper -from typing import IO, Literal, TypeAlias, overload -from typing_extensions import Self +from typing import IO, Literal, overload +from typing_extensions import Self, TypeAlias if sys.version_info >= (3, 14): from compression._common._streams import BaseStream diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 1bfd9cc9f7a8..89bd998b4dfe 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -6,8 +6,8 @@ from abc import ABCMeta, abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from email._policybase import _MessageT from types import GenericAlias, TracebackType -from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias __all__ = [ "Mailbox", diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index 74c32694a7f9..ce549e01f528 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -1,5 +1,5 @@ from collections.abc import Mapping, Sequence -from typing import TypeAlias +from typing_extensions import TypeAlias _Cap: TypeAlias = dict[str, str | int] diff --git a/stdlib/marshal.pyi b/stdlib/marshal.pyi index ad0c4cb40ded..46c421e4ce30 100644 --- a/stdlib/marshal.pyi +++ b/stdlib/marshal.pyi @@ -2,7 +2,8 @@ import builtins import sys import types from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite -from typing import Any, Final, TypeAlias +from typing import Any, Final +from typing_extensions import TypeAlias version: Final[int] diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 30858b870f68..1903d488f7bb 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -1,7 +1,8 @@ import sys from _typeshed import SupportsMul, SupportsRMul from collections.abc import Iterable -from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 4e27695f179e..005020b8b6b3 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -15,7 +15,8 @@ ALLOCATIONGRANULARITY: Final[int] if sys.platform == "linux": MAP_DENYWRITE: Final[int] MAP_EXECUTABLE: Final[int] - MAP_POPULATE: Final[int] + if sys.version_info >= (3, 10): + MAP_POPULATE: Final[int] if sys.version_info >= (3, 11) and sys.platform != "win32" and sys.platform != "darwin": MAP_STACK: Final[int] diff --git a/stdlib/msilib/sequence.pyi b/stdlib/msilib/sequence.pyi index 9b01c416f1d6..a9f5c24717bd 100644 --- a/stdlib/msilib/sequence.pyi +++ b/stdlib/msilib/sequence.pyi @@ -1,5 +1,6 @@ import sys -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias if sys.platform == "win32": _SequenceType: TypeAlias = list[tuple[str, str | None, int]] diff --git a/stdlib/msvcrt.pyi b/stdlib/msvcrt.pyi index 1518f7974de7..5feca8eab5c1 100644 --- a/stdlib/msvcrt.pyi +++ b/stdlib/msvcrt.pyi @@ -28,4 +28,5 @@ if sys.platform == "win32": def ungetwch(unicode_char: str, /) -> None: ... def heapmin() -> None: ... def SetErrorMode(mode: int, /) -> int: ... - def GetErrorMode() -> int: ... # undocumented + if sys.version_info >= (3, 10): + def GetErrorMode() -> int: ... # undocumented diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index b9475c5baa49..cd4fa102c0f3 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -3,8 +3,8 @@ import sys from _typeshed import Incomplete, ReadableBuffer from collections.abc import Iterable from types import TracebackType -from typing import Any, Generic, SupportsIndex, TypeAlias, TypeVar -from typing_extensions import Self +from typing import Any, Generic, SupportsIndex, TypeVar +from typing_extensions import Self, TypeAlias __all__ = ["Client", "Listener", "Pipe", "wait"] diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index 960678698648..03d1d2e5c220 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -9,7 +9,8 @@ from multiprocessing.managers import SyncManager from multiprocessing.pool import Pool as _Pool from multiprocessing.process import BaseProcess from multiprocessing.sharedctypes import Synchronized, SynchronizedArray, SynchronizedString -from typing import Any, ClassVar, Literal, TypeAlias, TypeVar, overload +from typing import Any, ClassVar, Literal, TypeVar, overload +from typing_extensions import TypeAlias if sys.platform != "win32": from multiprocessing.connection import Connection diff --git a/stdlib/multiprocessing/heap.pyi b/stdlib/multiprocessing/heap.pyi index cab9c58dc549..38191a099f1e 100644 --- a/stdlib/multiprocessing/heap.pyi +++ b/stdlib/multiprocessing/heap.pyi @@ -2,7 +2,8 @@ import sys from _typeshed import Incomplete from collections.abc import Callable from mmap import mmap -from typing import Protocol, TypeAlias, type_check_only +from typing import Protocol, type_check_only +from typing_extensions import TypeAlias __all__ = ["BufferWrapper"] diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 04051cf0ba08..bc6b2e6a9d27 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -14,8 +14,8 @@ from collections.abc import ( Set as AbstractSet, ) from types import GenericAlias, TracebackType -from typing import Any, AnyStr, ClassVar, Generic, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import Any, AnyStr, ClassVar, Generic, SupportsIndex, TypeVar, overload +from typing_extensions import Self, TypeAlias from . import pool from .connection import Connection, _Address @@ -227,7 +227,11 @@ class Server: ) -> None: ... def serve_forever(self) -> None: ... def accepter(self) -> None: ... - def handle_request(self, conn: _ServerConnection) -> None: ... + if sys.version_info >= (3, 10): + def handle_request(self, conn: _ServerConnection) -> None: ... + else: + def handle_request(self, c: _ServerConnection) -> None: ... + def serve_client(self, conn: _ServerConnection) -> None: ... def fallback_getvalue(self, conn: _ServerConnection, ident: str, obj: _T) -> _T: ... def fallback_str(self, conn: _ServerConnection, ident: str, obj: Any) -> str: ... diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 889e71c061e1..541e0b05dd8a 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -3,7 +3,7 @@ import threading from collections.abc import Callable from multiprocessing.context import BaseContext from types import TracebackType -from typing import TypeAlias +from typing_extensions import TypeAlias __all__ = ["Lock", "RLock", "Semaphore", "BoundedSemaphore", "Condition", "Event"] diff --git a/stdlib/netrc.pyi b/stdlib/netrc.pyi index 4b7035c3e565..480f55a46d64 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrOrBytesPath -from typing import TypeAlias +from typing_extensions import TypeAlias __all__ = ["netrc", "NetrcParseError"] diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 50b633ce1ad1..1fb1e79f69a1 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -4,8 +4,8 @@ import ssl from _typeshed import Unused from builtins import list as _list # conflicts with a method named "list" from collections.abc import Iterable -from typing import IO, Any, Final, NamedTuple, TypeAlias -from typing_extensions import Self +from typing import IO, Any, Final, NamedTuple +from typing_extensions import Self, TypeAlias __all__ = [ "NNTP", diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 47f76e1ebea9..9e02fbf9e106 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -35,14 +35,13 @@ from typing import ( Literal, NoReturn, Protocol, - TypeAlias, TypeVar, final, overload, runtime_checkable, type_check_only, ) -from typing_extensions import LiteralString, Self, Unpack, deprecated +from typing_extensions import LiteralString, Self, TypeAlias, Unpack, deprecated from . import path as _path @@ -803,7 +802,8 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo # st_uid, st_gid, st_size, st_atime, st_mtime, st_ctime. # # More items may be added at the end by some implementations. - __match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size") + if sys.version_info >= (3, 10): + __match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size") @property def st_mode(self) -> int: ... # protection bits, @@ -910,18 +910,19 @@ class DirEntry(Generic[AnyStr]): @final class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int, int]): - __match_args__: Final = ( - "f_bsize", - "f_frsize", - "f_blocks", - "f_bfree", - "f_bavail", - "f_files", - "f_ffree", - "f_favail", - "f_flag", - "f_namemax", - ) + if sys.version_info >= (3, 10): + __match_args__: Final = ( + "f_bsize", + "f_frsize", + "f_blocks", + "f_bfree", + "f_bavail", + "f_files", + "f_ffree", + "f_favail", + "f_flag", + "f_namemax", + ) @property def f_bsize(self) -> int: ... @@ -963,7 +964,8 @@ def strerror(code: int, /) -> str: ... def umask(mask: int, /) -> int: ... @final class uname_result(structseq[str], tuple[str, str, str, str, str]): - __match_args__: Final = ("sysname", "nodename", "release", "version", "machine") + if sys.version_info >= (3, 10): + __match_args__: Final = ("sysname", "nodename", "release", "version", "machine") @property def sysname(self) -> str: ... @@ -1151,7 +1153,8 @@ if sys.platform != "win32": def preadv(fd: int, buffers: SupportsLenAndGetItem[WriteableBuffer], offset: int, flags: int = 0, /) -> int: ... def pwritev(fd: int, buffers: SupportsLenAndGetItem[ReadableBuffer], offset: int, flags: int = 0, /) -> int: ... if sys.platform != "darwin": - RWF_APPEND: Final[int] # docs say available on 3.7+, stubtest says otherwise + if sys.version_info >= (3, 10): + RWF_APPEND: Final[int] # docs say available on 3.7+, stubtest says otherwise RWF_DSYNC: Final[int] RWF_SYNC: Final[int] RWF_HIPRI: Final[int] @@ -1178,7 +1181,8 @@ if sys.version_info >= (3, 14): @final class terminal_size(structseq[int], tuple[int, int]): - __match_args__: Final = ("columns", "lines") + if sys.version_info >= (3, 10): + __match_args__: Final = ("columns", "lines") @property def columns(self) -> int: ... @@ -1447,7 +1451,8 @@ else: @final class times_result(structseq[float], tuple[float, float, float, float, float]): - __match_args__: Final = ("user", "system", "children_user", "children_system", "elapsed") + if sys.version_info >= (3, 10): + __match_args__: Final = ("user", "system", "children_user", "children_system", "elapsed") @property def user(self) -> float: ... @@ -1464,9 +1469,16 @@ def times() -> times_result: ... def waitpid(pid: int, options: int, /) -> tuple[int, int]: ... if sys.platform == "win32": - def startfile( - filepath: StrOrBytesPath, operation: str = ..., arguments: str = "", cwd: StrOrBytesPath | None = None, show_cmd: int = 1 - ) -> None: ... + if sys.version_info >= (3, 10): + def startfile( + filepath: StrOrBytesPath, + operation: str = ..., + arguments: str = "", + cwd: StrOrBytesPath | None = None, + show_cmd: int = 1, + ) -> None: ... + else: + def startfile(filepath: StrOrBytesPath, operation: str = ...) -> None: ... else: if sys.version_info >= (3, 14): @@ -1490,7 +1502,8 @@ else: if sys.platform != "darwin" or sys.version_info >= (3, 13): @final class waitid_result(structseq[int], tuple[int, int, int, int, int]): - __match_args__: Final = ("si_pid", "si_uid", "si_signo", "si_status", "si_code") + if sys.version_info >= (3, 10): + __match_args__: Final = ("si_pid", "si_uid", "si_signo", "si_status", "si_code") @property def si_pid(self) -> int: ... @@ -1584,7 +1597,8 @@ else: if sys.platform != "win32": @final class sched_param(structseq[int], tuple[int]): - __match_args__: Final = ("sched_priority",) + if sys.version_info >= (3, 10): + __match_args__: Final = ("sched_priority",) def __new__(cls, sched_priority: int) -> Self: ... @property diff --git a/stdlib/pathlib/__init__.pyi b/stdlib/pathlib/__init__.pyi index 4338ce1bec5b..26dde2accd8d 100644 --- a/stdlib/pathlib/__init__.pyi +++ b/stdlib/pathlib/__init__.pyi @@ -151,8 +151,10 @@ class PureWindowsPath(PurePath): class Path(PurePath): if sys.version_info >= (3, 14): __slots__ = ("_info",) - else: + elif sys.version_info >= (3, 10): __slots__ = () + else: + __slots__ = ("_accessor",) if sys.version_info >= (3, 12): def __new__(cls, *args: StrPath, **kwargs: Unused) -> Self: ... # pyright: ignore[reportInconsistentConstructor] @@ -161,8 +163,12 @@ class Path(PurePath): @classmethod def cwd(cls) -> Self: ... - def stat(self, *, follow_symlinks: bool = True) -> stat_result: ... - def chmod(self, mode: int, *, follow_symlinks: bool = True) -> None: ... + if sys.version_info >= (3, 10): + def stat(self, *, follow_symlinks: bool = True) -> stat_result: ... + def chmod(self, mode: int, *, follow_symlinks: bool = True) -> None: ... + else: + def stat(self) -> stat_result: ... + def chmod(self, mode: int) -> None: ... if sys.version_info >= (3, 13): @classmethod @@ -308,12 +314,20 @@ class Path(PurePath): def is_mount(self) -> bool: ... def readlink(self) -> Self: ... - def rename(self, target: StrPath) -> Self: ... - def replace(self, target: StrPath) -> Self: ... + + if sys.version_info >= (3, 10): + def rename(self, target: StrPath) -> Self: ... + def replace(self, target: StrPath) -> Self: ... + else: + def rename(self, target: str | PurePath) -> Self: ... + def replace(self, target: str | PurePath) -> Self: ... + def resolve(self, strict: bool = False) -> Self: ... def rmdir(self) -> None: ... def symlink_to(self, target: StrOrBytesPath, target_is_directory: bool = False) -> None: ... - def hardlink_to(self, target: StrOrBytesPath) -> None: ... + if sys.version_info >= (3, 10): + def hardlink_to(self, target: StrOrBytesPath) -> None: ... + def touch(self, mode: int = 0o666, exist_ok: bool = True) -> None: ... def unlink(self, missing_ok: bool = False) -> None: ... @classmethod @@ -323,12 +337,18 @@ class Path(PurePath): def read_bytes(self) -> bytes: ... def samefile(self, other_path: StrPath) -> bool: ... def write_bytes(self, data: ReadableBuffer) -> int: ... - def write_text( - self, data: str, encoding: str | None = None, errors: str | None = None, newline: str | None = None - ) -> int: ... + if sys.version_info >= (3, 10): + def write_text( + self, data: str, encoding: str | None = None, errors: str | None = None, newline: str | None = None + ) -> int: ... + else: + def write_text(self, data: str, encoding: str | None = None, errors: str | None = None) -> int: ... if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `hardlink_to()` instead.") - def link_to(self, target: StrOrBytesPath) -> None: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `hardlink_to()` instead.") + def link_to(self, target: StrOrBytesPath) -> None: ... + else: + def link_to(self, target: StrOrBytesPath) -> None: ... if sys.version_info >= (3, 12): def walk( self, top_down: bool = True, on_error: Callable[[OSError], object] | None = None, follow_symlinks: bool = False diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index 6584c26e3a77..dc1cf3b28086 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -3,11 +3,12 @@ import sys from bdb import Bdb, _Backend from cmd import Cmd from collections.abc import Callable, Iterable, Mapping, Sequence +from inspect import _SourceObjectType from linecache import _ModuleGlobals from rlcompleter import Completer from types import CodeType, FrameType, TracebackType -from typing import IO, Any, ClassVar, Final, Literal, TypeAlias, TypeVar -from typing_extensions import ParamSpec, Self, deprecated +from typing import IO, Any, ClassVar, Final, Literal, TypeVar +from typing_extensions import ParamSpec, Self, TypeAlias, deprecated __all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"] if sys.version_info >= (3, 14): @@ -258,6 +259,10 @@ class Pdb(Bdb, Cmd): def find_function(funcname: str, filename: str) -> tuple[str, str, int] | None: ... def main() -> None: ... def help() -> None: ... + +if sys.version_info < (3, 10): + def getsourcelines(obj: _SourceObjectType) -> tuple[list[str], int]: ... + def lasti2lineno(code: CodeType, lasti: int) -> int: ... class _rstr(str): diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 98353d960888..8bbfaba31b67 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -1,6 +1,7 @@ import sys from collections.abc import Callable, Iterator, MutableMapping -from typing import IO, Any, Final, TypeAlias +from typing import IO, Any, Final +from typing_extensions import TypeAlias __all__ = ["dis", "genops", "optimize"] diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index d9c586d8b143..69d702bb155c 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -57,7 +57,8 @@ if sys.version_info >= (3, 12): else: @disjoint_base class uname_result(_uname_result_base): - __match_args__ = ("system", "node", "release", "version", "machine") # pyright: ignore[reportAssignmentType] + if sys.version_info >= (3, 10): + __match_args__ = ("system", "node", "release", "version", "machine") # pyright: ignore[reportAssignmentType] def __new__(_cls, system: str, node: str, release: str, version: str, machine: str) -> Self: ... @property @@ -78,7 +79,9 @@ def python_revision() -> str: ... def python_build() -> tuple[str, str]: ... def python_compiler() -> str: ... def platform(aliased: bool = False, terse: bool = False) -> str: ... -def freedesktop_os_release() -> dict[str, str]: ... + +if sys.version_info >= (3, 10): + def freedesktop_os_release() -> dict[str, str]: ... if sys.version_info >= (3, 13): class AndroidVer(NamedTuple): diff --git a/stdlib/poplib.pyi b/stdlib/poplib.pyi index 40496ee5286c..f5669ec87e87 100644 --- a/stdlib/poplib.pyi +++ b/stdlib/poplib.pyi @@ -4,8 +4,8 @@ import sys from _typeshed import StrOrBytesPath from builtins import list as _list # conflicts with a method named "list" from re import Pattern -from typing import Any, BinaryIO, Final, NoReturn, TypeAlias, overload -from typing_extensions import deprecated +from typing import Any, BinaryIO, Final, NoReturn, overload +from typing_extensions import TypeAlias, deprecated __all__ = ["POP3", "error_proto", "POP3_SSL"] diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 3259ff239038..6d0d76ab8217 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -39,7 +39,6 @@ if sys.platform != "win32": O_DIRECTORY as O_DIRECTORY, O_DSYNC as O_DSYNC, O_EXCL as O_EXCL, - O_FSYNC as O_FSYNC, O_NDELAY as O_NDELAY, O_NOCTTY as O_NOCTTY, O_NOFOLLOW as O_NOFOLLOW, @@ -228,6 +227,9 @@ if sys.platform != "win32": writev as writev, ) + if sys.version_info >= (3, 10): + from os import O_FSYNC as O_FSYNC + if sys.version_info >= (3, 11): from os import login_tty as login_tty @@ -271,7 +273,6 @@ if sys.platform != "win32": POSIX_FADV_RANDOM as POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL as POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED as POSIX_FADV_WILLNEED, - RWF_APPEND as RWF_APPEND, RWF_DSYNC as RWF_DSYNC, RWF_HIPRI as RWF_HIPRI, RWF_NOWAIT as RWF_NOWAIT, @@ -302,14 +303,14 @@ if sys.platform != "win32": setresuid as setresuid, ) + if sys.version_info >= (3, 10): + from os import RWF_APPEND as RWF_APPEND + if sys.platform != "darwin" or sys.version_info >= (3, 13): from os import waitid as waitid, waitid_result as waitid_result if sys.platform == "linux": from os import ( - EFD_CLOEXEC as EFD_CLOEXEC, - EFD_NONBLOCK as EFD_NONBLOCK, - EFD_SEMAPHORE as EFD_SEMAPHORE, GRND_NONBLOCK as GRND_NONBLOCK, GRND_RANDOM as GRND_RANDOM, MFD_ALLOW_SEALING as MFD_ALLOW_SEALING, @@ -340,16 +341,10 @@ if sys.platform != "win32": SCHED_BATCH as SCHED_BATCH, SCHED_IDLE as SCHED_IDLE, SCHED_RESET_ON_FORK as SCHED_RESET_ON_FORK, - SPLICE_F_MORE as SPLICE_F_MORE, - SPLICE_F_MOVE as SPLICE_F_MOVE, - SPLICE_F_NONBLOCK as SPLICE_F_NONBLOCK, XATTR_CREATE as XATTR_CREATE, XATTR_REPLACE as XATTR_REPLACE, XATTR_SIZE_MAX as XATTR_SIZE_MAX, copy_file_range as copy_file_range, - eventfd as eventfd, - eventfd_read as eventfd_read, - eventfd_write as eventfd_write, getrandom as getrandom, getxattr as getxattr, listxattr as listxattr, @@ -357,9 +352,22 @@ if sys.platform != "win32": pidfd_open as pidfd_open, removexattr as removexattr, setxattr as setxattr, - splice as splice, ) + if sys.version_info >= (3, 10): + from os import ( + EFD_CLOEXEC as EFD_CLOEXEC, + EFD_NONBLOCK as EFD_NONBLOCK, + EFD_SEMAPHORE as EFD_SEMAPHORE, + SPLICE_F_MORE as SPLICE_F_MORE, + SPLICE_F_MOVE as SPLICE_F_MOVE, + SPLICE_F_NONBLOCK as SPLICE_F_NONBLOCK, + eventfd as eventfd, + eventfd_read as eventfd_read, + eventfd_write as eventfd_write, + splice as splice, + ) + if sys.version_info >= (3, 12): from os import ( CLONE_FILES as CLONE_FILES, diff --git a/stdlib/pprint.pyi b/stdlib/pprint.pyi index 4085731a2a05..1e80462e2565 100644 --- a/stdlib/pprint.pyi +++ b/stdlib/pprint.pyi @@ -1,57 +1,112 @@ +import sys from _typeshed import SupportsWrite from collections import deque from typing import IO __all__ = ["pprint", "pformat", "isreadable", "isrecursive", "saferepr", "PrettyPrinter", "pp"] -def pformat( - object: object, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - underscore_numbers: bool = False, -) -> str: ... -def pp( - object: object, - stream: IO[str] | None = None, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = False, - underscore_numbers: bool = False, -) -> None: ... -def pprint( - object: object, - stream: IO[str] | None = None, - indent: int = 1, - width: int = 80, - depth: int | None = None, - *, - compact: bool = False, - sort_dicts: bool = True, - underscore_numbers: bool = False, -) -> None: ... -def isreadable(object: object) -> bool: ... -def isrecursive(object: object) -> bool: ... -def saferepr(object: object) -> str: ... +if sys.version_info >= (3, 10): + def pformat( + object: object, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + underscore_numbers: bool = False, + ) -> str: ... -class PrettyPrinter: - def __init__( - self, +else: + def pformat( + object: object, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + ) -> str: ... + +if sys.version_info >= (3, 10): + def pp( + object: object, + stream: IO[str] | None = None, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = False, + underscore_numbers: bool = False, + ) -> None: ... + +else: + def pp( + object: object, + stream: IO[str] | None = None, indent: int = 1, width: int = 80, depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = False, + ) -> None: ... + +if sys.version_info >= (3, 10): + def pprint( + object: object, stream: IO[str] | None = None, + indent: int = 1, + width: int = 80, + depth: int | None = None, *, compact: bool = False, sort_dicts: bool = True, underscore_numbers: bool = False, ) -> None: ... + +else: + def pprint( + object: object, + stream: IO[str] | None = None, + indent: int = 1, + width: int = 80, + depth: int | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + ) -> None: ... + +def isreadable(object: object) -> bool: ... +def isrecursive(object: object) -> bool: ... +def saferepr(object: object) -> str: ... + +class PrettyPrinter: + if sys.version_info >= (3, 10): + def __init__( + self, + indent: int = 1, + width: int = 80, + depth: int | None = None, + stream: IO[str] | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + underscore_numbers: bool = False, + ) -> None: ... + else: + def __init__( + self, + indent: int = 1, + width: int = 80, + depth: int | None = None, + stream: IO[str] | None = None, + *, + compact: bool = False, + sort_dicts: bool = True, + ) -> None: ... + def pformat(self, object: object) -> str: ... def pprint(self, object: object) -> None: ... def isreadable(self, object: object) -> bool: ... @@ -100,4 +155,5 @@ class PrettyPrinter: self, items: list[object], stream: SupportsWrite[str], indent: int, allowance: int, context: dict[int, int], level: int ) -> None: ... def _repr(self, object: object, context: dict[int, int], level: int) -> str: ... - def _safe_repr(self, object: object, context: dict[int, int], maxlevels: int, level: int) -> tuple[str, bool, bool]: ... + if sys.version_info >= (3, 10): + def _safe_repr(self, object: object, context: dict[int, int], maxlevels: int, level: int) -> tuple[str, bool, bool]: ... diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index d1bd18bbcd86..696193d9dc16 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,7 +1,7 @@ from _typeshed import StrOrBytesPath from collections.abc import Callable, Mapping -from typing import Any, TypeAlias, TypeVar -from typing_extensions import ParamSpec, Self +from typing import Any, TypeVar +from typing_extensions import ParamSpec, Self, TypeAlias __all__ = ["run", "runctx", "Profile"] diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index 5b22b579c02a..c1da2aea0fc5 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -4,8 +4,8 @@ from collections.abc import Iterable from cProfile import Profile as _cProfile from dataclasses import dataclass from profile import Profile -from typing import IO, Any, Literal, TypeAlias, overload -from typing_extensions import Self +from typing import IO, Any, Literal, overload +from typing_extensions import Self, TypeAlias if sys.version_info >= (3, 11): from enum import StrEnum diff --git a/stdlib/pty.pyi b/stdlib/pty.pyi index 2b7a605e50e0..d1c78f9e3dd6 100644 --- a/stdlib/pty.pyi +++ b/stdlib/pty.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Callable, Iterable -from typing import Final, TypeAlias -from typing_extensions import deprecated +from typing import Final +from typing_extensions import TypeAlias, deprecated if sys.platform != "win32": __all__ = ["openpty", "fork", "spawn"] diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index 6a7e24f78125..a84ba324718a 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -5,7 +5,8 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_passwd(structseq[Any], tuple[str, str, int, int, str, str, str]): - __match_args__: Final = ("pw_name", "pw_passwd", "pw_uid", "pw_gid", "pw_gecos", "pw_dir", "pw_shell") + if sys.version_info >= (3, 10): + __match_args__: Final = ("pw_name", "pw_passwd", "pw_uid", "pw_gid", "pw_gecos", "pw_dir", "pw_shell") @property def pw_name(self) -> str: ... diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index e0ee67c5e93f..334ce79b5dd0 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -1,4 +1,5 @@ import enum +import sys from typing import AnyStr __all__ = ["compile", "main", "PyCompileError", "PycInvalidationMode"] @@ -25,4 +26,9 @@ def compile( invalidation_mode: PycInvalidationMode | None = None, quiet: int = 0, ) -> AnyStr | None: ... -def main() -> None: ... + +if sys.version_info >= (3, 10): + def main() -> None: ... + +else: + def main(args: list[str] | None = None) -> int: ... diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index c950c7f82b0f..504a5d5f115a 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -1,3 +1,4 @@ +import sys from collections.abc import Mapping, Sequence __all__ = ["readmodule", "readmodule_ex", "Class", "Function"] @@ -8,7 +9,8 @@ class _Object: file: int lineno: int - end_lineno: int | None + if sys.version_info >= (3, 10): + end_lineno: int | None parent: _Object | None @@ -16,27 +18,34 @@ class _Object: # avoid variance issues in the subclasses children: Mapping[str, _Object] - def __init__( - self, module: str, name: str, file: str, lineno: int, end_lineno: int | None, parent: _Object | None - ) -> None: ... + if sys.version_info >= (3, 10): + def __init__( + self, module: str, name: str, file: str, lineno: int, end_lineno: int | None, parent: _Object | None + ) -> None: ... + else: + def __init__(self, module: str, name: str, file: str, lineno: int, parent: _Object | None) -> None: ... class Function(_Object): - is_async: bool + if sys.version_info >= (3, 10): + is_async: bool parent: Function | Class | None children: dict[str, Class | Function] - def __init__( - self, - module: str, - name: str, - file: str, - lineno: int, - parent: Function | Class | None = None, - is_async: bool = False, - *, - end_lineno: int | None = None, - ) -> None: ... + if sys.version_info >= (3, 10): + def __init__( + self, + module: str, + name: str, + file: str, + lineno: int, + parent: Function | Class | None = None, + is_async: bool = False, + *, + end_lineno: int | None = None, + ) -> None: ... + else: + def __init__(self, module: str, name: str, file: str, lineno: int, parent: Function | Class | None = None) -> None: ... class Class(_Object): super: list[Class | str] | None @@ -44,17 +53,22 @@ class Class(_Object): parent: Class | None children: dict[str, Class | Function] - def __init__( - self, - module: str, - name: str, - super_: list[Class | str] | None, - file: str, - lineno: int, - parent: Class | None = None, - *, - end_lineno: int | None = None, - ) -> None: ... + if sys.version_info >= (3, 10): + def __init__( + self, + module: str, + name: str, + super_: list[Class | str] | None, + file: str, + lineno: int, + parent: Class | None = None, + *, + end_lineno: int | None = None, + ) -> None: ... + else: + def __init__( + self, module: str, name: str, super: list[Class | str] | None, file: str, lineno: int, parent: Class | None = None + ) -> None: ... def readmodule(module: str, path: Sequence[str] | None = None) -> dict[str, Class]: ... def readmodule_ex(module: str, path: Sequence[str] | None = None) -> dict[str, Class | Function | list[str]]: ... diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 2d68b21466c2..f8129ac20ade 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -5,8 +5,8 @@ from builtins import list as _list # "list" conflicts with method name from collections.abc import Callable, Container, Mapping, MutableMapping from reprlib import Repr from types import MethodType, ModuleType, TracebackType -from typing import IO, Any, AnyStr, Final, NoReturn, Protocol, TypeGuard, TypeVar, overload, type_check_only -from typing_extensions import deprecated +from typing import IO, Any, AnyStr, Final, NoReturn, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeGuard, deprecated __all__ = ["help"] diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 54e275ad0f9e..bc522d5f3c92 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,8 +1,9 @@ +import sys from _typeshed import ReadableBuffer, SupportsRead from collections.abc import Callable from pyexpat import errors as errors, model as model -from typing import Any, Final, TypeAlias, final -from typing_extensions import CapsuleType +from typing import Any, Final, final +from typing_extensions import CapsuleType, TypeAlias from xml.parsers.expat import ExpatError as ExpatError EXPAT_VERSION: Final[str] # undocumented @@ -29,8 +30,11 @@ class XMLParserType: def UseForeignDTD(self, flag: bool = True, /) -> None: ... def GetReparseDeferralEnabled(self) -> bool: ... def SetReparseDeferralEnabled(self, enabled: bool, /) -> None: ... - def SetAllocTrackerActivationThreshold(self, threshold: int, /) -> None: ... - def SetAllocTrackerMaximumAmplification(self, max_factor: float, /) -> None: ... + if sys.version_info >= (3, 10): + # Added in Python 3.10.20, 3.11.15, 3.12.3, 3.13.10, 3.14.1 + def SetAllocTrackerActivationThreshold(self, threshold: int, /) -> None: ... + def SetAllocTrackerMaximumAmplification(self, max_factor: float, /) -> None: ... + @property def intern(self) -> dict[str, str]: ... buffer_size: int diff --git a/stdlib/random.pyi b/stdlib/random.pyi index e7911ceeab18..08619bf66351 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -4,7 +4,7 @@ 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, TypeVar, overload -from typing_extensions import deprecated +from typing_extensions import Self, deprecated __all__ = [ "Random", @@ -45,6 +45,9 @@ class Random(_random.Random): # Using other `seed` types is deprecated since 3.9 and removed in 3.11 # Ignore Y041, since random.seed doesn't treat int like a float subtype. Having an explicit # int better documents conventional usage of random.seed. + if sys.version_info < (3, 10): + # this is a workaround for pyright correctly flagging an inconsistent inherited constructor, see #14624 + def __new__(cls, x: int | float | str | bytes | bytearray | None = None) -> Self: ... # noqa: Y041 def seed(self, a: int | float | str | bytes | bytearray | None = None, version: int = 2) -> None: ... # type: ignore[override] # noqa: Y041 def getstate(self) -> tuple[Any, ...]: ... diff --git a/stdlib/re.pyi b/stdlib/re.pyi index c83e411c8121..fb2a06d5e4c8 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -5,8 +5,8 @@ import sys from _typeshed import MaybeNone, ReadableBuffer from collections.abc import Callable, Iterator, Mapping from types import GenericAlias -from typing import Any, AnyStr, Final, Generic, Literal, TypeAlias, TypeVar, final, overload -from typing_extensions import deprecated +from typing import Any, AnyStr, Final, Generic, Literal, TypeVar, final, overload +from typing_extensions import TypeAlias, deprecated __all__ = [ "match", diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index aff1e504a174..7325c267b32c 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -1,7 +1,8 @@ import sys from _typeshed import StrOrBytesPath from collections.abc import Callable, Sequence -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias if sys.platform != "win32": _Completer: TypeAlias = Callable[[str, int], str | None] diff --git a/stdlib/reprlib.pyi b/stdlib/reprlib.pyi index d990c2708ae9..68ada6569348 100644 --- a/stdlib/reprlib.pyi +++ b/stdlib/reprlib.pyi @@ -2,7 +2,8 @@ import sys from array import array from collections import deque from collections.abc import Callable -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias __all__ = ["Repr", "repr", "recursive_repr"] diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index 6cd5db48a8c2..f99cd5b08805 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -30,24 +30,25 @@ if sys.platform != "win32": class struct_rusage( structseq[float], tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int] ): - __match_args__: Final = ( - "ru_utime", - "ru_stime", - "ru_maxrss", - "ru_ixrss", - "ru_idrss", - "ru_isrss", - "ru_minflt", - "ru_majflt", - "ru_nswap", - "ru_inblock", - "ru_oublock", - "ru_msgsnd", - "ru_msgrcv", - "ru_nsignals", - "ru_nvcsw", - "ru_nivcsw", - ) + if sys.version_info >= (3, 10): + __match_args__: Final = ( + "ru_utime", + "ru_stime", + "ru_maxrss", + "ru_ixrss", + "ru_idrss", + "ru_isrss", + "ru_minflt", + "ru_majflt", + "ru_nswap", + "ru_inblock", + "ru_oublock", + "ru_msgsnd", + "ru_msgrcv", + "ru_nsignals", + "ru_nvcsw", + "ru_nivcsw", + ) @property def ru_utime(self) -> float: ... diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index 24da5b43bd09..436d9984ee4d 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,18 +1,33 @@ +import sys import time from collections.abc import Callable -from typing import Any, NamedTuple, TypeAlias +from typing import Any, ClassVar, NamedTuple, type_check_only +from typing_extensions import TypeAlias __all__ = ["scheduler"] _ActionCallback: TypeAlias = Callable[..., Any] -class Event(NamedTuple): - time: float - priority: Any - sequence: int - action: _ActionCallback - argument: tuple[Any, ...] - kwargs: dict[str, Any] # type: ignore[assignment] +if sys.version_info >= (3, 10): + class Event(NamedTuple): + time: float + priority: Any + sequence: int + action: _ActionCallback + argument: tuple[Any, ...] + kwargs: dict[str, Any] + +else: + @type_check_only + class _EventBase(NamedTuple): + time: float + priority: Any + action: _ActionCallback + argument: tuple[Any, ...] + kwargs: dict[str, Any] + + class Event(_EventBase): + __hash__: ClassVar[None] # type: ignore[assignment] class scheduler: timefunc: Callable[[], float] diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index 68822c50ece8..bcca4e341b9a 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import FileDescriptor, FileDescriptorLike, Unused from abc import ABCMeta, abstractmethod from collections.abc import Mapping -from typing import Any, Final, NamedTuple, TypeAlias -from typing_extensions import Self +from typing import Any, Final, NamedTuple +from typing_extensions import Self, TypeAlias _EventMask: TypeAlias = int diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index 54e7bdc58bfa..cc26cfc556a0 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -3,8 +3,8 @@ import sys from _typeshed import BytesPath, ExcInfo, FileDescriptorOrPath, MaybeNone, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite from collections.abc import Callable, Iterable, Sequence from tarfile import _TarfileFilter -from typing import Any, AnyStr, NamedTuple, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import deprecated +from typing import Any, AnyStr, NamedTuple, NoReturn, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias, deprecated __all__ = [ "copyfileobj", diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index 2aafb6630b0b..c2668bd8b32d 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -3,8 +3,8 @@ from _typeshed import structseq from collections.abc import Callable, Iterable from enum import IntEnum from types import FrameType -from typing import Any, Final, TypeAlias, final -from typing_extensions import Never +from typing import Any, Final, final +from typing_extensions import Never, TypeAlias NSIG: int @@ -68,8 +68,14 @@ _SIGNUM: TypeAlias = int | Signals _HANDLER: TypeAlias = Callable[[int, FrameType | None], Any] | int | Handlers | None def default_int_handler(signalnum: int, frame: FrameType | None, /) -> Never: ... -def getsignal(signalnum: _SIGNUM) -> _HANDLER: ... -def signal(signalnum: _SIGNUM, handler: _HANDLER) -> _HANDLER: ... + +if sys.version_info >= (3, 10): # arguments changed in 3.10.2 + def getsignal(signalnum: _SIGNUM) -> _HANDLER: ... + def signal(signalnum: _SIGNUM, handler: _HANDLER) -> _HANDLER: ... + +else: + def getsignal(signalnum: _SIGNUM, /) -> _HANDLER: ... + def signal(signalnum: _SIGNUM, handler: _HANDLER, /) -> _HANDLER: ... SIGABRT: Final = Signals.SIGABRT SIGFPE: Final = Signals.SIGFPE @@ -128,11 +134,18 @@ else: def getitimer(which: int, /) -> tuple[float, float]: ... def pause() -> None: ... def pthread_kill(thread_id: int, signalnum: int, /) -> None: ... - def pthread_sigmask(how: int, mask: Iterable[int]) -> set[_SIGNUM]: ... + if sys.version_info >= (3, 10): # arguments changed in 3.10.2 + def pthread_sigmask(how: int, mask: Iterable[int]) -> set[_SIGNUM]: ... + else: + def pthread_sigmask(how: int, mask: Iterable[int], /) -> set[_SIGNUM]: ... + def setitimer(which: int, seconds: float, interval: float = 0.0, /) -> tuple[float, float]: ... def siginterrupt(signalnum: int, flag: bool, /) -> None: ... def sigpending() -> Any: ... - def sigwait(sigset: Iterable[int]) -> _SIGNUM: ... + if sys.version_info >= (3, 10): # argument changed in 3.10.2 + def sigwait(sigset: Iterable[int]) -> _SIGNUM: ... + else: + def sigwait(sigset: Iterable[int], /) -> _SIGNUM: ... if sys.platform != "darwin": SIGCLD: Final = Signals.SIGCHLD # alias SIGPOLL: Final = Signals.SIGIO # alias @@ -144,7 +157,8 @@ else: @final class struct_siginfo(structseq[int], tuple[int, int, int, int, int, int, int]): - __match_args__: Final = ("si_signo", "si_code", "si_errno", "si_pid", "si_uid", "si_status", "si_band") + if sys.version_info >= (3, 10): + __match_args__: Final = ("si_signo", "si_code", "si_errno", "si_pid", "si_uid", "si_status", "si_band") @property def si_signo(self) -> int: ... diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index cc9ac391a441..dee7e949f42f 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -3,8 +3,8 @@ import asyncore import socket import sys from collections import defaultdict -from typing import Any, TypeAlias -from typing_extensions import deprecated +from typing import Any +from typing_extensions import TypeAlias, deprecated if sys.version_info >= (3, 11): __all__ = ["SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy"] diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 0567a7a05b8a..74b5ea2cb6fc 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -7,8 +7,8 @@ from re import Pattern from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Final, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import Any, Final, Protocol, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated __all__ = [ "SMTPException", diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 06ed67271aab..36a335e13d02 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -357,9 +357,10 @@ if sys.platform != "darwin": __all__ += ["TCP_KEEPIDLE", "AF_IRDA", "MSG_ERRQUEUE"] -from _socket import IP_RECVTOS as IP_RECVTOS +if sys.version_info >= (3, 10): + from _socket import IP_RECVTOS as IP_RECVTOS -__all__ += ["IP_RECVTOS"] + __all__ += ["IP_RECVTOS"] if sys.platform != "win32" and sys.platform != "darwin": from _socket import ( @@ -1086,7 +1087,10 @@ error = OSError class herror(error): ... class gaierror(error): ... -timeout = TimeoutError +if sys.version_info >= (3, 10): + timeout = TimeoutError +else: + class timeout(error): ... class AddressFamily(IntEnum): AF_INET = 2 diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index 05e0025d6a15..f321d14a792b 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -5,8 +5,8 @@ from _typeshed import ReadableBuffer from collections.abc import Callable from io import BufferedIOBase from socket import socket as _socket -from typing import Any, ClassVar, TypeAlias -from typing_extensions import Self +from typing import Any, ClassVar +from typing_extensions import Self, TypeAlias __all__ = [ "BaseServer", diff --git a/stdlib/spwd.pyi b/stdlib/spwd.pyi index 0a06cdfeef64..3a5d39997dcc 100644 --- a/stdlib/spwd.pyi +++ b/stdlib/spwd.pyi @@ -5,17 +5,18 @@ from typing import Any, Final, final if sys.platform != "win32": @final class struct_spwd(structseq[Any], tuple[str, str, int, int, int, int, int, int, int]): - __match_args__: Final = ( - "sp_namp", - "sp_pwdp", - "sp_lstchg", - "sp_min", - "sp_max", - "sp_warn", - "sp_inact", - "sp_expire", - "sp_flag", - ) + if sys.version_info >= (3, 10): + __match_args__: Final = ( + "sp_namp", + "sp_pwdp", + "sp_lstchg", + "sp_min", + "sp_max", + "sp_warn", + "sp_inact", + "sp_expire", + "sp_flag", + ) @property def sp_namp(self) -> str: ... diff --git a/stdlib/sqlite3/__init__.pyi b/stdlib/sqlite3/__init__.pyi index 353cd8ea556f..56bccb56d63a 100644 --- a/stdlib/sqlite3/__init__.pyi +++ b/stdlib/sqlite3/__init__.pyi @@ -62,8 +62,8 @@ from sqlite3.dbapi2 import ( threadsafety as threadsafety, ) from types import TracebackType -from typing import Any, Literal, Protocol, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only -from typing_extensions import Self, disjoint_base +from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base if sys.version_info < (3, 14): from sqlite3.dbapi2 import version_info as version_info @@ -211,6 +211,9 @@ if sys.version_info >= (3, 11): if sys.version_info < (3, 12): from sqlite3.dbapi2 import enable_shared_cache as enable_shared_cache, version as version +if sys.version_info < (3, 10): + from sqlite3.dbapi2 import OptimizedUnicode as OptimizedUnicode + _CursorT = TypeVar("_CursorT", bound=Cursor) _SqliteData: TypeAlias = str | ReadableBuffer | int | float | None # Data that is passed through adapters can be of any type accepted by an adapter. diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index bd7facfdd0cb..9e170a81243d 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -215,11 +215,18 @@ if sys.version_info < (3, 14): version: Final[str] if sys.version_info < (3, 12): - @deprecated( - "Deprecated since Python 3.10; removed in Python 3.12. " - "Open database in URI mode using `cache=shared` parameter instead." - ) - def enable_shared_cache(enable: int) -> None: ... + if sys.version_info >= (3, 10): + # deprecation wrapper that has a different name for the argument... + @deprecated( + "Deprecated since Python 3.10; removed in Python 3.12. " + "Open database in URI mode using `cache=shared` parameter instead." + ) + def enable_shared_cache(enable: int) -> None: ... + else: + from _sqlite3 import enable_shared_cache as enable_shared_cache + +if sys.version_info < (3, 10): + from _sqlite3 import OptimizedUnicode as OptimizedUnicode paramstyle: Final = "qmark" threadsafety: Literal[0, 1, 3] diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index 88e2d1ee0e4c..eaacbff312a9 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -3,7 +3,8 @@ from collections.abc import Iterable from re import Match, Pattern as _Pattern from sre_constants import * from sre_constants import _NamedIntConstant as _NIC, error as _Error -from typing import Any, Final, TypeAlias, overload +from typing import Any, Final, overload +from typing_extensions import TypeAlias SPECIAL_CHARS: Final = ".\\[{()*+?^$|" REPEAT_CHARS: Final = "*+?{" diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index d60232a1d72e..2053005f1ba6 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -27,8 +27,8 @@ from _ssl import ( ) from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from collections.abc import Callable, Iterable -from typing import Any, Final, Literal, NamedTuple, TypeAlias, TypedDict, overload, type_check_only -from typing_extensions import Never, Self, deprecated +from typing import Any, Final, Literal, NamedTuple, TypedDict, overload, type_check_only +from typing_extensions import Never, Self, TypeAlias, deprecated if sys.version_info >= (3, 13): from _ssl import HAS_PSK as HAS_PSK @@ -39,6 +39,9 @@ if sys.version_info >= (3, 14): if sys.version_info < (3, 12): from _ssl import RAND_pseudo_bytes as RAND_pseudo_bytes +if sys.version_info < (3, 10): + from _ssl import RAND_egd as RAND_egd + if sys.platform == "win32": from _ssl import enum_certificates as enum_certificates, enum_crls as enum_crls @@ -105,8 +108,9 @@ class VerifyFlags(enum.IntFlag): VERIFY_CRL_CHECK_CHAIN = 12 VERIFY_X509_STRICT = 32 VERIFY_X509_TRUSTED_FIRST = 32768 - VERIFY_ALLOW_PROXY_CERTS = 64 - VERIFY_X509_PARTIAL_CHAIN = 524288 + if sys.version_info >= (3, 10): + VERIFY_ALLOW_PROXY_CERTS = 64 + VERIFY_X509_PARTIAL_CHAIN = 524288 VERIFY_DEFAULT: Final = VerifyFlags.VERIFY_DEFAULT VERIFY_CRL_CHECK_LEAF: Final = VerifyFlags.VERIFY_CRL_CHECK_LEAF @@ -114,8 +118,9 @@ VERIFY_CRL_CHECK_CHAIN: Final = VerifyFlags.VERIFY_CRL_CHECK_CHAIN VERIFY_X509_STRICT: Final = VerifyFlags.VERIFY_X509_STRICT VERIFY_X509_TRUSTED_FIRST: Final = VerifyFlags.VERIFY_X509_TRUSTED_FIRST -VERIFY_ALLOW_PROXY_CERTS: Final = VerifyFlags.VERIFY_ALLOW_PROXY_CERTS -VERIFY_X509_PARTIAL_CHAIN: Final = VerifyFlags.VERIFY_X509_PARTIAL_CHAIN +if sys.version_info >= (3, 10): + VERIFY_ALLOW_PROXY_CERTS: Final = VerifyFlags.VERIFY_ALLOW_PROXY_CERTS + VERIFY_X509_PARTIAL_CHAIN: Final = VerifyFlags.VERIFY_X509_PARTIAL_CHAIN class _SSLMethod(enum.IntEnum): PROTOCOL_SSLv23 = 2 @@ -302,8 +307,12 @@ class SSLSocket(socket.socket): def compression(self) -> str | None: ... def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ... def selected_alpn_protocol(self) -> str | None: ... - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def selected_npn_protocol(self) -> str | None: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def selected_npn_protocol(self) -> str | None: ... + else: + def selected_npn_protocol(self) -> str | None: ... + def accept(self) -> tuple[SSLSocket, socket._RetAddress]: ... def unwrap(self) -> socket.socket: ... def version(self) -> str | None: ... @@ -337,9 +346,19 @@ if sys.version_info < (3, 12): def cert_time_to_seconds(cert_time: str) -> int: ... def DER_cert_to_PEM_cert(der_cert_bytes: ReadableBuffer) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... -def get_server_certificate( - addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None, timeout: float = ... -) -> str: ... + +if sys.version_info >= (3, 10): + def get_server_certificate( + addr: tuple[str, int], + ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, + ca_certs: str | None = None, + timeout: float = ..., + ) -> str: ... + +else: + def get_server_certificate( + addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None + ) -> str: ... class TLSVersion(enum.IntEnum): MINIMUM_SUPPORTED = -2 @@ -366,12 +385,17 @@ class SSLContext(_SSLContext): sslsocket_class: type[SSLSocket] keylog_filename: str post_handshake_auth: bool - security_level: int - @overload - def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ... - @overload - @deprecated("Deprecated since Python 3.10. Use a specific version of the SSL protocol.") - def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ... + if sys.version_info >= (3, 10): + security_level: int + if sys.version_info >= (3, 10): + @overload + def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ... + @overload + @deprecated("Deprecated since Python 3.10. Use a specific version of the SSL protocol.") + def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ... + else: + def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ... + def load_default_certs(self, purpose: Purpose = Purpose.SERVER_AUTH) -> None: ... def load_verify_locations( self, @@ -389,8 +413,12 @@ class SSLContext(_SSLContext): def set_default_verify_paths(self) -> None: ... def set_ciphers(self, cipherlist: str, /) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... + else: + def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... + def set_servername_callback(self, server_name_callback: _SrvnmeCbType | None) -> None: ... def load_dh_params(self, path: str, /) -> None: ... def set_ecdh_curve(self, name: str, /) -> None: ... @@ -419,18 +447,34 @@ def create_default_context( capath: StrOrBytesPath | None = None, cadata: str | ReadableBuffer | None = None, ) -> SSLContext: ... -def _create_unverified_context( - protocol: int | None = None, - *, - cert_reqs: int = VerifyMode.CERT_NONE, - check_hostname: bool = False, - purpose: Purpose = Purpose.SERVER_AUTH, - certfile: StrOrBytesPath | None = None, - keyfile: StrOrBytesPath | None = None, - cafile: StrOrBytesPath | None = None, - capath: StrOrBytesPath | None = None, - cadata: str | ReadableBuffer | None = None, -) -> SSLContext: ... + +if sys.version_info >= (3, 10): + def _create_unverified_context( + protocol: int | None = None, + *, + cert_reqs: int = VerifyMode.CERT_NONE, + check_hostname: bool = False, + purpose: Purpose = Purpose.SERVER_AUTH, + certfile: StrOrBytesPath | None = None, + keyfile: StrOrBytesPath | None = None, + cafile: StrOrBytesPath | None = None, + capath: StrOrBytesPath | None = None, + cadata: str | ReadableBuffer | None = None, + ) -> SSLContext: ... + +else: + def _create_unverified_context( + protocol: int = ..., + *, + cert_reqs: int = VerifyMode.CERT_NONE, + check_hostname: bool = False, + purpose: Purpose = Purpose.SERVER_AUTH, + certfile: StrOrBytesPath | None = None, + keyfile: StrOrBytesPath | None = None, + cafile: StrOrBytesPath | None = None, + capath: StrOrBytesPath | None = None, + cadata: str | ReadableBuffer | None = None, + ) -> SSLContext: ... _create_default_https_context = create_default_context @@ -453,8 +497,12 @@ class SSLObject: @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... def selected_alpn_protocol(self) -> str | None: ... - @deprecated("Deprecated since Python 3.10. Use ALPN instead.") - def selected_npn_protocol(self) -> str | None: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10. Use ALPN instead.") + def selected_npn_protocol(self) -> str | None: ... + else: + def selected_npn_protocol(self) -> str | None: ... + def cipher(self) -> tuple[str, str, int] | None: ... def shared_ciphers(self) -> list[tuple[str, str, int]] | None: ... def compression(self) -> str | None: ... diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index c0f4fb80f2c8..188bed3375bf 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -3,8 +3,8 @@ from _typeshed import SupportsRichComparisonT from collections.abc import Callable, Hashable, Iterable, Sequence, Sized from decimal import Decimal from fractions import Fraction -from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeAlias, TypeVar -from typing_extensions import Self +from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeVar +from typing_extensions import Self, TypeAlias __all__ = [ "StatisticsError", @@ -26,7 +26,8 @@ __all__ = [ "quantiles", ] -__all__ += ["covariance", "correlation", "linear_regression"] +if sys.version_info >= (3, 10): + __all__ += ["covariance", "correlation", "linear_regression"] if sys.version_info >= (3, 13): __all__ += ["kde", "kde_random"] @@ -54,7 +55,13 @@ else: def geometric_mean(data: Iterable[SupportsFloat]) -> float: ... def mean(data: Iterable[_NumberT]) -> _NumberT: ... -def harmonic_mean(data: Iterable[_NumberT], weights: Iterable[_Number] | None = None) -> _NumberT: ... + +if sys.version_info >= (3, 10): + def harmonic_mean(data: Iterable[_NumberT], weights: Iterable[_Number] | None = None) -> _NumberT: ... + +else: + def harmonic_mean(data: Iterable[_NumberT]) -> _NumberT: ... + def median(data: Iterable[_NumberT]) -> _NumberT: ... def median_low(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ... def median_high(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ... @@ -114,21 +121,22 @@ if sys.version_info >= (3, 12): x: Sequence[_Number], y: Sequence[_Number], /, *, method: Literal["linear", "ranked"] = "linear" ) -> float: ... -else: +elif sys.version_info >= (3, 10): def correlation(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... -def covariance(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... +if sys.version_info >= (3, 10): + def covariance(x: Sequence[_Number], y: Sequence[_Number], /) -> float: ... -class LinearRegression(NamedTuple): - slope: float - intercept: float + class LinearRegression(NamedTuple): + slope: float + intercept: float if sys.version_info >= (3, 11): def linear_regression( regressor: _SizedIterable[_Number], dependent_variable: _SizedIterable[_Number], /, *, proportional: bool = False ) -> LinearRegression: ... -else: +elif sys.version_info >= (3, 10): def linear_regression( regressor: _SizedIterable[_Number], dependent_variable: _SizedIterable[_Number], / ) -> LinearRegression: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 474d32483ce2..f6d7b88193ec 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath from collections.abc import Callable, Collection, Iterable, Mapping, Sequence from types import GenericAlias, TracebackType -from typing import IO, Any, AnyStr, Final, Generic, Literal, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import IO, Any, AnyStr, Final, Generic, Literal, TypeVar, overload +from typing_extensions import Self, TypeAlias __all__ = [ "Popen", @@ -294,7 +294,7 @@ if sys.version_info >= (3, 11): process_group: int | None = None, ) -> CompletedProcess[Any]: ... -else: +elif sys.version_info >= (3, 10): # 3.10 adds "pipesize" argument @overload def run( @@ -496,6 +496,201 @@ else: pipesize: int = -1, ) -> CompletedProcess[Any]: ... +else: + @overload + def run( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + capture_output: bool = False, + check: bool = False, + encoding: str | None = None, + errors: str | None = None, + input: str | None = None, + text: Literal[True], + timeout: float | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + capture_output: bool = False, + check: bool = False, + encoding: str, + errors: str | None = None, + input: str | None = None, + text: bool | None = None, + timeout: float | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + capture_output: bool = False, + check: bool = False, + encoding: str | None = None, + errors: str, + input: str | None = None, + text: bool | None = None, + timeout: float | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + *, + universal_newlines: Literal[True], + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + # where the *real* keyword only args start + capture_output: bool = False, + check: bool = False, + encoding: str | None = None, + errors: str | None = None, + input: str | None = None, + text: bool | None = None, + timeout: float | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> CompletedProcess[str]: ... + @overload + def run( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: Literal[False] | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + capture_output: bool = False, + check: bool = False, + encoding: None = None, + errors: None = None, + input: ReadableBuffer | None = None, + text: Literal[False] | None = None, + timeout: float | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> CompletedProcess[bytes]: ... + @overload + def run( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + capture_output: bool = False, + check: bool = False, + encoding: str | None = None, + errors: str | None = None, + input: _InputString | None = None, + text: bool | None = None, + timeout: float | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> CompletedProcess[Any]: ... + # Same args as Popen.__init__ if sys.version_info >= (3, 11): # 3.11 adds "process_group" argument @@ -504,7 +699,254 @@ if sys.version_info >= (3, 11): bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, - stdout: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + encoding: str | None = None, + timeout: float | None = None, + text: bool | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + pipesize: int = -1, + process_group: int | None = None, + ) -> int: ... + +elif sys.version_info >= (3, 10): + # 3.10 adds "pipesize" argument + def call( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + encoding: str | None = None, + timeout: float | None = None, + text: bool | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + pipesize: int = -1, + ) -> int: ... + +else: + def call( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + encoding: str | None = None, + timeout: float | None = None, + text: bool | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> int: ... + +# Same args as Popen.__init__ +if sys.version_info >= (3, 11): + # 3.11 adds "process_group" argument + def check_call( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + timeout: float | None = None, + *, + encoding: str | None = None, + text: bool | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + pipesize: int = -1, + process_group: int | None = None, + ) -> int: ... + +elif sys.version_info >= (3, 10): + # 3.10 adds "pipesize" argument + def check_call( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + timeout: float | None = None, + *, + encoding: str | None = None, + text: bool | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + pipesize: int = -1, + ) -> int: ... + +else: + def check_call( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stdout: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + timeout: float | None = None, + *, + encoding: str | None = None, + text: bool | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> int: ... + +if sys.version_info >= (3, 11): + # 3.11 adds "process_group" argument + @overload + def check_output( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + timeout: float | None = None, + input: _InputString | None = None, + encoding: str | None = None, + errors: str | None = None, + text: Literal[True], + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + pipesize: int = -1, + process_group: int | None = None, + ) -> str: ... + @overload + def check_output( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, + stderr: _FILE = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + timeout: float | None = None, + input: _InputString | None = None, + encoding: str, + errors: str | None = None, + text: bool | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + pipesize: int = -1, + process_group: int | None = None, + ) -> str: ... + @overload + def check_output( + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, @@ -518,8 +960,10 @@ if sys.version_info >= (3, 11): start_new_session: bool = False, pass_fds: Collection[int] = (), *, - encoding: str | None = None, timeout: float | None = None, + input: _InputString | None = None, + encoding: str | None = None, + errors: str, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, @@ -527,80 +971,76 @@ if sys.version_info >= (3, 11): umask: int = -1, pipesize: int = -1, process_group: int | None = None, - ) -> int: ... - -else: - # 3.10 adds "pipesize" argument - def call( + ) -> str: ... + @overload + def check_output( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, - stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: bool | None = None, + *, + universal_newlines: Literal[True], startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - *, - encoding: str | None = None, + # where the real keyword only ones start timeout: float | None = None, + input: _InputString | None = None, + encoding: str | None = None, + errors: str | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - ) -> int: ... - -# Same args as Popen.__init__ -if sys.version_info >= (3, 11): - # 3.11 adds "process_group" argument - def check_call( + process_group: int | None = None, + ) -> str: ... + @overload + def check_output( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, - stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: bool | None = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - timeout: float | None = None, *, - encoding: str | None = None, - text: bool | None = None, + timeout: float | None = None, + input: _InputString | None = None, + encoding: None = None, + errors: None = None, + text: Literal[False] | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, process_group: int | None = None, - ) -> int: ... - -else: - # 3.10 adds "pipesize" argument - def check_call( + ) -> bytes: ... + @overload + def check_output( args: _CMD, bufsize: int = -1, executable: StrOrBytesPath | None = None, stdin: _FILE = None, - stdout: _FILE = None, stderr: _FILE = None, preexec_fn: Callable[[], object] | None = None, close_fds: bool = True, @@ -613,19 +1053,22 @@ else: restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), - timeout: float | None = None, *, + timeout: float | None = None, + input: _InputString | None = None, encoding: str | None = None, + errors: str | None = None, text: bool | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - ) -> int: ... + process_group: int | None = None, + ) -> Any: ... # morally: -> str | bytes -if sys.version_info >= (3, 11): - # 3.11 adds "process_group" argument +elif sys.version_info >= (3, 10): + # 3.10 adds "pipesize" argument @overload def check_output( args: _CMD, @@ -655,7 +1098,6 @@ if sys.version_info >= (3, 11): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, ) -> str: ... @overload def check_output( @@ -686,7 +1128,6 @@ if sys.version_info >= (3, 11): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, ) -> str: ... @overload def check_output( @@ -717,7 +1158,6 @@ if sys.version_info >= (3, 11): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, ) -> str: ... @overload def check_output( @@ -749,7 +1189,6 @@ if sys.version_info >= (3, 11): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, ) -> str: ... @overload def check_output( @@ -780,7 +1219,6 @@ if sys.version_info >= (3, 11): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, ) -> bytes: ... @overload def check_output( @@ -811,11 +1249,9 @@ if sys.version_info >= (3, 11): extra_groups: Iterable[str | int] | None = None, umask: int = -1, pipesize: int = -1, - process_group: int | None = None, ) -> Any: ... # morally: -> str | bytes else: - # 3.10 adds "pipesize" argument @overload def check_output( args: _CMD, @@ -844,7 +1280,6 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, - pipesize: int = -1, ) -> str: ... @overload def check_output( @@ -874,7 +1309,6 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, - pipesize: int = -1, ) -> str: ... @overload def check_output( @@ -904,7 +1338,6 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, - pipesize: int = -1, ) -> str: ... @overload def check_output( @@ -935,7 +1368,6 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, - pipesize: int = -1, ) -> str: ... @overload def check_output( @@ -965,7 +1397,6 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, - pipesize: int = -1, ) -> bytes: ... @overload def check_output( @@ -995,7 +1426,6 @@ else: group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, umask: int = -1, - pipesize: int = -1, ) -> Any: ... # morally: -> str | bytes PIPE: Final[int] @@ -1228,7 +1658,7 @@ class Popen(Generic[AnyStr]): pipesize: int = -1, process_group: int | None = None, ) -> None: ... - else: + elif sys.version_info >= (3, 10): # pipesize is added in 3.10 @overload def __init__( @@ -1411,6 +1841,182 @@ class Popen(Generic[AnyStr]): umask: int = -1, pipesize: int = -1, ) -> None: ... + else: + @overload + def __init__( + self: Popen[str], + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE | None = None, + stdout: _FILE | None = None, + stderr: _FILE | None = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + text: bool | None = None, + encoding: str, + errors: str | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> None: ... + @overload + def __init__( + self: Popen[str], + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE | None = None, + stdout: _FILE | None = None, + stderr: _FILE | None = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + text: bool | None = None, + encoding: str | None = None, + errors: str, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> None: ... + @overload + def __init__( + self: Popen[str], + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE | None = None, + stdout: _FILE | None = None, + stderr: _FILE | None = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + *, + universal_newlines: Literal[True], + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + # where the *real* keyword only args start + text: bool | None = None, + encoding: str | None = None, + errors: str | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> None: ... + @overload + def __init__( + self: Popen[str], + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE | None = None, + stdout: _FILE | None = None, + stderr: _FILE | None = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + text: Literal[True], + encoding: str | None = None, + errors: str | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> None: ... + @overload + def __init__( + self: Popen[bytes], + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE | None = None, + stdout: _FILE | None = None, + stderr: _FILE | None = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: Literal[False] | None = None, + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + text: Literal[False] | None = None, + encoding: None = None, + errors: None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> None: ... + @overload + def __init__( + self: Popen[Any], + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE | None = None, + stdout: _FILE | None = None, + stderr: _FILE | None = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + text: bool | None = None, + encoding: str | None = None, + errors: str | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> None: ... def poll(self) -> int | None: ... def wait(self, timeout: float | None = None) -> int: ... diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index 1f18c041465e..f83a0a4c520e 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,6 +1,6 @@ from _typeshed import Unused -from typing import IO, Any, Final, Literal, NamedTuple, NoReturn, TypeAlias, overload -from typing_extensions import Self +from typing import IO, Any, Final, Literal, NamedTuple, NoReturn, overload +from typing_extensions import Self, TypeAlias _File: TypeAlias = str | IO[bytes] diff --git a/stdlib/sys/__init__.pyi b/stdlib/sys/__init__.pyi index 734adae57184..6abef85dfb7f 100644 --- a/stdlib/sys/__init__.pyi +++ b/stdlib/sys/__init__.pyi @@ -5,8 +5,8 @@ from builtins import object as _object from collections.abc import AsyncGenerator, Callable, Sequence from io import TextIOWrapper from types import FrameType, ModuleType, TracebackType -from typing import Any, Final, Literal, NoReturn, Protocol, TextIO, TypeAlias, TypeVar, final, overload, type_check_only -from typing_extensions import LiteralString, deprecated +from typing import Any, Final, Literal, NoReturn, Protocol, TextIO, TypeVar, final, overload, type_check_only +from typing_extensions import LiteralString, TypeAlias, deprecated _T = TypeVar("_T") @@ -40,7 +40,8 @@ maxsize: int maxunicode: int meta_path: list[MetaPathFinderProtocol] modules: dict[str, ModuleType] -orig_argv: list[str] +if sys.version_info >= (3, 10): + orig_argv: list[str] path: list[str] path_hooks: list[Callable[[str], PathEntryFinderProtocol]] path_importer_cache: dict[str, PathEntryFinderProtocol | None] @@ -65,7 +66,8 @@ stdin: TextIO | MaybeNone stdout: TextIO | MaybeNone stderr: TextIO | MaybeNone -stdlib_module_names: frozenset[str] +if sys.version_info >= (3, 10): + stdlib_module_names: frozenset[str] __stdin__: Final[TextIOWrapper | None] # Contains the original value of stdin __stdout__: Final[TextIOWrapper | None] # Contains the original value of stdout @@ -122,7 +124,7 @@ class _flags(_UninstantiableStructseq, tuple[int, ...]): "safe_path", "int_max_str_digits", ) - else: + elif sys.version_info >= (3, 10): __match_args__: Final = ( "debug", "inspect", @@ -173,8 +175,9 @@ class _flags(_UninstantiableStructseq, tuple[int, ...]): def dev_mode(self) -> bool: ... @property def utf8_mode(self) -> int: ... - @property - def warn_default_encoding(self) -> int: ... + if sys.version_info >= (3, 10): + @property + def warn_default_encoding(self) -> int: ... if sys.version_info >= (3, 11): @property def safe_path(self) -> bool: ... @@ -200,19 +203,20 @@ float_info: _float_info @final @type_check_only class _float_info(structseq[float], tuple[float, int, int, float, int, int, int, int, float, int, int]): - __match_args__: Final = ( - "max", - "max_exp", - "max_10_exp", - "min", - "min_exp", - "min_10_exp", - "dig", - "mant_dig", - "epsilon", - "radix", - "rounds", - ) + if sys.version_info >= (3, 10): + __match_args__: Final = ( + "max", + "max_exp", + "max_10_exp", + "min", + "min_exp", + "min_10_exp", + "dig", + "mant_dig", + "epsilon", + "radix", + "rounds", + ) @property def max(self) -> float: ... # DBL_MAX @@ -243,7 +247,8 @@ hash_info: _hash_info @final @type_check_only class _hash_info(structseq[Any | int], tuple[int, int, int, int, int, str, int, int, int]): - __match_args__: Final = ("width", "modulus", "inf", "nan", "imag", "algorithm", "hash_bits", "seed_bits", "cutoff") + if sys.version_info >= (3, 10): + __match_args__: Final = ("width", "modulus", "inf", "nan", "imag", "algorithm", "hash_bits", "seed_bits", "cutoff") @property def width(self) -> int: ... @@ -285,7 +290,8 @@ int_info: _int_info @final @type_check_only class _int_info(structseq[int], tuple[int, int, int, int]): - __match_args__: Final = ("bits_per_digit", "sizeof_digit", "default_max_str_digits", "str_digits_check_threshold") + if sys.version_info >= (3, 10): + __match_args__: Final = ("bits_per_digit", "sizeof_digit", "default_max_str_digits", "str_digits_check_threshold") @property def bits_per_digit(self) -> int: ... @@ -303,7 +309,8 @@ _ThreadInfoLock: TypeAlias = Literal["semaphore", "mutex+cond"] | None @final @type_check_only class _thread_info(_UninstantiableStructseq, tuple[_ThreadInfoName, _ThreadInfoLock, str | None]): - __match_args__: Final = ("name", "lock", "version") + if sys.version_info >= (3, 10): + __match_args__: Final = ("name", "lock", "version") @property def name(self) -> _ThreadInfoName: ... @@ -319,7 +326,8 @@ _ReleaseLevel: TypeAlias = Literal["alpha", "beta", "candidate", "final"] @final @type_check_only class _version_info(_UninstantiableStructseq, tuple[int, int, int, _ReleaseLevel, int]): - __match_args__: Final = ("major", "minor", "micro", "releaselevel", "serial") + if sys.version_info >= (3, 10): + __match_args__: Final = ("major", "minor", "micro", "releaselevel", "serial") @property def major(self) -> int: ... @@ -459,7 +467,8 @@ _AsyncgenHook: TypeAlias = Callable[[AsyncGenerator[Any, Any]], None] | None @final @type_check_only class _asyncgen_hooks(structseq[_AsyncgenHook], tuple[_AsyncgenHook, _AsyncgenHook]): - __match_args__: Final = ("firstiter", "finalizer") + if sys.version_info >= (3, 10): + __match_args__: Final = ("firstiter", "finalizer") @property def firstiter(self) -> _AsyncgenHook: ... diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index 19268ebb33fc..8de7ddc4255f 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -26,11 +26,13 @@ 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_default_scheme() -> LiteralString: ... -def get_preferred_scheme(key: Literal["prefix", "home", "user"]) -> LiteralString: ... -# Documented -- see https://docs.python.org/3/library/sysconfig.html#sysconfig._get_preferred_schemes -def _get_preferred_schemes() -> dict[Literal["prefix", "home", "user"], LiteralString]: ... +if sys.version_info >= (3, 10): + def get_default_scheme() -> LiteralString: ... + def get_preferred_scheme(key: Literal["prefix", "home", "user"]) -> LiteralString: ... + # Documented -- see https://docs.python.org/3/library/sysconfig.html#sysconfig._get_preferred_schemes + def _get_preferred_schemes() -> dict[Literal["prefix", "home", "user"], LiteralString]: ... + def get_path_names() -> tuple[str, ...]: ... def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = None, expand: bool = True) -> str: ... def get_paths(scheme: str = ..., vars: dict[str, Any] | None = None, expand: bool = True) -> dict[str, str]: ... diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 91da5ab4f5b4..6e68c370f3aa 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -6,8 +6,8 @@ from builtins import list as _list # aliases to avoid name clashes with fields 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, ClassVar, Final, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import IO, ClassVar, Final, Literal, Protocol, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated if sys.version_info >= (3, 14): from compression.zstd import ZstdDict diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 1e8e8679add5..26491074ff71 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -421,7 +421,7 @@ class TemporaryDirectory(Generic[AnyStr]): *, delete: bool = True, ) -> None: ... - else: + elif sys.version_info >= (3, 10): @overload def __init__( self: TemporaryDirectory[str], @@ -438,6 +438,18 @@ class TemporaryDirectory(Generic[AnyStr]): dir: BytesPath | None = None, ignore_cleanup_errors: bool = False, ) -> None: ... + else: + @overload + def __init__( + self: TemporaryDirectory[str], suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None + ) -> None: ... + @overload + def __init__( + self: TemporaryDirectory[bytes], + suffix: bytes | None = None, + prefix: bytes | None = None, + dir: BytesPath | None = None, + ) -> None: ... def cleanup(self) -> None: ... def __enter__(self) -> AnyStr: ... diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index 971c9ad46bf4..a35be5dfe740 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -1,6 +1,7 @@ import sys from _typeshed import FileDescriptorLike -from typing import Any, Final, TypeAlias +from typing import Any, Final +from typing_extensions import TypeAlias # Must be a list of length 7, containing 6 ints and a list of NCCS 1-character bytes or ints. _Attr: TypeAlias = list[int | list[bytes | int]] | list[int | list[bytes]] | list[int | list[int]] diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index b806ce0ae084..abc7fe7e8124 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -37,7 +37,8 @@ __all__ = [ "get_native_id", ] -__all__ += ["getprofile", "gettrace"] +if sys.version_info >= (3, 10): + __all__ += ["getprofile", "gettrace"] if sys.version_info >= (3, 12): __all__ += ["setprofile_all_threads", "settrace_all_threads"] @@ -60,8 +61,10 @@ if sys.version_info >= (3, 12): def setprofile_all_threads(func: ProfileFunction | None) -> None: ... def settrace_all_threads(func: TraceFunction | None) -> None: ... -def gettrace() -> TraceFunction | None: ... -def getprofile() -> ProfileFunction | None: ... +if sys.version_info >= (3, 10): + def gettrace() -> TraceFunction | None: ... + def getprofile() -> ProfileFunction | None: ... + def stack_size(size: int = 0, /) -> int: ... TIMEOUT_MAX: Final[float] @@ -170,7 +173,8 @@ class Event: def wait(self, timeout: float | None = None) -> bool: ... excepthook: Callable[[_ExceptHookArgs], object] -__excepthook__: Callable[[_ExceptHookArgs], object] +if sys.version_info >= (3, 10): + __excepthook__: Callable[[_ExceptHookArgs], object] ExceptHookArgs = _ExceptHookArgs class Timer(Thread): diff --git a/stdlib/time.pyi b/stdlib/time.pyi index ac53089b8d82..64a009318894 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -1,6 +1,7 @@ import sys from _typeshed import structseq -from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, final, type_check_only +from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, final, type_check_only +from typing_extensions import TypeAlias _TimeTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int] @@ -46,7 +47,8 @@ if sys.platform == "linux": # https://github.com/python/typeshed/pull/6560#discussion_r767162532 @final class struct_time(structseq[Any | int], _TimeTuple): - __match_args__: Final = ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst") + if sys.version_info >= (3, 10): + __match_args__: Final = ("tm_year", "tm_mon", "tm_mday", "tm_hour", "tm_min", "tm_sec", "tm_wday", "tm_yday", "tm_isdst") @property def tm_year(self) -> int: ... diff --git a/stdlib/timeit.pyi b/stdlib/timeit.pyi index 9ce00952c882..61935815f68b 100644 --- a/stdlib/timeit.pyi +++ b/stdlib/timeit.pyi @@ -1,6 +1,7 @@ import time from collections.abc import Callable, Sequence -from typing import IO, Any, TypeAlias +from typing import IO, Any +from typing_extensions import TypeAlias __all__ = ["Timer", "timeit", "repeat", "default_timer"] diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 265d6bb98794..90225a8a3652 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -5,21 +5,8 @@ from collections.abc import Callable, Iterable, Mapping, Sequence from tkinter.constants import * from tkinter.font import _FontDescription from types import GenericAlias, TracebackType -from typing import ( - Any, - ClassVar, - Final, - Generic, - Literal, - NamedTuple, - Protocol, - TypeAlias, - TypedDict, - TypeVar, - overload, - type_check_only, -) -from typing_extensions import TypeVarTuple, Unpack, deprecated, disjoint_base +from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, Protocol, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias, TypeVarTuple, Unpack, deprecated, disjoint_base if sys.version_info >= (3, 11): from enum import StrEnum diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index 5d660c56fe50..327ba7a2432e 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,8 +1,9 @@ import _tkinter import itertools +import sys import tkinter -from typing import Any, ClassVar, Final, Literal, TypeAlias, TypedDict, overload, type_check_only -from typing_extensions import Unpack +from typing import Any, ClassVar, Final, Literal, TypedDict, overload, type_check_only +from typing_extensions import TypeAlias, Unpack __all__ = ["NORMAL", "ROMAN", "BOLD", "ITALIC", "nametofont", "Font", "families", "names"] @@ -111,4 +112,9 @@ class Font: def families(root: tkinter.Misc | None = None, displayof: tkinter.Misc | None = None) -> tuple[str, ...]: ... def names(root: tkinter.Misc | None = None) -> tuple[str, ...]: ... -def nametofont(name: str, root: tkinter.Misc | None = None) -> Font: ... + +if sys.version_info >= (3, 10): + def nametofont(name: str, root: tkinter.Misc | None = None) -> Font: ... + +else: + def nametofont(name: str) -> Font: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index c2d79e4c7aa0..7143c7cce592 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -4,8 +4,8 @@ import tkinter from _typeshed import MaybeNone from collections.abc import Callable, Iterable, Sequence from tkinter.font import _FontDescription -from typing import Any, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Never, ParamSpec, Unpack +from typing import Any, Literal, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Never, ParamSpec, TypeAlias, Unpack __all__ = [ "Button", diff --git a/stdlib/token.pyi b/stdlib/token.pyi index a9ee3a48b87c..fd1b10da1d12 100644 --- a/stdlib/token.pyi +++ b/stdlib/token.pyi @@ -73,7 +73,8 @@ __all__ = [ if sys.version_info < (3, 13): __all__ += ["ASYNC", "AWAIT"] -__all__ += ["SOFT_KEYWORD"] +if sys.version_info >= (3, 10): + __all__ += ["SOFT_KEYWORD"] if sys.version_info >= (3, 12): __all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"] @@ -149,7 +150,8 @@ TYPE_COMMENT: Final[int] TYPE_IGNORE: Final[int] COLONEQUAL: Final[int] EXACT_TOKEN_TYPES: Final[dict[str, int]] -SOFT_KEYWORD: Final[int] +if sys.version_info >= (3, 10): + SOFT_KEYWORD: Final[int] if sys.version_info >= (3, 12): EXCLAMATION: Final[int] diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index 3ea4e7db7248..00a24b4eea07 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -3,8 +3,8 @@ from _typeshed import FileDescriptorOrPath from collections.abc import Callable, Generator, Iterable, Sequence from re import Pattern from token import * -from typing import Any, Final, NamedTuple, TextIO, TypeAlias, type_check_only -from typing_extensions import disjoint_base +from typing import Any, Final, NamedTuple, TextIO, type_check_only +from typing_extensions import TypeAlias, disjoint_base if sys.version_info < (3, 12): # Avoid double assignment to Final name by imports, which pyright objects to. @@ -89,7 +89,8 @@ __all__ = [ if sys.version_info < (3, 13): __all__ += ["ASYNC", "AWAIT"] -__all__ += ["SOFT_KEYWORD"] +if sys.version_info >= (3, 10): + __all__ += ["SOFT_KEYWORD"] if sys.version_info >= (3, 12): __all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"] diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index 20351dd5eccf..7e7cc1e9ac54 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -2,8 +2,8 @@ import sys import types from _typeshed import Incomplete, StrPath, TraceFunction from collections.abc import Callable, Iterable, Mapping, Sequence -from typing import Any, TypeAlias, TypeVar -from typing_extensions import ParamSpec +from typing import Any, TypeVar +from typing_extensions import ParamSpec, TypeAlias __all__ = ["Trace", "CoverageResults"] diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index 593c13ef5eb4..4305706afa20 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import SupportsWrite, Unused from collections.abc import Generator, Iterable, Iterator, Mapping from types import FrameType, TracebackType -from typing import Any, ClassVar, Literal, SupportsIndex, TypeAlias, overload -from typing_extensions import Self, deprecated +from typing import Any, ClassVar, Literal, SupportsIndex, overload +from typing_extensions import Self, TypeAlias, deprecated __all__ = [ "extract_stack", @@ -33,31 +33,51 @@ if sys.version_info >= (3, 14): _FrameSummaryTuple: TypeAlias = tuple[str, int, str, str | None] def print_tb(tb: TracebackType | None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ... -@overload -def print_exception( - exc: type[BaseException] | None, - /, - value: BaseException | None = ..., - tb: TracebackType | None = ..., - limit: int | None = None, - file: SupportsWrite[str] | None = None, - chain: bool = True, -) -> None: ... -@overload -def print_exception( - exc: BaseException, /, *, limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True -) -> None: ... -@overload -def format_exception( - exc: type[BaseException] | None, - /, - value: BaseException | None = ..., - tb: TracebackType | None = ..., - limit: int | None = None, - chain: bool = True, -) -> list[str]: ... -@overload -def format_exception(exc: BaseException, /, *, limit: int | None = None, chain: bool = True) -> list[str]: ... + +if sys.version_info >= (3, 10): + @overload + def print_exception( + exc: type[BaseException] | None, + /, + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = None, + file: SupportsWrite[str] | None = None, + chain: bool = True, + ) -> None: ... + @overload + def print_exception( + exc: BaseException, /, *, limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True + ) -> None: ... + @overload + def format_exception( + exc: type[BaseException] | None, + /, + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = None, + chain: bool = True, + ) -> list[str]: ... + @overload + def format_exception(exc: BaseException, /, *, limit: int | None = None, chain: bool = True) -> list[str]: ... + +else: + def print_exception( + etype: type[BaseException] | None, + value: BaseException | None, + tb: TracebackType | None, + limit: int | None = None, + file: SupportsWrite[str] | None = None, + chain: bool = True, + ) -> None: ... + def format_exception( + etype: type[BaseException] | None, + value: BaseException | None, + tb: TracebackType | None, + limit: int | None = None, + chain: bool = True, + ) -> list[str]: ... + def print_exc(limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ... def print_last(limit: int | None = None, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ... def print_stack(f: FrameType | None = None, limit: int | None = None, file: SupportsWrite[str] | None = None) -> None: ... @@ -72,12 +92,15 @@ if sys.version_info >= (3, 13): @overload def format_exception_only(exc: Unused, /, value: BaseException | None, *, show_group: bool = False) -> list[str]: ... -else: +elif sys.version_info >= (3, 10): @overload def format_exception_only(exc: BaseException | None, /) -> list[str]: ... @overload def format_exception_only(exc: Unused, /, value: BaseException | None) -> list[str]: ... +else: + def format_exception_only(etype: type[BaseException] | None, value: BaseException | None) -> list[str]: ... + def format_exc(limit: int | None = None, chain: bool = True) -> str: ... def format_tb(tb: TracebackType | None, limit: int | None = None) -> list[str]: ... def format_stack(f: FrameType | None = None, limit: int | None = None) -> list[str]: ... @@ -103,10 +126,12 @@ class TracebackException: # These fields only exist for `SyntaxError`s, but there is no way to express that in the type system. filename: str lineno: str | None - end_lineno: str | None + if sys.version_info >= (3, 10): + end_lineno: str | None text: str offset: int - end_offset: int | None + if sys.version_info >= (3, 10): + end_offset: int | None msg: str if sys.version_info >= (3, 13): @@ -148,7 +173,7 @@ class TracebackException: max_group_depth: int = 10, _seen: set[int] | None = None, ) -> None: ... - else: + elif sys.version_info >= (3, 10): def __init__( self, exc_type: type[BaseException], @@ -161,6 +186,18 @@ class TracebackException: compact: bool = False, _seen: set[int] | None = None, ) -> None: ... + else: + def __init__( + self, + exc_type: type[BaseException], + exc_value: BaseException, + exc_traceback: TracebackType | None, + *, + limit: int | None = None, + lookup_lines: bool = True, + capture_locals: bool = False, + _seen: set[int] | None = None, + ) -> None: ... if sys.version_info >= (3, 11): @classmethod @@ -175,7 +212,7 @@ class TracebackException: max_group_width: int = 15, max_group_depth: int = 10, ) -> Self: ... - else: + elif sys.version_info >= (3, 10): @classmethod def from_exception( cls, @@ -186,6 +223,11 @@ class TracebackException: capture_locals: bool = False, compact: bool = False, ) -> Self: ... + else: + @classmethod + def from_exception( + cls, exc: BaseException, *, limit: int | None = None, lookup_lines: bool = True, capture_locals: bool = False + ) -> Self: ... def __eq__(self, other: object) -> bool: ... __hash__: ClassVar[None] # type: ignore[assignment] diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 042d1ca94ee7..2a7ee0051af9 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,7 +1,8 @@ import sys from _tracemalloc import * from collections.abc import Sequence -from typing import Any, SupportsIndex, TypeAlias, overload +from typing import Any, SupportsIndex, overload +from typing_extensions import TypeAlias def get_object_traceback(obj: object) -> Traceback | None: ... def take_snapshot() -> Snapshot: ... diff --git a/stdlib/tty.pyi b/stdlib/tty.pyi index a0478335a3f3..ca3f0013b20e 100644 --- a/stdlib/tty.pyi +++ b/stdlib/tty.pyi @@ -1,6 +1,7 @@ import sys import termios -from typing import IO, Final, TypeAlias +from typing import IO, Final +from typing_extensions import TypeAlias if sys.platform != "win32": __all__ = ["setraw", "setcbreak"] diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 0667a8d5dbdd..b5f536d0e28e 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -3,8 +3,8 @@ from _typeshed import StrPath from collections.abc import Callable, Generator, Sequence from contextlib import contextmanager from tkinter import Canvas, Frame, Misc, PhotoImage, Scrollbar -from typing import Any, ClassVar, Literal, TypeAlias, TypedDict, overload, type_check_only -from typing_extensions import Self, deprecated, disjoint_base +from typing import Any, ClassVar, Literal, TypedDict, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated, disjoint_base __all__ = [ "ScrolledCanvas", diff --git a/stdlib/types.pyi b/stdlib/types.pyi index da8da3670f00..568f6ea68d0b 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -52,7 +52,8 @@ __all__ = [ "GenericAlias", ] -__all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"] +if sys.version_info >= (3, 10): + __all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"] if sys.version_info >= (3, 12): __all__ += ["get_original_bases"] @@ -83,8 +84,9 @@ class FunctionType: if sys.version_info >= (3, 14): __annotate__: AnnotateFunc | None __kwdefaults__: dict[str, Any] | None - @property - def __builtins__(self) -> dict[str, Any]: ... + if sys.version_info >= (3, 10): + @property + def __builtins__(self) -> dict[str, Any]: ... if sys.version_info >= (3, 12): __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] @@ -147,16 +149,22 @@ class CodeType: def co_name(self) -> str: ... @property def co_firstlineno(self) -> int: ... - @property - @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `CodeType.co_lines()` instead.") - def co_lnotab(self) -> bytes: ... + if sys.version_info >= (3, 10): + @property + @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `CodeType.co_lines()` instead.") + def co_lnotab(self) -> bytes: ... + else: + @property + def co_lnotab(self) -> bytes: ... + @property def co_freevars(self) -> tuple[str, ...]: ... @property def co_cellvars(self) -> tuple[str, ...]: ... - @property - def co_linetable(self) -> bytes: ... - def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ... + if sys.version_info >= (3, 10): + @property + def co_linetable(self) -> bytes: ... + def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ... if sys.version_info >= (3, 11): @property def co_exceptiontable(self) -> bytes: ... @@ -189,7 +197,7 @@ class CodeType: cellvars: tuple[str, ...] = ..., /, ) -> Self: ... - else: + elif sys.version_info >= (3, 10): def __new__( cls, argcount: int, @@ -210,6 +218,27 @@ class CodeType: cellvars: tuple[str, ...] = ..., /, ) -> Self: ... + else: + def __new__( + cls, + argcount: int, + posonlyargcount: int, + kwonlyargcount: int, + nlocals: int, + stacksize: int, + flags: int, + codestring: bytes, + constants: tuple[object, ...], + names: tuple[str, ...], + varnames: tuple[str, ...], + filename: str, + name: str, + firstlineno: int, + lnotab: bytes, + freevars: tuple[str, ...] = ..., + cellvars: tuple[str, ...] = ..., + /, + ) -> Self: ... if sys.version_info >= (3, 11): def replace( self, @@ -233,7 +262,7 @@ class CodeType: co_linetable: bytes = ..., co_exceptiontable: bytes = ..., ) -> Self: ... - else: + elif sys.version_info >= (3, 10): def replace( self, *, @@ -254,6 +283,27 @@ class CodeType: co_name: str = ..., co_linetable: bytes = ..., ) -> Self: ... + else: + def replace( + self, + *, + co_argcount: int = -1, + co_posonlyargcount: int = -1, + co_kwonlyargcount: int = -1, + co_nlocals: int = -1, + co_stacksize: int = -1, + co_flags: int = -1, + co_firstlineno: int = -1, + co_code: bytes = ..., + co_consts: tuple[object, ...] = ..., + 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 = ..., + ) -> Self: ... if sys.version_info >= (3, 13): __replace__ = replace @@ -647,42 +697,43 @@ class GenericAlias: def __unpacked__(self) -> bool: ... @property def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ... - - def __or__(self, value: Any, /) -> UnionType: ... - def __ror__(self, value: Any, /) -> UnionType: ... + if sys.version_info >= (3, 10): + def __or__(self, value: Any, /) -> UnionType: ... + def __ror__(self, value: Any, /) -> UnionType: ... # GenericAlias delegates attr access to `__origin__` def __getattr__(self, name: str) -> Any: ... -@final -class NoneType: - def __bool__(self) -> Literal[False]: ... +if sys.version_info >= (3, 10): + @final + class NoneType: + def __bool__(self) -> Literal[False]: ... -@final -class EllipsisType: ... + @final + class EllipsisType: ... -@final -class NotImplementedType(Any): ... + @final + class NotImplementedType(Any): ... -@final -class UnionType: - @property - def __args__(self) -> tuple[Any, ...]: ... - @property - def __parameters__(self) -> tuple[Any, ...]: ... - # `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`). - # Normally we'd express this using the return type of `_SpecialForm.__ror__`, - # but because `UnionType.__or__` accepts `Any`, type checkers will use - # the return type of `UnionType.__or__` to infer the result of this operation - # rather than `_SpecialForm.__ror__`. To mitigate this, we use `| Any` - # in the return type of `UnionType.__(r)or__`. - def __or__(self, value: Any, /) -> UnionType | Any: ... - def __ror__(self, value: Any, /) -> UnionType | Any: ... - def __eq__(self, value: object, /) -> bool: ... - def __hash__(self) -> int: ... - # you can only subscript a `UnionType` instance if at least one of the elements - # in the union is a generic alias instance that has a non-empty `__parameters__` - def __getitem__(self, parameters: Any) -> object: ... + @final + class UnionType: + @property + def __args__(self) -> tuple[Any, ...]: ... + @property + def __parameters__(self) -> tuple[Any, ...]: ... + # `(int | str) | Literal["foo"]` returns a generic alias to an instance of `_SpecialForm` (`Union`). + # Normally we'd express this using the return type of `_SpecialForm.__ror__`, + # but because `UnionType.__or__` accepts `Any`, type checkers will use + # the return type of `UnionType.__or__` to infer the result of this operation + # rather than `_SpecialForm.__ror__`. To mitigate this, we use `| Any` + # in the return type of `UnionType.__(r)or__`. + def __or__(self, value: Any, /) -> UnionType | Any: ... + def __ror__(self, value: Any, /) -> UnionType | Any: ... + def __eq__(self, value: object, /) -> bool: ... + def __hash__(self) -> int: ... + # you can only subscript a `UnionType` instance if at least one of the elements + # in the union is a generic alias instance that has a non-empty `__parameters__` + def __getitem__(self, parameters: Any) -> object: ... if sys.version_info >= (3, 13): @final diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 6a3532420c40..369af41a7ad9 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -27,7 +27,8 @@ if sys.version_info >= (3, 14): from annotationlib import Format -from types import UnionType +if sys.version_info >= (3, 10): + from types import UnionType __all__ = [ "AbstractSet", @@ -112,7 +113,8 @@ __all__ = [ if sys.version_info >= (3, 14): __all__ += ["evaluate_forward_ref"] -__all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"] +if sys.version_info >= (3, 10): + __all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"] if sys.version_info >= (3, 11): __all__ += [ @@ -204,9 +206,9 @@ class TypeVar: covariant: bool = False, contravariant: bool = False, ) -> None: ... - - def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm - def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm + if sys.version_info >= (3, 10): + def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm + def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm if sys.version_info >= (3, 11): def __typing_subst__(self, arg: Any, /) -> Any: ... if sys.version_info >= (3, 13): @@ -225,8 +227,9 @@ class TypeVar: class _SpecialForm(_Final): __slots__ = ("_name", "__doc__", "_getitem") def __getitem__(self, parameters: Any) -> object: ... - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... + if sys.version_info >= (3, 10): + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... Union: _SpecialForm Protocol: _SpecialForm @@ -272,108 +275,122 @@ if sys.version_info >= (3, 11): @property def evaluate_default(self) -> EvaluateFunc | None: ... -@final -class ParamSpecArgs: - @property - def __origin__(self) -> ParamSpec: ... - if sys.version_info >= (3, 12): - def __new__(cls, origin: ParamSpec) -> Self: ... - else: - def __init__(self, origin: ParamSpec) -> None: ... +if sys.version_info >= (3, 10): + @final + class ParamSpecArgs: + @property + def __origin__(self) -> ParamSpec: ... + if sys.version_info >= (3, 12): + def __new__(cls, origin: ParamSpec) -> Self: ... + else: + def __init__(self, origin: ParamSpec) -> None: ... - def __eq__(self, other: object, /) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] + def __eq__(self, other: object, /) -> bool: ... + __hash__: ClassVar[None] # type: ignore[assignment] -@final -class ParamSpecKwargs: - @property - def __origin__(self) -> ParamSpec: ... - if sys.version_info >= (3, 12): - def __new__(cls, origin: ParamSpec) -> Self: ... - else: - def __init__(self, origin: ParamSpec) -> None: ... + @final + class ParamSpecKwargs: + @property + def __origin__(self) -> ParamSpec: ... + if sys.version_info >= (3, 12): + def __new__(cls, origin: ParamSpec) -> Self: ... + else: + def __init__(self, origin: ParamSpec) -> None: ... - def __eq__(self, other: object, /) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] + def __eq__(self, other: object, /) -> bool: ... + __hash__: ClassVar[None] # type: ignore[assignment] -@final -class ParamSpec: - @property - def __name__(self) -> str: ... - @property - def __bound__(self) -> Any | None: ... # AnnotationForm - @property - def __covariant__(self) -> bool: ... - @property - def __contravariant__(self) -> bool: ... - if sys.version_info >= (3, 12): + @final + class ParamSpec: @property - def __infer_variance__(self) -> bool: ... - if sys.version_info >= (3, 13): + def __name__(self) -> str: ... @property - def __default__(self) -> Any: ... # AnnotationForm - if sys.version_info >= (3, 13): - def __new__( - cls, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - infer_variance: bool = False, - default: Any = ..., # AnnotationForm - ) -> Self: ... - elif sys.version_info >= (3, 12): - def __new__( - cls, - name: str, - *, - bound: Any | None = None, # AnnotationForm - contravariant: bool = False, - covariant: bool = False, - infer_variance: bool = False, - ) -> Self: ... - elif sys.version_info >= (3, 11): - def __new__( - cls, name: str, *, bound: Any | None = None, contravariant: bool = False, covariant: bool = False # AnnotationForm - ) -> Self: ... - else: - def __init__( - self, name: str, *, bound: Any | None = None, contravariant: bool = False, covariant: bool = False # AnnotationForm - ) -> None: ... - - @property - def args(self) -> ParamSpecArgs: ... - @property - def kwargs(self) -> ParamSpecKwargs: ... - if sys.version_info >= (3, 11): - def __typing_subst__(self, arg: Any, /) -> Any: ... - def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ... + def __bound__(self) -> Any | None: ... # AnnotationForm + @property + def __covariant__(self) -> bool: ... + @property + def __contravariant__(self) -> bool: ... + if sys.version_info >= (3, 12): + @property + def __infer_variance__(self) -> bool: ... + if sys.version_info >= (3, 13): + @property + def __default__(self) -> Any: ... # AnnotationForm + if sys.version_info >= (3, 13): + def __new__( + cls, + name: str, + *, + bound: Any | None = None, # AnnotationForm + contravariant: bool = False, + covariant: bool = False, + infer_variance: bool = False, + default: Any = ..., # AnnotationForm + ) -> Self: ... + elif sys.version_info >= (3, 12): + def __new__( + cls, + name: str, + *, + bound: Any | None = None, # AnnotationForm + contravariant: bool = False, + covariant: bool = False, + infer_variance: bool = False, + ) -> Self: ... + elif sys.version_info >= (3, 11): + def __new__( + cls, + name: str, + *, + bound: Any | None = None, # AnnotationForm + contravariant: bool = False, + covariant: bool = False, + ) -> Self: ... + else: + def __init__( + self, + name: str, + *, + bound: Any | None = None, # AnnotationForm + contravariant: bool = False, + covariant: bool = False, + ) -> None: ... - def __or__(self, right: Any, /) -> _SpecialForm: ... - def __ror__(self, left: Any, /) -> _SpecialForm: ... - if sys.version_info >= (3, 13): - def has_default(self) -> bool: ... - if sys.version_info >= (3, 14): @property - def evaluate_default(self) -> EvaluateFunc | None: ... + def args(self) -> ParamSpecArgs: ... + @property + def kwargs(self) -> ParamSpecKwargs: ... + if sys.version_info >= (3, 11): + def __typing_subst__(self, arg: Any, /) -> Any: ... + def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ... -Concatenate: _SpecialForm -TypeAlias: _SpecialForm -TypeGuard: _SpecialForm + def __or__(self, right: Any, /) -> _SpecialForm: ... + def __ror__(self, left: Any, /) -> _SpecialForm: ... + if sys.version_info >= (3, 13): + def has_default(self) -> bool: ... + if sys.version_info >= (3, 14): + @property + def evaluate_default(self) -> EvaluateFunc | None: ... -class NewType: - def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm - if sys.version_info >= (3, 11): - @staticmethod - def __call__(x: _T, /) -> _T: ... - else: - def __call__(self, x: _T) -> _T: ... + Concatenate: _SpecialForm + TypeAlias: _SpecialForm + TypeGuard: _SpecialForm - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... - __supertype__: type | NewType - __name__: str + class NewType: + def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm + if sys.version_info >= (3, 11): + @staticmethod + def __call__(x: _T, /) -> _T: ... + else: + def __call__(self, x: _T) -> _T: ... + + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... + __supertype__: type | NewType + __name__: str + +else: + def NewType(name: str, tp: Any) -> Any: ... _F = TypeVar("_F", bound=Callable[..., Any]) _P = _ParamSpec("_P") @@ -431,8 +448,12 @@ class _Generic: if sys.version_info < (3, 12): __slots__ = () - @classmethod - def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ... + if sys.version_info >= (3, 10): + @classmethod + def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ... + else: + @classmethod + def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ... Generic: type[_Generic] @@ -946,10 +967,13 @@ else: ) -> dict[str, Any]: ... # AnnotationForm def get_args(tp: Any) -> tuple[Any, ...]: ... # AnnotationForm -@overload -def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... -@overload -def get_origin(tp: UnionType) -> type[UnionType]: ... + +if sys.version_info >= (3, 10): + @overload + def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... + @overload + def get_origin(tp: UnionType) -> type[UnionType]: ... + @overload def get_origin(tp: GenericAlias) -> type: ... @overload @@ -1112,7 +1136,9 @@ else: def __or__(self, other: Any) -> _SpecialForm: ... def __ror__(self, other: Any) -> _SpecialForm: ... -def is_typeddict(tp: object) -> bool: ... +if sys.version_info >= (3, 10): + def is_typeddict(tp: object) -> bool: ... + def _type_repr(obj: object) -> str: ... if sys.version_info >= (3, 12): diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 495cc4eb3f03..8a9f0f3919ba 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -29,7 +29,7 @@ from collections.abc import ( ) from contextlib import AbstractAsyncContextManager as AsyncContextManager, AbstractContextManager as ContextManager from re import Match as Match, Pattern as Pattern -from types import GenericAlias, ModuleType, UnionType +from types import GenericAlias, ModuleType from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035 IO as IO, TYPE_CHECKING as TYPE_CHECKING, @@ -67,6 +67,9 @@ from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035 type_check_only, ) +if sys.version_info >= (3, 10): + from types import UnionType + # Please keep order the same as at runtime. __all__ = [ # Super-special typing primitives. @@ -271,8 +274,11 @@ else: ) -> dict[str, AnnotationForm]: ... def get_args(tp: AnnotationForm) -> tuple[AnnotationForm, ...]: ... -@overload -def get_origin(tp: UnionType) -> type[UnionType]: ... + +if sys.version_info >= (3, 10): + @overload + def get_origin(tp: UnionType) -> type[UnionType]: ... + @overload def get_origin(tp: GenericAlias) -> type: ... @overload @@ -284,14 +290,32 @@ Annotated: _SpecialForm _AnnotatedAlias: Any # undocumented # New and changed things in 3.10 -from typing import ( - Concatenate as Concatenate, - ParamSpecArgs as ParamSpecArgs, - ParamSpecKwargs as ParamSpecKwargs, - TypeAlias as TypeAlias, - TypeGuard as TypeGuard, - is_typeddict as is_typeddict, -) +if sys.version_info >= (3, 10): + from typing import ( + Concatenate as Concatenate, + ParamSpecArgs as ParamSpecArgs, + ParamSpecKwargs as ParamSpecKwargs, + TypeAlias as TypeAlias, + TypeGuard as TypeGuard, + is_typeddict as is_typeddict, + ) +else: + @final + class ParamSpecArgs: + @property + def __origin__(self) -> ParamSpec: ... + def __init__(self, origin: ParamSpec) -> None: ... + + @final + class ParamSpecKwargs: + @property + def __origin__(self) -> ParamSpec: ... + def __init__(self, origin: ParamSpec) -> None: ... + + Concatenate: _SpecialForm + TypeAlias: _SpecialForm + TypeGuard: _SpecialForm + def is_typeddict(tp: object) -> bool: ... # New and changed things in 3.11 if sys.version_info >= (3, 11): @@ -353,8 +377,9 @@ else: def __call__(self, obj: _T, /) -> _T: ... __supertype__: type | NewType __name__: str - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... + if sys.version_info >= (3, 10): + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... if sys.version_info >= (3, 12): from collections.abc import Buffer as Buffer @@ -502,8 +527,9 @@ else: ) -> None: ... def has_default(self) -> bool: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... - def __or__(self, right: Any) -> _SpecialForm: ... - def __ror__(self, left: Any) -> _SpecialForm: ... + if sys.version_info >= (3, 10): + def __or__(self, right: Any) -> _SpecialForm: ... + def __ror__(self, left: Any) -> _SpecialForm: ... if sys.version_info >= (3, 11): def __typing_subst__(self, arg: Any) -> Any: ... @@ -536,8 +562,9 @@ else: def kwargs(self) -> ParamSpecKwargs: ... def has_default(self) -> bool: ... def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... - def __or__(self, right: Any) -> _SpecialForm: ... - def __ror__(self, left: Any) -> _SpecialForm: ... + if sys.version_info >= (3, 10): + def __or__(self, right: Any) -> _SpecialForm: ... + def __ror__(self, left: Any) -> _SpecialForm: ... @final class TypeVarTuple: @@ -578,8 +605,9 @@ else: # Returns typing._GenericAlias, which isn't stubbed. def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> AnnotationForm: ... def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ... - def __or__(self, right: Any, /) -> _SpecialForm: ... - def __ror__(self, left: Any, /) -> _SpecialForm: ... + if sys.version_info >= (3, 10): + def __or__(self, right: Any, /) -> _SpecialForm: ... + def __ror__(self, left: Any, /) -> _SpecialForm: ... # PEP 727 class Doc: @@ -677,6 +705,6 @@ class Sentinel: if sys.version_info >= (3, 14): def __or__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions def __ror__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions - else: + elif sys.version_info >= (3, 10): def __or__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions def __ror__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions diff --git a/stdlib/unicodedata.pyi b/stdlib/unicodedata.pyi index 20acf0428158..9fff042f0b96 100644 --- a/stdlib/unicodedata.pyi +++ b/stdlib/unicodedata.pyi @@ -1,9 +1,14 @@ +import sys from _typeshed import ReadOnlyBuffer -from typing import Final, Literal, TypeAlias, TypeVar, final, overload +from typing import Any, Final, Literal, TypeVar, final, overload +from typing_extensions import TypeAlias ucd_3_2_0: UCD unidata_version: Final[str] +if sys.version_info < (3, 10): + ucnhash_CAPI: Any + _T = TypeVar("_T") _NormalizationForm: TypeAlias = Literal["NFC", "NFD", "NFKC", "NFKD"] diff --git a/stdlib/unittest/_log.pyi b/stdlib/unittest/_log.pyi index 6c6a63b096c1..011a970d8bbc 100644 --- a/stdlib/unittest/_log.pyi +++ b/stdlib/unittest/_log.pyi @@ -1,4 +1,5 @@ import logging +import sys from types import TracebackType from typing import ClassVar, Generic, NamedTuple, TypeVar from unittest.case import TestCase, _BaseTestCaseContext @@ -14,8 +15,11 @@ class _AssertLogsContext(_BaseTestCaseContext, Generic[_L]): logger_name: str level: int msg: None - def __init__(self, test_case: TestCase, logger_name: str, level: int, no_logs: bool) -> None: ... - no_logs: bool + if sys.version_info >= (3, 10): + def __init__(self, test_case: TestCase, logger_name: str, level: int, no_logs: bool) -> None: ... + no_logs: bool + else: + def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... def __enter__(self) -> _L: ... def __exit__( diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 4a7f40bbc556..a602196e73c6 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -168,9 +168,11 @@ class TestCase: def assertLogs( self, logger: str | logging.Logger | None = None, level: int | str | None = None ) -> _AssertLogsContext[_LoggingWatcher]: ... - def assertNoLogs( - self, logger: str | logging.Logger | None = None, level: int | str | None = None - ) -> _AssertLogsContext[None]: ... + if sys.version_info >= (3, 10): + def assertNoLogs( + self, logger: str | logging.Logger | None = None, level: int | str | None = None + ) -> _AssertLogsContext[None]: ... + @overload def assertAlmostEqual(self, first: _S, second: _S, places: None, msg: Any, delta: _SupportsAbsAndDunderGE) -> None: ... @overload @@ -275,7 +277,9 @@ class TestCase: self, subset: Mapping[Any, Any], dictionary: Mapping[Any, Any], msg: object = None ) -> None: ... - def __init_subclass__(cls, *args: Never, **kwargs: Never) -> None: ... + if sys.version_info >= (3, 10): + # Runtime has *args, **kwargs, but will error if any are supplied + def __init_subclass__(cls, *args: Never, **kwargs: Never) -> None: ... if sys.version_info >= (3, 14): def assertIsSubclass(self, cls: type, superclass: type | tuple[type, ...], msg: Any = None) -> None: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 251a394585f3..81de40c89849 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -4,8 +4,8 @@ import unittest.suite from collections.abc import Callable, Sequence from re import Pattern from types import ModuleType -from typing import Any, Final, TypeAlias -from typing_extensions import deprecated +from typing import Any, Final +from typing_extensions import TypeAlias, deprecated _SortComparisonMethod: TypeAlias = Callable[[str, str], int] _SuiteClass: TypeAlias = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite] diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 9993015c144e..ef51d721297a 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -3,8 +3,8 @@ from _typeshed import MaybeNone from collections.abc import Awaitable, Callable, Coroutine, Iterable, Mapping, Sequence from contextlib import _GeneratorContextManager from types import TracebackType -from typing import Any, ClassVar, Final, Generic, Literal, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, Self, disjoint_base +from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, Self, TypeAlias, disjoint_base _T = TypeVar("_T") _TT = TypeVar("_TT", bound=type[Any]) @@ -244,20 +244,35 @@ class _patch(Generic[_T]): additional_patchers: Any # If new==DEFAULT, self is _patch[Any]. Ideally we'd be able to add an overload for it so that self is _patch[MagicMock], # but that's impossible with the current type system. - def __init__( - self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 - getter: Callable[[], Any], - attribute: str, - new: _T, - spec: Any | None, - create: bool, - spec_set: Any | None, - autospec: Any | None, - new_callable: Any | None, - kwargs: Mapping[str, Any], - *, - unsafe: bool = False, - ) -> None: ... + if sys.version_info >= (3, 10): + def __init__( + self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 + getter: Callable[[], Any], + attribute: str, + new: _T, + spec: Any | None, + create: bool, + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, + kwargs: Mapping[str, Any], + *, + unsafe: bool = False, + ) -> None: ... + else: + def __init__( + self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780 + getter: Callable[[], Any], + attribute: str, + new: _T, + spec: Any | None, + create: bool, + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, + kwargs: Mapping[str, Any], + ) -> None: ... + def copy(self) -> _patch[_T]: ... @overload def __call__(self, func: _TT) -> _TT: ... @@ -300,8 +315,10 @@ class _patch_dict: clear: Any def __init__(self, in_dict: Any, values: Any = (), clear: Any = False, **kwargs: Any) -> None: ... def __call__(self, f: Any) -> Any: ... - def decorate_callable(self, f: _F) -> _F: ... - def decorate_async_callable(self, f: _AF) -> _AF: ... + if sys.version_info >= (3, 10): + def decorate_callable(self, f: _F) -> _F: ... + def decorate_async_callable(self, f: _AF) -> _AF: ... + def decorate_class(self, klass: Any) -> Any: ... def __enter__(self) -> Any: ... def __exit__(self, *args: object) -> Any: ... @@ -500,16 +517,27 @@ class _ANY(Any): ANY: _ANY -def create_autospec( - spec: Any, - spec_set: Any = False, - instance: Any = False, - _parent: Any | None = None, - _name: Any | None = None, - *, - unsafe: bool = False, - **kwargs: Any, -) -> Any: ... +if sys.version_info >= (3, 10): + def create_autospec( + spec: Any, + spec_set: Any = False, + instance: Any = False, + _parent: Any | None = None, + _name: Any | None = None, + *, + unsafe: bool = False, + **kwargs: Any, + ) -> Any: ... + +else: + def create_autospec( + spec: Any, + spec_set: Any = False, + instance: Any = False, + _parent: Any | None = None, + _name: Any | None = None, + **kwargs: Any, + ) -> Any: ... class _SpecState: spec: Any diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 081f6e1328e4..0761baaa2830 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -2,7 +2,8 @@ import sys import unittest.case from _typeshed import OptExcInfo from collections.abc import Callable -from typing import Any, Final, TextIO, TypeAlias, TypeVar +from typing import Any, Final, TextIO, TypeVar +from typing_extensions import TypeAlias _F = TypeVar("_F", bound=Callable[..., Any]) _DurationsType: TypeAlias = list[tuple[str, float]] diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index 3a2e08749e9b..f76771f55e13 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -4,8 +4,8 @@ import unittest.result import unittest.suite from _typeshed import SupportsFlush, SupportsWrite from collections.abc import Callable, Iterable -from typing import Any, Generic, Protocol, TypeAlias, TypeVar, type_check_only -from typing_extensions import Never +from typing import Any, Generic, Protocol, TypeVar, type_check_only +from typing_extensions import Never, TypeAlias from warnings import _ActionKind _ResultClassType: TypeAlias = Callable[[_TextTestStream, bool, int], TextTestResult[Any]] diff --git a/stdlib/unittest/suite.pyi b/stdlib/unittest/suite.pyi index b7cf75c68271..443396164b6f 100644 --- a/stdlib/unittest/suite.pyi +++ b/stdlib/unittest/suite.pyi @@ -1,7 +1,8 @@ import unittest.case import unittest.result from collections.abc import Iterable, Iterator -from typing import ClassVar, TypeAlias +from typing import ClassVar +from typing_extensions import TypeAlias _TestType: TypeAlias = unittest.case.TestCase | TestSuite diff --git a/stdlib/unittest/util.pyi b/stdlib/unittest/util.pyi index 11a6f903932f..763c1478f5e6 100644 --- a/stdlib/unittest/util.pyi +++ b/stdlib/unittest/util.pyi @@ -1,5 +1,6 @@ from collections.abc import MutableSequence, Sequence -from typing import Any, Final, Literal, Protocol, TypeAlias, TypeVar, type_check_only +from typing import Any, Final, Literal, Protocol, TypeVar, type_check_only +from typing_extensions import TypeAlias @type_check_only class _SupportsDunderLT(Protocol): diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index fe1cd6a71567..364892ecdf69 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,7 +1,8 @@ import sys from collections.abc import Iterable, Mapping, Sequence from types import GenericAlias -from typing import Any, AnyStr, Final, Generic, Literal, NamedTuple, Protocol, TypeAlias, overload, type_check_only +from typing import Any, AnyStr, Final, Generic, Literal, NamedTuple, Protocol, overload, type_check_only +from typing_extensions import TypeAlias __all__ = [ "urlparse", diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index fe790f00cf02..f7e1f278d3e6 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -6,8 +6,8 @@ from email.message import Message from http.client import HTTPConnection, HTTPMessage, HTTPResponse from http.cookiejar import CookieJar from re import Pattern -from typing import IO, Any, ClassVar, Literal, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import deprecated +from typing import IO, Any, ClassVar, Literal, NoReturn, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias, deprecated from urllib.error import HTTPError as HTTPError from urllib.response import addclosehook, addinfourl diff --git a/stdlib/uu.pyi b/stdlib/uu.pyi index 62bf6cb05f59..324053e04337 100644 --- a/stdlib/uu.pyi +++ b/stdlib/uu.pyi @@ -1,4 +1,5 @@ -from typing import BinaryIO, TypeAlias +from typing import BinaryIO +from typing_extensions import TypeAlias __all__ = ["Error", "encode", "decode"] diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index 06285e03aea7..055f4def311c 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -2,8 +2,8 @@ import builtins import sys from _typeshed import Unused from enum import Enum -from typing import Final, NoReturn, TypeAlias -from typing_extensions import LiteralString +from typing import Final, NoReturn +from typing_extensions import LiteralString, TypeAlias _FieldsType: TypeAlias = tuple[int, int, int, int, int, int] diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index 188b6bb6b246..49c98cb07540 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -3,8 +3,8 @@ import sys from _warnings import warn as warn, warn_explicit as warn_explicit from collections.abc import Sequence from types import ModuleType, TracebackType -from typing import Any, Generic, Literal, TextIO, TypeAlias, overload -from typing_extensions import LiteralString, TypeVar +from typing import Any, Generic, Literal, TextIO, overload +from typing_extensions import LiteralString, TypeAlias, TypeVar __all__ = [ "warn", diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index f0fdef5233e2..fd7dbfade884 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import ReadableBuffer, Unused -from typing import IO, Any, BinaryIO, Final, Literal, NamedTuple, NoReturn, TypeAlias, overload -from typing_extensions import Self, deprecated +from typing import IO, Any, BinaryIO, Final, Literal, NamedTuple, NoReturn, overload +from typing_extensions import Self, TypeAlias, deprecated __all__ = ["open", "Error", "Wave_read", "Wave_write"] diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index 61c591a9b4a5..a654bbcdfb61 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ReadableBuffer, Unused from types import TracebackType -from typing import Any, Final, Literal, TypeAlias, final, overload -from typing_extensions import Self +from typing import Any, Final, Literal, final, overload +from typing_extensions import Self, TypeAlias if sys.platform == "win32": _KeyType: TypeAlias = HKEYType | int diff --git a/stdlib/wsgiref/headers.pyi b/stdlib/wsgiref/headers.pyi index f249ffcf0223..9febad4b3277 100644 --- a/stdlib/wsgiref/headers.pyi +++ b/stdlib/wsgiref/headers.pyi @@ -1,5 +1,6 @@ from re import Pattern -from typing import Final, TypeAlias, overload +from typing import Final, overload +from typing_extensions import TypeAlias _HeaderList: TypeAlias = list[tuple[str, str]] diff --git a/stdlib/wsgiref/types.pyi b/stdlib/wsgiref/types.pyi index b7fd99809856..57276fd05ea8 100644 --- a/stdlib/wsgiref/types.pyi +++ b/stdlib/wsgiref/types.pyi @@ -1,6 +1,7 @@ from _typeshed import OptExcInfo from collections.abc import Callable, Iterable, Iterator -from typing import Any, Protocol, TypeAlias +from typing import Any, Protocol +from typing_extensions import TypeAlias __all__ = ["StartResponse", "WSGIEnvironment", "WSGIApplication", "InputStream", "ErrorStream", "FileWrapper"] diff --git a/stdlib/wsgiref/validate.pyi b/stdlib/wsgiref/validate.pyi index 498e03aa3673..fa8a6bbb8d03 100644 --- a/stdlib/wsgiref/validate.pyi +++ b/stdlib/wsgiref/validate.pyi @@ -1,6 +1,7 @@ from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication from collections.abc import Callable, Iterable, Iterator -from typing import Any, NoReturn, TypeAlias +from typing import Any, NoReturn +from typing_extensions import TypeAlias __all__ = ["validator"] diff --git a/stdlib/xml/dom/expatbuilder.pyi b/stdlib/xml/dom/expatbuilder.pyi index e41067182935..2b9ac8876970 100644 --- a/stdlib/xml/dom/expatbuilder.pyi +++ b/stdlib/xml/dom/expatbuilder.pyi @@ -1,5 +1,6 @@ from _typeshed import ReadableBuffer, SupportsRead -from typing import Any, Final, NoReturn, TypeAlias +from typing import Any, Final, NoReturn +from typing_extensions import TypeAlias from xml.dom.minidom import Document, DocumentFragment, DOMImplementation, Element, Node, TypeInfo from xml.dom.xmlbuilder import DOMBuilderFilter, Options from xml.parsers.expat import XMLParserType diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index fdc35f0de7c1..e0431417aa3c 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -3,8 +3,8 @@ from _collections_abc import dict_keys, dict_values from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Iterable, Sequence from types import TracebackType -from typing import Any, ClassVar, Generic, Literal, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, ClassVar, Generic, Literal, NoReturn, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias from xml.dom.minicompat import EmptyNodeList, NodeList from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS from xml.sax.xmlreader import XMLReader diff --git a/stdlib/xml/dom/pulldom.pyi b/stdlib/xml/dom/pulldom.pyi index 4ede39015585..df7a3ad0eddb 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import Incomplete, Unused from collections.abc import MutableSequence, Sequence -from typing import Final, Literal, NoReturn, TypeAlias -from typing_extensions import Self +from typing import Final, Literal, NoReturn +from typing_extensions import Self, TypeAlias from xml.dom.minidom import Comment, Document, DOMImplementation, Element, ProcessingInstruction, Text from xml.sax import _SupportsReadClose from xml.sax.handler import ContentHandler diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index 9eceabda921a..80f3c55c1489 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -1,6 +1,7 @@ from collections.abc import Callable, Generator, Iterable from re import Pattern -from typing import Any, Final, Literal, TypeAlias, TypeVar, overload +from typing import Any, Final, Literal, TypeVar, overload +from typing_extensions import TypeAlias from xml.etree.ElementTree import Element xpath_tokenizer_re: Final[Pattern[str]] diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 25faa8dde0b5..d728fb975bfb 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -2,8 +2,8 @@ import sys from _collections_abc import dict_keys from _typeshed import FileDescriptorOrPath, ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, Mapping, Sequence -from typing import Any, Final, Generic, Literal, Protocol, SupportsIndex, TypeAlias, TypeGuard, TypeVar, overload, type_check_only -from typing_extensions import deprecated, disjoint_base +from typing import Any, Final, Generic, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias, TypeGuard, deprecated, disjoint_base from xml.parsers.expat import XMLParserType __all__ = [ diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index 9b5c3bf4ddea..679466fa34d2 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -1,7 +1,8 @@ import sys from _typeshed import ReadableBuffer, StrPath, SupportsRead, _T_co from collections.abc import Iterable -from typing import Final, Protocol, TypeAlias, type_check_only +from typing import Final, Protocol, type_check_only +from typing_extensions import TypeAlias from xml.sax._exceptions import ( SAXException as SAXException, SAXNotRecognizedException as SAXNotRecognizedException, diff --git a/stdlib/xml/sax/expatreader.pyi b/stdlib/xml/sax/expatreader.pyi index dd8762da5137..3f9573a25f9a 100644 --- a/stdlib/xml/sax/expatreader.pyi +++ b/stdlib/xml/sax/expatreader.pyi @@ -1,8 +1,13 @@ +import sys from _typeshed import ReadableBuffer from collections.abc import Mapping -from typing import Any, Final, Literal, TypeAlias, overload +from typing import Any, Final, Literal, overload +from typing_extensions import TypeAlias from xml.sax import _Source, xmlreader -from xml.sax.handler import LexicalHandler, _ContentHandlerProtocol +from xml.sax.handler import _ContentHandlerProtocol + +if sys.version_info >= (3, 10): + from xml.sax.handler import LexicalHandler _BoolType: TypeAlias = Literal[0, 1] | bool @@ -28,16 +33,20 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): def setContentHandler(self, handler: _ContentHandlerProtocol) -> None: ... def getFeature(self, name: str) -> _BoolType: ... def setFeature(self, name: str, state: _BoolType) -> None: ... - @overload - def getProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"]) -> LexicalHandler | None: ... + if sys.version_info >= (3, 10): + @overload + def getProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"]) -> LexicalHandler | None: ... + @overload def getProperty(self, name: Literal["http://www.python.org/sax/properties/interning-dict"]) -> dict[str, Any] | None: ... @overload def getProperty(self, name: Literal["http://xml.org/sax/properties/xml-string"]) -> bytes | None: ... @overload def getProperty(self, name: str) -> object: ... - @overload - def setProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"], value: LexicalHandler) -> None: ... + if sys.version_info >= (3, 10): + @overload + def setProperty(self, name: Literal["http://xml.org/sax/properties/lexical-handler"], value: LexicalHandler) -> None: ... + @overload def setProperty( self, name: Literal["http://www.python.org/sax/properties/interning-dict"], value: dict[str, Any] diff --git a/stdlib/xml/sax/handler.pyi b/stdlib/xml/sax/handler.pyi index e1e080ac2d1a..5ecbfa6f1272 100644 --- a/stdlib/xml/sax/handler.pyi +++ b/stdlib/xml/sax/handler.pyi @@ -1,3 +1,4 @@ +import sys from typing import Final, NoReturn, Protocol, type_check_only from xml.sax import xmlreader @@ -76,9 +77,10 @@ property_encoding: Final = "http://www.python.org/sax/properties/encoding" property_interning_dict: Final[str] # too long string all_properties: Final[list[str]] -class LexicalHandler: - def comment(self, content: str) -> None: ... - def startDTD(self, name: str, public_id: str | None, system_id: str | None) -> None: ... - def endDTD(self) -> None: ... - def startCDATA(self) -> None: ... - def endCDATA(self) -> None: ... +if sys.version_info >= (3, 10): + class LexicalHandler: + def comment(self, content: str) -> None: ... + def startDTD(self, name: str, public_id: str | None, system_id: str | None) -> None: ... + def endDTD(self) -> None: ... + def startCDATA(self) -> None: ... + def endCDATA(self) -> None: ... diff --git a/stdlib/xml/sax/xmlreader.pyi b/stdlib/xml/sax/xmlreader.pyi index bec292f03282..e7d04ddeadb8 100644 --- a/stdlib/xml/sax/xmlreader.pyi +++ b/stdlib/xml/sax/xmlreader.pyi @@ -1,7 +1,7 @@ from _typeshed import ReadableBuffer from collections.abc import Mapping -from typing import Generic, Literal, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import Generic, Literal, TypeVar, overload +from typing_extensions import Self, TypeAlias from xml.sax import _Source, _SupportsReadClose from xml.sax.handler import _ContentHandlerProtocol, _DTDHandlerProtocol, _EntityResolverProtocol, _ErrorHandlerProtocol diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 18f8987f78fb..42420ee85848 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -6,8 +6,8 @@ from collections.abc import Callable, Iterable, Mapping from datetime import datetime from io import BytesIO from types import TracebackType -from typing import Any, ClassVar, Final, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import Self +from typing import Any, ClassVar, Final, Literal, Protocol, overload, type_check_only +from typing_extensions import Self, TypeAlias @type_check_only class _SupportsTimeTuple(Protocol): diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index 7bf397d2b1a4..286aaf980fbf 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -4,7 +4,8 @@ import socketserver from _typeshed import ReadableBuffer from collections.abc import Callable, Iterable, Mapping from re import Pattern -from typing import Any, ClassVar, Protocol, TypeAlias, type_check_only +from typing import Any, ClassVar, Protocol, type_check_only +from typing_extensions import TypeAlias from xmlrpc.client import Fault, _Marshallable # The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy diff --git a/stdlib/xxlimited.pyi b/stdlib/xxlimited.pyi index 503caf0183f3..78a50b85f405 100644 --- a/stdlib/xxlimited.pyi +++ b/stdlib/xxlimited.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, final +from typing import Any, ClassVar, final class Str(str): ... @@ -12,4 +12,13 @@ class Xxo: def foo(i: int, j: int, /) -> Any: ... def new() -> Xxo: ... -class Error(Exception): ... +if sys.version_info >= (3, 10): + class Error(Exception): ... + +else: + class error(Exception): ... + + class Null: + __hash__: ClassVar[None] # type: ignore[assignment] + + def roj(b: Any, /) -> None: ... diff --git a/stdlib/zipapp.pyi b/stdlib/zipapp.pyi index 48713bced892..c7cf1704b135 100644 --- a/stdlib/zipapp.pyi +++ b/stdlib/zipapp.pyi @@ -1,6 +1,7 @@ from collections.abc import Callable from pathlib import Path -from typing import BinaryIO, TypeAlias +from typing import BinaryIO +from typing_extensions import TypeAlias __all__ = ["ZipAppError", "create_archive", "get_interpreter"] diff --git a/stdlib/zipfile/__init__.pyi b/stdlib/zipfile/__init__.pyi index 1d9167997bec..19d8117a621f 100644 --- a/stdlib/zipfile/__init__.pyi +++ b/stdlib/zipfile/__init__.pyi @@ -5,8 +5,8 @@ from collections.abc import Callable, Iterable, Iterator from io import TextIOWrapper from os import PathLike from types import TracebackType -from typing import IO, Final, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import Self +from typing import IO, Final, Literal, Protocol, overload, type_check_only +from typing_extensions import Self, TypeAlias __all__ = [ "BadZipFile", @@ -345,8 +345,9 @@ else: def name(self) -> str: ... @property def parent(self) -> PathLike[str]: ... # undocumented - @property - def filename(self) -> PathLike[str]: ... # undocumented + if sys.version_info >= (3, 10): + @property + def filename(self) -> PathLike[str]: ... # undocumented if sys.version_info >= (3, 11): @property def suffix(self) -> str: ... @@ -369,7 +370,12 @@ else: ) -> TextIOWrapper: ... @overload def open(self, mode: Literal["rb", "wb"], *, pwd: bytes | None = None) -> IO[bytes]: ... - def iterdir(self) -> Iterator[Self]: ... + + if sys.version_info >= (3, 10): + def iterdir(self) -> Iterator[Self]: ... + else: + def iterdir(self) -> Iterator[Path]: ... + def is_dir(self) -> bool: ... def is_file(self) -> bool: ... def exists(self) -> bool: ... @@ -382,7 +388,11 @@ else: write_through: bool = False, ) -> str: ... def read_bytes(self) -> bytes: ... - def joinpath(self, *other: StrPath) -> Path: ... # undocumented + if sys.version_info >= (3, 10): + def joinpath(self, *other: StrPath) -> Path: ... + else: + def joinpath(self, add: StrPath) -> Path: ... # undocumented + def __truediv__(self, add: StrPath) -> Path: ... def is_zipfile(filename: StrOrBytesPath | _SupportsReadSeekTell) -> bool: ... diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index f660684d351e..22af3c272759 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -1,11 +1,19 @@ import sys -from _frozen_importlib_external import _LoaderBasics from _typeshed import StrOrBytesPath from importlib.machinery import ModuleSpec -from importlib.readers import ZipReader from types import CodeType, ModuleType from typing_extensions import deprecated +if sys.version_info >= (3, 10): + from importlib.readers import ZipReader +else: + from importlib.abc import ResourceReader + +if sys.version_info >= (3, 10): + from _frozen_importlib_external import _LoaderBasics +else: + _LoaderBasics = object + __all__ = ["ZipImportError", "zipimporter"] class ZipImportError(ImportError): ... @@ -19,24 +27,33 @@ class zipimporter(_LoaderBasics): def __init__(self, path: StrOrBytesPath) -> None: ... if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") - def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... - @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") - def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") + def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... + @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.") + def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... + else: + def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... + def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ... def get_code(self, fullname: str) -> CodeType: ... def get_data(self, pathname: str) -> bytes: ... def get_filename(self, fullname: str) -> str: ... if sys.version_info >= (3, 14): def get_resource_reader(self, fullname: str) -> ZipReader: ... # undocumented - else: + elif sys.version_info >= (3, 10): def get_resource_reader(self, fullname: str) -> ZipReader | None: ... # undocumented + else: + def get_resource_reader(self, fullname: str) -> ResourceReader | None: ... # undocumented def get_source(self, fullname: str) -> str | None: ... def is_package(self, fullname: str) -> bool: ... - @deprecated("Deprecated since Python 3.10; removed in Python 3.15. Use `exec_module()` instead.") - def load_module(self, fullname: str) -> ModuleType: ... - def exec_module(self, module: ModuleType) -> None: ... - def create_module(self, spec: ModuleSpec) -> None: ... - def find_spec(self, fullname: str, target: ModuleType | None = None) -> ModuleSpec | None: ... - def invalidate_caches(self) -> None: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated since Python 3.10; removed in Python 3.15. Use `exec_module()` instead.") + def load_module(self, fullname: str) -> ModuleType: ... + def exec_module(self, module: ModuleType) -> None: ... + def create_module(self, spec: ModuleSpec) -> None: ... + def find_spec(self, fullname: str, target: ModuleType | None = None) -> ModuleSpec | None: ... + def invalidate_caches(self) -> None: ... + else: + def load_module(self, fullname: str) -> ModuleType: ... diff --git a/stubs/Authlib/authlib/common/urls.pyi b/stubs/Authlib/authlib/common/urls.pyi index 969d4bcef05d..a07c2112c9be 100644 --- a/stubs/Authlib/authlib/common/urls.pyi +++ b/stubs/Authlib/authlib/common/urls.pyi @@ -1,5 +1,6 @@ from re import Pattern -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias always_safe: Final[str] urlencoded: Final[set[str]] diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi index c124cdd6abac..1160db3b44c9 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator -from typing import NoReturn, TypeAlias +from typing import NoReturn +from typing_extensions import TypeAlias from authlib.oauth1 import ClientAuth from authlib.oauth1.client import OAuth1Client as _OAuth1Client diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi index a2b10260e298..79d45bd3c2af 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator -from typing import NoReturn, TypeAlias +from typing import NoReturn +from typing_extensions import TypeAlias from authlib.oauth2.auth import ClientAuth, TokenAuth from authlib.oauth2.client import OAuth2Client as _OAuth2Client diff --git a/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi b/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi index 8d4ee3b0d012..b565feae8b3d 100644 --- a/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi +++ b/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete from collections.abc import Callable from re import Pattern -from typing import Any, Final, Generic, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing import Any, Final, Generic, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from ..rfc7517 import KeySet from .claims import JWTClaims diff --git a/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi b/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi index 146fffd4a7e7..5614f93883bc 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Collection, Mapping -from typing import TypeAlias, overload -from typing_extensions import deprecated +from typing import overload +from typing_extensions import TypeAlias, deprecated from authlib.oauth2 import JsonRequest, OAuth2Error, OAuth2Request from authlib.oauth2.rfc6749 import BaseGrant, ClientMixin diff --git a/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi b/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi index 1ee7e57abbb9..e121a2d0149f 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi @@ -1,6 +1,6 @@ from collections.abc import Collection from logging import Logger -from typing import TypeAlias +from typing_extensions import TypeAlias from authlib.oauth2 import OAuth2Request from authlib.oauth2.rfc6749 import AuthorizationEndpointMixin, BaseGrant, ClientMixin, TokenEndpointMixin diff --git a/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi b/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi index 82cd47e1c2d3..4ff9c136ef1b 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Collection -from typing import TypeAlias +from typing_extensions import TypeAlias from authlib.oauth2 import OAuth2Request from authlib.oauth2.rfc6749 import ClientMixin diff --git a/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi b/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi index 670fc27460b8..ed025a1bbdc5 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import TypeAlias +from typing_extensions import TypeAlias from authlib.oauth2.rfc6749 import BaseGrant, TokenEndpointMixin, TokenMixin diff --git a/stubs/Deprecated/deprecated/classic.pyi b/stubs/Deprecated/deprecated/classic.pyi index 99d2bd6e9bfa..3f4a2b87e87d 100644 --- a/stubs/Deprecated/deprecated/classic.pyi +++ b/stubs/Deprecated/deprecated/classic.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Any, Literal, TypeAlias, TypeVar, overload +from typing import Any, Literal, TypeVar, overload +from typing_extensions import TypeAlias _F = TypeVar("_F", bound=Callable[..., Any]) _Actions: TypeAlias = Literal["default", "error", "ignore", "always", "module", "once"] diff --git a/stubs/Flask-Cors/flask_cors/core.pyi b/stubs/Flask-Cors/flask_cors/core.pyi index 3fe8b4d2bca7..f2ae68861d68 100644 --- a/stubs/Flask-Cors/flask_cors/core.pyi +++ b/stubs/Flask-Cors/flask_cors/core.pyi @@ -2,7 +2,8 @@ from collections.abc import Iterable from datetime import timedelta from logging import Logger from re import Match, Pattern -from typing import Any, Final, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias import flask diff --git a/stubs/Flask-Migrate/flask_migrate/__init__.pyi b/stubs/Flask-Migrate/flask_migrate/__init__.pyi index ff7aef1bb881..41c0f76741fd 100644 --- a/stubs/Flask-Migrate/flask_migrate/__init__.pyi +++ b/stubs/Flask-Migrate/flask_migrate/__init__.pyi @@ -5,8 +5,8 @@ from _typeshed import StrPath, SupportsFlush, SupportsKeysAndGetItem, SupportsWr from argparse import Namespace from collections.abc import Callable, Iterable, Sequence from logging import Logger -from typing import Any, Protocol, TypeAlias, TypeVar, type_check_only -from typing_extensions import ParamSpec +from typing import Any, Protocol, TypeVar, type_check_only +from typing_extensions import ParamSpec, TypeAlias import flask from flask_sqlalchemy import SQLAlchemy diff --git a/stubs/Flask-SocketIO/flask_socketio/__init__.pyi b/stubs/Flask-SocketIO/flask_socketio/__init__.pyi index 7da0298fcc76..8fa0c25a66fc 100644 --- a/stubs/Flask-SocketIO/flask_socketio/__init__.pyi +++ b/stubs/Flask-SocketIO/flask_socketio/__init__.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from collections.abc import Callable from logging import Logger from threading import Thread -from typing import Any, Literal, Protocol, TypeAlias, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, Unpack +from typing import Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, TypeAlias, Unpack from flask import Flask from flask.testing import FlaskClient diff --git a/stubs/Markdown/markdown/treeprocessors.pyi b/stubs/Markdown/markdown/treeprocessors.pyi index 343896f9bb62..2648d02d213b 100644 --- a/stubs/Markdown/markdown/treeprocessors.pyi +++ b/stubs/Markdown/markdown/treeprocessors.pyi @@ -1,5 +1,6 @@ from re import Pattern -from typing import ClassVar, TypeGuard +from typing import ClassVar +from typing_extensions import TypeGuard from xml.etree.ElementTree import Element from markdown import util diff --git a/stubs/Markdown/markdown/util.pyi b/stubs/Markdown/markdown/util.pyi index 98b17d79dfdc..f30f9e08432c 100644 --- a/stubs/Markdown/markdown/util.pyi +++ b/stubs/Markdown/markdown/util.pyi @@ -1,3 +1,4 @@ +import sys from collections.abc import Iterator from re import Pattern from typing import Final, Generic, TypedDict, TypeVar, overload, type_check_only @@ -18,9 +19,13 @@ HTML_PLACEHOLDER_RE: Final[Pattern[str]] TAG_PLACEHOLDER: Final[str] RTL_BIDI_RANGES: Final[tuple[tuple[str, str], tuple[str, str]]] -from importlib import metadata +if sys.version_info >= (3, 10): + from importlib import metadata + def get_installed_extensions() -> metadata.EntryPoints: ... + +else: + def get_installed_extensions(): ... -def get_installed_extensions() -> metadata.EntryPoints: ... def deprecated(message: str, stacklevel: int = 2): ... @overload def parseBoolValue(value: str) -> bool: ... diff --git a/stubs/PyAutoGUI/pyautogui/__init__.pyi b/stubs/PyAutoGUI/pyautogui/__init__.pyi index b7e51fe29f27..08bb2b7b9529 100644 --- a/stubs/PyAutoGUI/pyautogui/__init__.pyi +++ b/stubs/PyAutoGUI/pyautogui/__init__.pyi @@ -2,8 +2,8 @@ import contextlib from _typeshed import ConvertibleToInt from collections.abc import Callable, Iterable, Sequence from datetime import datetime -from typing import Final, NamedTuple, SupportsIndex, SupportsInt, TypeAlias, TypeVar -from typing_extensions import ParamSpec +from typing import Final, NamedTuple, SupportsIndex, SupportsInt, TypeVar +from typing_extensions import ParamSpec, TypeAlias from pyscreeze import ( center as center, diff --git a/stubs/PyMySQL/pymysql/converters.pyi b/stubs/PyMySQL/pymysql/converters.pyi index e7a80135d612..2a8eaf1c8fe7 100644 --- a/stubs/PyMySQL/pymysql/converters.pyi +++ b/stubs/PyMySQL/pymysql/converters.pyi @@ -4,8 +4,8 @@ import time from _typeshed import Unused from collections.abc import Callable, Mapping, Sequence from decimal import Decimal -from typing import Any, NoReturn, TypeAlias, TypeVar -from typing_extensions import deprecated +from typing import Any, NoReturn, TypeVar +from typing_extensions import TypeAlias, deprecated _EscaperMapping: TypeAlias = Mapping[type[object], Callable[..., str]] | None _T = TypeVar("_T") diff --git a/stubs/PyScreeze/pyscreeze/__init__.pyi b/stubs/PyScreeze/pyscreeze/__init__.pyi index af512a883019..1405bfba0f23 100644 --- a/stubs/PyScreeze/pyscreeze/__init__.pyi +++ b/stubs/PyScreeze/pyscreeze/__init__.pyi @@ -1,8 +1,8 @@ import sys from _typeshed import ConvertibleToFloat, Incomplete, StrOrBytesPath, Unused from collections.abc import Callable, Generator -from typing import Final, NamedTuple, TypeAlias, TypeVar, overload -from typing_extensions import ParamSpec +from typing import Final, NamedTuple, TypeVar, overload +from typing_extensions import ParamSpec, TypeAlias from PIL import Image diff --git a/stubs/PySocks/socks.pyi b/stubs/PySocks/socks.pyi index cee5046615a1..931a8be77d8e 100644 --- a/stubs/PySocks/socks.pyi +++ b/stubs/PySocks/socks.pyi @@ -3,8 +3,8 @@ import socket import types from _typeshed import ReadableBuffer from collections.abc import Callable, Iterable, Mapping -from typing import Final, TypeAlias, TypeVar, overload -from typing_extensions import ParamSpec +from typing import Final, TypeVar, overload +from typing_extensions import ParamSpec, TypeAlias __version__: Final[str] diff --git a/stubs/PyYAML/yaml/cyaml.pyi b/stubs/PyYAML/yaml/cyaml.pyi index abe297bd4da1..f3642b6fa27e 100644 --- a/stubs/PyYAML/yaml/cyaml.pyi +++ b/stubs/PyYAML/yaml/cyaml.pyi @@ -1,6 +1,7 @@ from _typeshed import SupportsRead from collections.abc import Mapping, Sequence -from typing import IO, Any, TypeAlias +from typing import IO, Any +from typing_extensions import TypeAlias from ._yaml import CEmitter, CParser from .constructor import BaseConstructor, FullConstructor, SafeConstructor, UnsafeConstructor diff --git a/stubs/PyYAML/yaml/dumper.pyi b/stubs/PyYAML/yaml/dumper.pyi index e7b18733101d..f40d9db52e8f 100644 --- a/stubs/PyYAML/yaml/dumper.pyi +++ b/stubs/PyYAML/yaml/dumper.pyi @@ -1,5 +1,6 @@ from collections.abc import Mapping -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from yaml.emitter import Emitter from yaml.representer import BaseRepresenter, Representer, SafeRepresenter diff --git a/stubs/PyYAML/yaml/loader.pyi b/stubs/PyYAML/yaml/loader.pyi index 5f29f390c2e0..c3944411ca29 100644 --- a/stubs/PyYAML/yaml/loader.pyi +++ b/stubs/PyYAML/yaml/loader.pyi @@ -1,4 +1,4 @@ -from typing import TypeAlias +from typing_extensions import TypeAlias from yaml.composer import Composer from yaml.constructor import BaseConstructor, Constructor, FullConstructor, SafeConstructor diff --git a/stubs/PyYAML/yaml/reader.pyi b/stubs/PyYAML/yaml/reader.pyi index 84a0e36e2bee..a642be1b88bc 100644 --- a/stubs/PyYAML/yaml/reader.pyi +++ b/stubs/PyYAML/yaml/reader.pyi @@ -1,5 +1,6 @@ from _typeshed import SupportsRead -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from yaml.error import YAMLError diff --git a/stubs/Pygments/pygments/plugin.pyi b/stubs/Pygments/pygments/plugin.pyi index cb4a0f807cda..25253818d781 100644 --- a/stubs/Pygments/pygments/plugin.pyi +++ b/stubs/Pygments/pygments/plugin.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import Incomplete from collections.abc import Generator @@ -11,9 +12,15 @@ FORMATTER_ENTRY_POINT: str STYLE_ENTRY_POINT: str FILTER_ENTRY_POINT: str -from importlib.metadata import EntryPoints +if sys.version_info >= (3, 10): + from importlib.metadata import EntryPoints + def iter_entry_points(group_name: str) -> EntryPoints: ... + +else: + from importlib.metadata import EntryPoint + + def iter_entry_points(group_name: str) -> tuple[EntryPoint, ...] | list[EntryPoint]: ... -def iter_entry_points(group_name: str) -> EntryPoints: ... def find_plugin_lexers() -> Generator[type[Lexer]]: ... def find_plugin_formatters() -> Generator[tuple[str, type[Formatter[Incomplete]]]]: ... def find_plugin_styles() -> Generator[tuple[str, type[Style]]]: ... diff --git a/stubs/RPi.GPIO/RPi/GPIO/__init__.pyi b/stubs/RPi.GPIO/RPi/GPIO/__init__.pyi index 649e41573f28..861eb9a170da 100644 --- a/stubs/RPi.GPIO/RPi/GPIO/__init__.pyi +++ b/stubs/RPi.GPIO/RPi/GPIO/__init__.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Final, Literal, TypeAlias, TypedDict +from typing import Final, Literal, TypedDict +from typing_extensions import TypeAlias class _RPi_Info(TypedDict): P1_REVISION: int diff --git a/stubs/WTForms/wtforms/fields/choices.pyi b/stubs/WTForms/wtforms/fields/choices.pyi index fd7ee6e4fe0e..06f160738fb2 100644 --- a/stubs/WTForms/wtforms/fields/choices.pyi +++ b/stubs/WTForms/wtforms/fields/choices.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Iterable, Iterator, Sequence -from typing import Any, TypeAlias -from typing_extensions import Self +from typing import Any +from typing_extensions import Self, TypeAlias from wtforms.fields.core import Field, _Filter, _FormT, _Validator, _Widget from wtforms.form import BaseForm diff --git a/stubs/WTForms/wtforms/fields/core.pyi b/stubs/WTForms/wtforms/fields/core.pyi index 101f31fc03c6..49966fe751cb 100644 --- a/stubs/WTForms/wtforms/fields/core.pyi +++ b/stubs/WTForms/wtforms/fields/core.pyi @@ -1,7 +1,7 @@ from builtins import type as _type # type is being shadowed in Field from collections.abc import Callable, Iterable, Sequence -from typing import Any, Generic, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias from markupsafe import Markup from wtforms.form import BaseForm diff --git a/stubs/WTForms/wtforms/form.pyi b/stubs/WTForms/wtforms/form.pyi index a8337d394696..7c47bfe5644a 100644 --- a/stubs/WTForms/wtforms/form.pyi +++ b/stubs/WTForms/wtforms/form.pyi @@ -1,6 +1,7 @@ from _typeshed import SupportsItems from collections.abc import Iterable, Iterator, Mapping, Sequence -from typing import Any, ClassVar, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, ClassVar, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from wtforms.fields.core import Field, UnboundField from wtforms.meta import DefaultMeta, _MultiDictLike diff --git a/stubs/WTForms/wtforms/meta.pyi b/stubs/WTForms/wtforms/meta.pyi index 1ab9c382f8ea..e90a6b4fc066 100644 --- a/stubs/WTForms/wtforms/meta.pyi +++ b/stubs/WTForms/wtforms/meta.pyi @@ -1,6 +1,7 @@ from _typeshed import SupportsItems from collections.abc import Collection, Iterator, MutableMapping -from typing import Any, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from markupsafe import Markup from wtforms.fields.core import Field, UnboundField diff --git a/stubs/WebOb/webob/_types.pyi b/stubs/WebOb/webob/_types.pyi index 56557e82afcd..08fdc54b3dd6 100644 --- a/stubs/WebOb/webob/_types.pyi +++ b/stubs/WebOb/webob/_types.pyi @@ -1,4 +1,5 @@ -from typing import Protocol, TypeAlias, TypeVar, overload +from typing import Protocol, TypeVar, overload +from typing_extensions import TypeAlias _T = TypeVar("_T") _GetterReturnType_co = TypeVar("_GetterReturnType_co", covariant=True) diff --git a/stubs/WebOb/webob/acceptparse.pyi b/stubs/WebOb/webob/acceptparse.pyi index 30f6a593c5b1..069564e86749 100644 --- a/stubs/WebOb/webob/acceptparse.pyi +++ b/stubs/WebOb/webob/acceptparse.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsItems from collections.abc import Callable, Iterable, Iterator, Sequence -from typing import Any, Literal, NamedTuple, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias from webob._types import AsymmetricPropertyWithDelete diff --git a/stubs/WebOb/webob/cookies.pyi b/stubs/WebOb/webob/cookies.pyi index 29db78664067..5846b68d9e14 100644 --- a/stubs/WebOb/webob/cookies.pyi +++ b/stubs/WebOb/webob/cookies.pyi @@ -3,7 +3,8 @@ from _typeshed.wsgi import WSGIEnvironment from collections.abc import Collection, ItemsView, Iterator, KeysView, MutableMapping, ValuesView from datetime import date, datetime, timedelta from time import _TimeTuple, struct_time -from typing import Any, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from webob._types import AsymmetricProperty from webob.request import BaseRequest diff --git a/stubs/WebOb/webob/dec.pyi b/stubs/WebOb/webob/dec.pyi index eabac648b73d..4b5198a46a72 100644 --- a/stubs/WebOb/webob/dec.pyi +++ b/stubs/WebOb/webob/dec.pyi @@ -1,7 +1,7 @@ from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment from collections.abc import Callable, Iterable, Mapping -from typing import Any, Concatenate, Generic, TypeAlias, overload, type_check_only -from typing_extensions import Never, ParamSpec, Self, TypeVar +from typing import Any, Generic, overload, type_check_only +from typing_extensions import Concatenate, Never, ParamSpec, Self, TypeAlias, TypeVar from webob.request import BaseRequest, Request from webob.response import Response diff --git a/stubs/WebOb/webob/descriptors.pyi b/stubs/WebOb/webob/descriptors.pyi index e79e5d78d35b..b9c3e5aff2ec 100644 --- a/stubs/WebOb/webob/descriptors.pyi +++ b/stubs/WebOb/webob/descriptors.pyi @@ -1,7 +1,8 @@ from collections.abc import Callable, Iterable from datetime import date, datetime, timedelta from time import _TimeTuple, struct_time -from typing import Any, NamedTuple, TypeAlias, TypeVar, overload +from typing import Any, NamedTuple, TypeVar, overload +from typing_extensions import TypeAlias from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete from webob.byterange import ContentRange, Range diff --git a/stubs/WebOb/webob/etag.pyi b/stubs/WebOb/webob/etag.pyi index f6f5502d55f8..5f71a2ac1853 100644 --- a/stubs/WebOb/webob/etag.pyi +++ b/stubs/WebOb/webob/etag.pyi @@ -1,6 +1,7 @@ from collections.abc import Collection from datetime import datetime -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias from webob._types import AsymmetricPropertyWithDelete from webob.response import Response diff --git a/stubs/WebOb/webob/exc.pyi b/stubs/WebOb/webob/exc.pyi index d1671ef356dc..d2cdb2f11ce4 100644 --- a/stubs/WebOb/webob/exc.pyi +++ b/stubs/WebOb/webob/exc.pyi @@ -2,8 +2,8 @@ from _typeshed import SupportsItems, SupportsKeysAndGetItem from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment from collections.abc import Iterable from string import Template -from typing import Any, Literal, Protocol, TypeAlias, type_check_only -from typing_extensions import Self +from typing import Any, Literal, Protocol, type_check_only +from typing_extensions import Self, TypeAlias from webob.response import Response diff --git a/stubs/WebOb/webob/request.pyi b/stubs/WebOb/webob/request.pyi index 9cc026a69afe..310c2101ce98 100644 --- a/stubs/WebOb/webob/request.pyi +++ b/stubs/WebOb/webob/request.pyi @@ -4,8 +4,8 @@ from _typeshed import OptExcInfo, SupportsKeysAndGetItem, SupportsNoArgReadline, from _typeshed.wsgi import WSGIApplication, WSGIEnvironment from collections.abc import Iterable, Mapping from re import Pattern -from typing import IO, Any, ClassVar, Literal, Protocol, TypeAlias, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import IO, Any, ClassVar, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete from webob.acceptparse import _AcceptCharsetProperty, _AcceptEncodingProperty, _AcceptLanguageProperty, _AcceptProperty diff --git a/stubs/WebOb/webob/response.pyi b/stubs/WebOb/webob/response.pyi index 13a308fcc9f3..27d1e90dff04 100644 --- a/stubs/WebOb/webob/response.pyi +++ b/stubs/WebOb/webob/response.pyi @@ -2,8 +2,8 @@ from _typeshed import SupportsItems, SupportsRead from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment from collections.abc import Iterable, Iterator, Sequence from datetime import timedelta -from typing import IO, Any, Literal, Protocol, TypeAlias, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import IO, Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete from webob.byterange import ContentRange diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index 3ad94b0e3be7..71d2f47024ac 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -9,7 +9,8 @@ from _typeshed import ( from asyncio import AbstractEventLoop from collections.abc import Callable from concurrent.futures import Executor -from typing import Literal, TypeAlias, overload +from typing import Literal, overload +from typing_extensions import TypeAlias from ..base import AiofilesContextManager from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, AsyncIndirectBufferedIOBase, _UnknownAsyncBinaryIO diff --git a/stubs/assertpy/assertpy/base.pyi b/stubs/assertpy/assertpy/base.pyi index 56238d4001e3..be5db39ff985 100644 --- a/stubs/assertpy/assertpy/base.pyi +++ b/stubs/assertpy/assertpy/base.pyi @@ -1,5 +1,4 @@ -from typing import TypeAlias -from typing_extensions import Self +from typing_extensions import Self, TypeAlias __tracebackhide__: bool diff --git a/stubs/assertpy/assertpy/numeric.pyi b/stubs/assertpy/assertpy/numeric.pyi index cb3a0a372531..725bc4ed4dfb 100644 --- a/stubs/assertpy/assertpy/numeric.pyi +++ b/stubs/assertpy/assertpy/numeric.pyi @@ -1,6 +1,5 @@ from datetime import date -from typing import TypeAlias -from typing_extensions import Self +from typing_extensions import Self, TypeAlias __tracebackhide__: bool diff --git a/stubs/auth0-python/auth0/types.pyi b/stubs/auth0-python/auth0/types.pyi index 2d9d79d8cbdb..385643dc72d0 100644 --- a/stubs/auth0-python/auth0/types.pyi +++ b/stubs/auth0-python/auth0/types.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import TypeAlias +from typing_extensions import TypeAlias TimeoutType: TypeAlias = float | tuple[float, float] RequestData: TypeAlias = dict[str, Incomplete] | list[Incomplete] diff --git a/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi b/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi index d691f30e730f..0105c07dbcd7 100644 --- a/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi +++ b/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from logging import Logger -from typing import Final, Literal, TypeAlias -from typing_extensions import Self +from typing import Final, Literal +from typing_extensions import Self, TypeAlias _SampledTrue: TypeAlias = Literal[True, "1", 1] _SampledFalse: TypeAlias = Literal[False, "0", 0] diff --git a/stubs/bleach/bleach/__init__.pyi b/stubs/bleach/bleach/__init__.pyi index 7c31c84d592b..24befbe11fe2 100644 --- a/stubs/bleach/bleach/__init__.pyi +++ b/stubs/bleach/bleach/__init__.pyi @@ -1,5 +1,5 @@ from collections.abc import Container, Iterable -from typing import TypeAlias +from typing_extensions import TypeAlias from .callbacks import _Callback from .css_sanitizer import CSSSanitizer diff --git a/stubs/bleach/bleach/callbacks.pyi b/stubs/bleach/bleach/callbacks.pyi index 0ea1145fac8f..2e92a8645cfb 100644 --- a/stubs/bleach/bleach/callbacks.pyi +++ b/stubs/bleach/bleach/callbacks.pyi @@ -1,5 +1,6 @@ from collections.abc import MutableMapping -from typing import Protocol, TypeAlias, type_check_only +from typing import Protocol, type_check_only +from typing_extensions import TypeAlias from bleach import _HTMLAttrKey diff --git a/stubs/bleach/bleach/linkifier.pyi b/stubs/bleach/bleach/linkifier.pyi index 35d311f13dd1..e6ec5d0ae35a 100644 --- a/stubs/bleach/bleach/linkifier.pyi +++ b/stubs/bleach/bleach/linkifier.pyi @@ -1,6 +1,7 @@ from collections.abc import Container, Iterable, Iterator, Sequence from re import Pattern -from typing import Any, Final, TypeAlias +from typing import Any, Final +from typing_extensions import TypeAlias from html5lib.filters.base import Filter from html5lib.treewalkers.base import TreeWalker diff --git a/stubs/bleach/bleach/sanitizer.pyi b/stubs/bleach/bleach/sanitizer.pyi index 8484b419fd4f..897c17f8a27b 100644 --- a/stubs/bleach/bleach/sanitizer.pyi +++ b/stubs/bleach/bleach/sanitizer.pyi @@ -1,6 +1,7 @@ from collections.abc import Callable, Container, Iterable, Iterator from re import Pattern -from typing import Final, Protocol, TypeAlias, type_check_only +from typing import Final, Protocol, type_check_only +from typing_extensions import TypeAlias from html5lib.filters.base import Filter from html5lib.filters.sanitizer import Filter as SanitizerFilter diff --git a/stubs/boltons/boltons/dictutils.pyi b/stubs/boltons/boltons/dictutils.pyi index 386585975a2b..5e609ef9af13 100644 --- a/stubs/boltons/boltons/dictutils.pyi +++ b/stubs/boltons/boltons/dictutils.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsKeysAndGetItem from collections.abc import Generator, ItemsView, Iterable, KeysView, ValuesView -from typing import NoReturn, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import NoReturn, TypeVar, overload +from typing_extensions import Self, TypeAlias _KT = TypeVar("_KT") _VT = TypeVar("_VT") diff --git a/stubs/boltons/boltons/listutils.pyi b/stubs/boltons/boltons/listutils.pyi index 33be50272087..35b8332ff14f 100644 --- a/stubs/boltons/boltons/listutils.pyi +++ b/stubs/boltons/boltons/listutils.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import SupportsIndex, TypeAlias, TypeVar -from typing_extensions import Self +from typing import SupportsIndex, TypeVar +from typing_extensions import Self, TypeAlias _T = TypeVar("_T") diff --git a/stubs/boltons/boltons/queueutils.pyi b/stubs/boltons/boltons/queueutils.pyi index 83c6dd01e8a5..df8eca210e9d 100644 --- a/stubs/boltons/boltons/queueutils.pyi +++ b/stubs/boltons/boltons/queueutils.pyi @@ -1,4 +1,4 @@ -from typing import TypeAlias +from typing_extensions import TypeAlias class BasePriorityQueue: def __init__(self, **kw) -> None: ... diff --git a/stubs/braintree/braintree/util/generator.pyi b/stubs/braintree/braintree/util/generator.pyi index 03e10a43fede..cfd6c564f19c 100644 --- a/stubs/braintree/braintree/util/generator.pyi +++ b/stubs/braintree/braintree/util/generator.pyi @@ -1,7 +1,7 @@ import datetime import decimal from collections.abc import Iterable, Mapping -from typing import TypeAlias +from typing_extensions import TypeAlias integer_types = int text_type = str diff --git a/stubs/cffi/_cffi_backend.pyi b/stubs/cffi/_cffi_backend.pyi index e89a2438dc83..f2856bb90213 100644 --- a/stubs/cffi/_cffi_backend.pyi +++ b/stubs/cffi/_cffi_backend.pyi @@ -2,8 +2,8 @@ import sys import types from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer from collections.abc import Callable, Hashable -from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only -from typing_extensions import Self, disjoint_base +from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base _T = TypeVar("_T") diff --git a/stubs/cffi/cffi/api.pyi b/stubs/cffi/cffi/api.pyi index 1772b897ab11..07e9ffccab35 100644 --- a/stubs/cffi/cffi/api.pyi +++ b/stubs/cffi/cffi/api.pyi @@ -2,7 +2,8 @@ import sys import types from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Callable, Hashable -from typing import Any, Literal, TypeAlias, TypeVar, overload +from typing import Any, Literal, TypeVar, overload +from typing_extensions import TypeAlias import _cffi_backend from setuptools._distutils.extension import Extension diff --git a/stubs/cffi/cffi/recompiler.pyi b/stubs/cffi/cffi/recompiler.pyi index f95c84932278..729975b862db 100644 --- a/stubs/cffi/cffi/recompiler.pyi +++ b/stubs/cffi/cffi/recompiler.pyi @@ -1,6 +1,7 @@ import io from _typeshed import Incomplete, StrPath -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias from .cffi_opcode import * from .error import VerificationError as VerificationError diff --git a/stubs/cffi/cffi/verifier.pyi b/stubs/cffi/cffi/verifier.pyi index 5c8b8d733fbc..6901a0a3ba70 100644 --- a/stubs/cffi/cffi/verifier.pyi +++ b/stubs/cffi/cffi/verifier.pyi @@ -1,7 +1,8 @@ import io import os from _typeshed import Incomplete, StrPath -from typing import AnyStr, TypeAlias +from typing import AnyStr +from typing_extensions import TypeAlias NativeIO: TypeAlias = io.StringIO diff --git a/stubs/channels/channels/layers.pyi b/stubs/channels/channels/layers.pyi index e709d98398c7..1fae3a125aae 100644 --- a/stubs/channels/channels/layers.pyi +++ b/stubs/channels/channels/layers.pyi @@ -1,7 +1,7 @@ import asyncio from re import Pattern -from typing import Any, ClassVar, TypeAlias, overload -from typing_extensions import deprecated +from typing import Any, ClassVar, overload +from typing_extensions import TypeAlias, deprecated class ChannelLayerManager: backends: dict[str, BaseChannelLayer] diff --git a/stubs/channels/channels/testing/live.pyi b/stubs/channels/channels/testing/live.pyi index e9f52d6e5e22..b2cac0ae6260 100644 --- a/stubs/channels/channels/testing/live.pyi +++ b/stubs/channels/channels/testing/live.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Any, ClassVar, TypeAlias +from typing import Any, ClassVar +from typing_extensions import TypeAlias from channels.routing import ProtocolTypeRouter from channels.utils import _ChannelApplication diff --git a/stubs/channels/channels/testing/websocket.pyi b/stubs/channels/channels/testing/websocket.pyi index db743bed5d55..f303e90e5c39 100644 --- a/stubs/channels/channels/testing/websocket.pyi +++ b/stubs/channels/channels/testing/websocket.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import Any, Literal, TypeAlias, TypedDict, overload, type_check_only -from typing_extensions import NotRequired +from typing import Any, Literal, TypedDict, overload, type_check_only +from typing_extensions import NotRequired, TypeAlias from asgiref.typing import ASGIVersions from channels.testing.application import ApplicationCommunicator diff --git a/stubs/channels/channels/utils.pyi b/stubs/channels/channels/utils.pyi index 80b4dff1a902..0e0818abbbb6 100644 --- a/stubs/channels/channels/utils.pyi +++ b/stubs/channels/channels/utils.pyi @@ -1,5 +1,6 @@ from collections.abc import Awaitable, Callable -from typing import Any, Protocol, TypeAlias, type_check_only +from typing import Any, Protocol, type_check_only +from typing_extensions import TypeAlias from asgiref.typing import ASGIApplication, ASGIReceiveCallable diff --git a/stubs/click-log/click_log/options.pyi b/stubs/click-log/click_log/options.pyi index cea9e5edd8ea..f5fa67d96eac 100644 --- a/stubs/click-log/click_log/options.pyi +++ b/stubs/click-log/click_log/options.pyi @@ -1,6 +1,7 @@ import logging from collections.abc import Callable -from typing import Any, TypeAlias, TypeVar +from typing import Any, TypeVar +from typing_extensions import TypeAlias import click diff --git a/stubs/click-web/click_web/resources/input_fields.pyi b/stubs/click-web/click_web/resources/input_fields.pyi index a77853d9f5df..ec2ede4d14b2 100644 --- a/stubs/click-web/click_web/resources/input_fields.pyi +++ b/stubs/click-web/click_web/resources/input_fields.pyi @@ -1,3 +1,4 @@ +import sys from typing import Any, ClassVar, Final import click @@ -46,7 +47,10 @@ class BaseInput: def _build_name(self, name: str) -> str: ... class ChoiceInput(BaseInput): - param_type_cls: type[click.Choice[Any]] + if sys.version_info >= (3, 10): + param_type_cls: type[click.Choice[Any]] + else: + param_type_cls: type[click.Choice] class FlagInput(BaseInput): param_type_cls: None diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index e32fec9d33c3..284ea97814ca 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -3,7 +3,8 @@ from _typeshed import SupportsWrite from collections.abc import Callable, Sequence from re import Pattern from types import TracebackType -from typing import Any, ClassVar, TextIO, TypeAlias +from typing import Any, ClassVar, TextIO +from typing_extensions import TypeAlias if sys.platform == "win32": from .winterm import WinTerm diff --git a/stubs/colorful/colorful/core.pyi b/stubs/colorful/colorful/core.pyi index 2e79d5015818..93bce78dff43 100644 --- a/stubs/colorful/colorful/core.pyi +++ b/stubs/colorful/colorful/core.pyi @@ -4,8 +4,8 @@ from _typeshed import SupportsGetItem, SupportsItems, SupportsWrite # as a type annotation or type alias. from builtins import str as _str from collections.abc import Iterator -from typing import Any, Final, Literal, TypeAlias -from typing_extensions import LiteralString, Self +from typing import Any, Final, Literal +from typing_extensions import LiteralString, Self, TypeAlias # Custom type helpers _ColorModeType: TypeAlias = Literal[0, 8, 16, 256, 16777215] diff --git a/stubs/croniter/croniter/croniter.pyi b/stubs/croniter/croniter/croniter.pyi index da32a76d372c..7dd721ddbb2a 100644 --- a/stubs/croniter/croniter/croniter.pyi +++ b/stubs/croniter/croniter/croniter.pyi @@ -3,8 +3,8 @@ from _typeshed import Unused from collections import OrderedDict from collections.abc import Generator from re import Match, Pattern -from typing import Any, Final, Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Never, Self +from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Never, Self, TypeAlias _R_co = TypeVar("_R_co", float, datetime.datetime, default=float, covariant=True) _R2_co = TypeVar("_R2_co", float, datetime.datetime, covariant=True) diff --git a/stubs/dateparser/dateparser/__init__.pyi b/stubs/dateparser/dateparser/__init__.pyi index 8f20829b573c..cec3cb7b8a26 100644 --- a/stubs/dateparser/dateparser/__init__.pyi +++ b/stubs/dateparser/dateparser/__init__.pyi @@ -1,5 +1,6 @@ import datetime -from typing import Literal, TypeAlias, TypedDict, type_check_only +from typing import Literal, TypedDict, type_check_only +from typing_extensions import TypeAlias from .date import DateDataParser, _DetectLanguagesFunction diff --git a/stubs/dateparser/dateparser/date.pyi b/stubs/dateparser/dateparser/date.pyi index 35a45429f569..c26e35566218 100644 --- a/stubs/dateparser/dateparser/date.pyi +++ b/stubs/dateparser/dateparser/date.pyi @@ -2,7 +2,8 @@ import collections from collections.abc import Callable, Iterable, Iterator from datetime import datetime, tzinfo from re import Pattern -from typing import ClassVar, Final, Literal, TypeAlias, overload +from typing import ClassVar, Final, Literal, overload +from typing_extensions import TypeAlias from dateparser import _Settings from dateparser.conf import Settings diff --git a/stubs/dirhash/dirhash/__init__.pyi b/stubs/dirhash/dirhash/__init__.pyi index e708f597c636..5a24f69dc17c 100644 --- a/stubs/dirhash/dirhash/__init__.pyi +++ b/stubs/dirhash/dirhash/__init__.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator, Iterable from os import PathLike -from typing import TypeAlias, TypeVar +from typing import TypeVar +from typing_extensions import TypeAlias _DirNode: TypeAlias = Incomplete # scantree.DirNode _RecursionPath: TypeAlias = Incomplete # scantree.RecursionPath diff --git a/stubs/django-filter/django_filters/fields.pyi b/stubs/django-filter/django_filters/fields.pyi index 0b72e5ebb10f..7920f9878c9c 100644 --- a/stubs/django-filter/django_filters/fields.pyi +++ b/stubs/django-filter/django_filters/fields.pyi @@ -1,6 +1,7 @@ from _typeshed import Unused from collections.abc import Callable, Iterable, Mapping, Sequence -from typing import Any, NamedTuple, TypeAlias +from typing import Any, NamedTuple +from typing_extensions import TypeAlias from django import forms from django.db.models import Choices diff --git a/stubs/django-filter/django_filters/rest_framework/backends.pyi b/stubs/django-filter/django_filters/rest_framework/backends.pyi index c58bf4c98260..b45372d919af 100644 --- a/stubs/django-filter/django_filters/rest_framework/backends.pyi +++ b/stubs/django-filter/django_filters/rest_framework/backends.pyi @@ -1,4 +1,5 @@ -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from django.db.models import QuerySet from django.http import HttpRequest diff --git a/stubs/django-import-export/import_export/admin.pyi b/stubs/django-import-export/import_export/admin.pyi index 070dbd26720e..9f02027f90cc 100644 --- a/stubs/django-import-export/import_export/admin.pyi +++ b/stubs/django-import-export/import_export/admin.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Sequence from logging import Logger -from typing import Any, Literal, TypeAlias, TypeVar -from typing_extensions import deprecated +from typing import Any, Literal, TypeVar +from typing_extensions import TypeAlias, deprecated from django.contrib import admin from django.contrib.admin.helpers import ActionForm diff --git a/stubs/django-import-export/import_export/formats/base_formats.pyi b/stubs/django-import-export/import_export/formats/base_formats.pyi index 17c7f4a60ad4..a2206683b830 100644 --- a/stubs/django-import-export/import_export/formats/base_formats.pyi +++ b/stubs/django-import-export/import_export/formats/base_formats.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, ReadableBuffer from logging import Logger -from typing import IO, Any, ClassVar, TypeAlias -from typing_extensions import Self +from typing import IO, Any, ClassVar +from typing_extensions import Self, TypeAlias Dataset: TypeAlias = Incomplete # tablib.Dataset diff --git a/stubs/django-import-export/import_export/instance_loaders.pyi b/stubs/django-import-export/import_export/instance_loaders.pyi index e2840f83aba9..433eb9f71796 100644 --- a/stubs/django-import-export/import_export/instance_loaders.pyi +++ b/stubs/django-import-export/import_export/instance_loaders.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from django.db.models import Model, QuerySet diff --git a/stubs/django-import-export/import_export/mixins.pyi b/stubs/django-import-export/import_export/mixins.pyi index 7c5bd003e4f5..947753288e53 100644 --- a/stubs/django-import-export/import_export/mixins.pyi +++ b/stubs/django-import-export/import_export/mixins.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsGetItem from logging import Logger -from typing import Any, Generic, TypeAlias, TypeVar -from typing_extensions import deprecated +from typing import Any, Generic, TypeVar +from typing_extensions import TypeAlias, deprecated from django.db.models import Model, QuerySet from django.forms import BaseForm, Form diff --git a/stubs/django-import-export/import_export/resources.pyi b/stubs/django-import-export/import_export/resources.pyi index e1fa7ca37924..1f62c6b74aa2 100644 --- a/stubs/django-import-export/import_export/resources.pyi +++ b/stubs/django-import-export/import_export/resources.pyi @@ -3,8 +3,8 @@ from collections import OrderedDict from collections.abc import Iterator, Sequence from functools import partial from logging import Logger -from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeAlias, TypeVar, overload -from typing_extensions import deprecated +from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeVar, overload +from typing_extensions import TypeAlias, deprecated from django.db.models import Field as DjangoField, Model, QuerySet from django.utils.safestring import SafeString diff --git a/stubs/django-import-export/import_export/results.pyi b/stubs/django-import-export/import_export/results.pyi index 5d108fbf6d4e..509d94436403 100644 --- a/stubs/django-import-export/import_export/results.pyi +++ b/stubs/django-import-export/import_export/results.pyi @@ -2,7 +2,8 @@ from _typeshed import Incomplete from collections import OrderedDict from collections.abc import Iterator from functools import cached_property -from typing import Any, ClassVar, Literal, TypeAlias +from typing import Any, ClassVar, Literal +from typing_extensions import TypeAlias from django.core.exceptions import ValidationError from django.db.models import Model diff --git a/stubs/docker/docker/_types.pyi b/stubs/docker/docker/_types.pyi index 5500470c6fa5..21b38dcdb666 100644 --- a/stubs/docker/docker/_types.pyi +++ b/stubs/docker/docker/_types.pyi @@ -2,8 +2,8 @@ # This does not match a module in docker-py. from pathlib import Path -from typing import TypeAlias, TypedDict, type_check_only -from typing_extensions import NotRequired +from typing import TypedDict, type_check_only +from typing_extensions import NotRequired, TypeAlias # Type alias for JSON, explained at: # https://github.com/python/typing/issues/182#issuecomment-1320974824. diff --git a/stubs/docker/docker/api/container.pyi b/stubs/docker/docker/api/container.pyi index 07f153efad59..fb676cbb3e0c 100644 --- a/stubs/docker/docker/api/container.pyi +++ b/stubs/docker/docker/api/container.pyi @@ -1,6 +1,7 @@ import datetime from _typeshed import Incomplete -from typing import Any, Literal, TypeAlias, TypedDict, overload, type_check_only +from typing import Any, Literal, TypedDict, overload, type_check_only +from typing_extensions import TypeAlias from docker._types import WaitContainerResponse from docker.types.daemon import CancellableStream diff --git a/stubs/docker/docker/api/network.pyi b/stubs/docker/docker/api/network.pyi index 8443762babe2..1441ff496c6d 100644 --- a/stubs/docker/docker/api/network.pyi +++ b/stubs/docker/docker/api/network.pyi @@ -1,5 +1,6 @@ from collections.abc import Iterable -from typing import Any, Literal, TypeAlias, TypedDict, type_check_only +from typing import Any, Literal, TypedDict, type_check_only +from typing_extensions import TypeAlias from docker.types import IPAMConfig diff --git a/stubs/docker/docker/models/images.pyi b/stubs/docker/docker/models/images.pyi index d69e96cf4c0b..cf1e54ae0cea 100644 --- a/stubs/docker/docker/models/images.pyi +++ b/stubs/docker/docker/models/images.pyi @@ -1,7 +1,8 @@ from _typeshed import SupportsRead from collections.abc import Iterator from io import StringIO -from typing import IO, Any, Literal, TypeAlias, TypedDict, overload, type_check_only +from typing import IO, Any, Literal, TypedDict, overload, type_check_only +from typing_extensions import TypeAlias from docker._types import JSON diff --git a/stubs/docker/docker/transport/npipesocket.pyi b/stubs/docker/docker/transport/npipesocket.pyi index e7cc2538c8e3..086bb3346bcc 100644 --- a/stubs/docker/docker/transport/npipesocket.pyi +++ b/stubs/docker/docker/transport/npipesocket.pyi @@ -1,6 +1,7 @@ import io from _typeshed import ReadableBuffer -from typing import Any, Literal, NoReturn, TypeAlias +from typing import Any, Literal, NoReturn +from typing_extensions import TypeAlias cERROR_PIPE_BUSY: int cSECURITY_SQOS_PRESENT: int diff --git a/stubs/dockerfile-parse/dockerfile_parse/util.pyi b/stubs/dockerfile-parse/dockerfile_parse/util.pyi index ca1f4086b290..5ad32c3780b2 100644 --- a/stubs/dockerfile-parse/dockerfile_parse/util.pyi +++ b/stubs/dockerfile-parse/dockerfile_parse/util.pyi @@ -1,6 +1,7 @@ from collections.abc import Generator, Mapping, MutableMapping from io import StringIO -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias def b2u(string: bytes | str) -> str: ... def u2b(string: str | bytes) -> bytes: ... diff --git a/stubs/docutils/docutils/examples.pyi b/stubs/docutils/docutils/examples.pyi index 89912cd84d1f..42dd8c152903 100644 --- a/stubs/docutils/docutils/examples.pyi +++ b/stubs/docutils/docutils/examples.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, StrPath -from typing import Literal, TypeAlias, overload +from typing import Literal, overload +from typing_extensions import TypeAlias from docutils.core import Publisher from docutils.nodes import document diff --git a/stubs/docutils/docutils/nodes.pyi b/stubs/docutils/docutils/nodes.pyi index ef1b43b34b6d..82a5fba393a1 100644 --- a/stubs/docutils/docutils/nodes.pyi +++ b/stubs/docutils/docutils/nodes.pyi @@ -4,8 +4,8 @@ from _typeshed import Incomplete from abc import abstractmethod from collections import Counter from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence -from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated from docutils.frontend import Values from docutils.transforms import Transform, Transformer diff --git a/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi b/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi index a9b7a2c2956e..c46e90c800b7 100644 --- a/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi +++ b/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi @@ -1,4 +1,5 @@ -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias from docutils import parsers diff --git a/stubs/docutils/docutils/parsers/rst/__init__.pyi b/stubs/docutils/docutils/parsers/rst/__init__.pyi index 2ec7af62d1e1..75f834719d97 100644 --- a/stubs/docutils/docutils/parsers/rst/__init__.pyi +++ b/stubs/docutils/docutils/parsers/rst/__init__.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Sequence -from typing import Any, ClassVar, Final, Literal, TypeAlias +from typing import Any, ClassVar, Final, Literal +from typing_extensions import TypeAlias from docutils import nodes, parsers from docutils.parsers.rst.states import Inliner, RSTState, RSTStateMachine diff --git a/stubs/docutils/docutils/parsers/rst/directives/body.pyi b/stubs/docutils/docutils/parsers/rst/directives/body.pyi index 345309e71599..75f36f360876 100644 --- a/stubs/docutils/docutils/parsers/rst/directives/body.pyi +++ b/stubs/docutils/docutils/parsers/rst/directives/body.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import ClassVar, Final, TypeAlias +from typing import ClassVar, Final +from typing_extensions import TypeAlias from docutils import nodes from docutils.parsers.rst import Directive diff --git a/stubs/docutils/docutils/parsers/rst/roles.pyi b/stubs/docutils/docutils/parsers/rst/roles.pyi index 4697d6982e79..eb238c6f4905 100644 --- a/stubs/docutils/docutils/parsers/rst/roles.pyi +++ b/stubs/docutils/docutils/parsers/rst/roles.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Mapping, Sequence -from typing import Any, Final, TypeAlias -from typing_extensions import deprecated +from typing import Any, Final +from typing_extensions import TypeAlias, deprecated import docutils.parsers.rst.states from docutils import nodes diff --git a/stubs/docutils/docutils/parsers/rst/states.pyi b/stubs/docutils/docutils/parsers/rst/states.pyi index d6f7ad79dae4..05e0c556f9f7 100644 --- a/stubs/docutils/docutils/parsers/rst/states.pyi +++ b/stubs/docutils/docutils/parsers/rst/states.pyi @@ -2,7 +2,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable, Sequence from re import Match, Pattern from types import ModuleType, SimpleNamespace as Struct -from typing import Any, ClassVar, Final, NoReturn, TypeAlias +from typing import Any, ClassVar, Final, NoReturn +from typing_extensions import TypeAlias from docutils import ApplicationError, DataError, nodes from docutils.nodes import Node, system_message diff --git a/stubs/docutils/docutils/parsers/rst/tableparser.pyi b/stubs/docutils/docutils/parsers/rst/tableparser.pyi index ad805b9ccd52..dfb95bff53f3 100644 --- a/stubs/docutils/docutils/parsers/rst/tableparser.pyi +++ b/stubs/docutils/docutils/parsers/rst/tableparser.pyi @@ -1,5 +1,6 @@ from re import Pattern -from typing import ClassVar, Final, TypeAlias +from typing import ClassVar, Final +from typing_extensions import TypeAlias from docutils import DataError from docutils.statemachine import StringList diff --git a/stubs/docutils/docutils/statemachine.pyi b/stubs/docutils/docutils/statemachine.pyi index 2a4e88f2879c..353b27734915 100644 --- a/stubs/docutils/docutils/statemachine.pyi +++ b/stubs/docutils/docutils/statemachine.pyi @@ -1,8 +1,8 @@ import sys from collections.abc import Callable, Generator, Iterable, Iterator, Sequence from re import Match, Pattern -from typing import Any, ClassVar, Final, Generic, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import Any, ClassVar, Final, Generic, SupportsIndex, TypeVar, overload +from typing_extensions import Self, TypeAlias _T = TypeVar("_T") _Context = TypeVar("_Context") diff --git a/stubs/docutils/docutils/transforms/__init__.pyi b/stubs/docutils/docutils/transforms/__init__.pyi index a848d0768f9f..3a3732c53e9b 100644 --- a/stubs/docutils/docutils/transforms/__init__.pyi +++ b/stubs/docutils/docutils/transforms/__init__.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable, Mapping -from typing import Any, ClassVar, Final, TypeAlias +from typing import Any, ClassVar, Final +from typing_extensions import TypeAlias from docutils import ApplicationError, TransformSpec, nodes from docutils.languages import LanguageImporter diff --git a/stubs/docutils/docutils/utils/__init__.pyi b/stubs/docutils/docutils/utils/__init__.pyi index f076c0f2e8d8..30b4725712a4 100644 --- a/stubs/docutils/docutils/utils/__init__.pyi +++ b/stubs/docutils/docutils/utils/__init__.pyi @@ -2,8 +2,8 @@ import optparse from _typeshed import StrPath, SupportsWrite from collections.abc import Callable, Iterable, Mapping, Sequence from re import Pattern -from typing import Any, Final, Literal, TypeAlias, TypeVar -from typing_extensions import deprecated +from typing import Any, Final, Literal, TypeVar +from typing_extensions import TypeAlias, deprecated from docutils import ApplicationError, DataError, nodes from docutils.frontend import Values diff --git a/stubs/docutils/docutils/utils/code_analyzer.pyi b/stubs/docutils/docutils/utils/code_analyzer.pyi index e778c7db6afd..adbf7b956363 100644 --- a/stubs/docutils/docutils/utils/code_analyzer.pyi +++ b/stubs/docutils/docutils/utils/code_analyzer.pyi @@ -1,5 +1,6 @@ from collections.abc import Generator, Iterable -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias from docutils import ApplicationError diff --git a/stubs/ephem/ephem/_libastro.pyi b/stubs/ephem/ephem/_libastro.pyi index e2861e1aacd4..57f652a23823 100644 --- a/stubs/ephem/ephem/_libastro.pyi +++ b/stubs/ephem/ephem/_libastro.pyi @@ -1,7 +1,7 @@ from _typeshed import Unused from datetime import datetime as _datetime -from typing import Final, NoReturn, Protocol, TypeAlias, TypedDict, overload, type_check_only -from typing_extensions import Self, deprecated, disjoint_base +from typing import Final, NoReturn, Protocol, TypedDict, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated, disjoint_base _DateInitType: TypeAlias = ( Date diff --git a/stubs/fanstatic/fanstatic/core.pyi b/stubs/fanstatic/fanstatic/core.pyi index 9197bdd323c2..c57f58ec8b2a 100644 --- a/stubs/fanstatic/fanstatic/core.pyi +++ b/stubs/fanstatic/fanstatic/core.pyi @@ -2,7 +2,8 @@ from abc import abstractmethod from collections.abc import Callable, Iterable from threading import local from types import ModuleType -from typing import Literal, NewType, TypeAlias +from typing import Literal, NewType +from typing_extensions import TypeAlias from fanstatic.compiler import Compiler, Minifier diff --git a/stubs/flake8-builtins/flake8_builtins.pyi b/stubs/flake8-builtins/flake8_builtins.pyi index 9e80c36dc14a..25c003d39648 100644 --- a/stubs/flake8-builtins/flake8_builtins.pyi +++ b/stubs/flake8-builtins/flake8_builtins.pyi @@ -1,7 +1,8 @@ import ast from argparse import Namespace from collections.abc import Iterator -from typing import ClassVar, TypeAlias +from typing import ClassVar +from typing_extensions import TypeAlias from flake8.options.manager import OptionManager diff --git a/stubs/flake8/flake8/checker.pyi b/stubs/flake8/flake8/checker.pyi index d370840cc1b7..a2e67f9c01cc 100644 --- a/stubs/flake8/flake8/checker.pyi +++ b/stubs/flake8/flake8/checker.pyi @@ -3,7 +3,8 @@ import tokenize from _typeshed import Incomplete from collections.abc import Sequence from logging import Logger -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from .plugins.finder import Checkers, LoadedPlugin from .processor import _LogicalMapping diff --git a/stubs/flake8/flake8/processor.pyi b/stubs/flake8/flake8/processor.pyi index c2d5c2a58ca2..f193a21840be 100644 --- a/stubs/flake8/flake8/processor.pyi +++ b/stubs/flake8/flake8/processor.pyi @@ -4,7 +4,8 @@ from ast import AST from collections.abc import Generator from logging import Logger from tokenize import TokenInfo -from typing import Any, Final, TypeAlias +from typing import Any, Final +from typing_extensions import TypeAlias from .plugins.finder import LoadedPlugin diff --git a/stubs/fpdf2/fpdf/_fonttools_shims.pyi b/stubs/fpdf2/fpdf/_fonttools_shims.pyi index c108a0068ba9..f68d651014d6 100644 --- a/stubs/fpdf2/fpdf/_fonttools_shims.pyi +++ b/stubs/fpdf2/fpdf/_fonttools_shims.pyi @@ -2,7 +2,8 @@ from abc import ABCMeta, abstractmethod from collections.abc import Mapping from logging import Logger -from typing import Any, Protocol, TypeAlias +from typing import Any, Protocol +from typing_extensions import TypeAlias # from fonttools.ttLib.ttGlyphSet class _TTGlyph(Protocol): diff --git a/stubs/fpdf2/fpdf/drawing.pyi b/stubs/fpdf2/fpdf/drawing.pyi index 73c4c3357068..c393f1f7eaa7 100644 --- a/stubs/fpdf2/fpdf/drawing.pyi +++ b/stubs/fpdf2/fpdf/drawing.pyi @@ -1,12 +1,18 @@ import decimal +import sys from _typeshed import Incomplete, SupportsWrite from collections import OrderedDict from collections.abc import Callable, Generator, Iterable, Sequence from contextlib import contextmanager from re import Pattern -from types import EllipsisType -from typing import Any, ClassVar, Literal, NamedTuple, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, ClassVar, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias + +if sys.version_info >= (3, 10): + from types import EllipsisType +else: + # Rely on builtins.ellipsis + from builtins import ellipsis as EllipsisType from .enums import PathPaintRule from .syntax import Name, Raw diff --git a/stubs/fpdf2/fpdf/encryption.pyi b/stubs/fpdf2/fpdf/encryption.pyi index 14f133910b61..3c3edabd53f4 100644 --- a/stubs/fpdf2/fpdf/encryption.pyi +++ b/stubs/fpdf2/fpdf/encryption.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete, SupportsLenAndGetItem from collections.abc import Generator, Iterable from logging import Logger -from typing import ClassVar, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import ClassVar, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from .enums import AccessPermission, EncryptionMethod from .fpdf import FPDF diff --git a/stubs/fpdf2/fpdf/enums.pyi b/stubs/fpdf2/fpdf/enums.pyi index 076d48c0af6b..5c11f04e31ce 100644 --- a/stubs/fpdf2/fpdf/enums.pyi +++ b/stubs/fpdf2/fpdf/enums.pyi @@ -2,8 +2,8 @@ from abc import ABC, abstractmethod from collections.abc import Sequence from dataclasses import dataclass from enum import Enum, Flag, IntEnum, IntFlag -from typing import Final, Literal, TypeAlias -from typing_extensions import Self +from typing import Final, Literal +from typing_extensions import Self, TypeAlias from .drawing import DeviceCMYK, DeviceGray, DeviceRGB from .syntax import Name diff --git a/stubs/fpdf2/fpdf/fpdf.pyi b/stubs/fpdf2/fpdf/fpdf.pyi index 9d4f0d8b1f1f..820ba83c6b55 100644 --- a/stubs/fpdf2/fpdf/fpdf.pyi +++ b/stubs/fpdf2/fpdf/fpdf.pyi @@ -5,8 +5,8 @@ from contextlib import _GeneratorContextManager from io import BytesIO from pathlib import PurePath from re import Pattern -from typing import Any, ClassVar, Final, Literal, NamedTuple, TypeAlias, overload -from typing_extensions import deprecated +from typing import Any, ClassVar, Final, Literal, NamedTuple, overload +from typing_extensions import TypeAlias, deprecated from fpdf import ViewerPreferences from fpdf.outline import OutlineSection diff --git a/stubs/fpdf2/fpdf/html.pyi b/stubs/fpdf2/fpdf/html.pyi index a838697b0d69..8225d7177721 100644 --- a/stubs/fpdf2/fpdf/html.pyi +++ b/stubs/fpdf2/fpdf/html.pyi @@ -2,7 +2,8 @@ from _typeshed import Incomplete, SupportsKeysAndGetItem from collections.abc import Callable, Iterable, Mapping from html.parser import HTMLParser from logging import Logger -from typing import ClassVar, Final, Literal, TypeAlias +from typing import ClassVar, Final, Literal +from typing_extensions import TypeAlias from fpdf import FPDF diff --git a/stubs/fpdf2/fpdf/image_datastructures.pyi b/stubs/fpdf2/fpdf/image_datastructures.pyi index a45a50ee8e7b..24f3dd65bb7c 100644 --- a/stubs/fpdf2/fpdf/image_datastructures.pyi +++ b/stubs/fpdf2/fpdf/image_datastructures.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from dataclasses import dataclass -from typing import Any, Literal, TypeAlias +from typing import Any, Literal +from typing_extensions import TypeAlias from fpdf.enums import Align diff --git a/stubs/fpdf2/fpdf/image_parsing.pyi b/stubs/fpdf2/fpdf/image_parsing.pyi index 0d131c1338b2..67cbe33b7530 100644 --- a/stubs/fpdf2/fpdf/image_parsing.pyi +++ b/stubs/fpdf2/fpdf/image_parsing.pyi @@ -3,7 +3,8 @@ from dataclasses import dataclass from io import BytesIO from logging import Logger from types import TracebackType -from typing import Any, Final, Literal, TypeAlias +from typing import Any, Final, Literal +from typing_extensions import TypeAlias from PIL import Image diff --git a/stubs/fpdf2/fpdf/util.pyi b/stubs/fpdf2/fpdf/util.pyi index 9c98ae361a5f..f94c5861ad2c 100644 --- a/stubs/fpdf2/fpdf/util.pyi +++ b/stubs/fpdf2/fpdf/util.pyi @@ -1,5 +1,6 @@ from collections.abc import Iterable -from typing import Any, AnyStr, Final, Literal, NamedTuple, TypeAlias +from typing import Any, AnyStr, Final, Literal, NamedTuple +from typing_extensions import TypeAlias _Unit: TypeAlias = Literal["pt", "mm", "cm", "in"] diff --git a/stubs/gdb/gdb/__init__.pyi b/stubs/gdb/gdb/__init__.pyi index a1b62b9f97a1..2c0a12c8b95a 100644 --- a/stubs/gdb/gdb/__init__.pyi +++ b/stubs/gdb/gdb/__init__.pyi @@ -6,8 +6,8 @@ import _typeshed import threading from collections.abc import Callable, Iterator, Mapping, Sequence from contextlib import AbstractContextManager -from typing import Any, Final, Generic, Literal, Protocol, TypeAlias, TypedDict, TypeVar, final, overload, type_check_only -from typing_extensions import deprecated, disjoint_base +from typing import Any, Final, Generic, Literal, Protocol, TypedDict, TypeVar, final, overload, type_check_only +from typing_extensions import TypeAlias, deprecated, disjoint_base import gdb.FrameDecorator import gdb.types diff --git a/stubs/gdb/gdb/dap/next.pyi b/stubs/gdb/gdb/dap/next.pyi index 1418de48f8da..c23e4260b950 100644 --- a/stubs/gdb/gdb/dap/next.pyi +++ b/stubs/gdb/gdb/dap/next.pyi @@ -1,5 +1,6 @@ from _typeshed import Unused -from typing import Literal, TypeAlias, TypedDict, type_check_only +from typing import Literal, TypedDict, type_check_only +from typing_extensions import TypeAlias @type_check_only class _ContinueRequestResult(TypedDict): diff --git a/stubs/gdb/gdb/dap/server.pyi b/stubs/gdb/gdb/dap/server.pyi index 2d74c3cbfef7..22b8231f7d54 100644 --- a/stubs/gdb/gdb/dap/server.pyi +++ b/stubs/gdb/gdb/dap/server.pyi @@ -2,7 +2,8 @@ import threading from _typeshed import Incomplete, SupportsReadline, Unused from collections.abc import Callable from contextlib import AbstractContextManager -from typing import Any, Generic, TypeAlias, TypeVar, type_check_only +from typing import Any, Generic, TypeVar, type_check_only +from typing_extensions import TypeAlias from .io import _SupportsReadAndReadlineBytes, _SupportsWriteAndFlushBytes from .startup import DAPQueue diff --git a/stubs/gdb/gdb/dap/sources.pyi b/stubs/gdb/gdb/dap/sources.pyi index 7adee35f2c9b..f12bcb3c9ab9 100644 --- a/stubs/gdb/gdb/dap/sources.pyi +++ b/stubs/gdb/gdb/dap/sources.pyi @@ -1,5 +1,6 @@ from _typeshed import Unused -from typing import TypeAlias, TypedDict, type_check_only +from typing import TypedDict, type_check_only +from typing_extensions import TypeAlias _SourceReferenceID: TypeAlias = int diff --git a/stubs/gdb/gdb/dap/startup.pyi b/stubs/gdb/gdb/dap/startup.pyi index 107a408901d1..702f2d8bf77b 100644 --- a/stubs/gdb/gdb/dap/startup.pyi +++ b/stubs/gdb/gdb/dap/startup.pyi @@ -3,7 +3,8 @@ import io import queue import threading from collections.abc import Callable, Iterable -from typing import Any, ClassVar, TypeAlias, TypeVar +from typing import Any, ClassVar, TypeVar +from typing_extensions import TypeAlias import gdb diff --git a/stubs/geopandas/geopandas/_decorator.pyi b/stubs/geopandas/geopandas/_decorator.pyi index 6d82bcec9198..03f7f23fb12e 100644 --- a/stubs/geopandas/geopandas/_decorator.pyi +++ b/stubs/geopandas/geopandas/_decorator.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import TypeAlias, TypeVar, overload +from typing import TypeVar, overload +from typing_extensions import TypeAlias _AnyCallable: TypeAlias = Callable[..., object] _Func = TypeVar("_Func", bound=_AnyCallable) diff --git a/stubs/geopandas/geopandas/array.pyi b/stubs/geopandas/geopandas/array.pyi index 330174693752..ca9596b43cdf 100644 --- a/stubs/geopandas/geopandas/array.pyi +++ b/stubs/geopandas/geopandas/array.pyi @@ -1,8 +1,8 @@ import builtins from _typeshed import Incomplete, Unused from collections.abc import Callable, Collection -from typing import Any, ClassVar, Final, Literal, NoReturn, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import Self, deprecated +from typing import Any, ClassVar, Final, Literal, NoReturn, SupportsIndex, TypeVar, overload +from typing_extensions import Self, TypeAlias, deprecated import numpy as np import pandas as pd diff --git a/stubs/geopandas/geopandas/base.pyi b/stubs/geopandas/geopandas/base.pyi index 474ca5e9e3d8..979c4fcbebef 100644 --- a/stubs/geopandas/geopandas/base.pyi +++ b/stubs/geopandas/geopandas/base.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsGetItem from collections.abc import Callable, Collection, Hashable, Iterable, Mapping, Sequence -from typing import Any, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import Any, Literal, Protocol, SupportsIndex, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated import numpy as np import pandas as pd diff --git a/stubs/geopandas/geopandas/io/_geoarrow.pyi b/stubs/geopandas/geopandas/io/_geoarrow.pyi index 720cd25f9358..d4a53581cb8b 100644 --- a/stubs/geopandas/geopandas/io/_geoarrow.pyi +++ b/stubs/geopandas/geopandas/io/_geoarrow.pyi @@ -7,10 +7,9 @@ from typing import ( Any as _PATable, Literal, Protocol, - TypeAlias, type_check_only, ) -from typing_extensions import CapsuleType +from typing_extensions import CapsuleType, TypeAlias import numpy as np from numpy.typing import NDArray diff --git a/stubs/geopandas/geopandas/io/sql.pyi b/stubs/geopandas/geopandas/io/sql.pyi index a68afccb51ed..d498da5064c9 100644 --- a/stubs/geopandas/geopandas/io/sql.pyi +++ b/stubs/geopandas/geopandas/io/sql.pyi @@ -2,7 +2,8 @@ import sqlite3 from _typeshed import Incomplete, SupportsLenAndGetItem from collections.abc import Container, Iterator, Mapping from contextlib import AbstractContextManager -from typing import Any, Protocol, TypeAlias, overload, type_check_only +from typing import Any, Protocol, overload, type_check_only +from typing_extensions import TypeAlias from pandas._typing import Scalar diff --git a/stubs/geopandas/geopandas/plotting.pyi b/stubs/geopandas/geopandas/plotting.pyi index 7c511859e3e4..01528e6284e4 100644 --- a/stubs/geopandas/geopandas/plotting.pyi +++ b/stubs/geopandas/geopandas/plotting.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Collection, Hashable, Iterable, Mapping, Sequence -from typing import Literal, TypeAlias, overload +from typing import Literal, overload +from typing_extensions import TypeAlias import numpy as np import pandas as pd diff --git a/stubs/gevent/gevent/_ffi/loop.pyi b/stubs/gevent/gevent/_ffi/loop.pyi index 38222a945d36..3e3004679223 100644 --- a/stubs/gevent/gevent/_ffi/loop.pyi +++ b/stubs/gevent/gevent/_ffi/loop.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import FileDescriptor from collections.abc import Callable, Sequence from types import TracebackType -from typing import Protocol, TypeAlias, type_check_only -from typing_extensions import TypeVarTuple, Unpack +from typing import Protocol, type_check_only +from typing_extensions import TypeAlias, TypeVarTuple, Unpack from gevent._types import _AsyncWatcher, _Callback, _ChildWatcher, _IoWatcher, _StatWatcher, _TimerWatcher, _Watcher diff --git a/stubs/gevent/gevent/_types.pyi b/stubs/gevent/gevent/_types.pyi index a32dfd540140..16db1f4d497f 100644 --- a/stubs/gevent/gevent/_types.pyi +++ b/stubs/gevent/gevent/_types.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import FileDescriptor, StrOrBytesPath from collections.abc import Callable from types import TracebackType -from typing import Any, Literal, Protocol, TypeAlias, overload -from typing_extensions import TypeVarTuple, Unpack +from typing import Any, Literal, Protocol, overload +from typing_extensions import TypeAlias, TypeVarTuple, Unpack _Ts = TypeVarTuple("_Ts") diff --git a/stubs/gevent/gevent/_waiter.pyi b/stubs/gevent/gevent/_waiter.pyi index 44d6f3e9864e..a240f02585bf 100644 --- a/stubs/gevent/gevent/_waiter.pyi +++ b/stubs/gevent/gevent/_waiter.pyi @@ -1,5 +1,6 @@ from types import TracebackType -from typing import Generic, TypeAlias, TypeVar, final, overload +from typing import Generic, TypeVar, final, overload +from typing_extensions import TypeAlias from gevent.event import _ValueSource from gevent.hub import Hub diff --git a/stubs/gevent/gevent/baseserver.pyi b/stubs/gevent/gevent/baseserver.pyi index 3b6c59a54edb..95cfe0551b5b 100644 --- a/stubs/gevent/gevent/baseserver.pyi +++ b/stubs/gevent/gevent/baseserver.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Container from types import TracebackType -from typing import Generic, Literal, Protocol, TypeAlias, type_check_only -from typing_extensions import ParamSpec, Self, TypeVarTuple, Unpack +from typing import Generic, Literal, Protocol, type_check_only +from typing_extensions import ParamSpec, Self, TypeAlias, TypeVarTuple, Unpack from gevent._types import _Loop from gevent.pool import Pool diff --git a/stubs/gevent/gevent/event.pyi b/stubs/gevent/gevent/event.pyi index fa24fe5159d2..d5570b019301 100644 --- a/stubs/gevent/gevent/event.pyi +++ b/stubs/gevent/gevent/event.pyi @@ -1,5 +1,6 @@ from types import TracebackType -from typing import Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import Generic, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from gevent._abstract_linkable import AbstractLinkable diff --git a/stubs/gevent/gevent/events.pyi b/stubs/gevent/gevent/events.pyi index 22e0338690e1..237d84ba2898 100644 --- a/stubs/gevent/gevent/events.pyi +++ b/stubs/gevent/gevent/events.pyi @@ -1,6 +1,7 @@ from collections.abc import Callable, Mapping, Sequence from types import ModuleType -from typing import Any, Protocol, TypeAlias, TypeVar, type_check_only +from typing import Any, Protocol, TypeVar, type_check_only +from typing_extensions import TypeAlias from gevent.hub import Hub from greenlet import greenlet as greenlet_t diff --git a/stubs/gevent/gevent/fileobject.pyi b/stubs/gevent/gevent/fileobject.pyi index 86fb43ebfd32..db49e17e084f 100644 --- a/stubs/gevent/gevent/fileobject.pyi +++ b/stubs/gevent/gevent/fileobject.pyi @@ -1,5 +1,6 @@ import sys -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from gevent._fileobjectcommon import FileObjectBlock as FileObjectBlock, FileObjectThread as FileObjectThread diff --git a/stubs/gevent/gevent/libev/watcher.pyi b/stubs/gevent/gevent/libev/watcher.pyi index a0c5d563b88a..4da07d7f30ee 100644 --- a/stubs/gevent/gevent/libev/watcher.pyi +++ b/stubs/gevent/gevent/libev/watcher.pyi @@ -1,8 +1,7 @@ import sys from _typeshed import FileDescriptor from collections.abc import Callable -from typing import TypeAlias -from typing_extensions import ParamSpec +from typing_extensions import ParamSpec, TypeAlias from gevent._ffi import watcher as _base from gevent.libev.corecffi import loop as cffi_loop diff --git a/stubs/gevent/gevent/selectors.pyi b/stubs/gevent/gevent/selectors.pyi index f25d16cd1f91..dd65f230a885 100644 --- a/stubs/gevent/gevent/selectors.pyi +++ b/stubs/gevent/gevent/selectors.pyi @@ -1,7 +1,8 @@ from _typeshed import FileDescriptorLike from collections.abc import Mapping from selectors import BaseSelector, SelectorKey -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from gevent._util import Lazy from gevent.hub import Hub diff --git a/stubs/gevent/gevent/server.pyi b/stubs/gevent/gevent/server.pyi index 0ee394c80c6f..a76b21c2bb6d 100644 --- a/stubs/gevent/gevent/server.pyi +++ b/stubs/gevent/gevent/server.pyi @@ -1,7 +1,8 @@ from _socket import _Address as _StrictAddress from _typeshed import ReadableBuffer, StrOrBytesPath from collections.abc import Callable -from typing import Any, ClassVar, TypeAlias, TypedDict, overload, type_check_only +from typing import Any, ClassVar, TypedDict, overload, type_check_only +from typing_extensions import TypeAlias from gevent.baseserver import BaseServer, _Spawner from gevent.socket import socket as _GeventSocket diff --git a/stubs/gevent/gevent/threadpool.pyi b/stubs/gevent/gevent/threadpool.pyi index d4391700d14d..3ce23ac79fb6 100644 --- a/stubs/gevent/gevent/threadpool.pyi +++ b/stubs/gevent/gevent/threadpool.pyi @@ -1,7 +1,7 @@ import concurrent.futures from collections.abc import Callable -from typing import Any, Generic, TypeAlias, TypeVar -from typing_extensions import ParamSpec +from typing import Any, Generic, TypeVar +from typing_extensions import ParamSpec, TypeAlias from gevent._threading import Queue from gevent._types import _AsyncWatcher, _Watcher diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi index 6fd446d432c9..e13a58438c4f 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -1,8 +1,8 @@ import datetime from _typeshed import Unused from collections.abc import Callable, Iterable, Sequence -from typing import Any, Literal, NoReturn, TypeAlias -from typing_extensions import Self +from typing import Any, Literal, NoReturn +from typing_extensions import Self, TypeAlias from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module diff --git a/stubs/greenlet/greenlet/_greenlet.pyi b/stubs/greenlet/greenlet/_greenlet.pyi index cc3c255e43da..92607c354f82 100644 --- a/stubs/greenlet/greenlet/_greenlet.pyi +++ b/stubs/greenlet/greenlet/_greenlet.pyi @@ -2,8 +2,8 @@ import sys from collections.abc import Callable from contextvars import Context from types import FrameType, TracebackType -from typing import Any, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import disjoint_base +from typing import Any, Literal, Protocol, overload, type_check_only +from typing_extensions import TypeAlias, disjoint_base _TraceEvent: TypeAlias = Literal["switch", "throw"] _TraceCallback: TypeAlias = Callable[[_TraceEvent, tuple[greenlet, greenlet]], object] diff --git a/stubs/grpcio-reflection/grpc_reflection/v1alpha/reflection.pyi b/stubs/grpcio-reflection/grpc_reflection/v1alpha/reflection.pyi index 0c00500de3a7..8b336b9bee3c 100644 --- a/stubs/grpcio-reflection/grpc_reflection/v1alpha/reflection.pyi +++ b/stubs/grpcio-reflection/grpc_reflection/v1alpha/reflection.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias import grpc import grpc.aio diff --git a/stubs/grpcio/grpc/__init__.pyi b/stubs/grpcio/grpc/__init__.pyi index b4e585b08c9b..107ab51f33a9 100644 --- a/stubs/grpcio/grpc/__init__.pyi +++ b/stubs/grpcio/grpc/__init__.pyi @@ -4,8 +4,8 @@ import threading from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from concurrent import futures from types import ModuleType, TracebackType -from typing import Any, Generic, NoReturn, Protocol, TypeAlias, TypeVar, type_check_only -from typing_extensions import Self +from typing import Any, Generic, NoReturn, Protocol, TypeVar, type_check_only +from typing_extensions import Self, TypeAlias from . import aio as aio diff --git a/stubs/grpcio/grpc/aio/__init__.pyi b/stubs/grpcio/grpc/aio/__init__.pyi index d05a8c3ddbe5..4c8ef012fb29 100644 --- a/stubs/grpcio/grpc/aio/__init__.pyi +++ b/stubs/grpcio/grpc/aio/__init__.pyi @@ -4,8 +4,8 @@ from _typeshed import Incomplete from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable, Generator, Iterable, Iterator, Mapping, Sequence from concurrent import futures from types import TracebackType -from typing import Any, Generic, NoReturn, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, Generic, NoReturn, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias from grpc import ( CallCredentials, diff --git a/stubs/gunicorn/gunicorn/_types.pyi b/stubs/gunicorn/gunicorn/_types.pyi index 815a1179f98c..cbe38ddfd655 100644 --- a/stubs/gunicorn/gunicorn/_types.pyi +++ b/stubs/gunicorn/gunicorn/_types.pyi @@ -1,8 +1,8 @@ ### This .pyi file is a helper for centralized storage types that are reused across different runtime modules. ### from _typeshed import FileDescriptor from collections.abc import Awaitable, Callable, Iterable, MutableMapping -from typing import Any, TypeAlias -from typing_extensions import LiteralString +from typing import Any +from typing_extensions import LiteralString, TypeAlias _StatusType: TypeAlias = str _HeadersType: TypeAlias = Iterable[tuple[str, str]] diff --git a/stubs/gunicorn/gunicorn/config.pyi b/stubs/gunicorn/gunicorn/config.pyi index e115582e30e6..ba1e706db78e 100644 --- a/stubs/gunicorn/gunicorn/config.pyi +++ b/stubs/gunicorn/gunicorn/config.pyi @@ -2,7 +2,8 @@ import argparse from _typeshed import ConvertibleToInt from collections.abc import Callable, Container from ssl import SSLContext, _SSLMethod -from typing import Annotated, Any, ClassVar, Final, TypeAlias, overload +from typing import Annotated, Any, ClassVar, Final, overload +from typing_extensions import TypeAlias from gunicorn.arbiter import Arbiter from gunicorn.glogging import Logger as GLogger diff --git a/stubs/gunicorn/gunicorn/glogging.pyi b/stubs/gunicorn/gunicorn/glogging.pyi index 0ee4a9edfb4c..f04f94909706 100644 --- a/stubs/gunicorn/gunicorn/glogging.pyi +++ b/stubs/gunicorn/gunicorn/glogging.pyi @@ -4,7 +4,8 @@ from collections.abc import Mapping from datetime import timedelta from logging.config import _DictConfigArgs from socket import SocketKind -from typing import Annotated, Any, ClassVar, Literal, TypeAlias, TypedDict, type_check_only +from typing import Annotated, Any, ClassVar, Literal, TypedDict, type_check_only +from typing_extensions import TypeAlias from gunicorn.http import Request from gunicorn.http.wsgi import Response diff --git a/stubs/gunicorn/gunicorn/http/body.pyi b/stubs/gunicorn/gunicorn/http/body.pyi index 10b4d0af94da..cc2735015b6a 100644 --- a/stubs/gunicorn/gunicorn/http/body.pyi +++ b/stubs/gunicorn/gunicorn/http/body.pyi @@ -1,6 +1,6 @@ import io from collections.abc import Callable, Generator, Iterator -from typing import TypeAlias +from typing_extensions import TypeAlias from gunicorn.http.message import Request from gunicorn.http.unreader import Unreader diff --git a/stubs/gunicorn/gunicorn/http2/connection.pyi b/stubs/gunicorn/gunicorn/http2/connection.pyi index 5ef587127e7f..ee5f50a0dbaa 100644 --- a/stubs/gunicorn/gunicorn/http2/connection.pyi +++ b/stubs/gunicorn/gunicorn/http2/connection.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete from collections.abc import Iterable from ssl import SSLSocket -from typing import Any, ClassVar, TypeAlias +from typing import Any, ClassVar +from typing_extensions import TypeAlias from gunicorn.config import Config from gunicorn.http2.request import HTTP2Request diff --git a/stubs/gunicorn/gunicorn/reloader.pyi b/stubs/gunicorn/gunicorn/reloader.pyi index f6f0ff9cc92d..7d729d281949 100644 --- a/stubs/gunicorn/gunicorn/reloader.pyi +++ b/stubs/gunicorn/gunicorn/reloader.pyi @@ -2,7 +2,8 @@ import sys import threading from collections.abc import Callable, Iterable from re import Pattern -from typing import Final, NoReturn, TypeAlias, TypedDict, type_check_only +from typing import Final, NoReturn, TypedDict, type_check_only +from typing_extensions import TypeAlias COMPILED_EXT_RE: Final[Pattern[str]] diff --git a/stubs/gunicorn/gunicorn/workers/geventlet.pyi b/stubs/gunicorn/gunicorn/workers/geventlet.pyi index c0a53550ceae..481996a13837 100644 --- a/stubs/gunicorn/gunicorn/workers/geventlet.pyi +++ b/stubs/gunicorn/gunicorn/workers/geventlet.pyi @@ -1,5 +1,6 @@ from types import FrameType -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from gunicorn.workers.base_async import AsyncWorker diff --git a/stubs/gunicorn/gunicorn/workers/gtornado.pyi b/stubs/gunicorn/gunicorn/workers/gtornado.pyi index 25267d4d46bb..cac5ed08e525 100644 --- a/stubs/gunicorn/gunicorn/workers/gtornado.pyi +++ b/stubs/gunicorn/gunicorn/workers/gtornado.pyi @@ -1,5 +1,6 @@ from types import FrameType -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from gunicorn.workers.base import Worker diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 0f12313590cd..8cccb842afe8 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -3,8 +3,8 @@ from _typeshed import Incomplete, ReadableBuffer from collections.abc import Callable, Sequence from datetime import date, datetime, time from types import TracebackType -from typing import Any, Final, Literal, TypeAlias, overload -from typing_extensions import Self, disjoint_base +from typing import Any, Final, Literal, overload +from typing_extensions import Self, TypeAlias, disjoint_base from .resultrow import ResultRow diff --git a/stubs/html5lib/html5lib/_inputstream.pyi b/stubs/html5lib/html5lib/_inputstream.pyi index f3d92a878716..53a94876db6f 100644 --- a/stubs/html5lib/html5lib/_inputstream.pyi +++ b/stubs/html5lib/html5lib/_inputstream.pyi @@ -2,8 +2,8 @@ import re from _io import BytesIO, StringIO from _typeshed import Incomplete, ReadableBuffer, SupportsRead from collections.abc import Callable, Iterable -from typing import Any, AnyStr, Generic, Literal, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import Any, AnyStr, Generic, Literal, TypeVar, overload +from typing_extensions import Self, TypeAlias from webencodings import Encoding diff --git a/stubs/icalendar/icalendar/alarms.pyi b/stubs/icalendar/icalendar/alarms.pyi index ec2befb72de1..975a413369ce 100644 --- a/stubs/icalendar/icalendar/alarms.pyi +++ b/stubs/icalendar/icalendar/alarms.pyi @@ -1,5 +1,5 @@ import datetime -from typing import TypeAlias +from typing_extensions import TypeAlias from .cal import Alarm, Event, Todo from .error import ( diff --git a/stubs/icalendar/icalendar/parser_tools.pyi b/stubs/icalendar/icalendar/parser_tools.pyi index 357d5ee6bd00..6456cc836306 100644 --- a/stubs/icalendar/icalendar/parser_tools.pyi +++ b/stubs/icalendar/icalendar/parser_tools.pyi @@ -1,4 +1,5 @@ -from typing import Any, Final, TypeAlias, TypeVar, overload +from typing import Any, Final, TypeVar, overload +from typing_extensions import TypeAlias _T = TypeVar("_T") diff --git a/stubs/icalendar/icalendar/prop.pyi b/stubs/icalendar/icalendar/prop.pyi index c591282c04b2..2675ebe82baf 100644 --- a/stubs/icalendar/icalendar/prop.pyi +++ b/stubs/icalendar/icalendar/prop.pyi @@ -3,8 +3,8 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Supports from collections.abc import Iterable, Iterator from enum import Enum from re import Pattern -from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeAlias, overload, type_check_only -from typing_extensions import Self +from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, overload, type_check_only +from typing_extensions import Self, TypeAlias from .caselessdict import CaselessDict from .parser import Parameters diff --git a/stubs/icalendar/icalendar/tools.pyi b/stubs/icalendar/icalendar/tools.pyi index b5d7c82d16bc..d63d649f8041 100644 --- a/stubs/icalendar/icalendar/tools.pyi +++ b/stubs/icalendar/icalendar/tools.pyi @@ -1,6 +1,6 @@ import datetime -from typing import Final, TypeGuard -from typing_extensions import TypeIs, deprecated +from typing import Final +from typing_extensions import TypeGuard, TypeIs, deprecated from pytz.tzinfo import BaseTzInfo diff --git a/stubs/inifile/inifile.pyi b/stubs/inifile/inifile.pyi index c3ed7c06dbdd..c64a3168d983 100644 --- a/stubs/inifile/inifile.pyi +++ b/stubs/inifile/inifile.pyi @@ -1,6 +1,7 @@ from _typeshed import StrPath, SupportsKeysAndGetItem from collections.abc import Container, Iterable, Iterator, Mapping, MutableMapping, Sequence -from typing import Literal, TypeAlias, TypeVar, overload +from typing import Literal, TypeVar, overload +from typing_extensions import TypeAlias from uuid import UUID _T = TypeVar("_T") diff --git a/stubs/jmespath/jmespath/ast.pyi b/stubs/jmespath/jmespath/ast.pyi index 53d718e084a0..d8c75d0abdde 100644 --- a/stubs/jmespath/jmespath/ast.pyi +++ b/stubs/jmespath/jmespath/ast.pyi @@ -1,5 +1,5 @@ -from typing import Literal, TypeAlias, TypedDict, type_check_only -from typing_extensions import NotRequired +from typing import Literal, TypedDict, type_check_only +from typing_extensions import NotRequired, TypeAlias _NodeType: TypeAlias = Literal[ "comparator", diff --git a/stubs/jsonschema/jsonschema/_format.pyi b/stubs/jsonschema/jsonschema/_format.pyi index 9204059bee6d..8b9912dc59ac 100644 --- a/stubs/jsonschema/jsonschema/_format.pyi +++ b/stubs/jsonschema/jsonschema/_format.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Iterable -from typing import TypeAlias, TypeVar +from typing import TypeVar +from typing_extensions import TypeAlias _FormatCheckCallable: TypeAlias = Callable[[object], bool] _F = TypeVar("_F", bound=_FormatCheckCallable) diff --git a/stubs/jsonschema/jsonschema/_typing.pyi b/stubs/jsonschema/jsonschema/_typing.pyi index 78e946676d79..bf096c3fa078 100644 --- a/stubs/jsonschema/jsonschema/_typing.pyi +++ b/stubs/jsonschema/jsonschema/_typing.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Iterable -from typing import Any, Protocol, TypeAlias +from typing import Any, Protocol +from typing_extensions import TypeAlias from jsonschema.protocols import Validator from referencing.jsonschema import Schema diff --git a/stubs/jsonschema/jsonschema/exceptions.pyi b/stubs/jsonschema/jsonschema/exceptions.pyi index 937a03e2587a..aef0c616e705 100644 --- a/stubs/jsonschema/jsonschema/exceptions.pyi +++ b/stubs/jsonschema/jsonschema/exceptions.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, SupportsRichComparison, sentinel from collections import deque from collections.abc import Callable, Container, Iterable, Iterator, Mapping, MutableMapping, Sequence -from typing import Any, TypeAlias -from typing_extensions import Self, deprecated +from typing import Any +from typing_extensions import Self, TypeAlias, deprecated from ._types import TypeChecker from ._utils import Unset diff --git a/stubs/jsonschema/jsonschema/protocols.pyi b/stubs/jsonschema/jsonschema/protocols.pyi index 5fea709eeaaf..8f523c1ca4a6 100644 --- a/stubs/jsonschema/jsonschema/protocols.pyi +++ b/stubs/jsonschema/jsonschema/protocols.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterator, Mapping, Sequence -from typing import Any, ClassVar, Protocol, TypeAlias +from typing import Any, ClassVar, Protocol +from typing_extensions import TypeAlias import referencing.jsonschema from jsonschema._format import FormatChecker diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi index 4da9902c8492..4e93434f1d65 100644 --- a/stubs/jsonschema/jsonschema/validators.pyi +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, SupportsKeysAndGetItem from collections.abc import Callable, Generator, Iterable, Iterator, Mapping from contextlib import contextmanager -from typing import Any, ClassVar, TypeAlias, overload, type_check_only -from typing_extensions import deprecated +from typing import Any, ClassVar, overload, type_check_only +from typing_extensions import TypeAlias, deprecated from referencing.jsonschema import Schema, SchemaRegistry from referencing.typing import URI diff --git a/stubs/jwcrypto/jwcrypto/jwk.pyi b/stubs/jwcrypto/jwcrypto/jwk.pyi index d4408c03b344..721b4e892e9b 100644 --- a/stubs/jwcrypto/jwcrypto/jwk.pyi +++ b/stubs/jwcrypto/jwcrypto/jwk.pyi @@ -1,8 +1,8 @@ from _typeshed import Unused from collections.abc import Callable, Sequence from enum import Enum -from typing import Any, Literal, NamedTuple, TypeAlias, TypeVar, overload -from typing_extensions import Self, deprecated +from typing import Any, Literal, NamedTuple, TypeVar, overload +from typing_extensions import Self, TypeAlias, deprecated from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import ec, rsa diff --git a/stubs/keyboard/keyboard/__init__.pyi b/stubs/keyboard/keyboard/__init__.pyi index b6b2763fe9b3..432d233660fc 100644 --- a/stubs/keyboard/keyboard/__init__.pyi +++ b/stubs/keyboard/keyboard/__init__.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Generator, Iterable, Sequence from queue import Queue from threading import Event as _UninterruptibleEvent -from typing import TypeAlias +from typing_extensions import TypeAlias from ._canonical_names import all_modifiers as all_modifiers, sided_modifiers as sided_modifiers from ._keyboard_event import KEY_DOWN as KEY_DOWN, KEY_UP as KEY_UP, KeyboardEvent as KeyboardEvent diff --git a/stubs/keyboard/keyboard/_generic.pyi b/stubs/keyboard/keyboard/_generic.pyi index a1784b3d89a8..8f61d95c2698 100644 --- a/stubs/keyboard/keyboard/_generic.pyi +++ b/stubs/keyboard/keyboard/_generic.pyi @@ -1,7 +1,8 @@ from collections.abc import Callable from queue import Queue from threading import Lock, Thread -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from ._keyboard_event import KeyboardEvent from ._mouse_event import _MouseEvent diff --git a/stubs/keyboard/keyboard/_mouse_event.pyi b/stubs/keyboard/keyboard/_mouse_event.pyi index e9e95b80e112..ce8e04af9482 100644 --- a/stubs/keyboard/keyboard/_mouse_event.pyi +++ b/stubs/keyboard/keyboard/_mouse_event.pyi @@ -1,5 +1,6 @@ import sys -from typing import Literal, NamedTuple, TypeAlias +from typing import Literal, NamedTuple +from typing_extensions import TypeAlias _MouseEvent: TypeAlias = ButtonEvent | WheelEvent | MoveEvent # noqa: Y047 # Used outside diff --git a/stubs/keyboard/keyboard/mouse.pyi b/stubs/keyboard/keyboard/mouse.pyi index 6105f85d59a9..16008246893d 100644 --- a/stubs/keyboard/keyboard/mouse.pyi +++ b/stubs/keyboard/keyboard/mouse.pyi @@ -1,7 +1,8 @@ import sys from collections.abc import Callable, Iterable from ctypes import c_long -from typing import Literal, SupportsInt, TypeAlias, TypeVar +from typing import Literal, SupportsInt, TypeVar +from typing_extensions import TypeAlias from ._generic import GenericListener as _GenericListener from ._mouse_event import ( diff --git a/stubs/ldap3/ldap3/core/connection.pyi b/stubs/ldap3/ldap3/core/connection.pyi index 0ee8700e0902..47df86aa6ad8 100644 --- a/stubs/ldap3/ldap3/core/connection.pyi +++ b/stubs/ldap3/ldap3/core/connection.pyi @@ -1,8 +1,8 @@ from _collections_abc import Generator, dict_keys from _typeshed import Incomplete, ReadableBuffer from types import TracebackType -from typing import Literal, TypeAlias -from typing_extensions import Self +from typing import Literal +from typing_extensions import Self, TypeAlias from pyasn1.type.base import Asn1Item diff --git a/stubs/ldap3/ldap3/utils/asn1.pyi b/stubs/ldap3/ldap3/utils/asn1.pyi index 0455ffd7cf7a..4d4abfcea9ca 100644 --- a/stubs/ldap3/ldap3/utils/asn1.pyi +++ b/stubs/ldap3/ldap3/utils/asn1.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete, IndexableBuffer, SliceableBuffer, Unused from collections.abc import Callable, Mapping -from typing import Any, Final, TypeAlias, TypeVar, overload +from typing import Any, Final, TypeVar, overload +from typing_extensions import TypeAlias from pyasn1.codec.ber.encoder import AbstractItemEncoder from pyasn1.type.tag import TagSet diff --git a/stubs/libsass/sass.pyi b/stubs/libsass/sass.pyi index 8bcb341df18c..b81a15213378 100644 --- a/stubs/libsass/sass.pyi +++ b/stubs/libsass/sass.pyi @@ -1,8 +1,8 @@ import enum from _typeshed import ConvertibleToFloat, SupportsKeysAndGetItem from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence, Set as AbstractSet -from typing import Any, Generic, Literal, NamedTuple, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import ParamSpec, Self +from typing import Any, Generic, Literal, NamedTuple, TypeVar, overload, type_check_only +from typing_extensions import ParamSpec, Self, TypeAlias _T = TypeVar("_T") _KT = TypeVar("_KT") diff --git a/stubs/lupa/lupa/lua51.pyi b/stubs/lupa/lupa/lua51.pyi index 768251730bff..6cc8152115ca 100644 --- a/stubs/lupa/lupa/lua51.pyi +++ b/stubs/lupa/lupa/lua51.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable -from typing import Any, Final, Generic, TypeAlias, TypeVar, type_check_only -from typing_extensions import Self, disjoint_base +from typing import Any, Final, Generic, TypeVar, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base __all__ = [ "LUA_VERSION", diff --git a/stubs/lupa/lupa/lua52.pyi b/stubs/lupa/lupa/lua52.pyi index 768251730bff..6cc8152115ca 100644 --- a/stubs/lupa/lupa/lua52.pyi +++ b/stubs/lupa/lupa/lua52.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable -from typing import Any, Final, Generic, TypeAlias, TypeVar, type_check_only -from typing_extensions import Self, disjoint_base +from typing import Any, Final, Generic, TypeVar, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base __all__ = [ "LUA_VERSION", diff --git a/stubs/lupa/lupa/lua53.pyi b/stubs/lupa/lupa/lua53.pyi index 768251730bff..6cc8152115ca 100644 --- a/stubs/lupa/lupa/lua53.pyi +++ b/stubs/lupa/lupa/lua53.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable -from typing import Any, Final, Generic, TypeAlias, TypeVar, type_check_only -from typing_extensions import Self, disjoint_base +from typing import Any, Final, Generic, TypeVar, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base __all__ = [ "LUA_VERSION", diff --git a/stubs/lupa/lupa/lua54.pyi b/stubs/lupa/lupa/lua54.pyi index 768251730bff..6cc8152115ca 100644 --- a/stubs/lupa/lupa/lua54.pyi +++ b/stubs/lupa/lupa/lua54.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable -from typing import Any, Final, Generic, TypeAlias, TypeVar, type_check_only -from typing_extensions import Self, disjoint_base +from typing import Any, Final, Generic, TypeVar, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base __all__ = [ "LUA_VERSION", diff --git a/stubs/m3u8/m3u8/__init__.pyi b/stubs/m3u8/m3u8/__init__.pyi index 6fe32d5edeee..8ce37aeb0b52 100644 --- a/stubs/m3u8/m3u8/__init__.pyi +++ b/stubs/m3u8/m3u8/__init__.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Mapping -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from m3u8.httpclient import _HTTPClientProtocol from m3u8.model import ( diff --git a/stubs/m3u8/m3u8/model.pyi b/stubs/m3u8/m3u8/model.pyi index e59d19cf1f50..53e31529e23e 100644 --- a/stubs/m3u8/m3u8/model.pyi +++ b/stubs/m3u8/m3u8/model.pyi @@ -2,7 +2,8 @@ import datetime as dt from _typeshed import Incomplete, StrOrBytesPath, Unused from collections.abc import Callable, Iterable, Mapping from decimal import Decimal -from typing import Any, ClassVar, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from m3u8.mixins import BasePathMixin, GroupedBasePathMixin from m3u8.protocol import ext_x_map, ext_x_session_key diff --git a/stubs/m3u8/m3u8/parser.pyi b/stubs/m3u8/m3u8/parser.pyi index aeee2b4d6a6d..4eaf0543ffc8 100644 --- a/stubs/m3u8/m3u8/parser.pyi +++ b/stubs/m3u8/m3u8/parser.pyi @@ -2,7 +2,8 @@ from collections.abc import Callable from datetime import date, datetime, time from itertools import repeat from re import Pattern -from typing import Any, TypeAlias, overload +from typing import Any, overload +from typing_extensions import TypeAlias _CustomTagsParser: TypeAlias = Callable[[str, int, dict[str, Any], dict[str, Any]], object] diff --git a/stubs/mock/mock/backports.pyi b/stubs/mock/mock/backports.pyi index 9cb45af2cd60..fd968db5d6cb 100644 --- a/stubs/mock/mock/backports.pyi +++ b/stubs/mock/mock/backports.pyi @@ -1,2 +1,7 @@ -from inspect import iscoroutinefunction as iscoroutinefunction +import sys from unittest import IsolatedAsyncioTestCase as IsolatedAsyncioTestCase + +if sys.version_info >= (3, 10): + from inspect import iscoroutinefunction as iscoroutinefunction +else: + from asyncio import iscoroutinefunction as iscoroutinefunction diff --git a/stubs/mysqlclient/MySQLdb/connections.pyi b/stubs/mysqlclient/MySQLdb/connections.pyi index c35ccd31689e..0a4f8965fcba 100644 --- a/stubs/mysqlclient/MySQLdb/connections.pyi +++ b/stubs/mysqlclient/MySQLdb/connections.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from re import Pattern from types import TracebackType -from typing import Any, TypeAlias -from typing_extensions import LiteralString, Self +from typing import Any +from typing_extensions import LiteralString, Self, TypeAlias from . import _mysql, cursors from ._exceptions import ( diff --git a/stubs/mysqlclient/MySQLdb/cursors.pyi b/stubs/mysqlclient/MySQLdb/cursors.pyi index f0dd10ea95d8..e3111af67896 100644 --- a/stubs/mysqlclient/MySQLdb/cursors.pyi +++ b/stubs/mysqlclient/MySQLdb/cursors.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable from re import Pattern -from typing import TypeAlias -from typing_extensions import LiteralString +from typing_extensions import LiteralString, TypeAlias from .connections import _Literal diff --git a/stubs/nanoid/nanoid/method.pyi b/stubs/nanoid/nanoid/method.pyi index 0e79a8e09215..1a8b33fa9f9a 100644 --- a/stubs/nanoid/nanoid/method.pyi +++ b/stubs/nanoid/nanoid/method.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Sequence -from typing import TypeAlias +from typing_extensions import TypeAlias _Algorithm: TypeAlias = Callable[[int], Sequence[int]] diff --git a/stubs/netaddr/netaddr/eui/ieee.pyi b/stubs/netaddr/netaddr/eui/ieee.pyi index 560ee2a1eefe..a5f2079af176 100644 --- a/stubs/netaddr/netaddr/eui/ieee.pyi +++ b/stubs/netaddr/netaddr/eui/ieee.pyi @@ -1,7 +1,8 @@ import _csv from _typeshed import FileDescriptorOrPath, StrOrBytesPath from collections.abc import Iterable -from typing import Any, BinaryIO, TextIO, TypeAlias +from typing import Any, BinaryIO, TextIO +from typing_extensions import TypeAlias from netaddr.core import Publisher, Subscriber diff --git a/stubs/netaddr/netaddr/ip/__init__.pyi b/stubs/netaddr/netaddr/ip/__init__.pyi index 6c61ff4cc056..9aa6a680bd43 100644 --- a/stubs/netaddr/netaddr/ip/__init__.pyi +++ b/stubs/netaddr/netaddr/ip/__init__.pyi @@ -2,8 +2,8 @@ from _typeshed import ConvertibleToInt, Unused from abc import abstractmethod from collections.abc import Iterable, Iterator from types import ModuleType -from typing import Literal, SupportsIndex, SupportsInt, TypeAlias, overload -from typing_extensions import Self +from typing import Literal, SupportsIndex, SupportsInt, overload +from typing_extensions import Self, TypeAlias from netaddr.core import DictDotLookup from netaddr.strategy.ipv6 import ipv6_verbose diff --git a/stubs/netaddr/netaddr/ip/glob.pyi b/stubs/netaddr/netaddr/ip/glob.pyi index 42f5c8f3e802..e0836fcf3bdd 100644 --- a/stubs/netaddr/netaddr/ip/glob.pyi +++ b/stubs/netaddr/netaddr/ip/glob.pyi @@ -1,4 +1,4 @@ -from typing import TypeGuard +from typing_extensions import TypeGuard from netaddr.ip import IPAddress, IPNetwork, IPRange, _IPAddressAddr, _IPNetworkAddr diff --git a/stubs/netaddr/netaddr/ip/iana.pyi b/stubs/netaddr/netaddr/ip/iana.pyi index 1d205a275d25..a689f90cb52c 100644 --- a/stubs/netaddr/netaddr/ip/iana.pyi +++ b/stubs/netaddr/netaddr/ip/iana.pyi @@ -1,6 +1,7 @@ from _typeshed import SupportsWrite from collections.abc import Callable, Mapping, MutableMapping -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from xml.sax import _Source, handler from xml.sax.xmlreader import AttributesImpl, InputSource, XMLReader diff --git a/stubs/netaddr/netaddr/ip/sets.pyi b/stubs/netaddr/netaddr/ip/sets.pyi index 720336f82bfa..b512ee720b30 100644 --- a/stubs/netaddr/netaddr/ip/sets.pyi +++ b/stubs/netaddr/netaddr/ip/sets.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable, Iterator -from typing import NoReturn, TypeAlias -from typing_extensions import Self +from typing import NoReturn +from typing_extensions import Self, TypeAlias from netaddr.ip import IPAddress, IPNetwork, IPRange, _IPNetworkAddr diff --git a/stubs/networkx/networkx/_typing.pyi b/stubs/networkx/networkx/_typing.pyi index e9c78cbbc497..ff530c5ba668 100644 --- a/stubs/networkx/networkx/_typing.pyi +++ b/stubs/networkx/networkx/_typing.pyi @@ -1,8 +1,9 @@ # Stub-only module, can't be imported at runtime. +import sys from collections.abc import Collection -from typing import Any, Protocol, TypeAlias, type_check_only -from typing_extensions import TypeVar +from typing import Any, Protocol, type_check_only +from typing_extensions import TypeAlias, TypeVar import numpy as np @@ -12,11 +13,16 @@ _GenericT_co = TypeVar("_GenericT_co", bound=np.generic, covariant=True) _ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=Any, covariant=True) # numpy aliases -@type_check_only -class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]): - def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ... +if sys.version_info >= (3, 10): + @type_check_only + class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]): + def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ... -ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]] + ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]] +else: + # networkx does not support Python 3.9 but pyright still runs on 3.9 in CI + # See https://github.com/python/typeshed/issues/10722 + ArrayLike1D: TypeAlias = Collection[_ScalarT] | np.ndarray[tuple[int], np.dtype[_GenericT]] Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_GenericT]] Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_GenericT]] diff --git a/stubs/networkx/networkx/algorithms/approximation/density.pyi b/stubs/networkx/networkx/algorithms/approximation/density.pyi index 8d84f8373b39..b5cd3cb16bb6 100644 --- a/stubs/networkx/networkx/algorithms/approximation/density.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/density.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Hashable -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable diff --git a/stubs/networkx/networkx/algorithms/community/local.pyi b/stubs/networkx/networkx/algorithms/community/local.pyi index 9799724b299b..4825f964529f 100644 --- a/stubs/networkx/networkx/algorithms/community/local.pyi +++ b/stubs/networkx/networkx/algorithms/community/local.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Hashable -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi index 8b109a2b9f5b..8043d3647d19 100644 --- a/stubs/networkx/networkx/algorithms/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Mapping -from typing import TypeAlias +from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index bee3ecf7470c..5eb7445b0065 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Collection, Generator -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 1855ba5228c7..086c697e26a1 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, MutableMapping from functools import cached_property -from typing import Any, ClassVar, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import Any, ClassVar, TypeVar, overload +from typing_extensions import Self, TypeAlias import numpy from networkx.classes.coreviews import AdjacencyView, AtlasView diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index 72b1a09d453c..ce68d24d34e8 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -1,7 +1,7 @@ from collections.abc import Hashable from functools import cached_property -from typing import Any, ClassVar, TypeAlias, overload -from typing_extensions import Self, TypeVar +from typing import Any, ClassVar, overload +from typing_extensions import Self, TypeAlias, TypeVar from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.graph import Graph, _MapFactory, _Node diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 52f5b16f3e31..53a0f816c4f5 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Collection, Hashable, Iterable -from typing import Literal, TypeAlias, TypeVar, overload +from typing import Literal, TypeVar, overload +from typing_extensions import TypeAlias import numpy from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index 0ecb4a6d4289..914763eb57ee 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -1,5 +1,6 @@ from collections.abc import Collection, Mapping -from typing import Any, Literal, TypeAlias +from typing import Any, Literal +from typing_extensions import TypeAlias import numpy as np from networkx._typing import Array1D, Array2D, ArrayLike1D, Seed diff --git a/stubs/networkx/networkx/drawing/nx_latex.pyi b/stubs/networkx/networkx/drawing/nx_latex.pyi index 90beba19dd14..353ea573e092 100644 --- a/stubs/networkx/networkx/drawing/nx_latex.pyi +++ b/stubs/networkx/networkx/drawing/nx_latex.pyi @@ -1,7 +1,6 @@ from _typeshed import StrPath, SupportsWrite from collections.abc import Collection -from typing import TypeAlias -from typing_extensions import TypeVar +from typing_extensions import TypeAlias, TypeVar from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index ee4002b32ed5..160766f7d884 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsItems from collections.abc import Callable, Collection, Hashable, Iterable, Mapping, Sequence -from typing import Any, Generic, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Unpack +from typing import Any, Generic, Literal, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias, Unpack import numpy as np from matplotlib.axes import Axes # type: ignore[import-not-found] diff --git a/stubs/networkx/networkx/utils/configs.pyi b/stubs/networkx/networkx/utils/configs.pyi index edc2908066d4..780ccf7233a2 100644 --- a/stubs/networkx/networkx/utils/configs.pyi +++ b/stubs/networkx/networkx/utils/configs.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import Incomplete from collections.abc import Callable, ItemsView, Iterable, Iterator, KeysView, ValuesView from dataclasses import dataclass @@ -8,30 +9,57 @@ __all__ = ["Config"] # TODO: Our pyright test doesn't understand `requires_python` in METADATA.toml # https://github.com/python/typeshed/issues/14025 -@dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False) -class Config: - def __init_subclass__(cls, strict: bool = True) -> None: ... - def __new__(cls, **kwargs) -> Self: ... - def __dir__(self) -> Iterable[str]: ... - def __setattr__(self, name: str, value) -> None: ... - def __delattr__(self, name: str) -> None: ... - def __contains__(self, key: object) -> bool: ... - def __iter__(self) -> Iterator[str]: ... - def __len__(self) -> int: ... - def __reversed__(self) -> Iterator[str]: ... - def __getitem__(self, key: str): ... - def __setitem__(self, key: str, value) -> None: ... - def __delitem__(self, key: str) -> None: ... - def get(self, key: str, default=None): ... - def items(self) -> ItemsView[str, Incomplete]: ... - def keys(self) -> KeysView[str]: ... - def values(self) -> ValuesView[Incomplete]: ... - def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... - def __call__(self, **kwargs) -> Self: ... - def __enter__(self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None - ) -> None: ... +if sys.version_info >= (3, 10): + @dataclass(init=False, eq=False, slots=True, kw_only=True, match_args=False) + class Config: + def __init_subclass__(cls, strict: bool = True) -> None: ... + def __new__(cls, **kwargs) -> Self: ... + def __dir__(self) -> Iterable[str]: ... + def __setattr__(self, name: str, value) -> None: ... + def __delattr__(self, name: str) -> None: ... + def __contains__(self, key: object) -> bool: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... + def __reversed__(self) -> Iterator[str]: ... + def __getitem__(self, key: str): ... + def __setitem__(self, key: str, value) -> None: ... + def __delitem__(self, key: str) -> None: ... + def get(self, key: str, default=None): ... + def items(self) -> ItemsView[str, Incomplete]: ... + def keys(self) -> KeysView[str]: ... + def values(self) -> ValuesView[Incomplete]: ... + def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... + def __call__(self, **kwargs) -> Self: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + ) -> None: ... + +else: + @dataclass(init=False, eq=False) + class Config: + def __init_subclass__(cls, strict: bool = True) -> None: ... + def __new__(cls, **kwargs) -> Self: ... + def __dir__(self) -> Iterable[str]: ... + def __setattr__(self, name: str, value) -> None: ... + def __delattr__(self, name: str) -> None: ... + def __contains__(self, key: object) -> bool: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... + def __reversed__(self) -> Iterator[str]: ... + def __getitem__(self, key: str): ... + def __setitem__(self, key: str, value) -> None: ... + def __delitem__(self, key: str) -> None: ... + def get(self, key: str, default=None): ... + def items(self) -> ItemsView[str, Incomplete]: ... + def keys(self) -> KeysView[str]: ... + def values(self) -> ValuesView[Incomplete]: ... + def __reduce__(self) -> tuple[Callable[..., Self], tuple[type[Self], dict[Incomplete, Incomplete]]]: ... + def __call__(self, **kwargs) -> Self: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + ) -> None: ... class NetworkXConfig(Config): backend_priority: list[str] diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi index b87ff7572956..f925c63d1b8b 100644 --- a/stubs/networkx/networkx/utils/misc.pyi +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -1,6 +1,7 @@ import random +import sys from types import ModuleType -from typing import TypeAlias +from typing_extensions import Self, TypeAlias import numpy from networkx.classes.graph import Graph, _Node @@ -37,6 +38,10 @@ def create_random_state(random_state=None): ... class PythonRandomViaNumpyBits(random.Random): def __init__(self, rng: numpy.random.Generator | None = None) -> None: ... + if sys.version_info < (3, 10): + # this is a workaround for pyright correctly flagging an inconsistent inherited constructor, see #14624 + def __new__(cls, rng: numpy.random.Generator | None = None) -> Self: ... + def getrandbits(self, k: int) -> int: ... class PythonRandomInterface: diff --git a/stubs/oauthlib/oauthlib/common.pyi b/stubs/oauthlib/oauthlib/common.pyi index 73cb190cadbd..15112d51863c 100644 --- a/stubs/oauthlib/oauthlib/common.pyi +++ b/stubs/oauthlib/oauthlib/common.pyi @@ -2,7 +2,8 @@ import re from _typeshed import Incomplete, SupportsLenAndGetItem from collections.abc import Iterable, Mapping from logging import Logger -from typing import Any, Final, Literal, TypeAlias, TypeVar, overload +from typing import Any, Final, Literal, TypeVar, overload +from typing_extensions import TypeAlias _T = TypeVar("_T") _V = TypeVar("_V") diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/base.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/base.pyi index aa5cf71e7aa0..2d3a88dbd3e0 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/base.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/base.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToInt, Incomplete from collections.abc import Callable -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias from oauthlib.common import _HTTPMethod from oauthlib.oauth2.rfc6749.tokens import OAuth2Token diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/grant_types/base.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/grant_types/base.pyi index ec02b7862aba..f8f35c9827fd 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/grant_types/base.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/grant_types/base.pyi @@ -2,7 +2,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable from itertools import chain from logging import Logger -from typing import TypeAlias, TypeVar +from typing import TypeVar +from typing_extensions import TypeAlias from oauthlib.common import Request diff --git a/stubs/objgraph/objgraph.pyi b/stubs/objgraph/objgraph.pyi index 8278461c3fde..427c6e405126 100644 --- a/stubs/objgraph/objgraph.pyi +++ b/stubs/objgraph/objgraph.pyi @@ -2,7 +2,8 @@ from _typeshed import Incomplete, SupportsWrite from collections import defaultdict from collections.abc import Callable, Container, Iterable from types import ModuleType -from typing import Final, Literal, TypeAlias, TypeGuard +from typing import Final, Literal +from typing_extensions import TypeAlias, TypeGuard IS_INTERACTIVE: bool diff --git a/stubs/olefile/olefile/olefile.pyi b/stubs/olefile/olefile/olefile.pyi index 3790921224bb..bc7d74306ae4 100644 --- a/stubs/olefile/olefile/olefile.pyi +++ b/stubs/olefile/olefile/olefile.pyi @@ -4,8 +4,8 @@ import io import logging import traceback from collections.abc import Sequence -from typing import IO, AnyStr, Generic, TypeAlias -from typing_extensions import Self +from typing import IO, AnyStr, Generic +from typing_extensions import Self, TypeAlias __date__: str __version__: str diff --git a/stubs/openpyxl/openpyxl/__init__.pyi b/stubs/openpyxl/openpyxl/__init__.pyi index 13e79c8bdc1d..627a7afc5720 100644 --- a/stubs/openpyxl/openpyxl/__init__.pyi +++ b/stubs/openpyxl/openpyxl/__init__.pyi @@ -1,5 +1,6 @@ from _typeshed import StrPath, SupportsRead, SupportsWrite -from typing import IO, Literal, Protocol, TypeAlias, type_check_only +from typing import IO, Literal, Protocol, type_check_only +from typing_extensions import TypeAlias from openpyxl.compat.numbers import NUMPY as NUMPY from openpyxl.reader.excel import load_workbook as load_workbook diff --git a/stubs/openpyxl/openpyxl/cell/__init__.pyi b/stubs/openpyxl/openpyxl/cell/__init__.pyi index 7bd4c41d9494..5501a28fd6eb 100644 --- a/stubs/openpyxl/openpyxl/cell/__init__.pyi +++ b/stubs/openpyxl/openpyxl/cell/__init__.pyi @@ -1,6 +1,7 @@ from datetime import date, datetime, time, timedelta from decimal import Decimal -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from openpyxl.cell.rich_text import CellRichText from openpyxl.worksheet.formula import ArrayFormula, DataTableFormula diff --git a/stubs/openpyxl/openpyxl/cell/text.pyi b/stubs/openpyxl/openpyxl/cell/text.pyi index 178fc1611059..1a81339267a3 100644 --- a/stubs/openpyxl/openpyxl/cell/text.pyi +++ b/stubs/openpyxl/openpyxl/cell/text.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Integer, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.nested import NestedString, NestedText, _NestedNoneSetParam diff --git a/stubs/openpyxl/openpyxl/chart/_chart.pyi b/stubs/openpyxl/openpyxl/chart/_chart.pyi index 61e472151af8..0c7220617894 100644 --- a/stubs/openpyxl/openpyxl/chart/_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/_chart.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.layout import Layout from openpyxl.chart.legend import Legend diff --git a/stubs/openpyxl/openpyxl/chart/area_chart.pyi b/stubs/openpyxl/openpyxl/chart/area_chart.pyi index 25c1336a323a..2d80d765ccff 100644 --- a/stubs/openpyxl/openpyxl/chart/area_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/area_chart.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, SeriesAxis, TextAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/axis.pyi b/stubs/openpyxl/openpyxl/chart/axis.pyi index 45292f690c93..068ac588da0d 100644 --- a/stubs/openpyxl/openpyxl/chart/axis.pyi +++ b/stubs/openpyxl/openpyxl/chart/axis.pyi @@ -1,6 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias, overload -from typing_extensions import Self +from typing import ClassVar, Literal, overload +from typing_extensions import Self, TypeAlias from openpyxl.chart.layout import Layout from openpyxl.chart.shapes import GraphicalProperties diff --git a/stubs/openpyxl/openpyxl/chart/bar_chart.pyi b/stubs/openpyxl/openpyxl/chart/bar_chart.pyi index eecafc725838..c5326c40e3cd 100644 --- a/stubs/openpyxl/openpyxl/chart/bar_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/bar_chart.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, SeriesAxis, TextAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi b/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi index d9e1cd4dc4f8..a6585ddd213e 100644 --- a/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.axis import NumericAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/chartspace.pyi b/stubs/openpyxl/openpyxl/chart/chartspace.pyi index 6effdd86a89f..fef551ba034b 100644 --- a/stubs/openpyxl/openpyxl/chart/chartspace.pyi +++ b/stubs/openpyxl/openpyxl/chart/chartspace.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.chart._3d import Surface, View3D from openpyxl.chart.legend import Legend diff --git a/stubs/openpyxl/openpyxl/chart/error_bar.pyi b/stubs/openpyxl/openpyxl/chart/error_bar.pyi index f39d64fa107f..4eb20316a98e 100644 --- a/stubs/openpyxl/openpyxl/chart/error_bar.pyi +++ b/stubs/openpyxl/openpyxl/chart/error_bar.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.data_source import NumDataSource from openpyxl.chart.shapes import GraphicalProperties diff --git a/stubs/openpyxl/openpyxl/chart/label.pyi b/stubs/openpyxl/openpyxl/chart/label.pyi index 4c3fe53b3320..a5b11f8b4f45 100644 --- a/stubs/openpyxl/openpyxl/chart/label.pyi +++ b/stubs/openpyxl/openpyxl/chart/label.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.text import RichText diff --git a/stubs/openpyxl/openpyxl/chart/layout.pyi b/stubs/openpyxl/openpyxl/chart/layout.pyi index dde22b10a1d7..92cd7dd2b317 100644 --- a/stubs/openpyxl/openpyxl/chart/layout.pyi +++ b/stubs/openpyxl/openpyxl/chart/layout.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Typed from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/chart/legend.pyi b/stubs/openpyxl/openpyxl/chart/legend.pyi index ba5fc7d3aa82..341e60026289 100644 --- a/stubs/openpyxl/openpyxl/chart/legend.pyi +++ b/stubs/openpyxl/openpyxl/chart/legend.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.layout import Layout from openpyxl.chart.shapes import GraphicalProperties diff --git a/stubs/openpyxl/openpyxl/chart/line_chart.pyi b/stubs/openpyxl/openpyxl/chart/line_chart.pyi index 4bcdc2abd5c8..e03d6c35a397 100644 --- a/stubs/openpyxl/openpyxl/chart/line_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/line_chart.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, _BaseAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/marker.pyi b/stubs/openpyxl/openpyxl/chart/marker.pyi index bd526ee90985..2b13a32b17dc 100644 --- a/stubs/openpyxl/openpyxl/chart/marker.pyi +++ b/stubs/openpyxl/openpyxl/chart/marker.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.picture import PictureOptions from openpyxl.chart.shapes import GraphicalProperties diff --git a/stubs/openpyxl/openpyxl/chart/picture.pyi b/stubs/openpyxl/openpyxl/chart/picture.pyi index ee14ab6f85cd..d82a9022eb29 100644 --- a/stubs/openpyxl/openpyxl/chart/picture.pyi +++ b/stubs/openpyxl/openpyxl/chart/picture.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import _ConvertibleToBool from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedNoneSet, _NestedNoneSetParam diff --git a/stubs/openpyxl/openpyxl/chart/pie_chart.pyi b/stubs/openpyxl/openpyxl/chart/pie_chart.pyi index c43e6f1dafe6..f6e1d1fc6f3e 100644 --- a/stubs/openpyxl/openpyxl/chart/pie_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/pie_chart.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.axis import ChartLines from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/radar_chart.pyi b/stubs/openpyxl/openpyxl/chart/radar_chart.pyi index bf5cc4ca66ac..c5b8fced041a 100644 --- a/stubs/openpyxl/openpyxl/chart/radar_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/radar_chart.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.axis import NumericAxis, TextAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi b/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi index 787e5c5e66c5..03e0ae289ca3 100644 --- a/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.axis import NumericAxis, TextAxis from openpyxl.chart.label import DataLabelList diff --git a/stubs/openpyxl/openpyxl/chart/series.pyi b/stubs/openpyxl/openpyxl/chart/series.pyi index 7feb904e0961..3cad7ed07012 100644 --- a/stubs/openpyxl/openpyxl/chart/series.pyi +++ b/stubs/openpyxl/openpyxl/chart/series.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.data_source import AxDataSource, NumDataSource, StrRef from openpyxl.chart.error_bar import ErrorBars diff --git a/stubs/openpyxl/openpyxl/chart/shapes.pyi b/stubs/openpyxl/openpyxl/chart/shapes.pyi index d2758e4b2cc8..c285bbe921a0 100644 --- a/stubs/openpyxl/openpyxl/chart/shapes.pyi +++ b/stubs/openpyxl/openpyxl/chart/shapes.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.nested import EmptyTag diff --git a/stubs/openpyxl/openpyxl/chart/trendline.pyi b/stubs/openpyxl/openpyxl/chart/trendline.pyi index 9b93515b49b0..e76da34ef402 100644 --- a/stubs/openpyxl/openpyxl/chart/trendline.pyi +++ b/stubs/openpyxl/openpyxl/chart/trendline.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.chart.data_source import NumFmt from openpyxl.chart.layout import Layout diff --git a/stubs/openpyxl/openpyxl/chartsheet/publish.pyi b/stubs/openpyxl/openpyxl/chartsheet/publish.pyi index 94a0fba4d4b7..56780bc5ca04 100644 --- a/stubs/openpyxl/openpyxl/chartsheet/publish.pyi +++ b/stubs/openpyxl/openpyxl/chartsheet/publish.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, Integer, Set, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi b/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi index efda9069f61f..51799b51ce1f 100644 --- a/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi +++ b/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused from collections.abc import Generator -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.cell import _CellOrMergedCell from openpyxl.cell.text import Text diff --git a/stubs/openpyxl/openpyxl/comments/shape_writer.pyi b/stubs/openpyxl/openpyxl/comments/shape_writer.pyi index b908498d47a5..22ac968ef82c 100644 --- a/stubs/openpyxl/openpyxl/comments/shape_writer.pyi +++ b/stubs/openpyxl/openpyxl/comments/shape_writer.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from ..xml._functions_overloads import _lxml_Element, _ParentElement diff --git a/stubs/openpyxl/openpyxl/compat/numbers.pyi b/stubs/openpyxl/openpyxl/compat/numbers.pyi index 060ba461585a..7db010ddb060 100644 --- a/stubs/openpyxl/openpyxl/compat/numbers.pyi +++ b/stubs/openpyxl/openpyxl/compat/numbers.pyi @@ -1,5 +1,6 @@ from decimal import Decimal -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias # NOTE: Can't specify numpy as a dependency because openpyxl doesn't declare it as one # import numpy diff --git a/stubs/openpyxl/openpyxl/descriptors/base.pyi b/stubs/openpyxl/openpyxl/descriptors/base.pyi index e85095f8f2a7..e7f9515bfcd5 100644 --- a/stubs/openpyxl/openpyxl/descriptors/base.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/base.pyi @@ -2,7 +2,8 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Readable from collections.abc import Iterable, Sized from datetime import datetime from re import Pattern -from typing import Any, Generic, Literal, TypeAlias, TypeVar, overload +from typing import Any, Generic, Literal, TypeVar, overload +from typing_extensions import TypeAlias from openpyxl.descriptors import Strict from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/descriptors/nested.pyi b/stubs/openpyxl/openpyxl/descriptors/nested.pyi index e10e546383dc..c2424b239ca5 100644 --- a/stubs/openpyxl/openpyxl/descriptors/nested.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/nested.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Unused from collections.abc import Iterable -from typing import Any, ClassVar, Literal, NoReturn, TypeAlias, overload +from typing import Any, ClassVar, Literal, NoReturn, overload +from typing_extensions import TypeAlias from openpyxl.descriptors import Strict from openpyxl.descriptors.base import Bool, Convertible, Descriptor, Float, Integer, MinMax, NoneSet, Set, String diff --git a/stubs/openpyxl/openpyxl/drawing/colors.pyi b/stubs/openpyxl/openpyxl/drawing/colors.pyi index c73200009afd..00c6a9c5d865 100644 --- a/stubs/openpyxl/openpyxl/drawing/colors.pyi +++ b/stubs/openpyxl/openpyxl/drawing/colors.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Final, Literal, TypeAlias, overload +from typing import ClassVar, Final, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors import Strict, Typed from openpyxl.descriptors.base import Alias, Integer, MinMax, Set, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/drawing/effect.pyi b/stubs/openpyxl/openpyxl/drawing/effect.pyi index 550ef04cf892..839440db4c7e 100644 --- a/stubs/openpyxl/openpyxl/drawing/effect.pyi +++ b/stubs/openpyxl/openpyxl/drawing/effect.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, Float, Integer, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/drawing/fill.pyi b/stubs/openpyxl/openpyxl/drawing/fill.pyi index 6ee8f5964c6d..0a4a365244fd 100644 --- a/stubs/openpyxl/openpyxl/drawing/fill.pyi +++ b/stubs/openpyxl/openpyxl/drawing/fill.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Bool, Integer, MinMax, NoneSet, Set, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/drawing/geometry.pyi b/stubs/openpyxl/openpyxl/drawing/geometry.pyi index adf70df8d996..4e2241e94ebd 100644 --- a/stubs/openpyxl/openpyxl/drawing/geometry.pyi +++ b/stubs/openpyxl/openpyxl/drawing/geometry.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Bool, Float, Integer, MinMax, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import Coordinate, ExtensionList, Percentage diff --git a/stubs/openpyxl/openpyxl/drawing/image.pyi b/stubs/openpyxl/openpyxl/drawing/image.pyi index c3a35a1384b4..645600adf025 100644 --- a/stubs/openpyxl/openpyxl/drawing/image.pyi +++ b/stubs/openpyxl/openpyxl/drawing/image.pyi @@ -1,7 +1,8 @@ from _typeshed import SupportsRead from pathlib import Path from types import ModuleType -from typing import Any, Literal, TypeAlias +from typing import Any, Literal +from typing_extensions import TypeAlias from openpyxl.drawing.spreadsheet_drawing import _AnchorBase diff --git a/stubs/openpyxl/openpyxl/drawing/line.pyi b/stubs/openpyxl/openpyxl/drawing/line.pyi index 209d8165ea15..130895608758 100644 --- a/stubs/openpyxl/openpyxl/drawing/line.pyi +++ b/stubs/openpyxl/openpyxl/drawing/line.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Integer, MinMax, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/drawing/properties.pyi b/stubs/openpyxl/openpyxl/drawing/properties.pyi index f95685c72325..0444a5321293 100644 --- a/stubs/openpyxl/openpyxl/drawing/properties.pyi +++ b/stubs/openpyxl/openpyxl/drawing/properties.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, NoneSet, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi b/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi index f675b423b091..df2388c58f95 100644 --- a/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi +++ b/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Bool, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.nested import NestedText diff --git a/stubs/openpyxl/openpyxl/drawing/text.pyi b/stubs/openpyxl/openpyxl/drawing/text.pyi index 3ead43febde6..b5ed491d7cc4 100644 --- a/stubs/openpyxl/openpyxl/drawing/text.pyi +++ b/stubs/openpyxl/openpyxl/drawing/text.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Bool, Integer, MinMax, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import Coordinate, ExtensionList diff --git a/stubs/openpyxl/openpyxl/formatting/rule.pyi b/stubs/openpyxl/openpyxl/formatting/rule.pyi index f74d9536a760..cd5efaae934d 100644 --- a/stubs/openpyxl/openpyxl/formatting/rule.pyi +++ b/stubs/openpyxl/openpyxl/formatting/rule.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors import Float, Strict from openpyxl.descriptors.base import Bool, Integer, NoneSet, Set, String, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/formula/tokenizer.pyi b/stubs/openpyxl/openpyxl/formula/tokenizer.pyi index f7b2e270b690..f37992ae87a6 100644 --- a/stubs/openpyxl/openpyxl/formula/tokenizer.pyi +++ b/stubs/openpyxl/openpyxl/formula/tokenizer.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from re import Pattern -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias _TokenTypesNotOperand: TypeAlias = Literal[ "LITERAL", "FUNC", "ARRAY", "PAREN", "SEP", "OPERATOR-PREFIX", "OPERATOR-INFIX", "OPERATOR-POSTFIX", "WHITE-SPACE" diff --git a/stubs/openpyxl/openpyxl/packaging/custom.pyi b/stubs/openpyxl/openpyxl/packaging/custom.pyi index 8721ae124986..ec95af53f5b9 100644 --- a/stubs/openpyxl/openpyxl/packaging/custom.pyi +++ b/stubs/openpyxl/openpyxl/packaging/custom.pyi @@ -1,8 +1,8 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete from collections.abc import Iterator from datetime import datetime -from typing import Any, Final, Generic, Literal, TypeAlias, TypeVar -from typing_extensions import Self +from typing import Any, Final, Generic, Literal, TypeVar +from typing_extensions import Self, TypeAlias from openpyxl.descriptors import Sequence, Strict from openpyxl.descriptors.base import Bool, DateTime, Float, Integer, String, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/packaging/workbook.pyi b/stubs/openpyxl/openpyxl/packaging/workbook.pyi index 5eeb46b36fea..3734b75e9932 100644 --- a/stubs/openpyxl/openpyxl/packaging/workbook.pyi +++ b/stubs/openpyxl/openpyxl/packaging/workbook.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl import _VisibilityType from openpyxl.descriptors.base import Alias, Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/pivot/cache.pyi b/stubs/openpyxl/openpyxl/pivot/cache.pyi index 47a0578ab695..d156091b67a9 100644 --- a/stubs/openpyxl/openpyxl/pivot/cache.pyi +++ b/stubs/openpyxl/openpyxl/pivot/cache.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused from datetime import datetime -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, DateTime, Float, Integer, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/pivot/table.pyi b/stubs/openpyxl/openpyxl/pivot/table.pyi index 8082827be382..c90e97612c17 100644 --- a/stubs/openpyxl/openpyxl/pivot/table.pyi +++ b/stubs/openpyxl/openpyxl/pivot/table.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, Integer, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/reader/excel.pyi b/stubs/openpyxl/openpyxl/reader/excel.pyi index da45a60724e6..8c5472928e20 100644 --- a/stubs/openpyxl/openpyxl/reader/excel.pyi +++ b/stubs/openpyxl/openpyxl/reader/excel.pyi @@ -1,4 +1,5 @@ -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias from zipfile import ZipFile from openpyxl import _ZipFileFileProtocol diff --git a/stubs/openpyxl/openpyxl/styles/alignment.pyi b/stubs/openpyxl/openpyxl/styles/alignment.pyi index 40f69c4e46cd..f6ec12d50bf3 100644 --- a/stubs/openpyxl/openpyxl/styles/alignment.pyi +++ b/stubs/openpyxl/openpyxl/styles/alignment.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToFloat from collections.abc import Iterator -from typing import ClassVar, Final, Literal, TypeAlias +from typing import ClassVar, Final, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Bool, Min, MinMax, NoneSet, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/styles/borders.pyi b/stubs/openpyxl/openpyxl/styles/borders.pyi index 099ce57e7446..4c75f3e5ca25 100644 --- a/stubs/openpyxl/openpyxl/styles/borders.pyi +++ b/stubs/openpyxl/openpyxl/styles/borders.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterator -from typing import ClassVar, Final, Literal, TypeAlias +from typing import ClassVar, Final, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Alias, Bool, NoneSet, Typed, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/styles/fills.pyi b/stubs/openpyxl/openpyxl/styles/fills.pyi index 498f9d1a7c15..85be254a903d 100644 --- a/stubs/openpyxl/openpyxl/styles/fills.pyi +++ b/stubs/openpyxl/openpyxl/styles/fills.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToFloat, Incomplete, Unused from collections.abc import Iterable, Iterator, Sequence as ABCSequence -from typing import ClassVar, Final, Literal, TypeAlias +from typing import ClassVar, Final, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors import Sequence, Strict from openpyxl.descriptors.base import Alias, Float, MinMax, NoneSet, Set diff --git a/stubs/openpyxl/openpyxl/styles/fonts.pyi b/stubs/openpyxl/openpyxl/styles/fonts.pyi index 48aeeb27d9b3..91ec30035922 100644 --- a/stubs/openpyxl/openpyxl/styles/fonts.pyi +++ b/stubs/openpyxl/openpyxl/styles/fonts.pyi @@ -1,6 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt -from typing import ClassVar, Final, Literal, TypeAlias -from typing_extensions import Self +from typing import ClassVar, Final, Literal +from typing_extensions import Self, TypeAlias from openpyxl.descriptors.base import Alias, _ConvertibleToBool from openpyxl.descriptors.nested import ( diff --git a/stubs/openpyxl/openpyxl/styles/numbers.pyi b/stubs/openpyxl/openpyxl/styles/numbers.pyi index 92a6ee263689..56ded3062828 100644 --- a/stubs/openpyxl/openpyxl/styles/numbers.pyi +++ b/stubs/openpyxl/openpyxl/styles/numbers.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused from re import Pattern -from typing import ClassVar, Final, Literal, SupportsIndex, TypeGuard, overload +from typing import ClassVar, Final, Literal, SupportsIndex, overload +from typing_extensions import TypeGuard from openpyxl.descriptors import Strict, String from openpyxl.descriptors.base import Integer diff --git a/stubs/openpyxl/openpyxl/styles/table.pyi b/stubs/openpyxl/openpyxl/styles/table.pyi index 03e629854e3c..889b12ea4da3 100644 --- a/stubs/openpyxl/openpyxl/styles/table.pyi +++ b/stubs/openpyxl/openpyxl/styles/table.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, Integer, Set, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/utils/cell.pyi b/stubs/openpyxl/openpyxl/utils/cell.pyi index 1c108f435d94..22a05774e7fc 100644 --- a/stubs/openpyxl/openpyxl/utils/cell.pyi +++ b/stubs/openpyxl/openpyxl/utils/cell.pyi @@ -1,6 +1,7 @@ from collections.abc import Generator from re import Pattern -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias # "1:1" | "A1:A1" | "A:A" _RangeBoundariesTuple: TypeAlias = tuple[None, int, None, int] | tuple[int, int, int, int] | tuple[int, None, int, None] diff --git a/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi b/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi index 32cbcbd7371e..7e0e72060e2d 100644 --- a/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi +++ b/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from zipfile import ZipFile from openpyxl.descriptors.base import Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/workbook/properties.pyi b/stubs/openpyxl/openpyxl/workbook/properties.pyi index 145df27bd4b5..f95fd2be4505 100644 --- a/stubs/openpyxl/openpyxl/workbook/properties.pyi +++ b/stubs/openpyxl/openpyxl/workbook/properties.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, Float, Integer, NoneSet, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/workbook/smart_tags.pyi b/stubs/openpyxl/openpyxl/workbook/smart_tags.pyi index 6f0baf5e448d..f6ae41ad7030 100644 --- a/stubs/openpyxl/openpyxl/workbook/smart_tags.pyi +++ b/stubs/openpyxl/openpyxl/workbook/smart_tags.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, NoneSet, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/workbook/views.pyi b/stubs/openpyxl/openpyxl/workbook/views.pyi index cd876c04952e..9c0abeb8872f 100644 --- a/stubs/openpyxl/openpyxl/workbook/views.pyi +++ b/stubs/openpyxl/openpyxl/workbook/views.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl import _VisibilityType from openpyxl.descriptors.base import Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/workbook/web.pyi b/stubs/openpyxl/openpyxl/workbook/web.pyi index 21fcb87987c9..a83615353cd8 100644 --- a/stubs/openpyxl/openpyxl/workbook/web.pyi +++ b/stubs/openpyxl/openpyxl/workbook/web.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, Integer, NoneSet, String, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/workbook/workbook.pyi b/stubs/openpyxl/openpyxl/workbook/workbook.pyi index 402b82f4d0ed..f93f634796d5 100644 --- a/stubs/openpyxl/openpyxl/workbook/workbook.pyi +++ b/stubs/openpyxl/openpyxl/workbook/workbook.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, Unused from collections.abc import Iterator from datetime import datetime -from typing import Any, Final, TypeAlias, type_check_only -from typing_extensions import deprecated +from typing import Any, Final, type_check_only +from typing_extensions import TypeAlias, deprecated from zipfile import ZipFile from openpyxl import _Decodable, _ZipFileFileWriteProtocol diff --git a/stubs/openpyxl/openpyxl/worksheet/_writer.pyi b/stubs/openpyxl/openpyxl/worksheet/_writer.pyi index 329d15fc4b26..92ca8dc7b9a6 100644 --- a/stubs/openpyxl/openpyxl/worksheet/_writer.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/_writer.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete, ReadableBuffer, StrPath, Unused from collections.abc import Generator, Iterable -from typing import Protocol, TypeAlias, type_check_only +from typing import Protocol, type_check_only +from typing_extensions import TypeAlias from openpyxl.cell import _CellOrMergedCell from openpyxl.worksheet._write_only import WriteOnlyWorksheet diff --git a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi index 500a40aee250..d1f955ab2ad9 100644 --- a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, Protocol, TypeAlias, type_check_only +from typing import ClassVar, Literal, Protocol, type_check_only +from typing_extensions import TypeAlias from openpyxl.descriptors.base import ( Alias, diff --git a/stubs/openpyxl/openpyxl/worksheet/filters.pyi b/stubs/openpyxl/openpyxl/worksheet/filters.pyi index 120a8b4f6a3a..530321e49d0e 100644 --- a/stubs/openpyxl/openpyxl/worksheet/filters.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/filters.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused from datetime import datetime -from typing import ClassVar, Final, Literal, TypeAlias, overload +from typing import ClassVar, Final, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import ( Alias, diff --git a/stubs/openpyxl/openpyxl/worksheet/ole.pyi b/stubs/openpyxl/openpyxl/worksheet/ole.pyi index 08749e9e3435..2b8d68e78de2 100644 --- a/stubs/openpyxl/openpyxl/worksheet/ole.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/ole.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, TypeAlias, overload +from typing import ClassVar, Literal, overload +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, Integer, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable diff --git a/stubs/openpyxl/openpyxl/worksheet/page.pyi b/stubs/openpyxl/openpyxl/worksheet/page.pyi index 843caa742464..d4c75ea6b259 100644 --- a/stubs/openpyxl/openpyxl/worksheet/page.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/page.pyi @@ -1,6 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete -from typing import ClassVar, Literal, TypeAlias -from typing_extensions import Self +from typing import ClassVar, Literal +from typing_extensions import Self, TypeAlias from openpyxl.descriptors.base import Bool, Float, Integer, NoneSet, _ConvertibleToBool from openpyxl.descriptors.serialisable import Serialisable, _ChildSerialisableTreeElement diff --git a/stubs/openpyxl/openpyxl/worksheet/table.pyi b/stubs/openpyxl/openpyxl/worksheet/table.pyi index 0ab3d5052796..8650bbadec1d 100644 --- a/stubs/openpyxl/openpyxl/worksheet/table.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/table.pyi @@ -1,7 +1,7 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused from collections.abc import Iterator -from typing import ClassVar, Final, Literal, TypeAlias, overload -from typing_extensions import Self +from typing import ClassVar, Final, Literal, overload +from typing_extensions import Self, TypeAlias from openpyxl.descriptors import Strict, String from openpyxl.descriptors.base import Alias, Bool, Integer, NoneSet, Typed, _ConvertibleToBool diff --git a/stubs/openpyxl/openpyxl/worksheet/views.pyi b/stubs/openpyxl/openpyxl/worksheet/views.pyi index 70e6420988fd..72f05ffe0844 100644 --- a/stubs/openpyxl/openpyxl/worksheet/views.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/views.pyi @@ -1,5 +1,6 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, Unused -from typing import ClassVar, Literal, TypeAlias +from typing import ClassVar, Literal +from typing_extensions import TypeAlias from openpyxl.descriptors.base import Bool, Float, Integer, NoneSet, Set, String, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList diff --git a/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi b/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi index c08ed1526970..cbdac51f363c 100644 --- a/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi +++ b/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi @@ -2,7 +2,8 @@ from _typeshed import Incomplete, ReadableBuffer from collections.abc import Iterable, Iterator, Mapping, Sequence -from typing import Any, Protocol, TypeAlias, TypeVar, overload +from typing import Any, Protocol, TypeVar, overload +from typing_extensions import TypeAlias from xml.etree.ElementTree import Element, ElementTree, QName, XMLParser, _FileRead from openpyxl.chart.axis import ChartLines diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index cdebe0df4c5e..46e65a286538 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable from threading import Event -from typing import TypeAlias +from typing_extensions import TypeAlias from paramiko.message import Message from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/message.pyi b/stubs/paramiko/paramiko/message.pyi index 88bed87b56a7..ef87f97b4eb2 100644 --- a/stubs/paramiko/paramiko/message.pyi +++ b/stubs/paramiko/paramiko/message.pyi @@ -1,7 +1,8 @@ from _typeshed import ReadableBuffer from collections.abc import Iterable from io import BytesIO -from typing import Any, Protocol, TypeAlias, type_check_only +from typing import Any, Protocol, type_check_only +from typing_extensions import TypeAlias @type_check_only class _SupportsAsBytes(Protocol): diff --git a/stubs/paramiko/paramiko/sftp_client.pyi b/stubs/paramiko/paramiko/sftp_client.pyi index f0bc69af6290..ae59ad2ecb2b 100644 --- a/stubs/paramiko/paramiko/sftp_client.pyi +++ b/stubs/paramiko/paramiko/sftp_client.pyi @@ -1,8 +1,8 @@ from _typeshed import StrOrBytesPath from collections.abc import Callable, Iterator from logging import Logger -from typing import IO, TypeAlias -from typing_extensions import Self +from typing import IO +from typing_extensions import Self, TypeAlias from paramiko.channel import Channel from paramiko.sftp import BaseSFTP diff --git a/stubs/paramiko/paramiko/transport.pyi b/stubs/paramiko/paramiko/transport.pyi index 1cb5214789db..6b2f2df1c279 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -4,7 +4,8 @@ from logging import Logger from socket import socket from threading import Condition, Event, Lock, Thread from types import ModuleType -from typing import Any, Protocol, TypeAlias, type_check_only +from typing import Any, Protocol, type_check_only +from typing_extensions import TypeAlias from paramiko.auth_handler import AuthHandler, AuthOnlyHandler, _InteractiveCallback from paramiko.channel import Channel diff --git a/stubs/paramiko/paramiko/win_pageant.pyi b/stubs/paramiko/paramiko/win_pageant.pyi index 1f9edee17eae..3cc870bb0719 100644 --- a/stubs/paramiko/paramiko/win_pageant.pyi +++ b/stubs/paramiko/paramiko/win_pageant.pyi @@ -1,7 +1,8 @@ import ctypes import sys from _typeshed import Incomplete -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias if sys.platform == "win32": win32con_WM_COPYDATA: int diff --git a/stubs/parsimonious/parsimonious/expressions.pyi b/stubs/parsimonious/parsimonious/expressions.pyi index 514768f57b5a..fcc6965fa442 100644 --- a/stubs/parsimonious/parsimonious/expressions.pyi +++ b/stubs/parsimonious/parsimonious/expressions.pyi @@ -1,8 +1,8 @@ import collections.abc from collections.abc import Callable, Mapping from re import Pattern -from typing import Any, TypeAlias -from typing_extensions import Self +from typing import Any +from typing_extensions import Self, TypeAlias from parsimonious.exceptions import ParseError from parsimonious.grammar import Grammar diff --git a/stubs/passlib/passlib/pwd.pyi b/stubs/passlib/passlib/pwd.pyi index 3b95af327e97..a1189c161b7d 100644 --- a/stubs/passlib/passlib/pwd.pyi +++ b/stubs/passlib/passlib/pwd.pyi @@ -1,8 +1,8 @@ import random from abc import abstractmethod from collections.abc import Callable, Iterator, MutableMapping, Sequence -from typing import Any, Final, Literal, TypeAlias, overload -from typing_extensions import Self +from typing import Any, Final, Literal, overload +from typing_extensions import Self, TypeAlias class SequenceGenerator: length: int | None diff --git a/stubs/peewee/playhouse/flask_utils.pyi b/stubs/peewee/playhouse/flask_utils.pyi index a774c4eaa2fc..78c9ce62776e 100644 --- a/stubs/peewee/playhouse/flask_utils.pyi +++ b/stubs/peewee/playhouse/flask_utils.pyi @@ -1,6 +1,7 @@ from _typeshed import Unused from collections.abc import Container -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from peewee import Database, ModelBase, Proxy diff --git a/stubs/pexpect/pexpect/spawnbase.pyi b/stubs/pexpect/pexpect/spawnbase.pyi index fc29f065d504..116fe3b5f7f1 100644 --- a/stubs/pexpect/pexpect/spawnbase.pyi +++ b/stubs/pexpect/pexpect/spawnbase.pyi @@ -1,7 +1,8 @@ from asyncio import ReadTransport from collections.abc import Awaitable, Callable, Iterable from re import Match, Pattern -from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, TypeAlias, overload, type_check_only +from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, overload, type_check_only +from typing_extensions import TypeAlias from ._async import PatternWaiter from .exceptions import EOF, TIMEOUT diff --git a/stubs/pika/pika/compat.pyi b/stubs/pika/pika/compat.pyi index 92494ec7f3f0..6d3d68be080f 100644 --- a/stubs/pika/pika/compat.pyi +++ b/stubs/pika/pika/compat.pyi @@ -2,7 +2,8 @@ from abc import ABCMeta from collections.abc import ItemsView, Mapping, ValuesView from io import StringIO as StringIO from re import Pattern -from typing import Any, Final, SupportsIndex, TypeGuard, TypeVar +from typing import Any, Final, SupportsIndex, TypeVar +from typing_extensions import TypeGuard from urllib.parse import parse_qs, quote, unquote, urlencode as urlencode, urlparse as urlparse _KT = TypeVar("_KT") diff --git a/stubs/pika/pika/data.pyi b/stubs/pika/pika/data.pyi index 3e3b289c22a4..c32cde389957 100644 --- a/stubs/pika/pika/data.pyi +++ b/stubs/pika/pika/data.pyi @@ -1,7 +1,7 @@ from collections.abc import Mapping from datetime import datetime from decimal import Decimal -from typing import TypeAlias +from typing_extensions import TypeAlias _Value: TypeAlias = str | bytes | bool | int | Decimal | datetime | _ArgumentMapping | list[_Value] | None _ArgumentMapping: TypeAlias = Mapping[str, _Value] diff --git a/stubs/pika/pika/spec.pyi b/stubs/pika/pika/spec.pyi index ef1d13c3a69f..05fd5e8dcaa0 100644 --- a/stubs/pika/pika/spec.pyi +++ b/stubs/pika/pika/spec.pyi @@ -3,8 +3,8 @@ from _typeshed import Incomplete from collections.abc import Mapping from datetime import datetime from decimal import Decimal -from typing import ClassVar, Final, Literal, TypeAlias -from typing_extensions import Self +from typing import ClassVar, Final, Literal +from typing_extensions import Self, TypeAlias from pika.amqp_object import Class, Method, Properties from pika.delivery_mode import DeliveryMode diff --git a/stubs/pony/pony/__init__.pyi b/stubs/pony/pony/__init__.pyi index 3a6a1123886a..0bcdbcbd0c60 100644 --- a/stubs/pony/pony/__init__.pyi +++ b/stubs/pony/pony/__init__.pyi @@ -1,4 +1,5 @@ -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias _Mode: TypeAlias = Literal[ "GAE-LOCAL", "GAE-SERVER", "MOD_WSGI", "INTERACTIVE", "FCGI-FLUP", "UWSGI", "FLASK", "CHERRYPY", "BOTTLE", "UNKNOWN" diff --git a/stubs/pony/pony/orm/core.pyi b/stubs/pony/pony/orm/core.pyi index 5bee204805bc..87c311910ab5 100644 --- a/stubs/pony/pony/orm/core.pyi +++ b/stubs/pony/pony/orm/core.pyi @@ -6,8 +6,8 @@ from _typeshed import Incomplete from collections import defaultdict from collections.abc import Callable, Generator from logging import Logger -from typing import Literal, NoReturn, TypeAlias, TypeVar -from typing_extensions import Self, deprecated +from typing import Literal, NoReturn, TypeVar +from typing_extensions import Self, TypeAlias, deprecated import pony as pony from pony.orm.asttranslation import TranslationError as TranslationError diff --git a/stubs/pony/pony/orm/sqlbuilding.pyi b/stubs/pony/pony/orm/sqlbuilding.pyi index e123d2be9993..abfe2f849511 100644 --- a/stubs/pony/pony/orm/sqlbuilding.pyi +++ b/stubs/pony/pony/orm/sqlbuilding.pyi @@ -1,3 +1,4 @@ +import sys import types from _typeshed import Incomplete from collections.abc import Iterable @@ -142,8 +143,13 @@ class SQLBuilder: def RANDOM(builder): ... def RAWSQL(builder, sql): ... def build_json_path(builder, path): ... - @classmethod - def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ... + if sys.version_info >= (3, 10): + @classmethod + def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ... + else: + @classmethod + def eval_json_path(cls, values: Iterable[int | str | type | slice]) -> str: ... + def JSON_QUERY(builder, expr, path) -> None: ... def JSON_VALUE(builder, expr, path, type) -> None: ... def JSON_NONZERO(builder, expr) -> None: ... diff --git a/stubs/portpicker/portpicker.pyi b/stubs/portpicker/portpicker.pyi index 9162cfa9874a..cac293cbcf52 100644 --- a/stubs/portpicker/portpicker.pyi +++ b/stubs/portpicker/portpicker.pyi @@ -1,5 +1,5 @@ import socket -from typing import TypeAlias +from typing_extensions import TypeAlias _Port: TypeAlias = int diff --git a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi index c392f1f37dbf..a6f744c26074 100644 --- a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi +++ b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi @@ -17,8 +17,8 @@ flag "--${NAME}_out" is passed to protoc. import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.descriptor_pb2 @@ -26,6 +26,11 @@ import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index 69f1c2382d0b..d1150c0618d1 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -12,14 +12,19 @@ without any other information (e.g. without reading its imports). import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Edition: diff --git a/stubs/protobuf/google/protobuf/internal/decoder.pyi b/stubs/protobuf/google/protobuf/internal/decoder.pyi index 9024cd2f383d..94ed7f615360 100644 --- a/stubs/protobuf/google/protobuf/internal/decoder.pyi +++ b/stubs/protobuf/google/protobuf/internal/decoder.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from google.protobuf.descriptor import Descriptor, FieldDescriptor from google.protobuf.message import Message diff --git a/stubs/protobuf/google/protobuf/internal/encoder.pyi b/stubs/protobuf/google/protobuf/internal/encoder.pyi index a4473fb49919..278478edb3ed 100644 --- a/stubs/protobuf/google/protobuf/internal/encoder.pyi +++ b/stubs/protobuf/google/protobuf/internal/encoder.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import TypeAlias +from typing_extensions import TypeAlias from google.protobuf.descriptor import FieldDescriptor diff --git a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi index 957e30b9d301..6527d3f6978e 100644 --- a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +++ b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete, SupportsItems from collections.abc import Iterable, Iterator, KeysView, Mapping, Sequence from datetime import datetime, timedelta, tzinfo -from typing import Any as tAny, TypeAlias +from typing import Any as tAny +from typing_extensions import TypeAlias from google.protobuf import struct_pb2 diff --git a/stubs/protobuf/google/protobuf/struct_pb2.pyi b/stubs/protobuf/google/protobuf/struct_pb2.pyi index 1308b9475726..8e63dabfc2f1 100644 --- a/stubs/protobuf/google/protobuf/struct_pb2.pyi +++ b/stubs/protobuf/google/protobuf/struct_pb2.pyi @@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -43,6 +43,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.internal.well_known_types import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _NullValue: diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index e2096d630600..c9a9da29a125 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -1,6 +1,7 @@ from _typeshed import SupportsWrite from collections.abc import Callable, Iterable -from typing import Any, TypeAlias, TypeVar +from typing import Any, TypeVar +from typing_extensions import TypeAlias from .descriptor import FieldDescriptor from .descriptor_pool import DescriptorPool diff --git a/stubs/protobuf/google/protobuf/type_pb2.pyi b/stubs/protobuf/google/protobuf/type_pb2.pyi index e01d65d565b2..a8a7eb07c778 100644 --- a/stubs/protobuf/google/protobuf/type_pb2.pyi +++ b/stubs/protobuf/google/protobuf/type_pb2.pyi @@ -34,8 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -44,6 +44,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import google.protobuf.source_context_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Syntax: diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index c54581f8d668..7012bf7e8233 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -4,8 +4,8 @@ from collections.abc import Callable, Collection, Iterable, Iterator from contextlib import AbstractContextManager from subprocess import _CMD, _ENV, _FILE from types import TracebackType -from typing import Any, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import Self, deprecated +from typing import Any, Literal, Protocol, overload, type_check_only +from typing_extensions import Self, TypeAlias, deprecated from psutil._common import ( AIX as AIX, @@ -237,7 +237,7 @@ class Popen(Process): pipesize: int = -1, process_group: int | None = None, ) -> None: ... - else: + elif sys.version_info >= (3, 10): def __init__( self, args: _CMD, @@ -267,6 +267,35 @@ class Popen(Process): umask: int = -1, pipesize: int = -1, ) -> None: ... + else: + def __init__( + self, + args: _CMD, + bufsize: int = -1, + executable: StrOrBytesPath | None = None, + stdin: _FILE | None = None, + stdout: _FILE | None = None, + stderr: _FILE | None = None, + preexec_fn: Callable[[], object] | None = None, + close_fds: bool = True, + shell: bool = False, + cwd: StrOrBytesPath | None = None, + env: _ENV | None = None, + universal_newlines: bool | None = None, + startupinfo: Any | None = None, + creationflags: int = 0, + restore_signals: bool = True, + start_new_session: bool = False, + pass_fds: Collection[int] = (), + *, + text: bool | None = None, + encoding: str | None = None, + errors: str | None = None, + user: str | int | None = None, + group: str | int | None = None, + extra_groups: Iterable[str | int] | None = None, + umask: int = -1, + ) -> None: ... def __enter__(self) -> Self: ... def __exit__( diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi index aabab424befc..8899cb13f8de 100644 --- a/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -2,8 +2,8 @@ import datetime as dt from _typeshed import ConvertibleToInt, Incomplete, SupportsRead, SupportsReadline, SupportsWrite, Unused from collections.abc import Callable, Iterable, Mapping, Sequence from types import TracebackType -from typing import Any, Literal, NoReturn, Protocol, TextIO, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, disjoint_base +from typing import Any, Literal, NoReturn, Protocol, TextIO, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias, disjoint_base from psycopg2.extras import ReplicationCursor as extras_ReplicationCursor from psycopg2.sql import Composable diff --git a/stubs/pyaudio/pyaudio.pyi b/stubs/pyaudio/pyaudio.pyi index 8df1043bb36b..214688981ab6 100644 --- a/stubs/pyaudio/pyaudio.pyi +++ b/stubs/pyaudio/pyaudio.pyi @@ -1,6 +1,7 @@ import sys from collections.abc import Callable, Mapping, Sequence -from typing import ClassVar, Final, TypeAlias +from typing import ClassVar, Final +from typing_extensions import TypeAlias __docformat__: str diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index ff0741ae0dfc..2dc2f2e35ca4 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -1,6 +1,7 @@ from collections.abc import Collection, Sequence from pathlib import Path -from typing import Generic, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only +from typing import Generic, Literal, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias import numpy as np import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index ab763578101a..e402feaf4214 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -1,4 +1,5 @@ -from typing import Literal, TypeAlias, TypedDict, type_check_only +from typing import Literal, TypedDict, type_check_only +from typing_extensions import TypeAlias import numpy as np import numpy.typing as npt diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index dffff2e673db..6f75c9e38f22 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -1,4 +1,5 @@ -from typing import Any, TypeAlias, overload +from typing import Any, overload +from typing_extensions import TypeAlias import numpy as np import numpy.typing as npt diff --git a/stubs/pyflakes/pyflakes/checker.pyi b/stubs/pyflakes/pyflakes/checker.pyi index 0c2fd601fb9b..0b87aa5a84e6 100644 --- a/stubs/pyflakes/pyflakes/checker.pyi +++ b/stubs/pyflakes/pyflakes/checker.pyi @@ -4,8 +4,8 @@ from _typeshed import StrOrLiteralStr, Unused from collections.abc import Callable, Generator, Iterable, Iterator, Sequence from contextlib import contextmanager from re import Pattern -from typing import Any, ClassVar, Final, Literal, TypeAlias, TypeVar, overload -from typing_extensions import Never, ParamSpec +from typing import Any, ClassVar, Final, Literal, TypeVar, overload +from typing_extensions import Never, ParamSpec, TypeAlias from pyflakes.messages import Message @@ -19,7 +19,12 @@ builtin_vars: Final[list[str]] def parse_format_string( format_string: StrOrLiteralStr, ) -> Iterable[tuple[StrOrLiteralStr, StrOrLiteralStr | None, StrOrLiteralStr | None, StrOrLiteralStr | None]]: ... -def getAlternatives(n: ast.If | ast.Try | ast.Match) -> list[ast.AST]: ... + +if sys.version_info >= (3, 10): + def getAlternatives(n: ast.If | ast.Try | ast.Match) -> list[ast.AST]: ... + +else: + def getAlternatives(n: ast.If | ast.Try) -> list[ast.AST]: ... FOR_TYPES: Final[tuple[type[ast.For], type[ast.AsyncFor]]] MAPPING_KEY_RE: Final[Pattern[str]] @@ -144,16 +149,29 @@ class AnnotationState: def in_annotation(func: _F) -> _F: ... def in_string_annotation(func: _F) -> _F: ... -_Match: TypeAlias = ast.Match -_MatchCase: TypeAlias = ast.match_case -_MatchValue: TypeAlias = ast.MatchValue -_MatchSingleton: TypeAlias = ast.MatchSingleton -_MatchSequence: TypeAlias = ast.MatchSequence -_MatchStar: TypeAlias = ast.MatchStar -_MatchMapping: TypeAlias = ast.MatchMapping -_MatchClass: TypeAlias = ast.MatchClass -_MatchAs: TypeAlias = ast.MatchAs -_MatchOr: TypeAlias = ast.MatchOr +if sys.version_info >= (3, 10): + _Match: TypeAlias = ast.Match + _MatchCase: TypeAlias = ast.match_case + _MatchValue: TypeAlias = ast.MatchValue + _MatchSingleton: TypeAlias = ast.MatchSingleton + _MatchSequence: TypeAlias = ast.MatchSequence + _MatchStar: TypeAlias = ast.MatchStar + _MatchMapping: TypeAlias = ast.MatchMapping + _MatchClass: TypeAlias = ast.MatchClass + _MatchAs: TypeAlias = ast.MatchAs + _MatchOr: TypeAlias = ast.MatchOr +else: + # The methods using these should never be called on Python < 3.10. + _Match: TypeAlias = Never + _MatchCase: TypeAlias = Never + _MatchValue: TypeAlias = Never + _MatchSingleton: TypeAlias = Never + _MatchSequence: TypeAlias = Never + _MatchStar: TypeAlias = Never + _MatchMapping: TypeAlias = Never + _MatchClass: TypeAlias = Never + _MatchAs: TypeAlias = Never + _MatchOr: TypeAlias = Never if sys.version_info >= (3, 12): _TypeVar: TypeAlias = ast.TypeVar diff --git a/stubs/pyinstaller/PyInstaller/__main__.pyi b/stubs/pyinstaller/PyInstaller/__main__.pyi index 9f6397bdab29..8b295520d59b 100644 --- a/stubs/pyinstaller/PyInstaller/__main__.pyi +++ b/stubs/pyinstaller/PyInstaller/__main__.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsKeysAndGetItem from collections.abc import Iterable -from typing import TypeAlias +from typing_extensions import TypeAlias # Used to update PyInstaller.config.CONF _PyIConfig: TypeAlias = ( diff --git a/stubs/pyinstaller/PyInstaller/building/__init__.pyi b/stubs/pyinstaller/PyInstaller/building/__init__.pyi index bf87a78779b4..036849a0e51c 100644 --- a/stubs/pyinstaller/PyInstaller/building/__init__.pyi +++ b/stubs/pyinstaller/PyInstaller/building/__init__.pyi @@ -1,4 +1,4 @@ -from typing import TypeAlias +from typing_extensions import TypeAlias # PyiBlockCipher is deprecated and misleads users into thinking it adds any security. Runtime deprecation warning: # DEPRECATION: Bytecode encryption will be removed in PyInstaller v6. diff --git a/stubs/pyinstaller/PyInstaller/building/api.pyi b/stubs/pyinstaller/PyInstaller/building/api.pyi index 97e2c340c5a9..1aa2339ff101 100644 --- a/stubs/pyinstaller/PyInstaller/building/api.pyi +++ b/stubs/pyinstaller/PyInstaller/building/api.pyi @@ -6,7 +6,8 @@ import sys from _typeshed import FileDescriptorOrPath, StrOrBytesPath, StrPath, Unused from collections.abc import Iterable, Mapping, Sequence from types import CodeType -from typing import ClassVar, Final, Literal, TypeAlias +from typing import ClassVar, Final, Literal +from typing_extensions import TypeAlias from PyInstaller.building import _PyiBlockCipher from PyInstaller.building.build_main import Analysis diff --git a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi index 0c3878a0b9ce..cfb1cf70b6d3 100644 --- a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi +++ b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi @@ -1,7 +1,7 @@ # https://pyinstaller.org/en/stable/advanced-topics.html#the-toc-and-tree-classes from collections.abc import Iterable, Sequence -from typing import ClassVar, Literal, SupportsIndex, TypeAlias -from typing_extensions import LiteralString, Self +from typing import ClassVar, Literal, SupportsIndex +from typing_extensions import LiteralString, Self, TypeAlias _TypeCode: TypeAlias = Literal["DEPENDENCY", "SYMLINK", "DATA", "BINARY", "EXECUTABLE", "EXTENSION", "OPTION"] _TOCTuple: TypeAlias = tuple[str, str | None, _TypeCode | None] diff --git a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi index 8e6f37c238d3..027d6a54739a 100644 --- a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi @@ -4,7 +4,7 @@ # However, some PyiModuleGraph typed class attributes are still documented as existing in imphookapi. from _typeshed import Incomplete, StrPath, SupportsKeysAndGetItem from collections.abc import Iterable -from typing import TypeAlias +from typing_extensions import TypeAlias from PyInstaller.lib.modulegraph.modulegraph import Alias, Node diff --git a/stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi b/stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi index 1e2e7c6425ef..f4af6b33c4ac 100644 --- a/stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/win32/versioninfo.pyi @@ -1,6 +1,7 @@ from _typeshed import SliceableBuffer, Unused from collections.abc import Sequence -from typing import Any, Protocol, TypeAlias, type_check_only +from typing import Any, Protocol, type_check_only +from typing_extensions import TypeAlias _FourIntSequence: TypeAlias = Sequence[int] _TwoIntSequence: TypeAlias = Sequence[int] diff --git a/stubs/pyjks/jks/bks.pyi b/stubs/pyjks/jks/bks.pyi index d083d6b95d2f..0e12e65376ef 100644 --- a/stubs/pyjks/jks/bks.pyi +++ b/stubs/pyjks/jks/bks.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsKeysAndGetItem, Unused -from typing import Final, Literal, TypeAlias -from typing_extensions import Self +from typing import Final, Literal +from typing_extensions import Self, TypeAlias from .jks import TrustedCertEntry from .util import AbstractKeystore, AbstractKeystoreEntry diff --git a/stubs/pyjks/jks/jks.pyi b/stubs/pyjks/jks/jks.pyi index fb1e814864a1..9c816cc7bf74 100644 --- a/stubs/pyjks/jks/jks.pyi +++ b/stubs/pyjks/jks/jks.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsKeysAndGetItem, Unused from collections.abc import Iterable -from typing import Final, Literal, NoReturn, TypeAlias, overload -from typing_extensions import Self +from typing import Final, Literal, NoReturn, overload +from typing_extensions import Self, TypeAlias from .util import AbstractKeystore, AbstractKeystoreEntry diff --git a/stubs/pyjks/jks/rfc7292.pyi b/stubs/pyjks/jks/rfc7292.pyi index 400f6d577568..b57599fc38da 100644 --- a/stubs/pyjks/jks/rfc7292.pyi +++ b/stubs/pyjks/jks/rfc7292.pyi @@ -1,5 +1,6 @@ from hashlib import _Hash -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias from pyasn1.type.namedtype import NamedTypes from pyasn1.type.univ import Sequence diff --git a/stubs/pyjks/jks/util.pyi b/stubs/pyjks/jks/util.pyi index 8e913d36654c..84f576dce440 100644 --- a/stubs/pyjks/jks/util.pyi +++ b/stubs/pyjks/jks/util.pyi @@ -1,8 +1,8 @@ from _typeshed import FileDescriptorOrPath, SupportsKeysAndGetItem, Unused from collections.abc import Iterable from struct import Struct -from typing import Final, Literal, TypeAlias -from typing_extensions import Self +from typing import Final, Literal +from typing_extensions import Self, TypeAlias from .bks import BksKeyEntry from .jks import PrivateKeyEntry diff --git a/stubs/pyperclip/pyperclip/__init__.pyi b/stubs/pyperclip/pyperclip/__init__.pyi index 28ac5248078d..4d2947e849f7 100644 --- a/stubs/pyperclip/pyperclip/__init__.pyi +++ b/stubs/pyperclip/pyperclip/__init__.pyi @@ -1,7 +1,8 @@ __all__ = ["copy", "paste", "set_clipboard", "determine_clipboard"] from collections.abc import Callable -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias class PyperclipException(RuntimeError): ... diff --git a/stubs/pyserial/serial/win32.pyi b/stubs/pyserial/serial/win32.pyi index 807f2679c4e5..be1cb025d166 100644 --- a/stubs/pyserial/serial/win32.pyi +++ b/stubs/pyserial/serial/win32.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import Incomplete from ctypes import Structure, Union, _CField, _NamedFuncPointer, _Pointer, c_int64, c_ulong, c_void_p from ctypes.wintypes import DWORD -from typing import TypeAlias +from typing_extensions import TypeAlias if sys.platform == "win32": def is_64bit() -> bool: ... diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 087bc5695425..188e13aff8ac 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -2,8 +2,8 @@ from collections.abc import Callable, Sequence from contextlib import AbstractContextManager from stat import S_IMODE as S_IMODE from types import TracebackType -from typing import IO, Literal, TypeAlias -from typing_extensions import Self +from typing import IO, Literal +from typing_extensions import Self, TypeAlias import paramiko from paramiko import AuthenticationException as AuthenticationException diff --git a/stubs/pysftp/pysftp/helpers.pyi b/stubs/pysftp/pysftp/helpers.pyi index 7967be313ae2..96116d13f33f 100644 --- a/stubs/pysftp/pysftp/helpers.pyi +++ b/stubs/pysftp/pysftp/helpers.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Iterator from contextlib import AbstractContextManager -from typing import TypeAlias +from typing_extensions import TypeAlias def known_hosts() -> str: ... def st_mode_to_int(val: int) -> int: ... diff --git a/stubs/python-crontab/crontab.pyi b/stubs/python-crontab/crontab.pyi index c7ca54a2f581..a33bb1193eb8 100644 --- a/stubs/python-crontab/crontab.pyi +++ b/stubs/python-crontab/crontab.pyi @@ -7,8 +7,8 @@ from collections.abc import Callable, Generator, Iterable, Iterator from datetime import datetime from logging import Logger from types import TracebackType -from typing import Any, Final, Literal, Protocol, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, Final, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias from croniter.croniter import croniter from cronlog import CronLog diff --git a/stubs/python-dateutil/dateutil/parser/_parser.pyi b/stubs/python-dateutil/dateutil/parser/_parser.pyi index 65f2af983d12..9119ec25d7b7 100644 --- a/stubs/python-dateutil/dateutil/parser/_parser.pyi +++ b/stubs/python-dateutil/dateutil/parser/_parser.pyi @@ -3,8 +3,8 @@ from _typeshed import SupportsRead from collections.abc import Callable, Mapping from datetime import _TzInfo, datetime from io import StringIO -from typing import IO, Any, TypeAlias -from typing_extensions import Self +from typing import IO, Any +from typing_extensions import Self, TypeAlias _FileOrStr: TypeAlias = bytes | str | IO[str] | IO[Any] _TzData: TypeAlias = _TzInfo | int | str | None diff --git a/stubs/python-dateutil/dateutil/parser/isoparser.pyi b/stubs/python-dateutil/dateutil/parser/isoparser.pyi index 82bdb19b9baf..51a9c153af81 100644 --- a/stubs/python-dateutil/dateutil/parser/isoparser.pyi +++ b/stubs/python-dateutil/dateutil/parser/isoparser.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsRead from datetime import date, datetime, time, tzinfo -from typing import TypeAlias +from typing_extensions import TypeAlias _Readable: TypeAlias = SupportsRead[str | bytes] _TakesAscii: TypeAlias = str | bytes | _Readable diff --git a/stubs/python-dateutil/dateutil/relativedelta.pyi b/stubs/python-dateutil/dateutil/relativedelta.pyi index 7214673c2da1..90f155f70717 100644 --- a/stubs/python-dateutil/dateutil/relativedelta.pyi +++ b/stubs/python-dateutil/dateutil/relativedelta.pyi @@ -1,6 +1,6 @@ from datetime import date, timedelta -from typing import SupportsFloat, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import SupportsFloat, TypeVar, overload +from typing_extensions import Self, TypeAlias # See #9817 for why we reexport this here from ._common import weekday as weekday diff --git a/stubs/python-dateutil/dateutil/rrule.pyi b/stubs/python-dateutil/dateutil/rrule.pyi index a8f40a7fa616..dd712283fd3a 100644 --- a/stubs/python-dateutil/dateutil/rrule.pyi +++ b/stubs/python-dateutil/dateutil/rrule.pyi @@ -1,7 +1,7 @@ import datetime from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence -from typing import Final, Literal, TypeAlias, overload -from typing_extensions import Self +from typing import Final, Literal, overload +from typing_extensions import Self, TypeAlias from dateutil.parser._parser import _TzInfos diff --git a/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi b/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi index 687e3f563a89..65627ecdd773 100644 --- a/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi +++ b/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from collections.abc import Callable from io import BytesIO from tarfile import _Fileobj -from typing import Final, TypeAlias, TypeVar, overload -from typing_extensions import Self, deprecated +from typing import Final, TypeVar, overload +from typing_extensions import Self, TypeAlias, deprecated from dateutil.tz import tzfile as _tzfile diff --git a/stubs/python-jenkins/jenkins/__init__.pyi b/stubs/python-jenkins/jenkins/__init__.pyi index 67182d33b61b..a605ab5c0ee0 100644 --- a/stubs/python-jenkins/jenkins/__init__.pyi +++ b/stubs/python-jenkins/jenkins/__init__.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Mapping, MutableMapping, Sequence from re import Pattern -from typing import Any, Final, Literal, TypeAlias, TypedDict, overload, type_check_only -from typing_extensions import Required, deprecated +from typing import Any, Final, Literal, TypedDict, overload, type_check_only +from typing_extensions import Required, TypeAlias, deprecated import requests from requests.models import Request, Response diff --git a/stubs/python-nmap/nmap/nmap.pyi b/stubs/python-nmap/nmap/nmap.pyi index 740467d72e55..884a9b363743 100644 --- a/stubs/python-nmap/nmap/nmap.pyi +++ b/stubs/python-nmap/nmap/nmap.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Iterable, Iterator -from typing import Any, TypeAlias, TypedDict, TypeVar, type_check_only +from typing import Any, TypedDict, TypeVar, type_check_only +from typing_extensions import TypeAlias _T = TypeVar("_T") _Callback: TypeAlias = Callable[[str, _Result], object] diff --git a/stubs/python-xlib/Xlib/_typing.pyi b/stubs/python-xlib/Xlib/_typing.pyi index 90f05ff16109..550da8afdc16 100644 --- a/stubs/python-xlib/Xlib/_typing.pyi +++ b/stubs/python-xlib/Xlib/_typing.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import TypeAlias, TypeVar +from typing import TypeVar +from typing_extensions import TypeAlias from Xlib.error import XError from Xlib.protocol.rq import Request diff --git a/stubs/python-xlib/Xlib/display.pyi b/stubs/python-xlib/Xlib/display.pyi index 8ee8b6df0c36..535e3e2e0139 100644 --- a/stubs/python-xlib/Xlib/display.pyi +++ b/stubs/python-xlib/Xlib/display.pyi @@ -1,7 +1,8 @@ from collections.abc import Callable, Iterable, Sequence from re import Pattern from types import FunctionType, MethodType -from typing import Any, Literal, TypeAlias, TypedDict, overload, type_check_only +from typing import Any, Literal, TypedDict, overload, type_check_only +from typing_extensions import TypeAlias from Xlib import error from Xlib._typing import ErrorHandler diff --git a/stubs/python-xlib/Xlib/ext/composite.pyi b/stubs/python-xlib/Xlib/ext/composite.pyi index 9582ae777e6c..3d647de0f6b8 100644 --- a/stubs/python-xlib/Xlib/ext/composite.pyi +++ b/stubs/python-xlib/Xlib/ext/composite.pyi @@ -1,6 +1,7 @@ from _typeshed import Unused from collections.abc import Callable -from typing import Any, Final, TypeAlias +from typing import Any, Final +from typing_extensions import TypeAlias from Xlib._typing import ErrorHandler from Xlib.display import Display diff --git a/stubs/python-xlib/Xlib/ext/randr.pyi b/stubs/python-xlib/Xlib/ext/randr.pyi index 9aac2eee1301..0ff95176124f 100644 --- a/stubs/python-xlib/Xlib/ext/randr.pyi +++ b/stubs/python-xlib/Xlib/ext/randr.pyi @@ -1,5 +1,6 @@ from collections.abc import Sequence -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias from Xlib.display import Display from Xlib.protocol import request, rq diff --git a/stubs/python-xlib/Xlib/protocol/event.pyi b/stubs/python-xlib/Xlib/protocol/event.pyi index f033a985b030..b4366c8a9c40 100644 --- a/stubs/python-xlib/Xlib/protocol/event.pyi +++ b/stubs/python-xlib/Xlib/protocol/event.pyi @@ -1,4 +1,5 @@ -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias from Xlib.protocol import rq diff --git a/stubs/python-xlib/Xlib/protocol/rq.pyi b/stubs/python-xlib/Xlib/protocol/rq.pyi index 689e7cd5dfd7..b429499d38a0 100644 --- a/stubs/python-xlib/Xlib/protocol/rq.pyi +++ b/stubs/python-xlib/Xlib/protocol/rq.pyi @@ -4,8 +4,8 @@ from array import array # Avoid name collision with List.type from builtins import type as Type from collections.abc import Callable, Iterable, Sequence -from typing import Any, Final, Literal, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import LiteralString +from typing import Any, Final, Literal, SupportsIndex, TypeVar, overload, type_check_only +from typing_extensions import LiteralString, TypeAlias from Xlib._typing import ErrorHandler from Xlib.display import _BaseDisplay, _ResourceBaseClass diff --git a/stubs/python-xlib/Xlib/protocol/structs.pyi b/stubs/python-xlib/Xlib/protocol/structs.pyi index 47508e6a636c..60e004c478ac 100644 --- a/stubs/python-xlib/Xlib/protocol/structs.pyi +++ b/stubs/python-xlib/Xlib/protocol/structs.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Sequence -from typing import TypeAlias +from typing_extensions import TypeAlias from Xlib.protocol import rq diff --git a/stubs/python-xlib/Xlib/rdb.pyi b/stubs/python-xlib/Xlib/rdb.pyi index f0ec57c5b656..e330353a01ec 100644 --- a/stubs/python-xlib/Xlib/rdb.pyi +++ b/stubs/python-xlib/Xlib/rdb.pyi @@ -1,7 +1,8 @@ from _typeshed import SupportsDunderGT, SupportsDunderLT, SupportsRead from collections.abc import Iterable, Mapping, Sequence from re import Pattern -from typing import Any, Final, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, Final, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from Xlib.display import Display from Xlib.support.lock import _DummyLock diff --git a/stubs/python-xlib/Xlib/support/unix_connect.pyi b/stubs/python-xlib/Xlib/support/unix_connect.pyi index 74e6a749ff91..600d3daa76c4 100644 --- a/stubs/python-xlib/Xlib/support/unix_connect.pyi +++ b/stubs/python-xlib/Xlib/support/unix_connect.pyi @@ -4,7 +4,8 @@ from _typeshed import Unused from platform import uname_result from re import Pattern from socket import socket -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias if sys.platform == "darwin": SUPPORTED_PROTOCOLS: Final[tuple[None, Literal["tcp"], Literal["unix"], Literal["darwin"]]] diff --git a/stubs/pywin32/_win32typing.pyi b/stubs/pywin32/_win32typing.pyi index 8da571213176..38d9d578b468 100644 --- a/stubs/pywin32/_win32typing.pyi +++ b/stubs/pywin32/_win32typing.pyi @@ -1,8 +1,8 @@ # Not available at runtime. Contains type definitions that are otherwise not exposed and not part of a specific module. from _typeshed import Incomplete, Unused from collections.abc import Iterable, Sequence -from typing import Literal, NoReturn, SupportsIndex, TypeAlias, final, overload -from typing_extensions import Self, deprecated, disjoint_base +from typing import Literal, NoReturn, SupportsIndex, final, overload +from typing_extensions import Self, TypeAlias, deprecated, disjoint_base from win32.lib.pywintypes import TimeType diff --git a/stubs/pywin32/pythoncom.pyi b/stubs/pywin32/pythoncom.pyi index d938fb4ca787..6368357725a9 100644 --- a/stubs/pywin32/pythoncom.pyi +++ b/stubs/pywin32/pythoncom.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, Unused from abc import abstractmethod from collections.abc import Sequence -from typing import ClassVar, SupportsInt, TypeAlias, overload -from typing_extensions import deprecated, disjoint_base +from typing import ClassVar, SupportsInt, overload +from typing_extensions import TypeAlias, deprecated, disjoint_base import _win32typing from win32.lib.pywintypes import TimeType, com_error as com_error diff --git a/stubs/pywin32/win32/lib/ntsecuritycon.pyi b/stubs/pywin32/win32/lib/ntsecuritycon.pyi index 7d4d6e8cc02c..19bb7a9d5b8b 100644 --- a/stubs/pywin32/win32/lib/ntsecuritycon.pyi +++ b/stubs/pywin32/win32/lib/ntsecuritycon.pyi @@ -1,4 +1,4 @@ -from typing import TypeAlias +from typing_extensions import TypeAlias _SixIntTuple: TypeAlias = tuple[int, int, int, int, int, int] diff --git a/stubs/pywin32/win32com/client/__init__.pyi b/stubs/pywin32/win32com/client/__init__.pyi index 563a0768c21b..987a842edbec 100644 --- a/stubs/pywin32/win32com/client/__init__.pyi +++ b/stubs/pywin32/win32com/client/__init__.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete, Unused from collections.abc import Iterator -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias import _win32typing from pythoncom import com_record diff --git a/stubs/pywin32/win32com/client/dynamic.pyi b/stubs/pywin32/win32com/client/dynamic.pyi index 87cd47fb3e34..17b3cb620fff 100644 --- a/stubs/pywin32/win32com/client/dynamic.pyi +++ b/stubs/pywin32/win32com/client/dynamic.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete -from typing import Any, Protocol, TypeAlias, TypeVar, overload +from typing import Any, Protocol, TypeVar, overload +from typing_extensions import TypeAlias import _win32typing from win32.lib.pywintypes import IIDType diff --git a/stubs/pywin32/win32com/server/dispatcher.pyi b/stubs/pywin32/win32com/server/dispatcher.pyi index 6c4c9dd74ace..2644262edd5c 100644 --- a/stubs/pywin32/win32com/server/dispatcher.pyi +++ b/stubs/pywin32/win32com/server/dispatcher.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import TypeAlias +from typing_extensions import TypeAlias from win32com.server.policy import BasicWrapPolicy diff --git a/stubs/pywin32/win32com/universal.pyi b/stubs/pywin32/win32com/universal.pyi index 99e6186e863d..fe0e626fc0d3 100644 --- a/stubs/pywin32/win32com/universal.pyi +++ b/stubs/pywin32/win32com/universal.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable -from typing import TypeAlias +from typing_extensions import TypeAlias import pythoncom diff --git a/stubs/pywin32/win32comext/adsi/adsi.pyi b/stubs/pywin32/win32comext/adsi/adsi.pyi index 69cb550e4fd2..b5acc70cb365 100644 --- a/stubs/pywin32/win32comext/adsi/adsi.pyi +++ b/stubs/pywin32/win32comext/adsi/adsi.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import TypeAlias +from typing_extensions import TypeAlias import _win32typing from win32.lib.pywintypes import com_error diff --git a/stubs/pywin32/win32comext/propsys/propsys.pyi b/stubs/pywin32/win32comext/propsys/propsys.pyi index 090ef130f25b..08b4c67826e9 100644 --- a/stubs/pywin32/win32comext/propsys/propsys.pyi +++ b/stubs/pywin32/win32comext/propsys/propsys.pyi @@ -1,4 +1,4 @@ -from typing import TypeAlias +from typing_extensions import TypeAlias import _win32typing from win32.lib.pywintypes import com_error diff --git a/stubs/pywin32/win32comext/shell/shell.pyi b/stubs/pywin32/win32comext/shell/shell.pyi index 357a9b38c11f..8b63eda438ff 100644 --- a/stubs/pywin32/win32comext/shell/shell.pyi +++ b/stubs/pywin32/win32comext/shell/shell.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import TypeAlias +from typing_extensions import TypeAlias import _win32typing from win32.lib.pywintypes import com_error diff --git a/stubs/pyxdg/xdg/MenuEditor.pyi b/stubs/pyxdg/xdg/MenuEditor.pyi index 48626276a760..5e8c98136df4 100644 --- a/stubs/pyxdg/xdg/MenuEditor.pyi +++ b/stubs/pyxdg/xdg/MenuEditor.pyi @@ -1,5 +1,6 @@ from _typeshed import StrPath, Unused -from typing import Literal, TypeAlias, overload +from typing import Literal, overload +from typing_extensions import TypeAlias from xml.etree.ElementTree import ElementTree from .Menu import Menu, MenuEntry, Separator, XMLMenuBuilder diff --git a/stubs/pyxdg/xdg/Mime.pyi b/stubs/pyxdg/xdg/Mime.pyi index 38607506caea..f31eec421531 100644 --- a/stubs/pyxdg/xdg/Mime.pyi +++ b/stubs/pyxdg/xdg/Mime.pyi @@ -3,8 +3,8 @@ from _typeshed import StrOrBytesPath, SupportsLenAndGetItem, Unused from collections import defaultdict from collections.abc import Collection, Iterable from io import BytesIO -from typing import Literal, TypeAlias -from typing_extensions import Self +from typing import Literal +from typing_extensions import Self, TypeAlias FREE_NS: str types: dict[str, MIMEtype] diff --git a/stubs/qrbill/qrbill/bill.pyi b/stubs/qrbill/qrbill/bill.pyi index 2cabe1fd1af8..001175230974 100644 --- a/stubs/qrbill/qrbill/bill.pyi +++ b/stubs/qrbill/qrbill/bill.pyi @@ -2,8 +2,8 @@ from _typeshed import SupportsWrite from collections.abc import Iterable, Iterator, Mapping from decimal import Decimal from pathlib import Path -from typing import Any, Final, Literal, TypeAlias, overload -from typing_extensions import deprecated +from typing import Any, Final, Literal, overload +from typing_extensions import TypeAlias, deprecated from qrcode.image.svg import SvgPathImage diff --git a/stubs/qrcode/qrcode/_types.pyi b/stubs/qrcode/qrcode/_types.pyi index dac241617872..2fb145fc4fc0 100644 --- a/stubs/qrcode/qrcode/_types.pyi +++ b/stubs/qrcode/qrcode/_types.pyi @@ -1,6 +1,7 @@ # Type aliases used in this stub package from _typeshed import SupportsWrite -from typing import Any, Protocol, TypeAlias +from typing import Any, Protocol +from typing_extensions import TypeAlias Box: TypeAlias = tuple[tuple[int, int], tuple[int, int]] Ink: TypeAlias = tuple[int, int, int] | tuple[int, int, int, int] diff --git a/stubs/qrcode/qrcode/image/base.pyi b/stubs/qrcode/qrcode/image/base.pyi index 03a5133994f4..0d43f58698d8 100644 --- a/stubs/qrcode/qrcode/image/base.pyi +++ b/stubs/qrcode/qrcode/image/base.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import IO, Any, TypeAlias +from typing import IO, Any +from typing_extensions import TypeAlias from ..main import ModulesType, QRCode from .styles.moduledrawers.base import QRModuleDrawer diff --git a/stubs/qrcode/qrcode/image/pure.pyi b/stubs/qrcode/qrcode/image/pure.pyi index 45fdfbc3004e..ec5df707f02f 100644 --- a/stubs/qrcode/qrcode/image/pure.pyi +++ b/stubs/qrcode/qrcode/image/pure.pyi @@ -1,6 +1,7 @@ from _typeshed import SupportsWrite from collections.abc import Generator -from typing import Any, Literal, TypeAlias +from typing import Any, Literal +from typing_extensions import TypeAlias from . import base diff --git a/stubs/qrcode/qrcode/main.pyi b/stubs/qrcode/qrcode/main.pyi index f7b35f39219f..09a7b7a16eca 100644 --- a/stubs/qrcode/qrcode/main.pyi +++ b/stubs/qrcode/qrcode/main.pyi @@ -1,6 +1,7 @@ from _typeshed import ConvertibleToInt from collections.abc import Sequence -from typing import Any, Generic, NamedTuple, Protocol, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, Generic, NamedTuple, Protocol, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias from ._types import ErrorCorrect, MaskPattern from .image.base import BaseImage diff --git a/stubs/qrcode/qrcode/util.pyi b/stubs/qrcode/qrcode/util.pyi index bb1ac696115c..df4832c5d11d 100644 --- a/stubs/qrcode/qrcode/util.pyi +++ b/stubs/qrcode/qrcode/util.pyi @@ -1,6 +1,7 @@ from collections.abc import Callable, Generator from re import Pattern -from typing import Final, Literal, TypeAlias, overload +from typing import Final, Literal, overload +from typing_extensions import TypeAlias from ._types import ErrorCorrect, MaskPattern from .base import RSBlock as RSBlock diff --git a/stubs/regex/regex/_regex_core.pyi b/stubs/regex/regex/_regex_core.pyi index d8f3014f9a73..5778565d5fcc 100644 --- a/stubs/regex/regex/_regex_core.pyi +++ b/stubs/regex/regex/_regex_core.pyi @@ -1,6 +1,7 @@ import enum from collections.abc import Callable -from typing import Any, AnyStr, Generic, TypeAlias +from typing import Any, AnyStr, Generic +from typing_extensions import TypeAlias from ._main import Pattern diff --git a/stubs/reportlab/reportlab/graphics/shapes.pyi b/stubs/reportlab/reportlab/graphics/shapes.pyi index 253538227f0f..f9d290b79a2c 100644 --- a/stubs/reportlab/reportlab/graphics/shapes.pyi +++ b/stubs/reportlab/reportlab/graphics/shapes.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete, SupportsItems from abc import abstractmethod from collections.abc import Iterable, Sequence -from typing import Any, Final, Literal, NoReturn, TypeAlias, TypedDict, type_check_only -from typing_extensions import Self, Unpack +from typing import Any, Final, Literal, NoReturn, TypedDict, type_check_only +from typing_extensions import Self, TypeAlias, Unpack from reportlab.lib.colors import Color from reportlab.lib.validators import NoneOr, Validator diff --git a/stubs/reportlab/reportlab/lib/colors.pyi b/stubs/reportlab/reportlab/lib/colors.pyi index f281d37ced14..362233967f88 100644 --- a/stubs/reportlab/reportlab/lib/colors.pyi +++ b/stubs/reportlab/reportlab/lib/colors.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable, Iterator -from typing import Final, Literal, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Final, Literal, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias _ColorT = TypeVar("_ColorT", bound=Color) # NOTE: Reportlab is very inconsistent and sometimes uses the interpretation diff --git a/stubs/reportlab/reportlab/lib/fonts.pyi b/stubs/reportlab/reportlab/lib/fonts.pyi index 665e34909894..2edeba631d38 100644 --- a/stubs/reportlab/reportlab/lib/fonts.pyi +++ b/stubs/reportlab/reportlab/lib/fonts.pyi @@ -1,4 +1,5 @@ -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias _BoolInt: TypeAlias = Literal[0, 1] diff --git a/stubs/reportlab/reportlab/lib/styles.pyi b/stubs/reportlab/reportlab/lib/styles.pyi index 096d8d031a3a..028d9b0cd5a8 100644 --- a/stubs/reportlab/reportlab/lib/styles.pyi +++ b/stubs/reportlab/reportlab/lib/styles.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from typing import Any, ClassVar, Literal, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import Any, ClassVar, Literal, TypeVar, overload +from typing_extensions import Self, TypeAlias from reportlab.lib.colors import Color diff --git a/stubs/reportlab/reportlab/pdfgen/textobject.pyi b/stubs/reportlab/reportlab/pdfgen/textobject.pyi index ed187f7e9aaa..e0162746b4d8 100644 --- a/stubs/reportlab/reportlab/pdfgen/textobject.pyi +++ b/stubs/reportlab/reportlab/pdfgen/textobject.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete, Unused from collections.abc import Callable -from typing import Final, Literal, TypeAlias +from typing import Final, Literal +from typing_extensions import TypeAlias from reportlab.lib.colors import Color from reportlab.pdfbase.ttfonts import ShapedStr diff --git a/stubs/reportlab/reportlab/platypus/doctemplate.pyi b/stubs/reportlab/reportlab/platypus/doctemplate.pyi index bdafbd35c529..c3ffee40eb39 100644 --- a/stubs/reportlab/reportlab/platypus/doctemplate.pyi +++ b/stubs/reportlab/reportlab/platypus/doctemplate.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from abc import abstractmethod from collections.abc import Callable -from typing import IO, Any, Literal, Protocol, TypeAlias, type_check_only -from typing_extensions import Self +from typing import IO, Any, Literal, Protocol, type_check_only +from typing_extensions import Self, TypeAlias from reportlab.pdfgen.canvas import Canvas from reportlab.platypus.flowables import Flowable diff --git a/stubs/reportlab/reportlab/platypus/flowables.pyi b/stubs/reportlab/reportlab/platypus/flowables.pyi index b3a433df28f0..da28237e3850 100644 --- a/stubs/reportlab/reportlab/platypus/flowables.pyi +++ b/stubs/reportlab/reportlab/platypus/flowables.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsRead, Unused from collections.abc import Callable, Iterable, Sequence -from typing import Any, Literal, NoReturn, Protocol, TypeAlias, type_check_only -from typing_extensions import Self +from typing import Any, Literal, NoReturn, Protocol, type_check_only +from typing_extensions import Self, TypeAlias from reportlab.lib.colors import Color from reportlab.lib.styles import ListStyle, ParagraphStyle, PropertySet diff --git a/stubs/reportlab/reportlab/platypus/para.pyi b/stubs/reportlab/reportlab/platypus/para.pyi index 59ff594b0db7..a83dce246445 100644 --- a/stubs/reportlab/reportlab/platypus/para.pyi +++ b/stubs/reportlab/reportlab/platypus/para.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, Unused from collections.abc import Callable, Mapping -from typing import Any, Final, Literal, Protocol, TypeAlias, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Unpack +from typing import Any, Final, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias, Unpack from reportlab.lib.colors import Color from reportlab.lib.styles import ParagraphStyle, PropertySet, StyleSheet1 diff --git a/stubs/reportlab/reportlab/platypus/tableofcontents.pyi b/stubs/reportlab/reportlab/platypus/tableofcontents.pyi index 0ae40aa5b850..8159bde6ae53 100644 --- a/stubs/reportlab/reportlab/platypus/tableofcontents.pyi +++ b/stubs/reportlab/reportlab/platypus/tableofcontents.pyi @@ -1,7 +1,7 @@ from _typeshed import Unused from collections.abc import Callable, Iterable, Sequence -from typing import Any, Final, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Unpack +from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import TypeAlias, Unpack from reportlab.lib.styles import ParagraphStyle, PropertySet from reportlab.pdfgen.canvas import Canvas diff --git a/stubs/reportlab/reportlab/platypus/tables.pyi b/stubs/reportlab/reportlab/platypus/tables.pyi index c8208372970f..905b2fd8180c 100644 --- a/stubs/reportlab/reportlab/platypus/tables.pyi +++ b/stubs/reportlab/reportlab/platypus/tables.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from abc import abstractmethod from collections.abc import Collection, Iterable, Sequence -from typing import Any, Literal, NamedTuple, TypeAlias, overload -from typing_extensions import Unpack +from typing import Any, Literal, NamedTuple, overload +from typing_extensions import TypeAlias, Unpack from reportlab.lib.colors import Color from reportlab.lib.styles import PropertySet diff --git a/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi b/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi index b9f9b11962b5..a6e089ec90d7 100644 --- a/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi +++ b/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from logging import Logger -from typing import TypeAlias, TypedDict, type_check_only +from typing import TypedDict, type_check_only +from typing_extensions import TypeAlias import requests from oauthlib.oauth1 import Client diff --git a/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi b/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi index 27a21c3e8f48..1ad322a9f42c 100644 --- a/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi +++ b/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from logging import Logger -from typing import Any, Literal, Protocol, TypeAlias, TypedDict, overload, type_check_only +from typing import Any, Literal, Protocol, TypedDict, overload, type_check_only +from typing_extensions import TypeAlias import requests from oauthlib.oauth2 import Client diff --git a/stubs/requests/requests/api.pyi b/stubs/requests/requests/api.pyi index c29ff6472fc1..49e0ce247432 100644 --- a/stubs/requests/requests/api.pyi +++ b/stubs/requests/requests/api.pyi @@ -1,6 +1,6 @@ from collections.abc import Mapping from http.cookiejar import CookieJar -from typing import TypeAlias +from typing_extensions import TypeAlias from .models import _JSON, Response from .sessions import _Auth, _Cert, _Data, _Files, _HooksInput, _Params, _TextMapping, _Timeout, _Verify diff --git a/stubs/requests/requests/compat.pyi b/stubs/requests/requests/compat.pyi index 520f08f4a39c..1d6af41632f9 100644 --- a/stubs/requests/requests/compat.pyi +++ b/stubs/requests/requests/compat.pyi @@ -1,6 +1,7 @@ from builtins import bytes as bytes, str as str from collections import OrderedDict as OrderedDict -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias from urllib.parse import ( quote as quote, quote_plus as quote_plus, diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 0e85e09a6a8f..2747c9799eed 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -2,8 +2,8 @@ import datetime from _typeshed import Incomplete, MaybeNone, Unused from collections.abc import Callable, Iterator from json import JSONDecoder -from typing import Any, TypeAlias -from typing_extensions import Self +from typing import Any +from typing_extensions import Self, TypeAlias from urllib3 import exceptions as urllib3_exceptions, fields, filepost, util from urllib3.response import HTTPResponse diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index fb9c618b50aa..33ee2ae9b8a6 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsItems, SupportsRead, Unused from collections.abc import Callable, Iterable, Mapping, MutableMapping -from typing import Any, TypeAlias, TypedDict, type_check_only -from typing_extensions import Self +from typing import Any, TypedDict, type_check_only +from typing_extensions import Self, TypeAlias from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, utils from .models import _JSON, Response diff --git a/stubs/requests/requests/utils.pyi b/stubs/requests/requests/utils.pyi index da6798d3c72d..3edd7c1038a0 100644 --- a/stubs/requests/requests/utils.pyi +++ b/stubs/requests/requests/utils.pyi @@ -3,7 +3,8 @@ from _typeshed import Incomplete, StrOrBytesPath from collections.abc import Generator, Iterable, Mapping from contextlib import _GeneratorContextManager from io import BufferedWriter -from typing import AnyStr, TypeAlias +from typing import AnyStr +from typing_extensions import TypeAlias from . import compat, cookies, exceptions, structures from .models import PreparedRequest, Request diff --git a/stubs/s2clientprotocol/s2clientprotocol/common_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/common_pb2.pyi index fee537abac78..cfa0bec86506 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/common_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/common_pb2.pyi @@ -4,13 +4,18 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Race: diff --git a/stubs/s2clientprotocol/s2clientprotocol/data_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/data_pb2.pyi index c6bf7ff7d384..cd68bb65df02 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/data_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/data_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import s2clientprotocol.common_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Attribute: diff --git a/stubs/s2clientprotocol/s2clientprotocol/debug_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/debug_pb2.pyi index d49c912f7c15..eba2ae972064 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/debug_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/debug_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import s2clientprotocol.common_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DebugGameState: diff --git a/stubs/s2clientprotocol/s2clientprotocol/error_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/error_pb2.pyi index 596c8a615935..5c14aaba748c 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/error_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/error_pb2.pyi @@ -4,12 +4,17 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _ActionResult: diff --git a/stubs/s2clientprotocol/s2clientprotocol/raw_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/raw_pb2.pyi index 93404cc79b66..a50167f1e087 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/raw_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/raw_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import s2clientprotocol.common_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DisplayType: diff --git a/stubs/s2clientprotocol/s2clientprotocol/sc2api_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/sc2api_pb2.pyi index 6de874016424..fbf53b67a613 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/sc2api_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/sc2api_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -22,6 +22,11 @@ import s2clientprotocol.score_pb2 import s2clientprotocol.spatial_pb2 import s2clientprotocol.ui_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Status: diff --git a/stubs/s2clientprotocol/s2clientprotocol/score_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/score_pb2.pyi index 132d735f0a37..611578a5c889 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/score_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/score_pb2.pyi @@ -4,13 +4,18 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/s2clientprotocol/s2clientprotocol/spatial_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/spatial_pb2.pyi index aef910f795fa..5fd2301ac84b 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/spatial_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/spatial_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import s2clientprotocol.common_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/s2clientprotocol/s2clientprotocol/ui_pb2.pyi b/stubs/s2clientprotocol/s2clientprotocol/ui_pb2.pyi index 09d87f173072..2608a8aa142c 100644 --- a/stubs/s2clientprotocol/s2clientprotocol/ui_pb2.pyi +++ b/stubs/s2clientprotocol/s2clientprotocol/ui_pb2.pyi @@ -5,14 +5,19 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/seaborn/seaborn/_core/groupby.pyi b/stubs/seaborn/seaborn/_core/groupby.pyi index aabca58d7075..f466aee67341 100644 --- a/stubs/seaborn/seaborn/_core/groupby.pyi +++ b/stubs/seaborn/seaborn/_core/groupby.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable, Hashable, Mapping -from typing import Concatenate, TypeAlias -from typing_extensions import ParamSpec +from typing_extensions import Concatenate, ParamSpec, TypeAlias from numpy import ufunc from pandas import DataFrame diff --git a/stubs/seaborn/seaborn/_core/properties.pyi b/stubs/seaborn/seaborn/_core/properties.pyi index 548cc5a9d3ce..20cbe28fa0e0 100644 --- a/stubs/seaborn/seaborn/_core/properties.pyi +++ b/stubs/seaborn/seaborn/_core/properties.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from matplotlib.markers import MarkerStyle from matplotlib.path import Path diff --git a/stubs/seaborn/seaborn/_core/scales.pyi b/stubs/seaborn/seaborn/_core/scales.pyi index 8e164e265ef0..c294169ea554 100644 --- a/stubs/seaborn/seaborn/_core/scales.pyi +++ b/stubs/seaborn/seaborn/_core/scales.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Sequence from dataclasses import dataclass -from typing import Any, ClassVar, TypeAlias -from typing_extensions import Self +from typing import Any, ClassVar +from typing_extensions import Self, TypeAlias from matplotlib.axis import Ticker from matplotlib.scale import ScaleBase diff --git a/stubs/seaborn/seaborn/_core/typing.pyi b/stubs/seaborn/seaborn/_core/typing.pyi index c114bdf8f09f..415f818440ee 100644 --- a/stubs/seaborn/seaborn/_core/typing.pyi +++ b/stubs/seaborn/seaborn/_core/typing.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete from collections.abc import Iterable, Mapping from datetime import date, datetime, timedelta -from typing import Any, Protocol, TypeAlias, type_check_only +from typing import Any, Protocol, type_check_only +from typing_extensions import TypeAlias from matplotlib.colors import Colormap, Normalize from numpy import ndarray diff --git a/stubs/seaborn/seaborn/_marks/base.pyi b/stubs/seaborn/seaborn/_marks/base.pyi index 80989c2f4274..a1d029ff7547 100644 --- a/stubs/seaborn/seaborn/_marks/base.pyi +++ b/stubs/seaborn/seaborn/_marks/base.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from dataclasses import dataclass -from typing import Any, TypeAlias, TypeVar +from typing import Any, TypeVar +from typing_extensions import TypeAlias from numpy.typing import NDArray from pandas import DataFrame diff --git a/stubs/seaborn/seaborn/axisgrid.pyi b/stubs/seaborn/seaborn/axisgrid.pyi index 16ff332d4b74..1f4072570aeb 100644 --- a/stubs/seaborn/seaborn/axisgrid.pyi +++ b/stubs/seaborn/seaborn/axisgrid.pyi @@ -1,8 +1,8 @@ import os from _typeshed import Incomplete from collections.abc import Callable, Generator, Iterable, Mapping -from typing import IO, Any, Concatenate, Literal, TypeAlias, TypeVar -from typing_extensions import ParamSpec, Self, deprecated +from typing import IO, Any, Literal, TypeVar +from typing_extensions import Concatenate, ParamSpec, Self, TypeAlias, deprecated import numpy as np from matplotlib.artist import Artist diff --git a/stubs/seaborn/seaborn/distributions.pyi b/stubs/seaborn/seaborn/distributions.pyi index 036a0d9d4e43..06ecfb7197e0 100644 --- a/stubs/seaborn/seaborn/distributions.pyi +++ b/stubs/seaborn/seaborn/distributions.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import Any, Literal, Protocol, TypeAlias, TypeVar, type_check_only -from typing_extensions import deprecated +from typing import Any, Literal, Protocol, TypeVar, type_check_only +from typing_extensions import TypeAlias, deprecated from matplotlib.axes import Axes from matplotlib.colors import Colormap diff --git a/stubs/seaborn/seaborn/external/kde.pyi b/stubs/seaborn/seaborn/external/kde.pyi index 76769a3fd5f8..e886570721d1 100644 --- a/stubs/seaborn/seaborn/external/kde.pyi +++ b/stubs/seaborn/seaborn/external/kde.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Any, Literal, Protocol, TypeAlias, type_check_only +from typing import Any, Literal, Protocol, type_check_only +from typing_extensions import TypeAlias import numpy as np from numpy.typing import ArrayLike, NDArray diff --git a/stubs/seaborn/seaborn/matrix.pyi b/stubs/seaborn/seaborn/matrix.pyi index 6aae408d9808..34ba5bb99aad 100644 --- a/stubs/seaborn/seaborn/matrix.pyi +++ b/stubs/seaborn/seaborn/matrix.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Hashable, Iterable, Mapping, Sequence -from typing import Literal, TypeAlias, TypedDict, type_check_only -from typing_extensions import Self +from typing import Literal, TypedDict, type_check_only +from typing_extensions import Self, TypeAlias import numpy as np import pandas as pd diff --git a/stubs/seaborn/seaborn/palettes.pyi b/stubs/seaborn/seaborn/palettes.pyi index 133ead3504cf..64ea321d28e5 100644 --- a/stubs/seaborn/seaborn/palettes.pyi +++ b/stubs/seaborn/seaborn/palettes.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable, Sequence -from typing import Literal, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import Literal, TypeVar, overload +from typing_extensions import Self, TypeAlias from matplotlib.colors import Colormap, LinearSegmentedColormap, ListedColormap from matplotlib.typing import ColorType diff --git a/stubs/seaborn/seaborn/regression.pyi b/stubs/seaborn/seaborn/regression.pyi index eb4bd4412ad6..b3e79b0e7aa5 100644 --- a/stubs/seaborn/seaborn/regression.pyi +++ b/stubs/seaborn/seaborn/regression.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable -from typing import Any, Literal, TypeAlias, overload +from typing import Any, Literal, overload +from typing_extensions import TypeAlias import pandas as pd from matplotlib.axes import Axes diff --git a/stubs/seaborn/seaborn/relational.pyi b/stubs/seaborn/seaborn/relational.pyi index 7b4ebc48bf2c..7a7bde159a1c 100644 --- a/stubs/seaborn/seaborn/relational.pyi +++ b/stubs/seaborn/seaborn/relational.pyi @@ -1,5 +1,6 @@ from collections.abc import Iterable, Mapping, Sequence -from typing import Any, Literal, TypeAlias +from typing import Any, Literal +from typing_extensions import TypeAlias from matplotlib.axes import Axes from matplotlib.colors import Colormap diff --git a/stubs/seaborn/seaborn/utils.pyi b/stubs/seaborn/seaborn/utils.pyi index aa57881400d5..a54afc15ccd1 100644 --- a/stubs/seaborn/seaborn/utils.pyi +++ b/stubs/seaborn/seaborn/utils.pyi @@ -1,8 +1,8 @@ import datetime as dt from _typeshed import Incomplete, SupportsGetItem from collections.abc import Callable, Iterable, Mapping, Sequence -from typing import Any, Literal, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import deprecated +from typing import Any, Literal, SupportsIndex, TypeVar, overload +from typing_extensions import TypeAlias, deprecated import numpy as np import pandas as pd diff --git a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi index 9648d4f7986f..7ee78dababdc 100644 --- a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi +++ b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi @@ -1,8 +1,8 @@ from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused from collections.abc import Callable, Iterable, MutableSequence, Sequence from subprocess import _ENV -from typing import ClassVar, Final, Literal, TypeAlias, TypeVar, overload -from typing_extensions import TypeVarTuple, Unpack +from typing import ClassVar, Final, Literal, TypeVar, overload +from typing_extensions import TypeAlias, TypeVarTuple, Unpack _Macro: TypeAlias = tuple[str] | tuple[str, str | None] _StrPathT = TypeVar("_StrPathT", bound=StrPath) diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index a4085c7ecdf4..dcfc826db663 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite from collections.abc import Iterable, MutableMapping from re import Pattern -from typing import IO, ClassVar, Literal, TypeAlias, TypeVar, overload +from typing import IO, ClassVar, Literal, TypeVar, overload +from typing_extensions import TypeAlias from .cmd import Command diff --git a/stubs/setuptools/setuptools/build_meta.pyi b/stubs/setuptools/setuptools/build_meta.pyi index 45a733d1128d..04de70231d33 100644 --- a/stubs/setuptools/setuptools/build_meta.pyi +++ b/stubs/setuptools/setuptools/build_meta.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete, StrPath from collections.abc import Mapping from contextlib import _GeneratorContextManager -from typing import NoReturn, TypeAlias +from typing import NoReturn +from typing_extensions import TypeAlias from . import dist diff --git a/stubs/setuptools/setuptools/command/editable_wheel.pyi b/stubs/setuptools/setuptools/command/editable_wheel.pyi index d9aececdac84..615c0059db10 100644 --- a/stubs/setuptools/setuptools/command/editable_wheel.pyi +++ b/stubs/setuptools/setuptools/command/editable_wheel.pyi @@ -3,8 +3,8 @@ from collections.abc import Iterator, Mapping from enum import Enum from pathlib import Path from types import TracebackType -from typing import ClassVar, Protocol, TypeAlias -from typing_extensions import Self +from typing import ClassVar, Protocol +from typing_extensions import Self, TypeAlias from .. import Command, errors, namespaces from ..dist import Distribution diff --git a/stubs/setuptools/setuptools/config/setupcfg.pyi b/stubs/setuptools/setuptools/config/setupcfg.pyi index 35eb6821565f..7c78eefd9250 100644 --- a/stubs/setuptools/setuptools/config/setupcfg.pyi +++ b/stubs/setuptools/setuptools/config/setupcfg.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete, StrPath from abc import abstractmethod from collections.abc import Callable, Iterable -from typing import Any, ClassVar, Generic, TypeAlias, TypeVar +from typing import Any, ClassVar, Generic, TypeVar +from typing_extensions import TypeAlias from .._distutils.dist import DistributionMetadata from ..dist import Distribution diff --git a/stubs/setuptools/setuptools/warnings.pyi b/stubs/setuptools/setuptools/warnings.pyi index 81d3bcfb3922..6bb52b66dc9c 100644 --- a/stubs/setuptools/setuptools/warnings.pyi +++ b/stubs/setuptools/setuptools/warnings.pyi @@ -1,4 +1,4 @@ -from typing import TypeAlias +from typing_extensions import TypeAlias _DueDate: TypeAlias = tuple[int, int, int] # time tuple diff --git a/stubs/shapely/shapely/_geometry.pyi b/stubs/shapely/shapely/_geometry.pyi index 381f306867d9..3e1a92ca5ab0 100644 --- a/stubs/shapely/shapely/_geometry.pyi +++ b/stubs/shapely/shapely/_geometry.pyi @@ -1,5 +1,6 @@ from enum import IntEnum -from typing import Any, Literal, SupportsIndex, TypeAlias, overload +from typing import Any, Literal, SupportsIndex, overload +from typing_extensions import TypeAlias import numpy as np from numpy.typing import NDArray diff --git a/stubs/shapely/shapely/_typing.pyi b/stubs/shapely/shapely/_typing.pyi index 931dc2e7cc59..224af9553f03 100644 --- a/stubs/shapely/shapely/_typing.pyi +++ b/stubs/shapely/shapely/_typing.pyi @@ -1,7 +1,8 @@ import sys from _typeshed import SupportsWrite as SupportsWrite from collections.abc import Sequence -from typing import Any, Protocol, TypeAlias, TypeVar, type_check_only +from typing import Any, Protocol, TypeVar, type_check_only +from typing_extensions import TypeAlias import numpy as np from numpy.typing import NDArray diff --git a/stubs/shapely/shapely/affinity.pyi b/stubs/shapely/shapely/affinity.pyi index fbca24462789..aaaaef0c5969 100644 --- a/stubs/shapely/shapely/affinity.pyi +++ b/stubs/shapely/shapely/affinity.pyi @@ -1,5 +1,6 @@ from collections.abc import Collection -from typing import Literal, TypeAlias, overload +from typing import Literal, overload +from typing_extensions import TypeAlias from ._typing import GeoT from .geometry import Point diff --git a/stubs/shapely/shapely/creation.pyi b/stubs/shapely/shapely/creation.pyi index d009e3a06a63..193100448eaa 100644 --- a/stubs/shapely/shapely/creation.pyi +++ b/stubs/shapely/shapely/creation.pyi @@ -1,5 +1,6 @@ from collections.abc import Sequence -from typing import Literal, SupportsIndex, TypeAlias, overload +from typing import Literal, SupportsIndex, overload +from typing_extensions import TypeAlias import numpy as np from numpy.typing import NDArray diff --git a/stubs/shapely/shapely/geometry/linestring.pyi b/stubs/shapely/shapely/geometry/linestring.pyi index 7e0cc926a7ff..4c5b37ab4df0 100644 --- a/stubs/shapely/shapely/geometry/linestring.pyi +++ b/stubs/shapely/shapely/geometry/linestring.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import Literal, SupportsFloat, SupportsIndex, TypeAlias -from typing_extensions import Self +from typing import Literal, SupportsFloat, SupportsIndex +from typing_extensions import Self, TypeAlias from .._typing import ArrayLikeSeq from ..constructive import BufferJoinStyle diff --git a/stubs/shapely/shapely/geometry/point.pyi b/stubs/shapely/shapely/geometry/point.pyi index 41b429fc652c..f68ae98bc2ed 100644 --- a/stubs/shapely/shapely/geometry/point.pyi +++ b/stubs/shapely/shapely/geometry/point.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterable -from typing import TypeAlias, overload -from typing_extensions import Self +from typing import overload +from typing_extensions import Self, TypeAlias from .._typing import ArrayLikeSeq from .base import BaseGeometry diff --git a/stubs/shapely/shapely/geometry/polygon.pyi b/stubs/shapely/shapely/geometry/polygon.pyi index ee8feb530ea0..6d2fd90725a4 100644 --- a/stubs/shapely/shapely/geometry/polygon.pyi +++ b/stubs/shapely/shapely/geometry/polygon.pyi @@ -1,6 +1,6 @@ from collections.abc import Collection -from typing import NoReturn, TypeAlias, overload -from typing_extensions import Self +from typing import NoReturn, overload +from typing_extensions import Self, TypeAlias from .base import BaseGeometry from .linestring import LineString, _ConvertibleToLineString diff --git a/stubs/shapely/shapely/io.pyi b/stubs/shapely/shapely/io.pyi index fba4035f3328..54b17de3fa0d 100644 --- a/stubs/shapely/shapely/io.pyi +++ b/stubs/shapely/shapely/io.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete -from typing import Literal, TypeAlias, overload +from typing import Literal, overload +from typing_extensions import TypeAlias import numpy as np from numpy.typing import NDArray diff --git a/stubs/shapely/shapely/predicates.pyi b/stubs/shapely/shapely/predicates.pyi index e6e7466c1fe4..a9e39dfadead 100644 --- a/stubs/shapely/shapely/predicates.pyi +++ b/stubs/shapely/shapely/predicates.pyi @@ -1,4 +1,6 @@ -from typing import Any, Literal, TypeAlias, TypeGuard, overload +import sys +from typing import Any, Literal, overload +from typing_extensions import TypeAlias, TypeGuard import numpy as np from numpy.typing import NDArray @@ -7,8 +9,12 @@ from ._typing import ArrayLike, ArrayLikeSeq, OptGeoArrayLike, OptGeoArrayLikeSe from .geometry.base import BaseGeometry from .lib import Geometry -_NPTrue: TypeAlias = np.bool_[Literal[True]] -_NPFalse: TypeAlias = np.bool_[Literal[False]] +if sys.version_info >= (3, 10): + _NPTrue: TypeAlias = np.bool_[Literal[True]] + _NPFalse: TypeAlias = np.bool_[Literal[False]] +else: + _NPTrue: TypeAlias = np.bool_ + _NPFalse: TypeAlias = np.bool_ __all__ = [ "contains", diff --git a/stubs/shapely/shapely/strtree.pyi b/stubs/shapely/shapely/strtree.pyi index fda47412cd7a..0e03e3ffc338 100644 --- a/stubs/shapely/shapely/strtree.pyi +++ b/stubs/shapely/shapely/strtree.pyi @@ -1,4 +1,5 @@ -from typing import Any, Literal, SupportsIndex, TypeAlias, overload +from typing import Any, Literal, SupportsIndex, overload +from typing_extensions import TypeAlias import numpy as np from numpy.typing import NDArray diff --git a/stubs/simplejson/simplejson/__init__.pyi b/stubs/simplejson/simplejson/__init__.pyi index 7c523a8f603a..7705280f31ef 100644 --- a/stubs/simplejson/simplejson/__init__.pyi +++ b/stubs/simplejson/simplejson/__init__.pyi @@ -1,7 +1,8 @@ from _typeshed import SupportsRichComparison from collections import OrderedDict from collections.abc import Callable -from typing import IO, Any, TypeAlias, TypeVar, overload +from typing import IO, Any, TypeVar, overload +from typing_extensions import TypeAlias from simplejson.decoder import JSONDecoder as JSONDecoder from simplejson.encoder import JSONEncoder as JSONEncoder, JSONEncoderForHTML as JSONEncoderForHTML diff --git a/stubs/slumber/slumber/serialize.pyi b/stubs/slumber/slumber/serialize.pyi index 49a611cc084b..e806a448e9b8 100644 --- a/stubs/slumber/slumber/serialize.pyi +++ b/stubs/slumber/slumber/serialize.pyi @@ -1,4 +1,5 @@ -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias _Data: TypeAlias = str | bytes | bytearray diff --git a/stubs/tabulate/tabulate/__init__.pyi b/stubs/tabulate/tabulate/__init__.pyi index 28d2ddf55914..f258717ad56f 100644 --- a/stubs/tabulate/tabulate/__init__.pyi +++ b/stubs/tabulate/tabulate/__init__.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Container, Iterable, Mapping, Sequence -from typing import Any, Final, NamedTuple, TypeAlias -from typing_extensions import Self +from typing import Any, Final, NamedTuple +from typing_extensions import Self, TypeAlias from .version import __version__ as __version__ diff --git a/stubs/tensorflow/tensorflow/_aliases.pyi b/stubs/tensorflow/tensorflow/_aliases.pyi index 5793cc3a569d..6bc6918a6b21 100644 --- a/stubs/tensorflow/tensorflow/_aliases.pyi +++ b/stubs/tensorflow/tensorflow/_aliases.pyi @@ -2,7 +2,8 @@ # Everything in this module is private for stubs. There is no runtime equivalent. from collections.abc import Iterable, Mapping, Sequence -from typing import Any, Protocol, TypeAlias, TypeVar +from typing import Any, Protocol, TypeVar +from typing_extensions import TypeAlias import numpy as np import numpy.typing as npt diff --git a/stubs/tensorflow/tensorflow/bitwise.pyi b/stubs/tensorflow/tensorflow/bitwise.pyi index f01e1bbc1a82..2045d9987326 100644 --- a/stubs/tensorflow/tensorflow/bitwise.pyi +++ b/stubs/tensorflow/tensorflow/bitwise.pyi @@ -1,4 +1,5 @@ -from typing import Any, TypeAlias, overload +from typing import Any, overload +from typing_extensions import TypeAlias import numpy as np import tensorflow as tf diff --git a/stubs/tensorflow/tensorflow/compiler/xla/service/hlo_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/service/hlo_pb2.pyi index 48a158aefb60..9057959cc005 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/service/hlo_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/service/hlo_pb2.pyi @@ -17,8 +17,8 @@ protos as JSON, which includes the field names in the serialization. import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -27,6 +27,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.compiler.xla.xla_data_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _CustomCallSchedule: diff --git a/stubs/tensorflow/tensorflow/compiler/xla/service/metrics_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/service/metrics_pb2.pyi index fba3dafb4740..05eaf7379849 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/service/metrics_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/service/metrics_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -16,6 +16,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import google.protobuf.timestamp_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/compiler/xla/tsl/protobuf/test_log_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/tsl/protobuf/test_log_pb2.pyi index efaaa1719332..a0cd6ef6a44b 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/tsl/protobuf/test_log_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/tsl/protobuf/test_log_pb2.pyi @@ -5,8 +5,8 @@ Protocol messages for describing the results of benchmarks and unit tests.""" import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -15,6 +15,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import google.protobuf.wrappers_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/compiler/xla/xla_data_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/xla_data_pb2.pyi index 410c871a3792..de86f1c8f255 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/xla_data_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/xla_data_pb2.pyi @@ -19,14 +19,19 @@ limitations under the License. import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _PrimitiveType: diff --git a/stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi b/stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi index 3dfda71957ea..17820b9e12c0 100644 --- a/stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi +++ b/stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi @@ -19,8 +19,8 @@ limitations under the License. import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -30,6 +30,11 @@ import google.protobuf.message import tensorflow.compiler.xla.service.hlo_pb2 import tensorflow.compiler.xla.xla_data_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/framework/api_def_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/api_def_pb2.pyi index 33d3e9c582b2..b3d8c424234f 100644 --- a/stubs/tensorflow/tensorflow/core/framework/api_def_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/api_def_pb2.pyi @@ -7,8 +7,8 @@ overrides for client language op code generators. import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -16,6 +16,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.attr_value_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/framework/dataset_options_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/dataset_options_pb2.pyi index 42235b08f937..724249f3c540 100644 --- a/stubs/tensorflow/tensorflow/core/framework/dataset_options_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/dataset_options_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.model_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _AutoShardPolicy: diff --git a/stubs/tensorflow/tensorflow/core/framework/full_type_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/full_type_pb2.pyi index f7fe50b8b90b..8025593122d5 100644 --- a/stubs/tensorflow/tensorflow/core/framework/full_type_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/full_type_pb2.pyi @@ -5,14 +5,19 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _FullTypeId: diff --git a/stubs/tensorflow/tensorflow/core/framework/graph_transfer_info_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/graph_transfer_info_pb2.pyi index d215035a107f..bba887ced518 100644 --- a/stubs/tensorflow/tensorflow/core/framework/graph_transfer_info_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/graph_transfer_info_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.types_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/framework/model_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/model_pb2.pyi index 150b7725ee46..5f80b951a386 100644 --- a/stubs/tensorflow/tensorflow/core/framework/model_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/model_pb2.pyi @@ -5,14 +5,19 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _NodeClass: diff --git a/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi index 226880af238a..152ce34664ac 100644 --- a/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/optimized_function_graph_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -15,6 +15,11 @@ import google.protobuf.message import tensorflow.core.framework.graph_pb2 import tensorflow.core.framework.types_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/framework/summary_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/summary_pb2.pyi index 16180facbdad..848d802496f8 100644 --- a/stubs/tensorflow/tensorflow/core/framework/summary_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/summary_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.tensor_pb2 import tensorflow.tsl.protobuf.histogram_pb2 + +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions from tensorflow.tsl.protobuf.histogram_pb2 import HistogramProto as HistogramProto DESCRIPTOR: google.protobuf.descriptor.FileDescriptor diff --git a/stubs/tensorflow/tensorflow/core/framework/types_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/types_pb2.pyi index e368d062e5d2..18c74011593b 100644 --- a/stubs/tensorflow/tensorflow/core/framework/types_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/types_pb2.pyi @@ -4,13 +4,18 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DataType: diff --git a/stubs/tensorflow/tensorflow/core/framework/variable_pb2.pyi b/stubs/tensorflow/tensorflow/core/framework/variable_pb2.pyi index dafb2a02ce36..1341eee711e5 100644 --- a/stubs/tensorflow/tensorflow/core/framework/variable_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/framework/variable_pb2.pyi @@ -5,14 +5,19 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _VariableSynchronization: diff --git a/stubs/tensorflow/tensorflow/core/protobuf/config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/config_pb2.pyi index ba33c25c47ec..1930db2b79dd 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/config_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -21,6 +21,11 @@ import tensorflow.core.protobuf.rewriter_config_pb2 import tensorflow.tsl.protobuf.coordination_config_pb2 import tensorflow.tsl.protobuf.rpc_options_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/core_platform_payloads_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/core_platform_payloads_pb2.pyi index 71bf2b685a57..39763f66f4e6 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/core_platform_payloads_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/core_platform_payloads_pb2.pyi @@ -4,13 +4,18 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/data_service_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/data_service_pb2.pyi index 9db48a907212..cdafebecf7eb 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/data_service_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/data_service_pb2.pyi @@ -4,13 +4,18 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DeploymentMode: diff --git a/stubs/tensorflow/tensorflow/core/protobuf/debug_event_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/debug_event_pb2.pyi index 8d984ba3d659..2906b660d309 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/debug_event_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/debug_event_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -15,6 +15,11 @@ import google.protobuf.message import tensorflow.core.framework.graph_debug_info_pb2 import tensorflow.core.framework.tensor_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _TensorDebugMode: diff --git a/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi index ce514732ffb8..0779991c7dd3 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -15,6 +15,11 @@ import google.protobuf.message import tensorflow.core.framework.attr_value_pb2 import tensorflow.core.protobuf.verifier_config_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/saved_object_graph_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/saved_object_graph_pb2.pyi index a686181a2d54..ddc1f9d6a6ca 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/saved_object_graph_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/saved_object_graph_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -20,6 +20,11 @@ import tensorflow.core.framework.versions_pb2 import tensorflow.core.protobuf.struct_pb2 import tensorflow.core.protobuf.trackable_object_graph_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/saver_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/saver_pb2.pyi index 30b13a3daf67..42159a4dbb60 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/saver_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/saver_pb2.pyi @@ -4,13 +4,18 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/struct_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/struct_pb2.pyi index 2496f696b773..3d3bdfcaf808 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/struct_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/struct_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -16,6 +16,11 @@ import tensorflow.core.framework.tensor_pb2 import tensorflow.core.framework.tensor_shape_pb2 import tensorflow.core.framework.types_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tensor_bundle_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tensor_bundle_pb2.pyi index 34ff8bc16b6a..58f69470b734 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tensor_bundle_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tensor_bundle_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -17,6 +17,11 @@ import tensorflow.core.framework.tensor_slice_pb2 import tensorflow.core.framework.types_pb2 import tensorflow.core.framework.versions_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/compilation_result_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/compilation_result_pb2.pyi index 28c70f3cfca0..1220c78dc5f5 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/compilation_result_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/compilation_result_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -15,6 +15,11 @@ import google.protobuf.message import tensorflow.compiler.xla.service.hlo_pb2 import tensorflow.tsl.protobuf.error_codes_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/optimization_parameters_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/optimization_parameters_pb2.pyi index 556c44a4e4e6..9b914134520d 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/optimization_parameters_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/optimization_parameters_pb2.pyi @@ -4,8 +4,8 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper @@ -13,6 +13,11 @@ import google.protobuf.message import google.protobuf.wrappers_pb2 import tensorflow.compiler.xla.service.hlo_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/topology_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/topology_pb2.pyi index 9e13767d0d5e..574cd7a67e8e 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/topology_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/topology_pb2.pyi @@ -5,14 +5,19 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/tpu/tpu_embedding_configuration_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/tpu/tpu_embedding_configuration_pb2.pyi index 6ac17eba8944..32d67050f571 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/tpu/tpu_embedding_configuration_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/tpu/tpu_embedding_configuration_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.protobuf.tpu.optimization_parameters_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/protobuf/verifier_config_pb2.pyi b/stubs/tensorflow/tensorflow/core/protobuf/verifier_config_pb2.pyi index 03b90de11f1c..c65f7c9cdb24 100644 --- a/stubs/tensorflow/tensorflow/core/protobuf/verifier_config_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/protobuf/verifier_config_pb2.pyi @@ -4,13 +4,18 @@ isort:skip_file """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final diff --git a/stubs/tensorflow/tensorflow/core/util/event_pb2.pyi b/stubs/tensorflow/tensorflow/core/util/event_pb2.pyi index 4e5edb82484e..7a8ac4afd856 100644 --- a/stubs/tensorflow/tensorflow/core/util/event_pb2.pyi +++ b/stubs/tensorflow/tensorflow/core/util/event_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import tensorflow.core.framework.summary_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _WorkerHealth: diff --git a/stubs/tensorflow/tensorflow/io/__init__.pyi b/stubs/tensorflow/tensorflow/io/__init__.pyi index 593131b765b9..51f45b5fd315 100644 --- a/stubs/tensorflow/tensorflow/io/__init__.pyi +++ b/stubs/tensorflow/tensorflow/io/__init__.pyi @@ -1,7 +1,7 @@ from collections.abc import Iterable, Mapping from types import TracebackType -from typing import Literal, NamedTuple, TypeAlias -from typing_extensions import Self +from typing import Literal, NamedTuple +from typing_extensions import Self, TypeAlias from tensorflow._aliases import DTypeLike, ShapeLike, TensorCompatible, TensorLike from tensorflow.io import gfile as gfile diff --git a/stubs/tensorflow/tensorflow/keras/activations.pyi b/stubs/tensorflow/tensorflow/keras/activations.pyi index 2cdcf2d43593..262b1f173c94 100644 --- a/stubs/tensorflow/tensorflow/keras/activations.pyi +++ b/stubs/tensorflow/tensorflow/keras/activations.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias import numpy as np from tensorflow import Tensor diff --git a/stubs/tensorflow/tensorflow/keras/callbacks.pyi b/stubs/tensorflow/tensorflow/keras/callbacks.pyi index 74037b3a6501..22deff0be2e6 100644 --- a/stubs/tensorflow/tensorflow/keras/callbacks.pyi +++ b/stubs/tensorflow/tensorflow/keras/callbacks.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Mapping, Sequence -from typing import Any, Literal, TypeAlias +from typing import Any, Literal +from typing_extensions import TypeAlias import tensorflow as tf from requests.api import _HeadersMapping diff --git a/stubs/tensorflow/tensorflow/keras/initializers.pyi b/stubs/tensorflow/tensorflow/keras/initializers.pyi index fc6c7669ed70..f24c31b42ca4 100644 --- a/stubs/tensorflow/tensorflow/keras/initializers.pyi +++ b/stubs/tensorflow/tensorflow/keras/initializers.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable -from typing import Any, TypeAlias, overload -from typing_extensions import Self +from typing import Any, overload +from typing_extensions import Self, TypeAlias from tensorflow import Tensor from tensorflow._aliases import DTypeLike, ShapeLike, TensorCompatible diff --git a/stubs/tensorflow/tensorflow/keras/layers/__init__.pyi b/stubs/tensorflow/tensorflow/keras/layers/__init__.pyi index 427dcdc254c8..9764b04dbe0e 100644 --- a/stubs/tensorflow/tensorflow/keras/layers/__init__.pyi +++ b/stubs/tensorflow/tensorflow/keras/layers/__init__.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable, Sequence -from typing import Any, Generic, Literal, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, Generic, Literal, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias import tensorflow as tf from tensorflow import Tensor, Variable diff --git a/stubs/tensorflow/tensorflow/keras/losses.pyi b/stubs/tensorflow/tensorflow/keras/losses.pyi index 7b2eecbc9c2a..ebb96740637e 100644 --- a/stubs/tensorflow/tensorflow/keras/losses.pyi +++ b/stubs/tensorflow/tensorflow/keras/losses.pyi @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod from collections.abc import Callable -from typing import Any, Final, Literal, TypeAlias, TypeGuard, TypeVar, overload -from typing_extensions import Self +from typing import Any, Final, Literal, TypeVar, overload +from typing_extensions import Self, TypeAlias, TypeGuard from tensorflow import Tensor from tensorflow._aliases import KerasSerializable, TensorCompatible diff --git a/stubs/tensorflow/tensorflow/keras/metrics.pyi b/stubs/tensorflow/tensorflow/keras/metrics.pyi index e6f12a00c857..33b8a3fb623d 100644 --- a/stubs/tensorflow/tensorflow/keras/metrics.pyi +++ b/stubs/tensorflow/tensorflow/keras/metrics.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from abc import ABCMeta, abstractmethod from collections.abc import Callable, Iterable, Sequence from enum import Enum -from typing import Any, Literal, TypeAlias, type_check_only -from typing_extensions import Self +from typing import Any, Literal, type_check_only +from typing_extensions import Self, TypeAlias import tensorflow as tf from tensorflow import Operation, Tensor diff --git a/stubs/tensorflow/tensorflow/keras/models.pyi b/stubs/tensorflow/tensorflow/keras/models.pyi index aaf919a3573d..afbd68461ac5 100644 --- a/stubs/tensorflow/tensorflow/keras/models.pyi +++ b/stubs/tensorflow/tensorflow/keras/models.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Container, Iterator from pathlib import Path -from typing import Any, Literal, TypeAlias -from typing_extensions import Self, deprecated +from typing import Any, Literal +from typing_extensions import Self, TypeAlias, deprecated import numpy as np import numpy.typing as npt diff --git a/stubs/tensorflow/tensorflow/keras/optimizers/legacy/__init__.pyi b/stubs/tensorflow/tensorflow/keras/optimizers/legacy/__init__.pyi index 15fb8c0f7181..dc69ac7e2d51 100644 --- a/stubs/tensorflow/tensorflow/keras/optimizers/legacy/__init__.pyi +++ b/stubs/tensorflow/tensorflow/keras/optimizers/legacy/__init__.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Iterable -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias import tensorflow as tf from tensorflow._aliases import Gradients diff --git a/stubs/tensorflow/tensorflow/keras/regularizers.pyi b/stubs/tensorflow/tensorflow/keras/regularizers.pyi index 9935bd1c3a1b..448fb65870f3 100644 --- a/stubs/tensorflow/tensorflow/keras/regularizers.pyi +++ b/stubs/tensorflow/tensorflow/keras/regularizers.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable -from typing import Any, TypeAlias, overload -from typing_extensions import Self +from typing import Any, overload +from typing_extensions import Self, TypeAlias from tensorflow import Tensor diff --git a/stubs/tensorflow/tensorflow/math.pyi b/stubs/tensorflow/tensorflow/math.pyi index a9a6c6c4a6a6..b64aeae674b5 100644 --- a/stubs/tensorflow/tensorflow/math.pyi +++ b/stubs/tensorflow/tensorflow/math.pyi @@ -1,5 +1,6 @@ from collections.abc import Iterable -from typing import TypeAlias, TypeVar, overload +from typing import TypeVar, overload +from typing_extensions import TypeAlias from tensorflow import IndexedSlices, RaggedTensor, Tensor from tensorflow._aliases import DTypeLike, ShapeLike, TensorCompatible diff --git a/stubs/tensorflow/tensorflow/python/feature_column/feature_column_v2.pyi b/stubs/tensorflow/tensorflow/python/feature_column/feature_column_v2.pyi index 84571bb27921..e2f02fa4b40f 100644 --- a/stubs/tensorflow/tensorflow/python/feature_column/feature_column_v2.pyi +++ b/stubs/tensorflow/tensorflow/python/feature_column/feature_column_v2.pyi @@ -5,8 +5,8 @@ from _typeshed import Incomplete from abc import ABC, ABCMeta, abstractmethod from collections.abc import Callable, Sequence -from typing import Literal, TypeAlias -from typing_extensions import Self +from typing import Literal +from typing_extensions import Self, TypeAlias import tensorflow as tf from tensorflow._aliases import ShapeLike diff --git a/stubs/tensorflow/tensorflow/random.pyi b/stubs/tensorflow/tensorflow/random.pyi index 984773c69e7d..85884f19d6cb 100644 --- a/stubs/tensorflow/tensorflow/random.pyi +++ b/stubs/tensorflow/tensorflow/random.pyi @@ -1,6 +1,7 @@ from collections.abc import Sequence from enum import Enum -from typing import Literal, TypeAlias +from typing import Literal +from typing_extensions import TypeAlias import numpy as np import numpy.typing as npt diff --git a/stubs/tensorflow/tensorflow/saved_model/__init__.pyi b/stubs/tensorflow/tensorflow/saved_model/__init__.pyi index 96fe2cfeb342..c8244ba4f50e 100644 --- a/stubs/tensorflow/tensorflow/saved_model/__init__.pyi +++ b/stubs/tensorflow/tensorflow/saved_model/__init__.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from collections.abc import Mapping, Sequence from pathlib import Path -from typing import Any, Generic, Literal, TypeAlias, TypeVar -from typing_extensions import ParamSpec +from typing import Any, Generic, Literal, TypeVar +from typing_extensions import ParamSpec, TypeAlias import tensorflow as tf from tensorflow.python.training.tracking.autotrackable import AutoTrackable diff --git a/stubs/tensorflow/tensorflow/sparse.pyi b/stubs/tensorflow/tensorflow/sparse.pyi index d58e57f16a02..1cd1da7f361d 100644 --- a/stubs/tensorflow/tensorflow/sparse.pyi +++ b/stubs/tensorflow/tensorflow/sparse.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from abc import ABCMeta -from typing import TypeAlias +from typing_extensions import TypeAlias from tensorflow import Tensor, TensorShape from tensorflow._aliases import TensorCompatible diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_service_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_service_pb2.pyi index dbb7bf54242e..27721cfbefe4 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_service_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/coordination_service_pb2.pyi @@ -5,8 +5,8 @@ isort:skip_file import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.any_pb2 import google.protobuf.descriptor @@ -14,6 +14,11 @@ import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _CoordinatedTaskState: diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/dnn_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/dnn_pb2.pyi index bb9cd376f2ae..c8d947994d74 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/dnn_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/dnn_pb2.pyi @@ -5,8 +5,8 @@ LINT: LEGACY_NAMES""" import builtins import collections.abc +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.containers @@ -14,6 +14,11 @@ import google.protobuf.internal.enum_type_wrapper import google.protobuf.message import google.protobuf.wrappers_pb2 +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _DataType: diff --git a/stubs/tensorflow/tensorflow/tsl/protobuf/error_codes_pb2.pyi b/stubs/tensorflow/tensorflow/tsl/protobuf/error_codes_pb2.pyi index cc39f9f14eae..3b0b8dcf4b37 100644 --- a/stubs/tensorflow/tensorflow/tsl/protobuf/error_codes_pb2.pyi +++ b/stubs/tensorflow/tensorflow/tsl/protobuf/error_codes_pb2.pyi @@ -6,12 +6,17 @@ migrate. """ import builtins +import sys import typing -import typing as typing_extensions import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class _Code: diff --git a/stubs/toml/toml/decoder.pyi b/stubs/toml/toml/decoder.pyi index da0217df9391..131e164a34fe 100644 --- a/stubs/toml/toml/decoder.pyi +++ b/stubs/toml/toml/decoder.pyi @@ -2,7 +2,8 @@ from _typeshed import SupportsRead from collections.abc import Callable, MutableMapping from pathlib import PurePath from re import Pattern -from typing import Any, Generic, TypeAlias, TypeVar, overload +from typing import Any, Generic, TypeVar, overload +from typing_extensions import TypeAlias _MutableMappingT = TypeVar("_MutableMappingT", bound=MutableMapping[str, Any]) _PathLike: TypeAlias = str | bytes | PurePath diff --git a/stubs/ttkthemes/ttkthemes/_imgops.pyi b/stubs/ttkthemes/ttkthemes/_imgops.pyi index 5a65a25702a9..3322a352372a 100644 --- a/stubs/ttkthemes/ttkthemes/_imgops.pyi +++ b/stubs/ttkthemes/ttkthemes/_imgops.pyi @@ -1,4 +1,5 @@ -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias _Image: TypeAlias = Any # actually PIL.Image, but not worth adding a dependency diff --git a/stubs/uWSGI/uwsgi.pyi b/stubs/uWSGI/uwsgi.pyi index b605b8cf37ac..8d37a83ecf6b 100644 --- a/stubs/uWSGI/uwsgi.pyi +++ b/stubs/uWSGI/uwsgi.pyi @@ -2,8 +2,8 @@ from _typeshed import HasFileno, OptExcInfo, ReadOnlyBuffer from _typeshed.wsgi import WSGIApplication from collections.abc import Callable from types import ModuleType -from typing import Any, Literal, Protocol, TypeAlias, final, overload, type_check_only -from typing_extensions import Self +from typing import Any, Literal, Protocol, final, overload, type_check_only +from typing_extensions import Self, TypeAlias import uwsgidecorators diff --git a/stubs/waitress/waitress/adjustments.pyi b/stubs/waitress/waitress/adjustments.pyi index 2c3574a2a855..cd22f72bf0fb 100644 --- a/stubs/waitress/waitress/adjustments.pyi +++ b/stubs/waitress/waitress/adjustments.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete from collections.abc import Iterable, Sequence from socket import socket -from typing import Final, TypeAlias +from typing import Final +from typing_extensions import TypeAlias # Really complex, consider unpacking a TypedDict _AdjustmentsParams: TypeAlias = Incomplete diff --git a/stubs/waitress/waitress/wasyncore.pyi b/stubs/waitress/waitress/wasyncore.pyi index 788cbc8d2208..b50972143c27 100644 --- a/stubs/waitress/waitress/wasyncore.pyi +++ b/stubs/waitress/waitress/wasyncore.pyi @@ -4,7 +4,7 @@ from collections.abc import Mapping from io import BytesIO from logging import Logger from socket import _RetAddress, socket -from typing import TypeAlias +from typing_extensions import TypeAlias _Socket: TypeAlias = socket _SocketMap: TypeAlias = Mapping[int, socket] diff --git a/stubs/watchpoints/watchpoints/watch.pyi b/stubs/watchpoints/watchpoints/watch.pyi index bc9e9efbc61a..a10b9c456beb 100644 --- a/stubs/watchpoints/watchpoints/watch.pyi +++ b/stubs/watchpoints/watchpoints/watch.pyi @@ -3,7 +3,8 @@ from _typeshed import SupportsWrite, TraceFunction from collections.abc import Callable from pdb import Pdb from types import FrameType -from typing import Any, Literal, Protocol, TypeAlias, TypeVar, type_check_only +from typing import Any, Literal, Protocol, TypeVar, type_check_only +from typing_extensions import TypeAlias from .watch_element import WatchElement diff --git a/stubs/watchpoints/watchpoints/watch_element.pyi b/stubs/watchpoints/watchpoints/watch_element.pyi index 3bb23d966fed..b99f7e65f1c3 100644 --- a/stubs/watchpoints/watchpoints/watch_element.pyi +++ b/stubs/watchpoints/watchpoints/watch_element.pyi @@ -1,7 +1,8 @@ import ast from collections.abc import Callable, Iterable from types import FrameType -from typing import Any, Literal, TypeAlias, TypeVar +from typing import Any, Literal, TypeVar +from typing_extensions import TypeAlias from .watch_print import WatchPrint diff --git a/stubs/workalendar/workalendar/asia/israel.pyi b/stubs/workalendar/workalendar/asia/israel.pyi index c5de8f97ff0e..7b55f6a1ec86 100644 --- a/stubs/workalendar/workalendar/asia/israel.pyi +++ b/stubs/workalendar/workalendar/asia/israel.pyi @@ -1,5 +1,6 @@ import datetime -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from ..core import Calendar diff --git a/stubs/workalendar/workalendar/usa/florida.pyi b/stubs/workalendar/workalendar/usa/florida.pyi index 00317912d0e9..127f679fc4e6 100644 --- a/stubs/workalendar/workalendar/usa/florida.pyi +++ b/stubs/workalendar/workalendar/usa/florida.pyi @@ -1,5 +1,6 @@ import datetime -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from .core import UnitedStates diff --git a/stubs/wurlitzer/wurlitzer.pyi b/stubs/wurlitzer/wurlitzer.pyi index eee899a1e1ee..848c6383f04c 100644 --- a/stubs/wurlitzer/wurlitzer.pyi +++ b/stubs/wurlitzer/wurlitzer.pyi @@ -7,8 +7,8 @@ from _typeshed import SupportsWrite from contextlib import _GeneratorContextManager from threading import Thread from types import TracebackType -from typing import Any, Final, Literal, Protocol, TextIO, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing import Any, Final, Literal, Protocol, TextIO, TypeVar, overload, type_check_only +from typing_extensions import Self, TypeAlias STDOUT: Final = 2 PIPE: Final = 3 diff --git a/stubs/xmldiff/xmldiff/main.pyi b/stubs/xmldiff/xmldiff/main.pyi index 46d521b90474..78fcb4b31af7 100644 --- a/stubs/xmldiff/xmldiff/main.pyi +++ b/stubs/xmldiff/xmldiff/main.pyi @@ -1,6 +1,7 @@ from argparse import ArgumentParser from collections.abc import Iterable, Mapping, Sequence -from typing import Any, TypeAlias, overload +from typing import Any, overload +from typing_extensions import TypeAlias from xmldiff.actions import ( DeleteAttrib, diff --git a/stubs/xmltodict/xmltodict.pyi b/stubs/xmltodict/xmltodict.pyi index 6edb52a2fae2..937db619e499 100644 --- a/stubs/xmltodict/xmltodict.pyi +++ b/stubs/xmltodict/xmltodict.pyi @@ -1,6 +1,7 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Callable, Container, Generator, Mapping -from typing import Any, TypeAlias, overload +from typing import Any, overload +from typing_extensions import TypeAlias class ParsingInterrupted(Exception): ... diff --git a/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi b/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi index 4648784a5beb..785d62ddc96c 100644 --- a/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi +++ b/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi @@ -2,8 +2,8 @@ import types from collections.abc import Callable, Collection, Iterable, Iterator, Mapping from functools import cached_property from types import TracebackType -from typing import Any, TypeAlias -from typing_extensions import Self +from typing import Any +from typing_extensions import Self, TypeAlias from urllib.request import Request from yt_dlp.cache import Cache diff --git a/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi b/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi index dcffac8ec8dd..98ad67c2b7d5 100644 --- a/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi +++ b/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi @@ -1,5 +1,6 @@ from collections.abc import Mapping -from typing import Any, Literal, TypeAlias +from typing import Any, Literal +from typing_extensions import TypeAlias from ..extractor.common import _InfoDict from ..utils._utils import NO_DEFAULT diff --git a/stubs/yt-dlp/yt_dlp/extractor/common.pyi b/stubs/yt-dlp/yt_dlp/extractor/common.pyi index 882a504087d5..d977586c5182 100644 --- a/stubs/yt-dlp/yt_dlp/extractor/common.pyi +++ b/stubs/yt-dlp/yt_dlp/extractor/common.pyi @@ -3,8 +3,8 @@ from _typeshed import Incomplete, Unused from collections.abc import Callable, Collection, Iterable, Iterator, Mapping, Sequence from functools import cached_property from json.decoder import JSONDecoder -from typing import Any, ClassVar, Literal, TypeAlias, TypedDict, TypeVar, overload, type_check_only -from typing_extensions import Never, Required, deprecated +from typing import Any, ClassVar, Literal, TypedDict, TypeVar, overload, type_check_only +from typing_extensions import Never, Required, TypeAlias, deprecated from urllib.request import Request, _DataType from xml.etree import ElementTree as ET diff --git a/stubs/yt-dlp/yt_dlp/jsinterp.pyi b/stubs/yt-dlp/yt_dlp/jsinterp.pyi index f12c93d3fc46..4fbd25299b5c 100644 --- a/stubs/yt-dlp/yt_dlp/jsinterp.pyi +++ b/stubs/yt-dlp/yt_dlp/jsinterp.pyi @@ -1,7 +1,8 @@ import collections import types from collections.abc import Callable, Collection, Iterable, Mapping -from typing import Any, NoReturn, TypeAlias +from typing import Any, NoReturn +from typing_extensions import TypeAlias from yt_dlp.extractor.common import InfoExtractor from yt_dlp.utils._utils import function_with_repr diff --git a/stubs/yt-dlp/yt_dlp/networking/_helper.pyi b/stubs/yt-dlp/yt_dlp/networking/_helper.pyi index d0e48da6604a..d93a606440ad 100644 --- a/stubs/yt-dlp/yt_dlp/networking/_helper.pyi +++ b/stubs/yt-dlp/yt_dlp/networking/_helper.pyi @@ -3,7 +3,8 @@ from _socket import _Address from _typeshed import StrOrBytesPath from collections.abc import Callable, Iterable, Mapping from socket import AddressFamily, SocketKind -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias from ..socks import sockssocket from ..utils.networking import HTTPHeaderDict diff --git a/stubs/yt-dlp/yt_dlp/networking/common.pyi b/stubs/yt-dlp/yt_dlp/networking/common.pyi index bb600721f6e2..3c0f077ccb0a 100644 --- a/stubs/yt-dlp/yt_dlp/networking/common.pyi +++ b/stubs/yt-dlp/yt_dlp/networking/common.pyi @@ -5,8 +5,8 @@ from _typeshed import Unused from collections.abc import Callable, Iterable, Mapping from email.message import Message from logging import Logger -from typing import IO, Any, Final, TypeAlias -from typing_extensions import Self +from typing import IO, Any, Final +from typing_extensions import Self, TypeAlias from ..cookies import YoutubeDLCookieJar from ..utils._utils import _YDLLogger diff --git a/stubs/yt-dlp/yt_dlp/utils/_utils.pyi b/stubs/yt-dlp/yt_dlp/utils/_utils.pyi index 2d579b230a79..73e25f4453da 100644 --- a/stubs/yt-dlp/yt_dlp/utils/_utils.pyi +++ b/stubs/yt-dlp/yt_dlp/utils/_utils.pyi @@ -23,8 +23,8 @@ from functools import cache from optparse import Values from os import PathLike from re import Pattern -from typing import IO, Any, AnyStr, BinaryIO, Final, Generic, Literal, NamedTuple, TextIO, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing import IO, Any, AnyStr, BinaryIO, Final, Generic, Literal, NamedTuple, TextIO, TypeVar, overload +from typing_extensions import Self, TypeAlias from urllib.parse import _QueryType, _QuoteVia from xml.etree import ElementTree as ET diff --git a/stubs/yt-dlp/yt_dlp/utils/traversal.pyi b/stubs/yt-dlp/yt_dlp/utils/traversal.pyi index f50ace1d4f80..a59073a2b380 100644 --- a/stubs/yt-dlp/yt_dlp/utils/traversal.pyi +++ b/stubs/yt-dlp/yt_dlp/utils/traversal.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Collection, Iterable, Mapping -from typing import Any, TypeAlias, TypeVar, overload +from typing import Any, TypeVar, overload +from typing_extensions import TypeAlias from ._utils import NO_DEFAULT, ExtractorError diff --git a/stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi b/stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi index 260ad8b3b441..8b1e8e82331e 100644 --- a/stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi +++ b/stubs/zxcvbn/zxcvbn/adjacency_graphs.pyi @@ -1,4 +1,4 @@ -from typing import TypeAlias +from typing_extensions import TypeAlias _Graph: TypeAlias = dict[str, list[str | None]] diff --git a/tests/mypy_test.py b/tests/mypy_test.py index c9b3993839b9..dfc7adba8062 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -16,7 +16,8 @@ from itertools import product from pathlib import Path from threading import Lock -from typing import Annotated, Any, NamedTuple, TypeAlias +from typing import Annotated, Any, NamedTuple +from typing_extensions import TypeAlias from packaging.requirements import Requirement diff --git a/tests/regr_test.py b/tests/regr_test.py index f942e9d0f238..b37509ad9f83 100755 --- a/tests/regr_test.py +++ b/tests/regr_test.py @@ -19,7 +19,7 @@ from enum import IntEnum from functools import partial from pathlib import Path -from typing import TypeAlias +from typing_extensions import TypeAlias from ts_utils.metadata import get_recursive_requirements, read_metadata from ts_utils.mypy import mypy_configuration_from_distribution, temporary_mypy_config_file diff --git a/tests/stubtest_stdlib.py b/tests/stubtest_stdlib.py index 4522a68691d5..ac794eb4bacd 100755 --- a/tests/stubtest_stdlib.py +++ b/tests/stubtest_stdlib.py @@ -32,6 +32,10 @@ def run_stubtest(typeshed_dir: Path) -> int: str(typeshed_dir), *allowlist_stubtest_arguments("stdlib"), ] + if sys.version_info < (3, 10): + # As discussed in https://github.com/python/typeshed/issues/3693, we only aim for + # positional-only arg accuracy for python 3.10 and above. + cmd += ["--ignore-positional-only"] print(" ".join(cmd), file=sys.stderr) try: subprocess.run(cmd, check=True) diff --git a/tests/typecheck_typeshed.py b/tests/typecheck_typeshed.py index 6ddbb90a8a5b..63449e4d4ee3 100755 --- a/tests/typecheck_typeshed.py +++ b/tests/typecheck_typeshed.py @@ -7,7 +7,7 @@ import subprocess import sys from itertools import product -from typing import TypeAlias +from typing_extensions import TypeAlias from ts_utils.utils import colored, print_error From 98c64a43567c047081b100521019a93e3fd1b730 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 9 Feb 2026 14:36:19 +0100 Subject: [PATCH 5/7] Ignore even more ruff codes for now --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6105f7287195..cbce36b45bc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,10 +148,13 @@ extend-safe-fixes = [ ] ignore = [ ### - # TODO: Disabled temporarily, until Python 3.9 branches are removed in + # TODO: Disabled temporarily, until Python 3.9 support is fully removed in # May 2026. ### "E402", # module level import not at top of file + "UP035", # import from typing + "UP036", # Remove unnecessary `sys.version_info` blocks + "RUF100", # Remove unused `noqa` directive ### # Rules that can conflict with the formatter (Black) # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules From d0af39252985671cd328fc1d44ae1065e1df7a12 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 9 Feb 2026 16:23:59 +0100 Subject: [PATCH 6/7] Re-enable E402 --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cbce36b45bc3..7ab525581fbf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -151,7 +151,6 @@ ignore = [ # TODO: Disabled temporarily, until Python 3.9 support is fully removed in # May 2026. ### - "E402", # module level import not at top of file "UP035", # import from typing "UP036", # Remove unnecessary `sys.version_info` blocks "RUF100", # Remove unused `noqa` directive From 2a40de282117c38300e1c2a6784a08159758e276 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 9 Feb 2026 16:26:03 +0100 Subject: [PATCH 7/7] Move RUF100 disable into noqa comments --- pyproject.toml | 1 - stdlib/_collections_abc.pyi | 2 +- stdlib/builtins.pyi | 2 +- stdlib/typing_extensions.pyi | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7ab525581fbf..b17677df41af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -153,7 +153,6 @@ ignore = [ ### "UP035", # import from typing "UP036", # Remove unnecessary `sys.version_info` blocks - "RUF100", # Remove unused `noqa` directive ### # Rules that can conflict with the formatter (Black) # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules diff --git a/stdlib/_collections_abc.pyi b/stdlib/_collections_abc.pyi index 319577c9284b..0fa81662dfbc 100644 --- a/stdlib/_collections_abc.pyi +++ b/stdlib/_collections_abc.pyi @@ -1,7 +1,7 @@ import sys from abc import abstractmethod from types import MappingProxyType -from typing import ( # noqa: Y022,Y038,UP035,Y057 +from typing import ( # noqa: Y022,Y038,UP035,Y057,RUF100 AbstractSet as Set, AsyncGenerator as AsyncGenerator, AsyncIterable as AsyncIterable, diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index efc51fe257ae..3c505241b352 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -37,7 +37,7 @@ from types import CellType, CodeType, GenericAlias, TracebackType # mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping} # are imported from collections.abc in builtins.pyi -from typing import ( # noqa: Y022,UP035 +from typing import ( # noqa: Y022,UP035,RUF100 IO, Any, BinaryIO, diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 8a9f0f3919ba..16cf0611a58a 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -30,7 +30,7 @@ from collections.abc import ( from contextlib import AbstractAsyncContextManager as AsyncContextManager, AbstractContextManager as ContextManager from re import Match as Match, Pattern as Pattern from types import GenericAlias, ModuleType -from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035 +from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035,RUF100 IO as IO, TYPE_CHECKING as TYPE_CHECKING, AbstractSet as AbstractSet,