From d5a67a2b7cb75777e3cf0c9edd6456c7888080a8 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 17:49:47 +0300 Subject: [PATCH 01/13] run script --- stdlib/_ast.pyi | 66 +- stdlib/_bisect.pyi | 20 +- stdlib/_codecs.pyi | 82 +-- stdlib/_compression.pyi | 2 +- stdlib/_csv.pyi | 4 +- stdlib/_curses.pyi | 8 +- stdlib/_dummy_thread.pyi | 6 +- stdlib/_dummy_threading.pyi | 52 +- stdlib/_json.pyi | 4 +- stdlib/_msi.pyi | 6 +- stdlib/_osx_support.pyi | 8 +- stdlib/_sitebuiltins.pyi | 2 +- stdlib/_socket.pyi | 6 +- stdlib/_thread.pyi | 10 +- stdlib/_tracemalloc.pyi | 2 +- stdlib/_typeshed/wsgi.pyi | 2 +- stdlib/_typeshed/xml.pyi | 4 +- stdlib/_warnings.pyi | 20 +- stdlib/_weakref.pyi | 8 +- stdlib/_weakrefset.pyi | 14 +- stdlib/_winapi.pyi | 18 +- stdlib/aifc.pyi | 12 +- stdlib/argparse.pyi | 182 ++--- stdlib/array.pyi | 10 +- stdlib/ast.pyi | 26 +- stdlib/asynchat.pyi | 6 +- stdlib/asyncio/base_events.pyi | 126 ++-- stdlib/asyncio/base_subprocess.pyi | 26 +- stdlib/asyncio/base_tasks.pyi | 4 +- stdlib/asyncio/events.pyi | 146 ++-- stdlib/asyncio/exceptions.pyi | 4 +- stdlib/asyncio/format_helpers.pyi | 6 +- stdlib/asyncio/futures.pyi | 12 +- stdlib/asyncio/locks.pyi | 20 +- stdlib/asyncio/proactor_events.pyi | 32 +- stdlib/asyncio/protocols.pyi | 6 +- stdlib/asyncio/queues.pyi | 2 +- stdlib/asyncio/runners.pyi | 2 +- stdlib/asyncio/selector_events.pyi | 2 +- stdlib/asyncio/sslproto.pyi | 44 +- stdlib/asyncio/staggered.pyi | 6 +- stdlib/asyncio/streams.pyi | 38 +- stdlib/asyncio/subprocess.pyi | 96 +-- stdlib/asyncio/tasks.pyi | 110 +-- stdlib/asyncio/transports.pyi | 12 +- stdlib/asyncio/trsock.pyi | 20 +- stdlib/asyncio/unix_events.pyi | 12 +- stdlib/asyncio/windows_events.pyi | 6 +- stdlib/asyncio/windows_utils.pyi | 2 +- stdlib/asyncore.pyi | 30 +- stdlib/audioop.pyi | 6 +- stdlib/base64.pyi | 18 +- stdlib/bdb.pyi | 44 +- stdlib/binascii.pyi | 14 +- stdlib/builtins.pyi | 294 ++++---- stdlib/bz2.pyi | 34 +- stdlib/cProfile.pyi | 8 +- stdlib/calendar.pyi | 8 +- stdlib/cgi.pyi | 28 +- stdlib/cgitb.pyi | 16 +- stdlib/cmd.pyi | 20 +- stdlib/codecs.pyi | 66 +- stdlib/codeop.pyi | 4 +- stdlib/collections/__init__.pyi | 90 +-- stdlib/compileall.pyi | 48 +- stdlib/concurrent/futures/_base.pyi | 14 +- stdlib/concurrent/futures/process.pyi | 8 +- stdlib/concurrent/futures/thread.pyi | 6 +- stdlib/configparser.pyi | 86 +-- stdlib/contextlib.pyi | 14 +- stdlib/contextvars.pyi | 6 +- stdlib/copy.pyi | 2 +- stdlib/copyreg.pyi | 4 +- stdlib/crypt.pyi | 6 +- stdlib/csv.pyi | 22 +- stdlib/ctypes/__init__.pyi | 34 +- stdlib/ctypes/util.pyi | 4 +- stdlib/curses/ascii.pyi | 32 +- stdlib/curses/textpad.pyi | 4 +- stdlib/dataclasses.pyi | 38 +- stdlib/datetime.pyi | 40 +- stdlib/dbm/__init__.pyi | 2 +- stdlib/dbm/dumb.pyi | 2 +- stdlib/dbm/gnu.pyi | 10 +- stdlib/dbm/ndbm.pyi | 6 +- stdlib/decimal.pyi | 104 +-- stdlib/difflib.pyi | 14 +- stdlib/dis.pyi | 20 +- stdlib/distutils/archive_util.pyi | 14 +- stdlib/distutils/ccompiler.pyi | 116 ++-- stdlib/distutils/cmd.pyi | 26 +- stdlib/distutils/core.pyi | 6 +- stdlib/distutils/debug.pyi | 2 +- stdlib/distutils/dist.pyi | 48 +- stdlib/distutils/extension.pyi | 28 +- stdlib/distutils/fancy_getopt.pyi | 12 +- stdlib/distutils/file_util.pyi | 2 +- stdlib/distutils/filelist.pyi | 38 +- stdlib/distutils/spawn.pyi | 2 +- stdlib/distutils/sysconfig.pyi | 8 +- stdlib/distutils/text_file.pyi | 8 +- stdlib/distutils/version.pyi | 24 +- stdlib/doctest.pyi | 90 +-- stdlib/email/_header_value_parser.pyi | 20 +- stdlib/email/charset.pyi | 10 +- stdlib/email/errors.pyi | 4 +- stdlib/email/generator.pyi | 24 +- stdlib/email/header.pyi | 20 +- stdlib/email/headerregistry.pyi | 16 +- stdlib/email/iterators.pyi | 2 +- stdlib/email/message.pyi | 54 +- stdlib/email/mime/application.pyi | 4 +- stdlib/email/mime/audio.pyi | 6 +- stdlib/email/mime/base.pyi | 2 +- stdlib/email/mime/image.pyi | 6 +- stdlib/email/mime/message.pyi | 2 +- stdlib/email/mime/multipart.pyi | 6 +- stdlib/email/mime/text.pyi | 2 +- stdlib/email/parser.pyi | 4 +- stdlib/email/policy.pyi | 6 +- stdlib/email/utils.pyi | 18 +- stdlib/encodings/__init__.pyi | 4 +- stdlib/encodings/utf_8.pyi | 10 +- stdlib/ensurepip/__init__.pyi | 2 +- stdlib/enum.pyi | 14 +- stdlib/filecmp.pyi | 16 +- stdlib/fileinput.pyi | 12 +- stdlib/formatter.pyi | 34 +- stdlib/fractions.pyi | 38 +- stdlib/ftplib.pyi | 48 +- stdlib/functools.pyi | 12 +- stdlib/gc.pyi | 2 +- stdlib/genericpath.pyi | 4 +- stdlib/getpass.pyi | 2 +- stdlib/gettext.pyi | 32 +- stdlib/glob.pyi | 6 +- stdlib/graphlib.pyi | 2 +- stdlib/grp.pyi | 2 +- stdlib/gzip.pyi | 60 +- stdlib/hashlib.pyi | 10 +- stdlib/heapq.pyi | 6 +- stdlib/hmac.pyi | 6 +- stdlib/html/parser.pyi | 6 +- stdlib/http/client.pyi | 68 +- stdlib/http/cookiejar.pyi | 60 +- stdlib/http/cookies.pyi | 16 +- stdlib/http/server.pyi | 12 +- stdlib/imaplib.pyi | 46 +- stdlib/imghdr.pyi | 6 +- stdlib/imp.pyi | 14 +- stdlib/importlib/__init__.pyi | 8 +- stdlib/importlib/abc.pyi | 30 +- stdlib/importlib/machinery.pyi | 52 +- stdlib/importlib/metadata.pyi | 22 +- stdlib/importlib/util.pyi | 18 +- stdlib/inspect.pyi | 100 +-- stdlib/io.pyi | 52 +- stdlib/ipaddress.pyi | 16 +- stdlib/itertools.pyi | 14 +- stdlib/json/__init__.pyi | 44 +- stdlib/json/decoder.pyi | 10 +- stdlib/json/encoder.pyi | 6 +- stdlib/lib2to3/pgen2/driver.pyi | 6 +- stdlib/lib2to3/pgen2/parse.pyi | 16 +- stdlib/lib2to3/pgen2/pgen.pyi | 8 +- stdlib/lib2to3/pytree.pyi | 36 +- stdlib/locale.pyi | 10 +- stdlib/logging/__init__.pyi | 216 +++--- stdlib/logging/config.pyi | 12 +- stdlib/logging/handlers.pyi | 84 +-- stdlib/lzma.pyi | 66 +- stdlib/macpath.pyi | 2 +- stdlib/macurl2path.pyi | 2 +- stdlib/mailbox.pyi | 46 +- stdlib/mailcap.pyi | 2 +- stdlib/math.pyi | 2 +- stdlib/mimetypes.pyi | 14 +- stdlib/mmap.pyi | 6 +- stdlib/modulefinder.pyi | 22 +- stdlib/msilib/__init__.pyi | 60 +- stdlib/msilib/schema.pyi | 2 +- stdlib/msilib/text.pyi | 4 +- stdlib/multiprocessing/__init__.pyi | 16 +- stdlib/multiprocessing/connection.pyi | 20 +- stdlib/multiprocessing/context.pyi | 46 +- stdlib/multiprocessing/dummy/__init__.pyi | 8 +- stdlib/multiprocessing/dummy/connection.pyi | 10 +- stdlib/multiprocessing/managers.pyi | 34 +- stdlib/multiprocessing/pool.pyi | 46 +- stdlib/multiprocessing/process.pyi | 16 +- stdlib/multiprocessing/queues.pyi | 4 +- stdlib/multiprocessing/shared_memory.pyi | 4 +- stdlib/multiprocessing/sharedctypes.pyi | 48 +- stdlib/multiprocessing/spawn.pyi | 2 +- stdlib/multiprocessing/synchronize.pyi | 16 +- stdlib/netrc.pyi | 10 +- stdlib/nntplib.pyi | 32 +- stdlib/numbers.pyi | 2 +- stdlib/opcode.pyi | 4 +- stdlib/optparse.pyi | 80 +-- stdlib/os/__init__.pyi | 140 ++-- stdlib/pathlib.pyi | 34 +- stdlib/pdb.pyi | 106 +-- stdlib/pickle.pyi | 22 +- stdlib/pickletools.pyi | 20 +- stdlib/pkgutil.pyi | 16 +- stdlib/platform.pyi | 2 +- stdlib/plistlib.pyi | 12 +- stdlib/poplib.pyi | 10 +- stdlib/posix.pyi | 14 +- stdlib/posixpath.pyi | 6 +- stdlib/pprint.pyi | 38 +- stdlib/profile.pyi | 8 +- stdlib/pstats.pyi | 12 +- stdlib/pty.pyi | 2 +- stdlib/py_compile.pyi | 22 +- stdlib/pyclbr.pyi | 14 +- stdlib/pydoc.pyi | 106 +-- stdlib/pyexpat/__init__.pyi | 58 +- stdlib/queue.pyi | 8 +- stdlib/random.pyi | 28 +- stdlib/re.pyi | 18 +- stdlib/readline.pyi | 12 +- stdlib/rlcompleter.pyi | 4 +- stdlib/runpy.pyi | 4 +- stdlib/sched.pyi | 2 +- stdlib/secrets.pyi | 6 +- stdlib/select.pyi | 16 +- stdlib/selectors.pyi | 14 +- stdlib/shelve.pyi | 12 +- stdlib/shlex.pyi | 8 +- stdlib/shutil.pyi | 32 +- stdlib/signal.pyi | 4 +- stdlib/site.pyi | 10 +- stdlib/smtpd.pyi | 16 +- stdlib/smtplib.pyi | 62 +- stdlib/sndhdr.pyi | 6 +- stdlib/socket.pyi | 46 +- stdlib/socketserver.pyi | 14 +- stdlib/sqlite3/dbapi2.pyi | 24 +- stdlib/sre_compile.pyi | 2 +- stdlib/sre_constants.pyi | 6 +- stdlib/sre_parse.pyi | 28 +- stdlib/ssl.pyi | 138 ++-- stdlib/statistics.pyi | 18 +- stdlib/string.pyi | 8 +- stdlib/struct.pyi | 14 +- stdlib/subprocess.pyi | 610 ++++++++--------- stdlib/sunau.pyi | 6 +- stdlib/symtable.pyi | 4 +- stdlib/sys.pyi | 32 +- stdlib/sysconfig.pyi | 8 +- stdlib/tarfile.pyi | 246 +++---- stdlib/telnetlib.pyi | 12 +- stdlib/tempfile.pyi | 224 +++---- stdlib/textwrap.pyi | 6 +- stdlib/threading.pyi | 52 +- stdlib/time.pyi | 24 +- stdlib/timeit.pyi | 12 +- stdlib/tkinter/__init__.pyi | 626 +++++++++--------- stdlib/tkinter/colorchooser.pyi | 4 +- stdlib/tkinter/commondialog.pyi | 6 +- stdlib/tkinter/dialog.pyi | 2 +- stdlib/tkinter/dnd.pyi | 10 +- stdlib/tkinter/filedialog.pyi | 14 +- stdlib/tkinter/font.pyi | 36 +- stdlib/tkinter/messagebox.pyi | 16 +- stdlib/tkinter/scrolledtext.pyi | 2 +- stdlib/tkinter/simpledialog.pyi | 20 +- stdlib/tkinter/tix.pyi | 96 +-- stdlib/tkinter/ttk.pyi | 280 ++++---- stdlib/tokenize.pyi | 6 +- stdlib/trace.pyi | 26 +- stdlib/traceback.pyi | 84 +-- stdlib/tracemalloc.pyi | 20 +- stdlib/turtle.pyi | 114 ++-- stdlib/types.pyi | 54 +- stdlib/typing.pyi | 102 +-- stdlib/typing_extensions.pyi | 10 +- stdlib/unicodedata.pyi | 20 +- stdlib/unittest/__init__.pyi | 2 +- stdlib/unittest/case.pyi | 94 +-- stdlib/unittest/loader.pyi | 10 +- stdlib/unittest/main.pyi | 34 +- stdlib/unittest/mock.pyi | 134 ++-- stdlib/unittest/result.pyi | 4 +- stdlib/unittest/runner.pyi | 8 +- stdlib/urllib/error.pyi | 6 +- stdlib/urllib/parse.pyi | 42 +- stdlib/urllib/request.pyi | 162 ++--- stdlib/urllib/response.pyi | 6 +- stdlib/urllib/robotparser.pyi | 6 +- stdlib/uu.pyi | 6 +- stdlib/uuid.pyi | 28 +- stdlib/venv/__init__.pyi | 12 +- stdlib/warnings.pyi | 34 +- stdlib/wave.pyi | 4 +- stdlib/weakref.pyi | 14 +- stdlib/webbrowser.pyi | 10 +- stdlib/winreg.pyi | 14 +- stdlib/winsound.pyi | 4 +- stdlib/wsgiref/handlers.pyi | 10 +- stdlib/wsgiref/headers.pyi | 8 +- stdlib/wsgiref/simple_server.pyi | 6 +- stdlib/wsgiref/util.pyi | 2 +- stdlib/wsgiref/validate.pyi | 4 +- stdlib/xml/dom/domreg.pyi | 2 +- stdlib/xml/dom/minicompat.pyi | 2 +- stdlib/xml/dom/minidom.pyi | 30 +- stdlib/xml/dom/pulldom.pyi | 8 +- stdlib/xml/etree/ElementInclude.pyi | 10 +- stdlib/xml/etree/ElementPath.pyi | 14 +- stdlib/xml/etree/ElementTree.pyi | 166 ++--- stdlib/xml/sax/__init__.pyi | 6 +- stdlib/xml/sax/saxutils.pyi | 4 +- stdlib/xml/sax/xmlreader.pyi | 2 +- stdlib/xmlrpc/client.pyi | 60 +- stdlib/xmlrpc/server.pyi | 36 +- stdlib/zipapp.pyi | 10 +- stdlib/zipfile.pyi | 88 +-- stdlib/zipimport.pyi | 12 +- stdlib/zlib.pyi | 4 +- stdlib/zoneinfo/__init__.pyi | 4 +- .../DateTimeRange/datetimerange/__init__.pyi | 14 +- stubs/Deprecated/deprecated/classic.pyi | 6 +- stubs/Deprecated/deprecated/sphinx.pyi | 6 +- stubs/Flask/flask/app.pyi | 60 +- stubs/Flask/flask/blueprints.pyi | 48 +- stubs/Flask/flask/cli.pyi | 6 +- stubs/Flask/flask/config.pyi | 6 +- stubs/Flask/flask/ctx.pyi | 6 +- stubs/Flask/flask/helpers.pyi | 14 +- stubs/Flask/flask/json/tag.pyi | 2 +- stubs/Flask/flask/sessions.pyi | 6 +- stubs/Flask/flask/signals.pyi | 4 +- stubs/Flask/flask/templating.pyi | 2 +- stubs/Flask/flask/testing.pyi | 22 +- stubs/Flask/flask/wrappers.pyi | 12 +- stubs/JACK-Client/jack/__init__.pyi | 46 +- stubs/Jinja2/jinja2/_compat.pyi | 2 +- stubs/Jinja2/jinja2/bccache.pyi | 6 +- stubs/Jinja2/jinja2/compiler.pyi | 22 +- stubs/Jinja2/jinja2/debug.pyi | 6 +- stubs/Jinja2/jinja2/defaults.pyi | 4 +- stubs/Jinja2/jinja2/environment.pyi | 76 +-- stubs/Jinja2/jinja2/exceptions.pyi | 8 +- stubs/Jinja2/jinja2/ext.pyi | 14 +- stubs/Jinja2/jinja2/filters.pyi | 16 +- stubs/Jinja2/jinja2/lexer.pyi | 6 +- stubs/Jinja2/jinja2/loaders.pyi | 10 +- stubs/Jinja2/jinja2/nodes.pyi | 52 +- stubs/Jinja2/jinja2/parser.pyi | 18 +- stubs/Jinja2/jinja2/runtime.pyi | 14 +- stubs/Jinja2/jinja2/utils.pyi | 16 +- stubs/Markdown/markdown/core.pyi | 38 +- .../markdown/extensions/codehilite.pyi | 8 +- stubs/Markdown/markdown/inlinepatterns.pyi | 8 +- stubs/Markdown/markdown/treeprocessors.pyi | 4 +- stubs/Markdown/markdown/util.pyi | 2 +- stubs/MarkupSafe/markupsafe/__init__.pyi | 16 +- stubs/MarkupSafe/markupsafe/_native.pyi | 4 +- stubs/MarkupSafe/markupsafe/_speedups.pyi | 4 +- stubs/PyMySQL/pymysql/cursors.pyi | 4 +- stubs/PyYAML/yaml/__init__.pyi | 28 +- stubs/PyYAML/yaml/composer.pyi | 8 +- stubs/PyYAML/yaml/cyaml.pyi | 52 +- stubs/Pygments/pygments/__init__.pyi | 4 +- stubs/Pygments/pygments/cmdline.pyi | 2 +- stubs/Pygments/pygments/filter.pyi | 2 +- stubs/Pygments/pygments/formatters/html.pyi | 6 +- .../pygments/formatters/terminal256.pyi | 2 +- stubs/Pygments/pygments/lexer.pyi | 10 +- stubs/Pygments/pygments/util.pyi | 8 +- stubs/Werkzeug/werkzeug/_compat.pyi | 2 +- stubs/Werkzeug/werkzeug/_internal.pyi | 14 +- stubs/Werkzeug/werkzeug/_reloader.pyi | 4 +- stubs/Werkzeug/werkzeug/contrib/atom.pyi | 4 +- stubs/Werkzeug/werkzeug/contrib/cache.pyi | 36 +- stubs/Werkzeug/werkzeug/contrib/fixers.pyi | 4 +- stubs/Werkzeug/werkzeug/contrib/iterio.pyi | 12 +- .../werkzeug/contrib/securecookie.pyi | 16 +- stubs/Werkzeug/werkzeug/contrib/sessions.pyi | 18 +- stubs/Werkzeug/werkzeug/datastructures.pyi | 144 ++-- stubs/Werkzeug/werkzeug/debug/__init__.pyi | 4 +- stubs/Werkzeug/werkzeug/debug/console.pyi | 4 +- stubs/Werkzeug/werkzeug/debug/repr.pyi | 4 +- stubs/Werkzeug/werkzeug/debug/tbtools.pyi | 4 +- stubs/Werkzeug/werkzeug/exceptions.pyi | 46 +- stubs/Werkzeug/werkzeug/formparser.pyi | 44 +- stubs/Werkzeug/werkzeug/http.pyi | 80 +-- stubs/Werkzeug/werkzeug/local.pyi | 4 +- .../werkzeug/middleware/dispatcher.pyi | 2 +- stubs/Werkzeug/werkzeug/middleware/lint.pyi | 2 +- .../Werkzeug/werkzeug/middleware/profiler.pyi | 4 +- .../werkzeug/middleware/proxy_fix.pyi | 4 +- .../werkzeug/middleware/shared_data.pyi | 6 +- stubs/Werkzeug/werkzeug/routing.pyi | 70 +- stubs/Werkzeug/werkzeug/script.pyi | 10 +- stubs/Werkzeug/werkzeug/security.pyi | 4 +- stubs/Werkzeug/werkzeug/serving.pyi | 46 +- stubs/Werkzeug/werkzeug/test.pyi | 46 +- stubs/Werkzeug/werkzeug/urls.pyi | 18 +- stubs/Werkzeug/werkzeug/useragents.pyi | 8 +- stubs/Werkzeug/werkzeug/utils.pyi | 8 +- stubs/Werkzeug/werkzeug/wrappers.pyi | 82 +-- stubs/Werkzeug/werkzeug/wsgi.pyi | 22 +- stubs/aiofiles/aiofiles/base.pyi | 4 +- stubs/aiofiles/aiofiles/os.pyi | 12 +- .../aiofiles/aiofiles/threadpool/__init__.pyi | 38 +- stubs/aiofiles/aiofiles/threadpool/binary.pyi | 8 +- stubs/aiofiles/aiofiles/threadpool/text.pyi | 10 +- stubs/atomicwrites/atomicwrites/__init__.pyi | 2 +- stubs/bleach/bleach/__init__.pyi | 2 +- stubs/bleach/bleach/html5lib_shim.pyi | 6 +- stubs/bleach/bleach/linkifier.pyi | 4 +- stubs/bleach/bleach/sanitizer.pyi | 2 +- stubs/boto/boto/__init__.pyi | 112 ++-- stubs/boto/boto/auth.pyi | 6 +- stubs/boto/boto/connection.pyi | 78 +-- stubs/boto/boto/exception.pyi | 18 +- stubs/boto/boto/kms/layer1.pyi | 92 +-- stubs/boto/boto/plugin.pyi | 2 +- stubs/boto/boto/regioninfo.pyi | 10 +- stubs/boto/boto/s3/__init__.pyi | 6 +- stubs/boto/boto/s3/acl.pyi | 20 +- stubs/boto/boto/s3/bucket.pyi | 154 ++--- stubs/boto/boto/s3/bucketlistresultset.pyi | 28 +- stubs/boto/boto/s3/bucketlogging.pyi | 2 +- stubs/boto/boto/s3/connection.pyi | 64 +- stubs/boto/boto/s3/cors.pyi | 20 +- stubs/boto/boto/s3/deletemarker.pyi | 2 +- stubs/boto/boto/s3/key.pyi | 152 ++--- stubs/boto/boto/s3/lifecycle.pyi | 22 +- stubs/boto/boto/s3/multidelete.pyi | 10 +- stubs/boto/boto/s3/multipart.pyi | 26 +- stubs/boto/boto/s3/prefix.pyi | 2 +- stubs/boto/boto/s3/tagging.pyi | 2 +- stubs/boto/boto/s3/user.pyi | 2 +- stubs/boto/boto/s3/website.pyi | 38 +- stubs/boto/boto/utils.pyi | 74 +-- stubs/cachetools/cachetools/cache.pyi | 2 +- stubs/cachetools/cachetools/decorators.pyi | 6 +- stubs/cachetools/cachetools/func.pyi | 2 +- stubs/cachetools/cachetools/lfu.pyi | 2 +- stubs/cachetools/cachetools/lru.pyi | 2 +- stubs/cachetools/cachetools/rr.pyi | 4 +- stubs/cachetools/cachetools/ttl.pyi | 4 +- .../characteristic/__init__.pyi | 20 +- stubs/chardet/chardet/universaldetector.pyi | 4 +- .../click-spinner/click_spinner/__init__.pyi | 6 +- stubs/click/click/_termui_impl.pyi | 4 +- stubs/click/click/core.pyi | 150 ++--- stubs/click/click/decorators.pyi | 208 +++--- stubs/click/click/exceptions.pyi | 40 +- stubs/click/click/formatting.pyi | 6 +- stubs/click/click/globals.pyi | 2 +- stubs/click/click/parser.pyi | 22 +- stubs/click/click/termui.pyi | 76 +-- stubs/click/click/testing.pyi | 22 +- stubs/click/click/types.pyi | 74 +-- stubs/click/click/utils.pyi | 16 +- stubs/colorama/colorama/ansitowin32.pyi | 2 +- stubs/colorama/colorama/initialise.pyi | 14 +- stubs/colorama/colorama/winterm.pyi | 12 +- stubs/croniter/croniter.pyi | 20 +- stubs/cryptography/cryptography/fernet.pyi | 8 +- .../hazmat/backends/interfaces.pyi | 12 +- .../hazmat/bindings/openssl/binding.pyi | 4 +- .../hazmat/primitives/asymmetric/dh.pyi | 10 +- .../hazmat/primitives/asymmetric/dsa.pyi | 12 +- .../hazmat/primitives/asymmetric/ec.pyi | 14 +- .../hazmat/primitives/asymmetric/padding.pyi | 4 +- .../hazmat/primitives/asymmetric/rsa.pyi | 12 +- .../hazmat/primitives/ciphers/__init__.pyi | 2 +- .../hazmat/primitives/ciphers/aead.pyi | 14 +- .../hazmat/primitives/ciphers/modes.pyi | 2 +- .../cryptography/hazmat/primitives/cmac.pyi | 2 +- .../cryptography/hazmat/primitives/hashes.pyi | 2 +- .../cryptography/hazmat/primitives/hmac.pyi | 2 +- .../hazmat/primitives/kdf/concatkdf.pyi | 8 +- .../hazmat/primitives/kdf/hkdf.pyi | 8 +- .../hazmat/primitives/kdf/kbkdf.pyi | 8 +- .../hazmat/primitives/kdf/pbkdf2.pyi | 2 +- .../hazmat/primitives/kdf/scrypt.pyi | 2 +- .../hazmat/primitives/kdf/x963kdf.pyi | 2 +- .../hazmat/primitives/keywrap.pyi | 8 +- .../primitives/serialization/__init__.pyi | 20 +- .../primitives/serialization/pkcs12.pyi | 10 +- .../hazmat/primitives/serialization/pkcs7.pyi | 6 +- .../hazmat/primitives/twofactor/hotp.pyi | 4 +- .../hazmat/primitives/twofactor/totp.pyi | 4 +- .../cryptography/x509/__init__.pyi | 78 +-- stubs/cryptography/cryptography/x509/oid.pyi | 2 +- stubs/dataclasses/dataclasses.pyi | 18 +- stubs/dateparser/dateparser.pyi | 12 +- stubs/decorator/decorator.pyi | 40 +- stubs/docopt/docopt.pyi | 4 +- stubs/docutils/docutils/__init__.pyi | 10 +- stubs/docutils/docutils/frontend.pyi | 26 +- stubs/docutils/docutils/io.pyi | 24 +- .../docutils/parsers/rst/__init__.pyi | 2 +- stubs/docutils/docutils/utils/__init__.pyi | 6 +- stubs/emoji/emoji/core.pyi | 2 +- stubs/filelock/filelock/__init__.pyi | 10 +- stubs/first/first.pyi | 8 +- stubs/geoip2/geoip2/database.pyi | 6 +- stubs/geoip2/geoip2/errors.pyi | 6 +- stubs/geoip2/geoip2/models.pyi | 22 +- stubs/itsdangerous/itsdangerous.pyi | 144 ++-- stubs/maxminddb/maxminddb/reader.pyi | 10 +- stubs/mock/mock.pyi | 160 ++--- stubs/mypy-extensions/mypy_extensions.pyi | 8 +- stubs/nmap/nmap/nmap.pyi | 16 +- .../oauthlib/oauth1/rfc5849/signature.pyi | 4 +- stubs/orjson/orjson.pyi | 4 +- stubs/paramiko/paramiko/_winapi.pyi | 10 +- stubs/paramiko/paramiko/auth_handler.pyi | 20 +- stubs/paramiko/paramiko/ber.pyi | 6 +- stubs/paramiko/paramiko/buffered_pipe.pyi | 2 +- stubs/paramiko/paramiko/channel.pyi | 14 +- stubs/paramiko/paramiko/client.pyi | 34 +- stubs/paramiko/paramiko/config.pyi | 6 +- stubs/paramiko/paramiko/dsskey.pyi | 28 +- stubs/paramiko/paramiko/ecdsakey.pyi | 26 +- stubs/paramiko/paramiko/ed25519key.pyi | 10 +- stubs/paramiko/paramiko/file.pyi | 8 +- stubs/paramiko/paramiko/hostkeys.pyi | 12 +- stubs/paramiko/paramiko/kex_curve25519.pyi | 2 +- stubs/paramiko/paramiko/kex_ecdh_nist.pyi | 6 +- stubs/paramiko/paramiko/kex_gex.pyi | 12 +- stubs/paramiko/paramiko/kex_gss.pyi | 16 +- stubs/paramiko/paramiko/message.pyi | 2 +- stubs/paramiko/paramiko/pkey.pyi | 16 +- stubs/paramiko/paramiko/proxy.pyi | 2 +- stubs/paramiko/paramiko/py3compat.pyi | 16 +- stubs/paramiko/paramiko/rsakey.pyi | 20 +- stubs/paramiko/paramiko/server.pyi | 14 +- stubs/paramiko/paramiko/sftp.pyi | 2 +- stubs/paramiko/paramiko/sftp_attr.pyi | 14 +- stubs/paramiko/paramiko/sftp_client.pyi | 56 +- stubs/paramiko/paramiko/sftp_file.pyi | 4 +- stubs/paramiko/paramiko/sftp_handle.pyi | 4 +- stubs/paramiko/paramiko/sftp_server.pyi | 2 +- stubs/paramiko/paramiko/sftp_si.pyi | 10 +- stubs/paramiko/paramiko/ssh_exception.pyi | 6 +- stubs/paramiko/paramiko/ssh_gss.pyi | 20 +- stubs/paramiko/paramiko/transport.pyi | 88 +-- stubs/paramiko/paramiko/util.pyi | 4 +- stubs/polib/polib.pyi | 26 +- stubs/protobuf/google/protobuf/api_pb2.pyi | 10 +- .../google/protobuf/compiler/plugin_pb2.pyi | 30 +- .../google/protobuf/descriptor_pb2.pyi | 250 +++---- .../google/protobuf/descriptor_pool.pyi | 4 +- .../google/protobuf/field_mask_pb2.pyi | 2 +- .../google/protobuf/internal/containers.pyi | 8 +- .../protobuf/internal/extension_dict.pyi | 2 +- .../protobuf/internal/well_known_types.pyi | 4 +- .../protobuf/google/protobuf/json_format.pyi | 14 +- .../google/protobuf/message_factory.pyi | 2 +- stubs/protobuf/google/protobuf/service.pyi | 10 +- stubs/protobuf/google/protobuf/struct_pb2.pyi | 12 +- .../google/protobuf/symbol_database.pyi | 2 +- .../protobuf/google/protobuf/text_format.pyi | 76 +-- stubs/protobuf/google/protobuf/type_pb2.pyi | 20 +- stubs/pyRFC3339/pyrfc3339/utils.pyi | 6 +- stubs/pyaudio/pyaudio.pyi | 38 +- stubs/pysftp/pysftp/__init__.pyi | 42 +- stubs/pysftp/pysftp/helpers.pyi | 2 +- stubs/python-dateutil/dateutil/_common.pyi | 2 +- stubs/python-dateutil/dateutil/parser.pyi | 20 +- .../dateutil/relativedelta.pyi | 58 +- stubs/python-dateutil/dateutil/rrule.pyi | 30 +- stubs/python-dateutil/dateutil/tz/_common.pyi | 6 +- stubs/python-dateutil/dateutil/tz/tz.pyi | 56 +- stubs/python-dateutil/dateutil/utils.pyi | 2 +- stubs/python-gflags/gflags.pyi | 30 +- stubs/python-slugify/slugify/slugify.pyi | 2 +- stubs/pytz/pytz/__init__.pyi | 24 +- stubs/pyvmomi/pyVmomi/vmodl/query.pyi | 4 +- stubs/redis/redis/client.pyi | 554 ++++++++-------- stubs/redis/redis/connection.pyi | 18 +- stubs/redis/redis/lock.pyi | 14 +- stubs/redis/redis/utils.pyi | 4 +- stubs/requests/requests/adapters.pyi | 20 +- stubs/requests/requests/api.pyi | 220 +++--- stubs/requests/requests/auth.pyi | 2 +- stubs/requests/requests/models.pyi | 14 +- stubs/requests/requests/sessions.pyi | 228 +++---- stubs/requests/requests/structures.pyi | 4 +- stubs/requests/requests/utils.pyi | 6 +- stubs/retry/retry/api.pyi | 20 +- stubs/setuptools/pkg_resources/__init__.pyi | 78 +-- stubs/simplejson/simplejson/scanner.pyi | 6 +- stubs/six/six/__init__.pyi | 30 +- stubs/tabulate/tabulate.pyi | 22 +- stubs/termcolor/termcolor.pyi | 4 +- stubs/toml/toml.pyi | 2 +- stubs/typed-ast/typed_ast/ast27.pyi | 64 +- stubs/typed-ast/typed_ast/ast3.pyi | 70 +- stubs/waitress/waitress/adjustments.pyi | 16 +- stubs/waitress/waitress/buffers.pyi | 14 +- stubs/waitress/waitress/channel.pyi | 6 +- stubs/waitress/waitress/compat.pyi | 2 +- stubs/waitress/waitress/parser.pyi | 4 +- stubs/waitress/waitress/proxy_headers.pyi | 4 +- stubs/waitress/waitress/receiver.pyi | 2 +- stubs/waitress/waitress/runner.pyi | 2 +- stubs/waitress/waitress/server.pyi | 36 +- stubs/waitress/waitress/task.pyi | 4 +- stubs/waitress/waitress/trigger.pyi | 4 +- stubs/waitress/waitress/wasyncore.pyi | 28 +- 611 files changed, 8517 insertions(+), 8535 deletions(-) diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index eee5b55f01b0..97f140d61513 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -18,9 +18,9 @@ class AST: lineno: int col_offset: int if sys.version_info >= (3, 8): - end_lineno: Optional[int] - end_col_offset: Optional[int] - type_comment: Optional[str] + end_lineno: int | None + end_col_offset: int | None + type_comment: str | None class mod(AST): ... @@ -50,14 +50,14 @@ class FunctionDef(stmt): args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - returns: Optional[expr] + returns: expr | None class AsyncFunctionDef(stmt): name: _identifier args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - returns: Optional[expr] + returns: expr | None class ClassDef(stmt): name: _identifier @@ -67,7 +67,7 @@ class ClassDef(stmt): decorator_list: typing.List[expr] class Return(stmt): - value: Optional[expr] + value: expr | None class Delete(stmt): targets: typing.List[expr] @@ -84,7 +84,7 @@ class AugAssign(stmt): class AnnAssign(stmt): target: expr annotation: expr - value: Optional[expr] + value: expr | None simple: int class For(stmt): @@ -118,8 +118,8 @@ class AsyncWith(stmt): body: typing.List[stmt] class Raise(stmt): - exc: Optional[expr] - cause: Optional[expr] + exc: expr | None + cause: expr | None class Try(stmt): body: typing.List[stmt] @@ -129,13 +129,13 @@ class Try(stmt): class Assert(stmt): test: expr - msg: Optional[expr] + msg: expr | None class Import(stmt): names: typing.List[alias] class ImportFrom(stmt): - module: Optional[_identifier] + module: _identifier | None names: typing.List[alias] level: int @@ -176,7 +176,7 @@ class IfExp(expr): orelse: expr class Dict(expr): - keys: typing.List[Optional[expr]] + keys: typing.List[expr | None] values: typing.List[expr] class Set(expr): @@ -203,7 +203,7 @@ class Await(expr): value: expr class Yield(expr): - value: Optional[expr] + value: expr | None class YieldFrom(expr): value: expr @@ -220,8 +220,8 @@ class Call(expr): class FormattedValue(expr): value: expr - conversion: Optional[int] - format_spec: Optional[expr] + conversion: int | None + format_spec: expr | None class JoinedStr(expr): values: typing.List[expr] @@ -239,7 +239,7 @@ if sys.version_info < (3, 8): class Constant(expr): value: Any # None, str, bytes, bool, int, float, complex, Ellipsis - kind: Optional[str] + kind: str | None # Aliases for value, for backwards compatibility s: Any n: complex @@ -261,9 +261,9 @@ else: _SliceT = slice class Slice(_SliceT): - lower: Optional[expr] - upper: Optional[expr] - step: Optional[expr] + lower: expr | None + upper: expr | None + step: expr | None if sys.version_info < (3, 9): class ExtSlice(slice): @@ -347,35 +347,35 @@ class comprehension(AST): class excepthandler(AST): ... class ExceptHandler(excepthandler): - type: Optional[expr] - name: Optional[_identifier] + type: expr | None + name: _identifier | None body: typing.List[stmt] class arguments(AST): if sys.version_info >= (3, 8): posonlyargs: typing.List[arg] args: typing.List[arg] - vararg: Optional[arg] + vararg: arg | None kwonlyargs: typing.List[arg] - kw_defaults: typing.List[Optional[expr]] - kwarg: Optional[arg] + kw_defaults: typing.List[expr | None] + kwarg: arg | None defaults: typing.List[expr] class arg(AST): arg: _identifier - annotation: Optional[expr] + annotation: expr | None class keyword(AST): - arg: Optional[_identifier] + arg: _identifier | None value: expr class alias(AST): name: _identifier - asname: Optional[_identifier] + asname: _identifier | None class withitem(AST): context_expr: expr - optional_vars: Optional[expr] + optional_vars: expr | None if sys.version_info >= (3, 10): class Match(stmt): @@ -386,7 +386,7 @@ if sys.version_info >= (3, 10): _pattern = pattern class match_case(AST): pattern: _pattern - guard: Optional[expr] + guard: expr | None body: typing.List[stmt] class MatchValue(pattern): value: expr @@ -395,18 +395,18 @@ if sys.version_info >= (3, 10): class MatchSequence(pattern): patterns: typing.List[pattern] class MatchStar(pattern): - name: Optional[_identifier] + name: _identifier | None class MatchMapping(pattern): keys: typing.List[expr] patterns: typing.List[pattern] - rest: Optional[_identifier] + rest: _identifier | None class MatchClass(pattern): cls: expr patterns: typing.List[pattern] kwd_attrs: typing.List[_identifier] kwd_patterns: typing.List[pattern] class MatchAs(pattern): - pattern: Optional[_pattern] - name: Optional[_identifier] + pattern: _pattern | None + name: _identifier | None class MatchOr(pattern): patterns: typing.List[pattern] diff --git a/stdlib/_bisect.pyi b/stdlib/_bisect.pyi index 3ca863a2e939..2e9b82203d39 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -6,30 +6,30 @@ _T = TypeVar("_T") if sys.version_info >= (3, 10): def bisect_left( - a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... + a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ... ) -> int: ... def bisect_right( - a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... + a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ... ) -> int: ... def insort_left( a: MutableSequence[_T], x: _T, lo: int = ..., - hi: Optional[int] = ..., + hi: int | None = ..., *, - key: Optional[Callable[[_T], SupportsLessThan]] = ..., + key: Callable[[_T], SupportsLessThan] | None = ..., ) -> None: ... def insort_right( a: MutableSequence[_T], x: _T, lo: int = ..., - hi: Optional[int] = ..., + hi: int | None = ..., *, - key: Optional[Callable[[_T], SupportsLessThan]] = ..., + key: Callable[[_T], SupportsLessThan] | None = ..., ) -> None: ... else: - def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... - def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... - def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... - def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... + def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ... + def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ... + def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ... + def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ... diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 9d420af898e2..469aa99dacf5 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -13,56 +13,56 @@ def register(__search_function: Callable[[str], Any]) -> None: ... def register_error(__errors: str, __handler: _Handler) -> None: ... def lookup(__encoding: str) -> codecs.CodecInfo: ... def lookup_error(__name: str) -> _Handler: ... -def decode(obj: Any, encoding: str = ..., errors: Optional[str] = ...) -> Any: ... -def encode(obj: Any, encoding: str = ..., errors: Optional[str] = ...) -> Any: ... +def decode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ... +def encode(obj: Any, encoding: str = ..., errors: str | None = ...) -> Any: ... def charmap_build(__map: str) -> _MapT: ... -def ascii_decode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[str, int]: ... -def ascii_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def charmap_decode(__data: bytes, __errors: Optional[str] = ..., __mapping: Optional[_MapT] = ...) -> Tuple[str, int]: ... -def charmap_encode(__str: str, __errors: Optional[str] = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ... -def escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ... -def escape_encode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def latin_1_decode(__data: bytes, __errors: Optional[str] = ...) -> Tuple[str, int]: ... -def latin_1_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def raw_unicode_escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ... -def raw_unicode_escape_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def readbuffer_encode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def unicode_escape_decode(__data: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ... -def unicode_escape_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... +def ascii_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ... +def ascii_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def charmap_decode(__data: bytes, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[str, int]: ... +def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _MapT | None = ...) -> Tuple[bytes, int]: ... +def escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ... +def escape_encode(__data: bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def latin_1_decode(__data: bytes, __errors: str | None = ...) -> Tuple[str, int]: ... +def latin_1_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def raw_unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ... +def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def readbuffer_encode(__data: str | bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def unicode_escape_decode(__data: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ... +def unicode_escape_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... if sys.version_info < (3, 8): - def unicode_internal_decode(__obj: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[str, int]: ... - def unicode_internal_encode(__obj: Union[str, bytes], __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... + def unicode_internal_decode(__obj: str | bytes, __errors: str | None = ...) -> Tuple[str, int]: ... + def unicode_internal_encode(__obj: str | bytes, __errors: str | None = ...) -> Tuple[bytes, int]: ... -def utf_16_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_16_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def utf_16_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_16_encode(__str: str, __errors: Optional[str] = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ... +def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... +def utf_16_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def utf_16_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... +def utf_16_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ... def utf_16_ex_decode( - __data: bytes, __errors: Optional[str] = ..., __byteorder: int = ..., __final: int = ... + __data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ... ) -> Tuple[str, int, int]: ... -def utf_16_le_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_16_le_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def utf_32_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_32_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def utf_32_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_32_encode(__str: str, __errors: Optional[str] = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ... +def utf_16_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... +def utf_16_le_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def utf_32_be_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... +def utf_32_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def utf_32_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... +def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ... def utf_32_ex_decode( - __data: bytes, __errors: Optional[str] = ..., __byteorder: int = ..., __final: int = ... + __data: bytes, __errors: str | None = ..., __byteorder: int = ..., __final: int = ... ) -> Tuple[str, int, int]: ... -def utf_32_le_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_32_le_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def utf_7_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_7_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def utf_8_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... -def utf_8_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... +def utf_32_le_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... +def utf_32_le_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def utf_7_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... +def utf_7_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def utf_8_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... +def utf_8_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... if sys.platform == "win32": - def mbcs_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... - def mbcs_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... + def mbcs_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... + def mbcs_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... def code_page_decode( - __codepage: int, __data: bytes, __errors: Optional[str] = ..., __final: int = ... + __codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ... ) -> Tuple[str, int]: ... - def code_page_encode(__code_page: int, __str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... - def oem_decode(__data: bytes, __errors: Optional[str] = ..., __final: int = ...) -> Tuple[str, int]: ... - def oem_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... + def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... + def oem_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... + def oem_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... diff --git a/stdlib/_compression.pyi b/stdlib/_compression.pyi index 6cbf5e9ffdff..12a160566958 100644 --- a/stdlib/_compression.pyi +++ b/stdlib/_compression.pyi @@ -16,7 +16,7 @@ class DecompressReader(RawIOBase): self, fp: _Reader, decomp_factory: Callable[..., object], - trailing_error: Union[Type[Exception], Tuple[Type[Exception], ...]] = ..., + trailing_error: Type[Exception] | Tuple[Type[Exception], ...] = ..., **decomp_args: Any, ) -> None: ... def readable(self) -> bool: ... diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index 45d05f478cb4..ef85aca8d6f0 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -9,8 +9,8 @@ class Error(Exception): ... class Dialect: delimiter: str - quotechar: Optional[str] - escapechar: Optional[str] + quotechar: str | None + escapechar: str | None doublequote: bool skipinitialspace: bool lineterminator: str diff --git a/stdlib/_curses.pyi b/stdlib/_curses.pyi index b64fa66e08b5..bb2d4fdbd4bb 100644 --- a/stdlib/_curses.pyi +++ b/stdlib/_curses.pyi @@ -338,7 +338,7 @@ def resize_term(__nlines: int, __ncols: int) -> None: ... def resizeterm(__nlines: int, __ncols: int) -> None: ... def savetty() -> None: ... def setsyx(__y: int, __x: int) -> None: ... -def setupterm(term: Optional[str] = ..., fd: int = ...) -> None: ... +def setupterm(term: str | None = ..., fd: int = ...) -> None: ... def start_color() -> None: ... def termattrs() -> int: ... def termname() -> bytes: ... @@ -359,7 +359,7 @@ def tparm( ) -> bytes: ... def typeahead(__fd: int) -> None: ... def unctrl(__ch: _chtype) -> bytes: ... -def unget_wch(__ch: Union[int, str]) -> None: ... +def unget_wch(__ch: int | str) -> None: ... def ungetch(__ch: _chtype) -> None: ... def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ... def update_lines_cols() -> int: ... @@ -434,9 +434,9 @@ class _CursesWindow: @overload def getch(self, y: int, x: int) -> int: ... @overload - def get_wch(self) -> Union[int, str]: ... + def get_wch(self) -> int | str: ... @overload - def get_wch(self, y: int, x: int) -> Union[int, str]: ... + def get_wch(self, y: int, x: int) -> int | str: ... @overload def getkey(self) -> str: ... @overload diff --git a/stdlib/_dummy_thread.pyi b/stdlib/_dummy_thread.pyi index 1260d42de958..a9ccdd56c8d1 100644 --- a/stdlib/_dummy_thread.pyi +++ b/stdlib/_dummy_thread.pyi @@ -7,13 +7,13 @@ def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs def exit() -> NoReturn: ... def get_ident() -> int: ... def allocate_lock() -> LockType: ... -def stack_size(size: Optional[int] = ...) -> int: ... +def stack_size(size: int | None = ...) -> int: ... class LockType(object): locked_status: bool def __init__(self) -> None: ... - def acquire(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ... - def __enter__(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ... + def acquire(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ... + def __enter__(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ... def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ... def release(self) -> bool: ... def locked(self) -> bool: ... diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index de75375056e0..47246fe05f0e 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -21,7 +21,7 @@ if sys.version_info >= (3, 8): from _thread import get_native_id as get_native_id def settrace(func: _TF) -> None: ... -def setprofile(func: Optional[_PF]) -> None: ... +def setprofile(func: _PF | None) -> None: ... def stack_size(size: int = ...) -> int: ... TIMEOUT_MAX: float @@ -35,26 +35,26 @@ class local(object): class Thread: name: str - ident: Optional[int] + ident: int | None daemon: bool def __init__( self, group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., + target: Callable[..., Any] | None = ..., + name: str | None = ..., args: Iterable[Any] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., + kwargs: Mapping[str, Any] | None = ..., *, - daemon: Optional[bool] = ..., + daemon: bool | None = ..., ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... - def join(self, timeout: Optional[float] = ...) -> None: ... + def join(self, timeout: float | None = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: str) -> None: ... if sys.version_info >= (3, 8): @property - def native_id(self) -> Optional[int]: ... # only available on some platforms + def native_id(self) -> int | None: ... # only available on some platforms def is_alive(self) -> bool: ... if sys.version_info < (3, 9): def isAlive(self) -> bool: ... @@ -67,8 +67,8 @@ class Lock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -77,23 +77,23 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock class Condition: - def __init__(self, lock: Union[Lock, _RLock, None] = ...) -> None: ... + def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> bool: ... - def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ... + def wait(self, timeout: float | None = ...) -> bool: ... + def wait_for(self, predicate: Callable[[], _T], timeout: float | None = ...) -> _T: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -101,10 +101,10 @@ class Condition: class Semaphore: def __init__(self, value: int = ...) -> None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... + def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... + def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... if sys.version_info >= (3, 9): def release(self, n: int = ...) -> None: ... else: @@ -117,7 +117,7 @@ class Event: def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> bool: ... + def wait(self, timeout: float | None = ...) -> bool: ... if sys.version_info >= (3, 8): from _thread import _excepthook, _ExceptHookArgs @@ -130,8 +130,8 @@ class Timer(Thread): self, interval: float, function: Callable[..., Any], - args: Optional[Iterable[Any]] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., + args: Iterable[Any] | None = ..., + kwargs: Mapping[str, Any] | None = ..., ) -> None: ... def cancel(self) -> None: ... @@ -139,8 +139,8 @@ class Barrier: parties: int n_waiting: int broken: bool - def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> int: ... + def __init__(self, parties: int, action: Callable[[], None] | None = ..., timeout: float | None = ...) -> None: ... + def wait(self, timeout: float | None = ...) -> int: ... def reset(self) -> None: ... def abort(self) -> None: ... diff --git a/stdlib/_json.pyi b/stdlib/_json.pyi index af2b024af5af..ddfde30a312b 100644 --- a/stdlib/_json.pyi +++ b/stdlib/_json.pyi @@ -11,10 +11,10 @@ class make_encoder: item_separator: Any def __init__( self, - markers: Optional[Dict[int, Any]], + markers: Dict[int, Any] | None, default: Callable[[Any], Any], encoder: Callable[[str], str], - indent: Optional[int], + indent: int | None, key_separator: str, item_separator: str, sort_keys: bool, diff --git a/stdlib/_msi.pyi b/stdlib/_msi.pyi index a8f9c60bbadd..f70a6df31a74 100644 --- a/stdlib/_msi.pyi +++ b/stdlib/_msi.pyi @@ -5,7 +5,7 @@ if sys.platform == "win32": # Actual typename View, not exposed by the implementation class _View: - def Execute(self, params: Optional[_Record] = ...) -> None: ... + def Execute(self, params: _Record | None = ...) -> None: ... def GetColumnInfo(self, kind: int) -> _Record: ... def Fetch(self) -> _Record: ... def Modify(self, mode: int, record: _Record) -> None: ... @@ -15,9 +15,9 @@ if sys.platform == "win32": __init__: None # type: ignore # Actual typename Summary, not exposed by the implementation class _Summary: - def GetProperty(self, propid: int) -> Optional[Union[str, bytes]]: ... + def GetProperty(self, propid: int) -> str | bytes | None: ... def GetPropertyCount(self) -> int: ... - def SetProperty(self, propid: int, value: Union[str, bytes]) -> None: ... + def SetProperty(self, propid: int, value: str | bytes) -> None: ... def Persist(self) -> None: ... # Don't exist at runtime __new__: None # type: ignore diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index 5d67d996b30a..0362ebef3a2f 100644 --- a/stdlib/_osx_support.pyi +++ b/stdlib/_osx_support.pyi @@ -10,11 +10,11 @@ _UNIVERSAL_CONFIG_VARS: Tuple[str, ...] # undocumented _COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented _INITPRE: str # undocumented -def _find_executable(executable: str, path: Optional[str] = ...) -> Optional[str]: ... # undocumented -def _read_output(commandstring: str) -> Optional[str]: ... # undocumented +def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented +def _read_output(commandstring: str) -> str | None: ... # undocumented def _find_build_tool(toolname: str) -> str: ... # undocumented -_SYSTEM_VERSION: Optional[str] # undocumented +_SYSTEM_VERSION: str | None # undocumented def _get_system_version() -> str: ... # undocumented def _remove_original_values(_config_vars: Dict[str, str]) -> None: ... # undocumented @@ -30,4 +30,4 @@ def customize_config_vars(_config_vars: Dict[str, str]) -> Dict[str, str]: ... def customize_compiler(_config_vars: Dict[str, str]) -> Dict[str, str]: ... def get_platform_osx( _config_vars: Dict[str, str], osname: _T, release: _K, machine: _V -) -> Tuple[Union[str, _T], Union[str, _K], Union[str, _V]]: ... +) -> Tuple[str | _T, str | _K, str | _V]: ... diff --git a/stdlib/_sitebuiltins.pyi b/stdlib/_sitebuiltins.pyi index e0e9316aa290..f00084b9e25d 100644 --- a/stdlib/_sitebuiltins.pyi +++ b/stdlib/_sitebuiltins.pyi @@ -5,7 +5,7 @@ class Quitter: name: str eof: str def __init__(self, name: str, eof: str) -> None: ... - def __call__(self, code: Optional[int] = ...) -> NoReturn: ... + def __call__(self, code: int | None = ...) -> NoReturn: ... class _Printer: MAXLINES: ClassVar[Literal[23]] diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 109241870801..cb76e35d3868 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -541,7 +541,7 @@ class socket: def getsockopt(self, __level: int, __optname: int, __buflen: int) -> bytes: ... if sys.version_info >= (3, 7): def getblocking(self) -> bool: ... - def gettimeout(self) -> Optional[float]: ... + def gettimeout(self) -> float | None: ... if sys.platform == "win32": def ioctl(self, __control: int, __option: int | tuple[int, int, int] | bool) -> None: ... def listen(self, __backlog: int = ...) -> None: ... @@ -599,7 +599,7 @@ def getaddrinfo( type: int = ..., proto: int = ..., flags: int = ..., -) -> list[tuple[int, int, int, str, Union[tuple[str, int], tuple[str, int, int, int]]]]: ... +) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ... def gethostbyname(__hostname: str) -> str: ... def gethostbyname_ex(__hostname: str) -> tuple[str, list[str], list[str]]: ... def gethostname() -> str: ... @@ -618,7 +618,7 @@ def inet_pton(__address_family: int, __ip_string: str) -> bytes: ... def inet_ntop(__address_family: int, __packed_ip: bytes) -> str: ... def CMSG_LEN(__length: int) -> int: ... def CMSG_SPACE(__length: int) -> int: ... -def getdefaulttimeout() -> Optional[float]: ... +def getdefaulttimeout() -> float | None: ... def setdefaulttimeout(__timeout: float | None) -> None: ... def socketpair(__family: int = ..., __type: int = ..., __proto: int = ...) -> tuple[socket, socket]: ... diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 513678499223..234331fcaa4c 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -15,7 +15,7 @@ class LockType: def locked(self) -> bool: ... def __enter__(self) -> bool: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> int: ... @@ -29,13 +29,13 @@ TIMEOUT_MAX: float if sys.version_info >= (3, 8): def get_native_id() -> int: ... # only available on some platforms - class _ExceptHookArgs(Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]): + class _ExceptHookArgs(Tuple[Type[BaseException], BaseException | None, TracebackType | None, Thread | None]): @property def exc_type(self) -> Type[BaseException]: ... @property - def exc_value(self) -> Optional[BaseException]: ... + def exc_value(self) -> BaseException | None: ... @property - def exc_traceback(self) -> Optional[TracebackType]: ... + def exc_traceback(self) -> TracebackType | None: ... @property - def thread(self) -> Optional[Thread]: ... + def thread(self) -> Thread | None: ... _excepthook: Callable[[_ExceptHookArgs], Any] diff --git a/stdlib/_tracemalloc.pyi b/stdlib/_tracemalloc.pyi index 4319ed46da64..0b7550c7ef51 100644 --- a/stdlib/_tracemalloc.pyi +++ b/stdlib/_tracemalloc.pyi @@ -2,7 +2,7 @@ import sys from tracemalloc import _FrameTupleT, _TraceTupleT from typing import Optional, Sequence, Tuple -def _get_object_traceback(__obj: object) -> Optional[Sequence[_FrameTupleT]]: ... +def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ... def _get_traces() -> Sequence[_TraceTupleT]: ... def clear_traces() -> None: ... def get_traceback_limit() -> int: ... diff --git a/stdlib/_typeshed/wsgi.pyi b/stdlib/_typeshed/wsgi.pyi index d99d37f05ab2..7ec00c341666 100644 --- a/stdlib/_typeshed/wsgi.pyi +++ b/stdlib/_typeshed/wsgi.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Tupl # stable class StartResponse(Protocol): def __call__( - self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_OptExcInfo] = ... + self, status: str, headers: List[Tuple[str, str]], exc_info: _OptExcInfo | None = ... ) -> Callable[[bytes], Any]: ... WSGIEnvironment = Dict[str, Any] # stable diff --git a/stdlib/_typeshed/xml.pyi b/stdlib/_typeshed/xml.pyi index cabac0bc9991..9017589a4e0d 100644 --- a/stdlib/_typeshed/xml.pyi +++ b/stdlib/_typeshed/xml.pyi @@ -5,6 +5,6 @@ from typing_extensions import Protocol # As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects class DOMImplementation(Protocol): - def hasFeature(self, feature: str, version: Optional[str]) -> bool: ... - def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Optional[Any]) -> Any: ... + def hasFeature(self, feature: str, version: str | None) -> bool: ... + def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Any | None) -> Any: ... def createDocumentType(self, qualifiedName: str, publicId: str, systemId: str) -> Any: ... diff --git a/stdlib/_warnings.pyi b/stdlib/_warnings.pyi index 33d4f0b9e3bb..2cfb48f3b4cc 100644 --- a/stdlib/_warnings.pyi +++ b/stdlib/_warnings.pyi @@ -5,19 +5,19 @@ _onceregistry: Dict[Any, Any] filters: List[Tuple[Any, ...]] @overload -def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ...) -> None: ... +def warn(message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... @overload -def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Optional[Any] = ...) -> None: ... +def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... @overload def warn_explicit( message: str, category: Type[Warning], filename: str, lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - source: Optional[Any] = ..., + module: str | None = ..., + registry: Dict[str | Tuple[str, Type[Warning], int], int] | None = ..., + module_globals: Dict[str, Any] | None = ..., + source: Any | None = ..., ) -> None: ... @overload def warn_explicit( @@ -25,8 +25,8 @@ def warn_explicit( category: Any, filename: str, lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - source: Optional[Any] = ..., + module: str | None = ..., + registry: Dict[str | Tuple[str, Type[Warning], int], int] | None = ..., + module_globals: Dict[str, Any] | None = ..., + source: Any | None = ..., ) -> None: ... diff --git a/stdlib/_weakref.pyi b/stdlib/_weakref.pyi index 01974c522369..f366213e2bd4 100644 --- a/stdlib/_weakref.pyi +++ b/stdlib/_weakref.pyi @@ -15,8 +15,8 @@ class ProxyType(Generic[_T]): # "weakproxy" class ReferenceType(Generic[_T]): __callback__: Callable[[ReferenceType[_T]], Any] - def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ... - def __call__(self) -> Optional[_T]: ... + def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> None: ... + def __call__(self) -> _T | None: ... def __hash__(self) -> int: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -26,8 +26,8 @@ ref = ReferenceType def getweakrefcount(__object: Any) -> int: ... def getweakrefs(object: Any) -> List[Any]: ... @overload -def proxy(object: _C, callback: Optional[Callable[[_C], Any]] = ...) -> CallableProxyType[_C]: ... +def proxy(object: _C, callback: Callable[[_C], Any] | None = ...) -> CallableProxyType[_C]: ... # Return CallableProxyType if object is callable, ProxyType otherwise @overload -def proxy(object: _T, callback: Optional[Callable[[_T], Any]] = ...) -> Any: ... +def proxy(object: _T, callback: Callable[[_T], Any] | None = ...) -> Any: ... diff --git a/stdlib/_weakrefset.pyi b/stdlib/_weakrefset.pyi index c369584aa243..82cae5660de5 100644 --- a/stdlib/_weakrefset.pyi +++ b/stdlib/_weakrefset.pyi @@ -9,7 +9,7 @@ _T = TypeVar("_T") _SelfT = TypeVar("_SelfT", bound=WeakSet[Any]) class WeakSet(MutableSet[_T], Generic[_T]): - def __init__(self, data: Optional[Iterable[_T]] = ...) -> None: ... + def __init__(self, data: Iterable[_T] | None = ...) -> None: ... def add(self, item: _T) -> None: ... def clear(self) -> None: ... def discard(self, item: _T) -> None: ... @@ -20,7 +20,7 @@ class WeakSet(MutableSet[_T], Generic[_T]): def __contains__(self, item: object) -> bool: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... - def __ior__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def __ior__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... def difference(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... def __sub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... def difference_update(self, other: Iterable[_T]) -> None: ... @@ -36,12 +36,12 @@ class WeakSet(MutableSet[_T], Generic[_T]): def __ge__(self, other: Iterable[_T]) -> bool: ... def __gt__(self, other: Iterable[_T]) -> bool: ... def __eq__(self, other: object) -> bool: ... - def symmetric_difference(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... - def __xor__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def symmetric_difference(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... + def __xor__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... def symmetric_difference_update(self, other: Iterable[Any]) -> None: ... - def __ixor__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... - def union(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... - def __or__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def __ixor__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... + def union(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... + def __or__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... def isdisjoint(self, other: Iterable[_T]) -> bool: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index 09245b5218c1..d6351ca2ebb2 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -52,7 +52,7 @@ def ConnectNamedPipe(handle: int, overlapped: Literal[True]) -> Overlapped: ... @overload def ConnectNamedPipe(handle: int, overlapped: Literal[False] = ...) -> None: ... @overload -def ConnectNamedPipe(handle: int, overlapped: bool) -> Optional[Overlapped]: ... +def ConnectNamedPipe(handle: int, overlapped: bool) -> Overlapped | None: ... def CreateFile( __file_name: str, __desired_access: int, @@ -75,14 +75,14 @@ def CreateNamedPipe( ) -> int: ... def CreatePipe(__pipe_attrs: Any, __size: int) -> Tuple[int, int]: ... def CreateProcess( - __application_name: Optional[str], - __command_line: Optional[str], + __application_name: str | None, + __command_line: str | None, __proc_attrs: Any, __thread_attrs: Any, __inherit_handles: bool, __creation_flags: int, __env_mapping: Dict[str, str], - __current_directory: Optional[str], + __current_directory: str | None, __startup_info: Any, ) -> Tuple[int, int, int, int]: ... def DuplicateHandle( @@ -106,15 +106,15 @@ def GetModuleFileName(__module_handle: int) -> str: ... def GetStdHandle(__std_handle: int) -> int: ... def GetVersion() -> int: ... def OpenProcess(__desired_access: int, __inherit_handle: bool, __process_id: int) -> int: ... -def PeekNamedPipe(__handle: int, __size: int = ...) -> Union[Tuple[int, int], Tuple[bytes, int, int]]: ... +def PeekNamedPipe(__handle: int, __size: int = ...) -> Tuple[int, int] | Tuple[bytes, int, int]: ... @overload def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> Tuple[Overlapped, int]: ... @overload def ReadFile(handle: int, size: int, overlapped: Literal[False] = ...) -> Tuple[bytes, int]: ... @overload -def ReadFile(handle: int, size: int, overlapped: Union[int, bool]) -> Tuple[Any, int]: ... +def ReadFile(handle: int, size: int, overlapped: int | bool) -> Tuple[Any, int]: ... def SetNamedPipeHandleState( - __named_pipe: int, __mode: Optional[int], __max_collection_count: Optional[int], __collect_data_timeout: Optional[int] + __named_pipe: int, __mode: int | None, __max_collection_count: int | None, __collect_data_timeout: int | None ) -> None: ... def TerminateProcess(__handle: int, __exit_code: int) -> None: ... def WaitForMultipleObjects(__handle_seq: Sequence[int], __wait_flag: bool, __milliseconds: int = ...) -> int: ... @@ -125,10 +125,10 @@ def WriteFile(handle: int, buffer: bytes, overlapped: Literal[True]) -> Tuple[Ov @overload def WriteFile(handle: int, buffer: bytes, overlapped: Literal[False] = ...) -> Tuple[int, int]: ... @overload -def WriteFile(handle: int, buffer: bytes, overlapped: Union[int, bool]) -> Tuple[Any, int]: ... +def WriteFile(handle: int, buffer: bytes, overlapped: int | bool) -> Tuple[Any, int]: ... class Overlapped: event: int = ... def GetOverlappedResult(self, __wait: bool) -> Tuple[int, int]: ... def cancel(self) -> None: ... - def getbuffer(self) -> Optional[bytes]: ... + def getbuffer(self) -> bytes | None: ... diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index 25df252fe30e..fdf5a1b82834 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -21,7 +21,7 @@ class Aifc_read: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def getfp(self) -> IO[bytes]: ... @@ -35,7 +35,7 @@ class Aifc_read: def getcomptype(self) -> bytes: ... def getcompname(self) -> bytes: ... def getparams(self) -> _aifc_params: ... - def getmarkers(self) -> Optional[List[_Marker]]: ... + def getmarkers(self) -> List[_Marker] | None: ... def getmark(self, id: int) -> _Marker: ... def setpos(self, pos: int) -> None: ... def readframes(self, nframes: int) -> bytes: ... @@ -45,7 +45,7 @@ class Aifc_write: def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def aiff(self) -> None: ... @@ -65,7 +65,7 @@ class Aifc_write: def getparams(self) -> _aifc_params: ... def setmark(self, id: int, pos: int, name: bytes) -> None: ... def getmark(self, id: int) -> _Marker: ... - def getmarkers(self) -> Optional[List[_Marker]]: ... + def getmarkers(self) -> List[_Marker] | None: ... def tell(self) -> int: ... def writeframesraw(self, data: Any) -> None: ... # Actual type for data is Buffer Protocol def writeframes(self, data: Any) -> None: ... @@ -76,7 +76,7 @@ def open(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ... @overload def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... @overload -def open(f: _File, mode: Optional[str] = ...) -> Any: ... +def open(f: _File, mode: str | None = ...) -> Any: ... if sys.version_info < (3, 9): @overload @@ -84,4 +84,4 @@ if sys.version_info < (3, 9): @overload def openfp(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... @overload - def openfp(f: _File, mode: Optional[str] = ...) -> Any: ... + def openfp(f: _File, mode: str | None = ...) -> Any: ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index ec9ce24bc25b..2570cf87dbd7 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -32,9 +32,9 @@ ZERO_OR_MORE: str _UNRECOGNIZED_ARGS_ATTR: str # undocumented class ArgumentError(Exception): - argument_name: Optional[str] + argument_name: str | None message: str - def __init__(self, argument: Optional[Action], message: str) -> None: ... + def __init__(self, argument: Action | None, message: str) -> None: ... # undocumented class _AttributeHolder: @@ -43,7 +43,7 @@ class _AttributeHolder: # undocumented class _ActionsContainer: - description: Optional[str] + description: str | None prefix_chars: str argument_default: Any conflict_handler: str @@ -56,7 +56,7 @@ class _ActionsContainer: _defaults: Dict[str, Any] _negative_number_matcher: Pattern[str] _has_negative_number_optionals: List[bool] - def __init__(self, description: Optional[str], prefix_chars: str, argument_default: Any, conflict_handler: str) -> None: ... + def __init__(self, description: str | None, prefix_chars: str, argument_default: Any, conflict_handler: str) -> None: ... def register(self, registry_name: str, value: Any, object: Any) -> None: ... def _registry_get(self, registry_name: str, value: Any, default: Any = ...) -> Any: ... def set_defaults(self, **kwargs: Any) -> None: ... @@ -64,16 +64,16 @@ class _ActionsContainer: def add_argument( self, *name_or_flags: str, - action: Union[str, Type[Action]] = ..., - nargs: Union[int, str] = ..., + action: str | Type[Action] = ..., + nargs: int | str = ..., const: Any = ..., default: Any = ..., - type: Union[Callable[[str], _T], Callable[[str], _T], FileType] = ..., - choices: Optional[Iterable[_T]] = ..., + type: Callable[[str], _T] | Callable[[str], _T] | FileType = ..., + choices: Iterable[_T] | None = ..., required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., - dest: Optional[str] = ..., + help: str | None = ..., + metavar: str | Tuple[str, ...] | None = ..., + dest: str | None = ..., version: str = ..., **kwargs: Any, ) -> Action: ... @@ -84,7 +84,7 @@ class _ActionsContainer: def _add_container_actions(self, container: _ActionsContainer) -> None: ... def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> Dict[str, Any]: ... def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... - def _pop_action_class(self, kwargs: Any, default: Optional[Type[Action]] = ...) -> Type[Action]: ... + def _pop_action_class(self, kwargs: Any, default: Type[Action] | None = ...) -> Type[Action]: ... def _get_handler(self) -> Callable[[Action, Iterable[Tuple[str, Action]]], Any]: ... def _check_conflict(self, action: Action) -> None: ... def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[Tuple[str, Action]]) -> NoReturn: ... @@ -95,29 +95,29 @@ class _FormatterClass(Protocol): class ArgumentParser(_AttributeHolder, _ActionsContainer): prog: str - usage: Optional[str] - epilog: Optional[str] + usage: str | None + epilog: str | None formatter_class: _FormatterClass - fromfile_prefix_chars: Optional[str] + fromfile_prefix_chars: str | None add_help: bool allow_abbrev: bool # undocumented _positionals: _ArgumentGroup _optionals: _ArgumentGroup - _subparsers: Optional[_ArgumentGroup] + _subparsers: _ArgumentGroup | None if sys.version_info >= (3, 9): def __init__( self, - prog: Optional[str] = ..., - usage: Optional[str] = ..., - description: Optional[str] = ..., - epilog: Optional[str] = ..., + prog: str | None = ..., + usage: str | None = ..., + description: str | None = ..., + epilog: str | None = ..., parents: Sequence[ArgumentParser] = ..., formatter_class: _FormatterClass = ..., prefix_chars: str = ..., - fromfile_prefix_chars: Optional[str] = ..., + fromfile_prefix_chars: str | None = ..., argument_default: Any = ..., conflict_handler: str = ..., add_help: bool = ..., @@ -127,14 +127,14 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): else: def __init__( self, - prog: Optional[str] = ..., - usage: Optional[str] = ..., - description: Optional[str] = ..., - epilog: Optional[str] = ..., + prog: str | None = ..., + usage: str | None = ..., + description: str | None = ..., + epilog: str | None = ..., parents: Sequence[ArgumentParser] = ..., formatter_class: _FormatterClass = ..., prefix_chars: str = ..., - fromfile_prefix_chars: Optional[str] = ..., + fromfile_prefix_chars: str | None = ..., argument_default: Any = ..., conflict_handler: str = ..., add_help: bool = ..., @@ -143,11 +143,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): # The type-ignores in these overloads should be temporary. See: # https://github.com/python/typeshed/pull/2643#issuecomment-442280277 @overload - def parse_args(self, args: Optional[Sequence[str]] = ...) -> Namespace: ... + def parse_args(self, args: Sequence[str] | None = ...) -> Namespace: ... @overload - def parse_args(self, args: Optional[Sequence[str]], namespace: None) -> Namespace: ... # type: ignore + def parse_args(self, args: Sequence[str] | None, namespace: None) -> Namespace: ... # type: ignore @overload - def parse_args(self, args: Optional[Sequence[str]], namespace: _N) -> _N: ... + def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ... @overload def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore @overload @@ -157,46 +157,46 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): self, *, title: str = ..., - description: Optional[str] = ..., + description: str | None = ..., prog: str = ..., parser_class: Type[ArgumentParser] = ..., action: Type[Action] = ..., option_string: str = ..., - dest: Optional[str] = ..., + dest: str | None = ..., required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[str] = ..., + help: str | None = ..., + metavar: str | None = ..., ) -> _SubParsersAction: ... else: def add_subparsers( self, *, title: str = ..., - description: Optional[str] = ..., + description: str | None = ..., prog: str = ..., parser_class: Type[ArgumentParser] = ..., action: Type[Action] = ..., option_string: str = ..., - dest: Optional[str] = ..., - help: Optional[str] = ..., - metavar: Optional[str] = ..., + dest: str | None = ..., + help: str | None = ..., + metavar: str | None = ..., ) -> _SubParsersAction: ... - def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... - def print_help(self, file: Optional[IO[str]] = ...) -> None: ... + def print_usage(self, file: IO[str] | None = ...) -> None: ... + def print_help(self, file: IO[str] | None = ...) -> None: ... def format_usage(self) -> str: ... def format_help(self) -> str: ... def parse_known_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... + self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... ) -> Tuple[Namespace, List[str]]: ... def convert_arg_line_to_args(self, arg_line: str) -> List[str]: ... - def exit(self, status: int = ..., message: Optional[str] = ...) -> NoReturn: ... + def exit(self, status: int = ..., message: str | None = ...) -> NoReturn: ... def error(self, message: str) -> NoReturn: ... if sys.version_info >= (3, 7): def parse_intermixed_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... + self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... ) -> Namespace: ... def parse_known_intermixed_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... + self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... ) -> Tuple[Namespace, List[str]]: ... # undocumented def _get_optional_actions(self) -> List[Action]: ... @@ -205,14 +205,14 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def _read_args_from_files(self, arg_strings: List[str]) -> List[str]: ... def _match_argument(self, action: Action, arg_strings_pattern: str) -> int: ... def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: str) -> List[int]: ... - def _parse_optional(self, arg_string: str) -> Optional[Tuple[Optional[Action], str, Optional[str]]]: ... - def _get_option_tuples(self, option_string: str) -> List[Tuple[Action, str, Optional[str]]]: ... + def _parse_optional(self, arg_string: str) -> Tuple[Action | None, str, str | None] | None: ... + def _get_option_tuples(self, option_string: str) -> List[Tuple[Action, str, str | None]]: ... def _get_nargs_pattern(self, action: Action) -> str: ... def _get_values(self, action: Action, arg_strings: List[str]) -> Any: ... def _get_value(self, action: Action, arg_string: str) -> Any: ... def _check_value(self, action: Action, value: Any) -> None: ... def _get_formatter(self) -> HelpFormatter: ... - def _print_message(self, message: str, file: Optional[IO[str]] = ...) -> None: ... + def _print_message(self, message: str, file: IO[str] | None = ...) -> None: ... class HelpFormatter: # undocumented @@ -229,23 +229,23 @@ class HelpFormatter: _long_break_matcher: Pattern[str] _Section: Type[Any] # Nested class def __init__( - self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ... + self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ... ) -> None: ... def _indent(self) -> None: ... def _dedent(self) -> None: ... def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ... - def start_section(self, heading: Optional[str]) -> None: ... + def start_section(self, heading: str | None) -> None: ... def end_section(self) -> None: ... - def add_text(self, text: Optional[str]) -> None: ... + def add_text(self, text: str | None) -> None: ... def add_usage( - self, usage: Optional[str], actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[str] = ... + self, usage: str | None, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: str | None = ... ) -> None: ... def add_argument(self, action: Action) -> None: ... def add_arguments(self, actions: Iterable[Action]) -> None: ... def format_help(self) -> str: ... def _join_parts(self, part_strings: Iterable[str]) -> str: ... def _format_usage( - self, usage: str, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[str] + self, usage: str, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: str | None ) -> str: ... def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_ArgumentGroup]) -> str: ... def _format_text(self, text: str) -> str: ... @@ -257,7 +257,7 @@ class HelpFormatter: def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ... def _split_lines(self, text: str, width: int) -> List[str]: ... def _fill_text(self, text: str, width: int, indent: str) -> str: ... - def _get_help_string(self, action: Action) -> Optional[str]: ... + def _get_help_string(self, action: Action) -> str | None: ... def _get_default_metavar_for_optional(self, action: Action) -> str: ... def _get_default_metavar_for_positional(self, action: Action) -> str: ... @@ -269,33 +269,33 @@ class MetavarTypeHelpFormatter(HelpFormatter): ... class Action(_AttributeHolder): option_strings: Sequence[str] dest: str - nargs: Optional[Union[int, str]] + nargs: int | str | None const: Any default: Any - type: Union[Callable[[str], Any], FileType, None] - choices: Optional[Iterable[Any]] + type: Callable[[str], Any] | FileType | None + choices: Iterable[Any] | None required: bool - help: Optional[str] - metavar: Optional[Union[str, Tuple[str, ...]]] + help: str | None + metavar: str | Tuple[str, ...] | None def __init__( self, option_strings: Sequence[str], dest: str, - nargs: Optional[Union[int, str]] = ..., - const: Optional[_T] = ..., - default: Union[_T, str, None] = ..., - type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., - choices: Optional[Iterable[_T]] = ..., + nargs: int | str | None = ..., + const: _T | None = ..., + default: _T | str | None = ..., + type: Callable[[str], _T] | Callable[[str], _T] | FileType | None = ..., + choices: Iterable[_T] | None = ..., required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + help: str | None = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... def __call__( self, parser: ArgumentParser, namespace: Namespace, - values: Union[str, Sequence[Any], None], - option_string: Optional[str] = ..., + values: str | Sequence[Any] | None, + option_string: str | None = ..., ) -> None: ... if sys.version_info >= (3, 9): def format_usage(self) -> str: ... @@ -306,12 +306,12 @@ if sys.version_info >= (3, 9): self, option_strings: Sequence[str], dest: str, - default: Union[_T, str, None] = ..., - type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., - choices: Optional[Iterable[_T]] = ..., + default: _T | str | None = ..., + type: Callable[[str], _T] | Callable[[str], _T] | FileType | None = ..., + choices: Iterable[_T] | None = ..., required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + help: str | None = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... class Namespace(_AttributeHolder): @@ -324,19 +324,19 @@ class FileType: # undocumented _mode: str _bufsize: int - _encoding: Optional[str] - _errors: Optional[str] + _encoding: str | None + _errors: str | None def __init__( - self, mode: str = ..., bufsize: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ... + self, mode: str = ..., bufsize: int = ..., encoding: str | None = ..., errors: str | None = ... ) -> None: ... def __call__(self, string: str) -> IO[Any]: ... # undocumented class _ArgumentGroup(_ActionsContainer): - title: Optional[str] + title: str | None _group_actions: List[Action] def __init__( - self, container: _ActionsContainer, title: Optional[str] = ..., description: Optional[str] = ..., **kwargs: Any + self, container: _ActionsContainer, title: str | None = ..., description: str | None = ..., **kwargs: Any ) -> None: ... # undocumented @@ -357,20 +357,20 @@ class _StoreConstAction(Action): const: Any, default: Any = ..., required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + help: str | None = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... # undocumented class _StoreTrueAction(_StoreConstAction): def __init__( - self, option_strings: Sequence[str], dest: str, default: bool = ..., required: bool = ..., help: Optional[str] = ... + self, option_strings: Sequence[str], dest: str, default: bool = ..., required: bool = ..., help: str | None = ... ) -> None: ... # undocumented class _StoreFalseAction(_StoreConstAction): def __init__( - self, option_strings: Sequence[str], dest: str, default: bool = ..., required: bool = ..., help: Optional[str] = ... + self, option_strings: Sequence[str], dest: str, default: bool = ..., required: bool = ..., help: str | None = ... ) -> None: ... # undocumented @@ -385,25 +385,25 @@ class _AppendConstAction(Action): const: Any, default: Any = ..., required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + help: str | None = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... # undocumented class _CountAction(Action): def __init__( - self, option_strings: Sequence[str], dest: str, default: Any = ..., required: bool = ..., help: Optional[str] = ... + self, option_strings: Sequence[str], dest: str, default: Any = ..., required: bool = ..., help: str | None = ... ) -> None: ... # undocumented class _HelpAction(Action): - def __init__(self, option_strings: Sequence[str], dest: str = ..., default: str = ..., help: Optional[str] = ...) -> None: ... + def __init__(self, option_strings: Sequence[str], dest: str = ..., default: str = ..., help: str | None = ...) -> None: ... # undocumented class _VersionAction(Action): - version: Optional[str] + version: str | None def __init__( - self, option_strings: Sequence[str], version: Optional[str] = ..., dest: str = ..., default: str = ..., help: str = ... + self, option_strings: Sequence[str], version: str | None = ..., dest: str = ..., default: str = ..., help: str = ... ) -> None: ... # undocumented @@ -422,8 +422,8 @@ class _SubParsersAction(Action): parser_class: Type[ArgumentParser], dest: str = ..., required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + help: str | None = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... else: def __init__( @@ -432,8 +432,8 @@ class _SubParsersAction(Action): prog: str, parser_class: Type[ArgumentParser], dest: str = ..., - help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + help: str | None = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: str, **kwargs: Any) -> ArgumentParser: ... @@ -447,4 +447,4 @@ if sys.version_info < (3, 7): def _ensure_value(namespace: Namespace, name: str, value: Any) -> Any: ... # undocumented -def _get_action_name(argument: Optional[Action]) -> Optional[str]: ... +def _get_action_name(argument: Action | None) -> str | None: ... diff --git a/stdlib/array.pyi b/stdlib/array.pyi index a215494d2ff0..60d440dacf0e 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -15,13 +15,13 @@ class array(MutableSequence[_T], Generic[_T]): typecode: _TypeCode itemsize: int @overload - def __init__(self: array[int], typecode: _IntTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + def __init__(self: array[int], typecode: _IntTypeCode, __initializer: bytes | Iterable[_T] = ...) -> None: ... @overload - def __init__(self: array[float], typecode: _FloatTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + def __init__(self: array[float], typecode: _FloatTypeCode, __initializer: bytes | Iterable[_T] = ...) -> None: ... @overload - def __init__(self: array[str], typecode: _UnicodeTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + def __init__(self: array[str], typecode: _UnicodeTypeCode, __initializer: bytes | Iterable[_T] = ...) -> None: ... @overload - def __init__(self, typecode: str, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + def __init__(self, typecode: str, __initializer: bytes | Iterable[_T] = ...) -> None: ... def append(self, __v: _T) -> None: ... def buffer_info(self) -> Tuple[int, int]: ... def byteswap(self) -> None: ... @@ -55,7 +55,7 @@ class array(MutableSequence[_T], Generic[_T]): def __setitem__(self, i: int, o: _T) -> None: ... @overload def __setitem__(self, s: slice, o: array[_T]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... def __add__(self, x: array[_T]) -> array[_T]: ... def __ge__(self, other: array[_T]) -> bool: ... def __gt__(self, other: array[_T]) -> bool: ... diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index ff1cd00c7757..0f4e79db7ca7 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -150,7 +150,7 @@ class NodeVisitor: class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> AST: ... # TODO: Override the visit_* methods with better return types. - # The usual return type is Optional[AST], but Iterable[AST] + # The usual return type is AST | None, but Iterable[AST] # is also allowed in some cases -- this needs to be mapped. _T = TypeVar("_T", bound=AST) @@ -158,28 +158,28 @@ _T = TypeVar("_T", bound=AST) if sys.version_info >= (3, 8): @overload def parse( - source: Union[str, bytes], - filename: Union[str, bytes] = ..., + source: str | bytes, + filename: str | bytes = ..., mode: Literal["exec"] = ..., *, type_comments: bool = ..., - feature_version: Union[None, int, _typing.Tuple[int, int]] = ..., + feature_version: None | int | _typing.Tuple[int, int] = ..., ) -> Module: ... @overload def parse( - source: Union[str, bytes], - filename: Union[str, bytes] = ..., + source: str | bytes, + filename: str | bytes = ..., mode: str = ..., *, type_comments: bool = ..., - feature_version: Union[None, int, _typing.Tuple[int, int]] = ..., + feature_version: None | int | _typing.Tuple[int, int] = ..., ) -> AST: ... else: @overload - def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: Literal["exec"] = ...) -> Module: ... + def parse(source: str | bytes, filename: str | bytes = ..., mode: Literal["exec"] = ...) -> Module: ... @overload - def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ... + def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ... if sys.version_info >= (3, 9): def unparse(ast_obj: AST) -> str: ... @@ -188,20 +188,20 @@ def copy_location(new_node: _T, old_node: AST) -> _T: ... if sys.version_info >= (3, 9): def dump( - node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: Union[int, str, None] = ... + node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: int | str | None = ... ) -> str: ... else: def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: _T) -> _T: ... -def get_docstring(node: AST, clean: bool = ...) -> Optional[str]: ... +def get_docstring(node: AST, clean: bool = ...) -> str | None: ... def increment_lineno(node: _T, n: int = ...) -> _T: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[_typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: Union[str, AST]) -> Any: ... +def literal_eval(node_or_string: str | AST) -> Any: ... if sys.version_info >= (3, 8): - def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> Optional[str]: ... + def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> str | None: ... def walk(node: AST) -> Iterator[AST]: ... diff --git a/stdlib/asynchat.pyi b/stdlib/asynchat.pyi index 94637d04a264..4fabf46f4ed6 100644 --- a/stdlib/asynchat.pyi +++ b/stdlib/asynchat.pyi @@ -10,13 +10,13 @@ class simple_producer: class async_chat(asyncore.dispatcher): ac_in_buffer_size: int ac_out_buffer_size: int - def __init__(self, sock: Optional[socket.socket] = ..., map: Optional[asyncore._maptype] = ...) -> None: ... + def __init__(self, sock: socket.socket | None = ..., map: asyncore._maptype | None = ...) -> None: ... @abstractmethod def collect_incoming_data(self, data: bytes) -> None: ... @abstractmethod def found_terminator(self) -> None: ... - def set_terminator(self, term: Union[bytes, int, None]) -> None: ... - def get_terminator(self) -> Union[bytes, int, None]: ... + def set_terminator(self, term: bytes | int | None) -> None: ... + def get_terminator(self) -> bytes | int | None: ... def handle_read(self) -> None: ... def handle_write(self) -> None: ... def handle_close(self) -> None: ... diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index a0848da5b250..8f1bd00860b4 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -31,7 +31,7 @@ class Server(AbstractServer): protocol_factory: _ProtocolFactory, ssl_context: _SSLContext, backlog: int, - ssl_handshake_timeout: Optional[float], + ssl_handshake_timeout: float | None, ) -> None: ... else: def __init__(self, loop: AbstractEventLoop, sockets: list[socket]) -> None: ... @@ -42,7 +42,7 @@ class Server(AbstractServer): @property def sockets(self) -> list[socket]: ... else: - sockets: Optional[list[socket]] + sockets: list[socket] | None class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def run_forever(self) -> None: ... @@ -58,12 +58,12 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def shutdown_asyncgens(self) -> None: ... # Methods scheduling callbacks. All these return Handles. if sys.version_info >= (3, 7): - def call_soon(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ... + def call_soon(self, callback: Callable[..., Any], *args: Any, context: Context | None = ...) -> Handle: ... def call_later( - self, delay: float, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ... + self, delay: float, callback: Callable[..., Any], *args: Any, context: Context | None = ... ) -> TimerHandle: ... def call_at( - self, when: float, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ... + self, when: float, callback: Callable[..., Any], *args: Any, context: Context | None = ... ) -> TimerHandle: ... else: def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ... @@ -74,16 +74,16 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def create_future(self) -> Future[Any]: ... # Tasks methods if sys.version_info >= (3, 8): - def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: object = ...) -> Task[_T]: ... + def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T], *, name: object = ...) -> Task[_T]: ... else: - def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... + def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T]) -> Task[_T]: ... def set_task_factory( - self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]] + self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None ) -> None: ... - def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ... + def get_task_factory(self) -> Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None: ... # Methods for interacting with threads if sys.version_info >= (3, 7): - def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ... + def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Context | None = ...) -> Handle: ... else: def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Future[_T]: ... @@ -91,16 +91,16 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): # Network I/O methods returning Futures. async def getaddrinfo( self, - host: Optional[str], - port: Union[str, int, None], + host: str | None, + port: str | int | None, *, family: int = ..., type: int = ..., proto: int = ..., flags: int = ..., - ) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ... + ) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[str, int] | Tuple[str, int, int, int]]]: ... async def getnameinfo( - self, sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int = ... + self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ... ) -> Tuple[str, str]: ... if sys.version_info >= (3, 8): @overload @@ -115,11 +115,11 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., - happy_eyeballs_delay: Optional[float] = ..., - interleave: Optional[int] = ..., + local_addr: Tuple[str, int] | None = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., + happy_eyeballs_delay: float | None = ..., + interleave: int | None = ..., ) -> _TransProtPair: ... @overload async def create_connection( @@ -134,10 +134,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): flags: int = ..., sock: socket, local_addr: None = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., - happy_eyeballs_delay: Optional[float] = ..., - interleave: Optional[int] = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., + happy_eyeballs_delay: float | None = ..., + interleave: int | None = ..., ) -> _TransProtPair: ... elif sys.version_info >= (3, 7): @overload @@ -152,9 +152,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + local_addr: Tuple[str, int] | None = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... @overload async def create_connection( @@ -169,8 +169,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): flags: int = ..., sock: socket, local_addr: None = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... else: @overload @@ -185,8 +185,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., + local_addr: Tuple[str, int] | None = ..., + server_hostname: str | None = ..., ) -> _TransProtPair: ... @overload async def create_connection( @@ -201,17 +201,17 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): flags: int = ..., sock: socket, local_addr: None = ..., - server_hostname: Optional[str] = ..., + server_hostname: str | None = ..., ) -> _TransProtPair: ... if sys.version_info >= (3, 7): async def sock_sendfile( - self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, fallback: Optional[bool] = ... + self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ... ) -> int: ... @overload async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[Union[str, Sequence[str]]] = ..., + host: str | Sequence[str] | None = ..., port: int = ..., *, family: int = ..., @@ -219,9 +219,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): sock: None = ..., backlog: int = ..., ssl: _SSLContext = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., - ssl_handshake_timeout: Optional[float] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., + ssl_handshake_timeout: float | None = ..., start_serving: bool = ..., ) -> Server: ... @overload @@ -236,9 +236,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): sock: socket = ..., backlog: int = ..., ssl: _SSLContext = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., - ssl_handshake_timeout: Optional[float] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., + ssl_handshake_timeout: float | None = ..., start_serving: bool = ..., ) -> Server: ... async def connect_accepted_socket( @@ -247,14 +247,14 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): sock: socket, *, ssl: _SSLContext = ..., - ssl_handshake_timeout: Optional[float] = ..., + ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... async def sendfile( self, transport: BaseTransport, file: IO[bytes], offset: int = ..., - count: Optional[int] = ..., + count: int | None = ..., *, fallback: bool = ..., ) -> int: ... @@ -265,15 +265,15 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): sslcontext: ssl.SSLContext, *, server_side: bool = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., ) -> BaseTransport: ... else: @overload async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[Union[str, Sequence[str]]] = ..., + host: str | Sequence[str] | None = ..., port: int = ..., *, family: int = ..., @@ -281,8 +281,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): sock: None = ..., backlog: int = ..., ssl: _SSLContext = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., ) -> Server: ... @overload async def create_server( @@ -296,8 +296,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): sock: socket, backlog: int = ..., ssl: _SSLContext = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., ) -> Server: ... async def connect_accepted_socket( self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ... @@ -305,16 +305,16 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def create_datagram_endpoint( self, protocol_factory: _ProtocolFactory, - local_addr: Optional[Tuple[str, int]] = ..., - remote_addr: Optional[Tuple[str, int]] = ..., + local_addr: Tuple[str, int] | None = ..., + remote_addr: Tuple[str, int] | None = ..., *, family: int = ..., proto: int = ..., flags: int = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., - allow_broadcast: Optional[bool] = ..., - sock: Optional[socket] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., + allow_broadcast: bool | None = ..., + sock: socket | None = ..., ) -> _TransProtPair: ... # Pipes and subprocesses. async def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ... @@ -322,11 +322,11 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def subprocess_shell( self, protocol_factory: _ProtocolFactory, - cmd: Union[bytes, str], + cmd: bytes | str, *, - stdin: Union[int, IO[Any], None] = ..., - stdout: Union[int, IO[Any], None] = ..., - stderr: Union[int, IO[Any], None] = ..., + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., universal_newlines: Literal[False] = ..., shell: Literal[True] = ..., bufsize: Literal[0] = ..., @@ -340,9 +340,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): protocol_factory: _ProtocolFactory, program: Any, *args: Any, - stdin: Union[int, IO[Any], None] = ..., - stdout: Union[int, IO[Any], None] = ..., - stderr: Union[int, IO[Any], None] = ..., + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., universal_newlines: Literal[False] = ..., shell: Literal[True] = ..., bufsize: Literal[0] = ..., @@ -370,8 +370,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ... def remove_signal_handler(self, sig: int) -> bool: ... # Error handlers. - def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ... - def get_exception_handler(self) -> Optional[_ExceptionHandler]: ... + def set_exception_handler(self, handler: _ExceptionHandler | None) -> None: ... + def get_exception_handler(self) -> _ExceptionHandler | None: ... def default_exception_handler(self, context: _Context) -> None: ... def call_exception_handler(self, context: _Context) -> None: ... # Debug flag management. diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index acdf985205ab..96cea24f06a9 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -10,9 +10,9 @@ class BaseSubprocessTransport(transports.SubprocessTransport): _closed: bool # undocumented _protocol: protocols.SubprocessProtocol # undocumented _loop: events.AbstractEventLoop # undocumented - _proc: Optional[subprocess.Popen[Any]] # undocumented - _pid: Optional[int] # undocumented - _returncode: Optional[int] # undocumented + _proc: subprocess.Popen[Any] | None # undocumented + _pid: int | None # undocumented + _returncode: int | None # undocumented _exit_waiters: List[futures.Future[Any]] # undocumented _pending_calls: Deque[Tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented _pipes: Dict[int, _File] # undocumented @@ -21,19 +21,19 @@ class BaseSubprocessTransport(transports.SubprocessTransport): self, loop: events.AbstractEventLoop, protocol: protocols.SubprocessProtocol, - args: Union[str, bytes, Sequence[Union[str, bytes]]], + args: str | bytes | Sequence[str | bytes], shell: bool, stdin: _File, stdout: _File, stderr: _File, bufsize: int, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Any] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Any | None = ..., **kwargs: Any, ) -> None: ... def _start( self, - args: Union[str, bytes, Sequence[Union[str, bytes]]], + args: str | bytes | Sequence[str | bytes], shell: bool, stdin: _File, stdout: _File, @@ -45,26 +45,26 @@ class BaseSubprocessTransport(transports.SubprocessTransport): def get_protocol(self) -> protocols.BaseProtocol: ... def is_closing(self) -> bool: ... def close(self) -> None: ... - def get_pid(self) -> Optional[int]: ... # type: ignore - def get_returncode(self) -> Optional[int]: ... + def get_pid(self) -> int | None: ... # type: ignore + def get_returncode(self) -> int | None: ... def get_pipe_transport(self, fd: int) -> _File: ... # type: ignore def _check_proc(self) -> None: ... # undocumented def send_signal(self, signal: int) -> None: ... # type: ignore def terminate(self) -> None: ... def kill(self) -> None: ... - async def _connect_pipes(self, waiter: Optional[futures.Future[Any]]) -> None: ... # undocumented + async def _connect_pipes(self, waiter: futures.Future[Any] | None) -> None: ... # undocumented def _call(self, cb: Callable[..., Any], *data: Any) -> None: ... # undocumented - def _pipe_connection_lost(self, fd: int, exc: Optional[BaseException]) -> None: ... # undocumented + def _pipe_connection_lost(self, fd: int, exc: BaseException | None) -> None: ... # undocumented def _pipe_data_received(self, fd: int, data: bytes) -> None: ... # undocumented def _process_exited(self, returncode: int) -> None: ... # undocumented async def _wait(self) -> int: ... # undocumented def _try_finish(self) -> None: ... # undocumented - def _call_connection_lost(self, exc: Optional[BaseException]) -> None: ... # undocumented + def _call_connection_lost(self, exc: BaseException | None) -> None: ... # undocumented class WriteSubprocessPipeProto(protocols.BaseProtocol): # undocumented def __init__(self, proc: BaseSubprocessTransport, fd: int) -> None: ... def connection_made(self, transport: transports.BaseTransport) -> None: ... - def connection_lost(self, exc: Optional[BaseException]) -> None: ... + def connection_lost(self, exc: BaseException | None) -> None: ... def pause_writing(self) -> None: ... def resume_writing(self) -> None: ... diff --git a/stdlib/asyncio/base_tasks.pyi b/stdlib/asyncio/base_tasks.pyi index b336ae488aed..94c39a1e7592 100644 --- a/stdlib/asyncio/base_tasks.pyi +++ b/stdlib/asyncio/base_tasks.pyi @@ -5,5 +5,5 @@ from typing import Any, List, Optional from . import tasks def _task_repr_info(task: tasks.Task[Any]) -> List[str]: ... # undocumented -def _task_get_stack(task: tasks.Task[Any], limit: Optional[int]) -> List[FrameType]: ... # undocumented -def _task_print_stack(task: tasks.Task[Any], limit: Optional[int], file: StrOrBytesPath) -> None: ... # undocumented +def _task_get_stack(task: tasks.Task[Any], limit: int | None) -> List[FrameType]: ... # undocumented +def _task_print_stack(task: tasks.Task[Any], limit: int | None, file: StrOrBytesPath) -> None: ... # undocumented diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 61aecbf6a698..ec7d4b4ef312 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -28,7 +28,7 @@ class Handle: _args: Sequence[Any] if sys.version_info >= (3, 7): def __init__( - self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop, context: Optional[Context] = ... + self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop, context: Context | None = ... ) -> None: ... else: def __init__(self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ... @@ -46,7 +46,7 @@ class TimerHandle(Handle): callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop, - context: Optional[Context] = ..., + context: Context | None = ..., ) -> None: ... else: def __init__(self, when: float, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ... @@ -101,16 +101,16 @@ class AbstractEventLoop(metaclass=ABCMeta): # Tasks methods if sys.version_info >= (3, 8): @abstractmethod - def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ...) -> Task[_T]: ... + def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T], *, name: str | None = ...) -> Task[_T]: ... else: @abstractmethod - def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... + def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T]) -> Task[_T]: ... @abstractmethod def set_task_factory( - self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]] + self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None ) -> None: ... @abstractmethod - def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ... + def get_task_factory(self) -> Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None: ... # Methods for interacting with threads @abstractmethod def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... @@ -122,17 +122,17 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod async def getaddrinfo( self, - host: Optional[str], - port: Union[str, int, None], + host: str | None, + port: str | int | None, *, family: int = ..., type: int = ..., proto: int = ..., flags: int = ..., - ) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ... + ) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[str, int] | Tuple[str, int, int, int]]]: ... @abstractmethod async def getnameinfo( - self, sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int = ... + self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ... ) -> Tuple[str, str]: ... if sys.version_info >= (3, 8): @overload @@ -148,11 +148,11 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., - happy_eyeballs_delay: Optional[float] = ..., - interleave: Optional[int] = ..., + local_addr: Tuple[str, int] | None = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., + happy_eyeballs_delay: float | None = ..., + interleave: int | None = ..., ) -> _TransProtPair: ... @overload @abstractmethod @@ -168,10 +168,10 @@ class AbstractEventLoop(metaclass=ABCMeta): flags: int = ..., sock: socket, local_addr: None = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., - happy_eyeballs_delay: Optional[float] = ..., - interleave: Optional[int] = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., + happy_eyeballs_delay: float | None = ..., + interleave: int | None = ..., ) -> _TransProtPair: ... elif sys.version_info >= (3, 7): @overload @@ -187,9 +187,9 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + local_addr: Tuple[str, int] | None = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... @overload @abstractmethod @@ -205,8 +205,8 @@ class AbstractEventLoop(metaclass=ABCMeta): flags: int = ..., sock: socket, local_addr: None = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... else: @overload @@ -222,8 +222,8 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., + local_addr: Tuple[str, int] | None = ..., + server_hostname: str | None = ..., ) -> _TransProtPair: ... @overload @abstractmethod @@ -239,19 +239,19 @@ class AbstractEventLoop(metaclass=ABCMeta): flags: int = ..., sock: socket, local_addr: None = ..., - server_hostname: Optional[str] = ..., + server_hostname: str | None = ..., ) -> _TransProtPair: ... if sys.version_info >= (3, 7): @abstractmethod async def sock_sendfile( - self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *, fallback: Optional[bool] = ... + self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ... ) -> int: ... @overload @abstractmethod async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[Union[str, Sequence[str]]] = ..., + host: str | Sequence[str] | None = ..., port: int = ..., *, family: int = ..., @@ -259,9 +259,9 @@ class AbstractEventLoop(metaclass=ABCMeta): sock: None = ..., backlog: int = ..., ssl: _SSLContext = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., - ssl_handshake_timeout: Optional[float] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., + ssl_handshake_timeout: float | None = ..., start_serving: bool = ..., ) -> Server: ... @overload @@ -277,30 +277,30 @@ class AbstractEventLoop(metaclass=ABCMeta): sock: socket = ..., backlog: int = ..., ssl: _SSLContext = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., - ssl_handshake_timeout: Optional[float] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., + ssl_handshake_timeout: float | None = ..., start_serving: bool = ..., ) -> Server: ... async def create_unix_connection( self, protocol_factory: _ProtocolFactory, - path: Optional[str] = ..., + path: str | None = ..., *, ssl: _SSLContext = ..., - sock: Optional[socket] = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + sock: socket | None = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... async def create_unix_server( self, protocol_factory: _ProtocolFactory, - path: Optional[str] = ..., + path: str | None = ..., *, - sock: Optional[socket] = ..., + sock: socket | None = ..., backlog: int = ..., ssl: _SSLContext = ..., - ssl_handshake_timeout: Optional[float] = ..., + ssl_handshake_timeout: float | None = ..., start_serving: bool = ..., ) -> Server: ... @abstractmethod @@ -309,7 +309,7 @@ class AbstractEventLoop(metaclass=ABCMeta): transport: BaseTransport, file: IO[bytes], offset: int = ..., - count: Optional[int] = ..., + count: int | None = ..., *, fallback: bool = ..., ) -> int: ... @@ -321,8 +321,8 @@ class AbstractEventLoop(metaclass=ABCMeta): sslcontext: ssl.SSLContext, *, server_side: bool = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., ) -> BaseTransport: ... else: @overload @@ -330,7 +330,7 @@ class AbstractEventLoop(metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[Union[str, Sequence[str]]] = ..., + host: str | Sequence[str] | None = ..., port: int = ..., *, family: int = ..., @@ -338,8 +338,8 @@ class AbstractEventLoop(metaclass=ABCMeta): sock: None = ..., backlog: int = ..., ssl: _SSLContext = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., ) -> Server: ... @overload @abstractmethod @@ -354,8 +354,8 @@ class AbstractEventLoop(metaclass=ABCMeta): sock: socket, backlog: int = ..., ssl: _SSLContext = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., ) -> Server: ... async def create_unix_connection( self, @@ -363,15 +363,15 @@ class AbstractEventLoop(metaclass=ABCMeta): path: str, *, ssl: _SSLContext = ..., - sock: Optional[socket] = ..., - server_hostname: Optional[str] = ..., + sock: socket | None = ..., + server_hostname: str | None = ..., ) -> _TransProtPair: ... async def create_unix_server( self, protocol_factory: _ProtocolFactory, path: str, *, - sock: Optional[socket] = ..., + sock: socket | None = ..., backlog: int = ..., ssl: _SSLContext = ..., ) -> Server: ... @@ -379,16 +379,16 @@ class AbstractEventLoop(metaclass=ABCMeta): async def create_datagram_endpoint( self, protocol_factory: _ProtocolFactory, - local_addr: Optional[Tuple[str, int]] = ..., - remote_addr: Optional[Tuple[str, int]] = ..., + local_addr: Tuple[str, int] | None = ..., + remote_addr: Tuple[str, int] | None = ..., *, family: int = ..., proto: int = ..., flags: int = ..., - reuse_address: Optional[bool] = ..., - reuse_port: Optional[bool] = ..., - allow_broadcast: Optional[bool] = ..., - sock: Optional[socket] = ..., + reuse_address: bool | None = ..., + reuse_port: bool | None = ..., + allow_broadcast: bool | None = ..., + sock: socket | None = ..., ) -> _TransProtPair: ... # Pipes and subprocesses. @abstractmethod @@ -399,11 +399,11 @@ class AbstractEventLoop(metaclass=ABCMeta): async def subprocess_shell( self, protocol_factory: _ProtocolFactory, - cmd: Union[bytes, str], + cmd: bytes | str, *, - stdin: Union[int, IO[Any], None] = ..., - stdout: Union[int, IO[Any], None] = ..., - stderr: Union[int, IO[Any], None] = ..., + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., universal_newlines: Literal[False] = ..., shell: Literal[True] = ..., bufsize: Literal[0] = ..., @@ -418,9 +418,9 @@ class AbstractEventLoop(metaclass=ABCMeta): protocol_factory: _ProtocolFactory, program: Any, *args: Any, - stdin: Union[int, IO[Any], None] = ..., - stdout: Union[int, IO[Any], None] = ..., - stderr: Union[int, IO[Any], None] = ..., + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., universal_newlines: Literal[False] = ..., shell: Literal[True] = ..., bufsize: Literal[0] = ..., @@ -464,9 +464,9 @@ class AbstractEventLoop(metaclass=ABCMeta): def remove_signal_handler(self, sig: int) -> bool: ... # Error handlers. @abstractmethod - def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ... + def set_exception_handler(self, handler: _ExceptionHandler | None) -> None: ... @abstractmethod - def get_exception_handler(self) -> Optional[_ExceptionHandler]: ... + def get_exception_handler(self) -> _ExceptionHandler | None: ... @abstractmethod def default_exception_handler(self, context: _Context) -> None: ... @abstractmethod @@ -484,7 +484,7 @@ class AbstractEventLoopPolicy(metaclass=ABCMeta): @abstractmethod def get_event_loop(self) -> AbstractEventLoop: ... @abstractmethod - def set_event_loop(self, loop: Optional[AbstractEventLoop]) -> None: ... + def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ... @abstractmethod def new_event_loop(self) -> AbstractEventLoop: ... # Child processes handling (Unix only). @@ -496,17 +496,17 @@ class AbstractEventLoopPolicy(metaclass=ABCMeta): class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta): def __init__(self) -> None: ... def get_event_loop(self) -> AbstractEventLoop: ... - def set_event_loop(self, loop: Optional[AbstractEventLoop]) -> None: ... + def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ... def new_event_loop(self) -> AbstractEventLoop: ... def get_event_loop_policy() -> AbstractEventLoopPolicy: ... -def set_event_loop_policy(policy: Optional[AbstractEventLoopPolicy]) -> None: ... +def set_event_loop_policy(policy: AbstractEventLoopPolicy | None) -> None: ... def get_event_loop() -> AbstractEventLoop: ... -def set_event_loop(loop: Optional[AbstractEventLoop]) -> None: ... +def set_event_loop(loop: AbstractEventLoop | None) -> None: ... def new_event_loop() -> AbstractEventLoop: ... def get_child_watcher() -> AbstractChildWatcher: ... def set_child_watcher(watcher: AbstractChildWatcher) -> None: ... -def _set_running_loop(__loop: Optional[AbstractEventLoop]) -> None: ... +def _set_running_loop(__loop: AbstractEventLoop | None) -> None: ... def _get_running_loop() -> AbstractEventLoop: ... if sys.version_info >= (3, 7): diff --git a/stdlib/asyncio/exceptions.pyi b/stdlib/asyncio/exceptions.pyi index ecec9560a850..5ee8a3ea3c08 100644 --- a/stdlib/asyncio/exceptions.pyi +++ b/stdlib/asyncio/exceptions.pyi @@ -7,9 +7,9 @@ if sys.version_info >= (3, 8): class InvalidStateError(Exception): ... class SendfileNotAvailableError(RuntimeError): ... class IncompleteReadError(EOFError): - expected: Optional[int] + expected: int | None partial: bytes - def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... + def __init__(self, partial: bytes, expected: int | None) -> None: ... class LimitOverrunError(Exception): consumed: int def __init__(self, message: str, consumed: int) -> None: ... diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index 5c075a910931..8dd07a7a90b2 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -5,7 +5,7 @@ from types import FrameType, FunctionType from typing import Any, Dict, Iterable, Optional, Tuple, Union, overload class _HasWrapper: - __wrapper__: Union[_HasWrapper, FunctionType] + __wrapper__: _HasWrapper | FunctionType _FuncType = Union[FunctionType, _HasWrapper, functools.partial[Any], functools.partialmethod[Any]] @@ -13,8 +13,8 @@ if sys.version_info >= (3, 7): @overload def _get_function_source(func: _FuncType) -> Tuple[str, int]: ... @overload - def _get_function_source(func: object) -> Optional[Tuple[str, int]]: ... + def _get_function_source(func: object) -> Tuple[str, int] | None: ... def _format_callback_source(func: object, args: Iterable[Any]) -> str: ... def _format_args_and_kwargs(args: Iterable[Any], kwargs: Dict[str, Any]) -> str: ... def _format_callback(func: object, args: Iterable[Any], kwargs: Dict[str, Any], suffix: str = ...) -> str: ... - def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> traceback.StackSummary: ... + def extract_stack(f: FrameType | None = ..., limit: int | None = ...) -> traceback.StackSummary: ... diff --git a/stdlib/asyncio/futures.pyi b/stdlib/asyncio/futures.pyi index 1252c02cb58d..a5b19cacccd9 100644 --- a/stdlib/asyncio/futures.pyi +++ b/stdlib/asyncio/futures.pyi @@ -33,28 +33,28 @@ class Future(Awaitable[_T], Iterable[_T]): _exception: BaseException _blocking = False _log_traceback = False - def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ... + def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ... def __repr__(self) -> str: ... def __del__(self) -> None: ... if sys.version_info >= (3, 7): def get_loop(self) -> AbstractEventLoop: ... def _callbacks(self: _S) -> List[Tuple[Callable[[_S], Any], Context]]: ... - def add_done_callback(self: _S, __fn: Callable[[_S], Any], *, context: Optional[Context] = ...) -> None: ... + def add_done_callback(self: _S, __fn: Callable[[_S], Any], *, context: Context | None = ...) -> None: ... else: @property def _callbacks(self: _S) -> List[Callable[[_S], Any]]: ... def add_done_callback(self: _S, __fn: Callable[[_S], Any]) -> None: ... if sys.version_info >= (3, 9): - def cancel(self, msg: Optional[str] = ...) -> bool: ... + def cancel(self, msg: str | None = ...) -> bool: ... else: def cancel(self) -> bool: ... def cancelled(self) -> bool: ... def done(self) -> bool: ... def result(self) -> _T: ... - def exception(self) -> Optional[BaseException]: ... + def exception(self) -> BaseException | None: ... def remove_done_callback(self: _S, __fn: Callable[[_S], Any]) -> int: ... def set_result(self, __result: _T) -> None: ... - def set_exception(self, __exception: Union[type, BaseException]) -> None: ... + def set_exception(self, __exception: type | BaseException) -> None: ... def __iter__(self) -> Generator[Any, None, _T]: ... def __await__(self) -> Generator[Any, None, _T]: ... @property @@ -62,4 +62,4 @@ class Future(Awaitable[_T], Iterable[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -def wrap_future(future: Union[_ConcurrentFuture[_T], Future[_T]], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ... +def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 7480c3394e70..af605f9a93e6 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -9,19 +9,19 @@ _T = TypeVar("_T") if sys.version_info >= (3, 9): class _ContextManagerMixin: - def __init__(self, lock: Union[Lock, Semaphore]) -> None: ... + def __init__(self, lock: Lock | Semaphore) -> None: ... def __aenter__(self) -> Awaitable[None]: ... def __aexit__( - self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> Awaitable[None]: ... else: class _ContextManager: - def __init__(self, lock: Union[Lock, Semaphore]) -> None: ... + def __init__(self, lock: Lock | Semaphore) -> None: ... def __enter__(self) -> object: ... def __exit__(self, *args: Any) -> None: ... class _ContextManagerMixin: - def __init__(self, lock: Union[Lock, Semaphore]) -> None: ... + def __init__(self, lock: Lock | Semaphore) -> None: ... # Apparently this exists to *prohibit* use as a context manager. def __enter__(self) -> object: ... def __exit__(self, *args: Any) -> None: ... @@ -29,24 +29,24 @@ else: def __await__(self) -> Generator[Any, None, _ContextManager]: ... def __aenter__(self) -> Awaitable[None]: ... def __aexit__( - self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> Awaitable[None]: ... class Lock(_ContextManagerMixin): - def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ... + def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> bool: ... def release(self) -> None: ... class Event: - def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ... + def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ... def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... async def wait(self) -> bool: ... class Condition(_ContextManagerMixin): - def __init__(self, lock: Optional[Lock] = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ... + def __init__(self, lock: Lock | None = ..., *, loop: AbstractEventLoop | None = ...) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> bool: ... def release(self) -> None: ... @@ -58,11 +58,11 @@ class Condition(_ContextManagerMixin): class Semaphore(_ContextManagerMixin): _value: int _waiters: Deque[Future[Any]] - def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ... + def __init__(self, value: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ... def locked(self) -> bool: ... async def acquire(self) -> bool: ... def release(self) -> None: ... def _wake_up_next(self) -> None: ... class BoundedSemaphore(Semaphore): - def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ... + def __init__(self, value: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ... diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index b4598cec8ef8..b2a1b104b89b 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -8,7 +8,7 @@ from . import base_events, constants, events, futures, streams, transports if sys.version_info >= (3, 8): class _WarnCallbackProtocol(Protocol): def __call__( - self, message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ... + self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... ) -> None: ... class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): @@ -17,9 +17,9 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., + server: events.AbstractServer | None = ..., ) -> None: ... def __repr__(self) -> str: ... if sys.version_info >= (3, 8): @@ -34,9 +34,9 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTran loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., + server: events.AbstractServer | None = ..., ) -> None: ... class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): @@ -45,9 +45,9 @@ class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.Wri loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., + server: events.AbstractServer | None = ..., ) -> None: ... class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): @@ -56,9 +56,9 @@ class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., + server: events.AbstractServer | None = ..., ) -> None: ... class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ... @@ -71,9 +71,9 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., + server: events.AbstractServer | None = ..., ) -> None: ... def _set_extra(self, sock: socket) -> None: ... def can_write_eof(self) -> Literal[True]: ... diff --git a/stdlib/asyncio/protocols.pyi b/stdlib/asyncio/protocols.pyi index ec89a299956f..a6b356550edb 100644 --- a/stdlib/asyncio/protocols.pyi +++ b/stdlib/asyncio/protocols.pyi @@ -4,13 +4,13 @@ from typing import Optional, Tuple class BaseProtocol: def connection_made(self, transport: transports.BaseTransport) -> None: ... - def connection_lost(self, exc: Optional[Exception]) -> None: ... + def connection_lost(self, exc: Exception | None) -> None: ... def pause_writing(self) -> None: ... def resume_writing(self) -> None: ... class Protocol(BaseProtocol): def data_received(self, data: bytes) -> None: ... - def eof_received(self) -> Optional[bool]: ... + def eof_received(self) -> bool | None: ... if sys.version_info >= (3, 7): class BufferedProtocol(BaseProtocol): @@ -23,5 +23,5 @@ class DatagramProtocol(BaseProtocol): class SubprocessProtocol(BaseProtocol): def pipe_data_received(self, fd: int, data: bytes) -> None: ... - def pipe_connection_lost(self, fd: int, exc: Optional[Exception]) -> None: ... + def pipe_connection_lost(self, fd: int, exc: Exception | None) -> None: ... def process_exited(self) -> None: ... diff --git a/stdlib/asyncio/queues.pyi b/stdlib/asyncio/queues.pyi index 2d4bada035b3..25d815aed455 100644 --- a/stdlib/asyncio/queues.pyi +++ b/stdlib/asyncio/queues.pyi @@ -11,7 +11,7 @@ class QueueFull(Exception): ... _T = TypeVar("_T") class Queue(Generic[_T]): - def __init__(self, maxsize: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ... + def __init__(self, maxsize: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ... def _init(self, maxsize: int) -> None: ... def _get(self) -> _T: ... def _put(self, item: _T) -> None: ... diff --git a/stdlib/asyncio/runners.pyi b/stdlib/asyncio/runners.pyi index 1628cb3e89f1..aa914fac0767 100644 --- a/stdlib/asyncio/runners.pyi +++ b/stdlib/asyncio/runners.pyi @@ -5,6 +5,6 @@ if sys.version_info >= (3, 7): _T = TypeVar("_T") if sys.version_info >= (3, 8): - def run(main: Awaitable[_T], *, debug: Optional[bool] = ...) -> _T: ... + def run(main: Awaitable[_T], *, debug: bool | None = ...) -> _T: ... else: def run(main: Awaitable[_T], *, debug: bool = ...) -> _T: ... diff --git a/stdlib/asyncio/selector_events.pyi b/stdlib/asyncio/selector_events.pyi index 8946bb050ac2..7ed70cda0ad7 100644 --- a/stdlib/asyncio/selector_events.pyi +++ b/stdlib/asyncio/selector_events.pyi @@ -4,4 +4,4 @@ from typing import Optional from . import base_events class BaseSelectorEventLoop(base_events.BaseEventLoop): - def __init__(self, selector: Optional[selectors.BaseSelector] = ...) -> None: ... + def __init__(self, selector: selectors.BaseSelector | None = ...) -> None: ... diff --git a/stdlib/asyncio/sslproto.pyi b/stdlib/asyncio/sslproto.pyi index a267736ec997..ad4c537fbbab 100644 --- a/stdlib/asyncio/sslproto.pyi +++ b/stdlib/asyncio/sslproto.pyi @@ -5,7 +5,7 @@ from typing_extensions import Literal from . import constants, events, futures, protocols, transports -def _create_transport_context(server_side: bool, server_hostname: Optional[str]) -> ssl.SSLContext: ... +def _create_transport_context(server_side: bool, server_hostname: str | None) -> ssl.SSLContext: ... _UNWRAPPED: Literal["UNWRAPPED"] _DO_HANDSHAKE: Literal["DO_HANDSHAKE"] @@ -18,25 +18,25 @@ class _SSLPipe: _context: ssl.SSLContext _server_side: bool - _server_hostname: Optional[str] + _server_hostname: str | None _state: str _incoming: ssl.MemoryBIO _outgoing: ssl.MemoryBIO - _sslobj: Optional[ssl.SSLObject] + _sslobj: ssl.SSLObject | None _need_ssldata: bool - _handshake_cb: Optional[Callable[[Optional[BaseException]], None]] - _shutdown_cb: Optional[Callable[[], None]] - def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: Optional[str] = ...) -> None: ... + _handshake_cb: Callable[[BaseException | None], None] | None + _shutdown_cb: Callable[[], None] | None + def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: str | None = ...) -> None: ... @property def context(self) -> ssl.SSLContext: ... @property - def ssl_object(self) -> Optional[ssl.SSLObject]: ... + def ssl_object(self) -> ssl.SSLObject | None: ... @property def need_ssldata(self) -> bool: ... @property def wrapped(self) -> bool: ... - def do_handshake(self, callback: Optional[Callable[[Optional[BaseException]], None]] = ...) -> List[bytes]: ... - def shutdown(self, callback: Optional[Callable[[], None]] = ...) -> List[bytes]: ... + def do_handshake(self, callback: Callable[[BaseException | None], None] | None = ...) -> List[bytes]: ... + def shutdown(self, callback: Callable[[], None] | None = ...) -> List[bytes]: ... def feed_eof(self) -> None: ... def feed_ssldata(self, data: bytes, only_handshake: bool = ...) -> Tuple[List[bytes], List[bytes]]: ... def feed_appdata(self, data: bytes, offset: int = ...) -> Tuple[List[bytes], int]: ... @@ -49,7 +49,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): _ssl_protocol: SSLProtocol _closed: bool def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ... - def get_extra_info(self, name: str, default: Optional[Any] = ...) -> Dict[str, Any]: ... + def get_extra_info(self, name: str, default: Any | None = ...) -> Dict[str, Any]: ... def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ... def get_protocol(self) -> protocols.BaseProtocol: ... def is_closing(self) -> bool: ... @@ -58,7 +58,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): def is_reading(self) -> bool: ... def pause_reading(self) -> None: ... def resume_reading(self) -> None: ... - def set_write_buffer_limits(self, high: Optional[int] = ..., low: Optional[int] = ...) -> None: ... + def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ... def get_write_buffer_size(self) -> int: ... if sys.version_info >= (3, 7): @property @@ -70,7 +70,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): class SSLProtocol(protocols.Protocol): _server_side: bool - _server_hostname: Optional[str] + _server_hostname: str | None _sslcontext: ssl.SSLContext _extra: Dict[str, Any] _write_backlog: Deque[Tuple[bytes, int]] @@ -78,13 +78,13 @@ class SSLProtocol(protocols.Protocol): _waiter: futures.Future[Any] _loop: events.AbstractEventLoop _app_transport: _SSLProtocolTransport - _sslpipe: Optional[_SSLPipe] + _sslpipe: _SSLPipe | None _session_established: bool _in_handshake: bool _in_shutdown: bool - _transport: Optional[transports.BaseTransport] + _transport: transports.BaseTransport | None _call_connection_made: bool - _ssl_handshake_timeout: Optional[int] + _ssl_handshake_timeout: int | None _app_protocol: protocols.BaseProtocol _app_protocol_is_buffer: bool @@ -96,9 +96,9 @@ class SSLProtocol(protocols.Protocol): sslcontext: ssl.SSLContext, waiter: futures.Future[Any], server_side: bool = ..., - server_hostname: Optional[str] = ..., + server_hostname: str | None = ..., call_connection_made: bool = ..., - ssl_handshake_timeout: Optional[int] = ..., + ssl_handshake_timeout: int | None = ..., ) -> None: ... else: def __init__( @@ -108,25 +108,25 @@ class SSLProtocol(protocols.Protocol): sslcontext: ssl.SSLContext, waiter: futures.Future[Any], server_side: bool = ..., - server_hostname: Optional[str] = ..., + server_hostname: str | None = ..., call_connection_made: bool = ..., ) -> None: ... if sys.version_info >= (3, 7): def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ... - def _wakeup_waiter(self, exc: Optional[BaseException] = ...) -> None: ... + def _wakeup_waiter(self, exc: BaseException | None = ...) -> None: ... def connection_made(self, transport: transports.BaseTransport) -> None: ... - def connection_lost(self, exc: Optional[BaseException]) -> None: ... + def connection_lost(self, exc: BaseException | None) -> None: ... def pause_writing(self) -> None: ... def resume_writing(self) -> None: ... def data_received(self, data: bytes) -> None: ... def eof_received(self) -> None: ... - def _get_extra_info(self, name: str, default: Optional[Any] = ...) -> Any: ... + def _get_extra_info(self, name: str, default: Any | None = ...) -> Any: ... def _start_shutdown(self) -> None: ... def _write_appdata(self, data: bytes) -> None: ... def _start_handshake(self) -> None: ... if sys.version_info >= (3, 7): def _check_handshake_timeout(self) -> None: ... - def _on_handshake_complete(self, handshake_exc: Optional[BaseException]) -> None: ... + def _on_handshake_complete(self, handshake_exc: BaseException | None) -> None: ... def _process_write_backlog(self) -> None: ... def _fatal_error(self, exc: BaseException, message: str = ...) -> None: ... def _finalize(self) -> None: ... diff --git a/stdlib/asyncio/staggered.pyi b/stdlib/asyncio/staggered.pyi index 057883e0ab2c..3a70fbf88b46 100644 --- a/stdlib/asyncio/staggered.pyi +++ b/stdlib/asyncio/staggered.pyi @@ -6,7 +6,7 @@ from . import events if sys.version_info >= (3, 8): async def staggered_race( coro_fns: Iterable[Callable[[], Awaitable[Any]]], - delay: Optional[float], + delay: float | None, *, - loop: Optional[events.AbstractEventLoop] = ..., - ) -> Tuple[Any, Optional[int], List[Optional[Exception]]]: ... + loop: events.AbstractEventLoop | None = ..., + ) -> Tuple[Any, int | None, List[Exception | None]]: ... diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index 770baa9fb4af..75e7e96bfc0d 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -9,30 +9,30 @@ _ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Await if sys.version_info < (3, 8): class IncompleteReadError(EOFError): - expected: Optional[int] + expected: int | None partial: bytes - def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... + def __init__(self, partial: bytes, expected: int | None) -> None: ... class LimitOverrunError(Exception): consumed: int def __init__(self, message: str, consumed: int) -> None: ... async def open_connection( - host: Optional[str] = ..., - port: Optional[Union[int, str]] = ..., + host: str | None = ..., + port: int | str | None = ..., *, - loop: Optional[events.AbstractEventLoop] = ..., + loop: events.AbstractEventLoop | None = ..., limit: int = ..., - ssl_handshake_timeout: Optional[float] = ..., + ssl_handshake_timeout: float | None = ..., **kwds: Any, ) -> Tuple[StreamReader, StreamWriter]: ... async def start_server( client_connected_cb: _ClientConnectedCallback, - host: Optional[str] = ..., - port: Optional[Union[int, str]] = ..., + host: str | None = ..., + port: int | str | None = ..., *, - loop: Optional[events.AbstractEventLoop] = ..., + loop: events.AbstractEventLoop | None = ..., limit: int = ..., - ssl_handshake_timeout: Optional[float] = ..., + ssl_handshake_timeout: float | None = ..., **kwds: Any, ) -> Server: ... @@ -42,29 +42,29 @@ if sys.platform != "win32": else: _PathType = str async def open_unix_connection( - path: Optional[_PathType] = ..., *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., **kwds: Any + path: _PathType | None = ..., *, loop: events.AbstractEventLoop | None = ..., limit: int = ..., **kwds: Any ) -> Tuple[StreamReader, StreamWriter]: ... async def start_unix_server( client_connected_cb: _ClientConnectedCallback, - path: Optional[_PathType] = ..., + path: _PathType | None = ..., *, - loop: Optional[events.AbstractEventLoop] = ..., + loop: events.AbstractEventLoop | None = ..., limit: int = ..., **kwds: Any, ) -> Server: ... class FlowControlMixin(protocols.Protocol): - def __init__(self, loop: Optional[events.AbstractEventLoop] = ...) -> None: ... + def __init__(self, loop: events.AbstractEventLoop | None = ...) -> None: ... class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): def __init__( self, stream_reader: StreamReader, - client_connected_cb: Optional[_ClientConnectedCallback] = ..., - loop: Optional[events.AbstractEventLoop] = ..., + client_connected_cb: _ClientConnectedCallback | None = ..., + loop: events.AbstractEventLoop | None = ..., ) -> None: ... def connection_made(self, transport: transports.BaseTransport) -> None: ... - def connection_lost(self, exc: Optional[Exception]) -> None: ... + def connection_lost(self, exc: Exception | None) -> None: ... def data_received(self, data: bytes) -> None: ... def eof_received(self) -> bool: ... @@ -73,7 +73,7 @@ class StreamWriter: self, transport: transports.BaseTransport, protocol: protocols.BaseProtocol, - reader: Optional[StreamReader], + reader: StreamReader | None, loop: events.AbstractEventLoop, ) -> None: ... @property @@ -90,7 +90,7 @@ class StreamWriter: async def drain(self) -> None: ... class StreamReader: - def __init__(self, limit: int = ..., loop: Optional[events.AbstractEventLoop] = ...) -> None: ... + def __init__(self, limit: int = ..., loop: events.AbstractEventLoop | None = ...) -> None: ... def exception(self) -> Exception: ... def set_exception(self, exc: Exception) -> None: ... def set_transport(self, transport: transports.BaseTransport) -> None: ... diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index 9d28d9e2bc4b..544d31e5e35b 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -15,37 +15,37 @@ STDOUT: int DEVNULL: int class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol): - stdin: Optional[streams.StreamWriter] - stdout: Optional[streams.StreamReader] - stderr: Optional[streams.StreamReader] + stdin: streams.StreamWriter | None + stdout: streams.StreamReader | None + stderr: streams.StreamReader | None def __init__(self, limit: int, loop: events.AbstractEventLoop) -> None: ... def connection_made(self, transport: transports.BaseTransport) -> None: ... - def pipe_data_received(self, fd: int, data: Union[bytes, str]) -> None: ... - def pipe_connection_lost(self, fd: int, exc: Optional[Exception]) -> None: ... + def pipe_data_received(self, fd: int, data: bytes | str) -> None: ... + def pipe_connection_lost(self, fd: int, exc: Exception | None) -> None: ... def process_exited(self) -> None: ... class Process: - stdin: Optional[streams.StreamWriter] - stdout: Optional[streams.StreamReader] - stderr: Optional[streams.StreamReader] + stdin: streams.StreamWriter | None + stdout: streams.StreamReader | None + stderr: streams.StreamReader | None pid: int def __init__( self, transport: transports.BaseTransport, protocol: protocols.BaseProtocol, loop: events.AbstractEventLoop ) -> None: ... @property - def returncode(self) -> Optional[int]: ... + def returncode(self) -> int | None: ... async def wait(self) -> int: ... def send_signal(self, signal: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ... - async def communicate(self, input: Optional[bytes] = ...) -> Tuple[bytes, bytes]: ... + async def communicate(self, input: bytes | None = ...) -> Tuple[bytes, bytes]: ... if sys.version_info >= (3, 10): async def create_subprocess_shell( - cmd: Union[str, bytes], - stdin: Union[int, IO[Any], None] = ..., - stdout: Union[int, IO[Any], None] = ..., - stderr: Union[int, IO[Any], None] = ..., + cmd: str | bytes, + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., limit: int = ..., *, # These parameters are forced to these values by BaseEventLoop.subprocess_shell @@ -56,12 +56,12 @@ if sys.version_info >= (3, 10): errors: None = ..., text: Literal[False, None] = ..., # These parameters are taken by subprocess.Popen, which this ultimately delegates to - executable: Optional[StrOrBytesPath] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[subprocess._ENV] = ..., - startupinfo: Optional[Any] = ..., + cwd: StrOrBytesPath | None = ..., + env: subprocess._ENV | None = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., @@ -70,9 +70,9 @@ if sys.version_info >= (3, 10): async def create_subprocess_exec( program: _ExecArg, *args: _ExecArg, - stdin: Union[int, IO[Any], None] = ..., - stdout: Union[int, IO[Any], None] = ..., - stderr: Union[int, IO[Any], None] = ..., + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., limit: int = ..., # These parameters are forced to these values by BaseEventLoop.subprocess_shell universal_newlines: Literal[False] = ..., @@ -81,13 +81,13 @@ if sys.version_info >= (3, 10): encoding: None = ..., errors: None = ..., # These parameters are taken by subprocess.Popen, which this ultimately delegates to - text: Optional[bool] = ..., - executable: Optional[StrOrBytesPath] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + text: bool | None = ..., + executable: StrOrBytesPath | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[subprocess._ENV] = ..., - startupinfo: Optional[Any] = ..., + cwd: StrOrBytesPath | None = ..., + env: subprocess._ENV | None = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., @@ -96,11 +96,11 @@ if sys.version_info >= (3, 10): else: async def create_subprocess_shell( - cmd: Union[str, bytes], - stdin: Union[int, IO[Any], None] = ..., - stdout: Union[int, IO[Any], None] = ..., - stderr: Union[int, IO[Any], None] = ..., - loop: Optional[events.AbstractEventLoop] = ..., + cmd: str | bytes, + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., + loop: events.AbstractEventLoop | None = ..., limit: int = ..., *, # These parameters are forced to these values by BaseEventLoop.subprocess_shell @@ -111,12 +111,12 @@ else: errors: None = ..., text: Literal[False, None] = ..., # These parameters are taken by subprocess.Popen, which this ultimately delegates to - executable: Optional[StrOrBytesPath] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[subprocess._ENV] = ..., - startupinfo: Optional[Any] = ..., + cwd: StrOrBytesPath | None = ..., + env: subprocess._ENV | None = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., @@ -125,10 +125,10 @@ else: async def create_subprocess_exec( program: _ExecArg, *args: _ExecArg, - stdin: Union[int, IO[Any], None] = ..., - stdout: Union[int, IO[Any], None] = ..., - stderr: Union[int, IO[Any], None] = ..., - loop: Optional[events.AbstractEventLoop] = ..., + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., + loop: events.AbstractEventLoop | None = ..., limit: int = ..., # These parameters are forced to these values by BaseEventLoop.subprocess_shell universal_newlines: Literal[False] = ..., @@ -137,13 +137,13 @@ else: encoding: None = ..., errors: None = ..., # These parameters are taken by subprocess.Popen, which this ultimately delegates to - text: Optional[bool] = ..., - executable: Optional[StrOrBytesPath] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + text: bool | None = ..., + executable: StrOrBytesPath | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[subprocess._ENV] = ..., - startupinfo: Optional[Any] = ..., + cwd: StrOrBytesPath | None = ..., + env: subprocess._ENV | None = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index c306e9655daa..fe533fac2bb4 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -26,17 +26,17 @@ FIRST_COMPLETED: str ALL_COMPLETED: str if sys.version_info >= (3, 10): - def as_completed(fs: Iterable[_FutureT[_T]], *, timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ... + def as_completed(fs: Iterable[_FutureT[_T]], *, timeout: float | None = ...) -> Iterator[Future[_T]]: ... else: def as_completed( - fs: Iterable[_FutureT[_T]], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ... + fs: Iterable[_FutureT[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ... ) -> Iterator[Future[_T]]: ... @overload -def ensure_future(coro_or_future: _FT, *, loop: Optional[AbstractEventLoop] = ...) -> _FT: ... # type: ignore +def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = ...) -> _FT: ... # type: ignore @overload -def ensure_future(coro_or_future: Awaitable[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Task[_T]: ... +def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = ...) -> Task[_T]: ... # Prior to Python 3.7 'async' was an alias for 'ensure_future'. # It became a keyword in 3.7. @@ -91,11 +91,11 @@ if sys.version_info >= (3, 10): return_exceptions: bool = ..., ) -> Future[List[Any]]: ... @overload - def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: bool = ...) -> Future[Tuple[Union[_T1, BaseException]]]: ... + def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: bool = ...) -> Future[Tuple[_T1 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, return_exceptions: bool = ... - ) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException]]]: ... + ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -103,7 +103,7 @@ if sys.version_info >= (3, 10): coro_or_future3: _FutureT[_T3], *, return_exceptions: bool = ..., - ) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException]]]: ... + ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -113,7 +113,7 @@ if sys.version_info >= (3, 10): *, return_exceptions: bool = ..., ) -> Future[ - Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]] + Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException] ]: ... @overload def gather( @@ -126,25 +126,25 @@ if sys.version_info >= (3, 10): return_exceptions: bool = ..., ) -> Future[ Tuple[ - Union[_T1, BaseException], - Union[_T2, BaseException], - Union[_T3, BaseException], - Union[_T4, BaseException], - Union[_T5, BaseException], + _T1 | BaseException, + _T2 | BaseException, + _T3 | BaseException, + _T4 | BaseException, + _T5 | BaseException, ] ]: ... else: @overload def gather( - coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: Literal[False] = ... + coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ... ) -> Future[Tuple[_T1]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ..., ) -> Future[Tuple[_T1, _T2]]: ... @overload @@ -153,7 +153,7 @@ else: coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ..., ) -> Future[Tuple[_T1, _T2, _T3]]: ... @overload @@ -163,7 +163,7 @@ else: coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ..., ) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ... @overload @@ -174,7 +174,7 @@ else: coro_or_future4: _FutureT[_T4], coro_or_future5: _FutureT[_T5], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ..., ) -> Future[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload @@ -186,30 +186,30 @@ else: coro_or_future5: _FutureT[Any], coro_or_future6: _FutureT[Any], *coros_or_futures: _FutureT[Any], - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., ) -> Future[List[Any]]: ... @overload def gather( - coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ... - ) -> Future[Tuple[Union[_T1, BaseException]]]: ... + coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ... + ) -> Future[Tuple[_T1 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., - ) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException]]]: ... + ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., - ) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException]]]: ... + ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -217,10 +217,10 @@ else: coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., ) -> Future[ - Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]] + Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException] ]: ... @overload def gather( @@ -230,15 +230,15 @@ else: coro_or_future4: _FutureT[_T4], coro_or_future5: _FutureT[_T5], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., ) -> Future[ Tuple[ - Union[_T1, BaseException], - Union[_T2, BaseException], - Union[_T3, BaseException], - Union[_T4, BaseException], - Union[_T5, BaseException], + _T1 | BaseException, + _T2 | BaseException, + _T3 | BaseException, + _T4 | BaseException, + _T5 | BaseException, ] ]: ... @@ -248,68 +248,68 @@ if sys.version_info >= (3, 10): def shield(arg: _FutureT[_T]) -> Future[_T]: ... def sleep(delay: float, result: _T = ...) -> Future[_T]: ... @overload - def wait(fs: Iterable[_FT], *, timeout: Optional[float] = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore + def wait(fs: Iterable[_FT], *, timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore @overload def wait( - fs: Iterable[Awaitable[_T]], *, timeout: Optional[float] = ..., return_when: str = ... + fs: Iterable[Awaitable[_T]], *, timeout: float | None = ..., return_when: str = ... ) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ... - def wait_for(fut: _FutureT[_T], timeout: Optional[float]) -> Future[_T]: ... + def wait_for(fut: _FutureT[_T], timeout: float | None) -> Future[_T]: ... else: - def shield(arg: _FutureT[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ... - def sleep(delay: float, result: _T = ..., *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ... + def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... + def sleep(delay: float, result: _T = ..., *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... @overload - def wait(fs: Iterable[_FT], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore + def wait(fs: Iterable[_FT], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore @overload def wait( fs: Iterable[Awaitable[_T]], *, - loop: Optional[AbstractEventLoop] = ..., - timeout: Optional[float] = ..., + loop: AbstractEventLoop | None = ..., + timeout: float | None = ..., return_when: str = ..., ) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ... - def wait_for(fut: _FutureT[_T], timeout: Optional[float], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ... + def wait_for(fut: _FutureT[_T], timeout: float | None, *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... class Task(Future[_T], Generic[_T]): if sys.version_info >= (3, 8): def __init__( self, - coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], + coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, loop: AbstractEventLoop = ..., - name: Optional[str] = ..., + name: str | None = ..., ) -> None: ... else: def __init__( - self, coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ... + self, coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, loop: AbstractEventLoop = ... ) -> None: ... def __repr__(self) -> str: ... if sys.version_info >= (3, 8): - def get_coro(self) -> Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]]: ... + def get_coro(self) -> Generator[_TaskYieldType, None, _T] | Awaitable[_T]: ... def get_name(self) -> str: ... def set_name(self, __value: object) -> None: ... - def get_stack(self, *, limit: Optional[int] = ...) -> List[FrameType]: ... - def print_stack(self, *, limit: Optional[int] = ..., file: Optional[TextIO] = ...) -> None: ... + def get_stack(self, *, limit: int | None = ...) -> List[FrameType]: ... + def print_stack(self, *, limit: int | None = ..., file: TextIO | None = ...) -> None: ... if sys.version_info >= (3, 9): - def cancel(self, msg: Optional[str] = ...) -> bool: ... + def cancel(self, msg: str | None = ...) -> bool: ... else: def cancel(self) -> bool: ... if sys.version_info < (3, 9): @classmethod - def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... + def current_task(cls, loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... @classmethod - def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... + def all_tasks(cls, loop: AbstractEventLoop | None = ...) -> Set[Task[Any]]: ... if sys.version_info < (3, 7): def _wakeup(self, fut: Future[Any]) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... if sys.version_info >= (3, 7): - def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... + def all_tasks(loop: AbstractEventLoop | None = ...) -> Set[Task[Any]]: ... if sys.version_info >= (3, 8): def create_task( - coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, name: Optional[str] = ... + coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, name: str | None = ... ) -> Task[_T]: ... else: - def create_task(coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]]) -> Task[_T]: ... - def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... + def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T]) -> Task[_T]: ... + def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... diff --git a/stdlib/asyncio/transports.pyi b/stdlib/asyncio/transports.pyi index 636ac36301c1..7508cb789ea4 100644 --- a/stdlib/asyncio/transports.pyi +++ b/stdlib/asyncio/transports.pyi @@ -5,7 +5,7 @@ from socket import _Address from typing import Any, List, Mapping, Optional, Tuple class BaseTransport: - def __init__(self, extra: Optional[Mapping[Any, Any]] = ...) -> None: ... + def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ... def get_extra_info(self, name: Any, default: Any = ...) -> Any: ... def is_closing(self) -> bool: ... def close(self) -> None: ... @@ -19,7 +19,7 @@ class ReadTransport(BaseTransport): def resume_reading(self) -> None: ... class WriteTransport(BaseTransport): - def set_write_buffer_limits(self, high: Optional[int] = ..., low: Optional[int] = ...) -> None: ... + def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ... def get_write_buffer_size(self) -> int: ... def write(self, data: Any) -> None: ... def writelines(self, list_of_data: List[Any]) -> None: ... @@ -30,17 +30,17 @@ class WriteTransport(BaseTransport): class Transport(ReadTransport, WriteTransport): ... class DatagramTransport(BaseTransport): - def sendto(self, data: Any, addr: Optional[_Address] = ...) -> None: ... + def sendto(self, data: Any, addr: _Address | None = ...) -> None: ... def abort(self) -> None: ... class SubprocessTransport(BaseTransport): def get_pid(self) -> int: ... - def get_returncode(self) -> Optional[int]: ... - def get_pipe_transport(self, fd: int) -> Optional[BaseTransport]: ... + def get_returncode(self) -> int | None: ... + def get_pipe_transport(self, fd: int) -> BaseTransport | None: ... def send_signal(self, signal: int) -> int: ... def terminate(self) -> None: ... def kill(self) -> None: ... class _FlowControlMixin(Transport): - def __init__(self, extra: Optional[Mapping[Any, Any]] = ..., loop: Optional[AbstractEventLoop] = ...) -> None: ... + def __init__(self, extra: Mapping[Any, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ... def get_write_buffer_limits(self) -> Tuple[int, int]: ... diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 0bd3f0adb142..bc7a680cb25f 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -28,23 +28,23 @@ if sys.version_info >= (3, 8): @overload def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... @overload - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + def setsockopt(self, level: int, optname: int, value: int | bytes) -> None: ... @overload def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ... def getpeername(self) -> _RetAddress: ... def getsockname(self) -> _RetAddress: ... def getsockbyname(self) -> NoReturn: ... # This method doesn't exist on socket, yet is passed through? def accept(self) -> Tuple[socket.socket, _RetAddress]: ... - def connect(self, address: Union[_Address, bytes]) -> None: ... - def connect_ex(self, address: Union[_Address, bytes]) -> int: ... - def bind(self, address: Union[_Address, bytes]) -> None: ... + def connect(self, address: _Address | bytes) -> None: ... + def connect_ex(self, address: _Address | bytes) -> int: ... + def bind(self, address: _Address | bytes) -> None: ... if sys.platform == "win32": - def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ... + def ioctl(self, control: int, option: int | Tuple[int, int, int] | bool) -> None: ... else: - def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> NoReturn: ... + def ioctl(self, control: int, option: int | Tuple[int, int, int] | bool) -> NoReturn: ... def listen(self, __backlog: int = ...) -> None: ... def makefile(self) -> BinaryIO: ... - def sendfile(self, file: BinaryIO, offset: int = ..., count: Optional[int] = ...) -> int: ... + def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ... def close(self) -> None: ... def detach(self) -> int: ... if sys.platform == "linux": @@ -77,10 +77,10 @@ if sys.version_info >= (3, 8): def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ... def recvfrom(self, bufsize: int, flags: int = ...) -> Tuple[bytes, _RetAddress]: ... def recv(self, bufsize: int, flags: int = ...) -> bytes: ... - def settimeout(self, value: Optional[float]) -> None: ... - def gettimeout(self) -> Optional[float]: ... + def settimeout(self, value: float | None) -> None: ... + def gettimeout(self) -> float | None: ... def setblocking(self, flag: bool) -> None: ... def __enter__(self) -> socket.socket: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index d845acf5f338..edb8f3a289b1 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -11,11 +11,11 @@ from .selector_events import BaseSelectorEventLoop class AbstractChildWatcher: def add_child_handler(self, pid: int, callback: Callable[..., Any], *args: Any) -> None: ... def remove_child_handler(self, pid: int) -> bool: ... - def attach_loop(self, loop: Optional[AbstractEventLoop]) -> None: ... + def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... if sys.version_info >= (3, 8): def is_active(self) -> bool: ... @@ -34,16 +34,16 @@ class _UnixSelectorEventLoop(BaseSelectorEventLoop): async def create_unix_server( self, protocol_factory: _ProtocolFactory, - path: Optional[str] = ..., + path: str | None = ..., *, - sock: Optional[socket] = ..., + sock: socket | None = ..., backlog: int = ..., ssl: _SSLContext = ..., ) -> Server: ... class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy): def get_child_watcher(self) -> AbstractChildWatcher: ... - def set_child_watcher(self, watcher: Optional[AbstractChildWatcher]) -> None: ... + def set_child_watcher(self, watcher: AbstractChildWatcher | None) -> None: ... SelectorEventLoop = _UnixSelectorEventLoop @@ -54,7 +54,7 @@ if sys.version_info >= (3, 8): from typing import Protocol class _Warn(Protocol): def __call__( - self, message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ... + self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... ) -> None: ... class MultiLoopChildWatcher(AbstractChildWatcher): def __enter__(self: Self) -> Self: ... diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index ca76772f3d6d..266a5760839d 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -30,7 +30,7 @@ class PipeServer: class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): ... class ProactorEventLoop(proactor_events.BaseProactorEventLoop): - def __init__(self, proactor: Optional[IocpProactor] = ...) -> None: ... + def __init__(self, proactor: IocpProactor | None = ...) -> None: ... async def create_pipe_connection( self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str ) -> Tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ... @@ -43,7 +43,7 @@ class IocpProactor: def __repr__(self) -> str: ... def __del__(self) -> None: ... def set_loop(self, loop: events.AbstractEventLoop) -> None: ... - def select(self, timeout: Optional[int] = ...) -> List[futures.Future[Any]]: ... + def select(self, timeout: int | None = ...) -> List[futures.Future[Any]]: ... def recv(self, conn: socket.socket, nbytes: int, flags: int = ...) -> futures.Future[bytes]: ... if sys.version_info >= (3, 7): def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = ...) -> futures.Future[Any]: ... @@ -54,7 +54,7 @@ class IocpProactor: def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ... def accept_pipe(self, pipe: socket.socket) -> futures.Future[Any]: ... async def connect_pipe(self, address: bytes) -> windows_utils.PipeHandle: ... - def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: Optional[int] = ...) -> bool: ... + def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = ...) -> bool: ... def close(self) -> None: ... SelectorEventLoop = _WindowsSelectorEventLoop diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index 1d16127a5ebe..66c06661acb2 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -20,7 +20,7 @@ class PipeHandle: else: def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, t: Optional[type], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... + def __exit__(self, t: type | None, v: BaseException | None, tb: TracebackType | None) -> None: ... @property def handle(self) -> int: ... def fileno(self) -> int: ... diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index 2754d5efbb36..80b7747c5d0e 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -14,12 +14,12 @@ class ExitNow(Exception): ... def read(obj: Any) -> None: ... def write(obj: Any) -> None: ... def readwrite(obj: Any, flags: int) -> None: ... -def poll(timeout: float = ..., map: Optional[_maptype] = ...) -> None: ... -def poll2(timeout: float = ..., map: Optional[_maptype] = ...) -> None: ... +def poll(timeout: float = ..., map: _maptype | None = ...) -> None: ... +def poll2(timeout: float = ..., map: _maptype | None = ...) -> None: ... poll3 = poll2 -def loop(timeout: float = ..., use_poll: bool = ..., map: Optional[_maptype] = ..., count: Optional[int] = ...) -> None: ... +def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype | None = ..., count: int | None = ...) -> None: ... # Not really subclass of socket.socket; it's only delegation. # It is not covariant to it. @@ -31,19 +31,19 @@ class dispatcher: connecting: bool closing: bool ignore_log_types: frozenset[str] - socket: Optional[_socket] - def __init__(self, sock: Optional[_socket] = ..., map: Optional[_maptype] = ...) -> None: ... - def add_channel(self, map: Optional[_maptype] = ...) -> None: ... - def del_channel(self, map: Optional[_maptype] = ...) -> None: ... + socket: _socket | None + def __init__(self, sock: _socket | None = ..., map: _maptype | None = ...) -> None: ... + def add_channel(self, map: _maptype | None = ...) -> None: ... + def del_channel(self, map: _maptype | None = ...) -> None: ... def create_socket(self, family: int = ..., type: int = ...) -> None: ... - def set_socket(self, sock: _socket, map: Optional[_maptype] = ...) -> None: ... + def set_socket(self, sock: _socket, map: _maptype | None = ...) -> None: ... def set_reuse_addr(self) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... def listen(self, num: int) -> None: ... - def bind(self, addr: Union[Tuple[Any, ...], str]) -> None: ... - def connect(self, address: Union[Tuple[Any, ...], str]) -> None: ... - def accept(self) -> Optional[Tuple[_socket, Any]]: ... + def bind(self, addr: Tuple[Any, ...] | str) -> None: ... + def connect(self, address: Tuple[Any, ...] | str) -> None: ... + def accept(self) -> Tuple[_socket, Any] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... def close(self) -> None: ... @@ -62,14 +62,14 @@ class dispatcher: def handle_close(self) -> None: ... class dispatcher_with_send(dispatcher): - def __init__(self, sock: Optional[socket] = ..., map: Optional[_maptype] = ...) -> None: ... + def __init__(self, sock: socket | None = ..., map: _maptype | None = ...) -> None: ... def initiate_send(self) -> None: ... def handle_write(self) -> None: ... # incompatible signature: - # def send(self, data: bytes) -> Optional[int]: ... + # def send(self, data: bytes) -> int | None: ... def compact_traceback() -> Tuple[Tuple[str, str, str], type, type, str]: ... -def close_all(map: Optional[_maptype] = ..., ignore_all: bool = ...) -> None: ... +def close_all(map: _maptype | None = ..., ignore_all: bool = ...) -> None: ... if sys.platform != "win32": class file_wrapper: @@ -86,5 +86,5 @@ if sys.platform != "win32": def close(self) -> None: ... def fileno(self) -> int: ... class file_dispatcher(dispatcher): - def __init__(self, fd: FileDescriptorLike, map: Optional[_maptype] = ...) -> None: ... + def __init__(self, fd: FileDescriptorLike, map: _maptype | None = ...) -> None: ... def set_file(self, fd: int) -> None: ... diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index 606f4b9f5f7e..53ba6a46ec44 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -6,7 +6,7 @@ RatecvState = Tuple[int, Tuple[Tuple[int, int], ...]] class error(Exception): ... def add(__fragment1: bytes, __fragment2: bytes, __width: int) -> bytes: ... -def adpcm2lin(__fragment: bytes, __width: int, __state: Optional[AdpcmState]) -> Tuple[bytes, AdpcmState]: ... +def adpcm2lin(__fragment: bytes, __width: int, __state: AdpcmState | None) -> Tuple[bytes, AdpcmState]: ... def alaw2lin(__fragment: bytes, __width: int) -> bytes: ... def avg(__fragment: bytes, __width: int) -> int: ... def avgpp(__fragment: bytes, __width: int) -> int: ... @@ -17,7 +17,7 @@ def findfactor(__fragment: bytes, __reference: bytes) -> float: ... def findfit(__fragment: bytes, __reference: bytes) -> Tuple[int, float]: ... def findmax(__fragment: bytes, __length: int) -> int: ... def getsample(__fragment: bytes, __width: int, __index: int) -> int: ... -def lin2adpcm(__fragment: bytes, __width: int, __state: Optional[AdpcmState]) -> Tuple[bytes, AdpcmState]: ... +def lin2adpcm(__fragment: bytes, __width: int, __state: AdpcmState | None) -> Tuple[bytes, AdpcmState]: ... def lin2alaw(__fragment: bytes, __width: int) -> bytes: ... def lin2lin(__fragment: bytes, __width: int, __newwidth: int) -> bytes: ... def lin2ulaw(__fragment: bytes, __width: int) -> bytes: ... @@ -31,7 +31,7 @@ def ratecv( __nchannels: int, __inrate: int, __outrate: int, - __state: Optional[RatecvState], + __state: RatecvState | None, __weightA: int = ..., __weightB: int = ..., ) -> Tuple[bytes, RatecvState]: ... diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 47118516ca82..0e2dda19756e 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -1,27 +1,27 @@ import sys from typing import IO, Optional, Union -def b64encode(s: bytes, altchars: Optional[bytes] = ...) -> bytes: ... -def b64decode(s: Union[str, bytes], altchars: Optional[bytes] = ..., validate: bool = ...) -> bytes: ... +def b64encode(s: bytes, altchars: bytes | None = ...) -> bytes: ... +def b64decode(s: str | bytes, altchars: bytes | None = ..., validate: bool = ...) -> bytes: ... def standard_b64encode(s: bytes) -> bytes: ... -def standard_b64decode(s: Union[str, bytes]) -> bytes: ... +def standard_b64decode(s: str | bytes) -> bytes: ... def urlsafe_b64encode(s: bytes) -> bytes: ... -def urlsafe_b64decode(s: Union[str, bytes]) -> bytes: ... +def urlsafe_b64decode(s: str | bytes) -> bytes: ... def b32encode(s: bytes) -> bytes: ... -def b32decode(s: Union[str, bytes], casefold: bool = ..., map01: Optional[bytes] = ...) -> bytes: ... +def b32decode(s: str | bytes, casefold: bool = ..., map01: bytes | None = ...) -> bytes: ... def b16encode(s: bytes) -> bytes: ... -def b16decode(s: Union[str, bytes], casefold: bool = ...) -> bytes: ... +def b16decode(s: str | bytes, casefold: bool = ...) -> bytes: ... if sys.version_info >= (3, 10): def b32hexencode(s: bytes) -> bytes: ... - def b32hexdecode(s: Union[str, bytes], casefold: bool = ...) -> bytes: ... + def b32hexdecode(s: str | bytes, casefold: bool = ...) -> bytes: ... def a85encode(b: bytes, *, foldspaces: bool = ..., wrapcol: int = ..., pad: bool = ..., adobe: bool = ...) -> bytes: ... def a85decode( - b: Union[str, bytes], *, foldspaces: bool = ..., adobe: bool = ..., ignorechars: Union[str, bytes] = ... + b: str | bytes, *, foldspaces: bool = ..., adobe: bool = ..., ignorechars: str | bytes = ... ) -> bytes: ... def b85encode(b: bytes, pad: bool = ...) -> bytes: ... -def b85decode(b: Union[str, bytes]) -> bytes: ... +def b85decode(b: str | bytes) -> bytes: ... def decode(input: IO[bytes], output: IO[bytes]) -> None: ... def encode(input: IO[bytes], output: IO[bytes]) -> None: ... def encodebytes(s: bytes) -> bytes: ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index 9d76b3afde22..bf8f3c583260 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -11,16 +11,16 @@ class BdbQuit(Exception): ... class Bdb: - skip: Optional[Set[str]] + skip: Set[str] | None breaks: Dict[str, List[int]] fncache: Dict[str, str] - frame_returning: Optional[FrameType] - botframe: Optional[FrameType] + frame_returning: FrameType | None + botframe: FrameType | None quitting: bool - stopframe: Optional[FrameType] - returnframe: Optional[FrameType] + stopframe: FrameType | None + returnframe: FrameType | None stoplineno: int - def __init__(self, skip: Optional[Iterable[str]] = ...) -> None: ... + def __init__(self, skip: Iterable[str] | None = ...) -> None: ... def canonic(self, filename: str) -> str: ... def reset(self) -> None: ... def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ... @@ -31,21 +31,21 @@ class Bdb: def is_skipped_module(self, module_name: str) -> bool: ... def stop_here(self, frame: FrameType) -> bool: ... def break_here(self, frame: FrameType) -> bool: ... - def do_clear(self, arg: Any) -> Optional[bool]: ... + def do_clear(self, arg: Any) -> bool | None: ... def break_anywhere(self, frame: FrameType) -> bool: ... def user_call(self, frame: FrameType, argument_list: None) -> None: ... def user_line(self, frame: FrameType) -> None: ... def user_return(self, frame: FrameType, return_value: Any) -> None: ... def user_exception(self, frame: FrameType, exc_info: _ExcInfo) -> None: ... - def set_until(self, frame: FrameType, lineno: Optional[int] = ...) -> None: ... + def set_until(self, frame: FrameType, lineno: int | None = ...) -> None: ... def set_step(self) -> None: ... def set_next(self, frame: FrameType) -> None: ... def set_return(self, frame: FrameType) -> None: ... - def set_trace(self, frame: Optional[FrameType] = ...) -> None: ... + def set_trace(self, frame: FrameType | None = ...) -> None: ... def set_continue(self) -> None: ... def set_quit(self) -> None: ... def set_break( - self, filename: str, lineno: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ... + self, filename: str, lineno: int, temporary: bool = ..., cond: str | None = ..., funcname: str | None = ... ) -> None: ... def clear_break(self, filename: str, lineno: int) -> None: ... def clear_bpbynumber(self, arg: SupportsInt) -> None: ... @@ -56,43 +56,43 @@ class Bdb: def get_breaks(self, filename: str, lineno: int) -> List[Breakpoint]: ... def get_file_breaks(self, filename: str) -> List[Breakpoint]: ... def get_all_breaks(self) -> List[Breakpoint]: ... - def get_stack(self, f: Optional[FrameType], t: Optional[TracebackType]) -> Tuple[List[Tuple[FrameType, int]], int]: ... + def get_stack(self, f: FrameType | None, t: TracebackType | None) -> Tuple[List[Tuple[FrameType, int]], int]: ... def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ... def run( - self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ... + self, cmd: str | CodeType, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ... ) -> None: ... - def runeval(self, expr: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ... + def runeval(self, expr: str, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... def runctx( - self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]] + self, cmd: str | CodeType, globals: Dict[str, Any] | None, locals: Mapping[str, Any] | None ) -> None: ... - def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... + def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> _T | None: ... class Breakpoint: next: int = ... bplist: Dict[Tuple[str, int], List[Breakpoint]] = ... - bpbynumber: List[Optional[Breakpoint]] = ... + bpbynumber: List[Breakpoint | None] = ... - funcname: Optional[str] - func_first_executable_line: Optional[int] + funcname: str | None + func_first_executable_line: int | None file: str line: int temporary: bool - cond: Optional[str] + cond: str | None enabled: bool ignore: int hits: int number: int def __init__( - self, file: str, line: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ... + self, file: str, line: int, temporary: bool = ..., cond: str | None = ..., funcname: str | None = ... ) -> None: ... def deleteMe(self) -> None: ... def enable(self) -> None: ... def disable(self) -> None: ... - def bpprint(self, out: Optional[IO[str]] = ...) -> None: ... + def bpprint(self, out: IO[str] | None = ...) -> None: ... def bpformat(self) -> str: ... def __str__(self) -> str: ... def checkfuncname(b: Breakpoint, frame: FrameType) -> bool: ... -def effective(file: str, line: int, frame: FrameType) -> Union[Tuple[Breakpoint, bool], Tuple[None, None]]: ... +def effective(file: str, line: int, frame: FrameType) -> Tuple[Breakpoint, bool] | Tuple[None, None]: ... def set_trace() -> None: ... diff --git a/stdlib/binascii.pyi b/stdlib/binascii.pyi index b74df13c3187..f28c7590ae4b 100644 --- a/stdlib/binascii.pyi +++ b/stdlib/binascii.pyi @@ -1,7 +1,7 @@ import sys from typing import Union -def a2b_uu(__data: Union[str, bytes]) -> bytes: ... +def a2b_uu(__data: str | bytes) -> bytes: ... if sys.version_info >= (3, 7): def b2a_uu(__data: bytes, *, backtick: bool = ...) -> bytes: ... @@ -9,11 +9,11 @@ if sys.version_info >= (3, 7): else: def b2a_uu(__data: bytes) -> bytes: ... -def a2b_base64(__data: Union[str, bytes]) -> bytes: ... +def a2b_base64(__data: str | bytes) -> bytes: ... def b2a_base64(__data: bytes, *, newline: bool = ...) -> bytes: ... -def a2b_qp(data: Union[str, bytes], header: bool = ...) -> bytes: ... +def a2b_qp(data: str | bytes, header: bool = ...) -> bytes: ... def b2a_qp(data: bytes, quotetabs: bool = ..., istext: bool = ..., header: bool = ...) -> bytes: ... -def a2b_hqx(__data: Union[str, bytes]) -> bytes: ... +def a2b_hqx(__data: str | bytes) -> bytes: ... def rledecode_hqx(__data: bytes) -> bytes: ... def rlecode_hqx(__data: bytes) -> bytes: ... def b2a_hqx(__data: bytes) -> bytes: ... @@ -22,13 +22,13 @@ def crc32(__data: bytes, __crc: int = ...) -> int: ... def b2a_hex(__data: bytes) -> bytes: ... if sys.version_info >= (3, 8): - def hexlify(data: bytes, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> bytes: ... + def hexlify(data: bytes, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes: ... else: def hexlify(__data: bytes) -> bytes: ... -def a2b_hex(__hexstr: Union[str, bytes]) -> bytes: ... -def unhexlify(__hexstr: Union[str, bytes]) -> bytes: ... +def a2b_hex(__hexstr: str | bytes) -> bytes: ... +def unhexlify(__hexstr: str | bytes) -> bytes: ... class Error(ValueError): ... class Incomplete(Exception): ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 108aeba94174..46ace545416d 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -84,9 +84,9 @@ _TT = TypeVar("_TT", bound="type") _TBE = TypeVar("_TBE", bound="BaseException") class object: - __doc__: Optional[str] + __doc__: str | None __dict__: Dict[str, Any] - __slots__: Union[str, Iterable[str]] + __slots__: str | Iterable[str] __module__: str __annotations__: Dict[str, Any] @property @@ -106,7 +106,7 @@ class object: def __getattribute__(self, name: str) -> Any: ... def __delattr__(self, name: str) -> None: ... def __sizeof__(self) -> int: ... - def __reduce__(self) -> Union[str, Tuple[Any, ...]]: ... + def __reduce__(self) -> str | Tuple[Any, ...]: ... if sys.version_info >= (3, 8): def __reduce_ex__(self, protocol: SupportsIndex) -> str | Tuple[Any, ...]: ... else: @@ -119,14 +119,14 @@ class staticmethod(object): # Special, only valid as a decorator. __isabstractmethod__: bool def __init__(self, f: Callable[..., Any]) -> None: ... def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ... + def __get__(self, obj: _T, type: Type[_T] | None = ...) -> Callable[..., Any]: ... class classmethod(object): # Special, only valid as a decorator. __func__: Callable[..., Any] __isabstractmethod__: bool def __init__(self, f: Callable[..., Any]) -> None: ... def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ... + def __get__(self, obj: _T, type: Type[_T] | None = ...) -> Callable[..., Any]: ... class type(object): __base__: type @@ -140,7 +140,7 @@ class type(object): __mro__: Tuple[type, ...] __name__: str __qualname__: str - __text_signature__: Optional[str] + __text_signature__: str | None __weakrefoffset__: int @overload def __init__(self, o: object) -> None: ... @@ -173,9 +173,9 @@ class super(object): class int: @overload - def __new__(cls: Type[_T], x: Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc] = ...) -> _T: ... + def __new__(cls: Type[_T], x: str | bytes | SupportsInt | SupportsIndex | _SupportsTrunc = ...) -> _T: ... @overload - def __new__(cls: Type[_T], x: Union[str, bytes, bytearray], base: SupportsIndex) -> _T: ... + def __new__(cls: Type[_T], x: str | bytes | bytearray, base: SupportsIndex) -> _T: ... if sys.version_info >= (3, 8): def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ... @property @@ -210,10 +210,10 @@ class int: def __rmod__(self, x: int) -> int: ... def __rdivmod__(self, x: int) -> Tuple[int, int]: ... @overload - def __pow__(self, __x: Literal[2], __modulo: Optional[int] = ...) -> int: ... + def __pow__(self, __x: Literal[2], __modulo: int | None = ...) -> int: ... @overload - def __pow__(self, __x: int, __modulo: Optional[int] = ...) -> Any: ... # Return type can be int or float, depending on x. - def __rpow__(self, x: int, mod: Optional[int] = ...) -> Any: ... + def __pow__(self, __x: int, __modulo: int | None = ...) -> Any: ... # Return type can be int or float, depending on x. + def __rpow__(self, x: int, mod: int | None = ...) -> Any: ... def __and__(self, n: int) -> int: ... def __or__(self, n: int) -> int: ... def __xor__(self, n: int) -> int: ... @@ -247,7 +247,7 @@ class int: def __index__(self) -> int: ... class float: - def __new__(cls: Type[_T], x: Union[SupportsFloat, SupportsIndex, str, bytes, bytearray] = ...) -> _T: ... + def __new__(cls: Type[_T], x: SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> _T: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -304,7 +304,7 @@ class complex: @overload def __new__(cls: Type[_T], real: float = ..., imag: float = ...) -> _T: ... @overload - def __new__(cls: Type[_T], real: Union[str, SupportsComplex, SupportsIndex, complex]) -> _T: ... + def __new__(cls: Type[_T], real: str | SupportsComplex | SupportsIndex | complex) -> _T: ... @property def real(self) -> float: ... @property @@ -340,19 +340,19 @@ class str(Sequence[str]): def capitalize(self) -> str: ... def casefold(self) -> str: ... def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... - def count(self, x: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... + def count(self, x: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ... def endswith( - self, __suffix: Union[str, Tuple[str, ...]], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __suffix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... else: def expandtabs(self, tabsize: int = ...) -> str: ... - def find(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... + def find(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def format(self, *args: object, **kwargs: object) -> str: ... def format_map(self, map: _FormatMapMapping) -> str: ... - def index(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... + def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... if sys.version_info >= (3, 7): @@ -369,41 +369,41 @@ class str(Sequence[str]): def join(self, __iterable: Iterable[str]) -> str: ... def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... def lower(self) -> str: ... - def lstrip(self, __chars: Optional[str] = ...) -> str: ... + def lstrip(self, __chars: str | None = ...) -> str: ... def partition(self, __sep: str) -> Tuple[str, str, str]: ... def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ... if sys.version_info >= (3, 9): def removeprefix(self, __prefix: str) -> str: ... def removesuffix(self, __suffix: str) -> str: ... - def rfind(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... - def rindex(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... + def rfind(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... + def rindex(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... def rpartition(self, __sep: str) -> Tuple[str, str, str]: ... - def rsplit(self, sep: Optional[str] = ..., maxsplit: SupportsIndex = ...) -> List[str]: ... - def rstrip(self, __chars: Optional[str] = ...) -> str: ... - def split(self, sep: Optional[str] = ..., maxsplit: SupportsIndex = ...) -> List[str]: ... + def rsplit(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> List[str]: ... + def rstrip(self, __chars: str | None = ...) -> str: ... + def split(self, sep: str | None = ..., maxsplit: SupportsIndex = ...) -> List[str]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith( - self, __prefix: Union[str, Tuple[str, ...]], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __prefix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... - def strip(self, __chars: Optional[str] = ...) -> str: ... + def strip(self, __chars: str | None = ...) -> str: ... def swapcase(self) -> str: ... def title(self) -> str: ... - def translate(self, __table: Union[Mapping[int, Union[int, str, None]], Sequence[Union[int, str, None]]]) -> str: ... + def translate(self, __table: Mapping[int, int | str | None] | Sequence[int | str | None]) -> str: ... def upper(self) -> str: ... def zfill(self, __width: SupportsIndex) -> str: ... @staticmethod @overload - def maketrans(__x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... + def maketrans(__x: Dict[int, _T] | Dict[str, _T] | Dict[str | int, _T]) -> Dict[int, _T]: ... @staticmethod @overload - def maketrans(__x: str, __y: str, __z: Optional[str] = ...) -> Dict[int, Union[int, None]]: ... + def maketrans(__x: str, __y: str, __z: str | None = ...) -> Dict[int, int | None]: ... def __add__(self, s: str) -> str: ... # Incompatible with Sequence.__contains__ def __contains__(self, o: str) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ge__(self, x: str) -> bool: ... - def __getitem__(self, i: Union[int, slice]) -> str: ... + def __getitem__(self, i: int | slice) -> str: ... def __gt__(self, x: str) -> bool: ... def __hash__(self) -> int: ... def __iter__(self) -> Iterator[str]: ... @@ -437,9 +437,9 @@ class bytes(ByteString): def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( self, - __suffix: Union[bytes, Tuple[bytes, ...]], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., + __suffix: bytes | Tuple[bytes, ...], + __start: SupportsIndex | None = ..., + __end: SupportsIndex | None = ..., ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ... @@ -449,7 +449,7 @@ class bytes(ByteString): self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... + def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... else: def hex(self) -> str: ... def index( @@ -464,10 +464,10 @@ class bytes(ByteString): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, __iterable_of_bytes: Iterable[Union[ByteString, memoryview]]) -> bytes: ... + def join(self, __iterable_of_bytes: Iterable[ByteString | memoryview]) -> bytes: ... def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... def lower(self) -> bytes: ... - def lstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... + def lstrip(self, __bytes: bytes | None = ...) -> bytes: ... def partition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... def replace(self, __old: bytes, __new: bytes, __count: SupportsIndex = ...) -> bytes: ... if sys.version_info >= (3, 9): @@ -481,20 +481,20 @@ class bytes(ByteString): ) -> int: ... def rjust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... def rpartition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... - def rsplit(self, sep: Optional[bytes] = ..., maxsplit: SupportsIndex = ...) -> List[bytes]: ... - def rstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... - def split(self, sep: Optional[bytes] = ..., maxsplit: SupportsIndex = ...) -> List[bytes]: ... + def rsplit(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> List[bytes]: ... + def rstrip(self, __bytes: bytes | None = ...) -> bytes: ... + def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> List[bytes]: ... def splitlines(self, keepends: bool = ...) -> List[bytes]: ... def startswith( self, - __prefix: Union[bytes, Tuple[bytes, ...]], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., + __prefix: bytes | Tuple[bytes, ...], + __start: SupportsIndex | None = ..., + __end: SupportsIndex | None = ..., ) -> bool: ... - def strip(self, __bytes: Optional[bytes] = ...) -> bytes: ... + def strip(self, __bytes: bytes | None = ...) -> bytes: ... def swapcase(self) -> bytes: ... def title(self) -> bytes: ... - def translate(self, __table: Optional[bytes], delete: bytes = ...) -> bytes: ... + def translate(self, __table: bytes | None, delete: bytes = ...) -> bytes: ... def upper(self) -> bytes: ... def zfill(self, __width: SupportsIndex) -> bytes: ... @classmethod @@ -543,9 +543,9 @@ class bytearray(MutableSequence[int], ByteString): def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( self, - __suffix: Union[bytes, Tuple[bytes, ...]], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., + __suffix: bytes | Tuple[bytes, ...], + __start: SupportsIndex | None = ..., + __end: SupportsIndex | None = ..., ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ... @@ -556,7 +556,7 @@ class bytearray(MutableSequence[int], ByteString): self, __sub: bytes | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... + def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... else: def hex(self) -> str: ... def index( @@ -572,10 +572,10 @@ class bytearray(MutableSequence[int], ByteString): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, __iterable_of_bytes: Iterable[Union[ByteString, memoryview]]) -> bytearray: ... + def join(self, __iterable_of_bytes: Iterable[ByteString | memoryview]) -> bytearray: ... def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ... def lower(self) -> bytearray: ... - def lstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... + def lstrip(self, __bytes: bytes | None = ...) -> bytearray: ... def partition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... if sys.version_info >= (3, 9): def removeprefix(self, __prefix: bytes) -> bytearray: ... @@ -589,20 +589,20 @@ class bytearray(MutableSequence[int], ByteString): ) -> int: ... def rjust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ... def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: Optional[bytes] = ..., maxsplit: SupportsIndex = ...) -> List[bytearray]: ... - def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... - def split(self, sep: Optional[bytes] = ..., maxsplit: SupportsIndex = ...) -> List[bytearray]: ... + def rsplit(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> List[bytearray]: ... + def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... + def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( self, - __prefix: Union[bytes, Tuple[bytes, ...]], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., + __prefix: bytes | Tuple[bytes, ...], + __start: SupportsIndex | None = ..., + __end: SupportsIndex | None = ..., ) -> bool: ... - def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... + def strip(self, __bytes: bytes | None = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... - def translate(self, __table: Optional[bytes], delete: bytes = ...) -> bytearray: ... + def translate(self, __table: bytes | None, delete: bytes = ...) -> bytearray: ... def upper(self) -> bytearray: ... def zfill(self, __width: SupportsIndex) -> bytearray: ... @classmethod @@ -641,13 +641,13 @@ class bytearray(MutableSequence[int], ByteString): class memoryview(Sized, Sequence[int]): format: str itemsize: int - shape: Optional[Tuple[int, ...]] - strides: Optional[Tuple[int, ...]] - suboffsets: Optional[Tuple[int, ...]] + shape: Tuple[int, ...] | None + strides: Tuple[int, ...] | None + suboffsets: Tuple[int, ...] | None readonly: bool ndim: int - obj: Union[bytes, bytearray] + obj: bytes | bytearray c_contiguous: bool f_contiguous: bool contiguous: bool @@ -655,9 +655,9 @@ class memoryview(Sized, Sequence[int]): def __init__(self, obj: ReadableBuffer) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... - def cast(self, format: str, shape: Union[List[int], Tuple[int]] = ...) -> memoryview: ... + def cast(self, format: str, shape: List[int] | Tuple[int] = ...) -> memoryview: ... @overload def __getitem__(self, i: SupportsIndex) -> int: ... @overload @@ -670,7 +670,7 @@ class memoryview(Sized, Sequence[int]): @overload def __setitem__(self, i: SupportsIndex, o: SupportsIndex) -> None: ... if sys.version_info >= (3, 8): - def tobytes(self, order: Optional[Literal["C", "F", "A"]] = ...) -> bytes: ... + def tobytes(self, order: Literal["C", "F", "A"] | None = ...) -> bytes: ... else: def tobytes(self) -> bytes: ... def tolist(self) -> List[int]: ... @@ -678,7 +678,7 @@ class memoryview(Sized, Sequence[int]): def toreadonly(self) -> memoryview: ... def release(self) -> None: ... if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... + def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... else: def hex(self) -> str: ... @@ -738,7 +738,7 @@ class tuple(Sequence[_T_co], Generic[_T_co]): @overload def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... @overload - def __add__(self, x: Tuple[_T, ...]) -> Tuple[Union[_T_co, _T], ...]: ... + def __add__(self, x: Tuple[_T, ...]) -> Tuple[_T_co | _T, ...]: ... def __mul__(self, n: SupportsIndex) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: SupportsIndex) -> Tuple[_T_co, ...]: ... def count(self, __value: Any) -> int: ... @@ -785,7 +785,7 @@ class list(MutableSequence[_T], Generic[_T]): def __setitem__(self, i: SupportsIndex, o: _T) -> None: ... @overload def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - def __delitem__(self, i: Union[SupportsIndex, slice]) -> None: ... + def __delitem__(self, i: SupportsIndex | slice) -> None: ... def __add__(self, x: List[_T]) -> List[_T]: ... def __iadd__(self: _S, x: Iterable[_T]) -> _S: ... def __mul__(self, n: SupportsIndex) -> List[_T]: ... @@ -825,7 +825,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def items(self) -> ItemsView[_KT, _VT]: ... @classmethod @overload - def fromkeys(cls, __iterable: Iterable[_T], __value: None = ...) -> dict[_T, Optional[Any]]: ... + def fromkeys(cls, __iterable: Iterable[_T], __value: None = ...) -> dict[_T, Any | None]: ... @classmethod @overload def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> dict[_T, _S]: ... @@ -840,8 +840,8 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): __hash__: None # type: ignore if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... - def __or__(self, __value: Mapping[_T1, _T2]) -> Dict[Union[_KT, _T1], Union[_VT, _T2]]: ... - def __ror__(self, __value: Mapping[_T1, _T2]) -> Dict[Union[_KT, _T1], Union[_VT, _T2]]: ... + def __or__(self, __value: Mapping[_T1, _T2]) -> Dict[_KT | _T1, _VT | _T2]: ... + def __ror__(self, __value: Mapping[_T1, _T2]) -> Dict[_KT | _T1, _VT | _T2]: ... def __ior__(self, __value: Mapping[_KT, _VT]) -> Dict[_KT, _VT]: ... # type: ignore class set(MutableSet[_T], Generic[_T]): @@ -869,12 +869,12 @@ class set(MutableSet[_T], Generic[_T]): def __str__(self) -> str: ... def __and__(self, s: AbstractSet[object]) -> Set[_T]: ... def __iand__(self, s: AbstractSet[object]) -> Set[_T]: ... - def __or__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __ior__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __sub__(self, s: AbstractSet[Optional[_T]]) -> Set[_T]: ... - def __isub__(self, s: AbstractSet[Optional[_T]]) -> Set[_T]: ... - def __xor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __ixor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... + def __or__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... + def __ior__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... + def __sub__(self, s: AbstractSet[_T | None]) -> Set[_T]: ... + def __isub__(self, s: AbstractSet[_T | None]) -> Set[_T]: ... + def __xor__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... + def __ixor__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... def __le__(self, s: AbstractSet[object]) -> bool: ... def __lt__(self, s: AbstractSet[object]) -> bool: ... def __ge__(self, s: AbstractSet[object]) -> bool: ... @@ -898,9 +898,9 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]): def __iter__(self) -> Iterator[_T_co]: ... def __str__(self) -> str: ... def __and__(self, s: AbstractSet[_T_co]) -> FrozenSet[_T_co]: ... - def __or__(self, s: AbstractSet[_S]) -> FrozenSet[Union[_T_co, _S]]: ... + def __or__(self, s: AbstractSet[_S]) -> FrozenSet[_T_co | _S]: ... def __sub__(self, s: AbstractSet[_T_co]) -> FrozenSet[_T_co]: ... - def __xor__(self, s: AbstractSet[_S]) -> FrozenSet[Union[_T_co, _S]]: ... + def __xor__(self, s: AbstractSet[_S]) -> FrozenSet[_T_co | _S]: ... def __le__(self, s: AbstractSet[object]) -> bool: ... def __lt__(self, s: AbstractSet[object]) -> bool: ... def __ge__(self, s: AbstractSet[object]) -> bool: ... @@ -936,20 +936,20 @@ class range(Sequence[int]): def __reversed__(self) -> Iterator[int]: ... class property(object): - fget: Optional[Callable[[Any], Any]] - fset: Optional[Callable[[Any, Any], None]] - fdel: Optional[Callable[[Any], None]] + fget: Callable[[Any], Any] | None + fset: Callable[[Any, Any], None] | None + fdel: Callable[[Any], None] | None def __init__( self, - fget: Optional[Callable[[Any], Any]] = ..., - fset: Optional[Callable[[Any, Any], None]] = ..., - fdel: Optional[Callable[[Any], None]] = ..., - doc: Optional[str] = ..., + fget: Callable[[Any], Any] | None = ..., + fset: Callable[[Any, Any], None] | None = ..., + fdel: Callable[[Any], None] | None = ..., + doc: str | None = ..., ) -> None: ... def getter(self, fget: Callable[[Any], Any]) -> property: ... def setter(self, fset: Callable[[Any, Any], None]) -> property: ... def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: Optional[type] = ...) -> Any: ... + def __get__(self, obj: Any, type: type | None = ...) -> Any: ... def __set__(self, obj: Any, value: Any) -> None: ... def __delete__(self, obj: Any) -> None: ... @@ -964,7 +964,7 @@ def abs(__x: SupportsAbs[_T]) -> _T: ... def all(__iterable: Iterable[object]) -> bool: ... def any(__iterable: Iterable[object]) -> bool: ... def ascii(__obj: object) -> str: ... -def bin(__number: Union[int, SupportsIndex]) -> str: ... +def bin(__number: int | SupportsIndex) -> str: ... if sys.version_info >= (3, 7): def breakpoint(*args: Any, **kws: Any) -> None: ... @@ -984,12 +984,12 @@ if sys.version_info >= (3, 10): @overload async def anext(__i: AsyncIterator[_T]) -> _T: ... @overload - async def anext(__i: AsyncIterator[_T], default: _VT) -> Union[_T, _VT]: ... + async def anext(__i: AsyncIterator[_T], default: _VT) -> _T | _VT: ... if sys.version_info >= (3, 8): def compile( - source: Union[str, bytes, mod, AST], - filename: Union[str, bytes, _PathLike[Any]], + source: str | bytes | mod | AST, + filename: str | bytes | _PathLike[Any], mode: str, flags: int = ..., dont_inherit: int = ..., @@ -1000,8 +1000,8 @@ if sys.version_info >= (3, 8): else: def compile( - source: Union[str, bytes, mod, AST], - filename: Union[str, bytes, _PathLike[Any]], + source: str | bytes | mod | AST, + filename: str | bytes | _PathLike[Any], mode: str, flags: int = ..., dont_inherit: int = ..., @@ -1017,16 +1017,16 @@ def divmod(__x: SupportsDivMod[_T_contra, _T_co], __y: _T_contra) -> _T_co: ... @overload def divmod(__x: _T_contra, __y: SupportsRDivMod[_T_contra, _T_co]) -> _T_co: ... def eval( - __source: Union[str, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... + __source: str | bytes | CodeType, __globals: Dict[str, Any] | None = ..., __locals: Mapping[str, Any] | None = ... ) -> Any: ... def exec( - __source: Union[str, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... + __source: str | bytes | CodeType, __globals: Dict[str, Any] | None = ..., __locals: Mapping[str, Any] | None = ... ) -> Any: ... def exit(code: object = ...) -> NoReturn: ... class filter(Iterator[_T], Generic[_T]): @overload - def __init__(self, __function: None, __iterable: Iterable[Optional[_T]]) -> None: ... + def __init__(self, __function: None, __iterable: Iterable[_T | None]) -> None: ... @overload def __init__(self, __function: Callable[[_T], Any], __iterable: Iterable[_T]) -> None: ... def __iter__(self) -> Iterator[_T]: ... @@ -1039,36 +1039,36 @@ def getattr(__o: Any, name: str) -> Any: ... # While technically covered by the last overload, spelling out the types for None and bool # help mypy out in some tricky situations involving type context (aka bidirectional inference) @overload -def getattr(__o: Any, name: str, __default: None) -> Optional[Any]: ... +def getattr(__o: Any, name: str, __default: None) -> Any | None: ... @overload -def getattr(__o: Any, name: str, __default: bool) -> Union[Any, bool]: ... +def getattr(__o: Any, name: str, __default: bool) -> Any | bool: ... @overload -def getattr(__o: Any, name: str, __default: _T) -> Union[Any, _T]: ... +def getattr(__o: Any, name: str, __default: _T) -> Any | _T: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: str) -> bool: ... def hash(__obj: object) -> int: ... def help(*args: Any, **kwds: Any) -> None: ... -def hex(__number: Union[int, SupportsIndex]) -> str: ... +def hex(__number: int | SupportsIndex) -> str: ... def id(__obj: object) -> int: ... def input(__prompt: Any = ...) -> str: ... @overload def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... @overload -def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ... +def iter(__function: Callable[[], _T | None], __sentinel: None) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... if sys.version_info >= (3, 10): def isinstance( - __obj: object, __class_or_tuple: Union[type, types.UnionType, Tuple[Union[type, types.UnionType, Tuple[Any, ...]], ...]] + __obj: object, __class_or_tuple: type | types.UnionType | Tuple[type | types.UnionType | Tuple[Any, ...], ...] ) -> bool: ... def issubclass( - __cls: type, __class_or_tuple: Union[type, types.UnionType, Tuple[Union[type, types.UnionType, Tuple[Any, ...]], ...]] + __cls: type, __class_or_tuple: type | types.UnionType | Tuple[type | types.UnionType | Tuple[Any, ...], ...] ) -> bool: ... else: - def isinstance(__obj: object, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... - def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... + def isinstance(__obj: object, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... + def issubclass(__cls: type, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... def len(__obj: Sized) -> int: ... def license() -> None: ... @@ -1128,9 +1128,9 @@ def max(__iterable: Iterable[SupportsLessThanT], *, key: None = ...) -> Supports @overload def max(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsLessThan]) -> _T: ... @overload -def max(__iterable: Iterable[SupportsLessThanT], *, key: None = ..., default: _T) -> Union[SupportsLessThanT, _T]: ... +def max(__iterable: Iterable[SupportsLessThanT], *, key: None = ..., default: _T) -> SupportsLessThanT | _T: ... @overload -def max(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsLessThan], default: _T2) -> Union[_T1, _T2]: ... +def max(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsLessThan], default: _T2) -> _T1 | _T2: ... @overload def min( __arg1: SupportsLessThanT, __arg2: SupportsLessThanT, *_args: SupportsLessThanT, key: None = ... @@ -1142,14 +1142,14 @@ def min(__iterable: Iterable[SupportsLessThanT], *, key: None = ...) -> Supports @overload def min(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsLessThan]) -> _T: ... @overload -def min(__iterable: Iterable[SupportsLessThanT], *, key: None = ..., default: _T) -> Union[SupportsLessThanT, _T]: ... +def min(__iterable: Iterable[SupportsLessThanT], *, key: None = ..., default: _T) -> SupportsLessThanT | _T: ... @overload -def min(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsLessThan], default: _T2) -> Union[_T1, _T2]: ... +def min(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsLessThan], default: _T2) -> _T1 | _T2: ... @overload def next(__i: Iterator[_T]) -> _T: ... @overload -def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... -def oct(__number: Union[int, SupportsIndex]) -> str: ... +def next(__i: Iterator[_T], default: _VT) -> _T | _VT: ... +def oct(__number: int | SupportsIndex) -> str: ... _OpenFile = Union[StrOrBytesPath, int] _Opener = Callable[[str, int], int] @@ -1160,11 +1160,11 @@ def open( file: _OpenFile, mode: OpenTextMode = ..., buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> TextIOWrapper: ... # Unbuffered binary mode: returns a FileIO @@ -1177,7 +1177,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> FileIO: ... # Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter @@ -1190,7 +1190,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedRandom: ... @overload def open( @@ -1201,7 +1201,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedWriter: ... @overload def open( @@ -1212,7 +1212,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedReader: ... # Buffering cannot be determined: fall back to BinaryIO @@ -1225,7 +1225,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BinaryIO: ... # Fallback if mode is not specified @@ -1234,18 +1234,18 @@ def open( file: _OpenFile, mode: str, buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> IO[Any]: ... -def ord(__c: Union[str, bytes]) -> int: ... +def ord(__c: str | bytes) -> int: ... def print( *values: object, - sep: Optional[str] = ..., - end: Optional[str] = ..., - file: Optional[SupportsWrite[str]] = ..., + sep: str | None = ..., + end: str | None = ..., + file: SupportsWrite[str] | None = ..., flush: bool = ..., ) -> None: ... @@ -1309,15 +1309,15 @@ def sorted(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsLessThan], r if sys.version_info >= (3, 8): @overload - def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ... + def sum(__iterable: Iterable[_T]) -> _T | int: ... @overload - def sum(__iterable: Iterable[_T], start: _S) -> Union[_T, _S]: ... + def sum(__iterable: Iterable[_T], start: _S) -> _T | _S: ... else: @overload - def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ... + def sum(__iterable: Iterable[_T]) -> _T | int: ... @overload - def sum(__iterable: Iterable[_T], __start: _S) -> Union[_T, _S]: ... + def sum(__iterable: Iterable[_T], __start: _S) -> _T | _S: ... def vars(__object: Any = ...) -> Dict[str, Any]: ... @@ -1357,8 +1357,8 @@ class zip(Iterator[_T_co], Generic[_T_co]): def __import__( name: str, - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + globals: Mapping[str, Any] | None = ..., + locals: Mapping[str, Any] | None = ..., fromlist: Sequence[str] = ..., level: int = ..., ) -> Any: ... @@ -1371,14 +1371,14 @@ Ellipsis: ellipsis class BaseException(object): args: Tuple[Any, ...] - __cause__: Optional[BaseException] - __context__: Optional[BaseException] + __cause__: BaseException | None + __context__: BaseException | None __suppress_context__: bool - __traceback__: Optional[TracebackType] + __traceback__: TracebackType | None def __init__(self, *args: object) -> None: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... - def with_traceback(self: _TBE, tb: Optional[TracebackType]) -> _TBE: ... + def with_traceback(self: _TBE, tb: TracebackType | None) -> _TBE: ... class GeneratorExit(BaseException): ... class KeyboardInterrupt(BaseException): ... @@ -1396,7 +1396,7 @@ _StandardError = Exception class OSError(Exception): errno: int strerror: str - # filename, filename2 are actually Union[str, bytes, None] + # filename, filename2 are actually str | bytes | None filename: Any filename2: Any if sys.platform == "win32": @@ -1419,9 +1419,9 @@ class BufferError(_StandardError): ... class EOFError(_StandardError): ... class ImportError(_StandardError): - def __init__(self, *args: object, name: Optional[str] = ..., path: Optional[str] = ...) -> None: ... - name: Optional[str] - path: Optional[str] + def __init__(self, *args: object, name: str | None = ..., path: str | None = ...) -> None: ... + name: str | None + path: str | None msg: str # undocumented class LookupError(_StandardError): ... @@ -1439,13 +1439,13 @@ class StopAsyncIteration(Exception): class SyntaxError(_StandardError): msg: str - lineno: Optional[int] - offset: Optional[int] - text: Optional[str] - filename: Optional[str] + lineno: int | None + offset: int | None + text: str | None + filename: str | None if sys.version_info >= (3, 10): - end_lineno: Optional[int] - end_offset: Optional[int] + end_lineno: int | None + end_offset: int | None class SystemError(_StandardError): ... class TypeError(_StandardError): ... diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index 20fee8aa0b99..971c1fb5307e 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -40,9 +40,9 @@ def open( filename: _ReadableFileobj, mode: _ReadTextMode, compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> TextIO: ... @overload def open( @@ -58,14 +58,14 @@ def open( filename: _WritableFileobj, mode: _WriteTextMode, compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> TextIO: ... @overload def open( filename: StrOrBytesPath, - mode: Union[_ReadBinaryMode, _WriteBinaryMode] = ..., + mode: _ReadBinaryMode | _WriteBinaryMode = ..., compresslevel: int = ..., encoding: None = ..., errors: None = ..., @@ -74,11 +74,11 @@ def open( @overload def open( filename: StrOrBytesPath, - mode: Union[_ReadTextMode, _WriteTextMode], + mode: _ReadTextMode | _WriteTextMode, compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> TextIO: ... class BZ2File(BaseStream, IO[bytes]): @@ -90,30 +90,30 @@ class BZ2File(BaseStream, IO[bytes]): def __init__(self, filename: _ReadableFileobj, mode: _ReadBinaryMode = ..., *, compresslevel: int = ...) -> None: ... @overload def __init__( - self, filename: StrOrBytesPath, mode: Union[_ReadBinaryMode, _WriteBinaryMode] = ..., *, compresslevel: int = ... + self, filename: StrOrBytesPath, mode: _ReadBinaryMode | _WriteBinaryMode = ..., *, compresslevel: int = ... ) -> None: ... else: @overload def __init__( - self, filename: _WritableFileobj, mode: _WriteBinaryMode, buffering: Optional[Any] = ..., compresslevel: int = ... + self, filename: _WritableFileobj, mode: _WriteBinaryMode, buffering: Any | None = ..., compresslevel: int = ... ) -> None: ... @overload def __init__( self, filename: _ReadableFileobj, mode: _ReadBinaryMode = ..., - buffering: Optional[Any] = ..., + buffering: Any | None = ..., compresslevel: int = ..., ) -> None: ... @overload def __init__( self, filename: StrOrBytesPath, - mode: Union[_ReadBinaryMode, _WriteBinaryMode] = ..., - buffering: Optional[Any] = ..., + mode: _ReadBinaryMode | _WriteBinaryMode = ..., + buffering: Any | None = ..., compresslevel: int = ..., ) -> None: ... - def read(self, size: Optional[int] = ...) -> bytes: ... + def read(self, size: int | None = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore def readinto(self, b: WriteableBuffer) -> int: ... diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index a1deb38df4f4..d07a8c1c28a6 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -3,9 +3,9 @@ from _typeshed import Self, StrOrBytesPath from types import CodeType from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union -def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... +def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( - statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: Optional[str] = ..., sort: Union[str, int] = ... + statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... _T = TypeVar("_T") @@ -18,7 +18,7 @@ class Profile: ) -> None: ... def enable(self) -> None: ... def disable(self) -> None: ... - def print_stats(self, sort: Union[str, int] = ...) -> None: ... + def print_stats(self, sort: str | int = ...) -> None: ... def dump_stats(self, file: StrOrBytesPath) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... @@ -29,4 +29,4 @@ class Profile: def __enter__(self: Self) -> Self: ... def __exit__(self, *exc_info: Any) -> None: ... -def label(code: Union[str, CodeType]) -> _Label: ... # undocumented +def label(code: str | CodeType) -> _Label: ... # undocumented diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index c1d69a466f2e..c348cb8b4c27 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -67,7 +67,7 @@ class HTMLCalendar(Calendar): def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... def formatyear(self, theyear: int, width: int = ...) -> str: ... - def formatyearpage(self, theyear: int, width: int = ..., css: Optional[str] = ..., encoding: Optional[str] = ...) -> str: ... + def formatyearpage(self, theyear: int, width: int = ..., css: str | None = ..., encoding: str | None = ...) -> str: ... if sys.version_info >= (3, 7): cssclasses: List[str] cssclass_noday: str @@ -83,12 +83,12 @@ class different_locale: def __exit__(self, *args: Any) -> None: ... class LocaleTextCalendar(TextCalendar): - def __init__(self, firstweekday: int = ..., locale: Optional[_LocaleType] = ...) -> None: ... + def __init__(self, firstweekday: int = ..., locale: _LocaleType | None = ...) -> None: ... def formatweekday(self, day: int, width: int) -> str: ... def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... class LocaleHTMLCalendar(HTMLCalendar): - def __init__(self, firstweekday: int = ..., locale: Optional[_LocaleType] = ...) -> None: ... + def __init__(self, firstweekday: int = ..., locale: _LocaleType | None = ...) -> None: ... def formatweekday(self, day: int) -> str: ... def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... @@ -97,7 +97,7 @@ c: TextCalendar def setfirstweekday(firstweekday: int) -> None: ... def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... -def timegm(tuple: Union[Tuple[int, ...], struct_time]) -> int: ... +def timegm(tuple: Tuple[int, ...] | struct_time) -> int: ... # Data attributes day_name: Sequence[str] diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index da3a4d43c563..778cf632e1f0 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -7,7 +7,7 @@ from typing import IO, Any, Optional, Protocol, TypeVar, Union _T = TypeVar("_T", bound=FieldStorage) def parse( - fp: Optional[IO[Any]] = ..., + fp: IO[Any] | None = ..., environ: SupportsItemAccess[str, str] = ..., keep_blank_values: bool = ..., strict_parsing: bool = ..., @@ -38,14 +38,14 @@ def print_directory() -> None: ... def print_environ_usage() -> None: ... if sys.version_info < (3, 8): - def escape(s: str, quote: Optional[bool] = ...) -> str: ... + def escape(s: str, quote: bool | None = ...) -> str: ... class MiniFieldStorage: # The first five "Any" attributes here are always None, but mypy doesn't support that filename: Any list: Any type: Any - file: Optional[IO[bytes]] + file: IO[bytes] | None type_options: dict[Any, Any] disposition: Any disposition_options: dict[Any, Any] @@ -58,40 +58,40 @@ class MiniFieldStorage: _list = list class FieldStorage(object): - FieldStorageClass: Optional[_type] + FieldStorageClass: _type | None keep_blank_values: int strict_parsing: int - qs_on_post: Optional[str] + qs_on_post: str | None headers: Mapping[str, str] fp: IO[bytes] encoding: str errors: str outerboundary: bytes bytes_read: int - limit: Optional[int] + limit: int | None disposition: str disposition_options: dict[str, str] - filename: Optional[str] - file: Optional[IO[bytes]] + filename: str | None + file: IO[bytes] | None type: str type_options: dict[str, str] innerboundary: bytes length: int done: int - list: Optional[_list[Any]] - value: Union[None, bytes, _list[Any]] + list: _list[Any] | None + value: None | bytes | _list[Any] def __init__( self, - fp: Optional[IO[Any]] = ..., - headers: Optional[Mapping[str, str]] = ..., + fp: IO[Any] | None = ..., + headers: Mapping[str, str] | None = ..., outerboundary: bytes = ..., environ: SupportsGetItem[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ..., - limit: Optional[int] = ..., + limit: int | None = ..., encoding: str = ..., errors: str = ..., - max_num_fields: Optional[int] = ..., + max_num_fields: int | None = ..., separator: str = ..., ) -> None: ... def __enter__(self: _T) -> _T: ... diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index b8db1d8092a1..b2f1c23fa1a5 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -8,10 +8,10 @@ def reset() -> str: ... # undocumented def small(text: str) -> str: ... # undocumented def strong(text: str) -> str: ... # undocumented def grey(text: str) -> str: ... # undocumented -def lookup(name: str, frame: FrameType, locals: Dict[str, Any]) -> Tuple[Optional[str], Any]: ... # undocumented +def lookup(name: str, frame: FrameType, locals: Dict[str, Any]) -> Tuple[str | None, Any]: ... # undocumented def scanvars( reader: Callable[[], bytes], frame: FrameType, locals: Dict[str, Any] -) -> List[Tuple[str, Optional[str], Any]]: ... # undocumented +) -> List[Tuple[str, str | None, Any]]: ... # undocumented def html(einfo: _ExcInfo, context: int = ...) -> str: ... def text(einfo: _ExcInfo, context: int = ...) -> str: ... @@ -19,15 +19,15 @@ class Hook: # undocumented def __init__( self, display: int = ..., - logdir: Optional[StrOrBytesPath] = ..., + logdir: StrOrBytesPath | None = ..., context: int = ..., - file: Optional[IO[str]] = ..., + file: IO[str] | None = ..., format: str = ..., ) -> None: ... def __call__( - self, etype: Optional[Type[BaseException]], evalue: Optional[BaseException], etb: Optional[TracebackType] + self, etype: Type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None ) -> None: ... - def handle(self, info: Optional[_ExcInfo] = ...) -> None: ... + def handle(self, info: _ExcInfo | None = ...) -> None: ... -def handler(info: Optional[_ExcInfo] = ...) -> None: ... -def enable(display: int = ..., logdir: Optional[StrOrBytesPath] = ..., context: int = ..., format: str = ...) -> None: ... +def handler(info: _ExcInfo | None = ...) -> None: ... +def enable(display: int = ..., logdir: StrOrBytesPath | None = ..., context: int = ..., format: str = ...) -> None: ... diff --git a/stdlib/cmd.pyi b/stdlib/cmd.pyi index 0b7a7f704a9b..0ae61d8d0013 100644 --- a/stdlib/cmd.pyi +++ b/stdlib/cmd.pyi @@ -5,7 +5,7 @@ class Cmd: identchars: str ruler: str lastcmd: str - intro: Optional[Any] + intro: Any | None doc_leader: str doc_header: str misc_header: str @@ -16,24 +16,24 @@ class Cmd: stdout: IO[str] cmdqueue: List[str] completekey: str - def __init__(self, completekey: str = ..., stdin: Optional[IO[str]] = ..., stdout: Optional[IO[str]] = ...) -> None: ... - old_completer: Optional[Callable[[str, int], Optional[str]]] - def cmdloop(self, intro: Optional[Any] = ...) -> None: ... + def __init__(self, completekey: str = ..., stdin: IO[str] | None = ..., stdout: IO[str] | None = ...) -> None: ... + old_completer: Callable[[str, int], str | None] | None + def cmdloop(self, intro: Any | None = ...) -> None: ... def precmd(self, line: str) -> str: ... def postcmd(self, stop: bool, line: str) -> bool: ... def preloop(self) -> None: ... def postloop(self) -> None: ... - def parseline(self, line: str) -> Tuple[Optional[str], Optional[str], str]: ... + def parseline(self, line: str) -> Tuple[str | None, str | None, str]: ... def onecmd(self, line: str) -> bool: ... def emptyline(self) -> bool: ... def default(self, line: str) -> bool: ... def completedefault(self, *ignored: Any) -> List[str]: ... def completenames(self, text: str, *ignored: Any) -> List[str]: ... - completion_matches: Optional[List[str]] - def complete(self, text: str, state: int) -> Optional[List[str]]: ... + completion_matches: List[str] | None + def complete(self, text: str, state: int) -> List[str] | None: ... def get_names(self) -> List[str]: ... # Only the first element of args matters. def complete_help(self, *args: Any) -> List[str]: ... - def do_help(self, arg: str) -> Optional[bool]: ... - def print_topics(self, header: str, cmds: Optional[List[str]], cmdlen: Any, maxcol: int) -> None: ... - def columnize(self, list: Optional[List[str]], displaywidth: int = ...) -> None: ... + def do_help(self, arg: str) -> bool | None: ... + def print_topics(self, header: str, cmds: List[str] | None, cmdlen: Any, maxcol: int) -> None: ... + def columnize(self, list: List[str] | None, displaywidth: int = ...) -> None: ... diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 3e61c9eaf50c..1e9b0454965f 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -80,8 +80,8 @@ def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = . @overload def decode(obj: bytes, encoding: str = ..., errors: str = ...) -> str: ... def lookup(__encoding: str) -> CodecInfo: ... -def utf_16_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: bool = ...) -> Tuple[str, int]: ... # undocumented -def utf_16_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... # undocumented +def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> Tuple[str, int]: ... # undocumented +def utf_16_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... # undocumented class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): @property @@ -101,13 +101,13 @@ class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): cls, encode: _Encoder, decode: _Decoder, - streamreader: Optional[_StreamReader] = ..., - streamwriter: Optional[_StreamWriter] = ..., - incrementalencoder: Optional[_IncrementalEncoder] = ..., - incrementaldecoder: Optional[_IncrementalDecoder] = ..., - name: Optional[str] = ..., + streamreader: _StreamReader | None = ..., + streamwriter: _StreamWriter | None = ..., + incrementalencoder: _IncrementalEncoder | None = ..., + incrementaldecoder: _IncrementalDecoder | None = ..., + name: str | None = ..., *, - _is_text_encoding: Optional[bool] = ..., + _is_text_encoding: bool | None = ..., ) -> CodecInfo: ... def getencoder(encoding: str) -> _Encoder: ... @@ -116,16 +116,16 @@ def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ... def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ... def getreader(encoding: str) -> _StreamReader: ... def getwriter(encoding: str) -> _StreamWriter: ... -def register(__search_function: Callable[[str], Optional[CodecInfo]]) -> None: ... +def register(__search_function: Callable[[str], CodecInfo | None]) -> None: ... def open( - filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., buffering: int = ... + filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., buffering: int = ... ) -> StreamReaderWriter: ... -def EncodedFile(file: IO[bytes], data_encoding: str, file_encoding: Optional[str] = ..., errors: str = ...) -> StreamRecoder: ... +def EncodedFile(file: IO[bytes], data_encoding: str, file_encoding: str | None = ..., errors: str = ...) -> StreamRecoder: ... def iterencode(iterator: Iterable[str], encoding: str, errors: str = ...) -> Generator[bytes, None, None]: ... def iterdecode(iterator: Iterable[bytes], encoding: str, errors: str = ...) -> Generator[str, None, None]: ... if sys.version_info >= (3, 10): - def unregister(__search_function: Callable[[str], Optional[CodecInfo]]) -> None: ... + def unregister(__search_function: Callable[[str], CodecInfo | None]) -> None: ... BOM: bytes BOM_BE: bytes @@ -141,13 +141,13 @@ BOM_UTF32_LE: bytes # It is expected that different actions be taken depending on which of the # three subclasses of `UnicodeError` is actually ...ed. However, the Union # is still needed for at least one of the cases. -def register_error(__errors: str, __handler: Callable[[UnicodeError], Tuple[Union[str, bytes], int]]) -> None: ... -def lookup_error(__name: str) -> Callable[[UnicodeError], Tuple[Union[str, bytes], int]]: ... -def strict_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... -def replace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... -def ignore_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... -def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... -def backslashreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... +def register_error(__errors: str, __handler: Callable[[UnicodeError], Tuple[str | bytes, int]]) -> None: ... +def lookup_error(__name: str) -> Callable[[UnicodeError], Tuple[str | bytes, int]]: ... +def strict_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def replace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def ignore_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def backslashreplace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... class Codec: # These are sort of @abstractmethod but sort of not. @@ -162,8 +162,8 @@ class IncrementalEncoder: def encode(self, input: str, final: bool = ...) -> bytes: ... def reset(self) -> None: ... # documentation says int but str is needed for the subclass. - def getstate(self) -> Union[int, str]: ... - def setstate(self, state: Union[int, str]) -> None: ... + def getstate(self) -> int | str: ... + def setstate(self, state: int | str) -> None: ... class IncrementalDecoder: errors: str @@ -199,7 +199,7 @@ class StreamWriter(Codec): def reset(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -207,12 +207,12 @@ class StreamReader(Codec): errors: str def __init__(self, stream: IO[bytes], errors: str = ...) -> None: ... def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> str: ... - def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> str: ... - def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[str]: ... + def readline(self, size: int | None = ..., keepends: bool = ...) -> str: ... + def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[str]: ... def reset(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[str]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -224,8 +224,8 @@ _T = TypeVar("_T", bound=StreamReaderWriter) class StreamReaderWriter(TextIO): def __init__(self, stream: IO[bytes], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ... def read(self, size: int = ...) -> str: ... - def readline(self, size: Optional[int] = ...) -> str: ... - def readlines(self, sizehint: Optional[int] = ...) -> List[str]: ... + def readline(self, size: int | None = ...) -> str: ... + def readlines(self, sizehint: int | None = ...) -> List[str]: ... def __next__(self) -> str: ... def __iter__(self: _T) -> _T: ... # This actually returns None, but that's incompatible with the supertype @@ -236,7 +236,7 @@ class StreamReaderWriter(TextIO): def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __getattr__(self, name: str) -> Any: ... # These methods don't actually exist directly, but they are needed to satisfy the TextIO @@ -246,7 +246,7 @@ class StreamReaderWriter(TextIO): def flush(self) -> None: ... def isatty(self) -> bool: ... def readable(self) -> bool: ... - def truncate(self, size: Optional[int] = ...) -> int: ... + def truncate(self, size: int | None = ...) -> int: ... def seekable(self) -> bool: ... def tell(self) -> int: ... def writable(self) -> bool: ... @@ -264,8 +264,8 @@ class StreamRecoder(BinaryIO): errors: str = ..., ) -> None: ... def read(self, size: int = ...) -> bytes: ... - def readline(self, size: Optional[int] = ...) -> bytes: ... - def readlines(self, sizehint: Optional[int] = ...) -> List[bytes]: ... + def readline(self, size: int | None = ...) -> bytes: ... + def readlines(self, sizehint: int | None = ...) -> List[bytes]: ... def __next__(self) -> bytes: ... def __iter__(self: _SRT) -> _SRT: ... def write(self, data: bytes) -> int: ... @@ -274,7 +274,7 @@ class StreamRecoder(BinaryIO): def __getattr__(self, name: str) -> Any: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] + self, type: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None ) -> None: ... # These methods don't actually exist directly, but they are needed to satisfy the BinaryIO # interface. At runtime, they are delegated through __getattr__. @@ -284,7 +284,7 @@ class StreamRecoder(BinaryIO): def flush(self) -> None: ... def isatty(self) -> bool: ... def readable(self) -> bool: ... - def truncate(self, size: Optional[int] = ...) -> int: ... + def truncate(self, size: int | None = ...) -> int: ... def seekable(self) -> bool: ... def tell(self) -> int: ... def writable(self) -> bool: ... diff --git a/stdlib/codeop.pyi b/stdlib/codeop.pyi index f3d6c2819ec6..35cb4c5e3e60 100644 --- a/stdlib/codeop.pyi +++ b/stdlib/codeop.pyi @@ -1,7 +1,7 @@ from types import CodeType from typing import Optional -def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... +def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... class Compile: flags: int @@ -11,4 +11,4 @@ class Compile: class CommandCompiler: compiler: Compile def __init__(self) -> None: ... - def __call__(self, source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... + def __call__(self, source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index a625c2b38b1e..f24972423d9a 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -28,26 +28,26 @@ _VT = TypeVar("_VT") if sys.version_info >= (3, 7): def namedtuple( typename: str, - field_names: Union[str, Iterable[str]], + field_names: str | Iterable[str], *, rename: bool = ..., - module: Optional[str] = ..., - defaults: Optional[Iterable[Any]] = ..., + module: str | None = ..., + defaults: Iterable[Any] | None = ..., ) -> Type[Tuple[Any, ...]]: ... else: def namedtuple( typename: str, - field_names: Union[str, Iterable[str]], + field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., - module: Optional[str] = ..., + module: str | None = ..., ) -> Type[Tuple[Any, ...]]: ... class UserDict(MutableMapping[_KT, _VT]): data: Dict[_KT, _VT] - def __init__(self, __dict: Optional[Mapping[_KT, _VT]] = ..., **kwargs: _VT) -> None: ... + def __init__(self, __dict: Mapping[_KT, _VT] | None = ..., **kwargs: _VT) -> None: ... def __len__(self) -> int: ... def __getitem__(self, key: _KT) -> _VT: ... def __setitem__(self, key: _KT, item: _VT) -> None: ... @@ -56,11 +56,11 @@ class UserDict(MutableMapping[_KT, _VT]): def __contains__(self, key: object) -> bool: ... def copy(self: _S) -> _S: ... @classmethod - def fromkeys(cls: Type[_S], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _S: ... + def fromkeys(cls: Type[_S], iterable: Iterable[_KT], value: _VT | None = ...) -> _S: ... class UserList(MutableSequence[_T]): data: List[_T] - def __init__(self, initlist: Optional[Iterable[_T]] = ...) -> None: ... + def __init__(self, initlist: Iterable[_T] | None = ...) -> None: ... def __lt__(self, other: object) -> bool: ... def __le__(self, other: object) -> bool: ... def __gt__(self, other: object) -> bool: ... @@ -75,7 +75,7 @@ class UserList(MutableSequence[_T]): def __setitem__(self, i: int, o: _T) -> None: ... @overload def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... def __add__(self: _S, other: Iterable[_T]) -> _S: ... def __iadd__(self: _S, other: Iterable[_T]) -> _S: ... def __mul__(self: _S, n: int) -> _S: ... @@ -101,28 +101,28 @@ class UserString(Sequence[str]): def __float__(self) -> float: ... def __complex__(self) -> complex: ... def __getnewargs__(self) -> Tuple[str]: ... - def __lt__(self, string: Union[str, UserString]) -> bool: ... - def __le__(self, string: Union[str, UserString]) -> bool: ... - def __gt__(self, string: Union[str, UserString]) -> bool: ... - def __ge__(self, string: Union[str, UserString]) -> bool: ... + def __lt__(self, string: str | UserString) -> bool: ... + def __le__(self, string: str | UserString) -> bool: ... + def __gt__(self, string: str | UserString) -> bool: ... + def __ge__(self, string: str | UserString) -> bool: ... def __contains__(self, char: object) -> bool: ... def __len__(self) -> int: ... # It should return a str to implement Sequence correctly, but it doesn't. - def __getitem__(self: _UserStringT, i: Union[int, slice]) -> _UserStringT: ... # type: ignore + def __getitem__(self: _UserStringT, i: int | slice) -> _UserStringT: ... # type: ignore def __add__(self: _UserStringT, other: object) -> _UserStringT: ... def __mul__(self: _UserStringT, n: int) -> _UserStringT: ... def __mod__(self: _UserStringT, args: Any) -> _UserStringT: ... def capitalize(self: _UserStringT) -> _UserStringT: ... def casefold(self: _UserStringT) -> _UserStringT: ... def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... - def count(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... + def count(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... if sys.version_info >= (3, 8): - def encode(self: UserString, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> bytes: ... + def encode(self: UserString, encoding: str | None = ..., errors: str | None = ...) -> bytes: ... else: - def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UserStringT: ... - def endswith(self, suffix: Union[str, Tuple[str, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... + def encode(self: _UserStringT, encoding: str | None = ..., errors: str | None = ...) -> _UserStringT: ... + def endswith(self, suffix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ... - def find(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... + def find(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def format(self, *args: Any, **kwds: Any) -> str: ... def format_map(self, mapping: Mapping[str, Any]) -> str: ... def index(self, sub: str, start: int = ..., end: int = ...) -> int: ... @@ -140,30 +140,30 @@ class UserString(Sequence[str]): def join(self, seq: Iterable[str]) -> str: ... def ljust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... def lower(self: _UserStringT) -> _UserStringT: ... - def lstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... + def lstrip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ... @staticmethod @overload - def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... + def maketrans(x: Dict[int, _T] | Dict[str, _T] | Dict[str | int, _T]) -> Dict[int, _T]: ... @staticmethod @overload - def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ... + def maketrans(x: str, y: str, z: str = ...) -> Dict[int, int | None]: ... def partition(self, sep: str) -> Tuple[str, str, str]: ... if sys.version_info >= (3, 9): - def removeprefix(self: _UserStringT, __prefix: Union[str, UserString]) -> _UserStringT: ... - def removesuffix(self: _UserStringT, __suffix: Union[str, UserString]) -> _UserStringT: ... + def removeprefix(self: _UserStringT, __prefix: str | UserString) -> _UserStringT: ... + def removesuffix(self: _UserStringT, __suffix: str | UserString) -> _UserStringT: ... def replace( - self: _UserStringT, old: Union[str, UserString], new: Union[str, UserString], maxsplit: int = ... + self: _UserStringT, old: str | UserString, new: str | UserString, maxsplit: int = ... ) -> _UserStringT: ... - def rfind(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... + def rfind(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... + def rindex(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def rjust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... def rpartition(self, sep: str) -> Tuple[str, str, str]: ... - def rstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... - def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... - def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def rstrip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ... + def split(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ... + def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... - def startswith(self, prefix: Union[str, Tuple[str, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... - def strip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... + def startswith(self, prefix: str | Tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... + def strip(self: _UserStringT, chars: str | None = ...) -> _UserStringT: ... def swapcase(self: _UserStringT) -> _UserStringT: ... def title(self: _UserStringT) -> _UserStringT: ... def translate(self: _UserStringT, *args: Any) -> _UserStringT: ... @@ -172,8 +172,8 @@ class UserString(Sequence[str]): class deque(MutableSequence[_T], Generic[_T]): @property - def maxlen(self) -> Optional[int]: ... - def __init__(self, iterable: Iterable[_T] = ..., maxlen: Optional[int] = ...) -> None: ... + def maxlen(self) -> int | None: ... + def __init__(self, iterable: Iterable[_T] = ..., maxlen: int | None = ...) -> None: ... def append(self, x: _T) -> None: ... def appendleft(self, x: _T) -> None: ... def clear(self) -> None: ... @@ -221,9 +221,9 @@ class Counter(Dict[_T, int], Generic[_T]): def __init__(self, __iterable: Iterable[_T]) -> None: ... def copy(self: _S) -> _S: ... def elements(self) -> Iterator[_T]: ... - def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ... + def most_common(self, n: int | None = ...) -> List[Tuple[_T, int]]: ... @classmethod - def fromkeys(cls, iterable: Any, v: Optional[int] = ...) -> NoReturn: ... # type: ignore + def fromkeys(cls, iterable: Any, v: int | None = ...) -> NoReturn: ... # type: ignore @overload def subtract(self, __iterable: None = ...) -> None: ... @overload @@ -238,7 +238,7 @@ class Counter(Dict[_T, int], Generic[_T]): @overload def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ... @overload - def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ... + def update(self, __m: Iterable[_T] | Iterable[Tuple[_T, int]], **kwargs: int) -> None: ... @overload def update(self, __m: None = ..., **kwargs: int) -> None: ... def __add__(self, other: Counter[_T]) -> Counter[_T]: ... @@ -271,22 +271,22 @@ class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def values(self) -> _OrderedDictValuesView[_VT]: ... class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): - default_factory: Optional[Callable[[], _VT]] + default_factory: Callable[[], _VT] | None @overload def __init__(self, **kwargs: _VT) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]]) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]], **kwargs: _VT) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT]) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, map: Mapping[_KT, _VT]) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... @overload def __init__( - self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT + self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT ) -> None: ... def __missing__(self, key: _KT) -> _VT: ... # TODO __reversed__ @@ -295,7 +295,7 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]): maps: List[Mapping[_KT, _VT]] def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ... - def new_child(self, m: Optional[Mapping[_KT, _VT]] = ...) -> ChainMap[_KT, _VT]: ... + def new_child(self, m: Mapping[_KT, _VT] | None = ...) -> ChainMap[_KT, _VT]: ... @property def parents(self) -> ChainMap[_KT, _VT]: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... diff --git a/stdlib/compileall.pyi b/stdlib/compileall.pyi index 529568275c8c..4a8b734be634 100644 --- a/stdlib/compileall.pyi +++ b/stdlib/compileall.pyi @@ -11,34 +11,34 @@ class _SupportsSearch(Protocol): if sys.version_info >= (3, 9): def compile_dir( dir: StrPath, - maxlevels: Optional[int] = ..., - ddir: Optional[StrPath] = ..., + maxlevels: int | None = ..., + ddir: StrPath | None = ..., force: bool = ..., - rx: Optional[_SupportsSearch] = ..., + rx: _SupportsSearch | None = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., workers: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., + invalidation_mode: PycInvalidationMode | None = ..., *, - stripdir: Optional[str] = ..., # TODO: change to Optional[StrPath] once https://bugs.python.org/issue40447 is resolved - prependdir: Optional[StrPath] = ..., - limit_sl_dest: Optional[StrPath] = ..., + stripdir: str | None = ..., # TODO: change to StrPath | None once https://bugs.python.org/issue40447 is resolved + prependdir: StrPath | None = ..., + limit_sl_dest: StrPath | None = ..., hardlink_dupes: bool = ..., ) -> int: ... def compile_file( fullname: StrPath, - ddir: Optional[StrPath] = ..., + ddir: StrPath | None = ..., force: bool = ..., - rx: Optional[_SupportsSearch] = ..., + rx: _SupportsSearch | None = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., + invalidation_mode: PycInvalidationMode | None = ..., *, - stripdir: Optional[str] = ..., # TODO: change to Optional[StrPath] once https://bugs.python.org/issue40447 is resolved - prependdir: Optional[StrPath] = ..., - limit_sl_dest: Optional[StrPath] = ..., + stripdir: str | None = ..., # TODO: change to StrPath | None once https://bugs.python.org/issue40447 is resolved + prependdir: StrPath | None = ..., + limit_sl_dest: StrPath | None = ..., hardlink_dupes: bool = ..., ) -> int: ... @@ -46,33 +46,33 @@ elif sys.version_info >= (3, 7): def compile_dir( dir: StrPath, maxlevels: int = ..., - ddir: Optional[StrPath] = ..., + ddir: StrPath | None = ..., force: bool = ..., - rx: Optional[_SupportsSearch] = ..., + rx: _SupportsSearch | None = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., workers: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., + invalidation_mode: PycInvalidationMode | None = ..., ) -> int: ... def compile_file( fullname: StrPath, - ddir: Optional[StrPath] = ..., + ddir: StrPath | None = ..., force: bool = ..., - rx: Optional[_SupportsSearch] = ..., + rx: _SupportsSearch | None = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., + invalidation_mode: PycInvalidationMode | None = ..., ) -> int: ... else: def compile_dir( dir: StrPath, maxlevels: int = ..., - ddir: Optional[StrPath] = ..., + ddir: StrPath | None = ..., force: bool = ..., - rx: Optional[_SupportsSearch] = ..., + rx: _SupportsSearch | None = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., @@ -80,9 +80,9 @@ else: ) -> int: ... def compile_file( fullname: StrPath, - ddir: Optional[StrPath] = ..., + ddir: StrPath | None = ..., force: bool = ..., - rx: Optional[_SupportsSearch] = ..., + rx: _SupportsSearch | None = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., @@ -96,7 +96,7 @@ if sys.version_info >= (3, 7): quiet: int = ..., legacy: bool = ..., optimize: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., + invalidation_mode: PycInvalidationMode | None = ..., ) -> int: ... else: diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index df2afb9d9b6a..cbbe031ebc70 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -60,11 +60,11 @@ class Future(Generic[_T]): def running(self) -> bool: ... def done(self) -> bool: ... def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ... - def result(self, timeout: Optional[float] = ...) -> _T: ... + def result(self, timeout: float | None = ...) -> _T: ... def set_running_or_notify_cancel(self) -> bool: ... def set_result(self, result: _T) -> None: ... - def exception(self, timeout: Optional[float] = ...) -> Optional[BaseException]: ... - def set_exception(self, exception: Optional[BaseException]) -> None: ... + def exception(self, timeout: float | None = ...) -> BaseException | None: ... + def set_exception(self, exception: BaseException | None) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -74,16 +74,16 @@ class Executor: else: def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... def map( - self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ..., chunksize: int = ... + self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: float | None = ..., chunksize: int = ... ) -> Iterator[_T]: ... if sys.version_info >= (3, 9): def shutdown(self, wait: bool = ..., *, cancel_futures: bool = ...) -> None: ... else: def shutdown(self, wait: bool = ...) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Optional[bool]: ... + def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool | None: ... -def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ... +def as_completed(fs: Iterable[Future[_T]], timeout: float | None = ...) -> Iterator[Future[_T]]: ... # Ideally this would be a namedtuple, but mypy doesn't support generic tuple types. See #1976 class DoneAndNotDoneFutures(Sequence[Set[Future[_T]]]): @@ -96,7 +96,7 @@ class DoneAndNotDoneFutures(Sequence[Set[Future[_T]]]): @overload def __getitem__(self, s: slice) -> DoneAndNotDoneFutures[_T]: ... -def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> DoneAndNotDoneFutures[_T]: ... +def wait(fs: Iterable[Future[_T]], timeout: float | None = ..., return_when: str = ...) -> DoneAndNotDoneFutures[_T]: ... class _Waiter: event: threading.Event diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index a66557671ce5..e0003fe74761 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -17,12 +17,12 @@ if sys.version_info >= (3, 7): class ProcessPoolExecutor(Executor): def __init__( self, - max_workers: Optional[int] = ..., - mp_context: Optional[BaseContext] = ..., - initializer: Optional[Callable[..., None]] = ..., + max_workers: int | None = ..., + mp_context: BaseContext | None = ..., + initializer: Callable[..., None] | None = ..., initargs: Tuple[Any, ...] = ..., ) -> None: ... else: class ProcessPoolExecutor(Executor): - def __init__(self, max_workers: Optional[int] = ...) -> None: ... + def __init__(self, max_workers: int | None = ...) -> None: ... diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 9826922ca74f..788c81158454 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -21,13 +21,13 @@ class ThreadPoolExecutor(Executor): if sys.version_info >= (3, 7): def __init__( self, - max_workers: Optional[int] = ..., + max_workers: int | None = ..., thread_name_prefix: str = ..., - initializer: Optional[Callable[..., None]] = ..., + initializer: Callable[..., None] | None = ..., initargs: Tuple[Any, ...] = ..., ) -> None: ... else: - def __init__(self, max_workers: Optional[int] = ..., thread_name_prefix: str = ...) -> None: ... + def __init__(self, max_workers: int | None = ..., thread_name_prefix: str = ...) -> None: ... class _WorkItem(Generic[_S]): future: Future[_S] diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 46e5201a10bb..c8ae90f6573f 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -64,33 +64,33 @@ class RawConfigParser(_parser): @overload def __init__( self, - defaults: Optional[Mapping[str, Optional[str]]] = ..., + defaults: Mapping[str, str | None] | None = ..., dict_type: Type[Mapping[str, str]] = ..., allow_no_value: Literal[True] = ..., *, delimiters: Sequence[str] = ..., comment_prefixes: Sequence[str] = ..., - inline_comment_prefixes: Optional[Sequence[str]] = ..., + inline_comment_prefixes: Sequence[str] | None = ..., strict: bool = ..., empty_lines_in_values: bool = ..., default_section: str = ..., - interpolation: Optional[Interpolation] = ..., + interpolation: Interpolation | None = ..., converters: _converters = ..., ) -> None: ... @overload def __init__( self, - defaults: Optional[_section] = ..., + defaults: _section | None = ..., dict_type: Type[Mapping[str, str]] = ..., allow_no_value: bool = ..., *, delimiters: Sequence[str] = ..., comment_prefixes: Sequence[str] = ..., - inline_comment_prefixes: Optional[Sequence[str]] = ..., + inline_comment_prefixes: Sequence[str] | None = ..., strict: bool = ..., empty_lines_in_values: bool = ..., default_section: str = ..., - interpolation: Optional[Interpolation] = ..., + interpolation: Interpolation | None = ..., converters: _converters = ..., ) -> None: ... def __len__(self) -> int: ... @@ -104,31 +104,31 @@ class RawConfigParser(_parser): def has_section(self, section: str) -> bool: ... def options(self, section: str) -> List[str]: ... def has_option(self, section: str, option: str) -> bool: ... - def read(self, filenames: Union[_Path, Iterable[_Path]], encoding: Optional[str] = ...) -> List[str]: ... - def read_file(self, f: Iterable[str], source: Optional[str] = ...) -> None: ... + def read(self, filenames: _Path | Iterable[_Path], encoding: str | None = ...) -> List[str]: ... + def read_file(self, f: Iterable[str], source: str | None = ...) -> None: ... def read_string(self, string: str, source: str = ...) -> None: ... def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = ...) -> None: ... - def readfp(self, fp: Iterable[str], filename: Optional[str] = ...) -> None: ... + def readfp(self, fp: Iterable[str], filename: str | None = ...) -> None: ... # These get* methods are partially applied (with the same names) in # SectionProxy; the stubs should be kept updated together @overload - def getint(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> int: ... + def getint(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> int: ... @overload def getint( - self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... - ) -> Union[int, _T]: ... + self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ... + ) -> int | _T: ... @overload - def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> float: ... + def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ... @overload def getfloat( - self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... - ) -> Union[float, _T]: ... + self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ... + ) -> float | _T: ... @overload - def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> bool: ... + def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ... @overload def getboolean( - self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... - ) -> Union[bool, _T]: ... + self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ... + ) -> bool | _T: ... def _get_conv( self, section: str, @@ -136,21 +136,21 @@ class RawConfigParser(_parser): conv: Callable[[str], _T], *, raw: bool = ..., - vars: Optional[_section] = ..., + vars: _section | None = ..., fallback: _T = ..., ) -> _T: ... # This is incompatible with MutableMapping so we ignore the type @overload # type: ignore - def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> str: ... + def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> str: ... @overload def get( - self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T - ) -> Union[str, _T]: ... + self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T + ) -> str | _T: ... @overload - def items(self, *, raw: bool = ..., vars: Optional[_section] = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... + def items(self, *, raw: bool = ..., vars: _section | None = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... @overload - def items(self, section: str, raw: bool = ..., vars: Optional[_section] = ...) -> List[Tuple[str, str]]: ... - def set(self, section: str, option: str, value: Optional[str] = ...) -> None: ... + def items(self, section: str, raw: bool = ..., vars: _section | None = ...) -> List[Tuple[str, str]]: ... + def set(self, section: str, option: str, value: str | None = ...) -> None: ... def write(self, fp: SupportsWrite[str], space_around_delimiters: bool = ...) -> None: ... def remove_option(self, section: str, option: str) -> bool: ... def remove_section(self, section: str) -> bool: ... @@ -171,33 +171,33 @@ class SectionProxy(MutableMapping[str, str]): def parser(self) -> RawConfigParser: ... @property def name(self) -> str: ... - def get(self, option: str, fallback: Optional[str] = ..., *, raw: bool = ..., vars: Optional[_section] = ..., _impl: Optional[Any] = ..., **kwargs: Any) -> str: ... # type: ignore + def get(self, option: str, fallback: str | None = ..., *, raw: bool = ..., vars: _section | None = ..., _impl: Any | None = ..., **kwargs: Any) -> str: ... # type: ignore # These are partially-applied version of the methods with the same names in # RawConfigParser; the stubs should be kept updated together @overload - def getint(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> int: ... + def getint(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> int: ... @overload - def getint(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ...) -> Union[int, _T]: ... + def getint(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> int | _T: ... @overload - def getfloat(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> float: ... + def getfloat(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ... @overload def getfloat( - self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ... - ) -> Union[float, _T]: ... + self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ... + ) -> float | _T: ... @overload - def getboolean(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> bool: ... + def getboolean(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ... @overload def getboolean( - self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ... - ) -> Union[bool, _T]: ... + self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ... + ) -> bool | _T: ... # SectionProxy can have arbitrary attributes when custom converters are used def __getattr__(self, key: str) -> Callable[..., Any]: ... -class ConverterMapping(MutableMapping[str, Optional[_converter]]): +class ConverterMapping(MutableMapping[str, _converter | None]): GETTERCRE: Pattern[Any] def __init__(self, parser: RawConfigParser) -> None: ... def __getitem__(self, key: str) -> _converter: ... - def __setitem__(self, key: str, value: Optional[_converter]) -> None: ... + def __setitem__(self, key: str, value: _converter | None) -> None: ... def __delitem__(self, key: str) -> None: ... def __iter__(self) -> Iterator[str]: ... def __len__(self) -> int: ... @@ -212,16 +212,16 @@ class NoSectionError(Error): class DuplicateSectionError(Error): section: str - source: Optional[str] - lineno: Optional[int] - def __init__(self, section: str, source: Optional[str] = ..., lineno: Optional[int] = ...) -> None: ... + source: str | None + lineno: int | None + def __init__(self, section: str, source: str | None = ..., lineno: int | None = ...) -> None: ... class DuplicateOptionError(Error): section: str option: str - source: Optional[str] - lineno: Optional[int] - def __init__(self, section: str, option: str, source: Optional[str] = ..., lineno: Optional[int] = ...) -> None: ... + source: str | None + lineno: int | None + def __init__(self, section: str, option: str, source: str | None = ..., lineno: int | None = ...) -> None: ... class NoOptionError(Error): section: str @@ -245,7 +245,7 @@ class InterpolationSyntaxError(InterpolationError): ... class ParsingError(Error): source: str errors: List[Tuple[int, str]] - def __init__(self, source: Optional[str] = ..., filename: Optional[str] = ...) -> None: ... + def __init__(self, source: str | None = ..., filename: str | None = ...) -> None: ... def append(self, lineno: int, line: str) -> None: ... class MissingSectionHeaderError(ParsingError): diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index e2a680e4c65e..de56117f2d13 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -60,7 +60,7 @@ if sys.version_info >= (3, 10): class suppress(ContextManager[None]): def __init__(self, *exceptions: Type[BaseException]) -> None: ... def __exit__( - self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType] + self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> bool: ... class redirect_stdout(ContextManager[_T_io]): @@ -82,9 +82,9 @@ class ExitStack(ContextManager[ExitStack]): def __enter__(self: Self) -> Self: ... def __exit__( self, - __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], + __exc_type: Type[BaseException] | None, + __exc_value: BaseException | None, + __traceback: TracebackType | None, ) -> bool: ... if sys.version_info >= (3, 7): @@ -104,9 +104,9 @@ if sys.version_info >= (3, 7): def __aenter__(self: Self) -> Awaitable[Self]: ... def __aexit__( self, - __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], + __exc_type: Type[BaseException] | None, + __exc_value: BaseException | None, + __traceback: TracebackType | None, ) -> Awaitable[bool]: ... if sys.version_info >= (3, 10): diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index 069a6786688e..41c8bdbbe82c 100644 --- a/stdlib/contextvars.pyi +++ b/stdlib/contextvars.pyi @@ -14,7 +14,7 @@ class ContextVar(Generic[_T]): @overload def get(self) -> _T: ... @overload - def get(self, default: Union[_D, _T]) -> Union[_D, _T]: ... + def get(self, default: _D | _T) -> _D | _T: ... def set(self, value: _T) -> Token[_T]: ... def reset(self, token: Token[_T]) -> None: ... if sys.version_info >= (3, 9): @@ -36,9 +36,9 @@ def copy_context() -> Context: ... class Context(Mapping[ContextVar[Any], Any]): def __init__(self) -> None: ... @overload - def get(self, __key: ContextVar[Any]) -> Optional[Any]: ... + def get(self, __key: ContextVar[Any]) -> Any | None: ... @overload - def get(self, __key: ContextVar[Any], __default: Optional[Any]) -> Any: ... + def get(self, __key: ContextVar[Any], __default: Any | None) -> Any: ... def run(self, callable: Callable[..., _T], *args: Any, **kwargs: Any) -> _T: ... def copy(self) -> Context: ... def __getitem__(self, key: ContextVar[Any]) -> Any: ... diff --git a/stdlib/copy.pyi b/stdlib/copy.pyi index b51c79c66c6a..180e58756ead 100644 --- a/stdlib/copy.pyi +++ b/stdlib/copy.pyi @@ -6,7 +6,7 @@ _T = TypeVar("_T") PyStringMap: Any # Note: memo and _nil are internal kwargs. -def deepcopy(x: _T, memo: Optional[Dict[int, Any]] = ..., _nil: Any = ...) -> _T: ... +def deepcopy(x: _T, memo: Dict[int, Any] | None = ..., _nil: Any = ...) -> _T: ... def copy(x: _T) -> _T: ... class Error(Exception): ... diff --git a/stdlib/copyreg.pyi b/stdlib/copyreg.pyi index ea07ba410b6d..91b099888bab 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -7,8 +7,8 @@ __all__: List[str] def pickle( ob_type: _TypeT, - pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]], - constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ..., + pickle_function: Callable[[_TypeT], str | _Reduce[_TypeT]], + constructor_ob: Callable[[_Reduce[_TypeT]], _TypeT] | None = ..., ) -> None: ... def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ... diff --git a/stdlib/crypt.pyi b/stdlib/crypt.pyi index d8db0ffb4cea..3dfaa9bb0bc1 100644 --- a/stdlib/crypt.pyi +++ b/stdlib/crypt.pyi @@ -13,9 +13,9 @@ if sys.version_info >= (3, 7): methods: List[_Method] if sys.version_info >= (3, 7): - def mksalt(method: Optional[_Method] = ..., *, rounds: Optional[int] = ...) -> str: ... + def mksalt(method: _Method | None = ..., *, rounds: int | None = ...) -> str: ... else: - def mksalt(method: Optional[_Method] = ...) -> str: ... + def mksalt(method: _Method | None = ...) -> str: ... -def crypt(word: str, salt: Optional[Union[str, _Method]] = ...) -> str: ... +def crypt(word: str, salt: str | _Method | None = ...) -> str: ... diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 25a9e4aeb6c0..13539c6bd6e3 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -46,9 +46,9 @@ class unix_dialect(Dialect): quoting: int class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): - fieldnames: Optional[Sequence[_T]] - restkey: Optional[str] - restval: Optional[str] + fieldnames: Sequence[_T] | None + restkey: str | None + restval: str | None reader: _reader dialect: _DialectLike line_num: int @@ -57,8 +57,8 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): self, f: Iterable[str], fieldnames: Sequence[_T], - restkey: Optional[str] = ..., - restval: Optional[str] = ..., + restkey: str | None = ..., + restval: str | None = ..., dialect: _DialectLike = ..., *args: Any, **kwds: Any, @@ -67,9 +67,9 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): def __init__( self: DictReader[str], f: Iterable[str], - fieldnames: Optional[Sequence[str]] = ..., - restkey: Optional[str] = ..., - restval: Optional[str] = ..., + fieldnames: Sequence[str] | None = ..., + restkey: str | None = ..., + restval: str | None = ..., dialect: _DialectLike = ..., *args: Any, **kwds: Any, @@ -79,14 +79,14 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): class DictWriter(Generic[_T]): fieldnames: Sequence[_T] - restval: Optional[Any] + restval: Any | None extrasaction: str writer: _writer def __init__( self, f: Any, fieldnames: Sequence[_T], - restval: Optional[Any] = ..., + restval: Any | None = ..., extrasaction: str = ..., dialect: _DialectLike = ..., *args: Any, @@ -102,5 +102,5 @@ class DictWriter(Generic[_T]): class Sniffer(object): preferred: List[str] def __init__(self) -> None: ... - def sniff(self, sample: str, delimiters: Optional[str] = ...) -> Type[Dialect]: ... + def sniff(self, sample: str, delimiters: str | None = ...) -> Type[Dialect]: ... def has_header(self, sample: str) -> bool: ... diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 131bb4d7e1c0..adb4743140df 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -38,19 +38,19 @@ class CDLL(object): if sys.version_info >= (3, 8): def __init__( self, - name: Optional[str], + name: str | None, mode: int = ..., - handle: Optional[int] = ..., + handle: int | None = ..., use_errno: bool = ..., use_last_error: bool = ..., - winmode: Optional[int] = ..., + winmode: int | None = ..., ) -> None: ... else: def __init__( self, - name: Optional[str], + name: str | None, mode: int = ..., - handle: Optional[int] = ..., + handle: int | None = ..., use_errno: bool = ..., use_last_error: bool = ..., ) -> None: ... @@ -95,7 +95,7 @@ class _CDataMeta(type): class _CData(metaclass=_CDataMeta): _b_base: int = ... _b_needsfree_: bool = ... - _objects: Optional[Mapping[Any, int]] = ... + _objects: Mapping[Any, int] | None = ... @classmethod def from_buffer(cls: Type[_CT], source: _WritableBuffer, offset: int = ...) -> _CT: ... @classmethod @@ -133,15 +133,15 @@ class _NamedFuncPointer(_FuncPointer): class ArgumentError(Exception): ... def CFUNCTYPE( - restype: Optional[Type[_CData]], *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... + restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... ) -> Type[_FuncPointer]: ... if sys.platform == "win32": def WINFUNCTYPE( - restype: Optional[Type[_CData]], *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... + restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... ) -> Type[_FuncPointer]: ... -def PYFUNCTYPE(restype: Optional[Type[_CData]], *argtypes: Type[_CData]) -> Type[_FuncPointer]: ... +def PYFUNCTYPE(restype: Type[_CData] | None, *argtypes: Type[_CData]) -> Type[_FuncPointer]: ... class _CArgObject: ... @@ -161,11 +161,11 @@ def byref(obj: _CData, offset: int = ...) -> _CArgObject: ... _CastT = TypeVar("_CastT", bound=_CanCastTo) def cast(obj: _UnionT[_CData, _CArgObject, int], typ: Type[_CastT]) -> _CastT: ... -def create_string_buffer(init: _UnionT[int, bytes], size: Optional[int] = ...) -> Array[c_char]: ... +def create_string_buffer(init: _UnionT[int, bytes], size: int | None = ...) -> Array[c_char]: ... c_buffer = create_string_buffer -def create_unicode_buffer(init: _UnionT[int, str], size: Optional[int] = ...) -> Array[c_wchar]: ... +def create_unicode_buffer(init: _UnionT[int, str], size: int | None = ...) -> Array[c_wchar]: ... if sys.platform == "win32": def DllCanUnloadNow() -> int: ... @@ -208,7 +208,7 @@ def sizeof(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ... def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ... if sys.platform == "win32": - def WinError(code: Optional[int] = ..., descr: Optional[str] = ...) -> OSError: ... + def WinError(code: int | None = ..., descr: str | None = ...) -> OSError: ... def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ... @@ -221,8 +221,8 @@ class c_byte(_SimpleCData[int]): ... class c_char(_SimpleCData[bytes]): def __init__(self, value: _UnionT[int, bytes] = ...) -> None: ... -class c_char_p(_PointerLike, _SimpleCData[Optional[bytes]]): - def __init__(self, value: Optional[_UnionT[int, bytes]] = ...) -> None: ... +class c_char_p(_PointerLike, _SimpleCData[bytes | None]): + def __init__(self, value: _UnionT[int, bytes] | None = ...) -> None: ... class c_double(_SimpleCData[float]): ... class c_longdouble(_SimpleCData[float]): ... @@ -246,11 +246,11 @@ class c_uint64(_SimpleCData[int]): ... class c_ulong(_SimpleCData[int]): ... class c_ulonglong(_SimpleCData[int]): ... class c_ushort(_SimpleCData[int]): ... -class c_void_p(_PointerLike, _SimpleCData[Optional[int]]): ... +class c_void_p(_PointerLike, _SimpleCData[int | None]): ... class c_wchar(_SimpleCData[str]): ... -class c_wchar_p(_PointerLike, _SimpleCData[Optional[str]]): - def __init__(self, value: Optional[_UnionT[int, str]] = ...) -> None: ... +class c_wchar_p(_PointerLike, _SimpleCData[str | None]): + def __init__(self, value: _UnionT[int, str] | None = ...) -> None: ... class c_bool(_SimpleCData[bool]): def __init__(self, value: bool = ...) -> None: ... diff --git a/stdlib/ctypes/util.pyi b/stdlib/ctypes/util.pyi index 20914c70a05c..5d0a732de9f8 100644 --- a/stdlib/ctypes/util.pyi +++ b/stdlib/ctypes/util.pyi @@ -1,7 +1,7 @@ import sys from typing import Optional -def find_library(name: str) -> Optional[str]: ... +def find_library(name: str) -> str | None: ... if sys.platform == "win32": - def find_msvcrt() -> Optional[str]: ... + def find_msvcrt() -> str | None: ... diff --git a/stdlib/curses/ascii.pyi b/stdlib/curses/ascii.pyi index 10bab853adcf..1baff6e81a11 100644 --- a/stdlib/curses/ascii.pyi +++ b/stdlib/curses/ascii.pyi @@ -41,22 +41,22 @@ DEL: int controlnames: List[int] -def isalnum(c: Union[str, int]) -> bool: ... -def isalpha(c: Union[str, int]) -> bool: ... -def isascii(c: Union[str, int]) -> bool: ... -def isblank(c: Union[str, int]) -> bool: ... -def iscntrl(c: Union[str, int]) -> bool: ... -def isdigit(c: Union[str, int]) -> bool: ... -def isgraph(c: Union[str, int]) -> bool: ... -def islower(c: Union[str, int]) -> bool: ... -def isprint(c: Union[str, int]) -> bool: ... -def ispunct(c: Union[str, int]) -> bool: ... -def isspace(c: Union[str, int]) -> bool: ... -def isupper(c: Union[str, int]) -> bool: ... -def isxdigit(c: Union[str, int]) -> bool: ... -def isctrl(c: Union[str, int]) -> bool: ... -def ismeta(c: Union[str, int]) -> bool: ... +def isalnum(c: str | int) -> bool: ... +def isalpha(c: str | int) -> bool: ... +def isascii(c: str | int) -> bool: ... +def isblank(c: str | int) -> bool: ... +def iscntrl(c: str | int) -> bool: ... +def isdigit(c: str | int) -> bool: ... +def isgraph(c: str | int) -> bool: ... +def islower(c: str | int) -> bool: ... +def isprint(c: str | int) -> bool: ... +def ispunct(c: str | int) -> bool: ... +def isspace(c: str | int) -> bool: ... +def isupper(c: str | int) -> bool: ... +def isxdigit(c: str | int) -> bool: ... +def isctrl(c: str | int) -> bool: ... +def ismeta(c: str | int) -> bool: ... def ascii(c: _CharT) -> _CharT: ... def ctrl(c: _CharT) -> _CharT: ... def alt(c: _CharT) -> _CharT: ... -def unctrl(c: Union[str, int]) -> str: ... +def unctrl(c: str | int) -> str: ... diff --git a/stdlib/curses/textpad.pyi b/stdlib/curses/textpad.pyi index d2b5766fda26..41b32bc9b5e1 100644 --- a/stdlib/curses/textpad.pyi +++ b/stdlib/curses/textpad.pyi @@ -6,6 +6,6 @@ def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> Non class Textbox: stripspaces: bool def __init__(self, win: _CursesWindow, insert_mode: bool = ...) -> None: ... - def edit(self, validate: Optional[Callable[[int], int]] = ...) -> str: ... - def do_command(self, ch: Union[str, int]) -> None: ... + def edit(self, validate: Callable[[int], int] | None = ...) -> str: ... + def do_command(self, ch: str | int) -> None: ... def gather(self) -> str: ... diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index bf824abaf4e5..9dc893fb853a 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -74,7 +74,7 @@ class Field(Generic[_T]): default: _T default_factory: _DefaultFactory[_T] repr: bool - hash: Optional[bool] + hash: bool | None init: bool compare: bool metadata: Mapping[str, Any] @@ -86,7 +86,7 @@ class Field(Generic[_T]): default_factory: Callable[[], _T], init: bool, repr: bool, - hash: Optional[bool], + hash: bool | None, compare: bool, metadata: Mapping[str, Any], kw_only: bool, @@ -98,7 +98,7 @@ class Field(Generic[_T]): default_factory: Callable[[], _T], init: bool, repr: bool, - hash: Optional[bool], + hash: bool | None, compare: bool, metadata: Mapping[str, Any], ) -> None: ... @@ -114,9 +114,9 @@ if sys.version_info >= (3, 10): default: _T, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., kw_only: bool = ..., ) -> _T: ... @overload @@ -125,9 +125,9 @@ if sys.version_info >= (3, 10): default_factory: Callable[[], _T], init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., kw_only: bool = ..., ) -> _T: ... @overload @@ -135,9 +135,9 @@ if sys.version_info >= (3, 10): *, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., kw_only: bool = ..., ) -> Any: ... @@ -148,9 +148,9 @@ else: default: _T, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., ) -> _T: ... @overload def field( @@ -158,18 +158,18 @@ else: default_factory: Callable[[], _T], init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., ) -> _T: ... @overload def field( *, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., ) -> Any: ... def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... @@ -189,10 +189,10 @@ class InitVar(Generic[_T]): if sys.version_info >= (3, 10): def make_dataclass( cls_name: str, - fields: Iterable[Union[str, Tuple[str, type], Tuple[str, type, Field[Any]]]], + fields: Iterable[str | Tuple[str, type] | Tuple[str, type, Field[Any]]], *, bases: Tuple[type, ...] = ..., - namespace: Optional[Dict[str, Any]] = ..., + namespace: Dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., eq: bool = ..., @@ -206,10 +206,10 @@ if sys.version_info >= (3, 10): else: def make_dataclass( cls_name: str, - fields: Iterable[Union[str, Tuple[str, type], Tuple[str, type, Field[Any]]]], + fields: Iterable[str | Tuple[str, type] | Tuple[str, type, Field[Any]]], *, bases: Tuple[type, ...] = ..., - namespace: Optional[Dict[str, Any]] = ..., + namespace: Dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., eq: bool = ..., diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 4426a9eee28f..35cf7646631e 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -8,9 +8,9 @@ MINYEAR: int MAXYEAR: int class tzinfo: - def tzname(self, dt: Optional[datetime]) -> Optional[str]: ... - def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ... - def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... + def tzname(self, dt: datetime | None) -> str | None: ... + def utcoffset(self, dt: datetime | None) -> timedelta | None: ... + def dst(self, dt: datetime | None) -> timedelta | None: ... def fromutc(self, dt: datetime) -> datetime: ... # Alias required to avoid name conflicts with date(time).tzinfo. @@ -91,7 +91,7 @@ class time: minute: int = ..., second: int = ..., microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., + tzinfo: _tzinfo | None = ..., *, fold: int = ..., ) -> _S: ... @@ -104,7 +104,7 @@ class time: @property def microsecond(self) -> int: ... @property - def tzinfo(self) -> Optional[_tzinfo]: ... + def tzinfo(self) -> _tzinfo | None: ... @property def fold(self) -> int: ... def __le__(self, other: time) -> bool: ... @@ -118,16 +118,16 @@ class time: def fromisoformat(cls: Type[_S], time_string: str) -> _S: ... def strftime(self, fmt: str) -> str: ... def __format__(self, fmt: str) -> str: ... - def utcoffset(self) -> Optional[timedelta]: ... - def tzname(self) -> Optional[str]: ... - def dst(self) -> Optional[timedelta]: ... + def utcoffset(self) -> timedelta | None: ... + def tzname(self) -> str | None: ... + def dst(self) -> timedelta | None: ... def replace( self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., + tzinfo: _tzinfo | None = ..., *, fold: int = ..., ) -> time: ... @@ -195,7 +195,7 @@ class datetime(date): minute: int = ..., second: int = ..., microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., + tzinfo: _tzinfo | None = ..., *, fold: int = ..., ) -> _S: ... @@ -214,11 +214,11 @@ class datetime(date): @property def microsecond(self) -> int: ... @property - def tzinfo(self) -> Optional[_tzinfo]: ... + def tzinfo(self) -> _tzinfo | None: ... @property def fold(self) -> int: ... @classmethod - def fromtimestamp(cls: Type[_S], t: float, tz: Optional[_tzinfo] = ...) -> _S: ... + def fromtimestamp(cls: Type[_S], t: float, tz: _tzinfo | None = ...) -> _S: ... @classmethod def utcfromtimestamp(cls: Type[_S], t: float) -> _S: ... @classmethod @@ -227,7 +227,7 @@ class datetime(date): def fromordinal(cls: Type[_S], n: int) -> _S: ... if sys.version_info >= (3, 8): @classmethod - def now(cls: Type[_S], tz: Optional[_tzinfo] = ...) -> _S: ... + def now(cls: Type[_S], tz: _tzinfo | None = ...) -> _S: ... else: @overload @classmethod @@ -238,7 +238,7 @@ class datetime(date): @classmethod def utcnow(cls: Type[_S]) -> _S: ... @classmethod - def combine(cls, date: _date, time: _time, tzinfo: Optional[_tzinfo] = ...) -> datetime: ... + def combine(cls, date: _date, time: _time, tzinfo: _tzinfo | None = ...) -> datetime: ... if sys.version_info >= (3, 7): @classmethod def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... @@ -260,21 +260,21 @@ class datetime(date): minute: int = ..., second: int = ..., microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., + tzinfo: _tzinfo | None = ..., *, fold: int = ..., ) -> datetime: ... if sys.version_info >= (3, 8): - def astimezone(self: _S, tz: Optional[_tzinfo] = ...) -> _S: ... + def astimezone(self: _S, tz: _tzinfo | None = ...) -> _S: ... else: - def astimezone(self, tz: Optional[_tzinfo] = ...) -> datetime: ... + def astimezone(self, tz: _tzinfo | None = ...) -> datetime: ... def ctime(self) -> str: ... def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ... @classmethod def strptime(cls, date_string: str, format: str) -> datetime: ... - def utcoffset(self) -> Optional[timedelta]: ... - def tzname(self) -> Optional[str]: ... - def dst(self) -> Optional[timedelta]: ... + def utcoffset(self) -> timedelta | None: ... + def tzname(self) -> str | None: ... + def dst(self) -> timedelta | None: ... def __le__(self, other: datetime) -> bool: ... # type: ignore def __lt__(self, other: datetime) -> bool: ... # type: ignore def __ge__(self, other: datetime) -> bool: ... # type: ignore diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 7344d7b1b755..50001f5ca7c6 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -82,7 +82,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _error(Exception): ... diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index 1daa24b7f5b8..3c2ba6f791a6 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -20,7 +20,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index c694ca96b33f..21f2d7b8eac2 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -10,8 +10,8 @@ class error(OSError): ... # Actual typename gdbm, not exposed by the implementation class _gdbm: - def firstkey(self) -> Optional[bytes]: ... - def nextkey(self, key: _KeyType) -> Optional[bytes]: ... + def firstkey(self) -> bytes | None: ... + def nextkey(self, key: _KeyType) -> bytes | None: ... def reorganize(self) -> None: ... def sync(self) -> None: ... def close(self) -> None: ... @@ -22,12 +22,12 @@ class _gdbm: def __len__(self) -> int: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload - def get(self, k: _KeyType) -> Optional[bytes]: ... + def get(self, k: _KeyType) -> bytes | None: ... @overload - def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ... + def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... def keys(self) -> List[bytes]: ... def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... # Don't exist at runtime diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index 6af8d5c32fd7..b7366e1ea1b8 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -20,12 +20,12 @@ class _dbm: def __del__(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload - def get(self, k: _KeyType) -> Optional[bytes]: ... + def get(self, k: _KeyType) -> bytes | None: ... @overload - def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ... + def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... def keys(self) -> List[bytes]: ... def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... # Don't exist at runtime diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index f63243853133..11326541699a 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -44,18 +44,18 @@ class FloatOperation(DecimalException, TypeError): ... def setcontext(__context: Context) -> None: ... def getcontext() -> Context: ... -def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ... +def localcontext(ctx: Context | None = ...) -> _ContextManager: ... class Decimal(object): - def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ... + def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Context | None = ...) -> _DecimalT: ... @classmethod def from_float(cls, __f: float) -> Decimal: ... def __bool__(self) -> bool: ... - def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def compare(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def __hash__(self) -> int: ... def as_tuple(self) -> DecimalTuple: ... def as_integer_ratio(self) -> Tuple[int, int]: ... - def to_eng_string(self, context: Optional[Context] = ...) -> str: ... + def to_eng_string(self, context: Context | None = ...) -> str: ... def __abs__(self) -> Decimal: ... def __add__(self, other: _Decimal) -> Decimal: ... def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... @@ -69,7 +69,7 @@ class Decimal(object): def __mul__(self, other: _Decimal) -> Decimal: ... def __neg__(self) -> Decimal: ... def __pos__(self) -> Decimal: ... - def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ... + def __pow__(self, other: _Decimal, modulo: _Decimal | None = ...) -> Decimal: ... def __radd__(self, other: _Decimal) -> Decimal: ... def __rdivmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... def __rfloordiv__(self, other: _Decimal) -> Decimal: ... @@ -80,7 +80,7 @@ class Decimal(object): def __str__(self) -> str: ... def __sub__(self, other: _Decimal) -> Decimal: ... def __truediv__(self, other: _Decimal) -> Decimal: ... - def remainder_near(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def remainder_near(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def __float__(self) -> float: ... def __int__(self) -> int: ... def __trunc__(self) -> int: ... @@ -96,64 +96,64 @@ class Decimal(object): def __round__(self, ndigits: int) -> Decimal: ... def __floor__(self) -> int: ... def __ceil__(self) -> int: ... - def fma(self, other: _Decimal, third: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rpow__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def normalize(self, context: Optional[Context] = ...) -> Decimal: ... - def quantize(self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... - def same_quantum(self, other: _Decimal, context: Optional[Context] = ...) -> bool: ... - def to_integral_exact(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... - def to_integral_value(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... - def to_integral(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... - def sqrt(self, context: Optional[Context] = ...) -> Decimal: ... - def max(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def min(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def fma(self, other: _Decimal, third: _Decimal, context: Context | None = ...) -> Decimal: ... + def __rpow__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def normalize(self, context: Context | None = ...) -> Decimal: ... + def quantize(self, exp: _Decimal, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... + def same_quantum(self, other: _Decimal, context: Context | None = ...) -> bool: ... + def to_integral_exact(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... + def to_integral_value(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... + def to_integral(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... + def sqrt(self, context: Context | None = ...) -> Decimal: ... + def max(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def min(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def adjusted(self) -> int: ... def canonical(self) -> Decimal: ... - def compare_signal(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def compare_total(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def compare_total_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def compare_signal(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def compare_total(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def compare_total_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def copy_abs(self) -> Decimal: ... def copy_negate(self) -> Decimal: ... - def copy_sign(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def exp(self, context: Optional[Context] = ...) -> Decimal: ... + def copy_sign(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def exp(self, context: Context | None = ...) -> Decimal: ... def is_canonical(self) -> bool: ... def is_finite(self) -> bool: ... def is_infinite(self) -> bool: ... def is_nan(self) -> bool: ... - def is_normal(self, context: Optional[Context] = ...) -> bool: ... + def is_normal(self, context: Context | None = ...) -> bool: ... def is_qnan(self) -> bool: ... def is_signed(self) -> bool: ... def is_snan(self) -> bool: ... - def is_subnormal(self, context: Optional[Context] = ...) -> bool: ... + def is_subnormal(self, context: Context | None = ...) -> bool: ... def is_zero(self) -> bool: ... - def ln(self, context: Optional[Context] = ...) -> Decimal: ... - def log10(self, context: Optional[Context] = ...) -> Decimal: ... - def logb(self, context: Optional[Context] = ...) -> Decimal: ... - def logical_and(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def logical_invert(self, context: Optional[Context] = ...) -> Decimal: ... - def logical_or(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def logical_xor(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def max_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def min_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def next_minus(self, context: Optional[Context] = ...) -> Decimal: ... - def next_plus(self, context: Optional[Context] = ...) -> Decimal: ... - def next_toward(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def number_class(self, context: Optional[Context] = ...) -> str: ... + def ln(self, context: Context | None = ...) -> Decimal: ... + def log10(self, context: Context | None = ...) -> Decimal: ... + def logb(self, context: Context | None = ...) -> Decimal: ... + def logical_and(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def logical_invert(self, context: Context | None = ...) -> Decimal: ... + def logical_or(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def logical_xor(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def max_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def min_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def next_minus(self, context: Context | None = ...) -> Decimal: ... + def next_plus(self, context: Context | None = ...) -> Decimal: ... + def next_toward(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def number_class(self, context: Context | None = ...) -> str: ... def radix(self) -> Decimal: ... - def rotate(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def scaleb(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def shift(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def rotate(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def scaleb(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def shift(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def __reduce__(self) -> Tuple[Type[Decimal], Tuple[str]]: ... def __copy__(self) -> Decimal: ... def __deepcopy__(self, memo: Any) -> Decimal: ... - def __format__(self, specifier: str, context: Optional[Context] = ...) -> str: ... + def __format__(self, specifier: str, context: Context | None = ...) -> str: ... class _ContextManager(object): new_context: Context saved_context: Context def __init__(self, new_context: Context) -> None: ... def __enter__(self) -> Context: ... - def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... + def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... _TrapType = Type[DecimalException] @@ -168,15 +168,15 @@ class Context(object): flags: Dict[_TrapType, bool] def __init__( self, - prec: Optional[int] = ..., - rounding: Optional[str] = ..., - Emin: Optional[int] = ..., - Emax: Optional[int] = ..., - capitals: Optional[int] = ..., - clamp: Optional[int] = ..., - flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., + prec: int | None = ..., + rounding: str | None = ..., + Emin: int | None = ..., + Emax: int | None = ..., + capitals: int | None = ..., + clamp: int | None = ..., + flags: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., + traps: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., + _ignored_flags: List[_TrapType] | None = ..., ) -> None: ... # __setattr__() only allows to set a specific set of attributes, # already defined above. @@ -236,7 +236,7 @@ class Context(object): def normalize(self, __x: _Decimal) -> Decimal: ... def number_class(self, __x: _Decimal) -> str: ... def plus(self, __x: _Decimal) -> Decimal: ... - def power(self, a: _Decimal, b: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ... + def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = ...) -> Decimal: ... def quantize(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... def radix(self) -> Decimal: ... def remainder(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index 9dd98d331f3c..4793709fe7ce 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -29,14 +29,14 @@ class Match(NamedTuple): class SequenceMatcher(Generic[_T]): def __init__( - self, isjunk: Optional[Callable[[_T], bool]] = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ... + self, isjunk: Callable[[_T], bool] | None = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ... ) -> None: ... def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ... def set_seq1(self, a: Sequence[_T]) -> None: ... def set_seq2(self, b: Sequence[_T]) -> None: ... if sys.version_info >= (3, 9): def find_longest_match( - self, alo: int = ..., ahi: Optional[int] = ..., blo: int = ..., bhi: Optional[int] = ... + self, alo: int = ..., ahi: int | None = ..., blo: int = ..., bhi: int | None = ... ) -> Match: ... else: def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ... @@ -60,7 +60,7 @@ def get_close_matches( ) -> List[Sequence[_T]]: ... class Differ: - def __init__(self, linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ...) -> None: ... + def __init__(self, linejunk: _JunkCallback | None = ..., charjunk: _JunkCallback | None = ...) -> None: ... def compare(self, a: Sequence[str], b: Sequence[str]) -> Iterator[str]: ... def IS_LINE_JUNK(line: str, pat: Any = ...) -> bool: ... # pat is undocumented @@ -86,16 +86,16 @@ def context_diff( lineterm: str = ..., ) -> Iterator[str]: ... def ndiff( - a: Sequence[str], b: Sequence[str], linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ... + a: Sequence[str], b: Sequence[str], linejunk: _JunkCallback | None = ..., charjunk: _JunkCallback | None = ... ) -> Iterator[str]: ... class HtmlDiff(object): def __init__( self, tabsize: int = ..., - wrapcolumn: Optional[int] = ..., - linejunk: Optional[_JunkCallback] = ..., - charjunk: Optional[_JunkCallback] = ..., + wrapcolumn: int | None = ..., + linejunk: _JunkCallback | None = ..., + charjunk: _JunkCallback | None = ..., ) -> None: ... def make_file( self, diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index 60fa845d0206..3676ba0bb849 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -26,18 +26,18 @@ _have_code_or_string = Union[_have_code, str, bytes] class Instruction(NamedTuple): opname: str opcode: int - arg: Optional[int] + arg: int | None argval: Any argrepr: str offset: int - starts_line: Optional[int] + starts_line: int | None is_jump_target: bool class Bytecode: codeobj: types.CodeType first_line: int def __init__( - self, x: _have_code_or_string, *, first_line: Optional[int] = ..., current_offset: Optional[int] = ... + self, x: _have_code_or_string, *, first_line: int | None = ..., current_offset: int | None = ... ) -> None: ... def __iter__(self) -> Iterator[Instruction]: ... def __repr__(self) -> str: ... @@ -54,13 +54,13 @@ def pretty_flags(flags: int) -> str: ... def code_info(x: _have_code_or_string) -> str: ... if sys.version_info >= (3, 7): - def dis(x: Optional[_have_code_or_string] = ..., *, file: Optional[IO[str]] = ..., depth: Optional[int] = ...) -> None: ... + def dis(x: _have_code_or_string | None = ..., *, file: IO[str] | None = ..., depth: int | None = ...) -> None: ... else: - def dis(x: Optional[_have_code_or_string] = ..., *, file: Optional[IO[str]] = ...) -> None: ... + def dis(x: _have_code_or_string | None = ..., *, file: IO[str] | None = ...) -> None: ... -def distb(tb: Optional[types.TracebackType] = ..., *, file: Optional[IO[str]] = ...) -> None: ... -def disassemble(co: _have_code, lasti: int = ..., *, file: Optional[IO[str]] = ...) -> None: ... -def disco(co: _have_code, lasti: int = ..., *, file: Optional[IO[str]] = ...) -> None: ... -def show_code(co: _have_code, *, file: Optional[IO[str]] = ...) -> None: ... -def get_instructions(x: _have_code, *, first_line: Optional[int] = ...) -> Iterator[Instruction]: ... +def distb(tb: types.TracebackType | None = ..., *, file: IO[str] | None = ...) -> None: ... +def disassemble(co: _have_code, lasti: int = ..., *, file: IO[str] | None = ...) -> None: ... +def disco(co: _have_code, lasti: int = ..., *, file: IO[str] | None = ...) -> None: ... +def show_code(co: _have_code, *, file: IO[str] | None = ...) -> None: ... +def get_instructions(x: _have_code, *, first_line: int | None = ...) -> Iterator[Instruction]: ... diff --git a/stdlib/distutils/archive_util.pyi b/stdlib/distutils/archive_util.pyi index 76ae158de3e6..0cc06b3332de 100644 --- a/stdlib/distutils/archive_util.pyi +++ b/stdlib/distutils/archive_util.pyi @@ -3,20 +3,20 @@ from typing import Optional def make_archive( base_name: str, format: str, - root_dir: Optional[str] = ..., - base_dir: Optional[str] = ..., + root_dir: str | None = ..., + base_dir: str | None = ..., verbose: int = ..., dry_run: int = ..., - owner: Optional[str] = ..., - group: Optional[str] = ..., + owner: str | None = ..., + group: str | None = ..., ) -> str: ... def make_tarball( base_name: str, base_dir: str, - compress: Optional[str] = ..., + compress: str | None = ..., verbose: int = ..., dry_run: int = ..., - owner: Optional[str] = ..., - group: Optional[str] = ..., + owner: str | None = ..., + group: str | None = ..., ) -> str: ... def make_zipfile(base_name: str, base_dir: str, verbose: int = ..., dry_run: int = ...) -> str: ... diff --git a/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index 831311d2cb52..b0539bf9e5dc 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -6,9 +6,9 @@ def gen_lib_options( compiler: CCompiler, library_dirs: List[str], runtime_library_dirs: List[str], libraries: List[str] ) -> List[str]: ... def gen_preprocess_options(macros: List[_Macro], include_dirs: List[str]) -> List[str]: ... -def get_default_compiler(osname: Optional[str] = ..., platform: Optional[str] = ...) -> str: ... +def get_default_compiler(osname: str | None = ..., platform: str | None = ...) -> str: ... def new_compiler( - plat: Optional[str] = ..., compiler: Optional[str] = ..., verbose: int = ..., dry_run: int = ..., force: int = ... + plat: str | None = ..., compiler: str | None = ..., verbose: int = ..., dry_run: int = ..., force: int = ... ) -> CCompiler: ... def show_compilers() -> None: ... @@ -16,7 +16,7 @@ class CCompiler: dry_run: bool force: bool verbose: bool - output_dir: Optional[str] + output_dir: str | None macros: List[_Macro] include_dirs: List[str] libraries: List[str] @@ -32,19 +32,19 @@ class CCompiler: def set_library_dirs(self, dirs: List[str]) -> None: ... def add_runtime_library_dir(self, dir: str) -> None: ... def set_runtime_library_dirs(self, dirs: List[str]) -> None: ... - def define_macro(self, name: str, value: Optional[str] = ...) -> None: ... + def define_macro(self, name: str, value: str | None = ...) -> None: ... def undefine_macro(self, name: str) -> None: ... def add_link_object(self, object: str) -> None: ... def set_link_objects(self, objects: List[str]) -> None: ... - def detect_language(self, sources: Union[str, List[str]]) -> Optional[str]: ... - def find_library_file(self, dirs: List[str], lib: str, debug: bool = ...) -> Optional[str]: ... + def detect_language(self, sources: str | List[str]) -> str | None: ... + def find_library_file(self, dirs: List[str], lib: str, debug: bool = ...) -> str | None: ... def has_function( self, funcname: str, - includes: Optional[List[str]] = ..., - include_dirs: Optional[List[str]] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., + includes: List[str] | None = ..., + include_dirs: List[str] | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., ) -> bool: ... def library_dir_option(self, dir: str) -> str: ... def library_option(self, lib: str) -> str: ... @@ -53,95 +53,95 @@ class CCompiler: def compile( self, sources: List[str], - output_dir: Optional[str] = ..., - macros: Optional[_Macro] = ..., - include_dirs: Optional[List[str]] = ..., + output_dir: str | None = ..., + macros: _Macro | None = ..., + include_dirs: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - depends: Optional[List[str]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + depends: List[str] | None = ..., ) -> List[str]: ... def create_static_lib( self, objects: List[str], output_libname: str, - output_dir: Optional[str] = ..., + output_dir: str | None = ..., debug: bool = ..., - target_lang: Optional[str] = ..., + target_lang: str | None = ..., ) -> None: ... def link( self, target_desc: str, objects: List[str], output_filename: str, - output_dir: Optional[str] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + output_dir: str | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., + export_symbols: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_executable( self, objects: List[str], output_progname: str, - output_dir: Optional[str] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., + output_dir: str | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - target_lang: Optional[str] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_shared_lib( self, objects: List[str], output_libname: str, - output_dir: Optional[str] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + output_dir: str | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., + export_symbols: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_shared_object( self, objects: List[str], output_filename: str, - output_dir: Optional[str] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + output_dir: str | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., + export_symbols: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def preprocess( self, source: str, - output_file: Optional[str] = ..., - macros: Optional[List[_Macro]] = ..., - include_dirs: Optional[List[str]] = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., + output_file: str | None = ..., + macros: List[_Macro] | None = ..., + include_dirs: List[str] | None = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., ) -> None: ... def executable_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... def object_filenames(self, source_filenames: List[str], strip_dir: int = ..., output_dir: str = ...) -> List[str]: ... def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: Optional[str] = ..., level: int = ...) -> None: ... + def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... def spawn(self, cmd: List[str]) -> None: ... def mkpath(self, name: str, mode: int = ...) -> None: ... def move_file(self, src: str, dst: str) -> str: ... diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 93bfc7c9dbb5..63c910cd1c5f 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -3,7 +3,7 @@ from distutils.dist import Distribution from typing import Any, Callable, Iterable, List, Optional, Tuple, Union class Command: - sub_commands: List[Tuple[str, Optional[Callable[[Command], bool]]]] + sub_commands: List[Tuple[str, Callable[[Command], bool] | None]] def __init__(self, dist: Distribution) -> None: ... @abstractmethod def initialize_options(self) -> None: ... @@ -13,18 +13,18 @@ class Command: def run(self) -> None: ... def announce(self, msg: str, level: int = ...) -> None: ... def debug_print(self, msg: str) -> None: ... - def ensure_string(self, option: str, default: Optional[str] = ...) -> None: ... - def ensure_string_list(self, option: Union[str, List[str]]) -> None: ... + def ensure_string(self, option: str, default: str | None = ...) -> None: ... + def ensure_string_list(self, option: str | List[str]) -> None: ... def ensure_filename(self, option: str) -> None: ... def ensure_dirname(self, option: str) -> None: ... def get_command_name(self) -> str: ... def set_undefined_options(self, src_cmd: str, *option_pairs: Tuple[str, str]) -> None: ... def get_finalized_command(self, command: str, create: int = ...) -> Command: ... - def reinitialize_command(self, command: Union[Command, str], reinit_subcommands: int = ...) -> Command: ... + def reinitialize_command(self, command: Command | str, reinit_subcommands: int = ...) -> Command: ... def run_command(self, command: str) -> None: ... def get_sub_commands(self) -> List[str]: ... def warn(self, msg: str) -> None: ... - def execute(self, func: Callable[..., Any], args: Iterable[Any], msg: Optional[str] = ..., level: int = ...) -> None: ... + def execute(self, func: Callable[..., Any], args: Iterable[Any], msg: str | None = ..., level: int = ...) -> None: ... def mkpath(self, name: str, mode: int = ...) -> None: ... def copy_file( self, @@ -32,7 +32,7 @@ class Command: outfile: str, preserve_mode: int = ..., preserve_times: int = ..., - link: Optional[str] = ..., + link: str | None = ..., level: Any = ..., ) -> Tuple[str, bool]: ... # level is not used def copy_tree( @@ -50,18 +50,18 @@ class Command: self, base_name: str, format: str, - root_dir: Optional[str] = ..., - base_dir: Optional[str] = ..., - owner: Optional[str] = ..., - group: Optional[str] = ..., + root_dir: str | None = ..., + base_dir: str | None = ..., + owner: str | None = ..., + group: str | None = ..., ) -> str: ... def make_file( self, - infiles: Union[str, List[str], Tuple[str]], + infiles: str | List[str] | Tuple[str], outfile: str, func: Callable[..., Any], args: List[Any], - exec_msg: Optional[str] = ..., - skip_msg: Optional[str] = ..., + exec_msg: str | None = ..., + skip_msg: str | None = ..., level: Any = ..., ) -> None: ... # level is not used diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index 9a3fa70fd381..997134596087 100644 --- a/stdlib/distutils/core.pyi +++ b/stdlib/distutils/core.pyi @@ -25,8 +25,8 @@ def setup( script_args: List[str] = ..., options: Mapping[str, Any] = ..., license: str = ..., - keywords: Union[List[str], str] = ..., - platforms: Union[List[str], str] = ..., + keywords: List[str] | str = ..., + platforms: List[str] | str = ..., cmdclass: Mapping[str, Type[Command]] = ..., data_files: List[Tuple[str, List[str]]] = ..., package_dir: Mapping[str, str] = ..., @@ -45,4 +45,4 @@ def setup( fullname: str = ..., **attrs: Any, ) -> None: ... -def run_setup(script_name: str, script_args: Optional[List[str]] = ..., stop_after: str = ...) -> Distribution: ... +def run_setup(script_name: str, script_args: List[str] | None = ..., stop_after: str = ...) -> Distribution: ... diff --git a/stdlib/distutils/debug.pyi b/stdlib/distutils/debug.pyi index 89a7f3854ab4..9aacb8d4879c 100644 --- a/stdlib/distutils/debug.pyi +++ b/stdlib/distutils/debug.pyi @@ -1,3 +1,3 @@ from typing import Optional -DEBUG: Optional[bool] +DEBUG: bool | None diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 8655371adfaa..c8811ed7e4c1 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -3,24 +3,24 @@ from distutils.cmd import Command from typing import IO, Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, Union class DistributionMetadata: - def __init__(self, path: Optional[Union[int, StrOrBytesPath]] = ...) -> None: ... - name: Optional[str] - version: Optional[str] - author: Optional[str] - author_email: Optional[str] - maintainer: Optional[str] - maintainer_email: Optional[str] - url: Optional[str] - license: Optional[str] - description: Optional[str] - long_description: Optional[str] - keywords: Optional[Union[str, List[str]]] - platforms: Optional[Union[str, List[str]]] - classifiers: Optional[Union[str, List[str]]] - download_url: Optional[str] - provides: Optional[List[str]] - requires: Optional[List[str]] - obsoletes: Optional[List[str]] + def __init__(self, path: int | StrOrBytesPath | None = ...) -> None: ... + name: str | None + version: str | None + author: str | None + author_email: str | None + maintainer: str | None + maintainer_email: str | None + url: str | None + license: str | None + description: str | None + long_description: str | None + keywords: str | List[str] | None + platforms: str | List[str] | None + classifiers: str | List[str] | None + download_url: str | None + provides: List[str] | None + requires: List[str] | None + obsoletes: List[str] | None def read_pkg_file(self, file: IO[str]) -> None: ... def write_pkg_info(self, base_dir: str) -> None: ... def write_pkg_file(self, file: SupportsWrite[str]) -> None: ... @@ -38,9 +38,9 @@ class DistributionMetadata: def get_licence(self) -> str: ... def get_description(self) -> str: ... def get_long_description(self) -> str: ... - def get_keywords(self) -> Union[str, List[str]]: ... - def get_platforms(self) -> Union[str, List[str]]: ... - def get_classifiers(self) -> Union[str, List[str]]: ... + def get_keywords(self) -> str | List[str]: ... + def get_platforms(self) -> str | List[str]: ... + def get_classifiers(self) -> str | List[str]: ... def get_download_url(self) -> str: ... def get_requires(self) -> List[str]: ... def set_requires(self, value: Iterable[str]) -> None: ... @@ -52,7 +52,7 @@ class DistributionMetadata: class Distribution: cmdclass: Dict[str, Type[Command]] metadata: DistributionMetadata - def __init__(self, attrs: Optional[Mapping[str, Any]] = ...) -> None: ... + def __init__(self, attrs: Mapping[str, Any] | None = ...) -> None: ... def get_option_dict(self, command: str) -> Dict[str, Tuple[str, str]]: ... - def parse_config_files(self, filenames: Optional[Iterable[str]] = ...) -> None: ... - def get_command_obj(self, command: str, create: bool = ...) -> Optional[Command]: ... + def parse_config_files(self, filenames: Iterable[str] | None = ...) -> None: ... + def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... diff --git a/stdlib/distutils/extension.pyi b/stdlib/distutils/extension.pyi index 47aa8ad4f040..613a9b33fa24 100644 --- a/stdlib/distutils/extension.pyi +++ b/stdlib/distutils/extension.pyi @@ -5,18 +5,18 @@ class Extension: self, name: str, sources: List[str], - include_dirs: Optional[List[str]] = ..., - define_macros: Optional[List[Tuple[str, Optional[str]]]] = ..., - undef_macros: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - libraries: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - extra_objects: Optional[List[str]] = ..., - extra_compile_args: Optional[List[str]] = ..., - extra_link_args: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., - swig_opts: Optional[str] = ..., # undocumented - depends: Optional[List[str]] = ..., - language: Optional[str] = ..., - optional: Optional[bool] = ..., + include_dirs: List[str] | None = ..., + define_macros: List[Tuple[str, str | None]] | None = ..., + undef_macros: List[str] | None = ..., + library_dirs: List[str] | None = ..., + libraries: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., + extra_objects: List[str] | None = ..., + extra_compile_args: List[str] | None = ..., + extra_link_args: List[str] | None = ..., + export_symbols: List[str] | None = ..., + swig_opts: str | None = ..., # undocumented + depends: List[str] | None = ..., + language: str | None = ..., + optional: bool | None = ..., ) -> None: ... diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index 00f2cd648aeb..ab7ac0e6a152 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -4,19 +4,19 @@ _Option = Tuple[str, Optional[str], str] _GR = Tuple[List[str], OptionDummy] def fancy_getopt( - options: List[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: Optional[List[str]] -) -> Union[List[str], _GR]: ... + options: List[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: List[str] | None +) -> List[str] | _GR: ... def wrap_text(text: str, width: int) -> List[str]: ... class FancyGetopt: - def __init__(self, option_table: Optional[List[_Option]] = ...) -> None: ... + def __init__(self, option_table: List[_Option] | None = ...) -> None: ... # TODO kinda wrong, `getopt(object=object())` is invalid @overload - def getopt(self, args: Optional[List[str]] = ...) -> _GR: ... + def getopt(self, args: List[str] | None = ...) -> _GR: ... @overload - def getopt(self, args: Optional[List[str]], object: Any) -> List[str]: ... + def getopt(self, args: List[str] | None, object: Any) -> List[str]: ... def get_option_order(self) -> List[Tuple[str, str]]: ... - def generate_help(self, header: Optional[str] = ...) -> List[str]: ... + def generate_help(self, header: str | None = ...) -> List[str]: ... class OptionDummy: def __init__(self, options: Iterable[str] = ...) -> None: ... diff --git a/stdlib/distutils/file_util.pyi b/stdlib/distutils/file_util.pyi index 018339733df0..8c2b302efa6a 100644 --- a/stdlib/distutils/file_util.pyi +++ b/stdlib/distutils/file_util.pyi @@ -6,7 +6,7 @@ def copy_file( preserve_mode: bool = ..., preserve_times: bool = ..., update: bool = ..., - link: Optional[str] = ..., + link: str | None = ..., verbose: bool = ..., dry_run: bool = ..., ) -> Tuple[str, str]: ... diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 99e26218f171..24f990691896 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -3,7 +3,7 @@ from typing_extensions import Literal # class is entirely undocumented class FileList: - allfiles: Optional[Iterable[str]] = ... + allfiles: Iterable[str] | None = ... files: List[str] = ... def __init__(self, warn: None = ..., debug_print: None = ...) -> None: ... def set_allfiles(self, allfiles: Iterable[str]) -> None: ... @@ -16,45 +16,45 @@ class FileList: def process_template_line(self, line: str) -> None: ... @overload def include_pattern( - self, pattern: str, anchor: Union[int, bool] = ..., prefix: Optional[str] = ..., is_regex: Literal[0, False] = ... + self, pattern: str, anchor: int | bool = ..., prefix: str | None = ..., is_regex: Literal[0, False] = ... ) -> bool: ... @overload - def include_pattern(self, pattern: Union[str, Pattern[str]], *, is_regex: Literal[True, 1] = ...) -> bool: ... + def include_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> bool: ... @overload def include_pattern( self, - pattern: Union[str, Pattern[str]], - anchor: Union[int, bool] = ..., - prefix: Optional[str] = ..., - is_regex: Union[int, bool] = ..., + pattern: str | Pattern[str], + anchor: int | bool = ..., + prefix: str | None = ..., + is_regex: int | bool = ..., ) -> bool: ... @overload def exclude_pattern( - self, pattern: str, anchor: Union[int, bool] = ..., prefix: Optional[str] = ..., is_regex: Literal[0, False] = ... + self, pattern: str, anchor: int | bool = ..., prefix: str | None = ..., is_regex: Literal[0, False] = ... ) -> bool: ... @overload - def exclude_pattern(self, pattern: Union[str, Pattern[str]], *, is_regex: Literal[True, 1] = ...) -> bool: ... + def exclude_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> bool: ... @overload def exclude_pattern( self, - pattern: Union[str, Pattern[str]], - anchor: Union[int, bool] = ..., - prefix: Optional[str] = ..., - is_regex: Union[int, bool] = ..., + pattern: str | Pattern[str], + anchor: int | bool = ..., + prefix: str | None = ..., + is_regex: int | bool = ..., ) -> bool: ... def findall(dir: str = ...) -> List[str]: ... def glob_to_re(pattern: str) -> str: ... @overload def translate_pattern( - pattern: str, anchor: Union[int, bool] = ..., prefix: Optional[str] = ..., is_regex: Literal[False, 0] = ... + pattern: str, anchor: int | bool = ..., prefix: str | None = ..., is_regex: Literal[False, 0] = ... ) -> Pattern[str]: ... @overload -def translate_pattern(pattern: Union[str, Pattern[str]], *, is_regex: Literal[True, 1] = ...) -> Pattern[str]: ... +def translate_pattern(pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> Pattern[str]: ... @overload def translate_pattern( - pattern: Union[str, Pattern[str]], - anchor: Union[int, bool] = ..., - prefix: Optional[str] = ..., - is_regex: Union[int, bool] = ..., + pattern: str | Pattern[str], + anchor: int | bool = ..., + prefix: str | None = ..., + is_regex: int | bool = ..., ) -> Pattern[str]: ... diff --git a/stdlib/distutils/spawn.pyi b/stdlib/distutils/spawn.pyi index e12eae99bf29..6e51effd858d 100644 --- a/stdlib/distutils/spawn.pyi +++ b/stdlib/distutils/spawn.pyi @@ -1,4 +1,4 @@ from typing import List, Optional def spawn(cmd: List[str], search_path: bool = ..., verbose: bool = ..., dry_run: bool = ...) -> None: ... -def find_executable(executable: str, path: Optional[str] = ...) -> Optional[str]: ... +def find_executable(executable: str, path: str | None = ...) -> str | None: ... diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index 4b4baf416ffa..a5617cd76424 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -4,10 +4,10 @@ from typing import Mapping, Optional, Union PREFIX: str EXEC_PREFIX: str -def get_config_var(name: str) -> Union[int, str, None]: ... -def get_config_vars(*args: str) -> Mapping[str, Union[int, str]]: ... +def get_config_var(name: str) -> int | str | None: ... +def get_config_vars(*args: str) -> Mapping[str, int | str]: ... def get_config_h_filename() -> str: ... def get_makefile_filename() -> str: ... -def get_python_inc(plat_specific: bool = ..., prefix: Optional[str] = ...) -> str: ... -def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: Optional[str] = ...) -> str: ... +def get_python_inc(plat_specific: bool = ..., prefix: str | None = ...) -> str: ... +def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: str | None = ...) -> str: ... def customize_compiler(compiler: CCompiler) -> None: ... diff --git a/stdlib/distutils/text_file.pyi b/stdlib/distutils/text_file.pyi index a65f37305d94..71983de31e68 100644 --- a/stdlib/distutils/text_file.pyi +++ b/stdlib/distutils/text_file.pyi @@ -3,8 +3,8 @@ from typing import IO, List, Optional, Tuple, Union class TextFile: def __init__( self, - filename: Optional[str] = ..., - file: Optional[IO[str]] = ..., + filename: str | None = ..., + file: IO[str] | None = ..., *, strip_comments: bool = ..., lstrip_ws: bool = ..., @@ -15,7 +15,7 @@ class TextFile: ) -> None: ... def open(self, filename: str) -> None: ... def close(self) -> None: ... - def warn(self, msg: str, line: Optional[Union[List[int], Tuple[int, int], int]] = ...) -> None: ... - def readline(self) -> Optional[str]: ... + def warn(self, msg: str, line: List[int] | Tuple[int, int] | int | None = ...) -> None: ... + def readline(self) -> str | None: ... def readlines(self) -> List[str]: ... def unreadline(self, line: str) -> str: ... diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 311b0bead960..1b48b84b292b 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -6,33 +6,33 @@ _T = TypeVar("_T", bound=Version) class Version: def __repr__(self) -> str: ... def __eq__(self, other: object) -> bool: ... - def __lt__(self: _T, other: Union[_T, str]) -> bool: ... - def __le__(self: _T, other: Union[_T, str]) -> bool: ... - def __gt__(self: _T, other: Union[_T, str]) -> bool: ... - def __ge__(self: _T, other: Union[_T, str]) -> bool: ... + def __lt__(self: _T, other: _T | str) -> bool: ... + def __le__(self: _T, other: _T | str) -> bool: ... + def __gt__(self: _T, other: _T | str) -> bool: ... + def __ge__(self: _T, other: _T | str) -> bool: ... @abstractmethod - def __init__(self, vstring: Optional[str] = ...) -> None: ... + def __init__(self, vstring: str | None = ...) -> None: ... @abstractmethod def parse(self: _T, vstring: str) -> _T: ... @abstractmethod def __str__(self) -> str: ... @abstractmethod - def _cmp(self: _T, other: Union[_T, str]) -> bool: ... + def _cmp(self: _T, other: _T | str) -> bool: ... class StrictVersion(Version): version_re: Pattern[str] version: Tuple[int, int, int] - prerelease: Optional[Tuple[str, int]] - def __init__(self, vstring: Optional[str] = ...) -> None: ... + prerelease: Tuple[str, int] | None + def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... - def _cmp(self: _T, other: Union[_T, str]) -> bool: ... + def _cmp(self: _T, other: _T | str) -> bool: ... class LooseVersion(Version): component_re: Pattern[str] vstring: str - version: Tuple[Union[str, int], ...] - def __init__(self, vstring: Optional[str] = ...) -> None: ... + version: Tuple[str | int, ...] + def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... - def _cmp(self: _T, other: Union[_T, str]) -> bool: ... + def _cmp(self: _T, other: _T | str) -> bool: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 93dbdae1f44a..91f2640cd79a 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -33,7 +33,7 @@ ELLIPSIS_MARKER: str class Example: source: str want: str - exc_msg: Optional[str] + exc_msg: str | None lineno: int indent: int options: Dict[int, bool] @@ -41,10 +41,10 @@ class Example: self, source: str, want: str, - exc_msg: Optional[str] = ..., + exc_msg: str | None = ..., lineno: int = ..., indent: int = ..., - options: Optional[Dict[int, bool]] = ..., + options: Dict[int, bool] | None = ..., ) -> None: ... def __hash__(self) -> int: ... @@ -52,25 +52,25 @@ class DocTest: examples: List[Example] globs: Dict[str, Any] name: str - filename: Optional[str] - lineno: Optional[int] - docstring: Optional[str] + filename: str | None + lineno: int | None + docstring: str | None def __init__( self, examples: List[Example], globs: Dict[str, Any], name: str, - filename: Optional[str], - lineno: Optional[int], - docstring: Optional[str], + filename: str | None, + lineno: int | None, + docstring: str | None, ) -> None: ... def __hash__(self) -> int: ... def __lt__(self, other: DocTest) -> bool: ... class DocTestParser: - def parse(self, string: str, name: str = ...) -> List[Union[str, Example]]: ... + def parse(self, string: str, name: str = ...) -> List[str | Example]: ... def get_doctest( - self, string: str, globs: Dict[str, Any], name: str, filename: Optional[str], lineno: Optional[int] + self, string: str, globs: Dict[str, Any], name: str, filename: str | None, lineno: int | None ) -> DocTest: ... def get_examples(self, string: str, name: str = ...) -> List[Example]: ... @@ -81,10 +81,10 @@ class DocTestFinder: def find( self, obj: object, - name: Optional[str] = ..., - module: Union[None, bool, types.ModuleType] = ..., - globs: Optional[Dict[str, Any]] = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + name: str | None = ..., + module: None | bool | types.ModuleType = ..., + globs: Dict[str, Any] | None = ..., + extraglobs: Dict[str, Any] | None = ..., ) -> List[DocTest]: ... _Out = Callable[[str], Any] @@ -97,15 +97,15 @@ class DocTestRunner: tries: int failures: int test: DocTest - def __init__(self, checker: Optional[OutputChecker] = ..., verbose: Optional[bool] = ..., optionflags: int = ...) -> None: ... + def __init__(self, checker: OutputChecker | None = ..., verbose: bool | None = ..., optionflags: int = ...) -> None: ... def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ... def report_success(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ... def report_failure(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ... def report_unexpected_exception(self, out: _Out, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ... def run( - self, test: DocTest, compileflags: Optional[int] = ..., out: Optional[_Out] = ..., clear_globs: bool = ... + self, test: DocTest, compileflags: int | None = ..., out: _Out | None = ..., clear_globs: bool = ... ) -> TestResults: ... - def summarize(self, verbose: Optional[bool] = ...) -> TestResults: ... + def summarize(self, verbose: bool | None = ...) -> TestResults: ... def merge(self, other: DocTestRunner) -> None: ... class OutputChecker: @@ -126,39 +126,39 @@ class UnexpectedException(Exception): class DebugRunner(DocTestRunner): ... -master: Optional[DocTestRunner] +master: DocTestRunner | None def testmod( - m: Optional[types.ModuleType] = ..., - name: Optional[str] = ..., - globs: Optional[Dict[str, Any]] = ..., - verbose: Optional[bool] = ..., + m: types.ModuleType | None = ..., + name: str | None = ..., + globs: Dict[str, Any] | None = ..., + verbose: bool | None = ..., report: bool = ..., optionflags: int = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + extraglobs: Dict[str, Any] | None = ..., raise_on_error: bool = ..., exclude_empty: bool = ..., ) -> TestResults: ... def testfile( filename: str, module_relative: bool = ..., - name: Optional[str] = ..., - package: Union[None, str, types.ModuleType] = ..., - globs: Optional[Dict[str, Any]] = ..., - verbose: Optional[bool] = ..., + name: str | None = ..., + package: None | str | types.ModuleType = ..., + globs: Dict[str, Any] | None = ..., + verbose: bool | None = ..., report: bool = ..., optionflags: int = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + extraglobs: Dict[str, Any] | None = ..., raise_on_error: bool = ..., parser: DocTestParser = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., ) -> TestResults: ... def run_docstring_examples( f: object, globs: Dict[str, Any], verbose: bool = ..., name: str = ..., - compileflags: Optional[int] = ..., + compileflags: int | None = ..., optionflags: int = ..., ) -> None: ... def set_unittest_reportflags(flags: int) -> int: ... @@ -168,9 +168,9 @@ class DocTestCase(unittest.TestCase): self, test: DocTest, optionflags: int = ..., - setUp: Optional[Callable[[DocTest], Any]] = ..., - tearDown: Optional[Callable[[DocTest], Any]] = ..., - checker: Optional[OutputChecker] = ..., + setUp: Callable[[DocTest], Any] | None = ..., + tearDown: Callable[[DocTest], Any] | None = ..., + checker: OutputChecker | None = ..., ) -> None: ... def setUp(self) -> None: ... def tearDown(self) -> None: ... @@ -190,10 +190,10 @@ class SkipDocTestCase(DocTestCase): class _DocTestSuite(unittest.TestSuite): ... def DocTestSuite( - module: Union[None, str, types.ModuleType] = ..., - globs: Optional[Dict[str, Any]] = ..., - extraglobs: Optional[Dict[str, Any]] = ..., - test_finder: Optional[DocTestFinder] = ..., + module: None | str | types.ModuleType = ..., + globs: Dict[str, Any] | None = ..., + extraglobs: Dict[str, Any] | None = ..., + test_finder: DocTestFinder | None = ..., **options: Any, ) -> _DocTestSuite: ... @@ -204,15 +204,15 @@ class DocFileCase(DocTestCase): def DocFileTest( path: str, module_relative: bool = ..., - package: Union[None, str, types.ModuleType] = ..., - globs: Optional[Dict[str, Any]] = ..., + package: None | str | types.ModuleType = ..., + globs: Dict[str, Any] | None = ..., parser: DocTestParser = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., **options: Any, ) -> DocFileCase: ... def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... def script_from_examples(s: str) -> str: ... -def testsource(module: Union[None, str, types.ModuleType], name: str) -> str: ... -def debug_src(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ... -def debug_script(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ... -def debug(module: Union[None, str, types.ModuleType], name: str, pm: bool = ...) -> None: ... +def testsource(module: None | str | types.ModuleType, name: str) -> str: ... +def debug_src(src: str, pm: bool = ..., globs: Dict[str, Any] | None = ...) -> None: ... +def debug_script(src: str, pm: bool = ..., globs: Dict[str, Any] | None = ...) -> None: ... +def debug(module: None | str | types.ModuleType, name: str, pm: bool = ...) -> None: ... diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index 22a2a643ed1b..28427c25d1eb 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -23,8 +23,8 @@ def quote_string(value: Any) -> str: ... if sys.version_info >= (3, 7): rfc2047_matcher: Pattern[str] -class TokenList(List[Union[TokenList, Terminal]]): - token_type: Optional[str] = ... +class TokenList(List[TokenList | Terminal]): + token_type: str | None = ... syntactic_break: bool = ... ew_combine_allowed: bool = ... defects: List[MessageDefect] = ... @@ -69,9 +69,9 @@ class Token(TokenList): class EncodedWord(TokenList): token_type: str = ... - cte: Optional[str] = ... - charset: Optional[str] = ... - lang: Optional[str] = ... + cte: str | None = ... + charset: str | None = ... + lang: str | None = ... class QuotedString(TokenList): token_type: str = ... @@ -145,7 +145,7 @@ class NameAddr(TokenList): @property def domain(self) -> str: ... @property - def route(self) -> Optional[List[Domain]]: ... + def route(self) -> List[Domain] | None: ... @property def addr_spec(self) -> str: ... @@ -156,7 +156,7 @@ class AngleAddr(TokenList): @property def domain(self) -> str: ... @property - def route(self) -> Optional[List[Domain]]: ... + def route(self) -> List[Domain] | None: ... @property def addr_spec(self) -> str: ... @@ -247,8 +247,8 @@ class DomainLiteral(TokenList): class MIMEVersion(TokenList): token_type: str = ... - major: Optional[int] = ... - minor: Optional[int] = ... + major: int | None = ... + minor: int | None = ... class Parameter(TokenList): token_type: str = ... @@ -270,7 +270,7 @@ class Attribute(TokenList): class Section(TokenList): token_type: str = ... - number: Optional[int] = ... + number: int | None = ... class Value(TokenList): token_type: str = ... diff --git a/stdlib/email/charset.pyi b/stdlib/email/charset.pyi index 7c8e8ae711b9..505318f36111 100644 --- a/stdlib/email/charset.pyi +++ b/stdlib/email/charset.pyi @@ -8,12 +8,12 @@ class Charset: input_charset: str header_encoding: int body_encoding: int - output_charset: Optional[str] - input_codec: Optional[str] - output_codec: Optional[str] + output_charset: str | None + input_codec: str | None + output_codec: str | None def __init__(self, input_charset: str = ...) -> None: ... def get_body_encoding(self) -> str: ... - def get_output_charset(self) -> Optional[str]: ... + def get_output_charset(self) -> str | None: ... def header_encode(self, string: str) -> str: ... def header_encode_lines(self, string: str, maxlengths: Iterator[int]) -> List[str]: ... def body_encode(self, string: str) -> str: ... @@ -22,7 +22,7 @@ class Charset: def __ne__(self, other: Any) -> bool: ... def add_charset( - charset: str, header_enc: Optional[int] = ..., body_enc: Optional[int] = ..., output_charset: Optional[str] = ... + charset: str, header_enc: int | None = ..., body_enc: int | None = ..., output_charset: str | None = ... ) -> None: ... def add_alias(alias: str, canonical: str) -> None: ... def add_codec(charset: str, codecname: str) -> None: ... diff --git a/stdlib/email/errors.pyi b/stdlib/email/errors.pyi index 64ad41407857..c137cbf02135 100644 --- a/stdlib/email/errors.pyi +++ b/stdlib/email/errors.pyi @@ -9,7 +9,7 @@ class MultipartConversionError(MessageError, TypeError): ... class CharsetError(MessageError): ... class MessageDefect(ValueError): - def __init__(self, line: Optional[str] = ...) -> None: ... + def __init__(self, line: str | None = ...) -> None: ... class NoBoundaryInMultipartDefect(MessageDefect): ... class StartBoundaryNotFoundDefect(MessageDefect): ... @@ -31,7 +31,7 @@ class InvalidHeaderDefect(HeaderDefect): ... class HeaderMissingRequiredValue(HeaderDefect): ... class NonPrintableDefect(HeaderDefect): - def __init__(self, non_printables: Optional[str]) -> None: ... + def __init__(self, non_printables: str | None) -> None: ... class ObsoleteHeaderDefect(HeaderDefect): ... class NonASCIILocalPartDefect(HeaderDefect): ... diff --git a/stdlib/email/generator.pyi b/stdlib/email/generator.pyi index 522f74f31a43..cd0b2285a954 100644 --- a/stdlib/email/generator.pyi +++ b/stdlib/email/generator.pyi @@ -8,12 +8,12 @@ class Generator: def __init__( self, outfp: TextIO, - mangle_from_: Optional[bool] = ..., - maxheaderlen: Optional[int] = ..., + mangle_from_: bool | None = ..., + maxheaderlen: int | None = ..., *, - policy: Optional[Policy] = ..., + policy: Policy | None = ..., ) -> None: ... - def flatten(self, msg: Message, unixfrom: bool = ..., linesep: Optional[str] = ...) -> None: ... + def flatten(self, msg: Message, unixfrom: bool = ..., linesep: str | None = ...) -> None: ... class BytesGenerator: def clone(self, fp: BinaryIO) -> BytesGenerator: ... @@ -21,20 +21,20 @@ class BytesGenerator: def __init__( self, outfp: BinaryIO, - mangle_from_: Optional[bool] = ..., - maxheaderlen: Optional[int] = ..., + mangle_from_: bool | None = ..., + maxheaderlen: int | None = ..., *, - policy: Optional[Policy] = ..., + policy: Policy | None = ..., ) -> None: ... - def flatten(self, msg: Message, unixfrom: bool = ..., linesep: Optional[str] = ...) -> None: ... + def flatten(self, msg: Message, unixfrom: bool = ..., linesep: str | None = ...) -> None: ... class DecodedGenerator(Generator): def __init__( self, outfp: TextIO, - mangle_from_: Optional[bool] = ..., - maxheaderlen: Optional[int] = ..., - fmt: Optional[str] = ..., + mangle_from_: bool | None = ..., + maxheaderlen: int | None = ..., + fmt: str | None = ..., *, - policy: Optional[Policy] = ..., + policy: Policy | None = ..., ) -> None: ... diff --git a/stdlib/email/header.pyi b/stdlib/email/header.pyi index 1a5e1a2e4853..5591b370894e 100644 --- a/stdlib/email/header.pyi +++ b/stdlib/email/header.pyi @@ -4,23 +4,23 @@ from typing import Any, List, Optional, Tuple, Union class Header: def __init__( self, - s: Union[bytes, str, None] = ..., - charset: Union[Charset, str, None] = ..., - maxlinelen: Optional[int] = ..., - header_name: Optional[str] = ..., + s: bytes | str | None = ..., + charset: Charset | str | None = ..., + maxlinelen: int | None = ..., + header_name: str | None = ..., continuation_ws: str = ..., errors: str = ..., ) -> None: ... - def append(self, s: Union[bytes, str], charset: Union[Charset, str, None] = ..., errors: str = ...) -> None: ... - def encode(self, splitchars: str = ..., maxlinelen: Optional[int] = ..., linesep: str = ...) -> str: ... + def append(self, s: bytes | str, charset: Charset | str | None = ..., errors: str = ...) -> None: ... + def encode(self, splitchars: str = ..., maxlinelen: int | None = ..., linesep: str = ...) -> str: ... def __str__(self) -> str: ... def __eq__(self, other: Any) -> bool: ... def __ne__(self, other: Any) -> bool: ... -def decode_header(header: Union[Header, str]) -> List[Tuple[bytes, Optional[str]]]: ... +def decode_header(header: Header | str) -> List[Tuple[bytes, str | None]]: ... def make_header( - decoded_seq: List[Tuple[bytes, Optional[str]]], - maxlinelen: Optional[int] = ..., - header_name: Optional[str] = ..., + decoded_seq: List[Tuple[bytes, str | None]], + maxlinelen: int | None = ..., + header_name: str | None = ..., continuation_ws: str = ..., ) -> Header: ... diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index b661496b9b62..3f4804a61d5f 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -19,7 +19,7 @@ class BaseHeader(str): @property def defects(self) -> Tuple[MessageDefect, ...]: ... @property - def max_count(self) -> Optional[int]: ... + def max_count(self) -> int | None: ... def __new__(cls, name: str, value: Any) -> BaseHeader: ... def init(self, name: str, *, parse_tree: TokenList, defects: Iterable[MessageDefect]) -> None: ... def fold(self, *, policy: Policy) -> str: ... @@ -38,7 +38,7 @@ class DateHeader: @staticmethod def value_parser(value: str) -> UnstructuredTokenList: ... @classmethod - def parse(cls, value: Union[str, _datetime], kwds: Dict[str, Any]) -> None: ... + def parse(cls, value: str | _datetime, kwds: Dict[str, Any]) -> None: ... class UniqueDateHeader(DateHeader): ... @@ -62,11 +62,11 @@ class UniqueSingleAddressHeader(SingleAddressHeader): ... class MIMEVersionHeader: @property - def version(self) -> Optional[str]: ... + def version(self) -> str | None: ... @property - def major(self) -> Optional[int]: ... + def major(self) -> int | None: ... @property - def minor(self) -> Optional[int]: ... + def minor(self) -> int | None: ... @staticmethod def value_parser(value: str) -> MIMEVersion: ... @classmethod @@ -128,14 +128,14 @@ class Address: @property def addr_spec(self) -> str: ... def __init__( - self, display_name: str = ..., username: Optional[str] = ..., domain: Optional[str] = ..., addr_spec: Optional[str] = ... + self, display_name: str = ..., username: str | None = ..., domain: str | None = ..., addr_spec: str | None = ... ) -> None: ... def __str__(self) -> str: ... class Group: @property - def display_name(self) -> Optional[str]: ... + def display_name(self) -> str | None: ... @property def addresses(self) -> Tuple[Address, ...]: ... - def __init__(self, display_name: Optional[str] = ..., addresses: Optional[Iterable[Address]] = ...) -> None: ... + def __init__(self, display_name: str | None = ..., addresses: Iterable[Address] | None = ...) -> None: ... def __str__(self) -> str: ... diff --git a/stdlib/email/iterators.pyi b/stdlib/email/iterators.pyi index 2b3d14c2ebeb..817a3aea7c58 100644 --- a/stdlib/email/iterators.pyi +++ b/stdlib/email/iterators.pyi @@ -2,4 +2,4 @@ from email.message import Message from typing import Iterator, Optional def body_line_iterator(msg: Message, decode: bool = ...) -> Iterator[str]: ... -def typed_subpart_iterator(msg: Message, maintype: str = ..., subtype: Optional[str] = ...) -> Iterator[str]: ... +def typed_subpart_iterator(msg: Message, maintype: str = ..., subtype: str | None = ...) -> Iterator[str]: ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index 37c9caffa916..b08ccd78cc2d 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -14,15 +14,15 @@ _HeaderType = Any class Message: policy: Policy # undocumented - preamble: Optional[str] - epilogue: Optional[str] + preamble: str | None + epilogue: str | None defects: List[MessageDefect] def __str__(self) -> str: ... def is_multipart(self) -> bool: ... def set_unixfrom(self, unixfrom: str) -> None: ... - def get_unixfrom(self) -> Optional[str]: ... + def get_unixfrom(self) -> str | None: ... def attach(self, payload: Message) -> None: ... - def get_payload(self, i: Optional[int] = ..., decode: bool = ...) -> Any: ... # returns Optional[_PayloadType] + def get_payload(self, i: int | None = ..., decode: bool = ...) -> Any: ... # returns _PayloadType | None def set_payload(self, payload: _PayloadType, charset: _CharsetType = ...) -> None: ... def set_charset(self, charset: _CharsetType) -> None: ... def get_charset(self) -> _CharsetType: ... @@ -34,8 +34,8 @@ class Message: def keys(self) -> List[str]: ... def values(self) -> List[_HeaderType]: ... def items(self) -> List[Tuple[str, _HeaderType]]: ... - def get(self, name: str, failobj: _T = ...) -> Union[_HeaderType, _T]: ... - def get_all(self, name: str, failobj: _T = ...) -> Union[List[_HeaderType], _T]: ... + def get(self, name: str, failobj: _T = ...) -> _HeaderType | _T: ... + def get_all(self, name: str, failobj: _T = ...) -> List[_HeaderType] | _T: ... def add_header(self, _name: str, _value: str, **_params: _ParamsType) -> None: ... def replace_header(self, _name: str, _value: _HeaderType) -> None: ... def get_content_type(self) -> str: ... @@ -43,19 +43,19 @@ class Message: def get_content_subtype(self) -> str: ... def get_default_type(self) -> str: ... def set_default_type(self, ctype: str) -> None: ... - def get_params(self, failobj: _T = ..., header: str = ..., unquote: bool = ...) -> Union[List[Tuple[str, str]], _T]: ... - def get_param(self, param: str, failobj: _T = ..., header: str = ..., unquote: bool = ...) -> Union[_T, _ParamType]: ... + def get_params(self, failobj: _T = ..., header: str = ..., unquote: bool = ...) -> List[Tuple[str, str]] | _T: ... + def get_param(self, param: str, failobj: _T = ..., header: str = ..., unquote: bool = ...) -> _T | _ParamType: ... def del_param(self, param: str, header: str = ..., requote: bool = ...) -> None: ... def set_type(self, type: str, header: str = ..., requote: bool = ...) -> None: ... - def get_filename(self, failobj: _T = ...) -> Union[_T, str]: ... - def get_boundary(self, failobj: _T = ...) -> Union[_T, str]: ... + def get_filename(self, failobj: _T = ...) -> _T | str: ... + def get_boundary(self, failobj: _T = ...) -> _T | str: ... def set_boundary(self, boundary: str) -> None: ... - def get_content_charset(self, failobj: _T = ...) -> Union[_T, str]: ... - def get_charsets(self, failobj: _T = ...) -> Union[_T, List[str]]: ... + def get_content_charset(self, failobj: _T = ...) -> _T | str: ... + def get_charsets(self, failobj: _T = ...) -> _T | List[str]: ... def walk(self) -> Generator[Message, None, None]: ... - def get_content_disposition(self) -> Optional[str]: ... - def as_string(self, unixfrom: bool = ..., maxheaderlen: int = ..., policy: Optional[Policy] = ...) -> str: ... - def as_bytes(self, unixfrom: bool = ..., policy: Optional[Policy] = ...) -> bytes: ... + def get_content_disposition(self) -> str | None: ... + def as_string(self, unixfrom: bool = ..., maxheaderlen: int = ..., policy: Policy | None = ...) -> str: ... + def as_bytes(self, unixfrom: bool = ..., policy: Policy | None = ...) -> bytes: ... def __bytes__(self) -> bytes: ... def set_param( self, @@ -63,28 +63,28 @@ class Message: value: str, header: str = ..., requote: bool = ..., - charset: Optional[str] = ..., + charset: str | None = ..., language: str = ..., replace: bool = ..., ) -> None: ... def __init__(self, policy: Policy = ...) -> None: ... class MIMEPart(Message): - def __init__(self, policy: Optional[Policy] = ...) -> None: ... - def get_body(self, preferencelist: Sequence[str] = ...) -> Optional[Message]: ... + def __init__(self, policy: Policy | None = ...) -> None: ... + def get_body(self, preferencelist: Sequence[str] = ...) -> Message | None: ... def iter_attachments(self) -> Iterator[Message]: ... def iter_parts(self) -> Iterator[Message]: ... - def get_content(self, *args: Any, content_manager: Optional[ContentManager] = ..., **kw: Any) -> Any: ... - def set_content(self, *args: Any, content_manager: Optional[ContentManager] = ..., **kw: Any) -> None: ... - def make_related(self, boundary: Optional[str] = ...) -> None: ... - def make_alternative(self, boundary: Optional[str] = ...) -> None: ... - def make_mixed(self, boundary: Optional[str] = ...) -> None: ... - def add_related(self, *args: Any, content_manager: Optional[ContentManager] = ..., **kw: Any) -> None: ... - def add_alternative(self, *args: Any, content_manager: Optional[ContentManager] = ..., **kw: Any) -> None: ... - def add_attachment(self, *args: Any, content_manager: Optional[ContentManager] = ..., **kw: Any) -> None: ... + def get_content(self, *args: Any, content_manager: ContentManager | None = ..., **kw: Any) -> Any: ... + def set_content(self, *args: Any, content_manager: ContentManager | None = ..., **kw: Any) -> None: ... + def make_related(self, boundary: str | None = ...) -> None: ... + def make_alternative(self, boundary: str | None = ...) -> None: ... + def make_mixed(self, boundary: str | None = ...) -> None: ... + def add_related(self, *args: Any, content_manager: ContentManager | None = ..., **kw: Any) -> None: ... + def add_alternative(self, *args: Any, content_manager: ContentManager | None = ..., **kw: Any) -> None: ... + def add_attachment(self, *args: Any, content_manager: ContentManager | None = ..., **kw: Any) -> None: ... def clear(self) -> None: ... def clear_content(self) -> None: ... - def as_string(self, unixfrom: bool = ..., maxheaderlen: Optional[int] = ..., policy: Optional[Policy] = ...) -> str: ... + def as_string(self, unixfrom: bool = ..., maxheaderlen: int | None = ..., policy: Policy | None = ...) -> str: ... def is_attachment(self) -> bool: ... class EmailMessage(MIMEPart): ... diff --git a/stdlib/email/mime/application.pyi b/stdlib/email/mime/application.pyi index d1b2f1dad6b4..11fc470e9dd1 100644 --- a/stdlib/email/mime/application.pyi +++ b/stdlib/email/mime/application.pyi @@ -7,10 +7,10 @@ _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEApplication(MIMENonMultipart): def __init__( self, - _data: Union[str, bytes], + _data: str | bytes, _subtype: str = ..., _encoder: Callable[[MIMEApplication], None] = ..., *, - policy: Optional[Policy] = ..., + policy: Policy | None = ..., **_params: _ParamsType, ) -> None: ... diff --git a/stdlib/email/mime/audio.pyi b/stdlib/email/mime/audio.pyi index 9bd5b5ca57b0..ee6de410bf53 100644 --- a/stdlib/email/mime/audio.pyi +++ b/stdlib/email/mime/audio.pyi @@ -7,10 +7,10 @@ _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEAudio(MIMENonMultipart): def __init__( self, - _audiodata: Union[str, bytes], - _subtype: Optional[str] = ..., + _audiodata: str | bytes, + _subtype: str | None = ..., _encoder: Callable[[MIMEAudio], None] = ..., *, - policy: Optional[Policy] = ..., + policy: Policy | None = ..., **_params: _ParamsType, ) -> None: ... diff --git a/stdlib/email/mime/base.pyi b/stdlib/email/mime/base.pyi index 1e3223315e88..b88dfd492554 100644 --- a/stdlib/email/mime/base.pyi +++ b/stdlib/email/mime/base.pyi @@ -5,4 +5,4 @@ from typing import Optional, Tuple, Union _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEBase(email.message.Message): - def __init__(self, _maintype: str, _subtype: str, *, policy: Optional[Policy] = ..., **_params: _ParamsType) -> None: ... + def __init__(self, _maintype: str, _subtype: str, *, policy: Policy | None = ..., **_params: _ParamsType) -> None: ... diff --git a/stdlib/email/mime/image.pyi b/stdlib/email/mime/image.pyi index f192494ec74c..886aa74d5fe5 100644 --- a/stdlib/email/mime/image.pyi +++ b/stdlib/email/mime/image.pyi @@ -7,10 +7,10 @@ _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEImage(MIMENonMultipart): def __init__( self, - _imagedata: Union[str, bytes], - _subtype: Optional[str] = ..., + _imagedata: str | bytes, + _subtype: str | None = ..., _encoder: Callable[[MIMEImage], None] = ..., *, - policy: Optional[Policy] = ..., + policy: Policy | None = ..., **_params: _ParamsType, ) -> None: ... diff --git a/stdlib/email/mime/message.pyi b/stdlib/email/mime/message.pyi index d2ce81818a24..17b9ee8a3ab6 100644 --- a/stdlib/email/mime/message.pyi +++ b/stdlib/email/mime/message.pyi @@ -4,4 +4,4 @@ from email.policy import Policy from typing import Optional class MIMEMessage(MIMENonMultipart): - def __init__(self, _msg: Message, _subtype: str = ..., *, policy: Optional[Policy] = ...) -> None: ... + def __init__(self, _msg: Message, _subtype: str = ..., *, policy: Policy | None = ...) -> None: ... diff --git a/stdlib/email/mime/multipart.pyi b/stdlib/email/mime/multipart.pyi index eb5f662de058..6259ddf5ab8f 100644 --- a/stdlib/email/mime/multipart.pyi +++ b/stdlib/email/mime/multipart.pyi @@ -9,9 +9,9 @@ class MIMEMultipart(MIMEBase): def __init__( self, _subtype: str = ..., - boundary: Optional[str] = ..., - _subparts: Optional[Sequence[Message]] = ..., + boundary: str | None = ..., + _subparts: Sequence[Message] | None = ..., *, - policy: Optional[Policy] = ..., + policy: Policy | None = ..., **_params: _ParamsType, ) -> None: ... diff --git a/stdlib/email/mime/text.pyi b/stdlib/email/mime/text.pyi index aa5590ebb60f..716010b9a6fa 100644 --- a/stdlib/email/mime/text.pyi +++ b/stdlib/email/mime/text.pyi @@ -4,5 +4,5 @@ from typing import Optional class MIMEText(MIMENonMultipart): def __init__( - self, _text: str, _subtype: str = ..., _charset: Optional[str] = ..., *, policy: Optional[Policy] = ... + self, _text: str, _subtype: str = ..., _charset: str | None = ..., *, policy: Policy | None = ... ) -> None: ... diff --git a/stdlib/email/parser.pyi b/stdlib/email/parser.pyi index d081540a9d81..1978b7944394 100644 --- a/stdlib/email/parser.pyi +++ b/stdlib/email/parser.pyi @@ -7,12 +7,12 @@ FeedParser = email.feedparser.FeedParser BytesFeedParser = email.feedparser.BytesFeedParser class Parser: - def __init__(self, _class: Optional[Callable[[], Message]] = ..., *, policy: Policy = ...) -> None: ... + def __init__(self, _class: Callable[[], Message] | None = ..., *, policy: Policy = ...) -> None: ... def parse(self, fp: TextIO, headersonly: bool = ...) -> Message: ... def parsestr(self, text: str, headersonly: bool = ...) -> Message: ... class HeaderParser(Parser): - def __init__(self, _class: Optional[Callable[[], Message]] = ..., *, policy: Policy = ...) -> None: ... + def __init__(self, _class: Callable[[], Message] | None = ..., *, policy: Policy = ...) -> None: ... def parse(self, fp: TextIO, headersonly: bool = ...) -> Message: ... def parsestr(self, text: str, headersonly: bool = ...) -> Message: ... diff --git a/stdlib/email/policy.pyi b/stdlib/email/policy.pyi index d0906ebf1cf5..d6284e919fd6 100644 --- a/stdlib/email/policy.pyi +++ b/stdlib/email/policy.pyi @@ -6,7 +6,7 @@ from email.message import Message from typing import Any, Callable, List, Optional, Tuple, Union class Policy: - max_line_length: Optional[int] + max_line_length: int | None linesep: str cte_type: str raise_on_defect: bool @@ -15,7 +15,7 @@ class Policy: def clone(self, **kw: Any) -> Policy: ... def handle_defect(self, obj: Message, defect: MessageDefect) -> None: ... def register_defect(self, obj: Message, defect: MessageDefect) -> None: ... - def header_max_count(self, name: str) -> Optional[int]: ... + def header_max_count(self, name: str) -> int | None: ... @abstractmethod def header_source_parse(self, sourcelines: List[str]) -> Tuple[str, str]: ... @abstractmethod @@ -30,7 +30,7 @@ class Policy: class Compat32(Policy): def header_source_parse(self, sourcelines: List[str]) -> Tuple[str, str]: ... def header_store_parse(self, name: str, value: str) -> Tuple[str, str]: ... - def header_fetch_parse(self, name: str, value: str) -> Union[str, Header]: ... # type: ignore + def header_fetch_parse(self, name: str, value: str) -> str | Header: ... # type: ignore def fold(self, name: str, value: str) -> str: ... def fold_binary(self, name: str, value: str) -> bytes: ... diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index 3a39d4fcfd02..4230e6062d5c 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -8,17 +8,17 @@ _PDTZ = Tuple[int, int, int, int, int, int, int, int, int, Optional[int]] def quote(str: str) -> str: ... def unquote(str: str) -> str: ... -def parseaddr(addr: Optional[str]) -> Tuple[str, str]: ... -def formataddr(pair: Tuple[Optional[str], str], charset: Union[str, Charset] = ...) -> str: ... +def parseaddr(addr: str | None) -> Tuple[str, str]: ... +def formataddr(pair: Tuple[str | None, str], charset: str | Charset = ...) -> str: ... def getaddresses(fieldvalues: List[str]) -> List[Tuple[str, str]]: ... @overload def parsedate(data: None) -> None: ... @overload -def parsedate(data: str) -> Optional[Tuple[int, int, int, int, int, int, int, int, int]]: ... +def parsedate(data: str) -> Tuple[int, int, int, int, int, int, int, int, int] | None: ... @overload def parsedate_tz(data: None) -> None: ... @overload -def parsedate_tz(data: str) -> Optional[_PDTZ]: ... +def parsedate_tz(data: str) -> _PDTZ | None: ... if sys.version_info >= (3, 10): @overload @@ -30,11 +30,11 @@ else: def parsedate_to_datetime(data: str) -> datetime.datetime: ... def mktime_tz(data: _PDTZ) -> int: ... -def formatdate(timeval: Optional[float] = ..., localtime: bool = ..., usegmt: bool = ...) -> str: ... +def formatdate(timeval: float | None = ..., localtime: bool = ..., usegmt: bool = ...) -> str: ... def format_datetime(dt: datetime.datetime, usegmt: bool = ...) -> str: ... -def localtime(dt: Optional[datetime.datetime] = ..., isdst: int = ...) -> datetime.datetime: ... -def make_msgid(idstring: Optional[str] = ..., domain: Optional[str] = ...) -> str: ... -def decode_rfc2231(s: str) -> Tuple[Optional[str], Optional[str], str]: ... -def encode_rfc2231(s: str, charset: Optional[str] = ..., language: Optional[str] = ...) -> str: ... +def localtime(dt: datetime.datetime | None = ..., isdst: int = ...) -> datetime.datetime: ... +def make_msgid(idstring: str | None = ..., domain: str | None = ...) -> str: ... +def decode_rfc2231(s: str) -> Tuple[str | None, str | None, str]: ... +def encode_rfc2231(s: str, charset: str | None = ..., language: str | None = ...) -> str: ... def collapse_rfc2231_value(value: _ParamType, errors: str = ..., fallback_charset: str = ...) -> str: ... def decode_params(params: List[Tuple[str, str]]) -> List[Tuple[str, _ParamType]]: ... diff --git a/stdlib/encodings/__init__.pyi b/stdlib/encodings/__init__.pyi index 951a53f1c786..dd3cf28e2772 100644 --- a/stdlib/encodings/__init__.pyi +++ b/stdlib/encodings/__init__.pyi @@ -3,8 +3,8 @@ from typing import Any, Optional, Union class CodecRegistryError(LookupError, SystemError): ... -def normalize_encoding(encoding: Union[str, bytes]) -> str: ... -def search_function(encoding: str) -> Optional[CodecInfo]: ... +def normalize_encoding(encoding: str | bytes) -> str: ... +def search_function(encoding: str) -> CodecInfo | None: ... # Needed for submodules def __getattr__(name: str) -> Any: ... # incomplete diff --git a/stdlib/encodings/utf_8.pyi b/stdlib/encodings/utf_8.pyi index 96a156c792b6..416e90caa239 100644 --- a/stdlib/encodings/utf_8.pyi +++ b/stdlib/encodings/utf_8.pyi @@ -6,16 +6,16 @@ class IncrementalEncoder(codecs.IncrementalEncoder): class IncrementalDecoder(codecs.BufferedIncrementalDecoder): @staticmethod - def _buffer_decode(__data: bytes, __errors: Optional[str] = ..., __final: bool = ...) -> Tuple[str, int]: ... + def _buffer_decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> Tuple[str, int]: ... class StreamWriter(codecs.StreamWriter): @staticmethod - def encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... + def encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... class StreamReader(codecs.StreamReader): @staticmethod - def decode(__data: bytes, __errors: Optional[str] = ..., __final: bool = ...) -> Tuple[str, int]: ... + def decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> Tuple[str, int]: ... def getregentry() -> codecs.CodecInfo: ... -def encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def decode(input: bytes, errors: Optional[str] = ...) -> Tuple[str, int]: ... +def encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... +def decode(input: bytes, errors: str | None = ...) -> Tuple[str, int]: ... diff --git a/stdlib/ensurepip/__init__.pyi b/stdlib/ensurepip/__init__.pyi index 2b0d602c37db..bed46578fbb3 100644 --- a/stdlib/ensurepip/__init__.pyi +++ b/stdlib/ensurepip/__init__.pyi @@ -3,7 +3,7 @@ from typing import Optional def version() -> str: ... def bootstrap( *, - root: Optional[str] = ..., + root: str | None = ..., upgrade: bool = ..., user: bool = ..., altinstall: bool = ..., diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index 64bd74d813c9..da1c23bc286e 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -29,7 +29,7 @@ class Enum(metaclass=EnumMeta): _member_map_: Dict[str, Enum] # undocumented _value2member_map_: Dict[int, Enum] # undocumented if sys.version_info >= (3, 7): - _ignore_: Union[str, List[str]] + _ignore_: str | List[str] _order_: str __order__: str @classmethod @@ -46,7 +46,7 @@ class Enum(metaclass=EnumMeta): class IntEnum(int, Enum): value: int - def __new__(cls: Type[_T], value: Union[int, _T]) -> _T: ... + def __new__(cls: Type[_T], value: int | _T) -> _T: ... def unique(enumeration: _S) -> _S: ... @@ -70,17 +70,17 @@ class Flag(Enum): def __invert__(self: _T) -> _T: ... class IntFlag(int, Flag): - def __new__(cls: Type[_T], value: Union[int, _T]) -> _T: ... - def __or__(self: _T, other: Union[int, _T]) -> _T: ... - def __and__(self: _T, other: Union[int, _T]) -> _T: ... - def __xor__(self: _T, other: Union[int, _T]) -> _T: ... + def __new__(cls: Type[_T], value: int | _T) -> _T: ... + def __or__(self: _T, other: int | _T) -> _T: ... + def __and__(self: _T, other: int | _T) -> _T: ... + def __xor__(self: _T, other: int | _T) -> _T: ... __ror__ = __or__ __rand__ = __and__ __rxor__ = __xor__ if sys.version_info >= (3, 11): class StrEnum(str, Enum): - def __new__(cls: Type[_T], value: Union[int, _T]) -> _T: ... + def __new__(cls: Type[_T], value: int | _T) -> _T: ... class FlagBoundary(StrEnum): STRICT: str CONFORM: str diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index b3f20eb6b266..5438d0d5e47d 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -8,21 +8,21 @@ if sys.version_info >= (3, 9): DEFAULT_IGNORES: List[str] -def cmp(f1: StrOrBytesPath, f2: StrOrBytesPath, shallow: Union[int, bool] = ...) -> bool: ... +def cmp(f1: StrOrBytesPath, f2: StrOrBytesPath, shallow: int | bool = ...) -> bool: ... def cmpfiles( - a: Union[AnyStr, PathLike[AnyStr]], - b: Union[AnyStr, PathLike[AnyStr]], + a: AnyStr | PathLike[AnyStr], + b: AnyStr | PathLike[AnyStr], common: Iterable[AnyStr], - shallow: Union[int, bool] = ..., + shallow: int | bool = ..., ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... class dircmp(Generic[AnyStr]): def __init__( self, - a: Union[AnyStr, PathLike[AnyStr]], - b: Union[AnyStr, PathLike[AnyStr]], - ignore: Optional[Sequence[AnyStr]] = ..., - hide: Optional[Sequence[AnyStr]] = ..., + a: AnyStr | PathLike[AnyStr], + b: AnyStr | PathLike[AnyStr], + ignore: Sequence[AnyStr] | None = ..., + hide: Sequence[AnyStr] | None = ..., ) -> None: ... left: AnyStr right: AnyStr diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index 175e0b2693ca..bf88c7861bef 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -7,7 +7,7 @@ if sys.version_info >= (3, 9): if sys.version_info >= (3, 10): def input( - files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ..., + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ..., inplace: bool = ..., backup: str = ..., *, @@ -19,7 +19,7 @@ if sys.version_info >= (3, 10): elif sys.version_info >= (3, 8): def input( - files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ..., + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ..., inplace: bool = ..., backup: str = ..., *, @@ -29,7 +29,7 @@ elif sys.version_info >= (3, 8): else: def input( - files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ..., + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ..., inplace: bool = ..., backup: str = ..., bufsize: int = ..., @@ -50,7 +50,7 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): if sys.version_info >= (3, 10): def __init__( self, - files: Union[None, StrOrBytesPath, Iterable[StrOrBytesPath]] = ..., + files: None | StrOrBytesPath | Iterable[StrOrBytesPath] = ..., inplace: bool = ..., backup: str = ..., *, @@ -62,7 +62,7 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): elif sys.version_info >= (3, 8): def __init__( self, - files: Union[None, StrOrBytesPath, Iterable[StrOrBytesPath]] = ..., + files: None | StrOrBytesPath | Iterable[StrOrBytesPath] = ..., inplace: bool = ..., backup: str = ..., *, @@ -72,7 +72,7 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): else: def __init__( self, - files: Union[None, StrOrBytesPath, Iterable[StrOrBytesPath]] = ..., + files: None | StrOrBytesPath | Iterable[StrOrBytesPath] = ..., inplace: bool = ..., backup: str = ..., bufsize: int = ..., diff --git a/stdlib/formatter.pyi b/stdlib/formatter.pyi index 31c45592a215..f57d86c1022b 100644 --- a/stdlib/formatter.pyi +++ b/stdlib/formatter.pyi @@ -5,33 +5,33 @@ _FontType = Tuple[str, bool, bool, bool] _StylesType = Tuple[Any, ...] class NullFormatter: - writer: Optional[NullWriter] - def __init__(self, writer: Optional[NullWriter] = ...) -> None: ... + writer: NullWriter | None + def __init__(self, writer: NullWriter | None = ...) -> None: ... def end_paragraph(self, blankline: int) -> None: ... def add_line_break(self) -> None: ... def add_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def add_label_data(self, format: str, counter: int, blankline: Optional[int] = ...) -> None: ... + def add_label_data(self, format: str, counter: int, blankline: int | None = ...) -> None: ... def add_flowing_data(self, data: str) -> None: ... def add_literal_data(self, data: str) -> None: ... def flush_softspace(self) -> None: ... - def push_alignment(self, align: Optional[str]) -> None: ... + def push_alignment(self, align: str | None) -> None: ... def pop_alignment(self) -> None: ... def push_font(self, x: _FontType) -> None: ... def pop_font(self) -> None: ... def push_margin(self, margin: int) -> None: ... def pop_margin(self) -> None: ... - def set_spacing(self, spacing: Optional[str]) -> None: ... + def set_spacing(self, spacing: str | None) -> None: ... def push_style(self, *styles: _StylesType) -> None: ... def pop_style(self, n: int = ...) -> None: ... def assert_line_data(self, flag: int = ...) -> None: ... class AbstractFormatter: writer: NullWriter - align: Optional[str] - align_stack: List[Optional[str]] + align: str | None + align_stack: List[str | None] font_stack: List[_FontType] margin_stack: List[int] - spacing: Optional[str] + spacing: str | None style_stack: Any nospace: int softspace: int @@ -43,20 +43,20 @@ class AbstractFormatter: def end_paragraph(self, blankline: int) -> None: ... def add_line_break(self) -> None: ... def add_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def add_label_data(self, format: str, counter: int, blankline: Optional[int] = ...) -> None: ... + def add_label_data(self, format: str, counter: int, blankline: int | None = ...) -> None: ... def format_counter(self, format: Iterable[str], counter: int) -> str: ... def format_letter(self, case: str, counter: int) -> str: ... def format_roman(self, case: str, counter: int) -> str: ... def add_flowing_data(self, data: str) -> None: ... def add_literal_data(self, data: str) -> None: ... def flush_softspace(self) -> None: ... - def push_alignment(self, align: Optional[str]) -> None: ... + def push_alignment(self, align: str | None) -> None: ... def pop_alignment(self) -> None: ... def push_font(self, font: _FontType) -> None: ... def pop_font(self) -> None: ... def push_margin(self, margin: int) -> None: ... def pop_margin(self) -> None: ... - def set_spacing(self, spacing: Optional[str]) -> None: ... + def set_spacing(self, spacing: str | None) -> None: ... def push_style(self, *styles: _StylesType) -> None: ... def pop_style(self, n: int = ...) -> None: ... def assert_line_data(self, flag: int = ...) -> None: ... @@ -64,10 +64,10 @@ class AbstractFormatter: class NullWriter: def __init__(self) -> None: ... def flush(self) -> None: ... - def new_alignment(self, align: Optional[str]) -> None: ... + def new_alignment(self, align: str | None) -> None: ... def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... - def new_spacing(self, spacing: Optional[str]) -> None: ... + def new_spacing(self, spacing: str | None) -> None: ... def new_styles(self, styles: Tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... @@ -77,10 +77,10 @@ class NullWriter: def send_literal_data(self, data: str) -> None: ... class AbstractWriter(NullWriter): - def new_alignment(self, align: Optional[str]) -> None: ... + def new_alignment(self, align: str | None) -> None: ... def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... - def new_spacing(self, spacing: Optional[str]) -> None: ... + def new_spacing(self, spacing: str | None) -> None: ... def new_styles(self, styles: Tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... @@ -92,7 +92,7 @@ class AbstractWriter(NullWriter): class DumbWriter(NullWriter): file: IO[str] maxcol: int - def __init__(self, file: Optional[IO[str]] = ..., maxcol: int = ...) -> None: ... + def __init__(self, file: IO[str] | None = ..., maxcol: int = ...) -> None: ... def reset(self) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... @@ -100,4 +100,4 @@ class DumbWriter(NullWriter): def send_literal_data(self, data: str) -> None: ... def send_flowing_data(self, data: str) -> None: ... -def test(file: Optional[str] = ...) -> None: ... +def test(file: str | None = ...) -> None: ... diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index a59683c6b39f..ff5671e6f944 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -21,13 +21,13 @@ class Fraction(Rational): @overload def __new__( cls: Type[_T], - numerator: Union[int, Rational] = ..., - denominator: Optional[Union[int, Rational]] = ..., + numerator: int | Rational = ..., + denominator: int | Rational | None = ..., *, _normalize: bool = ..., ) -> _T: ... @overload - def __new__(cls: Type[_T], __value: Union[float, Decimal, str], *, _normalize: bool = ...) -> _T: ... + def __new__(cls: Type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ... @classmethod def from_float(cls, f: float) -> Fraction: ... @classmethod @@ -40,85 +40,85 @@ class Fraction(Rational): @property def denominator(self) -> int: ... @overload - def __add__(self, other: Union[int, Fraction]) -> Fraction: ... + def __add__(self, other: int | Fraction) -> Fraction: ... @overload def __add__(self, other: float) -> float: ... @overload def __add__(self, other: complex) -> complex: ... @overload - def __radd__(self, other: Union[int, Fraction]) -> Fraction: ... + def __radd__(self, other: int | Fraction) -> Fraction: ... @overload def __radd__(self, other: float) -> float: ... @overload def __radd__(self, other: complex) -> complex: ... @overload - def __sub__(self, other: Union[int, Fraction]) -> Fraction: ... + def __sub__(self, other: int | Fraction) -> Fraction: ... @overload def __sub__(self, other: float) -> float: ... @overload def __sub__(self, other: complex) -> complex: ... @overload - def __rsub__(self, other: Union[int, Fraction]) -> Fraction: ... + def __rsub__(self, other: int | Fraction) -> Fraction: ... @overload def __rsub__(self, other: float) -> float: ... @overload def __rsub__(self, other: complex) -> complex: ... @overload - def __mul__(self, other: Union[int, Fraction]) -> Fraction: ... + def __mul__(self, other: int | Fraction) -> Fraction: ... @overload def __mul__(self, other: float) -> float: ... @overload def __mul__(self, other: complex) -> complex: ... @overload - def __rmul__(self, other: Union[int, Fraction]) -> Fraction: ... + def __rmul__(self, other: int | Fraction) -> Fraction: ... @overload def __rmul__(self, other: float) -> float: ... @overload def __rmul__(self, other: complex) -> complex: ... @overload - def __truediv__(self, other: Union[int, Fraction]) -> Fraction: ... + def __truediv__(self, other: int | Fraction) -> Fraction: ... @overload def __truediv__(self, other: float) -> float: ... @overload def __truediv__(self, other: complex) -> complex: ... @overload - def __rtruediv__(self, other: Union[int, Fraction]) -> Fraction: ... + def __rtruediv__(self, other: int | Fraction) -> Fraction: ... @overload def __rtruediv__(self, other: float) -> float: ... @overload def __rtruediv__(self, other: complex) -> complex: ... @overload - def __floordiv__(self, other: Union[int, Fraction]) -> int: ... + def __floordiv__(self, other: int | Fraction) -> int: ... @overload def __floordiv__(self, other: float) -> float: ... @overload - def __rfloordiv__(self, other: Union[int, Fraction]) -> int: ... + def __rfloordiv__(self, other: int | Fraction) -> int: ... @overload def __rfloordiv__(self, other: float) -> float: ... @overload - def __mod__(self, other: Union[int, Fraction]) -> Fraction: ... + def __mod__(self, other: int | Fraction) -> Fraction: ... @overload def __mod__(self, other: float) -> float: ... @overload - def __rmod__(self, other: Union[int, Fraction]) -> Fraction: ... + def __rmod__(self, other: int | Fraction) -> Fraction: ... @overload def __rmod__(self, other: float) -> float: ... @overload - def __divmod__(self, other: Union[int, Fraction]) -> Tuple[int, Fraction]: ... + def __divmod__(self, other: int | Fraction) -> Tuple[int, Fraction]: ... @overload def __divmod__(self, other: float) -> Tuple[float, Fraction]: ... @overload - def __rdivmod__(self, other: Union[int, Fraction]) -> Tuple[int, Fraction]: ... + def __rdivmod__(self, other: int | Fraction) -> Tuple[int, Fraction]: ... @overload def __rdivmod__(self, other: float) -> Tuple[float, Fraction]: ... @overload def __pow__(self, other: int) -> Fraction: ... @overload - def __pow__(self, other: Union[float, Fraction]) -> float: ... + def __pow__(self, other: float | Fraction) -> float: ... @overload def __pow__(self, other: complex) -> complex: ... @overload - def __rpow__(self, other: Union[int, float, Fraction]) -> float: ... + def __rpow__(self, other: int | float | Fraction) -> float: ... @overload def __rpow__(self, other: complex) -> complex: ... def __pos__(self) -> Fraction: ... diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index ba2c458c4a46..cbc3c5a663cd 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -24,19 +24,19 @@ class FTP: host: str port: int maxline: int - sock: Optional[socket] - welcome: Optional[str] + sock: socket | None + welcome: str | None passiveserver: int timeout: int af: int lastresp: str - file: Optional[TextIO] + file: TextIO | None encoding: str def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... - source_address: Optional[Tuple[str, int]] + source_address: Tuple[str, int] | None def __init__( self, host: str = ..., @@ -44,15 +44,15 @@ class FTP: passwd: str = ..., acct: str = ..., timeout: float = ..., - source_address: Optional[Tuple[str, int]] = ..., + source_address: Tuple[str, int] | None = ..., ) -> None: ... def connect( - self, host: str = ..., port: int = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ... + self, host: str = ..., port: int = ..., timeout: float = ..., source_address: Tuple[str, int] | None = ... ) -> str: ... def getwelcome(self) -> str: ... def set_debuglevel(self, level: int) -> None: ... def debug(self, level: int) -> None: ... - def set_pasv(self, val: Union[bool, int]) -> None: ... + def set_pasv(self, val: bool | int) -> None: ... def sanitize(self, s: str) -> str: ... def putline(self, line: str) -> None: ... def putcmd(self, line: str) -> None: ... @@ -69,30 +69,30 @@ class FTP: def makepasv(self) -> Tuple[str, int]: ... def login(self, user: str = ..., passwd: str = ..., acct: str = ...) -> str: ... # In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers. - def ntransfercmd(self, cmd: str, rest: Optional[Union[int, str]] = ...) -> Tuple[socket, int]: ... - def transfercmd(self, cmd: str, rest: Optional[Union[int, str]] = ...) -> socket: ... + def ntransfercmd(self, cmd: str, rest: int | str | None = ...) -> Tuple[socket, int]: ... + def transfercmd(self, cmd: str, rest: int | str | None = ...) -> socket: ... def retrbinary( - self, cmd: str, callback: Callable[[bytes], Any], blocksize: int = ..., rest: Optional[Union[int, str]] = ... + self, cmd: str, callback: Callable[[bytes], Any], blocksize: int = ..., rest: int | str | None = ... ) -> str: ... def storbinary( self, cmd: str, fp: SupportsRead[bytes], blocksize: int = ..., - callback: Optional[Callable[[bytes], Any]] = ..., - rest: Optional[Union[int, str]] = ..., + callback: Callable[[bytes], Any] | None = ..., + rest: int | str | None = ..., ) -> str: ... - def retrlines(self, cmd: str, callback: Optional[Callable[[str], Any]] = ...) -> str: ... - def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Optional[Callable[[bytes], Any]] = ...) -> str: ... + def retrlines(self, cmd: str, callback: Callable[[str], Any] | None = ...) -> str: ... + def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Callable[[bytes], Any] | None = ...) -> str: ... def acct(self, password: str) -> str: ... def nlst(self, *args: str) -> List[str]: ... # Technically only the last arg can be a Callable but ... - def dir(self, *args: Union[str, Callable[[str], None]]) -> None: ... + def dir(self, *args: str | Callable[[str], None]) -> None: ... def mlsd(self, path: str = ..., facts: Iterable[str] = ...) -> Iterator[Tuple[str, Dict[str, str]]]: ... def rename(self, fromname: str, toname: str) -> str: ... def delete(self, filename: str) -> str: ... def cwd(self, dirname: str) -> str: ... - def size(self, filename: str) -> Optional[int]: ... + def size(self, filename: str) -> int | None: ... def mkd(self, dirname: str) -> str: ... def rmd(self, dirname: str) -> str: ... def pwd(self) -> str: ... @@ -106,15 +106,15 @@ class FTP_TLS(FTP): user: str = ..., passwd: str = ..., acct: str = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - context: Optional[SSLContext] = ..., + keyfile: str | None = ..., + certfile: str | None = ..., + context: SSLContext | None = ..., timeout: float = ..., - source_address: Optional[Tuple[str, int]] = ..., + source_address: Tuple[str, int] | None = ..., ) -> None: ... ssl_version: int - keyfile: Optional[str] - certfile: Optional[str] + keyfile: str | None + certfile: str | None context: SSLContext def login(self, user: str = ..., passwd: str = ..., acct: str = ..., secure: bool = ...) -> str: ... def auth(self) -> str: ... @@ -122,7 +122,7 @@ class FTP_TLS(FTP): def prot_c(self) -> str: ... def ccc(self) -> str: ... -def parse150(resp: str) -> Optional[int]: ... # undocumented +def parse150(resp: str) -> int | None: ... # undocumented def parse227(resp: str) -> Tuple[str, int]: ... # undocumented def parse229(resp: str, peer: Any) -> Tuple[str, int]: ... # undocumented def parse257(resp: str) -> str: ... # undocumented diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index d4a492c0102e..e4bae49a0dec 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -47,12 +47,12 @@ class _lru_cache_wrapper(Generic[_T]): if sys.version_info >= (3, 8): @overload - def lru_cache(maxsize: Optional[int] = ..., typed: bool = ...) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ... + def lru_cache(maxsize: int | None = ..., typed: bool = ...) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ... @overload def lru_cache(maxsize: Callable[..., _T], typed: bool = ...) -> _lru_cache_wrapper[_T]: ... else: - def lru_cache(maxsize: Optional[int] = ..., typed: bool = ...) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ... + def lru_cache(maxsize: int | None = ..., typed: bool = ...) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ... WRAPPER_ASSIGNMENTS: Sequence[str] WRAPPER_UPDATES: Sequence[str] @@ -75,7 +75,7 @@ class partial(Generic[_T]): _Descriptor = Any class partialmethod(Generic[_T]): - func: Union[Callable[..., _T], _Descriptor] + func: Callable[..., _T] | _Descriptor args: Tuple[Any, ...] keywords: Dict[str, Any] @overload @@ -121,12 +121,12 @@ if sys.version_info >= (3, 8): def __call__(self, *args: Any, **kwargs: Any) -> _T: ... class cached_property(Generic[_T]): func: Callable[[Any], _T] - attrname: Optional[str] + attrname: str | None def __init__(self, func: Callable[[Any], _T]) -> None: ... @overload - def __get__(self, instance: None, owner: Optional[Type[Any]] = ...) -> cached_property[_T]: ... + def __get__(self, instance: None, owner: Type[Any] | None = ...) -> cached_property[_T]: ... @overload - def __get__(self, instance: object, owner: Optional[Type[Any]] = ...) -> _T: ... + def __get__(self, instance: object, owner: Type[Any] | None = ...) -> _T: ... def __set_name__(self, owner: Type[Any], name: str) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/gc.pyi b/stdlib/gc.pyi index 841ffd8b34d2..5998b8e0c01a 100644 --- a/stdlib/gc.pyi +++ b/stdlib/gc.pyi @@ -16,7 +16,7 @@ def get_count() -> Tuple[int, int, int]: ... def get_debug() -> int: ... if sys.version_info >= (3, 8): - def get_objects(generation: Optional[int] = ...) -> List[Any]: ... + def get_objects(generation: int | None = ...) -> List[Any]: ... else: def get_objects() -> List[Any]: ... diff --git a/stdlib/genericpath.pyi b/stdlib/genericpath.pyi index 7bd6a1ebda58..b1f702efaa57 100644 --- a/stdlib/genericpath.pyi +++ b/stdlib/genericpath.pyi @@ -4,12 +4,12 @@ from typing import List, Sequence, Tuple, Union, overload from typing_extensions import Literal # All overloads can return empty string. Ideally, Literal[""] would be a valid -# Iterable[T], so that Union[List[T], Literal[""]] could be used as a return +# Iterable[T], so that List[T] | Literal[""] could be used as a return # type. But because this only works when T is str, we need Sequence[T] instead. @overload def commonprefix(m: Sequence[StrPath]) -> str: ... @overload -def commonprefix(m: Sequence[BytesPath]) -> Union[bytes, Literal[""]]: ... +def commonprefix(m: Sequence[BytesPath]) -> bytes | Literal[""]: ... @overload def commonprefix(m: Sequence[List[SupportsLessThanT]]) -> Sequence[SupportsLessThanT]: ... @overload diff --git a/stdlib/getpass.pyi b/stdlib/getpass.pyi index aac162a5166b..fe4be95d285a 100644 --- a/stdlib/getpass.pyi +++ b/stdlib/getpass.pyi @@ -1,6 +1,6 @@ from typing import Optional, TextIO -def getpass(prompt: str = ..., stream: Optional[TextIO] = ...) -> str: ... +def getpass(prompt: str = ..., stream: TextIO | None = ...) -> str: ... def getuser() -> str: ... class GetPassWarning(UserWarning): ... diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index dcbd214e04f8..658aa9d805c6 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -4,7 +4,7 @@ from typing import IO, Any, Container, Iterable, Optional, Sequence, Type, TypeV from typing_extensions import Literal class NullTranslations: - def __init__(self, fp: Optional[IO[str]] = ...) -> None: ... + def __init__(self, fp: IO[str] | None = ...) -> None: ... def _parse(self, fp: IO[str]) -> None: ... def add_fallback(self, fallback: NullTranslations) -> None: ... def gettext(self, message: str) -> str: ... @@ -18,7 +18,7 @@ class NullTranslations: def charset(self) -> Any: ... def output_charset(self) -> Any: ... def set_output_charset(self, charset: str) -> None: ... - def install(self, names: Optional[Container[str]] = ...) -> None: ... + def install(self, names: Container[str] | None = ...) -> None: ... class GNUTranslations(NullTranslations): LE_MAGIC: int @@ -26,43 +26,43 @@ class GNUTranslations(NullTranslations): CONTEXT: str VERSIONS: Sequence[int] -def find(domain: str, localedir: Optional[StrPath] = ..., languages: Optional[Iterable[str]] = ..., all: bool = ...) -> Any: ... +def find(domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., all: bool = ...) -> Any: ... _T = TypeVar("_T") @overload def translation( domain: str, - localedir: Optional[StrPath] = ..., - languages: Optional[Iterable[str]] = ..., + localedir: StrPath | None = ..., + languages: Iterable[str] | None = ..., class_: None = ..., fallback: bool = ..., - codeset: Optional[str] = ..., + codeset: str | None = ..., ) -> NullTranslations: ... @overload def translation( domain: str, - localedir: Optional[StrPath] = ..., - languages: Optional[Iterable[str]] = ..., + localedir: StrPath | None = ..., + languages: Iterable[str] | None = ..., class_: Type[_T] = ..., fallback: Literal[False] = ..., - codeset: Optional[str] = ..., + codeset: str | None = ..., ) -> _T: ... @overload def translation( domain: str, - localedir: Optional[StrPath] = ..., - languages: Optional[Iterable[str]] = ..., + localedir: StrPath | None = ..., + languages: Iterable[str] | None = ..., class_: Type[Any] = ..., fallback: Literal[True] = ..., - codeset: Optional[str] = ..., + codeset: str | None = ..., ) -> Any: ... def install( - domain: str, localedir: Optional[StrPath] = ..., codeset: Optional[str] = ..., names: Optional[Container[str]] = ... + domain: str, localedir: StrPath | None = ..., codeset: str | None = ..., names: Container[str] | None = ... ) -> None: ... -def textdomain(domain: Optional[str] = ...) -> str: ... -def bindtextdomain(domain: str, localedir: Optional[StrPath] = ...) -> str: ... -def bind_textdomain_codeset(domain: str, codeset: Optional[str] = ...) -> str: ... +def textdomain(domain: str | None = ...) -> str: ... +def bindtextdomain(domain: str, localedir: StrPath | None = ...) -> str: ... +def bind_textdomain_codeset(domain: str, codeset: str | None = ...) -> str: ... def dgettext(domain: str, message: str) -> str: ... def ldgettext(domain: str, message: str) -> str: ... def dngettext(domain: str, msgid1: str, msgid2: str, n: int) -> str: ... diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index 33582d15f2d0..f0462c96c41e 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -7,10 +7,10 @@ def glob1(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... if sys.version_info >= (3, 10): def glob( - pathname: AnyStr, *, root_dir: Optional[StrOrBytesPath] = ..., dir_fd: Optional[int] = ..., recursive: bool = ... + pathname: AnyStr, *, root_dir: StrOrBytesPath | None = ..., dir_fd: int | None = ..., recursive: bool = ... ) -> List[AnyStr]: ... def iglob( - pathname: AnyStr, *, root_dir: Optional[StrOrBytesPath] = ..., dir_fd: Optional[int] = ..., recursive: bool = ... + pathname: AnyStr, *, root_dir: StrOrBytesPath | None = ..., dir_fd: int | None = ..., recursive: bool = ... ) -> Iterator[AnyStr]: ... else: @@ -18,4 +18,4 @@ else: def iglob(pathname: AnyStr, *, recursive: bool = ...) -> Iterator[AnyStr]: ... def escape(pathname: AnyStr) -> AnyStr: ... -def has_magic(s: Union[str, bytes]) -> bool: ... # undocumented +def has_magic(s: str | bytes) -> bool: ... # undocumented diff --git a/stdlib/graphlib.pyi b/stdlib/graphlib.pyi index ca21b42329d2..bb4e373314dd 100644 --- a/stdlib/graphlib.pyi +++ b/stdlib/graphlib.pyi @@ -4,7 +4,7 @@ from typing import Generic, Iterable, Optional, Tuple, TypeVar _T = TypeVar("_T") class TopologicalSorter(Generic[_T]): - def __init__(self, graph: Optional[SupportsItems[_T, Iterable[_T]]] = ...) -> None: ... + def __init__(self, graph: SupportsItems[_T, Iterable[_T]] | None = ...) -> None: ... def add(self, node: _T, *predecessors: _T) -> None: ... def prepare(self) -> None: ... def is_active(self) -> bool: ... diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 8447f21736bb..63b7145d0350 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -2,7 +2,7 @@ from typing import List, NamedTuple, Optional class struct_group(NamedTuple): gr_name: str - gr_passwd: Optional[str] + gr_passwd: str | None gr_gid: int gr_mem: List[str] diff --git a/stdlib/gzip.pyi b/stdlib/gzip.pyi index efba70703d8d..3b21448c23f5 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -31,7 +31,7 @@ class _WritableFileobj(Protocol): @overload def open( - filename: Union[StrOrBytesPath, _ReadableFileobj], + filename: StrOrBytesPath | _ReadableFileobj, mode: _ReadBinaryMode = ..., compresslevel: int = ..., encoding: None = ..., @@ -40,7 +40,7 @@ def open( ) -> GzipFile: ... @overload def open( - filename: Union[StrOrBytesPath, _WritableFileobj], + filename: StrOrBytesPath | _WritableFileobj, mode: _WriteBinaryMode, compresslevel: int = ..., encoding: None = ..., @@ -52,19 +52,19 @@ def open( filename: StrOrBytesPath, mode: _OpenTextMode, compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> TextIO: ... @overload def open( - filename: Union[StrOrBytesPath, _ReadableFileobj, _WritableFileobj], + filename: StrOrBytesPath | _ReadableFileobj | _WritableFileobj, mode: str, compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., -) -> Union[GzipFile, TextIO]: ... + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., +) -> GzipFile | TextIO: ... class _PaddedFile: file: _ReadableFileobj @@ -78,19 +78,19 @@ if sys.version_info >= (3, 8): class BadGzipFile(OSError): ... class GzipFile(_compression.BaseStream): - myfileobj: Optional[FileIO] + myfileobj: FileIO | None mode: Literal[1, 2] name: str compress: zlib._Compress - fileobj: Union[_ReadableFileobj, _WritableFileobj] + fileobj: _ReadableFileobj | _WritableFileobj @overload def __init__( self, - filename: Optional[StrOrBytesPath], + filename: StrOrBytesPath | None, mode: _ReadBinaryMode, compresslevel: int = ..., - fileobj: Optional[_ReadableFileobj] = ..., - mtime: Optional[float] = ..., + fileobj: _ReadableFileobj | None = ..., + mtime: float | None = ..., ) -> None: ... @overload def __init__( @@ -98,17 +98,17 @@ class GzipFile(_compression.BaseStream): *, mode: _ReadBinaryMode, compresslevel: int = ..., - fileobj: Optional[_ReadableFileobj] = ..., - mtime: Optional[float] = ..., + fileobj: _ReadableFileobj | None = ..., + mtime: float | None = ..., ) -> None: ... @overload def __init__( self, - filename: Optional[StrOrBytesPath], + filename: StrOrBytesPath | None, mode: _WriteBinaryMode, compresslevel: int = ..., - fileobj: Optional[_WritableFileobj] = ..., - mtime: Optional[float] = ..., + fileobj: _WritableFileobj | None = ..., + mtime: float | None = ..., ) -> None: ... @overload def __init__( @@ -116,25 +116,25 @@ class GzipFile(_compression.BaseStream): *, mode: _WriteBinaryMode, compresslevel: int = ..., - fileobj: Optional[_WritableFileobj] = ..., - mtime: Optional[float] = ..., + fileobj: _WritableFileobj | None = ..., + mtime: float | None = ..., ) -> None: ... @overload def __init__( self, - filename: Optional[StrOrBytesPath] = ..., - mode: Optional[str] = ..., + filename: StrOrBytesPath | None = ..., + mode: str | None = ..., compresslevel: int = ..., - fileobj: Union[_ReadableFileobj, _WritableFileobj, None] = ..., - mtime: Optional[float] = ..., + fileobj: _ReadableFileobj | _WritableFileobj | None = ..., + mtime: float | None = ..., ) -> None: ... @property def filename(self) -> str: ... @property - def mtime(self) -> Optional[int]: ... + def mtime(self) -> int | None: ... crc: int def write(self, data: ReadableBuffer) -> int: ... - def read(self, size: Optional[int] = ...) -> bytes: ... + def read(self, size: int | None = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... def peek(self, n: int) -> bytes: ... @property @@ -147,14 +147,14 @@ class GzipFile(_compression.BaseStream): def writable(self) -> bool: ... def seekable(self) -> bool: ... def seek(self, offset: int, whence: int = ...) -> int: ... - def readline(self, size: Optional[int] = ...) -> bytes: ... + def readline(self, size: int | None = ...) -> bytes: ... class _GzipReader(_compression.DecompressReader): def __init__(self, fp: _ReadableFileobj) -> None: ... def read(self, size: int = ...) -> bytes: ... if sys.version_info >= (3, 8): - def compress(data: bytes, compresslevel: int = ..., *, mtime: Optional[float] = ...) -> bytes: ... + def compress(data: bytes, compresslevel: int = ..., *, mtime: float | None = ...) -> bytes: ... else: def compress(data: bytes, compresslevel: int = ...) -> bytes: ... diff --git a/stdlib/hashlib.pyi b/stdlib/hashlib.pyi index e4aee21450cc..f5ab456feb0f 100644 --- a/stdlib/hashlib.pyi +++ b/stdlib/hashlib.pyi @@ -47,7 +47,7 @@ algorithms_guaranteed: AbstractSet[str] algorithms_available: AbstractSet[str] def pbkdf2_hmac( - hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: Optional[int] = ... + hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: int | None = ... ) -> bytes: ... class _VarLenHash(object): @@ -70,10 +70,10 @@ shake_256 = _VarLenHash def scrypt( password: ReadableBuffer, *, - salt: Optional[ReadableBuffer] = ..., - n: Optional[int] = ..., - r: Optional[int] = ..., - p: Optional[int] = ..., + salt: ReadableBuffer | None = ..., + n: int | None = ..., + r: int | None = ..., + p: int | None = ..., maxmem: int = ..., dklen: int = ..., ) -> bytes: ... diff --git a/stdlib/heapq.pyi b/stdlib/heapq.pyi index 3d27a30bb412..86a0af89ff82 100644 --- a/stdlib/heapq.pyi +++ b/stdlib/heapq.pyi @@ -8,7 +8,7 @@ def heappop(__heap: List[_T]) -> _T: ... def heappushpop(__heap: List[_T], __item: _T) -> _T: ... def heapify(__heap: List[Any]) -> None: ... def heapreplace(__heap: List[_T], __item: _T) -> _T: ... -def merge(*iterables: Iterable[_T], key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...) -> Iterable[_T]: ... -def nlargest(n: int, iterable: Iterable[_T], key: Optional[Callable[[_T], SupportsLessThan]] = ...) -> List[_T]: ... -def nsmallest(n: int, iterable: Iterable[_T], key: Optional[Callable[[_T], SupportsLessThan]] = ...) -> List[_T]: ... +def merge(*iterables: Iterable[_T], key: Callable[[_T], Any] | None = ..., reverse: bool = ...) -> Iterable[_T]: ... +def nlargest(n: int, iterable: Iterable[_T], key: Callable[[_T], SupportsLessThan] | None = ...) -> List[_T]: ... +def nsmallest(n: int, iterable: Iterable[_T], key: Callable[[_T], SupportsLessThan] | None = ...) -> List[_T]: ... def _heapify_max(__x: List[Any]) -> None: ... # undocumented diff --git a/stdlib/hmac.pyi b/stdlib/hmac.pyi index de7b23d7ce00..d7963a3b23c5 100644 --- a/stdlib/hmac.pyi +++ b/stdlib/hmac.pyi @@ -13,18 +13,18 @@ if sys.version_info >= (3, 8): # In reality digestmod has a default value, but the function always throws an error # if the argument is not given, so we pretend it is a required argument. @overload - def new(key: bytes, msg: Optional[ReadableBuffer], digestmod: _DigestMod) -> HMAC: ... + def new(key: bytes, msg: ReadableBuffer | None, digestmod: _DigestMod) -> HMAC: ... @overload def new(key: bytes, *, digestmod: _DigestMod) -> HMAC: ... else: - def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... + def new(key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod | None = ...) -> HMAC: ... class HMAC: digest_size: int block_size: int name: str - def __init__(self, key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: _DigestMod = ...) -> None: ... + def __init__(self, key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod = ...) -> None: ... def update(self, msg: ReadableBuffer) -> None: ... def digest(self) -> bytes: ... def hexdigest(self) -> str: ... diff --git a/stdlib/html/parser.pyi b/stdlib/html/parser.pyi index 82431b7e1d3e..8eed327f156d 100644 --- a/stdlib/html/parser.pyi +++ b/stdlib/html/parser.pyi @@ -7,10 +7,10 @@ class HTMLParser(ParserBase): def close(self) -> None: ... def reset(self) -> None: ... def getpos(self) -> Tuple[int, int]: ... - def get_starttag_text(self) -> Optional[str]: ... - def handle_starttag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]) -> None: ... + def get_starttag_text(self) -> str | None: ... + def handle_starttag(self, tag: str, attrs: List[Tuple[str, str | None]]) -> None: ... def handle_endtag(self, tag: str) -> None: ... - def handle_startendtag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]) -> None: ... + def handle_startendtag(self, tag: str, attrs: List[Tuple[str, str | None]]) -> None: ... def handle_data(self, data: str) -> None: ... def handle_entityref(self, name: str) -> None: ... def handle_charref(self, name: str) -> None: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 59e64d873e23..34f517b1ce4a 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -103,24 +103,24 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): closed: bool status: int reason: str - def __init__(self, sock: socket, debuglevel: int = ..., method: Optional[str] = ..., url: Optional[str] = ...) -> None: ... + def __init__(self, sock: socket, debuglevel: int = ..., method: str | None = ..., url: str | None = ...) -> None: ... def peek(self, n: int = ...) -> bytes: ... - def read(self, amt: Optional[int] = ...) -> bytes: ... + def read(self, amt: int | None = ...) -> bytes: ... def read1(self, n: int = ...) -> bytes: ... def readinto(self, b: WriteableBuffer) -> int: ... def readline(self, limit: int = ...) -> bytes: ... # type: ignore @overload - def getheader(self, name: str) -> Optional[str]: ... + def getheader(self, name: str) -> str | None: ... @overload - def getheader(self, name: str, default: _T) -> Union[str, _T]: ... + def getheader(self, name: str, default: _T) -> str | _T: ... def getheaders(self) -> List[Tuple[str, str]]: ... def fileno(self) -> int: ... def isclosed(self) -> bool: ... def __iter__(self) -> Iterator[bytes]: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None + ) -> bool | None: ... def info(self) -> email.message.Message: ... def geturl(self) -> str: ... def getcode(self) -> int: ... @@ -133,14 +133,14 @@ class _HTTPConnectionProtocol(Protocol): def __call__( self, host: str, - port: Optional[int] = ..., + port: int | None = ..., timeout: float = ..., - source_address: Optional[Tuple[str, int]] = ..., + source_address: Tuple[str, int] | None = ..., blocksize: int = ..., ) -> HTTPConnection: ... else: def __call__( - self, host: str, port: Optional[int] = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ... + self, host: str, port: int | None = ..., timeout: float = ..., source_address: Tuple[str, int] | None = ... ) -> HTTPConnection: ... class HTTPConnection: @@ -148,7 +148,7 @@ class HTTPConnection: debuglevel: int = ... default_port: int = ... # undocumented response_class: Type[HTTPResponse] = ... # undocumented - timeout: Optional[float] + timeout: float | None host: str port: int sock: Any @@ -156,36 +156,36 @@ class HTTPConnection: def __init__( self, host: str, - port: Optional[int] = ..., - timeout: Optional[float] = ..., - source_address: Optional[Tuple[str, int]] = ..., + port: int | None = ..., + timeout: float | None = ..., + source_address: Tuple[str, int] | None = ..., blocksize: int = ..., ) -> None: ... else: def __init__( self, host: str, - port: Optional[int] = ..., - timeout: Optional[float] = ..., - source_address: Optional[Tuple[str, int]] = ..., + port: int | None = ..., + timeout: float | None = ..., + source_address: Tuple[str, int] | None = ..., ) -> None: ... def request( self, method: str, url: str, - body: Optional[_DataType] = ..., + body: _DataType | None = ..., headers: Mapping[str, str] = ..., *, encode_chunked: bool = ..., ) -> None: ... def getresponse(self) -> HTTPResponse: ... def set_debuglevel(self, level: int) -> None: ... - def set_tunnel(self, host: str, port: Optional[int] = ..., headers: Optional[Mapping[str, str]] = ...) -> None: ... + def set_tunnel(self, host: str, port: int | None = ..., headers: Mapping[str, str] | None = ...) -> None: ... def connect(self) -> None: ... def close(self) -> None: ... def putrequest(self, method: str, url: str, skip_host: bool = ..., skip_accept_encoding: bool = ...) -> None: ... def putheader(self, header: str, *argument: str) -> None: ... - def endheaders(self, message_body: Optional[_DataType] = ..., *, encode_chunked: bool = ...) -> None: ... + def endheaders(self, message_body: _DataType | None = ..., *, encode_chunked: bool = ...) -> None: ... def send(self, data: _DataType) -> None: ... class HTTPSConnection(HTTPConnection): @@ -193,28 +193,28 @@ class HTTPSConnection(HTTPConnection): def __init__( self, host: str, - port: Optional[int] = ..., - key_file: Optional[str] = ..., - cert_file: Optional[str] = ..., - timeout: Optional[float] = ..., - source_address: Optional[Tuple[str, int]] = ..., + port: int | None = ..., + key_file: str | None = ..., + cert_file: str | None = ..., + timeout: float | None = ..., + source_address: Tuple[str, int] | None = ..., *, - context: Optional[ssl.SSLContext] = ..., - check_hostname: Optional[bool] = ..., + context: ssl.SSLContext | None = ..., + check_hostname: bool | None = ..., blocksize: int = ..., ) -> None: ... else: def __init__( self, host: str, - port: Optional[int] = ..., - key_file: Optional[str] = ..., - cert_file: Optional[str] = ..., - timeout: Optional[float] = ..., - source_address: Optional[Tuple[str, int]] = ..., + port: int | None = ..., + key_file: str | None = ..., + cert_file: str | None = ..., + timeout: float | None = ..., + source_address: Tuple[str, int] | None = ..., *, - context: Optional[ssl.SSLContext] = ..., - check_hostname: Optional[bool] = ..., + context: ssl.SSLContext | None = ..., + check_hostname: bool | None = ..., ) -> None: ... class HTTPException(Exception): ... @@ -231,7 +231,7 @@ class UnknownTransferEncoding(HTTPException): ... class UnimplementedFileMode(HTTPException): ... class IncompleteRead(HTTPException): - def __init__(self, partial: bytes, expected: Optional[int] = ...) -> None: ... + def __init__(self, partial: bytes, expected: int | None = ...) -> None: ... class ImproperConnectionState(HTTPException): ... class CannotSendRequest(ImproperConnectionState): ... diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 685717af7032..09434eafcad9 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -15,14 +15,14 @@ class CookieJar(Iterable[Cookie]): domain_re: ClassVar[Pattern[str]] = ... # undocumented dots_re: ClassVar[Pattern[str]] = ... # undocumented magic_re: ClassVar[Pattern[str]] = ... # undocumented - def __init__(self, policy: Optional[CookiePolicy] = ...) -> None: ... + def __init__(self, policy: CookiePolicy | None = ...) -> None: ... def add_cookie_header(self, request: Request) -> None: ... def extract_cookies(self, response: HTTPResponse, request: Request) -> None: ... def set_policy(self, policy: CookiePolicy) -> None: ... def make_cookies(self, response: HTTPResponse, request: Request) -> Sequence[Cookie]: ... def set_cookie(self, cookie: Cookie) -> None: ... def set_cookie_if_ok(self, cookie: Cookie, request: Request) -> None: ... - def clear(self, domain: Optional[str] = ..., path: Optional[str] = ..., name: Optional[str] = ...) -> None: ... + def clear(self, domain: str | None = ..., path: str | None = ..., name: str | None = ...) -> None: ... def clear_session_cookies(self) -> None: ... def clear_expired_cookies(self) -> None: ... # undocumented def __iter__(self) -> Iterator[Cookie]: ... @@ -35,15 +35,15 @@ class FileCookieJar(CookieJar): delayload: bool if sys.version_info >= (3, 8): def __init__( - self, filename: Optional[StrPath] = ..., delayload: bool = ..., policy: Optional[CookiePolicy] = ... + self, filename: StrPath | None = ..., delayload: bool = ..., policy: CookiePolicy | None = ... ) -> None: ... else: def __init__( - self, filename: Optional[str] = ..., delayload: bool = ..., policy: Optional[CookiePolicy] = ... + self, filename: str | None = ..., delayload: bool = ..., policy: CookiePolicy | None = ... ) -> None: ... - def save(self, filename: Optional[str] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... - def load(self, filename: Optional[str] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... - def revert(self, filename: Optional[str] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... + def save(self, filename: str | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... + def load(self, filename: str | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... + def revert(self, filename: str | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... class MozillaCookieJar(FileCookieJar): header: ClassVar[str] = ... # undocumented @@ -76,11 +76,11 @@ class DefaultCookiePolicy(CookiePolicy): if sys.version_info >= (3, 8): def __init__( self, - blocked_domains: Optional[Sequence[str]] = ..., - allowed_domains: Optional[Sequence[str]] = ..., + blocked_domains: Sequence[str] | None = ..., + allowed_domains: Sequence[str] | None = ..., netscape: bool = ..., rfc2965: bool = ..., - rfc2109_as_netscape: Optional[bool] = ..., + rfc2109_as_netscape: bool | None = ..., hide_cookie2: bool = ..., strict_domain: bool = ..., strict_rfc2965_unverifiable: bool = ..., @@ -93,11 +93,11 @@ class DefaultCookiePolicy(CookiePolicy): else: def __init__( self, - blocked_domains: Optional[Sequence[str]] = ..., - allowed_domains: Optional[Sequence[str]] = ..., + blocked_domains: Sequence[str] | None = ..., + allowed_domains: Sequence[str] | None = ..., netscape: bool = ..., rfc2965: bool = ..., - rfc2109_as_netscape: Optional[bool] = ..., + rfc2109_as_netscape: bool | None = ..., hide_cookie2: bool = ..., strict_domain: bool = ..., strict_rfc2965_unverifiable: bool = ..., @@ -109,8 +109,8 @@ class DefaultCookiePolicy(CookiePolicy): def blocked_domains(self) -> Tuple[str, ...]: ... def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ... def is_blocked(self, domain: str) -> bool: ... - def allowed_domains(self) -> Optional[Tuple[str, ...]]: ... - def set_allowed_domains(self, allowed_domains: Optional[Sequence[str]]) -> None: ... + def allowed_domains(self) -> Tuple[str, ...] | None: ... + def set_allowed_domains(self, allowed_domains: Sequence[str] | None) -> None: ... def is_not_allowed(self, domain: str) -> bool: ... def set_ok_version(self, cookie: Cookie, request: Request) -> bool: ... # undocumented def set_ok_verifiability(self, cookie: Cookie, request: Request) -> bool: ... # undocumented @@ -126,17 +126,17 @@ class DefaultCookiePolicy(CookiePolicy): def return_ok_domain(self, cookie: Cookie, request: Request) -> bool: ... # undocumented class Cookie: - version: Optional[int] + version: int | None name: str - value: Optional[str] - port: Optional[str] + value: str | None + port: str | None path: str path_specified: bool secure: bool - expires: Optional[int] + expires: int | None discard: bool - comment: Optional[str] - comment_url: Optional[str] + comment: str | None + comment_url: str | None rfc2109: bool port_specified: bool domain: str # undocumented @@ -144,10 +144,10 @@ class Cookie: domain_initial_dot: bool def __init__( self, - version: Optional[int], + version: int | None, name: str, - value: Optional[str], # undocumented - port: Optional[str], + value: str | None, # undocumented + port: str | None, port_specified: bool, domain: str, domain_specified: bool, @@ -155,17 +155,17 @@ class Cookie: path: str, path_specified: bool, secure: bool, - expires: Optional[int], + expires: int | None, discard: bool, - comment: Optional[str], - comment_url: Optional[str], + comment: str | None, + comment_url: str | None, rest: Dict[str, str], rfc2109: bool = ..., ) -> None: ... def has_nonstandard_attr(self, name: str) -> bool: ... @overload - def get_nonstandard_attr(self, name: str) -> Optional[str]: ... + def get_nonstandard_attr(self, name: str) -> str | None: ... @overload - def get_nonstandard_attr(self, name: str, default: _T) -> Union[str, _T]: ... + def get_nonstandard_attr(self, name: str, default: _T) -> str | _T: ... def set_nonstandard_attr(self, name: str, value: str) -> None: ... - def is_expired(self, now: Optional[int] = ...) -> bool: ... + def is_expired(self, now: int | None = ...) -> bool: ... diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 99d2f6add836..6248bec95603 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -27,26 +27,26 @@ class Morsel(Dict[str, Any], Generic[_T]): def set(self, key: str, val: str, coded_val: _T) -> None: ... else: def set(self, key: str, val: str, coded_val: _T, LegalChars: str = ...) -> None: ... - def setdefault(self, key: str, val: Optional[str] = ...) -> str: ... + def setdefault(self, key: str, val: str | None = ...) -> str: ... # The dict update can also get a keywords argument so this is incompatible @overload # type: ignore def update(self, values: Mapping[str, str]) -> None: ... @overload def update(self, values: Iterable[Tuple[str, str]]) -> None: ... def isReservedKey(self, K: str) -> bool: ... - def output(self, attrs: Optional[List[str]] = ..., header: str = ...) -> str: ... - def js_output(self, attrs: Optional[List[str]] = ...) -> str: ... - def OutputString(self, attrs: Optional[List[str]] = ...) -> str: ... + def output(self, attrs: List[str] | None = ..., header: str = ...) -> str: ... + def js_output(self, attrs: List[str] | None = ...) -> str: ... + def OutputString(self, attrs: List[str] | None = ...) -> str: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]): - def __init__(self, input: Optional[_DataType] = ...) -> None: ... + def __init__(self, input: _DataType | None = ...) -> None: ... def value_decode(self, val: str) -> _T: ... def value_encode(self, val: _T) -> str: ... - def output(self, attrs: Optional[List[str]] = ..., header: str = ..., sep: str = ...) -> str: ... - def js_output(self, attrs: Optional[List[str]] = ...) -> str: ... + def output(self, attrs: List[str] | None = ..., header: str = ..., sep: str = ...) -> str: ... + def js_output(self, attrs: List[str] | None = ...) -> str: ... def load(self, rawdata: _DataType) -> None: ... - def __setitem__(self, key: str, value: Union[str, Morsel[_T]]) -> None: ... + def __setitem__(self, key: str, value: str | Morsel[_T]) -> None: ... class SimpleCookie(BaseCookie[_T], Generic[_T]): ... diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index bd97fe165c04..7c5c9818fe1f 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -31,22 +31,22 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): responses: Mapping[int, Tuple[str, str]] default_request_version: str # undocumented weekdayname: ClassVar[Sequence[str]] = ... # Undocumented - monthname: ClassVar[Sequence[Optional[str]]] = ... # Undocumented + monthname: ClassVar[Sequence[str | None]] = ... # Undocumented def __init__(self, request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer) -> None: ... def handle(self) -> None: ... def handle_one_request(self) -> None: ... def handle_expect_100(self) -> bool: ... - def send_error(self, code: int, message: Optional[str] = ..., explain: Optional[str] = ...) -> None: ... - def send_response(self, code: int, message: Optional[str] = ...) -> None: ... + def send_error(self, code: int, message: str | None = ..., explain: str | None = ...) -> None: ... + def send_response(self, code: int, message: str | None = ...) -> None: ... def send_header(self, keyword: str, value: str) -> None: ... - def send_response_only(self, code: int, message: Optional[str] = ...) -> None: ... + def send_response_only(self, code: int, message: str | None = ...) -> None: ... def end_headers(self) -> None: ... def flush_headers(self) -> None: ... - def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ... + def log_request(self, code: int | str = ..., size: int | str = ...) -> None: ... def log_error(self, format: str, *args: Any) -> None: ... def log_message(self, format: str, *args: Any) -> None: ... def version_string(self) -> str: ... - def date_time_string(self, timestamp: Optional[int] = ...) -> str: ... + def date_time_string(self, timestamp: int | None = ...) -> str: ... def log_date_time_string(self) -> str: ... def address_string(self) -> str: ... def parse_request(self) -> bool: ... # Undocumented diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 8ad242cca0f7..3d287eb4b5ab 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -21,9 +21,9 @@ class IMAP4: mustquote: Pattern[str] = ... debug: int = ... state: str = ... - literal: Optional[str] = ... - tagged_commands: Dict[bytes, Optional[List[bytes]]] - untagged_responses: Dict[str, List[Union[bytes, Tuple[bytes, bytes]]]] + literal: str | None = ... + tagged_commands: Dict[bytes, List[bytes] | None] + untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]] continuation_response: str = ... is_readonly: bool = ... tagnum: int = ... @@ -33,8 +33,8 @@ class IMAP4: capabilities: Tuple[str] = ... PROTOCOL_VERSION: str = ... if sys.version_info >= (3, 9): - def __init__(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ... - def open(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ... + def __init__(self, host: str = ..., port: int = ..., timeout: float | None = ...) -> None: ... + def open(self, host: str = ..., port: int = ..., timeout: float | None = ...) -> None: ... else: def __init__(self, host: str = ..., port: int = ...) -> None: ... def open(self, host: str = ..., port: int = ...) -> None: ... @@ -42,7 +42,7 @@ class IMAP4: host: str = ... port: int = ... sock: _socket = ... - file: Union[IO[str], IO[bytes]] = ... + file: IO[str] | IO[bytes] = ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... @@ -51,7 +51,7 @@ class IMAP4: def recent(self) -> _CommandResults: ... def response(self, code: str) -> _CommandResults: ... def append(self, mailbox: str, flags: str, date_time: str, message: str) -> str: ... - def authenticate(self, mechanism: str, authobject: Callable[[bytes], Optional[bytes]]) -> Tuple[str, str]: ... + def authenticate(self, mechanism: str, authobject: Callable[[bytes], bytes | None]) -> Tuple[str, str]: ... def capability(self) -> _CommandResults: ... def check(self) -> _CommandResults: ... def close(self) -> _CommandResults: ... @@ -61,7 +61,7 @@ class IMAP4: def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... def enable(self, capability: str) -> _CommandResults: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... + def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... def expunge(self) -> _CommandResults: ... def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ... def getacl(self, mailbox: str) -> _CommandResults: ... @@ -79,13 +79,13 @@ class IMAP4: def partial(self, message_num: str, message_part: str, start: str, length: str) -> _CommandResults: ... def proxyauth(self, user: str) -> _CommandResults: ... def rename(self, oldmailbox: str, newmailbox: str) -> _CommandResults: ... - def search(self, charset: Optional[str], *criteria: str) -> _CommandResults: ... - def select(self, mailbox: str = ..., readonly: bool = ...) -> Tuple[str, List[Optional[bytes]]]: ... + def search(self, charset: str | None, *criteria: str) -> _CommandResults: ... + def select(self, mailbox: str = ..., readonly: bool = ...) -> Tuple[str, List[bytes | None]]: ... def setacl(self, mailbox: str, who: str, what: str) -> _CommandResults: ... def setannotation(self, *args: str) -> _CommandResults: ... def setquota(self, root: str, limits: str) -> _CommandResults: ... def sort(self, sort_criteria: str, charset: str, *search_criteria: str) -> _CommandResults: ... - def starttls(self, ssl_context: Optional[Any] = ...) -> Tuple[Literal["OK"], List[None]]: ... + def starttls(self, ssl_context: Any | None = ...) -> Tuple[Literal["OK"], List[None]]: ... def status(self, mailbox: str, names: str) -> _CommandResults: ... def store(self, message_set: str, command: str, flags: str) -> _CommandResults: ... def subscribe(self, mailbox: str) -> _CommandResults: ... @@ -105,19 +105,19 @@ class IMAP4_SSL(IMAP4): self, host: str = ..., port: int = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - ssl_context: Optional[SSLContext] = ..., - timeout: Optional[float] = ..., + keyfile: str | None = ..., + certfile: str | None = ..., + ssl_context: SSLContext | None = ..., + timeout: float | None = ..., ) -> None: ... else: def __init__( self, host: str = ..., port: int = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - ssl_context: Optional[SSLContext] = ..., + keyfile: str | None = ..., + certfile: str | None = ..., + ssl_context: SSLContext | None = ..., ) -> None: ... host: str = ... port: int = ... @@ -125,9 +125,9 @@ class IMAP4_SSL(IMAP4): sslobj: SSLSocket = ... file: IO[Any] = ... if sys.version_info >= (3, 9): - def open(self, host: str = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ... + def open(self, host: str = ..., port: int | None = ..., timeout: float | None = ...) -> None: ... else: - def open(self, host: str = ..., port: Optional[int] = ...) -> None: ... + def open(self, host: str = ..., port: int | None = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... @@ -146,9 +146,9 @@ class IMAP4_stream(IMAP4): writefile: IO[Any] = ... readfile: IO[Any] = ... if sys.version_info >= (3, 9): - def open(self, host: Optional[str] = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ... + def open(self, host: str | None = ..., port: int | None = ..., timeout: float | None = ...) -> None: ... else: - def open(self, host: Optional[str] = ..., port: Optional[int] = ...) -> None: ... + def open(self, host: str | None = ..., port: int | None = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... @@ -164,4 +164,4 @@ class _Authenticator: def Internaldate2tuple(resp: str) -> time.struct_time: ... def Int2AP(num: int) -> str: ... def ParseFlags(resp: str) -> Tuple[str]: ... -def Time2Internaldate(date_time: Union[float, time.struct_time, str]) -> str: ... +def Time2Internaldate(date_time: float | time.struct_time | str) -> str: ... diff --git a/stdlib/imghdr.pyi b/stdlib/imghdr.pyi index 2b28b718a649..f972c6d70275 100644 --- a/stdlib/imghdr.pyi +++ b/stdlib/imghdr.pyi @@ -7,8 +7,8 @@ class _ReadableBinary(Protocol): def seek(self, offset: int) -> Any: ... @overload -def what(file: Union[StrPath, _ReadableBinary], h: None = ...) -> Optional[str]: ... +def what(file: StrPath | _ReadableBinary, h: None = ...) -> str | None: ... @overload -def what(file: Any, h: bytes) -> Optional[str]: ... +def what(file: Any, h: bytes) -> str | None: ... -tests: List[Callable[[bytes, Optional[BinaryIO]], Optional[str]]] +tests: List[Callable[[bytes, BinaryIO | None], str | None]] diff --git a/stdlib/imp.pyi b/stdlib/imp.pyi index c6049c38ee18..0f32f379c279 100644 --- a/stdlib/imp.pyi +++ b/stdlib/imp.pyi @@ -31,7 +31,7 @@ IMP_HOOK: int def new_module(name: str) -> types.ModuleType: ... def get_magic() -> bytes: ... def get_tag() -> str: ... -def cache_from_source(path: StrPath, debug_override: Optional[bool] = ...) -> str: ... +def cache_from_source(path: StrPath, debug_override: bool | None = ...) -> str: ... def source_from_cache(path: StrPath) -> str: ... def get_suffixes() -> List[Tuple[str, str, int]]: ... @@ -44,21 +44,21 @@ class NullImporter: class _FileLike(Protocol): closed: bool mode: str - def read(self) -> Union[str, bytes]: ... + def read(self) -> str | bytes: ... def close(self) -> Any: ... def __enter__(self) -> Any: ... def __exit__(self, *args: Any) -> Any: ... # PathLike doesn't work for the pathname argument here -def load_source(name: str, pathname: str, file: Optional[_FileLike] = ...) -> types.ModuleType: ... -def load_compiled(name: str, pathname: str, file: Optional[_FileLike] = ...) -> types.ModuleType: ... +def load_source(name: str, pathname: str, file: _FileLike | None = ...) -> types.ModuleType: ... +def load_compiled(name: str, pathname: str, file: _FileLike | None = ...) -> types.ModuleType: ... def load_package(name: str, path: StrPath) -> types.ModuleType: ... -def load_module(name: str, file: Optional[_FileLike], filename: str, details: Tuple[str, str, int]) -> types.ModuleType: ... +def load_module(name: str, file: _FileLike | None, filename: str, details: Tuple[str, str, int]) -> types.ModuleType: ... # IO[Any] is a TextIOWrapper if name is a .py file, and a FileIO otherwise. def find_module( - name: str, path: Union[None, List[str], List[PathLike[str]], List[StrPath]] = ... + name: str, path: None | List[str] | List[PathLike[str]] | List[StrPath] = ... ) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ... def reload(module: types.ModuleType) -> types.ModuleType: ... -def init_builtin(name: str) -> Optional[types.ModuleType]: ... +def init_builtin(name: str) -> types.ModuleType | None: ... def load_dynamic(name: str, path: str, file: Any = ...) -> types.ModuleType: ... # file argument is ignored diff --git a/stdlib/importlib/__init__.pyi b/stdlib/importlib/__init__.pyi index d55393df315e..600aec1281e4 100644 --- a/stdlib/importlib/__init__.pyi +++ b/stdlib/importlib/__init__.pyi @@ -4,12 +4,12 @@ from typing import Any, Mapping, Optional, Sequence def __import__( name: str, - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + globals: Mapping[str, Any] | None = ..., + locals: Mapping[str, Any] | None = ..., fromlist: Sequence[str] = ..., level: int = ..., ) -> types.ModuleType: ... -def import_module(name: str, package: Optional[str] = ...) -> types.ModuleType: ... -def find_loader(name: str, path: Optional[str] = ...) -> Optional[Loader]: ... +def import_module(name: str, package: str | None = ...) -> types.ModuleType: ... +def find_loader(name: str, path: str | None = ...) -> Loader | None: ... def invalidate_caches() -> None: ... def reload(module: types.ModuleType) -> types.ModuleType: ... diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 69b03567bb22..db850734070a 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -16,45 +16,45 @@ class ResourceLoader(Loader): class InspectLoader(Loader): def is_package(self, fullname: str) -> bool: ... - def get_code(self, fullname: str) -> Optional[types.CodeType]: ... + def get_code(self, fullname: str) -> types.CodeType | None: ... def load_module(self, fullname: str) -> types.ModuleType: ... @abstractmethod - def get_source(self, fullname: str) -> Optional[str]: ... + def get_source(self, fullname: str) -> str | None: ... def exec_module(self, module: types.ModuleType) -> None: ... @staticmethod - def source_to_code(data: Union[bytes, str], path: str = ...) -> types.CodeType: ... + def source_to_code(data: bytes | str, path: str = ...) -> types.CodeType: ... class ExecutionLoader(InspectLoader): @abstractmethod def get_filename(self, fullname: str) -> _Path: ... - def get_code(self, fullname: str) -> Optional[types.CodeType]: ... + def get_code(self, fullname: str) -> types.CodeType | None: ... class SourceLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta): def path_mtime(self, path: _Path) -> float: ... def set_data(self, path: _Path, data: bytes) -> None: ... - def get_source(self, fullname: str) -> Optional[str]: ... + def get_source(self, fullname: str) -> str | None: ... def path_stats(self, path: _Path) -> Mapping[str, Any]: ... # Please keep in sync with sys._MetaPathFinder class MetaPathFinder(Finder): - def find_module(self, fullname: str, path: Optional[Sequence[_Path]]) -> Optional[Loader]: ... + def find_module(self, fullname: str, path: Sequence[_Path] | 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: Optional[Sequence[_Path]], target: Optional[types.ModuleType] = ... - ) -> Optional[ModuleSpec]: ... + self, fullname: str, path: Sequence[_Path] | None, target: types.ModuleType | None = ... + ) -> ModuleSpec | None: ... class PathEntryFinder(Finder): - def find_module(self, fullname: str) -> Optional[Loader]: ... - def find_loader(self, fullname: str) -> Tuple[Optional[Loader], Sequence[_Path]]: ... + def find_module(self, fullname: str) -> Loader | None: ... + def find_loader(self, fullname: str) -> Tuple[Loader | None, Sequence[_Path]]: ... def invalidate_caches(self) -> None: ... # Not defined on the actual class, but expected to exist. - def find_spec(self, fullname: str, target: Optional[types.ModuleType] = ...) -> Optional[ModuleSpec]: ... + def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... 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) -> Optional[types.ModuleType]: ... + 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: ... @@ -67,8 +67,8 @@ class FileLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta): path: _Path def __init__(self, fullname: str, path: _Path) -> None: ... def get_data(self, path: _Path) -> bytes: ... - def get_filename(self, name: Optional[str] = ...) -> _Path: ... - def load_module(self, name: Optional[str] = ...) -> types.ModuleType: ... + def get_filename(self, name: str | None = ...) -> _Path: ... + def load_module(self, name: str | None = ...) -> types.ModuleType: ... if sys.version_info >= (3, 7): class ResourceReader(metaclass=ABCMeta): @@ -89,7 +89,7 @@ if sys.version_info >= (3, 9): @abstractmethod def read_bytes(self) -> bytes: ... @abstractmethod - def read_text(self, encoding: Optional[str] = ...) -> str: ... + def read_text(self, encoding: str | None = ...) -> str: ... @abstractmethod def is_dir(self) -> bool: ... @abstractmethod diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index beae43bd3937..af54a7bb2bc5 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -7,31 +7,31 @@ class ModuleSpec: def __init__( self, name: str, - loader: Optional[importlib.abc.Loader], + loader: importlib.abc.Loader | None, *, - origin: Optional[str] = ..., + origin: str | None = ..., loader_state: Any = ..., - is_package: Optional[bool] = ..., + is_package: bool | None = ..., ) -> None: ... name: str - loader: Optional[importlib.abc._LoaderProtocol] - origin: Optional[str] - submodule_search_locations: Optional[List[str]] + loader: importlib.abc._LoaderProtocol | None + origin: str | None + submodule_search_locations: List[str] | None loader_state: Any - cached: Optional[str] - parent: Optional[str] + cached: str | None + parent: str | None has_location: bool class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder @classmethod def find_module( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... - ) -> Optional[importlib.abc.Loader]: ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ... + ) -> importlib.abc.Loader | None: ... @classmethod def find_spec( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ..., target: Optional[types.ModuleType] = ... - ) -> Optional[ModuleSpec]: ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... + ) -> ModuleSpec | None: ... # InspectLoader @classmethod def is_package(cls, fullname: str) -> bool: ... @@ -45,7 +45,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) @staticmethod def module_repr(module: types.ModuleType) -> str: ... @classmethod - def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: ... + def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ... @classmethod def exec_module(cls, module: types.ModuleType) -> None: ... @@ -53,12 +53,12 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder @classmethod def find_module( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... - ) -> Optional[importlib.abc.Loader]: ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ... + ) -> importlib.abc.Loader | None: ... @classmethod def find_spec( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ..., target: Optional[types.ModuleType] = ... - ) -> Optional[ModuleSpec]: ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... + ) -> ModuleSpec | None: ... # InspectLoader @classmethod def is_package(cls, fullname: str) -> bool: ... @@ -72,29 +72,29 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): @staticmethod def module_repr(m: types.ModuleType) -> str: ... @classmethod - def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: ... + def create_module(cls, spec: ModuleSpec) -> types.ModuleType | None: ... @staticmethod def exec_module(module: types.ModuleType) -> None: ... class WindowsRegistryFinder(importlib.abc.MetaPathFinder): @classmethod def find_module( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... - ) -> Optional[importlib.abc.Loader]: ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ... + ) -> importlib.abc.Loader | None: ... @classmethod def find_spec( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ..., target: Optional[types.ModuleType] = ... - ) -> Optional[ModuleSpec]: ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... + ) -> ModuleSpec | None: ... class PathFinder: @classmethod def invalidate_caches(cls) -> None: ... @classmethod def find_spec( - cls, fullname: str, path: Optional[Sequence[Union[bytes, str]]] = ..., target: Optional[types.ModuleType] = ... - ) -> Optional[ModuleSpec]: ... + cls, fullname: str, path: Sequence[bytes | str] | None = ..., target: types.ModuleType | None = ... + ) -> ModuleSpec | None: ... @classmethod - def find_module(cls, fullname: str, path: Optional[Sequence[Union[bytes, str]]] = ...) -> Optional[importlib.abc.Loader]: ... + def find_module(cls, fullname: str, path: Sequence[bytes | str] | None = ...) -> importlib.abc.Loader | None: ... SOURCE_SUFFIXES: List[str] DEBUG_BYTECODE_SUFFIXES: List[str] @@ -119,5 +119,5 @@ class SourcelessFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader) class ExtensionFileLoader(importlib.abc.ExecutionLoader): def __init__(self, name: str, path: importlib.abc._Path) -> None: ... - def get_filename(self, name: Optional[str] = ...) -> importlib.abc._Path: ... + def get_filename(self, name: str | None = ...) -> importlib.abc._Path: ... def get_source(self, fullname: str) -> None: ... diff --git a/stdlib/importlib/metadata.pyi b/stdlib/importlib/metadata.pyi index 90d1062583d9..6b3474fbf118 100644 --- a/stdlib/importlib/metadata.pyi +++ b/stdlib/importlib/metadata.pyi @@ -27,8 +27,8 @@ if sys.version_info >= (3, 8): def read_binary(self) -> bytes: ... def locate(self) -> PathLike[str]: ... # The following attributes are not defined on PackagePath, but are dynamically added by Distribution.files: - hash: Optional[FileHash] - size: Optional[int] + hash: FileHash | None + size: int | None dist: Distribution class FileHash: mode: str @@ -36,7 +36,7 @@ if sys.version_info >= (3, 8): def __init__(self, spec: str) -> None: ... class Distribution: @abc.abstractmethod - def read_text(self, filename: str) -> Optional[str]: ... + def read_text(self, filename: str) -> str | None: ... @abc.abstractmethod def locate_file(self, path: StrPath) -> PathLike[str]: ... @classmethod @@ -47,7 +47,7 @@ if sys.version_info >= (3, 8): @overload @classmethod def discover( - cls, *, context: None = ..., name: Optional[str] = ..., path: List[str] = ..., **kwargs: Any + cls, *, context: None = ..., name: str | None = ..., path: List[str] = ..., **kwargs: Any ) -> Iterable[Distribution]: ... @staticmethod def at(path: StrPath) -> PathDistribution: ... @@ -58,13 +58,13 @@ if sys.version_info >= (3, 8): @property def entry_points(self) -> List[EntryPoint]: ... @property - def files(self) -> Optional[List[PackagePath]]: ... + def files(self) -> List[PackagePath] | None: ... @property - def requires(self) -> Optional[List[str]]: ... + def requires(self) -> List[str] | None: ... class DistributionFinder(MetaPathFinder): class Context: - name: Optional[str] - def __init__(self, *, name: Optional[str] = ..., path: List[str] = ..., **kwargs: Any) -> None: ... + name: str | None + def __init__(self, *, name: str | None = ..., path: List[str] = ..., **kwargs: Any) -> None: ... @property def path(self) -> List[str]: ... @abc.abstractmethod @@ -81,10 +81,10 @@ if sys.version_info >= (3, 8): def distributions(*, context: DistributionFinder.Context) -> Iterable[Distribution]: ... @overload def distributions( - *, context: None = ..., name: Optional[str] = ..., path: List[str] = ..., **kwargs: Any + *, context: None = ..., name: str | None = ..., path: List[str] = ..., **kwargs: Any ) -> Iterable[Distribution]: ... def metadata(distribution_name: str) -> Message: ... def version(distribution_name: str) -> str: ... def entry_points() -> Dict[str, Tuple[EntryPoint, ...]]: ... - def files(distribution_name: str) -> Optional[List[PackagePath]]: ... - def requires(distribution_name: str) -> Optional[List[str]]: ... + def files(distribution_name: str) -> List[PackagePath] | None: ... + def requires(distribution_name: str) -> List[str] | None: ... diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index 0fb786e9361c..a32054176e1a 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -11,25 +11,25 @@ def resolve_name(name: str, package: str | None) -> str: ... MAGIC_NUMBER: bytes -def cache_from_source(path: str, debug_override: Optional[bool] = ..., *, optimization: Optional[Any] = ...) -> str: ... +def cache_from_source(path: str, debug_override: bool | None = ..., *, optimization: Any | None = ...) -> str: ... def source_from_cache(path: str) -> str: ... def decode_source(source_bytes: bytes) -> str: ... -def find_spec(name: str, package: Optional[str] = ...) -> Optional[importlib.machinery.ModuleSpec]: ... +def find_spec(name: str, package: str | None = ...) -> importlib.machinery.ModuleSpec | None: ... def spec_from_loader( - name: str, loader: Optional[importlib.abc.Loader], *, origin: Optional[str] = ..., is_package: Optional[bool] = ... -) -> Optional[importlib.machinery.ModuleSpec]: ... + name: str, loader: importlib.abc.Loader | None, *, origin: str | None = ..., is_package: bool | None = ... +) -> importlib.machinery.ModuleSpec | None: ... def spec_from_file_location( name: str, - location: Optional[StrOrBytesPath] = ..., + location: StrOrBytesPath | None = ..., *, - loader: Optional[importlib.abc.Loader] = ..., - submodule_search_locations: Optional[List[str]] = ..., -) -> Optional[importlib.machinery.ModuleSpec]: ... + loader: importlib.abc.Loader | None = ..., + submodule_search_locations: List[str] | None = ..., +) -> importlib.machinery.ModuleSpec | None: ... def module_from_spec(spec: importlib.machinery.ModuleSpec) -> types.ModuleType: ... class LazyLoader(importlib.abc.Loader): def __init__(self, loader: importlib.abc.Loader) -> None: ... @classmethod def factory(cls, loader: importlib.abc.Loader) -> Callable[..., LazyLoader]: ... - def create_module(self, spec: importlib.machinery.ModuleSpec) -> Optional[types.ModuleType]: ... + def create_module(self, spec: importlib.machinery.ModuleSpec) -> types.ModuleType | None: ... def exec_module(self, module: types.ModuleType) -> None: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 946115e51874..e13b90a710d0 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -45,8 +45,8 @@ CO_ITERABLE_COROUTINE: int CO_ASYNC_GENERATOR: int TPFLAGS_IS_ABSTRACT: int -def getmembers(object: object, predicate: Optional[Callable[[Any], bool]] = ...) -> list[Tuple[str, Any]]: ... -def getmodulename(path: str) -> Optional[str]: ... +def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> list[Tuple[str, Any]]: ... +def getmodulename(path: str) -> str | None: ... def ismodule(object: object) -> TypeGuard[ModuleType]: ... def isclass(object: object) -> TypeGuard[Type[Any]]: ... def ismethod(object: object) -> TypeGuard[MethodType]: ... @@ -88,13 +88,13 @@ def ismemberdescriptor(object: object) -> bool: ... _SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] def findsource(object: _SourceObjectType) -> Tuple[list[str], int]: ... -def getabsfile(object: _SourceObjectType, _filename: Optional[str] = ...) -> str: ... +def getabsfile(object: _SourceObjectType, _filename: str | None = ...) -> str: ... def getblock(lines: Sequence[str]) -> Sequence[str]: ... -def getdoc(object: object) -> Optional[str]: ... -def getcomments(object: object) -> Optional[str]: ... +def getdoc(object: object) -> str | None: ... +def getcomments(object: object) -> str | None: ... def getfile(object: _SourceObjectType) -> str: ... -def getmodule(object: object, _filename: Optional[str] = ...) -> Optional[ModuleType]: ... -def getsourcefile(object: _SourceObjectType) -> Optional[str]: ... +def getmodule(object: object, _filename: str | None = ...) -> ModuleType | None: ... +def getsourcefile(object: _SourceObjectType) -> str | None: ... def getsourcelines(object: _SourceObjectType) -> Tuple[list[str], int]: ... def getsource(object: _SourceObjectType) -> str: ... def cleandoc(doc: str) -> str: ... @@ -108,8 +108,8 @@ if sys.version_info >= (3, 10): obj: Callable[..., Any], *, follow_wrapped: bool = ..., - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + globals: Mapping[str, Any] | None = ..., + locals: Mapping[str, Any] | None = ..., eval_str: bool = ..., ) -> Signature: ... @@ -117,7 +117,7 @@ else: def signature(obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Signature: ... class Signature: - def __init__(self, parameters: Optional[Sequence[Parameter]] = ..., *, return_annotation: Any = ...) -> None: ... + def __init__(self, parameters: Sequence[Parameter] | None = ..., *, return_annotation: Any = ...) -> None: ... # TODO: can we be more specific here? empty: object = ... @@ -127,7 +127,7 @@ class Signature: return_annotation: Any def bind(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ... - def replace(self: Self, *, parameters: Optional[Sequence[Parameter]] = ..., return_annotation: Any = ...) -> Self: ... + def replace(self: Self, *, parameters: Sequence[Parameter] | None = ..., return_annotation: Any = ...) -> Self: ... if sys.version_info >= (3, 10): @classmethod def from_callable( @@ -135,8 +135,8 @@ class Signature: obj: Callable[..., Any], *, follow_wrapped: bool = ..., - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + globals: Mapping[str, Any] | None = ..., + locals: Mapping[str, Any] | None = ..., eval_str: bool = ..., ) -> Signature: ... else: @@ -145,10 +145,10 @@ class Signature: if sys.version_info >= (3, 10): def get_annotations( - obj: Union[Callable[..., Any], Type[Any], ModuleType], + obj: Callable[..., Any] | Type[Any] | ModuleType, *, - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + globals: Mapping[str, Any] | None = ..., + locals: Mapping[str, Any] | None = ..., eval_str: bool = ..., ) -> dict[str, Any]: ... @@ -177,7 +177,7 @@ class Parameter: KEYWORD_ONLY: ClassVar[Literal[_ParameterKind.KEYWORD_ONLY]] VAR_KEYWORD: ClassVar[Literal[_ParameterKind.VAR_KEYWORD]] def replace( - self: Self, *, name: Optional[str] = ..., kind: Optional[_ParameterKind] = ..., default: Any = ..., annotation: Any = ... + self: Self, *, name: str | None = ..., kind: _ParameterKind | None = ..., default: Any = ..., annotation: Any = ... ) -> Self: ... class BoundArguments: @@ -194,51 +194,51 @@ class BoundArguments: # TODO: The actual return type should be list[_ClassTreeItem] but mypy doesn't # seem to be supporting this at the moment: -# _ClassTreeItem = Union[list[_ClassTreeItem], Tuple[type, Tuple[type, ...]]] +# _ClassTreeItem = list[_ClassTreeItem] | Tuple[type, Tuple[type, ...]] def getclasstree(classes: list[type], unique: bool = ...) -> list[Any]: ... -def walktree(classes: list[type], children: dict[Type[Any], list[type]], parent: Optional[Type[Any]]) -> list[Any]: ... +def walktree(classes: list[type], children: dict[Type[Any], list[type]], parent: Type[Any] | None) -> list[Any]: ... class ArgSpec(NamedTuple): args: list[str] - varargs: Optional[str] - keywords: Optional[str] + varargs: str | None + keywords: str | None defaults: Tuple[Any, ...] class Arguments(NamedTuple): args: list[str] - varargs: Optional[str] - varkw: Optional[str] + varargs: str | None + varkw: str | None def getargs(co: CodeType) -> Arguments: ... def getargspec(func: object) -> ArgSpec: ... class FullArgSpec(NamedTuple): args: list[str] - varargs: Optional[str] - varkw: Optional[str] - defaults: Optional[Tuple[Any, ...]] + varargs: str | None + varkw: str | None + defaults: Tuple[Any, ...] | None kwonlyargs: list[str] - kwonlydefaults: Optional[dict[str, Any]] + kwonlydefaults: dict[str, Any] | None annotations: dict[str, Any] def getfullargspec(func: object) -> FullArgSpec: ... class ArgInfo(NamedTuple): args: list[str] - varargs: Optional[str] - keywords: Optional[str] + varargs: str | None + keywords: str | None locals: dict[str, Any] def getargvalues(frame: FrameType) -> ArgInfo: ... -def formatannotation(annotation: object, base_module: Optional[str] = ...) -> str: ... +def formatannotation(annotation: object, base_module: str | None = ...) -> str: ... def formatannotationrelativeto(object: object) -> Callable[[object], str]: ... def formatargspec( args: list[str], - varargs: Optional[str] = ..., - varkw: Optional[str] = ..., - defaults: Optional[Tuple[Any, ...]] = ..., - kwonlyargs: Optional[Sequence[str]] = ..., - kwonlydefaults: Optional[dict[str, Any]] = ..., + varargs: str | None = ..., + varkw: str | None = ..., + defaults: Tuple[Any, ...] | None = ..., + kwonlyargs: Sequence[str] | None = ..., + kwonlydefaults: dict[str, Any] | None = ..., annotations: dict[str, Any] = ..., formatarg: Callable[[str], str] = ..., formatvarargs: Callable[[str], str] = ..., @@ -249,13 +249,13 @@ def formatargspec( ) -> str: ... def formatargvalues( args: list[str], - varargs: Optional[str], - varkw: Optional[str], - locals: Optional[dict[str, Any]], - formatarg: Optional[Callable[[str], str]] = ..., - formatvarargs: Optional[Callable[[str], str]] = ..., - formatvarkw: Optional[Callable[[str], str]] = ..., - formatvalue: Optional[Callable[[Any], str]] = ..., + varargs: str | None, + varkw: str | None, + locals: dict[str, Any] | None, + formatarg: Callable[[str], str] | None = ..., + formatvarargs: Callable[[str], str] | None = ..., + formatvarkw: Callable[[str], str] | None = ..., + formatvalue: Callable[[Any], str] | None = ..., ) -> str: ... def getmro(cls: type) -> Tuple[type, ...]: ... def getcallargs(__func: Callable[..., Any], *args: Any, **kwds: Any) -> dict[str, Any]: ... @@ -267,7 +267,7 @@ class ClosureVars(NamedTuple): unbound: Set[str] def getclosurevars(func: Callable[..., Any]) -> ClosureVars: ... -def unwrap(func: Callable[..., Any], *, stop: Optional[Callable[[Any], Any]] = ...) -> Any: ... +def unwrap(func: Callable[..., Any], *, stop: Callable[[Any], Any] | None = ...) -> Any: ... # # The interpreter stack @@ -277,22 +277,22 @@ class Traceback(NamedTuple): filename: str lineno: int function: str - code_context: Optional[list[str]] - index: Optional[int] # type: ignore + code_context: list[str] | None + index: int | None # type: ignore class FrameInfo(NamedTuple): frame: FrameType filename: str lineno: int function: str - code_context: Optional[list[str]] - index: Optional[int] # type: ignore + code_context: list[str] | None + index: int | None # type: ignore -def getframeinfo(frame: Union[FrameType, TracebackType], context: int = ...) -> Traceback: ... +def getframeinfo(frame: FrameType | TracebackType, context: int = ...) -> Traceback: ... def getouterframes(frame: Any, context: int = ...) -> list[FrameInfo]: ... def getinnerframes(tb: TracebackType, context: int = ...) -> list[FrameInfo]: ... def getlineno(frame: FrameType) -> int: ... -def currentframe() -> Optional[FrameType]: ... +def currentframe() -> FrameType | None: ... def stack(context: int = ...) -> list[FrameInfo]: ... def trace(context: int = ...) -> list[FrameInfo]: ... @@ -300,7 +300,7 @@ def trace(context: int = ...) -> list[FrameInfo]: ... # Fetching attributes statically # -def getattr_static(obj: object, attr: str, default: Optional[Any] = ...) -> Any: ... +def getattr_static(obj: object, attr: str, default: Any | None = ...) -> Any: ... # # Current State of Generators and Coroutines diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 5092d0ee39d1..0e8a5289f149 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -26,8 +26,8 @@ class IOBase: def __next__(self) -> bytes: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def close(self) -> None: ... def fileno(self) -> int: ... def flush(self) -> None: ... @@ -38,21 +38,21 @@ class IOBase: def seek(self, __offset: int, __whence: int = ...) -> int: ... def seekable(self) -> bool: ... def tell(self) -> int: ... - def truncate(self, __size: Optional[int] = ...) -> int: ... + def truncate(self, __size: int | None = ...) -> int: ... def writable(self) -> bool: ... write: Callable[..., Any] def writelines(self, __lines: Iterable[ReadableBuffer]) -> None: ... - def readline(self, __size: Optional[int] = ...) -> bytes: ... + def readline(self, __size: int | None = ...) -> bytes: ... def __del__(self) -> None: ... @property def closed(self) -> bool: ... - def _checkClosed(self, msg: Optional[str] = ...) -> None: ... # undocumented + def _checkClosed(self, msg: str | None = ...) -> None: ... # undocumented class RawIOBase(IOBase): def readall(self) -> bytes: ... - def readinto(self, __buffer: WriteableBuffer) -> Optional[int]: ... - def write(self, __b: ReadableBuffer) -> Optional[int]: ... - def read(self, __size: int = ...) -> Optional[bytes]: ... + def readinto(self, __buffer: WriteableBuffer) -> int | None: ... + def write(self, __b: ReadableBuffer) -> int | None: ... + def read(self, __size: int = ...) -> bytes | None: ... class BufferedIOBase(IOBase): raw: RawIOBase # This is not part of the BufferedIOBase API and may not exist on some implementations. @@ -60,7 +60,7 @@ class BufferedIOBase(IOBase): def readinto(self, __buffer: WriteableBuffer) -> int: ... def write(self, __buffer: ReadableBuffer) -> int: ... def readinto1(self, __buffer: WriteableBuffer) -> int: ... - def read(self, __size: Optional[int] = ...) -> bytes: ... + def read(self, __size: int | None = ...) -> bytes: ... def read1(self, __size: int = ...) -> bytes: ... class FileIO(RawIOBase, BinaryIO): @@ -85,9 +85,9 @@ class BytesIO(BufferedIOBase, BinaryIO): def getvalue(self) -> bytes: ... def getbuffer(self) -> memoryview: ... if sys.version_info >= (3, 7): - def read1(self, __size: Optional[int] = ...) -> bytes: ... + def read1(self, __size: int | None = ...) -> bytes: ... else: - def read1(self, __size: Optional[int]) -> bytes: ... # type: ignore + def read1(self, __size: int | None) -> bytes: ... # type: ignore class BufferedReader(BufferedIOBase, BinaryIO): def __enter__(self: Self) -> Self: ... @@ -118,8 +118,8 @@ class BufferedRWPair(BufferedIOBase): class TextIOBase(IOBase): encoding: str - errors: Optional[str] - newlines: Union[str, Tuple[str, ...], None] + errors: str | None + newlines: str | Tuple[str, ...] | None def __iter__(self) -> Iterator[str]: ... # type: ignore def __next__(self) -> str: ... # type: ignore def detach(self) -> BinaryIO: ... @@ -127,16 +127,16 @@ class TextIOBase(IOBase): def writelines(self, __lines: Iterable[str]) -> None: ... # type: ignore def readline(self, __size: int = ...) -> str: ... # type: ignore def readlines(self, __hint: int = ...) -> List[str]: ... # type: ignore - def read(self, __size: Optional[int] = ...) -> str: ... + def read(self, __size: int | None = ...) -> str: ... def tell(self) -> int: ... class TextIOWrapper(TextIOBase, TextIO): def __init__( self, buffer: IO[bytes], - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., line_buffering: bool = ..., write_through: bool = ..., ) -> None: ... @@ -152,11 +152,11 @@ class TextIOWrapper(TextIOBase, TextIO): def reconfigure( self, *, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - line_buffering: Optional[bool] = ..., - write_through: Optional[bool] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., + line_buffering: bool | None = ..., + write_through: bool | None = ..., ) -> None: ... # These are inherited from TextIOBase, but must exist in the stub to satisfy mypy. def __enter__(self: Self) -> Self: ... @@ -168,7 +168,7 @@ class TextIOWrapper(TextIOBase, TextIO): def seek(self, __cookie: int, __whence: int = ...) -> int: ... class StringIO(TextIOWrapper): - def __init__(self, initial_value: Optional[str] = ..., newline: Optional[str] = ...) -> None: ... + def __init__(self, initial_value: str | None = ..., newline: str | None = ...) -> None: ... # StringIO does not contain a "name" field. This workaround is necessary # to allow StringIO sub-classes to add this field, as it is defined # as a read-only property on IO[]. @@ -176,7 +176,7 @@ class StringIO(TextIOWrapper): def getvalue(self) -> str: ... class IncrementalNewlineDecoder(codecs.IncrementalDecoder): - def __init__(self, decoder: Optional[codecs.IncrementalDecoder], translate: bool, errors: str = ...) -> None: ... - def decode(self, input: Union[bytes, str], final: bool = ...) -> str: ... + def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ... + def decode(self, input: bytes | str, final: bool = ...) -> str: ... @property - def newlines(self) -> Optional[Union[str, Tuple[str, ...]]]: ... + def newlines(self) -> str | Tuple[str, ...] | None: ... diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index b4e2b2c4b3f9..cfad77f03f96 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -9,9 +9,9 @@ _A = TypeVar("_A", IPv4Address, IPv6Address) _N = TypeVar("_N", IPv4Network, IPv6Network) _T = TypeVar("_T") -def ip_address(address: object) -> Any: ... # morally Union[IPv4Address, IPv6Address] -def ip_network(address: object, strict: bool = ...) -> Any: ... # morally Union[IPv4Network, IPv6Network] -def ip_interface(address: object) -> Any: ... # morally Union[IPv4Interface, IPv6Interface] +def ip_address(address: object) -> Any: ... # morally IPv4Address | IPv6Address +def ip_network(address: object, strict: bool = ...) -> Any: ... # morally IPv4Network | IPv6Network +def ip_interface(address: object) -> Any: ... # morally IPv4Interface | IPv6Interface class _IPAddressBase: def __eq__(self, other: Any) -> bool: ... @@ -90,8 +90,8 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): if sys.version_info >= (3, 7): def subnet_of(self: _T, other: _T) -> bool: ... def supernet_of(self: _T, other: _T) -> bool: ... - def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ... - def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ... + def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> Iterator[_T]: ... + def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> _T: ... @property def with_hostmask(self) -> str: ... @property @@ -120,13 +120,13 @@ class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): ... class IPv6Address(_BaseAddress): @property - def ipv4_mapped(self) -> Optional[IPv4Address]: ... + def ipv4_mapped(self) -> IPv4Address | None: ... @property def is_site_local(self) -> bool: ... @property - def sixtofour(self) -> Optional[IPv4Address]: ... + def sixtofour(self) -> IPv4Address | None: ... @property - def teredo(self) -> Optional[Tuple[IPv4Address, IPv4Address]]: ... + def teredo(self) -> Tuple[IPv4Address, IPv4Address] | None: ... class IPv6Network(_BaseNetwork[IPv6Address]): @property diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 7fe08ca80531..348c5d6c2918 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -53,11 +53,11 @@ class repeat(Iterator[_T], Generic[_T]): class accumulate(Iterator[_T], Generic[_T]): if sys.version_info >= (3, 8): @overload - def __init__(self, iterable: Iterable[_T], func: None = ..., *, initial: Optional[_T] = ...) -> None: ... + def __init__(self, iterable: Iterable[_T], func: None = ..., *, initial: _T | None = ...) -> None: ... @overload - def __init__(self, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: Optional[_T] = ...) -> None: ... + def __init__(self, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = ...) -> None: ... else: - def __init__(self, iterable: Iterable[_T], func: Optional[Callable[[_T, _T], _T]] = ...) -> None: ... + def __init__(self, iterable: Iterable[_T], func: Callable[[_T, _T], _T] | None = ...) -> None: ... def __iter__(self) -> Iterator[_T]: ... def __next__(self) -> _T: ... @@ -80,7 +80,7 @@ class dropwhile(Iterator[_T], Generic[_T]): def __next__(self) -> _T: ... class filterfalse(Iterator[_T], Generic[_T]): - def __init__(self, __predicate: Optional[Predicate[_T]], __iterable: Iterable[_T]) -> None: ... + def __init__(self, __predicate: Predicate[_T] | None, __iterable: Iterable[_T]) -> None: ... def __iter__(self) -> Iterator[_T]: ... def __next__(self) -> _T: ... @@ -97,10 +97,10 @@ class groupby(Iterator[Tuple[_T, Iterator[_S]]], Generic[_T, _S]): class islice(Iterator[_T], Generic[_T]): @overload - def __init__(self, __iterable: Iterable[_T], __stop: Optional[int]) -> None: ... + def __init__(self, __iterable: Iterable[_T], __stop: int | None) -> None: ... @overload def __init__( - self, __iterable: Iterable[_T], __start: Optional[int], __stop: Optional[int], __step: Optional[int] = ... + self, __iterable: Iterable[_T], __start: int | None, __stop: int | None, __step: int | None = ... ) -> None: ... def __iter__(self) -> Iterator[_T]: ... def __next__(self) -> _T: ... @@ -177,7 +177,7 @@ class product(Iterator[_T_co], Generic[_T_co]): def __next__(self) -> _T_co: ... class permutations(Iterator[Tuple[_T, ...]], Generic[_T]): - def __init__(self, iterable: Iterable[_T], r: Optional[int] = ...) -> None: ... + def __init__(self, iterable: Iterable[_T], r: int | None = ...) -> None: ... def __iter__(self) -> Iterator[Tuple[_T, ...]]: ... def __next__(self) -> Tuple[_T, ...]: ... diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index 7b7a89ae20e2..1615c2fb8593 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -11,10 +11,10 @@ def dumps( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Optional[Type[JSONEncoder]] = ..., - indent: Union[None, int, str] = ..., - separators: Optional[Tuple[str, str]] = ..., - default: Optional[Callable[[Any], Any]] = ..., + cls: Type[JSONEncoder] | None = ..., + indent: None | int | str = ..., + separators: Tuple[str, str] | None = ..., + default: Callable[[Any], Any] | None = ..., sort_keys: bool = ..., **kwds: Any, ) -> str: ... @@ -26,33 +26,33 @@ def dump( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Optional[Type[JSONEncoder]] = ..., - indent: Union[None, int, str] = ..., - separators: Optional[Tuple[str, str]] = ..., - default: Optional[Callable[[Any], Any]] = ..., + cls: Type[JSONEncoder] | None = ..., + indent: None | int | str = ..., + separators: Tuple[str, str] | None = ..., + default: Callable[[Any], Any] | None = ..., sort_keys: bool = ..., **kwds: Any, ) -> None: ... def loads( - s: Union[str, bytes], + s: str | bytes, *, - cls: Optional[Type[JSONDecoder]] = ..., - object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., - parse_float: Optional[Callable[[str], Any]] = ..., - parse_int: Optional[Callable[[str], Any]] = ..., - parse_constant: Optional[Callable[[str], Any]] = ..., - object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ..., + cls: Type[JSONDecoder] | None = ..., + object_hook: Callable[[Dict[Any, Any]], Any] | None = ..., + parse_float: Callable[[str], Any] | None = ..., + parse_int: Callable[[str], Any] | None = ..., + parse_constant: Callable[[str], Any] | None = ..., + object_pairs_hook: Callable[[List[Tuple[Any, Any]]], Any] | None = ..., **kwds: Any, ) -> Any: ... def load( - fp: SupportsRead[Union[str, bytes]], + fp: SupportsRead[str | bytes], *, - cls: Optional[Type[JSONDecoder]] = ..., - object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., - parse_float: Optional[Callable[[str], Any]] = ..., - parse_int: Optional[Callable[[str], Any]] = ..., - parse_constant: Optional[Callable[[str], Any]] = ..., - object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ..., + cls: Type[JSONDecoder] | None = ..., + object_hook: Callable[[Dict[Any, Any]], Any] | None = ..., + parse_float: Callable[[str], Any] | None = ..., + parse_int: Callable[[str], Any] | None = ..., + parse_constant: Callable[[str], Any] | None = ..., + object_pairs_hook: Callable[[List[Tuple[Any, Any]]], Any] | None = ..., **kwds: Any, ) -> Any: ... def detect_encoding(b: bytes) -> str: ... # undocumented diff --git a/stdlib/json/decoder.pyi b/stdlib/json/decoder.pyi index 19d7b4eb2545..f8b15086c2eb 100644 --- a/stdlib/json/decoder.pyi +++ b/stdlib/json/decoder.pyi @@ -18,12 +18,12 @@ class JSONDecoder: def __init__( self, *, - object_hook: Optional[Callable[[Dict[str, Any]], Any]] = ..., - parse_float: Optional[Callable[[str], Any]] = ..., - parse_int: Optional[Callable[[str], Any]] = ..., - parse_constant: Optional[Callable[[str], Any]] = ..., + object_hook: Callable[[Dict[str, Any]], Any] | None = ..., + parse_float: Callable[[str], Any] | None = ..., + parse_int: Callable[[str], Any] | None = ..., + parse_constant: Callable[[str], Any] | None = ..., strict: bool = ..., - object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ..., + object_pairs_hook: Callable[[List[Tuple[str, Any]]], Any] | None = ..., ) -> None: ... def decode(self, s: str, _w: Callable[..., Any] = ...) -> Any: ... # _w is undocumented def raw_decode(self, s: str, idx: int = ...) -> Tuple[Any, int]: ... diff --git a/stdlib/json/encoder.pyi b/stdlib/json/encoder.pyi index 4155abd028dc..2eaa6dfa8d8c 100644 --- a/stdlib/json/encoder.pyi +++ b/stdlib/json/encoder.pyi @@ -21,9 +21,9 @@ class JSONEncoder: check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ..., - indent: Optional[int] = ..., - separators: Optional[Tuple[str, str]] = ..., - default: Optional[Callable[..., Any]] = ..., + indent: int | None = ..., + separators: Tuple[str, str] | None = ..., + default: Callable[..., Any] | None = ..., ) -> None: ... def default(self, o: Any) -> Any: ... def encode(self, o: Any) -> str: ... diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index f50cbd78bbaa..414b6e95c8ad 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -8,13 +8,13 @@ class Driver: grammar: Grammar logger: Logger convert: _Convert - def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ..., logger: Optional[Logger] = ...) -> None: ... + def __init__(self, grammar: Grammar, convert: _Convert | None = ..., logger: Logger | None = ...) -> None: ... def parse_tokens(self, tokens: Iterable[Any], debug: bool = ...) -> _NL: ... def parse_stream_raw(self, stream: IO[str], debug: bool = ...) -> _NL: ... def parse_stream(self, stream: IO[str], debug: bool = ...) -> _NL: ... - def parse_file(self, filename: StrPath, encoding: Optional[str] = ..., debug: bool = ...) -> _NL: ... + def parse_file(self, filename: StrPath, encoding: str | None = ..., debug: bool = ...) -> _NL: ... def parse_string(self, text: str, debug: bool = ...) -> _NL: ... def load_grammar( - gt: str = ..., gp: Optional[str] = ..., save: bool = ..., force: bool = ..., logger: Optional[Logger] = ... + gt: str = ..., gp: str | None = ..., save: bool = ..., force: bool = ..., logger: Logger | None = ... ) -> Grammar: ... diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index c84d2cdf73cc..b93867f9d9d4 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -7,20 +7,20 @@ _Context = Sequence[Any] class ParseError(Exception): msg: str type: int - value: Optional[str] + value: str | None context: _Context - def __init__(self, msg: str, type: int, value: Optional[str], context: _Context) -> None: ... + def __init__(self, msg: str, type: int, value: str | None, context: _Context) -> None: ... class Parser: grammar: Grammar convert: _Convert stack: List[Tuple[_DFAS, int, _RawNode]] - rootnode: Optional[_NL] + rootnode: _NL | None used_names: Set[str] - def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ...) -> None: ... - def setup(self, start: Optional[int] = ...) -> None: ... - def addtoken(self, type: int, value: Optional[str], context: _Context) -> bool: ... - def classify(self, type: int, value: Optional[str], context: _Context) -> int: ... - def shift(self, type: int, value: Optional[str], newstate: int, context: _Context) -> None: ... + def __init__(self, grammar: Grammar, convert: _Convert | None = ...) -> None: ... + def setup(self, start: int | None = ...) -> None: ... + def addtoken(self, type: int, value: str | None, context: _Context) -> bool: ... + def classify(self, type: int, value: str | None, context: _Context) -> int: ... + def shift(self, type: int, value: str | None, newstate: int, context: _Context) -> None: ... def push(self, type: int, newdfa: _DFAS, newstate: int, context: _Context) -> None: ... def pop(self) -> None: ... diff --git a/stdlib/lib2to3/pgen2/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index 6909eed9b5f1..c2dede8b7267 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -10,7 +10,7 @@ class ParserGenerator: stream: IO[str] generator: Iterator[_TokenInfo] first: Dict[str, Dict[str, int]] - def __init__(self, filename: StrPath, stream: Optional[IO[str]] = ...) -> None: ... + def __init__(self, filename: StrPath, stream: IO[str] | None = ...) -> None: ... def make_grammar(self) -> PgenGrammar: ... def make_first(self, c: PgenGrammar, name: str) -> Dict[int, int]: ... def make_label(self, c: PgenGrammar, label: str) -> int: ... @@ -25,14 +25,14 @@ class ParserGenerator: def parse_alt(self) -> Tuple[NFAState, NFAState]: ... def parse_item(self) -> Tuple[NFAState, NFAState]: ... def parse_atom(self) -> Tuple[NFAState, NFAState]: ... - def expect(self, type: int, value: Optional[Any] = ...) -> str: ... + def expect(self, type: int, value: Any | None = ...) -> str: ... def gettoken(self) -> None: ... def raise_error(self, msg: str, *args: Any) -> NoReturn: ... class NFAState: - arcs: List[Tuple[Optional[str], NFAState]] + arcs: List[Tuple[str | None, NFAState]] def __init__(self) -> None: ... - def addarc(self, next: NFAState, label: Optional[str] = ...) -> None: ... + def addarc(self, next: NFAState, label: str | None = ...) -> None: ... class DFAState: nfaset: Dict[NFAState, Any] diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 8d90ee39b76b..ff0ba49bab93 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -14,7 +14,7 @@ def type_repr(type_num: int) -> str: ... class Base: type: int - parent: Optional[Node] + parent: Node | None prefix: str children: List[_NL] was_changed: bool @@ -24,14 +24,14 @@ class Base: def clone(self: _P) -> _P: ... def post_order(self) -> Iterator[_NL]: ... def pre_order(self) -> Iterator[_NL]: ... - def replace(self, new: Union[_NL, List[_NL]]) -> None: ... + def replace(self, new: _NL | List[_NL]) -> None: ... def get_lineno(self) -> int: ... def changed(self) -> None: ... - def remove(self) -> Optional[int]: ... + def remove(self) -> int | None: ... @property - def next_sibling(self) -> Optional[_NL]: ... + def next_sibling(self) -> _NL | None: ... @property - def prev_sibling(self) -> Optional[_NL]: ... + def prev_sibling(self) -> _NL | None: ... def leaves(self) -> Iterator[Leaf]: ... def depth(self) -> int: ... def get_suffix(self) -> str: ... @@ -42,9 +42,9 @@ class Node(Base): self, type: int, children: List[_NL], - context: Optional[Any] = ..., - prefix: Optional[str] = ..., - fixers_applied: Optional[List[Any]] = ..., + context: Any | None = ..., + prefix: str | None = ..., + fixers_applied: List[Any] | None = ..., ) -> None: ... def set_child(self, i: int, child: _NL) -> None: ... def insert_child(self, i: int, child: _NL) -> None: ... @@ -59,8 +59,8 @@ class Leaf(Base): self, type: int, value: str, - context: Optional[_Context] = ..., - prefix: Optional[str] = ..., + context: _Context | None = ..., + prefix: str | None = ..., fixers_applied: List[Any] = ..., ) -> None: ... @@ -68,26 +68,26 @@ def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ... class BasePattern: type: int - content: Optional[str] - name: Optional[str] + content: str | None + name: str | None def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns - def match(self, node: _NL, results: Optional[_Results] = ...) -> bool: ... - def match_seq(self, nodes: List[_NL], results: Optional[_Results] = ...) -> bool: ... + def match(self, node: _NL, results: _Results | None = ...) -> bool: ... + def match_seq(self, nodes: List[_NL], results: _Results | None = ...) -> bool: ... def generate_matches(self, nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ... class LeafPattern(BasePattern): - def __init__(self, type: Optional[int] = ..., content: Optional[str] = ..., name: Optional[str] = ...) -> None: ... + def __init__(self, type: int | None = ..., content: str | None = ..., name: str | None = ...) -> None: ... class NodePattern(BasePattern): wildcards: bool - def __init__(self, type: Optional[int] = ..., content: Optional[str] = ..., name: Optional[str] = ...) -> None: ... + def __init__(self, type: int | None = ..., content: str | None = ..., name: str | None = ...) -> None: ... class WildcardPattern(BasePattern): min: int max: int - def __init__(self, content: Optional[str] = ..., min: int = ..., max: int = ..., name: Optional[str] = ...) -> None: ... + def __init__(self, content: str | None = ..., min: int = ..., max: int = ..., name: str | None = ...) -> None: ... class NegatedPattern(BasePattern): - def __init__(self, content: Optional[str] = ...) -> None: ... + def __init__(self, content: str | None = ...) -> None: ... def generate_matches(patterns: List[BasePattern], nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ... diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 1e575a64856a..b21ccf17c9c6 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -77,17 +77,17 @@ CHAR_MAX: int class Error(Exception): ... -def setlocale(category: int, locale: Union[_str, Iterable[_str], None] = ...) -> _str: ... -def localeconv() -> Mapping[_str, Union[int, _str, List[int]]]: ... +def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... +def localeconv() -> Mapping[_str, int | _str | List[int]]: ... def nl_langinfo(__key: int) -> _str: ... -def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> Tuple[Optional[_str], Optional[_str]]: ... +def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> Tuple[_str | None, _str | None]: ... def getlocale(category: int = ...) -> Sequence[_str]: ... def getpreferredencoding(do_setlocale: bool = ...) -> _str: ... def normalize(localename: _str) -> _str: ... def resetlocale(category: int = ...) -> None: ... def strcoll(string1: _str, string2: _str) -> int: ... def strxfrm(string: _str) -> _str: ... -def format(percent: _str, value: Union[float, Decimal], grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... +def format(percent: _str, value: float | Decimal, grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... if sys.version_info >= (3, 7): def format_string(f: _str, val: Any, grouping: bool = ..., monetary: bool = ...) -> _str: ... @@ -95,7 +95,7 @@ if sys.version_info >= (3, 7): else: def format_string(f: _str, val: Any, grouping: bool = ...) -> _str: ... -def currency(val: Union[int, float, Decimal], symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ... +def currency(val: int | float | Decimal, symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ... def delocalize(string: _str) -> _str: ... def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 1f16015dc0ec..922d6105e9a5 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -20,7 +20,7 @@ raiseExceptions: bool logThreads: bool logMultiprocessing: bool logProcesses: bool -_srcfile: Optional[str] +_srcfile: str | None def currentframe() -> FrameType: ... @@ -38,9 +38,9 @@ class Manager(object): # undocumented root: RootLogger disable: int emittedNoHandlerWarning: bool - loggerDict: dict[str, Union[Logger, PlaceHolder]] - loggerClass: Optional[Type[Logger]] - logRecordFactory: Optional[Callable[..., LogRecord]] + loggerDict: dict[str, Logger | PlaceHolder] + loggerClass: Type[Logger] | None + logRecordFactory: Callable[..., LogRecord] | None def __init__(self, rootnode: RootLogger) -> None: ... def getLogger(self, name: str) -> Logger: ... def setLoggerClass(self, klass: Type[Logger]) -> None: ... @@ -49,7 +49,7 @@ class Manager(object): # undocumented class Logger(Filterer): name: str # undocumented level: int # undocumented - parent: Optional[Logger] # undocumented + parent: Logger | None # undocumented propagate: bool handlers: list[Handler] # undocumented disabled: bool # undocumented @@ -68,7 +68,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def info( self, @@ -77,7 +77,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def warning( self, @@ -86,7 +86,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def warn( self, @@ -95,7 +95,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def error( self, @@ -104,7 +104,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def exception( self, @@ -113,7 +113,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def critical( self, @@ -122,7 +122,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def log( self, @@ -132,15 +132,15 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def _log( self, level: int, msg: Any, args: _ArgsType, - exc_info: Optional[_ExcInfoType] = ..., - extra: Optional[dict[str, Any]] = ..., + exc_info: _ExcInfoType | None = ..., + extra: dict[str, Any] | None = ..., stack_info: bool = ..., stacklevel: int = ..., ) -> None: ... # undocumented @@ -151,7 +151,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def info( self, @@ -159,7 +159,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def warning( self, @@ -167,7 +167,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def warn( self, @@ -175,7 +175,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def error( self, @@ -183,7 +183,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def critical( self, @@ -191,7 +191,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def log( self, @@ -200,7 +200,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def exception( self, @@ -208,15 +208,15 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def _log( self, level: int, msg: Any, args: _ArgsType, - exc_info: Optional[_ExcInfoType] = ..., - extra: Optional[dict[str, Any]] = ..., + exc_info: _ExcInfoType | None = ..., + extra: dict[str, Any] | None = ..., stack_info: bool = ..., ) -> None: ... # undocumented fatal = critical @@ -224,9 +224,9 @@ class Logger(Filterer): def addHandler(self, hdlr: Handler) -> None: ... def removeHandler(self, hdlr: Handler) -> None: ... if sys.version_info >= (3, 8): - def findCaller(self, stack_info: bool = ..., stacklevel: int = ...) -> tuple[str, int, str, Optional[str]]: ... + def findCaller(self, stack_info: bool = ..., stacklevel: int = ...) -> tuple[str, int, str, str | None]: ... else: - def findCaller(self, stack_info: bool = ...) -> tuple[str, int, str, Optional[str]]: ... + def findCaller(self, stack_info: bool = ...) -> tuple[str, int, str, str | None]: ... def handle(self, record: LogRecord) -> None: ... def makeRecord( self, @@ -236,10 +236,10 @@ class Logger(Filterer): lno: int, msg: Any, args: _ArgsType, - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., - extra: Optional[Mapping[str, Any]] = ..., - sinfo: Optional[str] = ..., + exc_info: _SysExcInfoType | None, + func: str | None = ..., + extra: Mapping[str, Any] | None = ..., + sinfo: str | None = ..., ) -> LogRecord: ... def hasHandlers(self) -> bool: ... def callHandlers(self, record: LogRecord) -> None: ... # undocumented @@ -255,9 +255,9 @@ NOTSET: int class Handler(Filterer): level: int # undocumented - formatter: Optional[Formatter] # undocumented - lock: Optional[threading.Lock] # undocumented - name: Optional[str] # undocumented + formatter: Formatter | None # undocumented + lock: threading.Lock | None # undocumented + name: str | None # undocumented def __init__(self, level: _Level = ...) -> None: ... def get_name(self) -> str: ... # undocumented def set_name(self, name: str) -> None: ... # undocumented @@ -265,7 +265,7 @@ class Handler(Filterer): def acquire(self) -> None: ... def release(self) -> None: ... def setLevel(self, level: _Level) -> None: ... - def setFormatter(self, fmt: Optional[Formatter]) -> None: ... + def setFormatter(self, fmt: Formatter | None) -> None: ... def filter(self, record: LogRecord) -> bool: ... def flush(self) -> None: ... def close(self) -> None: ... @@ -275,24 +275,24 @@ class Handler(Filterer): def emit(self, record: LogRecord) -> None: ... class Formatter: - converter: Callable[[Optional[float]], struct_time] - _fmt: Optional[str] # undocumented - datefmt: Optional[str] # undocumented + converter: Callable[[float | None], struct_time] + _fmt: str | None # undocumented + datefmt: str | None # undocumented _style: PercentStyle # undocumented default_time_format: str if sys.version_info >= (3, 9): - default_msec_format: Optional[str] + default_msec_format: str | None else: default_msec_format: str if sys.version_info >= (3, 8): def __init__( - self, fmt: Optional[str] = ..., datefmt: Optional[str] = ..., style: _FormatStyle = ..., validate: bool = ... + self, fmt: str | None = ..., datefmt: str | None = ..., style: _FormatStyle = ..., validate: bool = ... ) -> None: ... else: - def __init__(self, fmt: Optional[str] = ..., datefmt: Optional[str] = ..., style: _FormatStyle = ...) -> None: ... + def __init__(self, fmt: str | None = ..., datefmt: str | None = ..., style: _FormatStyle = ...) -> None: ... def format(self, record: LogRecord) -> str: ... - def formatTime(self, record: LogRecord, datefmt: Optional[str] = ...) -> str: ... + def formatTime(self, record: LogRecord, datefmt: str | None = ...) -> str: ... def formatException(self, ei: _SysExcInfoType) -> str: ... def formatMessage(self, record: LogRecord) -> str: ... # undocumented def formatStack(self, stack_info: str) -> str: ... @@ -300,7 +300,7 @@ class Formatter: class BufferingFormatter: linefmt: Formatter - def __init__(self, linefmt: Optional[Formatter] = ...) -> None: ... + def __init__(self, linefmt: Formatter | None = ...) -> None: ... def formatHeader(self, records: Sequence[LogRecord]) -> str: ... def formatFooter(self, records: Sequence[LogRecord]) -> str: ... def format(self, records: Sequence[LogRecord]) -> str: ... @@ -317,8 +317,8 @@ class LogRecord: args: _ArgsType | None asctime: str created: float - exc_info: Optional[_SysExcInfoType] - exc_text: Optional[str] + exc_info: _SysExcInfoType | None + exc_text: str | None filename: str funcName: str levelname: str @@ -330,12 +330,12 @@ class LogRecord: msg: str name: str pathname: str - process: Optional[int] - processName: Optional[str] + process: int | None + processName: str | None relativeCreated: float - stack_info: Optional[str] - thread: Optional[int] - threadName: Optional[str] + stack_info: str | None + thread: int | None + threadName: str | None def __init__( self, name: str, @@ -344,9 +344,9 @@ class LogRecord: lineno: int, msg: Any, args: _ArgsType | None, - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., - sinfo: Optional[str] = ..., + exc_info: _SysExcInfoType | None, + func: str | None = ..., + sinfo: str | None = ..., ) -> None: ... def getMessage(self) -> str: ... @@ -354,8 +354,8 @@ class LoggerAdapter: logger: Logger | LoggerAdapter manager: Manager # undocumented if sys.version_info >= (3, 10): - extra: Optional[Mapping[str, Any]] - def __init__(self, logger: Logger | LoggerAdapter, extra: Optional[Mapping[str, Any]]) -> None: ... + extra: Mapping[str, Any] | None + def __init__(self, logger: Logger | LoggerAdapter, extra: Mapping[str, Any] | None) -> None: ... else: extra: Mapping[str, Any] def __init__(self, logger: Logger | LoggerAdapter, extra: Mapping[str, Any]) -> None: ... @@ -368,7 +368,7 @@ class LoggerAdapter: exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def info( @@ -378,7 +378,7 @@ class LoggerAdapter: exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warning( @@ -388,7 +388,7 @@ class LoggerAdapter: exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warn( @@ -398,7 +398,7 @@ class LoggerAdapter: exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def error( @@ -408,7 +408,7 @@ class LoggerAdapter: exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def exception( @@ -418,7 +418,7 @@ class LoggerAdapter: exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def critical( @@ -428,7 +428,7 @@ class LoggerAdapter: exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def log( @@ -439,7 +439,7 @@ class LoggerAdapter: exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... else: @@ -449,7 +449,7 @@ class LoggerAdapter: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def info( @@ -458,7 +458,7 @@ class LoggerAdapter: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warning( @@ -467,7 +467,7 @@ class LoggerAdapter: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warn( @@ -476,7 +476,7 @@ class LoggerAdapter: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def error( @@ -485,7 +485,7 @@ class LoggerAdapter: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def exception( @@ -494,7 +494,7 @@ class LoggerAdapter: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def critical( @@ -503,7 +503,7 @@ class LoggerAdapter: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def log( @@ -513,7 +513,7 @@ class LoggerAdapter: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def isEnabledFor(self, level: int) -> bool: ... @@ -525,14 +525,14 @@ class LoggerAdapter: level: int, msg: Any, args: _ArgsType, - exc_info: Optional[_ExcInfoType] = ..., - extra: Optional[dict[str, Any]] = ..., + exc_info: _ExcInfoType | None = ..., + extra: dict[str, Any] | None = ..., stack_info: bool = ..., ) -> None: ... # undocumented @property def name(self) -> str: ... # undocumented -def getLogger(name: Optional[str] = ...) -> Logger: ... +def getLogger(name: str | None = ...) -> Logger: ... def getLoggerClass() -> Type[Logger]: ... def getLogRecordFactory() -> Callable[..., LogRecord]: ... @@ -543,7 +543,7 @@ if sys.version_info >= (3, 8): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def info( msg: Any, @@ -551,7 +551,7 @@ if sys.version_info >= (3, 8): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def warning( msg: Any, @@ -559,7 +559,7 @@ if sys.version_info >= (3, 8): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def warn( msg: Any, @@ -567,7 +567,7 @@ if sys.version_info >= (3, 8): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def error( msg: Any, @@ -575,7 +575,7 @@ if sys.version_info >= (3, 8): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def critical( msg: Any, @@ -583,7 +583,7 @@ if sys.version_info >= (3, 8): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def exception( msg: Any, @@ -591,7 +591,7 @@ if sys.version_info >= (3, 8): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... def log( level: int, @@ -600,30 +600,30 @@ if sys.version_info >= (3, 8): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... else: def debug( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[dict[str, Any]] = ... + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def info( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[dict[str, Any]] = ... + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def warning( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[dict[str, Any]] = ... + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def warn( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[dict[str, Any]] = ... + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def error( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[dict[str, Any]] = ... + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def critical( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[dict[str, Any]] = ... + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def exception( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[dict[str, Any]] = ... + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def log( level: int, @@ -631,7 +631,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., ) -> None: ... fatal = critical @@ -649,44 +649,44 @@ def makeLogRecord(dict: Mapping[str, Any]) -> LogRecord: ... if sys.version_info >= (3, 9): def basicConfig( *, - filename: Optional[StrPath] = ..., + filename: StrPath | None = ..., filemode: str = ..., format: str = ..., - datefmt: Optional[str] = ..., + datefmt: str | None = ..., style: _FormatStyle = ..., - level: Optional[_Level] = ..., - stream: Optional[SupportsWrite[str]] = ..., - handlers: Optional[Iterable[Handler]] = ..., - force: Optional[bool] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + level: _Level | None = ..., + stream: SupportsWrite[str] | None = ..., + handlers: Iterable[Handler] | None = ..., + force: bool | None = ..., + encoding: str | None = ..., + errors: str | None = ..., ) -> None: ... elif sys.version_info >= (3, 8): def basicConfig( *, - filename: Optional[StrPath] = ..., + filename: StrPath | None = ..., filemode: str = ..., format: str = ..., - datefmt: Optional[str] = ..., + datefmt: str | None = ..., style: _FormatStyle = ..., - level: Optional[_Level] = ..., - stream: Optional[SupportsWrite[str]] = ..., - handlers: Optional[Iterable[Handler]] = ..., + level: _Level | None = ..., + stream: SupportsWrite[str] | None = ..., + handlers: Iterable[Handler] | None = ..., force: bool = ..., ) -> None: ... else: def basicConfig( *, - filename: Optional[StrPath] = ..., + filename: StrPath | None = ..., filemode: str = ..., format: str = ..., - datefmt: Optional[str] = ..., + datefmt: str | None = ..., style: _FormatStyle = ..., - level: Optional[_Level] = ..., - stream: Optional[SupportsWrite[str]] = ..., - handlers: Optional[Iterable[Handler]] = ..., + level: _Level | None = ..., + stream: SupportsWrite[str] | None = ..., + handlers: Iterable[Handler] | None = ..., ) -> None: ... def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index ed79f48aa94c..5adee0b084d7 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -23,19 +23,19 @@ def dictConfig(config: dict[str, Any]) -> None: ... if sys.version_info >= (3, 10): def fileConfig( - fname: Union[_Path, IO[str], RawConfigParser], - defaults: Optional[dict[str, str]] = ..., + fname: _Path | IO[str] | RawConfigParser, + defaults: dict[str, str] | None = ..., disable_existing_loggers: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., ) -> None: ... else: def fileConfig( - fname: Union[_Path, IO[str], RawConfigParser], - defaults: Optional[dict[str, str]] = ..., + fname: _Path | IO[str] | RawConfigParser, + defaults: dict[str, str] | None = ..., disable_existing_loggers: bool = ..., ) -> None: ... def valid_ident(s: str) -> Literal[True]: ... # undocumented -def listen(port: int = ..., verify: Optional[Callable[[bytes], Optional[bytes]]] = ...) -> Thread: ... +def listen(port: int = ..., verify: Callable[[bytes], bytes | None] | None = ...) -> Thread: ... def stopListening() -> None: ... diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index 9f0755c2a966..3bb7e4ec6fcd 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -28,24 +28,24 @@ class WatchedFileHandler(FileHandler): self, filename: StrPath, mode: str = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., delay: bool = ..., - errors: Optional[str] = ..., + errors: str | None = ..., ) -> None: ... else: - def __init__(self, filename: StrPath, mode: str = ..., encoding: Optional[str] = ..., delay: bool = ...) -> None: ... + def __init__(self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ...) -> None: ... def _statstream(self) -> None: ... # undocumented def reopenIfNeeded(self) -> None: ... class BaseRotatingHandler(FileHandler): - namer: Optional[Callable[[str], str]] - rotator: Optional[Callable[[str, str], None]] + namer: Callable[[str], str] | None + rotator: Callable[[str, str], None] | None if sys.version_info >= (3, 9): def __init__( - self, filename: StrPath, mode: str, encoding: Optional[str] = ..., delay: bool = ..., errors: Optional[str] = ... + self, filename: StrPath, mode: str, encoding: str | None = ..., delay: bool = ..., errors: str | None = ... ) -> None: ... else: - def __init__(self, filename: StrPath, mode: str, encoding: Optional[str] = ..., delay: bool = ...) -> None: ... + def __init__(self, filename: StrPath, mode: str, encoding: str | None = ..., delay: bool = ...) -> None: ... def rotation_filename(self, default_name: str) -> str: ... def rotate(self, source: str, dest: str) -> None: ... @@ -59,9 +59,9 @@ class RotatingFileHandler(BaseRotatingHandler): mode: str = ..., maxBytes: int = ..., backupCount: int = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., delay: bool = ..., - errors: Optional[str] = ..., + errors: str | None = ..., ) -> None: ... else: def __init__( @@ -70,7 +70,7 @@ class RotatingFileHandler(BaseRotatingHandler): mode: str = ..., maxBytes: int = ..., backupCount: int = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., delay: bool = ..., ) -> None: ... def doRollover(self) -> None: ... @@ -80,7 +80,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler): when: str # undocumented backupCount: str # undocumented utc: bool # undocumented - atTime: Optional[datetime.datetime] # undocumented + atTime: datetime.datetime | None # undocumented interval: int # undocumented suffix: str # undocumented dayOfWeek: int # undocumented @@ -93,11 +93,11 @@ class TimedRotatingFileHandler(BaseRotatingHandler): when: str = ..., interval: int = ..., backupCount: int = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., delay: bool = ..., utc: bool = ..., - atTime: Optional[datetime.datetime] = ..., - errors: Optional[str] = ..., + atTime: datetime.datetime | None = ..., + errors: str | None = ..., ) -> None: ... else: def __init__( @@ -106,10 +106,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler): when: str = ..., interval: int = ..., backupCount: int = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., delay: bool = ..., utc: bool = ..., - atTime: Optional[datetime.datetime] = ..., + atTime: datetime.datetime | None = ..., ) -> None: ... def doRollover(self) -> None: ... def shouldRollover(self, record: LogRecord) -> int: ... # undocumented @@ -118,15 +118,15 @@ class TimedRotatingFileHandler(BaseRotatingHandler): class SocketHandler(Handler): host: str # undocumented - port: Optional[int] # undocumented - address: Union[tuple[str, int], str] # undocumented - sock: Optional[socket] # undocumented + port: int | None # undocumented + address: tuple[str, int] | str # undocumented + sock: socket | None # undocumented closeOnError: bool # undocumented - retryTime: Optional[float] # undocumented + retryTime: float | None # undocumented retryStart: float # undocumented retryFactor: float # undocumented retryMax: float # undocumented - def __init__(self, host: str, port: Optional[int]) -> None: ... + def __init__(self, host: str, port: int | None) -> None: ... def makeSocket(self, timeout: float = ...) -> socket: ... # timeout is undocumented def makePickle(self, record: LogRecord) -> bytes: ... def send(self, s: bytes) -> None: ... @@ -181,13 +181,13 @@ class SysLogHandler(Handler): facility_names: ClassVar[dict[str, int]] # undocumented priority_map: ClassVar[dict[str, str]] # undocumented def __init__( - self, address: Union[tuple[str, int], str] = ..., facility: int = ..., socktype: Optional[SocketKind] = ... + self, address: tuple[str, int] | str = ..., facility: int = ..., socktype: SocketKind | None = ... ) -> None: ... - def encodePriority(self, facility: Union[int, str], priority: Union[int, str]) -> int: ... + def encodePriority(self, facility: int | str, priority: int | str) -> int: ... def mapPriority(self, levelName: str) -> str: ... class NTEventLogHandler(Handler): - def __init__(self, appname: str, dllname: Optional[str] = ..., logtype: str = ...) -> None: ... + def __init__(self, appname: str, dllname: str | None = ..., logtype: str = ...) -> None: ... def getEventCategory(self, record: LogRecord) -> int: ... # TODO correct return value? def getEventType(self, record: LogRecord) -> int: ... @@ -195,23 +195,23 @@ class NTEventLogHandler(Handler): class SMTPHandler(Handler): mailhost: str # undocumented - mailport: Optional[int] # undocumented - username: Optional[str] # undocumented + mailport: int | None # undocumented + username: str | None # undocumented # password only exists as an attribute if passed credentials is a tuple or list password: str # undocumented fromaddr: str # undocumented toaddrs: list[str] # undocumented subject: str # undocumented - secure: Union[tuple[()], tuple[str], tuple[str, str], None] # undocumented + secure: tuple[()] | tuple[str] | tuple[str, str] | None # undocumented timeout: float # undocumented def __init__( self, - mailhost: Union[str, tuple[str, int]], + mailhost: str | tuple[str, int], fromaddr: str, - toaddrs: Union[str, list[str]], + toaddrs: str | list[str], subject: str, - credentials: Optional[tuple[str, str]] = ..., - secure: Union[tuple[()], tuple[str], tuple[str, str], None] = ..., + credentials: tuple[str, str] | None = ..., + secure: tuple[()] | tuple[str] | tuple[str, str] | None = ..., timeout: float = ..., ) -> None: ... def getSubject(self, record: LogRecord) -> str: ... @@ -224,28 +224,28 @@ class BufferingHandler(Handler): class MemoryHandler(BufferingHandler): flushLevel: int # undocumented - target: Optional[Handler] # undocumented + target: Handler | None # undocumented flushOnClose: bool # undocumented def __init__( - self, capacity: int, flushLevel: int = ..., target: Optional[Handler] = ..., flushOnClose: bool = ... + self, capacity: int, flushLevel: int = ..., target: Handler | None = ..., flushOnClose: bool = ... ) -> None: ... - def setTarget(self, target: Optional[Handler]) -> None: ... + def setTarget(self, target: Handler | None) -> None: ... class HTTPHandler(Handler): host: str # undocumented url: str # undocumented method: str # undocumented secure: bool # undocumented - credentials: Optional[tuple[str, str]] # undocumented - context: Optional[ssl.SSLContext] # undocumented + credentials: tuple[str, str] | None # undocumented + context: ssl.SSLContext | None # undocumented def __init__( self, host: str, url: str, method: str = ..., secure: bool = ..., - credentials: Optional[tuple[str, str]] = ..., - context: Optional[ssl.SSLContext] = ..., + credentials: tuple[str, str] | None = ..., + context: ssl.SSLContext | None = ..., ) -> None: ... def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ... if sys.version_info >= (3, 9): @@ -253,8 +253,8 @@ class HTTPHandler(Handler): class QueueHandler(Handler): if sys.version_info >= (3, 7): - queue: Union[SimpleQueue[Any], Queue[Any]] # undocumented - def __init__(self, queue: Union[SimpleQueue[Any], Queue[Any]]) -> None: ... + queue: SimpleQueue[Any] | Queue[Any] # undocumented + def __init__(self, queue: SimpleQueue[Any] | Queue[Any]) -> None: ... else: queue: Queue[Any] # undocumented def __init__(self, queue: Queue[Any]) -> None: ... @@ -265,9 +265,9 @@ class QueueListener: handlers: tuple[Handler] # undocumented respect_handler_level: bool # undocumented if sys.version_info >= (3, 7): - queue: Union[SimpleQueue[Any], Queue[Any]] # undocumented + queue: SimpleQueue[Any] | Queue[Any] # undocumented def __init__( - self, queue: Union[SimpleQueue[Any], Queue[Any]], *handlers: Handler, respect_handler_level: bool = ... + self, queue: SimpleQueue[Any] | Queue[Any], *handlers: Handler, respect_handler_level: bool = ... ) -> None: ... else: queue: Queue[Any] # undocumented diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index 1e4efd42a1a0..763f2f7bf544 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -42,7 +42,7 @@ PRESET_EXTREME: int # from _lzma.c class LZMADecompressor(object): def __init__( - self, format: Optional[int] = ..., memlimit: Optional[int] = ..., filters: Optional[_FilterChain] = ... + self, format: int | None = ..., memlimit: int | None = ..., filters: _FilterChain | None = ... ) -> None: ... def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... @property @@ -57,7 +57,7 @@ class LZMADecompressor(object): # from _lzma.c class LZMACompressor(object): def __init__( - self, format: Optional[int] = ..., check: int = ..., preset: Optional[int] = ..., filters: Optional[_FilterChain] = ... + self, format: int | None = ..., check: int = ..., preset: int | None = ..., filters: _FilterChain | None = ... ) -> None: ... def compress(self, __data: bytes) -> bytes: ... def flush(self) -> bytes: ... @@ -67,13 +67,13 @@ class LZMAError(Exception): ... class LZMAFile(io.BufferedIOBase, IO[bytes]): def __init__( self, - filename: Optional[_PathOrFile] = ..., + filename: _PathOrFile | None = ..., mode: str = ..., *, - format: Optional[int] = ..., + format: int | None = ..., check: int = ..., - preset: Optional[int] = ..., - filters: Optional[_FilterChain] = ..., + preset: int | None = ..., + filters: _FilterChain | None = ..., ) -> None: ... def __enter__(self: Self) -> Self: ... def close(self) -> None: ... @@ -84,9 +84,9 @@ class LZMAFile(io.BufferedIOBase, IO[bytes]): def readable(self) -> bool: ... def writable(self) -> bool: ... def peek(self, size: int = ...) -> bytes: ... - def read(self, size: Optional[int] = ...) -> bytes: ... + def read(self, size: int | None = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... - def readline(self, size: Optional[int] = ...) -> bytes: ... + def readline(self, size: int | None = ...) -> bytes: ... def write(self, data: ReadableBuffer) -> int: ... def seek(self, offset: int, whence: int = ...) -> int: ... def tell(self) -> int: ... @@ -96,10 +96,10 @@ def open( filename: _PathOrFile, mode: Literal["r", "rb"] = ..., *, - format: Optional[int] = ..., + format: int | None = ..., check: Literal[-1] = ..., preset: None = ..., - filters: Optional[_FilterChain] = ..., + filters: _FilterChain | None = ..., encoding: None = ..., errors: None = ..., newline: None = ..., @@ -109,10 +109,10 @@ def open( filename: _PathOrFile, mode: _OpenBinaryWritingMode, *, - format: Optional[int] = ..., + format: int | None = ..., check: int = ..., - preset: Optional[int] = ..., - filters: Optional[_FilterChain] = ..., + preset: int | None = ..., + filters: _FilterChain | None = ..., encoding: None = ..., errors: None = ..., newline: None = ..., @@ -122,42 +122,42 @@ def open( filename: StrOrBytesPath, mode: Literal["rt"], *, - format: Optional[int] = ..., + format: int | None = ..., check: Literal[-1] = ..., preset: None = ..., - filters: Optional[_FilterChain] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + filters: _FilterChain | None = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> TextIO: ... @overload def open( filename: StrOrBytesPath, mode: _OpenTextWritingMode, *, - format: Optional[int] = ..., + format: int | None = ..., check: int = ..., - preset: Optional[int] = ..., - filters: Optional[_FilterChain] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + preset: int | None = ..., + filters: _FilterChain | None = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> TextIO: ... @overload def open( filename: _PathOrFile, mode: str, *, - format: Optional[int] = ..., + format: int | None = ..., check: int = ..., - preset: Optional[int] = ..., - filters: Optional[_FilterChain] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., -) -> Union[LZMAFile, TextIO]: ... + preset: int | None = ..., + filters: _FilterChain | None = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., +) -> LZMAFile | TextIO: ... def compress( - data: bytes, format: int = ..., check: int = ..., preset: Optional[int] = ..., filters: Optional[_FilterChain] = ... + data: bytes, format: int = ..., check: int = ..., preset: int | None = ..., filters: _FilterChain | None = ... ) -> bytes: ... -def decompress(data: bytes, format: int = ..., memlimit: Optional[int] = ..., filters: Optional[_FilterChain] = ...) -> bytes: ... +def decompress(data: bytes, format: int = ..., memlimit: int | None = ..., filters: _FilterChain | None = ...) -> bytes: ... def is_check_supported(__check_id: int) -> bool: ... diff --git a/stdlib/macpath.pyi b/stdlib/macpath.pyi index ecb4e9146451..5e88670a0012 100644 --- a/stdlib/macpath.pyi +++ b/stdlib/macpath.pyi @@ -34,7 +34,7 @@ from posixpath import ( ) from typing import AnyStr, Optional, Tuple, overload -altsep: Optional[str] +altsep: str | None @overload def basename(s: PathLike[AnyStr]) -> AnyStr: ... diff --git a/stdlib/macurl2path.pyi b/stdlib/macurl2path.pyi index 025820b44e89..532d464d81ab 100644 --- a/stdlib/macurl2path.pyi +++ b/stdlib/macurl2path.pyi @@ -2,4 +2,4 @@ from typing import Union def url2pathname(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ... -def _pncomp2url(component: Union[str, bytes]) -> str: ... +def _pncomp2url(component: str | bytes) -> str: ... diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index a5e9322347d6..b8a28d42bc77 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -41,10 +41,10 @@ linesep: bytes class Mailbox(Generic[_MessageT]): - _path: Union[bytes, str] # undocumented - _factory: Optional[Callable[[IO[Any]], _MessageT]] # undocumented + _path: bytes | str # undocumented + _factory: Callable[[IO[Any]], _MessageT] | None # undocumented def __init__( - self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ... + self, path: StrOrBytesPath, factory: Callable[[IO[Any]], _MessageT] | None = ..., create: bool = ... ) -> None: ... def add(self, message: _MessageData) -> str: ... def remove(self, key: str) -> None: ... @@ -52,9 +52,9 @@ class Mailbox(Generic[_MessageT]): def discard(self, key: str) -> None: ... def __setitem__(self, key: str, message: _MessageData) -> None: ... @overload - def get(self, key: str, default: None = ...) -> Optional[_MessageT]: ... + def get(self, key: str, default: None = ...) -> _MessageT | None: ... @overload - def get(self, key: str, default: _T) -> Union[_MessageT, _T]: ... + def get(self, key: str, default: _T) -> _MessageT | _T: ... def __getitem__(self, key: str) -> _MessageT: ... def get_message(self, key: str) -> _MessageT: ... def get_string(self, key: str) -> str: ... @@ -72,11 +72,11 @@ class Mailbox(Generic[_MessageT]): def __len__(self) -> int: ... def clear(self) -> None: ... @overload - def pop(self, key: str, default: None = ...) -> Optional[_MessageT]: ... + def pop(self, key: str, default: None = ...) -> _MessageT | None: ... @overload - def pop(self, key: str, default: _T = ...) -> Union[_MessageT, _T]: ... + def pop(self, key: str, default: _T = ...) -> _MessageT | _T: ... def popitem(self) -> Tuple[str, _MessageT]: ... - def update(self, arg: Optional[Union[_HasIteritems, _HasItems, Iterable[Tuple[str, _MessageData]]]] = ...) -> None: ... + def update(self, arg: _HasIteritems | _HasItems | Iterable[Tuple[str, _MessageData]] | None = ...) -> None: ... def flush(self) -> None: ... def lock(self) -> None: ... def unlock(self) -> None: ... @@ -88,7 +88,7 @@ class Maildir(Mailbox[MaildirMessage]): colon: str def __init__( - self, dirname: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ... + self, dirname: StrOrBytesPath, factory: Callable[[IO[Any]], MaildirMessage] | None = ..., create: bool = ... ) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... @@ -96,7 +96,7 @@ class Maildir(Mailbox[MaildirMessage]): def add_folder(self, folder: str) -> Maildir: ... def remove_folder(self, folder: str) -> None: ... def clean(self) -> None: ... - def next(self) -> Optional[str]: ... + def next(self) -> str | None: ... class _singlefileMailbox(Mailbox[_MessageT]): ... @@ -107,17 +107,17 @@ class _mboxMMDF(_singlefileMailbox[_MessageT]): class mbox(_mboxMMDF[mboxMessage]): def __init__( - self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ... + self, path: StrOrBytesPath, factory: Callable[[IO[Any]], mboxMessage] | None = ..., create: bool = ... ) -> None: ... class MMDF(_mboxMMDF[MMDFMessage]): def __init__( - self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ... + self, path: StrOrBytesPath, factory: Callable[[IO[Any]], MMDFMessage] | None = ..., create: bool = ... ) -> None: ... class MH(Mailbox[MHMessage]): def __init__( - self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ... + self, path: StrOrBytesPath, factory: Callable[[IO[Any]], MHMessage] | None = ..., create: bool = ... ) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... @@ -130,13 +130,13 @@ class MH(Mailbox[MHMessage]): class Babyl(_singlefileMailbox[BabylMessage]): def __init__( - self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ... + self, path: StrOrBytesPath, factory: Callable[[IO[Any]], BabylMessage] | None = ..., create: bool = ... ) -> None: ... def get_file(self, key: str) -> IO[bytes]: ... def get_labels(self) -> List[str]: ... class Message(email.message.Message): - def __init__(self, message: Optional[_MessageData] = ...) -> None: ... + def __init__(self, message: _MessageData | None = ...) -> None: ... class MaildirMessage(Message): def get_subdir(self) -> str: ... @@ -153,7 +153,7 @@ class MaildirMessage(Message): class _mboxMMDFMessage(Message): def get_from(self) -> str: ... def set_from( - self, from_: str, time_: Optional[Union[bool, Tuple[int, int, int, int, int, int, int, int, int]]] = ... + self, from_: str, time_: bool | Tuple[int, int, int, int, int, int, int, int, int] | None = ... ) -> None: ... def get_flags(self) -> str: ... def set_flags(self, flags: Iterable[str]) -> None: ... @@ -180,18 +180,18 @@ class BabylMessage(Message): class MMDFMessage(_mboxMMDFMessage): ... class _ProxyFile(Generic[AnyStr]): - def __init__(self, f: IO[AnyStr], pos: Optional[int] = ...) -> None: ... - def read(self, size: Optional[int] = ...) -> AnyStr: ... - def read1(self, size: Optional[int] = ...) -> AnyStr: ... - def readline(self, size: Optional[int] = ...) -> AnyStr: ... - def readlines(self, sizehint: Optional[int] = ...) -> List[AnyStr]: ... + def __init__(self, f: IO[AnyStr], pos: int | None = ...) -> None: ... + def read(self, size: int | None = ...) -> AnyStr: ... + def read1(self, size: int | None = ...) -> AnyStr: ... + def readline(self, size: int | None = ...) -> AnyStr: ... + def readlines(self, sizehint: int | None = ...) -> List[AnyStr]: ... def __iter__(self) -> Iterator[AnyStr]: ... def tell(self) -> int: ... def seek(self, offset: int, whence: int = ...) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... @@ -203,7 +203,7 @@ class _ProxyFile(Generic[AnyStr]): def __class_getitem__(cls, item: Any) -> GenericAlias: ... class _PartialFile(_ProxyFile[AnyStr]): - def __init__(self, f: IO[AnyStr], start: Optional[int] = ..., stop: Optional[int] = ...) -> None: ... + def __init__(self, f: IO[AnyStr], start: int | None = ..., stop: int | None = ...) -> None: ... class Error(Exception): ... class NoSuchMailboxError(Error): ... diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index a65cc3a329d3..1f4b8c65d1b2 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -4,5 +4,5 @@ _Cap = Dict[str, Union[str, int]] def findmatch( caps: Mapping[str, List[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... -) -> Tuple[Optional[str], Optional[_Cap]]: ... +) -> Tuple[str | None, _Cap | None]: ... def getcaps() -> Dict[str, List[_Cap]]: ... diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 9aa54504c571..a1023f71bfd2 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -74,7 +74,7 @@ if sys.version_info >= (3, 9): def nextafter(__x: SupportsFloat, __y: SupportsFloat) -> float: ... if sys.version_info >= (3, 8): - def perm(__n: int, __k: Optional[int] = ...) -> int: ... + def perm(__n: int, __k: int | None = ...) -> int: ... def pow(__x: SupportsFloat, __y: SupportsFloat) -> float: ... diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index d1b440647620..4156fe161be0 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -3,15 +3,15 @@ from _typeshed import StrPath from typing import IO, Dict, List, Optional, Sequence, Tuple if sys.version_info >= (3, 8): - def guess_type(url: StrPath, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... + def guess_type(url: StrPath, strict: bool = ...) -> Tuple[str | None, str | None]: ... else: - def guess_type(url: str, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... + def guess_type(url: str, strict: bool = ...) -> Tuple[str | None, str | None]: ... def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... -def guess_extension(type: str, strict: bool = ...) -> Optional[str]: ... -def init(files: Optional[Sequence[str]] = ...) -> None: ... -def read_mime_types(file: str) -> Optional[Dict[str, str]]: ... +def guess_extension(type: str, strict: bool = ...) -> str | None: ... +def init(files: Sequence[str] | None = ...) -> None: ... +def read_mime_types(file: str) -> Dict[str, str] | None: ... def add_type(type: str, ext: str, strict: bool = ...) -> None: ... inited: bool @@ -27,8 +27,8 @@ class MimeTypes: types_map: Tuple[Dict[str, str], Dict[str, str]] types_map_inv: Tuple[Dict[str, str], Dict[str, str]] def __init__(self, filenames: Tuple[str, ...] = ..., strict: bool = ...) -> None: ... - def guess_extension(self, type: str, strict: bool = ...) -> Optional[str]: ... - def guess_type(self, url: str, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... + def guess_extension(self, type: str, strict: bool = ...) -> str | None: ... + def guess_type(self, url: str, strict: bool = ...) -> Tuple[str | None, str | None]: ... def guess_all_extensions(self, type: str, strict: bool = ...) -> List[str]: ... def read(self, filename: str, strict: bool = ...) -> None: ... def readfp(self, fp: IO[str], strict: bool = ...) -> None: ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index b942ade9cab2..acecb1f51683 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -27,7 +27,7 @@ if sys.platform != "win32": class mmap(ContextManager[mmap], Iterable[int], Sized): if sys.platform == "win32": def __init__( - self, fileno: int, length: int, tagname: Optional[str] = ..., access: int = ..., offset: int = ... + self, fileno: int, length: int, tagname: str | None = ..., access: int = ..., offset: int = ... ) -> None: ... else: def __init__( @@ -52,13 +52,13 @@ class mmap(ContextManager[mmap], Iterable[int], Sized): def madvise(self, option: int, start: int = ..., length: int = ...) -> None: ... def find(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... def rfind(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def read(self, n: Optional[int] = ...) -> bytes: ... + def read(self, n: int | None = ...) -> bytes: ... def write(self, bytes: ReadableBuffer) -> int: ... @overload def __getitem__(self, index: int) -> int: ... @overload def __getitem__(self, index: slice) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> NoReturn: ... + def __delitem__(self, index: int | slice) -> NoReturn: ... @overload def __setitem__(self, index: int, object: int) -> None: ... @overload diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index 7cb715ce706c..335e7917b13b 100644 --- a/stdlib/modulefinder.pyi +++ b/stdlib/modulefinder.pyi @@ -18,7 +18,7 @@ replacePackageMap: Dict[str, str] # undocumented def ReplacePackage(oldname: str, newname: str) -> None: ... class Module: # undocumented - def __init__(self, name: str, file: Optional[str] = ..., path: Optional[str] = ...) -> None: ... + def __init__(self, name: str, file: str | None = ..., path: str | None = ...) -> None: ... def __repr__(self) -> str: ... class ModuleFinder: @@ -34,15 +34,15 @@ class ModuleFinder: if sys.version_info >= (3, 8): def __init__( self, - path: Optional[List[str]] = ..., + path: List[str] | None = ..., debug: int = ..., - excludes: Optional[Container[str]] = ..., - replace_paths: Optional[Sequence[Tuple[str, str]]] = ..., + excludes: Container[str] | None = ..., + replace_paths: Sequence[Tuple[str, str]] | None = ..., ) -> None: ... else: def __init__( self, - path: Optional[List[str]] = ..., + path: List[str] | None = ..., debug: int = ..., excludes: Container[str] = ..., replace_paths: Sequence[Tuple[str, str]] = ..., @@ -53,22 +53,22 @@ class ModuleFinder: def run_script(self, pathname: str) -> None: ... def load_file(self, pathname: str) -> None: ... # undocumented def import_hook( - self, name: str, caller: Optional[Module] = ..., fromlist: Optional[List[str]] = ..., level: int = ... - ) -> Optional[Module]: ... # undocumented - def determine_parent(self, caller: Optional[Module], level: int = ...) -> Optional[Module]: ... # undocumented + self, name: str, caller: Module | None = ..., fromlist: List[str] | None = ..., level: int = ... + ) -> Module | None: ... # undocumented + def determine_parent(self, caller: Module | None, level: int = ...) -> Module | None: ... # undocumented def find_head_package(self, parent: Module, name: str) -> Tuple[Module, str]: ... # undocumented def load_tail(self, q: Module, tail: str) -> Module: ... # undocumented def ensure_fromlist(self, m: Module, fromlist: Iterable[str], recursive: int = ...) -> None: ... # undocumented def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented - def import_module(self, partname: str, fqname: str, parent: Module) -> Optional[Module]: ... # undocumented + def import_module(self, partname: str, fqname: str, parent: Module) -> Module | None: ... # undocumented def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: Tuple[str, str, str]) -> Module: ... # undocumented def scan_opcodes(self, co: CodeType) -> Iterator[Tuple[str, Tuple[Any, ...]]]: ... # undocumented def scan_code(self, co: CodeType, m: Module) -> None: ... # undocumented def load_package(self, fqname: str, pathname: str) -> Module: ... # undocumented def add_module(self, fqname: str) -> Module: ... # undocumented def find_module( - self, name: str, path: Optional[str], parent: Optional[Module] = ... - ) -> Tuple[Optional[IO[Any]], Optional[str], Tuple[str, str, int]]: ... # undocumented + self, name: str, path: str | None, parent: Module | None = ... + ) -> Tuple[IO[Any] | None, str | None, Tuple[str, str, int]]: ... # undocumented def report(self) -> None: ... def any_missing(self) -> List[str]: ... # undocumented def any_missing_maybe(self) -> Tuple[List[str], List[str]]: ... # undocumented diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 0442ffaaec83..1b25db5b5ca9 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -32,10 +32,10 @@ if sys.platform == "win32": def create(self, db: _Database) -> None: ... class _Unspecified: ... def change_sequence( - seq: Sequence[Tuple[str, Optional[str], int]], + seq: Sequence[Tuple[str, str | None, int]], action: str, - seqno: Union[int, Type[_Unspecified]] = ..., - cond: Union[str, Type[_Unspecified]] = ..., + seqno: int | Type[_Unspecified] = ..., + cond: str | Type[_Unspecified] = ..., ) -> None: ... def add_data(db: _Database, table: str, values: Iterable[Tuple[Any, ...]]) -> None: ... def add_stream(db: _Database, name: str, path: str) -> None: ... @@ -63,11 +63,11 @@ if sys.platform == "win32": basedir: str physical: str logical: str - component: Optional[str] + component: str | None short_names: Set[str] ids: Set[str] keyfiles: Dict[str, str] - componentflags: Optional[int] + componentflags: int | None absolute: str def __init__( self, @@ -77,21 +77,21 @@ if sys.platform == "win32": physical: str, _logical: str, default: str, - componentflags: Optional[int] = ..., + componentflags: int | None = ..., ) -> None: ... def start_component( self, - component: Optional[str] = ..., - feature: Optional[Feature] = ..., - flags: Optional[int] = ..., - keyfile: Optional[str] = ..., - uuid: Optional[str] = ..., + component: str | None = ..., + feature: Feature | None = ..., + flags: int | None = ..., + keyfile: str | None = ..., + uuid: str | None = ..., ) -> None: ... def make_short(self, file: str) -> str: ... def add_file( - self, file: str, src: Optional[str] = ..., version: Optional[str] = ..., language: Optional[str] = ... + self, file: str, src: str | None = ..., version: str | None = ..., language: str | None = ... ) -> str: ... - def glob(self, pattern: str, exclude: Optional[Container[str]] = ...) -> List[str]: ... + def glob(self, pattern: str, exclude: Container[str] | None = ...) -> List[str]: ... def remove_pyc(self) -> None: ... class Binary: @@ -109,8 +109,8 @@ if sys.platform == "win32": desc: str, display: int, level: int = ..., - parent: Optional[Feature] = ..., - directory: Optional[str] = ..., + parent: Feature | None = ..., + directory: str | None = ..., attributes: int = ..., ) -> None: ... def set_current(self) -> None: ... @@ -119,7 +119,7 @@ if sys.platform == "win32": dlg: Dialog name: str def __init__(self, dlg: Dialog, name: str) -> None: ... - def event(self, event: str, argument: str, condition: str = ..., ordering: Optional[int] = ...) -> None: ... + def event(self, event: str, argument: str, condition: str = ..., ordering: int | None = ...) -> None: ... def mapping(self, event: str, attribute: str) -> None: ... def condition(self, action: str, condition: str) -> None: ... class RadioButtonGroup(Control): @@ -127,7 +127,7 @@ if sys.platform == "win32": property: str index: int def __init__(self, dlg: Dialog, name: str, property: str) -> None: ... - def add(self, name: str, x: int, y: int, w: int, h: int, text: str, value: Optional[str] = ...) -> None: ... + def add(self, name: str, x: int, y: int, w: int, h: int, text: str, value: str | None = ...) -> None: ... class Dialog: db: _Database @@ -159,16 +159,16 @@ if sys.platform == "win32": w: int, h: int, attr: int, - prop: Optional[str], - text: Optional[str], - next: Optional[str], - help: Optional[str], + prop: str | None, + text: str | None, + next: str | None, + help: str | None, ) -> Control: ... - def text(self, name: str, x: int, y: int, w: int, h: int, attr: int, text: Optional[str]) -> Control: ... - def bitmap(self, name: str, x: int, y: int, w: int, h: int, text: Optional[str]) -> Control: ... + def text(self, name: str, x: int, y: int, w: int, h: int, attr: int, text: str | None) -> Control: ... + def bitmap(self, name: str, x: int, y: int, w: int, h: int, text: str | None) -> Control: ... def line(self, name: str, x: int, y: int, w: int, h: int) -> Control: ... def pushbutton( - self, name: str, x: int, y: int, w: int, h: int, attr: int, text: Optional[str], next: Optional[str] + self, name: str, x: int, y: int, w: int, h: int, attr: int, text: str | None, next: str | None ) -> Control: ... def radiogroup( self, @@ -178,9 +178,9 @@ if sys.platform == "win32": w: int, h: int, attr: int, - prop: Optional[str], - text: Optional[str], - next: Optional[str], + prop: str | None, + text: str | None, + next: str | None, ) -> RadioButtonGroup: ... def checkbox( self, @@ -190,7 +190,7 @@ if sys.platform == "win32": w: int, h: int, attr: int, - prop: Optional[str], - text: Optional[str], - next: Optional[str], + prop: str | None, + text: str | None, + next: str | None, ) -> Control: ... diff --git a/stdlib/msilib/schema.pyi b/stdlib/msilib/schema.pyi index 10b65088cf80..f7f71edff390 100644 --- a/stdlib/msilib/schema.pyi +++ b/stdlib/msilib/schema.pyi @@ -93,5 +93,5 @@ if sys.platform == "win32": tables: List[Table] _Validation_records: List[ - Tuple[str, str, str, Optional[int], Optional[int], Optional[str], Optional[int], Optional[str], Optional[str], str] + Tuple[str, str, str, int | None, int | None, str | None, int | None, str | None, str | None, str] ] diff --git a/stdlib/msilib/text.pyi b/stdlib/msilib/text.pyi index e338b8b5ba3d..79e166eed550 100644 --- a/stdlib/msilib/text.pyi +++ b/stdlib/msilib/text.pyi @@ -3,7 +3,7 @@ from typing import List, Optional, Tuple if sys.platform == "win32": - ActionText: List[Tuple[str, str, Optional[str]]] - UIText: List[Tuple[str, Optional[str]]] + ActionText: List[Tuple[str, str, str | None]] + UIText: List[Tuple[str, str | None]] tables: List[str] diff --git a/stdlib/multiprocessing/__init__.pyi b/stdlib/multiprocessing/__init__.pyi index c8f9e2c654bc..1be9e2efafd0 100644 --- a/stdlib/multiprocessing/__init__.pyi +++ b/stdlib/multiprocessing/__init__.pyi @@ -60,32 +60,32 @@ RawArray = context._default_context.RawArray Value = context._default_context.Value Array = context._default_context.Array -def Barrier(parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ...) -> _BarrierType: ... +def Barrier(parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ...) -> _BarrierType: ... def BoundedSemaphore(value: int = ...) -> _BoundedSemaphoreType: ... -def Condition(lock: Optional[_LockLike] = ...) -> _ConditionType: ... +def Condition(lock: _LockLike | None = ...) -> _ConditionType: ... def Event() -> _EventType: ... def Lock() -> _LockType: ... def RLock() -> _RLockType: ... def Semaphore(value: int = ...) -> _SemaphoreType: ... def Pipe(duplex: bool = ...) -> tuple[connection.Connection, connection.Connection]: ... def Pool( - processes: Optional[int] = ..., - initializer: Optional[Callable[..., Any]] = ..., + processes: int | None = ..., + initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ..., - maxtasksperchild: Optional[int] = ..., + maxtasksperchild: int | None = ..., ) -> pool.Pool: ... # ----- multiprocessing function stubs ----- def allow_connection_pickling() -> None: ... def cpu_count() -> int: ... def get_logger() -> Logger: ... -def log_to_stderr(level: Optional[Union[str, int]] = ...) -> Logger: ... +def log_to_stderr(level: str | int | None = ...) -> Logger: ... def Manager() -> SyncManager: ... def set_executable(executable: str) -> None: ... def set_forkserver_preload(module_names: list[str]) -> None: ... def get_all_start_methods() -> list[str]: ... -def get_start_method(allow_none: bool = ...) -> Optional[str]: ... -def set_start_method(method: str, force: Optional[bool] = ...) -> None: ... +def get_start_method(allow_none: bool = ...) -> str | None: ... +def set_start_method(method: str, force: bool | None = ...) -> None: ... if sys.platform != "win32": @overload diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index ce56bea53bd7..52c6636cd370 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -23,15 +23,15 @@ class _ConnectionBase: def writable(self) -> bool: ... # undocumented def fileno(self) -> int: ... def close(self) -> None: ... - def send_bytes(self, buf: bytes, offset: int = ..., size: Optional[int] = ...) -> None: ... + def send_bytes(self, buf: bytes, offset: int = ..., size: int | None = ...) -> None: ... def send(self, obj: Any) -> None: ... - def recv_bytes(self, maxlength: Optional[int] = ...) -> bytes: ... + def recv_bytes(self, maxlength: int | None = ...) -> bytes: ... def recv_bytes_into(self, buf: Any, offset: int = ...) -> int: ... def recv(self) -> Any: ... - def poll(self, timeout: Optional[float] = ...) -> bool: ... + def poll(self, timeout: float | None = ...) -> bool: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType] + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... class Connection(_ConnectionBase): ... @@ -41,23 +41,23 @@ if sys.platform == "win32": class Listener: def __init__( - self, address: Optional[_Address] = ..., family: Optional[str] = ..., backlog: int = ..., authkey: Optional[bytes] = ... + self, address: _Address | None = ..., family: str | None = ..., backlog: int = ..., authkey: bytes | None = ... ) -> None: ... def accept(self) -> Connection: ... def close(self) -> None: ... @property def address(self) -> _Address: ... @property - def last_accepted(self) -> Optional[_Address]: ... + def last_accepted(self) -> _Address | None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType] + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def deliver_challenge(connection: Connection, authkey: bytes) -> None: ... def answer_challenge(connection: Connection, authkey: bytes) -> None: ... def wait( - object_list: Iterable[Union[Connection, socket.socket, int]], timeout: Optional[float] = ... -) -> List[Union[Connection, socket.socket, int]]: ... -def Client(address: _Address, family: Optional[str] = ..., authkey: Optional[bytes] = ...) -> Connection: ... + object_list: Iterable[Connection | socket.socket | int], timeout: float | None = ... +) -> List[Connection | socket.socket | int]: ... +def Client(address: _Address, family: str | None = ..., authkey: bytes | None = ...) -> Connection: ... def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ... diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index e02bacc0a243..18b3b2910ca5 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -31,7 +31,7 @@ class BaseContext(object): def current_process() -> BaseProcess: ... if sys.version_info >= (3, 8): @staticmethod - def parent_process() -> Optional[BaseProcess]: ... + def parent_process() -> BaseProcess | None: ... @staticmethod def active_children() -> list[BaseProcess]: ... def cpu_count(self) -> int: ... @@ -40,10 +40,10 @@ class BaseContext(object): # TODO: change return to Pipe once a stub exists in multiprocessing.connection def Pipe(self, duplex: bool = ...) -> Any: ... def Barrier( - self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ... + self, parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ... ) -> synchronize.Barrier: ... def BoundedSemaphore(self, value: int = ...) -> synchronize.BoundedSemaphore: ... - def Condition(self, lock: Optional[_LockLike] = ...) -> synchronize.Condition: ... + def Condition(self, lock: _LockLike | None = ...) -> synchronize.Condition: ... def Event(self) -> synchronize.Event: ... def Lock(self) -> synchronize.Lock: ... def RLock(self) -> synchronize.RLock: ... @@ -53,54 +53,54 @@ class BaseContext(object): def SimpleQueue(self) -> queues.SimpleQueue[Any]: ... def Pool( self, - processes: Optional[int] = ..., - initializer: Optional[Callable[..., Any]] = ..., + processes: int | None = ..., + initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ..., - maxtasksperchild: Optional[int] = ..., + maxtasksperchild: int | None = ..., ) -> multiprocessing.pool.Pool: ... @overload def RawValue(self, typecode_or_type: Type[_CT], *args: Any) -> _CT: ... @overload def RawValue(self, typecode_or_type: str, *args: Any) -> Any: ... @overload - def RawArray(self, typecode_or_type: Type[_CT], size_or_initializer: Union[int, Sequence[Any]]) -> ctypes.Array[_CT]: ... + def RawArray(self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... @overload - def RawArray(self, typecode_or_type: str, size_or_initializer: Union[int, Sequence[Any]]) -> Any: ... + def RawArray(self, typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ... @overload def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Literal[False]) -> _CT: ... @overload - def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Union[Literal[True], _LockLike]) -> SynchronizedBase[_CT]: ... + def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[_CT]: ... @overload - def Value(self, typecode_or_type: str, *args: Any, lock: Union[Literal[True], _LockLike]) -> SynchronizedBase[Any]: ... + def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[Any]: ... @overload - def Value(self, typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ...) -> Any: ... + def Value(self, typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ... @overload def Array( - self, typecode_or_type: Type[_CT], size_or_initializer: Union[int, Sequence[Any]], *, lock: Literal[False] + self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False] ) -> _CT: ... @overload def Array( self, typecode_or_type: Type[_CT], - size_or_initializer: Union[int, Sequence[Any]], + size_or_initializer: int | Sequence[Any], *, - lock: Union[Literal[True], _LockLike], + lock: Literal[True] | _LockLike, ) -> SynchronizedArray[_CT]: ... @overload def Array( - self, typecode_or_type: str, size_or_initializer: Union[int, Sequence[Any]], *, lock: Union[Literal[True], _LockLike] + self, typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike ) -> SynchronizedArray[Any]: ... @overload def Array( self, - typecode_or_type: Union[str, Type[_CData]], - size_or_initializer: Union[int, Sequence[Any]], + typecode_or_type: str | Type[_CData], + size_or_initializer: int | Sequence[Any], *, - lock: Union[bool, _LockLike] = ..., + lock: bool | _LockLike = ..., ) -> Any: ... def freeze_support(self) -> None: ... def get_logger(self) -> Logger: ... - def log_to_stderr(self, level: Optional[str] = ...) -> Logger: ... + def log_to_stderr(self, level: str | None = ...) -> Logger: ... def allow_connection_pickling(self) -> None: ... def set_executable(self, executable: str) -> None: ... def set_forkserver_preload(self, module_names: list[str]) -> None: ... @@ -123,7 +123,7 @@ class BaseContext(object): @overload def get_context(self, method: str) -> BaseContext: ... def get_start_method(self, allow_none: bool = ...) -> str: ... - def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ... + def set_start_method(self, method: str | None, force: bool = ...) -> None: ... @property def reducer(self) -> str: ... @reducer.setter @@ -131,14 +131,14 @@ class BaseContext(object): def _check_available(self) -> None: ... class Process(BaseProcess): - _start_method: Optional[str] + _start_method: str | None @staticmethod def _Popen(process_obj: BaseProcess) -> DefaultContext: ... class DefaultContext(BaseContext): Process: Type[multiprocessing.Process] def __init__(self, context: BaseContext) -> None: ... - def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ... + def set_start_method(self, method: str | None, force: bool = ...) -> None: ... def get_start_method(self, allow_none: bool = ...) -> str: ... def get_all_start_methods(self) -> list[str]: ... @@ -177,6 +177,6 @@ else: Process: Type[SpawnProcess] def _force_start_method(method: str) -> None: ... -def get_spawning_popen() -> Optional[Any]: ... +def get_spawning_popen() -> Any | None: ... def set_spawning_popen(popen: Any) -> None: ... def assert_spawning(obj: Any) -> None: ... diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index 0089defc0099..55fda28bf776 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -18,12 +18,12 @@ class DummyProcess(threading.Thread): _parent: threading.Thread _pid: None _start_called: int - exitcode: Optional[int] + exitcode: int | None def __init__( self, group: Any = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., + target: Callable[..., Any] | None = ..., + name: str | None = ..., args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ..., ) -> None: ... @@ -44,7 +44,7 @@ class Value: def Array(typecode: Any, sequence: Sequence[Any], lock: Any = ...) -> array.array[Any]: ... def Manager() -> Any: ... def Pool( - processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ... + processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ... ) -> Any: ... def active_children() -> List[Any]: ... def current_process() -> threading.Thread: ... diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index d3abec749cde..b9257eb0322f 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -16,21 +16,21 @@ class Connection(object): send_bytes: Any def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __init__(self, _in: Any, _out: Any) -> None: ... def close(self) -> None: ... def poll(self, timeout: float = ...) -> bool: ... class Listener(object): - _backlog_queue: Optional[Queue[Any]] + _backlog_queue: Queue[Any] | None @property - def address(self) -> Optional[Queue[Any]]: ... + def address(self) -> Queue[Any] | None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... - def __init__(self, address: Optional[_Address] = ..., family: Optional[int] = ..., backlog: int = ...) -> None: ... + def __init__(self, address: _Address | None = ..., family: int | None = ..., backlog: int = ...) -> None: ... def accept(self) -> Connection: ... def close(self) -> None: ... diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 9cc671363f0b..43cd91d7dccb 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -44,18 +44,18 @@ class Namespace: _Namespace = Namespace class Token(object): - typeid: Optional[Union[str, bytes]] - address: Tuple[Union[str, bytes], int] - id: Optional[Union[str, bytes, int]] + typeid: str | bytes | None + address: Tuple[str | bytes, int] + id: str | bytes | int | None def __init__( - self, typeid: Optional[Union[bytes, str]], address: Tuple[Union[str, bytes], int], id: Optional[Union[str, bytes, int]] + self, typeid: bytes | str | None, address: Tuple[str | bytes, int], id: str | bytes | int | None ) -> None: ... def __repr__(self) -> str: ... def __getstate__( self, - ) -> Tuple[Optional[Union[str, bytes]], Tuple[Union[str, bytes], int], Optional[Union[str, bytes, int]]]: ... + ) -> Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]: ... def __setstate__( - self, state: Tuple[Optional[Union[str, bytes]], Tuple[Union[str, bytes], int], Optional[Union[str, bytes, int]]] + self, state: Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None] ) -> None: ... class BaseProxy(object): @@ -66,12 +66,12 @@ class BaseProxy(object): token: Any, serializer: str, manager: Any = ..., - authkey: Optional[AnyStr] = ..., + authkey: AnyStr | None = ..., exposed: Any = ..., incref: bool = ..., manager_owned: bool = ..., ) -> None: ... - def __deepcopy__(self, memo: Optional[Any]) -> Any: ... + def __deepcopy__(self, memo: Any | None) -> Any: ... def _callmethod(self, methodname: str, args: Tuple[Any, ...] = ..., kwds: Dict[Any, Any] = ...) -> None: ... def _getvalue(self) -> Any: ... def __reduce__(self) -> Tuple[Any, Tuple[Any, Any, str, Dict[Any, Any]]]: ... @@ -95,26 +95,26 @@ class Server: class BaseManager(ContextManager[BaseManager]): def __init__( self, - address: Optional[Any] = ..., - authkey: Optional[bytes] = ..., + address: Any | None = ..., + authkey: bytes | None = ..., serializer: str = ..., - ctx: Optional[BaseContext] = ..., + ctx: BaseContext | None = ..., ) -> None: ... def get_server(self) -> Server: ... def connect(self) -> None: ... - def start(self, initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...) -> None: ... + def start(self, initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ...) -> None: ... def shutdown(self) -> None: ... # only available after start() was called - def join(self, timeout: Optional[float] = ...) -> None: ... # undocumented + def join(self, timeout: float | None = ...) -> None: ... # undocumented @property def address(self) -> Any: ... @classmethod def register( cls, typeid: str, - callable: Optional[Callable[..., Any]] = ..., + callable: Callable[..., Any] | None = ..., proxytype: Any = ..., - exposed: Optional[Sequence[str]] = ..., - method_to_typeid: Optional[Mapping[str, str]] = ..., + exposed: Sequence[str] | None = ..., + method_to_typeid: Mapping[str, str] | None = ..., create_method: bool = ..., ) -> None: ... @@ -139,4 +139,4 @@ if sys.version_info >= (3, 8): class SharedMemoryManager(BaseManager): def get_server(self) -> SharedMemoryServer: ... def SharedMemory(self, size: int) -> _SharedMemory: ... - def ShareableList(self, sequence: Optional[Iterable[_SLT]]) -> _ShareableList[_SLT]: ... + def ShareableList(self, sequence: Iterable[_SLT] | None) -> _ShareableList[_SLT]: ... diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index 0f4d33dc376f..9f5cad97f31e 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -13,11 +13,11 @@ class ApplyResult(Generic[_T]): def __init__( self, pool: Pool, - callback: Optional[Callable[[_T], None]] = ..., - error_callback: Optional[Callable[[BaseException], None]] = ..., + callback: Callable[[_T], None] | None = ..., + error_callback: Callable[[BaseException], None] | None = ..., ) -> None: ... - def get(self, timeout: Optional[float] = ...) -> _T: ... - def wait(self, timeout: Optional[float] = ...) -> None: ... + def get(self, timeout: float | None = ...) -> _T: ... + def wait(self, timeout: float | None = ...) -> None: ... def ready(self) -> bool: ... def successful(self) -> bool: ... if sys.version_info >= (3, 9): @@ -30,19 +30,19 @@ class MapResult(ApplyResult[List[_T]]): ... class IMapIterator(Iterator[_T]): def __iter__(self: _S) -> _S: ... - def next(self, timeout: Optional[float] = ...) -> _T: ... - def __next__(self, timeout: Optional[float] = ...) -> _T: ... + def next(self, timeout: float | None = ...) -> _T: ... + def __next__(self, timeout: float | None = ...) -> _T: ... class IMapUnorderedIterator(IMapIterator[_T]): ... class Pool(ContextManager[Pool]): def __init__( self, - processes: Optional[int] = ..., - initializer: Optional[Callable[..., None]] = ..., + processes: int | None = ..., + initializer: Callable[..., None] | None = ..., initargs: Iterable[Any] = ..., - maxtasksperchild: Optional[int] = ..., - context: Optional[Any] = ..., + maxtasksperchild: int | None = ..., + context: Any | None = ..., ) -> None: ... def apply(self, func: Callable[..., _T], args: Iterable[Any] = ..., kwds: Mapping[str, Any] = ...) -> _T: ... def apply_async( @@ -50,30 +50,30 @@ class Pool(ContextManager[Pool]): func: Callable[..., _T], args: Iterable[Any] = ..., kwds: Mapping[str, Any] = ..., - callback: Optional[Callable[[_T], None]] = ..., - error_callback: Optional[Callable[[BaseException], None]] = ..., + callback: Callable[[_T], None] | None = ..., + error_callback: Callable[[BaseException], None] | None = ..., ) -> AsyncResult[_T]: ... - def map(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ...) -> List[_T]: ... + def map(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ...) -> List[_T]: ... def map_async( self, func: Callable[[_S], _T], iterable: Iterable[_S], - chunksize: Optional[int] = ..., - callback: Optional[Callable[[_T], None]] = ..., - error_callback: Optional[Callable[[BaseException], None]] = ..., + chunksize: int | None = ..., + callback: Callable[[_T], None] | None = ..., + error_callback: Callable[[BaseException], None] | None = ..., ) -> MapResult[_T]: ... - def imap(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ...) -> IMapIterator[_T]: ... + def imap(self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ...) -> IMapIterator[_T]: ... def imap_unordered( - self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: Optional[int] = ... + self, func: Callable[[_S], _T], iterable: Iterable[_S], chunksize: int | None = ... ) -> IMapIterator[_T]: ... - def starmap(self, func: Callable[..., _T], iterable: Iterable[Iterable[Any]], chunksize: Optional[int] = ...) -> List[_T]: ... + def starmap(self, func: Callable[..., _T], iterable: Iterable[Iterable[Any]], chunksize: int | None = ...) -> List[_T]: ... def starmap_async( self, func: Callable[..., _T], iterable: Iterable[Iterable[Any]], - chunksize: Optional[int] = ..., - callback: Optional[Callable[[_T], None]] = ..., - error_callback: Optional[Callable[[BaseException], None]] = ..., + chunksize: int | None = ..., + callback: Callable[[_T], None] | None = ..., + error_callback: Callable[[BaseException], None] | None = ..., ) -> AsyncResult[List[_T]]: ... def close(self) -> None: ... def terminate(self) -> None: ... @@ -82,7 +82,7 @@ class Pool(ContextManager[Pool]): class ThreadPool(Pool, ContextManager[ThreadPool]): def __init__( - self, processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ... + self, processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ... ) -> None: ... # undocumented diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index f2d0b5740baf..1c29e7f79a5b 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -8,12 +8,12 @@ class BaseProcess: def __init__( self, group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., + target: Callable[..., Any] | None = ..., + name: str | None = ..., args: Tuple[Any, ...] = ..., kwargs: Mapping[str, Any] = ..., *, - daemon: Optional[bool] = ..., + daemon: bool | None = ..., ) -> None: ... def run(self) -> None: ... def start(self) -> None: ... @@ -21,14 +21,14 @@ class BaseProcess: if sys.version_info >= (3, 7): def kill(self) -> None: ... def close(self) -> None: ... - def join(self, timeout: Optional[float] = ...) -> None: ... + def join(self, timeout: float | None = ...) -> None: ... def is_alive(self) -> bool: ... @property - def exitcode(self) -> Optional[int]: ... + def exitcode(self) -> int | None: ... @property - def ident(self) -> Optional[int]: ... + def ident(self) -> int | None: ... @property - def pid(self) -> Optional[int]: ... + def pid(self) -> int | None: ... @property def sentinel(self) -> int: ... @@ -36,4 +36,4 @@ def current_process() -> BaseProcess: ... def active_children() -> List[BaseProcess]: ... if sys.version_info >= (3, 8): - def parent_process() -> Optional[BaseProcess]: ... + def parent_process() -> BaseProcess | None: ... diff --git a/stdlib/multiprocessing/queues.pyi b/stdlib/multiprocessing/queues.pyi index ea555cfba70f..b3c71690e926 100644 --- a/stdlib/multiprocessing/queues.pyi +++ b/stdlib/multiprocessing/queues.pyi @@ -11,8 +11,8 @@ class Queue(queue.Queue[_T]): # FIXME: `ctx` is a circular dependency and it's not actually optional. # It's marked as such to be able to use the generic Queue in __init__.pyi. def __init__(self, maxsize: int = ..., *, ctx: Any = ...) -> None: ... - def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ... - def put(self, obj: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ... + def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... + def put(self, obj: _T, block: bool = ..., timeout: float | None = ...) -> None: ... def qsize(self) -> int: ... def empty(self) -> bool: ... def full(self) -> bool: ... diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index cf8b68bfc0da..ec86882d1d21 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -9,7 +9,7 @@ _SLT = TypeVar("_SLT", int, float, bool, str, bytes, None) if sys.version_info >= (3, 8): class SharedMemory: - def __init__(self, name: Optional[str] = ..., create: bool = ..., size: int = ...) -> None: ... + def __init__(self, name: str | None = ..., create: bool = ..., size: int = ...) -> None: ... @property def buf(self) -> memoryview: ... @property @@ -20,7 +20,7 @@ if sys.version_info >= (3, 8): def unlink(self) -> None: ... class ShareableList(Generic[_SLT]): shm: SharedMemory - def __init__(self, sequence: Optional[Iterable[_SLT]] = ..., *, name: Optional[str] = ...) -> None: ... + def __init__(self, sequence: Iterable[_SLT] | None = ..., *, name: str | None = ...) -> None: ... def __getitem__(self, position: int) -> _SLT: ... def __setitem__(self, position: int, value: _SLT) -> None: ... def __reduce__(self: _S) -> Tuple[_S, Tuple[_SLT, ...]]: ... diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index 0dc5977decd7..4b02927be3f7 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -14,72 +14,72 @@ def RawValue(typecode_or_type: Type[_CT], *args: Any) -> _CT: ... @overload def RawValue(typecode_or_type: str, *args: Any) -> Any: ... @overload -def RawArray(typecode_or_type: Type[_CT], size_or_initializer: Union[int, Sequence[Any]]) -> ctypes.Array[_CT]: ... +def RawArray(typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... @overload -def RawArray(typecode_or_type: str, size_or_initializer: Union[int, Sequence[Any]]) -> Any: ... +def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ... @overload -def Value(typecode_or_type: Type[_CT], *args: Any, lock: Literal[False], ctx: Optional[BaseContext] = ...) -> _CT: ... +def Value(typecode_or_type: Type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ... @overload def Value( - typecode_or_type: Type[_CT], *args: Any, lock: Union[Literal[True], _LockLike], ctx: Optional[BaseContext] = ... + typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ... ) -> SynchronizedBase[_CT]: ... @overload def Value( - typecode_or_type: str, *args: Any, lock: Union[Literal[True], _LockLike], ctx: Optional[BaseContext] = ... + typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ... ) -> SynchronizedBase[Any]: ... @overload def Value( - typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ..., ctx: Optional[BaseContext] = ... + typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ... ) -> Any: ... @overload def Array( typecode_or_type: Type[_CT], - size_or_initializer: Union[int, Sequence[Any]], + size_or_initializer: int | Sequence[Any], *, lock: Literal[False], - ctx: Optional[BaseContext] = ..., + ctx: BaseContext | None = ..., ) -> _CT: ... @overload def Array( typecode_or_type: Type[_CT], - size_or_initializer: Union[int, Sequence[Any]], + size_or_initializer: int | Sequence[Any], *, - lock: Union[Literal[True], _LockLike], - ctx: Optional[BaseContext] = ..., + lock: Literal[True] | _LockLike, + ctx: BaseContext | None = ..., ) -> SynchronizedArray[_CT]: ... @overload def Array( typecode_or_type: str, - size_or_initializer: Union[int, Sequence[Any]], + size_or_initializer: int | Sequence[Any], *, - lock: Union[Literal[True], _LockLike], - ctx: Optional[BaseContext] = ..., + lock: Literal[True] | _LockLike, + ctx: BaseContext | None = ..., ) -> SynchronizedArray[Any]: ... @overload def Array( - typecode_or_type: Union[str, Type[_CData]], - size_or_initializer: Union[int, Sequence[Any]], + typecode_or_type: str | Type[_CData], + size_or_initializer: int | Sequence[Any], *, - lock: Union[bool, _LockLike] = ..., - ctx: Optional[BaseContext] = ..., + lock: bool | _LockLike = ..., + ctx: BaseContext | None = ..., ) -> Any: ... def copy(obj: _CT) -> _CT: ... @overload -def synchronized(obj: _SimpleCData[_T], lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> Synchronized[_T]: ... +def synchronized(obj: _SimpleCData[_T], lock: _LockLike | None = ..., ctx: Any | None = ...) -> Synchronized[_T]: ... @overload -def synchronized(obj: ctypes.Array[c_char], lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> SynchronizedString: ... +def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedString: ... @overload -def synchronized(obj: ctypes.Array[_CT], lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> SynchronizedArray[_CT]: ... +def synchronized(obj: ctypes.Array[_CT], lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedArray[_CT]: ... @overload -def synchronized(obj: _CT, lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> SynchronizedBase[_CT]: ... +def synchronized(obj: _CT, lock: _LockLike | None = ..., ctx: Any | None = ...) -> SynchronizedBase[_CT]: ... class _AcquireFunc(Protocol): - def __call__(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ... + def __call__(self, block: bool = ..., timeout: float | None = ...) -> bool: ... class SynchronizedBase(Generic[_CT]): acquire: _AcquireFunc = ... release: Callable[[], None] = ... - def __init__(self, obj: Any, lock: Optional[_LockLike] = ..., ctx: Optional[Any] = ...) -> None: ... + def __init__(self, obj: Any, lock: _LockLike | None = ..., ctx: Any | None = ...) -> None: ... def __reduce__(self) -> tuple[Callable[..., Any], tuple[Any, _LockLike]]: ... def get_obj(self) -> _CT: ... def get_lock(self) -> _LockLike: ... diff --git a/stdlib/multiprocessing/spawn.pyi b/stdlib/multiprocessing/spawn.pyi index 0faee1754f93..27b9daf45677 100644 --- a/stdlib/multiprocessing/spawn.pyi +++ b/stdlib/multiprocessing/spawn.pyi @@ -9,7 +9,7 @@ def get_executable() -> str: ... def is_forking(argv: Sequence[str]) -> bool: ... def freeze_support() -> None: ... def get_command_line(**kwds: Any) -> List[str]: ... -def spawn_main(pipe_handle: int, parent_pid: Optional[int] = ..., tracker_fd: Optional[int] = ...) -> None: ... +def spawn_main(pipe_handle: int, parent_pid: int | None = ..., tracker_fd: int | None = ...) -> None: ... # undocumented def _main(fd: int) -> Any: ... diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 7eefc7676b66..5f9e085fb867 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -7,30 +7,30 @@ _LockLike = Union[Lock, RLock] class Barrier(threading.Barrier): def __init__( - self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ..., *ctx: BaseContext + self, parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ..., *ctx: BaseContext ) -> None: ... class BoundedSemaphore(Semaphore): def __init__(self, value: int = ..., *, ctx: BaseContext) -> None: ... class Condition(ContextManager[bool]): - def __init__(self, lock: Optional[_LockLike] = ..., *, ctx: BaseContext) -> None: ... + def __init__(self, lock: _LockLike | None = ..., *, ctx: BaseContext) -> None: ... if sys.version_info >= (3, 7): def notify(self, n: int = ...) -> None: ... else: def notify(self) -> None: ... def notify_all(self) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> bool: ... - def wait_for(self, predicate: Callable[[], bool], timeout: Optional[float] = ...) -> bool: ... - def acquire(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ... + def wait(self, timeout: float | None = ...) -> bool: ... + def wait_for(self, predicate: Callable[[], bool], timeout: float | None = ...) -> bool: ... + def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ... def release(self) -> None: ... class Event(ContextManager[bool]): - def __init__(self, lock: Optional[_LockLike] = ..., *, ctx: BaseContext) -> None: ... + def __init__(self, lock: _LockLike | None = ..., *, ctx: BaseContext) -> None: ... def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> bool: ... + def wait(self, timeout: float | None = ...) -> bool: ... class Lock(SemLock): def __init__(self, *, ctx: BaseContext) -> None: ... @@ -43,5 +43,5 @@ class Semaphore(SemLock): # Not part of public API class SemLock(ContextManager[bool]): - def acquire(self, block: bool = ..., timeout: Optional[float] = ...) -> bool: ... + def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ... def release(self) -> None: ... diff --git a/stdlib/netrc.pyi b/stdlib/netrc.pyi index b71c4b31501a..a0044f02b5e2 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -2,10 +2,10 @@ from _typeshed import StrOrBytesPath from typing import Dict, List, Optional, Tuple class NetrcParseError(Exception): - filename: Optional[str] - lineno: Optional[int] + filename: str | None + lineno: int | None msg: str - def __init__(self, msg: str, filename: Optional[StrOrBytesPath] = ..., lineno: Optional[int] = ...) -> None: ... + def __init__(self, msg: str, filename: StrOrBytesPath | None = ..., lineno: int | None = ...) -> None: ... # (login, account, password) tuple _NetrcTuple = Tuple[str, Optional[str], Optional[str]] @@ -13,5 +13,5 @@ _NetrcTuple = Tuple[str, Optional[str], Optional[str]] class netrc: hosts: Dict[str, _NetrcTuple] macros: Dict[str, List[str]] - def __init__(self, file: Optional[StrOrBytesPath] = ...) -> None: ... - def authenticators(self, host: str) -> Optional[_NetrcTuple]: ... + def __init__(self, file: StrOrBytesPath | None = ...) -> None: ... + def authenticators(self, host: str) -> _NetrcTuple | None: ... diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index c3c981626fd9..8263029158cc 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -45,7 +45,7 @@ class _NNTPBase: authenticated: bool nntp_implementation: str nntp_version: int - def __init__(self, file: IO[bytes], host: str, readermode: Optional[bool] = ..., timeout: float = ...) -> None: ... + def __init__(self, file: IO[bytes], host: str, readermode: bool | None = ..., timeout: float = ...) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... def getwelcome(self) -> str: ... @@ -53,11 +53,11 @@ class _NNTPBase: def set_debuglevel(self, level: int) -> None: ... def debug(self, level: int) -> None: ... def capabilities(self) -> Tuple[str, Dict[str, List[str]]]: ... - def newgroups(self, date: Union[datetime.date, datetime.datetime], *, file: _File = ...) -> Tuple[str, List[str]]: ... + def newgroups(self, date: datetime.date | datetime.datetime, *, file: _File = ...) -> Tuple[str, List[str]]: ... def newnews( - self, group: str, date: Union[datetime.date, datetime.datetime], *, file: _File = ... + self, group: str, date: datetime.date | datetime.datetime, *, file: _File = ... ) -> Tuple[str, List[str]]: ... - def list(self, group_pattern: Optional[str] = ..., *, file: _File = ...) -> Tuple[str, List[str]]: ... + def list(self, group_pattern: str | None = ..., *, file: _File = ...) -> Tuple[str, List[str]]: ... def description(self, group: str) -> str: ... def descriptions(self, group_pattern: str) -> Tuple[str, Dict[str, str]]: ... def group(self, name: str) -> Tuple[str, int, int, int, str]: ... @@ -72,17 +72,17 @@ class _NNTPBase: def xhdr(self, hdr: str, str: Any, *, file: _File = ...) -> Tuple[str, List[str]]: ... def xover(self, start: int, end: int, *, file: _File = ...) -> Tuple[str, List[Tuple[int, Dict[str, str]]]]: ... def over( - self, message_spec: Union[None, str, List[Any], Tuple[Any, ...]], *, file: _File = ... + self, message_spec: None | str | List[Any] | Tuple[Any, ...], *, file: _File = ... ) -> Tuple[str, List[Tuple[int, Dict[str, str]]]]: ... if sys.version_info < (3, 9): def xgtitle(self, group: str, *, file: _File = ...) -> Tuple[str, List[Tuple[str, str]]]: ... def xpath(self, id: Any) -> Tuple[str, str]: ... def date(self) -> Tuple[str, datetime.datetime]: ... - def post(self, data: Union[bytes, Iterable[bytes]]) -> str: ... - def ihave(self, message_id: Any, data: Union[bytes, Iterable[bytes]]) -> str: ... + def post(self, data: bytes | Iterable[bytes]) -> str: ... + def ihave(self, message_id: Any, data: bytes | Iterable[bytes]) -> str: ... def quit(self) -> str: ... - def login(self, user: Optional[str] = ..., password: Optional[str] = ..., usenetrc: bool = ...) -> None: ... - def starttls(self, context: Optional[ssl.SSLContext] = ...) -> None: ... + def login(self, user: str | None = ..., password: str | None = ..., usenetrc: bool = ...) -> None: ... + def starttls(self, context: ssl.SSLContext | None = ...) -> None: ... class NNTP(_NNTPBase): port: int @@ -91,9 +91,9 @@ class NNTP(_NNTPBase): self, host: str, port: int = ..., - user: Optional[str] = ..., - password: Optional[str] = ..., - readermode: Optional[bool] = ..., + user: str | None = ..., + password: str | None = ..., + readermode: bool | None = ..., usenetrc: bool = ..., timeout: float = ..., ) -> None: ... @@ -104,10 +104,10 @@ class NNTP_SSL(_NNTPBase): self, host: str, port: int = ..., - user: Optional[str] = ..., - password: Optional[str] = ..., - ssl_context: Optional[ssl.SSLContext] = ..., - readermode: Optional[bool] = ..., + user: str | None = ..., + password: str | None = ..., + ssl_context: ssl.SSLContext | None = ..., + readermode: bool | None = ..., usenetrc: bool = ..., timeout: float = ..., ) -> None: ... diff --git a/stdlib/numbers.pyi b/stdlib/numbers.pyi index 7c5dbe1610a2..7d56aa15f44d 100644 --- a/stdlib/numbers.pyi +++ b/stdlib/numbers.pyi @@ -94,7 +94,7 @@ class Integral(Rational): def __int__(self) -> int: ... def __index__(self) -> int: ... @abstractmethod - def __pow__(self, exponent: Any, modulus: Optional[Any] = ...) -> Any: ... + def __pow__(self, exponent: Any, modulus: Any | None = ...) -> Any: ... @abstractmethod def __lshift__(self, other: Any) -> Any: ... @abstractmethod diff --git a/stdlib/opcode.pyi b/stdlib/opcode.pyi index 74b39830041a..7d734b1c11be 100644 --- a/stdlib/opcode.pyi +++ b/stdlib/opcode.pyi @@ -16,9 +16,9 @@ HAVE_ARGUMENT: int EXTENDED_ARG: int if sys.version_info >= (3, 8): - def stack_effect(__opcode: int, __oparg: Optional[int] = ..., *, jump: Optional[bool] = ...) -> int: ... + def stack_effect(__opcode: int, __oparg: int | None = ..., *, jump: bool | None = ...) -> int: ... else: - def stack_effect(__opcode: int, __oparg: Optional[int] = ...) -> int: ... + def stack_effect(__opcode: int, __oparg: int | None = ...) -> int: ... hasnargs: List[int] diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index ff8ce8ea9f11..047dbffa8feb 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -42,7 +42,7 @@ class HelpFormatter: parser: OptionParser short_first: Any width: int - def __init__(self, indent_increment: int, max_help_position: int, width: Optional[int], short_first: int) -> None: ... + def __init__(self, indent_increment: int, max_help_position: int, width: int | None, short_first: int) -> None: ... def dedent(self) -> None: ... def expand_default(self, option: Option) -> str: ... def format_description(self, description: str) -> str: ... @@ -59,14 +59,14 @@ class HelpFormatter: class IndentedHelpFormatter(HelpFormatter): def __init__( - self, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ..., short_first: int = ... + self, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ..., short_first: int = ... ) -> None: ... def format_heading(self, heading: str) -> str: ... def format_usage(self, usage: str) -> str: ... class TitledHelpFormatter(HelpFormatter): def __init__( - self, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ..., short_first: int = ... + self, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ..., short_first: int = ... ) -> None: ... def format_heading(self, heading: str) -> str: ... def format_usage(self, usage: str) -> str: ... @@ -75,7 +75,7 @@ class Option: ACTIONS: Tuple[str, ...] ALWAYS_TYPED_ACTIONS: Tuple[str, ...] ATTRS: List[str] - CHECK_METHODS: Optional[List[Callable[..., Any]]] + CHECK_METHODS: List[Callable[..., Any]] | None CONST_ACTIONS: Tuple[str, ...] STORE_ACTIONS: Tuple[str, ...] TYPED_ACTIONS: Tuple[str, ...] @@ -84,23 +84,23 @@ class Option: _long_opts: List[str] _short_opts: List[str] action: str - dest: Optional[str] + dest: str | None default: Any nargs: int type: Any - callback: Optional[Callable[..., Any]] - callback_args: Optional[Tuple[Any, ...]] - callback_kwargs: Optional[Dict[str, Any]] - help: Optional[str] - metavar: Optional[str] - def __init__(self, *opts: Optional[str], **attrs: Any) -> None: ... + callback: Callable[..., Any] | None + callback_args: Tuple[Any, ...] | None + callback_kwargs: Dict[str, Any] | None + help: str | None + metavar: str | None + def __init__(self, *opts: str | None, **attrs: Any) -> None: ... def _check_action(self) -> None: ... def _check_callback(self) -> None: ... def _check_choice(self) -> None: ... def _check_const(self) -> None: ... def _check_dest(self) -> None: ... def _check_nargs(self) -> None: ... - def _check_opt_strings(self, opts: Iterable[Optional[str]]) -> List[str]: ... + def _check_opt_strings(self, opts: Iterable[str | None]) -> List[str]: ... def _check_type(self) -> None: ... def _set_attrs(self, attrs: Dict[str, Any]) -> None: ... def _set_opt_strings(self, opts: Iterable[str]) -> None: ... @@ -127,14 +127,14 @@ class OptionContainer: @overload def add_option(self, opt: Option) -> Option: ... @overload - def add_option(self, *args: Optional[str], **kwargs: Any) -> Any: ... + def add_option(self, *args: str | None, **kwargs: Any) -> Any: ... def add_options(self, option_list: Iterable[Option]) -> None: ... def destroy(self) -> None: ... - def format_description(self, formatter: Optional[HelpFormatter]) -> Any: ... - def format_help(self, formatter: Optional[HelpFormatter]) -> str: ... - def format_option_help(self, formatter: Optional[HelpFormatter]) -> str: ... + def format_description(self, formatter: HelpFormatter | None) -> Any: ... + def format_help(self, formatter: HelpFormatter | None) -> str: ... + def format_option_help(self, formatter: HelpFormatter | None) -> str: ... def get_description(self) -> Any: ... - def get_option(self, opt_str: str) -> Optional[Option]: ... + def get_option(self, opt_str: str) -> Option | None: ... def has_option(self, opt_str: str) -> bool: ... def remove_option(self, opt_str: str) -> None: ... def set_conflict_handler(self, handler: Any) -> None: ... @@ -144,12 +144,12 @@ class OptionGroup(OptionContainer): option_list: List[Option] parser: OptionParser title: str - def __init__(self, parser: OptionParser, title: str, description: Optional[str] = ...) -> None: ... + def __init__(self, parser: OptionParser, title: str, description: str | None = ...) -> None: ... def _create_option_list(self) -> None: ... def set_title(self, title: str) -> None: ... class Values: - def __init__(self, defaults: Optional[Mapping[str, Any]] = ...) -> None: ... + def __init__(self, defaults: Mapping[str, Any] | None = ...) -> None: ... def _update(self, dict: Mapping[str, Any], mode: Any) -> None: ... def _update_careful(self, dict: Mapping[str, Any]) -> None: ... def _update_loose(self, dict: Mapping[str, Any]) -> None: ... @@ -161,30 +161,30 @@ class Values: class OptionParser(OptionContainer): allow_interspersed_args: bool - epilog: Optional[str] + epilog: str | None formatter: HelpFormatter - largs: Optional[List[str]] + largs: List[str] | None option_groups: List[OptionGroup] option_list: List[Option] process_default_values: Any - prog: Optional[str] - rargs: Optional[List[Any]] + prog: str | None + rargs: List[Any] | None standard_option_list: List[Option] - usage: Optional[str] - values: Optional[Values] + usage: str | None + values: Values | None version: str def __init__( self, - usage: Optional[str] = ..., - option_list: Optional[Iterable[Option]] = ..., + usage: str | None = ..., + option_list: Iterable[Option] | None = ..., option_class: Type[Option] = ..., - version: Optional[str] = ..., + version: str | None = ..., conflict_handler: str = ..., - description: Optional[str] = ..., - formatter: Optional[HelpFormatter] = ..., + description: str | None = ..., + formatter: HelpFormatter | None = ..., add_help_option: bool = ..., - prog: Optional[str] = ..., - epilog: Optional[str] = ..., + prog: str | None = ..., + epilog: str | None = ..., ) -> None: ... def _add_help_option(self) -> None: ... def _add_version_option(self) -> None: ... @@ -205,22 +205,22 @@ class OptionParser(OptionContainer): def disable_interspersed_args(self) -> None: ... def enable_interspersed_args(self) -> None: ... def error(self, msg: str) -> None: ... - def exit(self, status: int = ..., msg: Optional[str] = ...) -> None: ... - def expand_prog_name(self, s: Optional[str]) -> Any: ... + def exit(self, status: int = ..., msg: str | None = ...) -> None: ... + def expand_prog_name(self, s: str | None) -> Any: ... def format_epilog(self, formatter: HelpFormatter) -> Any: ... - def format_help(self, formatter: Optional[HelpFormatter] = ...) -> str: ... - def format_option_help(self, formatter: Optional[HelpFormatter] = ...) -> str: ... + def format_help(self, formatter: HelpFormatter | None = ...) -> str: ... + def format_option_help(self, formatter: HelpFormatter | None = ...) -> str: ... def get_default_values(self) -> Values: ... def get_option_group(self, opt_str: str) -> Any: ... def get_prog_name(self) -> str: ... def get_usage(self) -> str: ... def get_version(self) -> str: ... def parse_args( - self, args: Optional[Sequence[AnyStr]] = ..., values: Optional[Values] = ... + self, args: Sequence[AnyStr] | None = ..., values: Values | None = ... ) -> Tuple[Values, List[AnyStr]]: ... - def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... - def print_help(self, file: Optional[IO[str]] = ...) -> None: ... - def print_version(self, file: Optional[IO[str]] = ...) -> None: ... + def print_usage(self, file: IO[str] | None = ...) -> None: ... + def print_help(self, file: IO[str] | None = ...) -> None: ... + def print_version(self, file: IO[str] | None = ...) -> None: ... def set_default(self, dest: Any, value: Any) -> None: ... def set_defaults(self, **kwargs: Any) -> None: ... def set_process_default_values(self, process: Any) -> None: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 71700daff545..363973d18503 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -171,7 +171,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: Optional[str] + altsep: str | None extsep: str pathsep: str defpath: str @@ -337,7 +337,7 @@ if sys.platform != "win32": if sys.version_info >= (3, 7): # f_fsid was added in https://github.com/python/cpython/pull/4571 class statvfs_result(_Tuple10Int): # Unix only - def __new__(cls, seq: Union[_Tuple10Int, _Tuple11Int], dict: Dict[str, int] = ...) -> statvfs_result: ... + def __new__(cls, seq: _Tuple10Int | _Tuple11Int, dict: Dict[str, int] = ...) -> statvfs_result: ... n_fields: int n_sequence_fields: int n_unnamed_fields: int @@ -379,7 +379,7 @@ def fspath(path: str) -> str: ... def fspath(path: bytes) -> bytes: ... @overload def fspath(path: PathLike[AnyStr]) -> AnyStr: ... -def get_exec_path(env: Optional[Mapping[str, str]] = ...) -> List[str]: ... +def get_exec_path(env: Mapping[str, str] | None = ...) -> List[str]: ... # NOTE: get_exec_path(): returns List[bytes] when env not None def getlogin() -> str: ... @@ -423,20 +423,20 @@ if sys.platform != "win32": def uname() -> uname_result: ... @overload -def getenv(key: str) -> Optional[str]: ... +def getenv(key: str) -> str | None: ... @overload -def getenv(key: str, default: _T) -> Union[str, _T]: ... +def getenv(key: str, default: _T) -> str | _T: ... if sys.platform != "win32": @overload - def getenvb(key: bytes) -> Optional[bytes]: ... + def getenvb(key: bytes) -> bytes | None: ... @overload - def getenvb(key: bytes, default: _T) -> Union[bytes, _T]: ... + def getenvb(key: bytes, default: _T) -> bytes | _T: ... -def putenv(__name: Union[bytes, str], __value: Union[bytes, str]) -> None: ... +def putenv(__name: bytes | str, __value: bytes | str) -> None: ... if sys.platform != "win32": - def unsetenv(__name: Union[bytes, str]) -> None: ... + def unsetenv(__name: bytes | str) -> None: ... _Opener = Callable[[str, int], int] @@ -445,11 +445,11 @@ def fdopen( fd: int, mode: OpenTextMode = ..., buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> _TextIOWrapper: ... @overload def fdopen( @@ -460,7 +460,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> FileIO: ... @overload def fdopen( @@ -471,7 +471,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedRandom: ... @overload def fdopen( @@ -482,7 +482,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedWriter: ... @overload def fdopen( @@ -493,7 +493,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedReader: ... @overload def fdopen( @@ -504,22 +504,22 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BinaryIO: ... @overload def fdopen( fd: int, mode: str, buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> IO[Any]: ... def close(fd: int) -> None: ... def closerange(__fd_low: int, __fd_high: int) -> None: ... -def device_encoding(fd: int) -> Optional[str]: ... +def device_encoding(fd: int) -> str | None: ... def dup(__fd: int) -> int: ... if sys.version_info >= (3, 7): @@ -531,7 +531,7 @@ else: def fstat(fd: int) -> stat_result: ... def fsync(fd: FileDescriptorLike) -> None: ... def lseek(__fd: int, __position: int, __how: int) -> int: ... -def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ... +def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: int | None = ...) -> int: ... def pipe() -> Tuple[int, int]: ... def read(__fd: int, __length: int) -> bytes: ... @@ -541,7 +541,7 @@ if sys.platform != "win32": def fchown(fd: int, uid: int, gid: int) -> None: ... if sys.platform != "darwin": def fdatasync(fd: FileDescriptorLike) -> None: ... # Unix only, not Mac - def fpathconf(__fd: int, __name: Union[str, int]) -> int: ... + def fpathconf(__fd: int, __name: str | int) -> int: ... def fstatvfs(__fd: int) -> statvfs_result: ... def ftruncate(__fd: int, __length: int) -> None: ... def get_blocking(__fd: int) -> bool: ... @@ -556,7 +556,7 @@ if sys.platform != "win32": def pread(__fd: int, __length: int, __offset: int) -> bytes: ... def pwrite(__fd: int, __buffer: bytes, __offset: int) -> int: ... @overload - def sendfile(out_fd: int, in_fd: int, offset: Optional[int], count: int) -> int: ... + def sendfile(out_fd: int, in_fd: int, offset: int | None, count: int) -> int: ... @overload def sendfile( out_fd: int, @@ -586,7 +586,7 @@ if sys.platform != "win32": def write(__fd: int, __data: bytes) -> int: ... def access( - path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., effective_ids: bool = ..., follow_symlinks: bool = ... + path: _FdOrAnyPath, mode: int, *, dir_fd: int | None = ..., effective_ids: bool = ..., follow_symlinks: bool = ... ) -> bool: ... def chdir(path: _FdOrAnyPath) -> None: ... @@ -595,12 +595,12 @@ if sys.platform != "win32": def getcwd() -> str: ... def getcwdb() -> bytes: ... -def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... +def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> None: ... if sys.platform != "win32": def chflags(path: StrOrBytesPath, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix def chown( - path: _FdOrAnyPath, uid: int, gid: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ... + path: _FdOrAnyPath, uid: int, gid: int, *, dir_fd: int | None = ..., follow_symlinks: bool = ... ) -> None: ... # Unix only if sys.platform != "win32": @@ -614,36 +614,36 @@ def link( src: StrOrBytesPath, dst: StrOrBytesPath, *, - src_dir_fd: Optional[int] = ..., - dst_dir_fd: Optional[int] = ..., + src_dir_fd: int | None = ..., + dst_dir_fd: int | None = ..., follow_symlinks: bool = ..., ) -> None: ... -def lstat(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> stat_result: ... -def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... +def lstat(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> stat_result: ... +def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ... if sys.platform != "win32": - def mkfifo(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only + def mkfifo(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ... # Unix only def makedirs(name: StrOrBytesPath, mode: int = ..., exist_ok: bool = ...) -> None: ... if sys.platform != "win32": - def mknod(path: StrOrBytesPath, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... + def mknod(path: StrOrBytesPath, mode: int = ..., device: int = ..., *, dir_fd: int | None = ...) -> None: ... def major(__device: int) -> int: ... def minor(__device: int) -> int: ... def makedev(__major: int, __minor: int) -> int: ... - def pathconf(path: _FdOrAnyPath, name: Union[str, int]) -> int: ... # Unix only + def pathconf(path: _FdOrAnyPath, name: str | int) -> int: ... # Unix only -def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ... -def remove(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... +def readlink(path: AnyStr | PathLike[AnyStr], *, dir_fd: int | None = ...) -> AnyStr: ... +def remove(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... def removedirs(name: StrOrBytesPath) -> None: ... def rename( - src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ... + src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ... ) -> None: ... def renames(old: StrOrBytesPath, new: StrOrBytesPath) -> None: ... def replace( - src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ... + src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ... ) -> None: ... -def rmdir(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... +def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... @@ -655,15 +655,15 @@ if sys.version_info >= (3, 7): @overload def scandir(path: int) -> _ScandirIterator[str]: ... @overload - def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ... + def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ... else: @overload def scandir(path: None = ...) -> _ScandirIterator[str]: ... @overload - def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ... + def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ... -def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ... +def stat(path: _FdOrAnyPath, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> stat_result: ... if sys.version_info < (3, 7): @overload @@ -675,27 +675,27 @@ if sys.platform != "win32": def statvfs(path: _FdOrAnyPath) -> statvfs_result: ... # Unix only def symlink( - src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: Optional[int] = ... + src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: int | None = ... ) -> None: ... if sys.platform != "win32": def sync() -> None: ... # Unix only def truncate(path: _FdOrAnyPath, length: int) -> None: ... # Unix only up to version 3.4 -def unlink(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... +def unlink(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... def utime( path: _FdOrAnyPath, - times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ..., + times: Tuple[int, int] | Tuple[float, float] | None = ..., *, ns: Tuple[int, int] = ..., - dir_fd: Optional[int] = ..., + dir_fd: int | None = ..., follow_symlinks: bool = ..., ) -> None: ... _OnError = Callable[[OSError], Any] def walk( - top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., onerror: Optional[_OnError] = ..., followlinks: bool = ... + top: AnyStr | PathLike[AnyStr], topdown: bool = ..., onerror: _OnError | None = ..., followlinks: bool = ... ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... if sys.platform != "win32": @@ -704,32 +704,32 @@ if sys.platform != "win32": def fwalk( top: StrPath = ..., topdown: bool = ..., - onerror: Optional[_OnError] = ..., + onerror: _OnError | None = ..., *, follow_symlinks: bool = ..., - dir_fd: Optional[int] = ..., + dir_fd: int | None = ..., ) -> Iterator[Tuple[str, List[str], List[str], int]]: ... @overload def fwalk( top: bytes, topdown: bool = ..., - onerror: Optional[_OnError] = ..., + onerror: _OnError | None = ..., *, follow_symlinks: bool = ..., - dir_fd: Optional[int] = ..., + dir_fd: int | None = ..., ) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ... else: def fwalk( top: StrPath = ..., topdown: bool = ..., - onerror: Optional[_OnError] = ..., + onerror: _OnError | None = ..., *, follow_symlinks: bool = ..., - dir_fd: Optional[int] = ..., + dir_fd: int | None = ..., ) -> Iterator[Tuple[str, List[str], List[str], int]]: ... if sys.platform == "linux": def getxattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> bytes: ... - def listxattr(path: Optional[_FdOrAnyPath] = ..., *, follow_symlinks: bool = ...) -> List[str]: ... + def listxattr(path: _FdOrAnyPath | None = ..., *, follow_symlinks: bool = ...) -> List[str]: ... def removexattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> None: ... def setxattr( path: _FdOrAnyPath, attribute: StrOrBytesPath, value: bytes, flags: int = ..., *, follow_symlinks: bool = ... @@ -755,10 +755,10 @@ _ExecVArgs = Union[ List[bytes], List[str], List[PathLike[Any]], - List[Union[bytes, str]], - List[Union[bytes, PathLike[Any]]], - List[Union[str, PathLike[Any]]], - List[Union[bytes, str, PathLike[Any]]], + List[bytes | str], + List[bytes | PathLike[Any]], + List[str | PathLike[Any]], + List[bytes | str | PathLike[Any]], ] _ExecEnv = Union[Mapping[bytes, Union[bytes, str]], Mapping[str, Union[bytes, str]]] @@ -780,7 +780,7 @@ if sys.platform != "win32": class _wrap_close(_TextIOWrapper): def __init__(self, stream: _TextIOWrapper, proc: Popen[str]) -> None: ... - def close(self) -> Optional[int]: ... # type: ignore + def close(self) -> int | None: ... # type: ignore def popen(cmd: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ... def spawnl(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: ... @@ -799,7 +799,7 @@ def times() -> times_result: ... def waitpid(__pid: int, __options: int) -> Tuple[int, int]: ... if sys.platform == "win32": - def startfile(path: StrOrBytesPath, operation: Optional[str] = ...) -> None: ... + def startfile(path: StrOrBytesPath, operation: str | None = ...) -> None: ... else: # Unix only @@ -838,13 +838,13 @@ if sys.platform != "win32": def sched_setaffinity(pid: int, mask: Iterable[int]) -> None: ... # some flavors of Unix def sched_getaffinity(pid: int) -> Set[int]: ... # some flavors of Unix -def cpu_count() -> Optional[int]: ... +def cpu_count() -> int | None: ... if sys.platform != "win32": # Unix only - def confstr(__name: Union[str, int]) -> Optional[str]: ... + def confstr(__name: str | int) -> str | None: ... def getloadavg() -> Tuple[float, float, float]: ... - def sysconf(__name: Union[str, int]) -> int: ... + def sysconf(__name: str | int) -> int: ... if sys.platform == "linux": def getrandom(size: int, flags: int = ...) -> bytes: ... @@ -854,16 +854,16 @@ def urandom(__size: int) -> bytes: ... if sys.version_info >= (3, 7) and sys.platform != "win32": def register_at_fork( *, - before: Optional[Callable[..., Any]] = ..., - after_in_parent: Optional[Callable[..., Any]] = ..., - after_in_child: Optional[Callable[..., Any]] = ..., + before: Callable[..., Any] | None = ..., + after_in_parent: Callable[..., Any] | None = ..., + after_in_child: Callable[..., Any] | None = ..., ) -> None: ... if sys.version_info >= (3, 8): if sys.platform == "win32": class _AddedDllDirectory: - path: Optional[str] - def __init__(self, path: Optional[str], cookie: _T, remove_dll_directory: Callable[[_T], Any]) -> None: ... + path: str | None + def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], Any]) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 11c96fae6093..11f0618e2da8 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -64,8 +64,8 @@ class Path(PurePath): def __new__(cls: Type[_P], *args: StrPath, **kwargs: Any) -> _P: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... @classmethod def cwd(cls: Type[_P]) -> _P: ... def stat(self) -> stat_result: ... @@ -93,9 +93,9 @@ class Path(PurePath): self, mode: OpenTextMode = ..., buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> TextIOWrapper: ... # Unbuffered binary mode: returns a FileIO @overload @@ -141,23 +141,23 @@ class Path(PurePath): self, mode: str, buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> IO[Any]: ... def owner(self) -> str: ... if sys.version_info >= (3, 9): def readlink(self: _P) -> _P: ... if sys.version_info >= (3, 8): - def rename(self: _P, target: Union[str, PurePath]) -> _P: ... - def replace(self: _P, target: Union[str, PurePath]) -> _P: ... + def rename(self: _P, target: str | PurePath) -> _P: ... + def replace(self: _P, target: str | PurePath) -> _P: ... else: - def rename(self, target: Union[str, PurePath]) -> None: ... - def replace(self, target: Union[str, PurePath]) -> None: ... + def rename(self, target: str | PurePath) -> None: ... + def replace(self, target: str | PurePath) -> None: ... def resolve(self: _P, strict: bool = ...) -> _P: ... def rglob(self: _P, pattern: str) -> Generator[_P, None, None]: ... def rmdir(self) -> None: ... - def symlink_to(self, target: Union[str, Path], target_is_directory: bool = ...) -> None: ... + def symlink_to(self, target: str | Path, target_is_directory: bool = ...) -> None: ... def touch(self, mode: int = ..., exist_ok: bool = ...) -> None: ... if sys.version_info >= (3, 8): def unlink(self, missing_ok: bool = ...) -> None: ... @@ -168,12 +168,12 @@ class Path(PurePath): def absolute(self: _P) -> _P: ... def expanduser(self: _P) -> _P: ... def read_bytes(self) -> bytes: ... - def read_text(self, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ... - def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ... + def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ... + def samefile(self, other_path: str | bytes | int | Path) -> bool: ... def write_bytes(self, data: bytes) -> int: ... - def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ... + def write_text(self, data: str, encoding: str | None = ..., errors: str | None = ...) -> int: ... if sys.version_info >= (3, 8): - def link_to(self, target: Union[StrPath, bytes]) -> None: ... + def link_to(self, target: StrPath | bytes) -> None: ... class PosixPath(Path, PurePosixPath): ... class WindowsPath(Path, PureWindowsPath): ... diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index ac25b368d6c6..ae4383f361d5 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -12,18 +12,18 @@ line_prefix: str # undocumented class Restart(Exception): ... -def run(statement: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ... -def runeval(expression: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> Any: ... +def run(statement: str, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... +def runeval(expression: str, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> Any: ... def runctx(statement: str, globals: Dict[str, Any], locals: Mapping[str, Any]) -> None: ... -def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... +def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> _T | None: ... if sys.version_info >= (3, 7): - def set_trace(*, header: Optional[str] = ...) -> None: ... + def set_trace(*, header: str | None = ...) -> None: ... else: def set_trace() -> None: ... -def post_mortem(t: Optional[TracebackType] = ...) -> None: ... +def post_mortem(t: TracebackType | None = ...) -> None: ... def pm() -> None: ... class Pdb(Bdb, Cmd): @@ -39,66 +39,66 @@ class Pdb(Bdb, Cmd): commands_doprompt: Dict[int, bool] commands_silent: Dict[int, bool] commands_defining: bool - commands_bnum: Optional[int] - lineno: Optional[int] + commands_bnum: int | None + lineno: int | None stack: List[Tuple[FrameType, int]] curindex: int - curframe: Optional[FrameType] + curframe: FrameType | None curframe_locals: Mapping[str, Any] def __init__( self, completekey: str = ..., - stdin: Optional[IO[str]] = ..., - stdout: Optional[IO[str]] = ..., - skip: Optional[Iterable[str]] = ..., + stdin: IO[str] | None = ..., + stdout: IO[str] | None = ..., + skip: Iterable[str] | None = ..., nosigint: bool = ..., readrc: bool = ..., ) -> None: ... def forget(self) -> None: ... - def setup(self, f: Optional[FrameType], tb: Optional[TracebackType]) -> None: ... + def setup(self, f: FrameType | None, tb: TracebackType | None) -> None: ... def execRcLines(self) -> None: ... def bp_commands(self, frame: FrameType) -> bool: ... - def interaction(self, frame: Optional[FrameType], traceback: Optional[TracebackType]) -> None: ... + def interaction(self, frame: FrameType | None, traceback: TracebackType | None) -> None: ... def displayhook(self, obj: object) -> None: ... def handle_command_def(self, line: str) -> bool: ... def defaultFile(self) -> str: ... - def lineinfo(self, identifier: str) -> Union[Tuple[None, None, None], Tuple[str, str, int]]: ... + def lineinfo(self, identifier: str) -> Tuple[None, None, None] | Tuple[str, str, int]: ... def checkline(self, filename: str, lineno: int) -> int: ... def _getval(self, arg: str) -> object: ... def print_stack_trace(self) -> None: ... def print_stack_entry(self, frame_lineno: Tuple[FrameType, int], prompt_prefix: str = ...) -> None: ... - def lookupmodule(self, filename: str) -> Optional[str]: ... + def lookupmodule(self, filename: str) -> str | None: ... def _runscript(self, filename: str) -> None: ... - def do_commands(self, arg: str) -> Optional[bool]: ... - def do_break(self, arg: str, temporary: bool = ...) -> Optional[bool]: ... - def do_tbreak(self, arg: str) -> Optional[bool]: ... - def do_enable(self, arg: str) -> Optional[bool]: ... - def do_disable(self, arg: str) -> Optional[bool]: ... - def do_condition(self, arg: str) -> Optional[bool]: ... - def do_ignore(self, arg: str) -> Optional[bool]: ... - def do_clear(self, arg: str) -> Optional[bool]: ... - def do_where(self, arg: str) -> Optional[bool]: ... - def do_up(self, arg: str) -> Optional[bool]: ... - def do_down(self, arg: str) -> Optional[bool]: ... - def do_until(self, arg: str) -> Optional[bool]: ... - def do_step(self, arg: str) -> Optional[bool]: ... - def do_next(self, arg: str) -> Optional[bool]: ... - def do_run(self, arg: str) -> Optional[bool]: ... - def do_return(self, arg: str) -> Optional[bool]: ... - def do_continue(self, arg: str) -> Optional[bool]: ... - def do_jump(self, arg: str) -> Optional[bool]: ... - def do_debug(self, arg: str) -> Optional[bool]: ... - def do_quit(self, arg: str) -> Optional[bool]: ... - def do_EOF(self, arg: str) -> Optional[bool]: ... - def do_args(self, arg: str) -> Optional[bool]: ... - def do_retval(self, arg: str) -> Optional[bool]: ... - def do_p(self, arg: str) -> Optional[bool]: ... - def do_pp(self, arg: str) -> Optional[bool]: ... - def do_list(self, arg: str) -> Optional[bool]: ... - def do_whatis(self, arg: str) -> Optional[bool]: ... - def do_alias(self, arg: str) -> Optional[bool]: ... - def do_unalias(self, arg: str) -> Optional[bool]: ... - def do_help(self, arg: str) -> Optional[bool]: ... + def do_commands(self, arg: str) -> bool | None: ... + def do_break(self, arg: str, temporary: bool = ...) -> bool | None: ... + def do_tbreak(self, arg: str) -> bool | None: ... + def do_enable(self, arg: str) -> bool | None: ... + def do_disable(self, arg: str) -> bool | None: ... + def do_condition(self, arg: str) -> bool | None: ... + def do_ignore(self, arg: str) -> bool | None: ... + def do_clear(self, arg: str) -> bool | None: ... + def do_where(self, arg: str) -> bool | None: ... + def do_up(self, arg: str) -> bool | None: ... + def do_down(self, arg: str) -> bool | None: ... + def do_until(self, arg: str) -> bool | None: ... + def do_step(self, arg: str) -> bool | None: ... + def do_next(self, arg: str) -> bool | None: ... + def do_run(self, arg: str) -> bool | None: ... + def do_return(self, arg: str) -> bool | None: ... + def do_continue(self, arg: str) -> bool | None: ... + def do_jump(self, arg: str) -> bool | None: ... + def do_debug(self, arg: str) -> bool | None: ... + def do_quit(self, arg: str) -> bool | None: ... + def do_EOF(self, arg: str) -> bool | None: ... + def do_args(self, arg: str) -> bool | None: ... + def do_retval(self, arg: str) -> bool | None: ... + def do_p(self, arg: str) -> bool | None: ... + def do_pp(self, arg: str) -> bool | None: ... + def do_list(self, arg: str) -> bool | None: ... + def do_whatis(self, arg: str) -> bool | None: ... + def do_alias(self, arg: str) -> bool | None: ... + def do_unalias(self, arg: str) -> bool | None: ... + def do_help(self, arg: str) -> bool | None: ... do_b = do_break do_cl = do_clear do_w = do_where @@ -125,16 +125,16 @@ class Pdb(Bdb, Cmd): def message(self, msg: str) -> None: ... def error(self, msg: str) -> None: ... def _select_frame(self, number: int) -> None: ... - def _getval_except(self, arg: str, frame: Optional[FrameType] = ...) -> object: ... + def _getval_except(self, arg: str, frame: FrameType | None = ...) -> object: ... def _print_lines( - self, lines: Sequence[str], start: int, breaks: Sequence[int] = ..., frame: Optional[FrameType] = ... + self, lines: Sequence[str], start: int, breaks: Sequence[int] = ..., frame: FrameType | None = ... ) -> None: ... def _cmdloop(self) -> None: ... - def do_display(self, arg: str) -> Optional[bool]: ... - def do_interact(self, arg: str) -> Optional[bool]: ... - def do_longlist(self, arg: str) -> Optional[bool]: ... - def do_source(self, arg: str) -> Optional[bool]: ... - def do_undisplay(self, arg: str) -> Optional[bool]: ... + def do_display(self, arg: str) -> bool | None: ... + def do_interact(self, arg: str) -> bool | None: ... + def do_longlist(self, arg: str) -> bool | None: ... + def do_source(self, arg: str) -> bool | None: ... + def do_undisplay(self, arg: str) -> bool | None: ... do_ll = do_longlist def _complete_location(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... def _complete_bpnumber(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... @@ -164,7 +164,7 @@ class Pdb(Bdb, Cmd): # undocumented -def find_function(funcname: str, filename: str) -> Optional[Tuple[str, str, int]]: ... +def find_function(funcname: str, filename: str) -> Tuple[str, str, int] | None: ... def main() -> None: ... def help() -> None: ... def getsourcelines(obj: _SourceObjectType) -> Tuple[List[str], int]: ... diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index 4183a019402a..2cfadf05ec73 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -17,13 +17,13 @@ if sys.version_info >= (3, 8): def dump( obj: Any, file: IO[bytes], - protocol: Optional[int] = ..., + protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ..., ) -> None: ... def dumps( - obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... + obj: Any, protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... ) -> bytes: ... def load( file: IO[bytes], @@ -31,15 +31,15 @@ if sys.version_info >= (3, 8): fix_imports: bool = ..., encoding: str = ..., errors: str = ..., - buffers: Optional[Iterable[Any]] = ..., + buffers: Iterable[Any] | None = ..., ) -> Any: ... def loads( - __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Optional[Iterable[Any]] = ... + __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ... ) -> Any: ... else: - def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... - def dumps(obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> bytes: ... + def dump(obj: Any, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ... + def dumps(obj: Any, protocol: int | None = ..., *, fix_imports: bool = ...) -> bytes: ... def load(file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ... def loads(data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ... @@ -51,8 +51,8 @@ _reducedtype = Union[ str, Tuple[Callable[..., Any], Tuple[Any, ...]], Tuple[Callable[..., Any], Tuple[Any, ...], Any], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]]], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]], + Tuple[Callable[..., Any], Tuple[Any, ...], Any, Iterator[Any] | None], + Tuple[Callable[..., Any], Tuple[Any, ...], Any, Iterator[Any] | None, Iterator[Any] | None], ] class Pickler: @@ -65,14 +65,14 @@ class Pickler: def __init__( self, file: IO[bytes], - protocol: Optional[int] = ..., + protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ..., ) -> None: ... def reducer_override(self, obj: Any) -> Any: ... else: - def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... + def __init__(self, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ... def dump(self, __obj: Any) -> None: ... def clear_memo(self) -> None: ... def persistent_id(self, obj: Any) -> Any: ... @@ -88,7 +88,7 @@ class Unpickler: fix_imports: bool = ..., encoding: str = ..., errors: str = ..., - buffers: Optional[Iterable[Any]] = ..., + buffers: Iterable[Any] | None = ..., ) -> None: ... else: def __init__(self, file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> None: ... diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 59c06624a6d5..99eac8bde92d 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -36,7 +36,7 @@ def read_uint8(f: IO[bytes]) -> int: ... uint8: ArgumentDescriptor -def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> Union[bytes, str]: ... +def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> bytes | str: ... stringnl: ArgumentDescriptor @@ -108,9 +108,9 @@ long4: ArgumentDescriptor class StackObject(object): name: str - obtype: Union[Type[Any], Tuple[Type[Any], ...]] + obtype: Type[Any] | Tuple[Type[Any], ...] doc: str - def __init__(self, name: str, obtype: Union[Type[Any], Tuple[Type[Any], ...]], doc: str) -> None: ... + def __init__(self, name: str, obtype: Type[Any] | Tuple[Type[Any], ...], doc: str) -> None: ... pyint: StackObject pylong: StackObject @@ -134,7 +134,7 @@ stackslice: StackObject class OpcodeInfo(object): name: str code: str - arg: Optional[ArgumentDescriptor] + arg: ArgumentDescriptor | None stack_before: List[StackObject] stack_after: List[StackObject] proto: int @@ -143,7 +143,7 @@ class OpcodeInfo(object): self, name: str, code: str, - arg: Optional[ArgumentDescriptor], + arg: ArgumentDescriptor | None, stack_before: List[StackObject], stack_after: List[StackObject], proto: int, @@ -152,12 +152,12 @@ class OpcodeInfo(object): opcodes: List[OpcodeInfo] -def genops(pickle: Union[bytes, IO[bytes]]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... -def optimize(p: Union[bytes, IO[bytes]]) -> bytes: ... +def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Any | None, int | None]]: ... +def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( - pickle: Union[bytes, IO[bytes]], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., + pickle: bytes | IO[bytes], + out: IO[str] | None = ..., + memo: MutableMapping[int, Any] | None = ..., indentlevel: int = ..., annotate: int = ..., ) -> None: ... diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index 583b262d44a2..51aa1d6dfa28 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -4,28 +4,28 @@ from importlib.abc import Loader, MetaPathFinder, PathEntryFinder from typing import IO, Any, Callable, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Union class ModuleInfo(NamedTuple): - module_finder: Union[MetaPathFinder, PathEntryFinder] + module_finder: MetaPathFinder | PathEntryFinder name: str ispkg: bool def extend_path(path: List[str], name: str) -> List[str]: ... class ImpImporter: - def __init__(self, path: Optional[str] = ...) -> None: ... + def __init__(self, path: str | None = ...) -> None: ... class ImpLoader: def __init__(self, fullname: str, file: IO[str], filename: str, etc: Tuple[str, str, int]) -> None: ... -def find_loader(fullname: str) -> Optional[Loader]: ... -def get_importer(path_item: str) -> Optional[PathEntryFinder]: ... +def find_loader(fullname: str) -> Loader | None: ... +def get_importer(path_item: str) -> PathEntryFinder | None: ... def get_loader(module_or_name: str) -> Loader: ... -def iter_importers(fullname: str = ...) -> Iterator[Union[MetaPathFinder, PathEntryFinder]]: ... -def iter_modules(path: Optional[Iterable[str]] = ..., prefix: str = ...) -> Iterator[ModuleInfo]: ... +def iter_importers(fullname: str = ...) -> Iterator[MetaPathFinder | PathEntryFinder]: ... +def iter_modules(path: Iterable[str] | None = ..., prefix: str = ...) -> Iterator[ModuleInfo]: ... def read_code(stream: SupportsRead[bytes]) -> Any: ... # undocumented def walk_packages( - path: Optional[Iterable[str]] = ..., prefix: str = ..., onerror: Optional[Callable[[str], None]] = ... + path: Iterable[str] | None = ..., prefix: str = ..., onerror: Callable[[str], None] | None = ... ) -> Iterator[ModuleInfo]: ... -def get_data(package: str, resource: str) -> Optional[bytes]: ... +def get_data(package: str, resource: str) -> bytes | None: ... if sys.version_info >= (3, 9): def resolve_name(name: str) -> Any: ... diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index 217882224d74..0f75cf82c8a0 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -8,7 +8,7 @@ from typing import NamedTuple, Optional, Tuple if sys.version_info >= (3, 8): def libc_ver( - executable: Optional[str] = ..., lib: str = ..., version: str = ..., chunksize: int = ... + executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ... ) -> Tuple[str, str]: ... else: diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index c74d0d8d5951..6551577b6d92 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -10,21 +10,21 @@ FMT_XML = PlistFormat.FMT_XML FMT_BINARY = PlistFormat.FMT_BINARY if sys.version_info >= (3, 9): - def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... - def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... + def load(fp: IO[bytes], *, fmt: PlistFormat | None = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... + def loads(value: bytes, *, fmt: PlistFormat | None = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... else: def load( fp: IO[bytes], *, - fmt: Optional[PlistFormat] = ..., + fmt: PlistFormat | None = ..., use_builtin_types: bool = ..., dict_type: Type[MutableMapping[str, Any]] = ..., ) -> Any: ... def loads( value: bytes, *, - fmt: Optional[PlistFormat] = ..., + fmt: PlistFormat | None = ..., use_builtin_types: bool = ..., dict_type: Type[MutableMapping[str, Any]] = ..., ) -> Any: ... @@ -35,8 +35,8 @@ def dump( def dumps(value: Mapping[str, Any], *, fmt: PlistFormat = ..., skipkeys: bool = ..., sort_keys: bool = ...) -> bytes: ... if sys.version_info < (3, 9): - def readPlist(pathOrFile: Union[str, IO[bytes]]) -> Any: ... - def writePlist(value: Mapping[str, Any], pathOrFile: Union[str, IO[bytes]]) -> None: ... + def readPlist(pathOrFile: str | IO[bytes]) -> Any: ... + def writePlist(value: Mapping[str, Any], pathOrFile: str | IO[bytes]) -> None: ... def readPlistFromBytes(data: bytes) -> Any: ... def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... diff --git a/stdlib/poplib.pyi b/stdlib/poplib.pyi index 8f09c59f930b..f63319ea0914 100644 --- a/stdlib/poplib.pyi +++ b/stdlib/poplib.pyi @@ -25,7 +25,7 @@ class POP3: def user(self, user: str) -> bytes: ... def pass_(self, pswd: str) -> bytes: ... def stat(self) -> Tuple[int, int]: ... - def list(self, which: Optional[Any] = ...) -> _LongResp: ... + def list(self, which: Any | None = ...) -> _LongResp: ... def retr(self, which: Any) -> _LongResp: ... def dele(self, which: Any) -> bytes: ... def noop(self) -> bytes: ... @@ -42,17 +42,17 @@ class POP3: def uidl(self, which: Any) -> bytes: ... def utf8(self) -> bytes: ... def capa(self) -> Dict[str, List[str]]: ... - def stls(self, context: Optional[ssl.SSLContext] = ...) -> bytes: ... + def stls(self, context: ssl.SSLContext | None = ...) -> bytes: ... class POP3_SSL(POP3): def __init__( self, host: str, port: int = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., + keyfile: str | None = ..., + certfile: str | None = ..., timeout: float = ..., - context: Optional[ssl.SSLContext] = ..., + context: ssl.SSLContext | None = ..., ) -> None: ... # "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored def stls(self, context: Any = ..., keyfile: Any = ..., certfile: Any = ...) -> bytes: ... diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 5c5ab4cf4202..353b858022c5 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -159,7 +159,7 @@ XATTR_REPLACE: int XATTR_SIZE_MAX: int @overload -def listdir(path: Optional[str] = ...) -> List[str]: ... +def listdir(path: str | None = ...) -> List[str]: ... @overload def listdir(path: bytes) -> List[bytes]: ... @overload @@ -173,26 +173,26 @@ if sys.platform != "win32" and sys.version_info >= (3, 8): argv: _ExecVArgs, env: _ExecEnv, *, - file_actions: Optional[Sequence[Tuple[Any, ...]]] = ..., - setpgroup: Optional[int] = ..., + file_actions: Sequence[Tuple[Any, ...]] | None = ..., + setpgroup: int | None = ..., resetids: bool = ..., setsid: bool = ..., setsigmask: Iterable[int] = ..., setsigdef: Iterable[int] = ..., - scheduler: Optional[Tuple[Any, sched_param]] = ..., + scheduler: Tuple[Any, sched_param] | None = ..., ) -> int: ... def posix_spawnp( path: StrOrBytesPath, argv: _ExecVArgs, env: _ExecEnv, *, - file_actions: Optional[Sequence[Tuple[Any, ...]]] = ..., - setpgroup: Optional[int] = ..., + file_actions: Sequence[Tuple[Any, ...]] | None = ..., + setpgroup: int | None = ..., resetids: bool = ..., setsid: bool = ..., setsigmask: Iterable[int] = ..., setsigdef: Iterable[int] = ..., - scheduler: Optional[Tuple[Any, sched_param]] = ..., + scheduler: Tuple[Any, sched_param] | None = ..., ) -> int: ... if sys.platform == "win32": diff --git a/stdlib/posixpath.pyi b/stdlib/posixpath.pyi index 4f0fcb7ed191..d357f2323e5a 100644 --- a/stdlib/posixpath.pyi +++ b/stdlib/posixpath.pyi @@ -21,7 +21,7 @@ supports_unicode_filenames: bool curdir: str pardir: str sep: str -altsep: Optional[str] +altsep: str | None extsep: str pathsep: str defpath: str @@ -78,9 +78,9 @@ else: def realpath(filename: AnyStr) -> AnyStr: ... @overload -def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ... +def relpath(path: BytesPath, start: BytesPath | None = ...) -> bytes: ... @overload -def relpath(path: StrPath, start: Optional[StrPath] = ...) -> str: ... +def relpath(path: StrPath, start: StrPath | None = ...) -> str: ... @overload def split(p: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... @overload diff --git a/stdlib/pprint.pyi b/stdlib/pprint.pyi index 7220010c8f05..f32b58427e37 100644 --- a/stdlib/pprint.pyi +++ b/stdlib/pprint.pyi @@ -6,7 +6,7 @@ if sys.version_info >= (3, 10): object: object, indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -18,7 +18,7 @@ elif sys.version_info >= (3, 8): object: object, indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -26,16 +26,16 @@ elif sys.version_info >= (3, 8): else: def pformat( - object: object, indent: int = ..., width: int = ..., depth: Optional[int] = ..., *, compact: bool = ... + object: object, indent: int = ..., width: int = ..., depth: int | None = ..., *, compact: bool = ... ) -> str: ... if sys.version_info >= (3, 10): def pp( object: object, - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -45,10 +45,10 @@ if sys.version_info >= (3, 10): elif sys.version_info >= (3, 8): def pp( object: object, - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -57,10 +57,10 @@ elif sys.version_info >= (3, 8): if sys.version_info >= (3, 10): def pprint( object: object, - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -70,10 +70,10 @@ if sys.version_info >= (3, 10): elif sys.version_info >= (3, 8): def pprint( object: object, - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -82,10 +82,10 @@ elif sys.version_info >= (3, 8): else: def pprint( object: object, - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., ) -> None: ... @@ -100,8 +100,8 @@ class PrettyPrinter: self, indent: int = ..., width: int = ..., - depth: Optional[int] = ..., - stream: Optional[IO[str]] = ..., + depth: int | None = ..., + stream: IO[str] | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -112,8 +112,8 @@ class PrettyPrinter: self, indent: int = ..., width: int = ..., - depth: Optional[int] = ..., - stream: Optional[IO[str]] = ..., + depth: int | None = ..., + stream: IO[str] | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -123,8 +123,8 @@ class PrettyPrinter: self, indent: int = ..., width: int = ..., - depth: Optional[int] = ..., - stream: Optional[IO[str]] = ..., + depth: int | None = ..., + stream: IO[str] | None = ..., *, compact: bool = ..., ) -> None: ... diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index 8052ede76aaf..2b822d7d5e52 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,9 +1,9 @@ from _typeshed import StrOrBytesPath from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union -def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... +def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( - statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: Optional[str] = ..., sort: Union[str, int] = ... + statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) @@ -13,11 +13,11 @@ _Label = Tuple[str, int, str] class Profile: bias: int stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented - def __init__(self, timer: Optional[Callable[[], float]] = ..., bias: Optional[int] = ...) -> None: ... + def __init__(self, timer: Callable[[], float] | None = ..., bias: int | None = ...) -> None: ... def set_cmd(self, cmd: str) -> None: ... def simulate_call(self, name: str) -> None: ... def simulate_cmd_complete(self) -> None: ... - def print_stats(self, sort: Union[str, int] = ...) -> None: ... + def print_stats(self, sort: str | int = ...) -> None: ... def dump_stats(self, file: StrOrBytesPath) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index 80ce44ddd54b..a9b1095cadf1 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -24,14 +24,14 @@ class Stats: sort_arg_dict_default: Dict[str, Tuple[Any, str]] def __init__( self: _T, - __arg: Union[None, str, Profile, _cProfile] = ..., - *args: Union[None, str, Profile, _cProfile, _T], - stream: Optional[IO[Any]] = ..., + __arg: None | str | Profile | _cProfile = ..., + *args: None | str | Profile | _cProfile | _T, + stream: IO[Any] | None = ..., ) -> None: ... - def init(self, arg: Union[None, str, Profile, _cProfile]) -> None: ... - def load_stats(self, arg: Union[None, str, Profile, _cProfile]) -> None: ... + def init(self, arg: None | str | Profile | _cProfile) -> None: ... + def load_stats(self, arg: None | str | Profile | _cProfile) -> None: ... def get_top_level_stats(self) -> None: ... - def add(self: _T, *arg_list: Union[None, str, Profile, _cProfile, _T]) -> _T: ... + def add(self: _T, *arg_list: None | str | Profile | _cProfile | _T) -> _T: ... def dump_stats(self, filename: StrOrBytesPath) -> None: ... def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ... @overload diff --git a/stdlib/pty.pyi b/stdlib/pty.pyi index d554d6041d3d..25959cd9fb35 100644 --- a/stdlib/pty.pyi +++ b/stdlib/pty.pyi @@ -12,4 +12,4 @@ def openpty() -> Tuple[int, int]: ... def master_open() -> Tuple[int, str]: ... def slave_open(tty_name: str) -> int: ... def fork() -> Tuple[int, int]: ... -def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... +def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 6a563a858282..7816ee2bf9a5 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -19,27 +19,27 @@ if sys.version_info >= (3, 7): if sys.version_info >= (3, 8): def compile( file: AnyStr, - cfile: Optional[AnyStr] = ..., - dfile: Optional[AnyStr] = ..., + cfile: AnyStr | None = ..., + dfile: AnyStr | None = ..., doraise: bool = ..., optimize: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., + invalidation_mode: PycInvalidationMode | None = ..., quiet: int = ..., - ) -> Optional[AnyStr]: ... + ) -> AnyStr | None: ... elif sys.version_info >= (3, 7): def compile( file: AnyStr, - cfile: Optional[AnyStr] = ..., - dfile: Optional[AnyStr] = ..., + cfile: AnyStr | None = ..., + dfile: AnyStr | None = ..., doraise: bool = ..., optimize: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., - ) -> Optional[AnyStr]: ... + invalidation_mode: PycInvalidationMode | None = ..., + ) -> AnyStr | None: ... else: def compile( - file: AnyStr, cfile: Optional[AnyStr] = ..., dfile: Optional[AnyStr] = ..., doraise: bool = ..., optimize: int = ... - ) -> Optional[AnyStr]: ... + file: AnyStr, cfile: AnyStr | None = ..., dfile: AnyStr | None = ..., doraise: bool = ..., optimize: int = ... + ) -> AnyStr | None: ... -def main(args: Optional[List[str]] = ...) -> int: ... +def main(args: List[str] | None = ...) -> int: ... diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index 665ea43c0d4a..77a342edb861 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -4,7 +4,7 @@ from typing import Dict, List, Optional, Sequence, Union class Class: module: str name: str - super: Optional[List[Union[Class, str]]] + super: List[Class | str] | None methods: Dict[str, int] file: int lineno: int @@ -14,13 +14,13 @@ class Class: self, module: str, name: str, - super: Optional[List[Union[Class, str]]], + super: List[Class | str] | None, file: str, lineno: int, - parent: Optional[Class] = ..., + parent: Class | None = ..., ) -> None: ... else: - def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... + def __init__(self, module: str, name: str, super: List[Class | str] | None, file: str, lineno: int) -> None: ... class Function: module: str @@ -29,9 +29,9 @@ class Function: lineno: int if sys.version_info >= (3, 7): - def __init__(self, module: str, name: str, file: str, lineno: int, parent: Optional[Function] = ...) -> None: ... + def __init__(self, module: str, name: str, file: str, lineno: int, parent: Function | None = ...) -> None: ... else: def __init__(self, module: str, name: str, file: str, lineno: int) -> None: ... -def readmodule(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Class]: ... -def readmodule_ex(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Union[Class, Function, List[str]]]: ... +def readmodule(module: str, path: Sequence[str] | None = ...) -> Dict[str, Class]: ... +def readmodule_ex(module: str, path: Sequence[str] | None = ...) -> Dict[str, Class | Function | List[str]]: ... diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index b41bef54304f..4b0e9b5f7819 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -35,17 +35,17 @@ def replace(text: AnyStr, *pairs: AnyStr) -> AnyStr: ... def cram(text: str, maxlen: int) -> str: ... def stripid(text: str) -> str: ... def allmethods(cl: type) -> MutableMapping[str, MethodType]: ... -def visiblename(name: str, all: Optional[Container[str]] = ..., obj: Optional[object] = ...) -> bool: ... +def visiblename(name: str, all: Container[str] | None = ..., obj: object | None = ...) -> bool: ... def classify_class_attrs(object: object) -> List[Tuple[str, str, type, str]]: ... def ispackage(path: str) -> bool: ... -def source_synopsis(file: IO[AnyStr]) -> Optional[AnyStr]: ... -def synopsis(filename: str, cache: MutableMapping[str, Tuple[int, str]] = ...) -> Optional[str]: ... +def source_synopsis(file: IO[AnyStr]) -> AnyStr | None: ... +def synopsis(filename: str, cache: MutableMapping[str, Tuple[int, str]] = ...) -> str | None: ... class ErrorDuringImport(Exception): filename: str - exc: Optional[Type[BaseException]] - value: Optional[BaseException] - tb: Optional[TracebackType] + exc: Type[BaseException] | None + value: BaseException | None + tb: TracebackType | None def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... def importfile(path: str) -> ModuleType: ... @@ -53,15 +53,15 @@ def safeimport(path: str, forceload: bool = ..., cache: MutableMapping[str, Modu class Doc: PYTHONDOCS: str - def document(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... - def fail(self, object: object, name: Optional[str] = ..., *args: Any) -> NoReturn: ... - def docmodule(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... - def docclass(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... - def docroutine(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... - def docother(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... - def docproperty(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... - def docdata(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... - def getdocloc(self, object: object, basedir: str = ...) -> Optional[str]: ... + def document(self, object: object, name: str | None = ..., *args: Any) -> str: ... + def fail(self, object: object, name: str | None = ..., *args: Any) -> NoReturn: ... + def docmodule(self, object: object, name: str | None = ..., *args: Any) -> str: ... + def docclass(self, object: object, name: str | None = ..., *args: Any) -> str: ... + def docroutine(self, object: object, name: str | None = ..., *args: Any) -> str: ... + def docother(self, object: object, name: str | None = ..., *args: Any) -> str: ... + def docproperty(self, object: object, name: str | None = ..., *args: Any) -> str: ... + def docdata(self, object: object, name: str | None = ..., *args: Any) -> str: ... + def getdocloc(self, object: object, basedir: str = ...) -> str | None: ... class HTMLRepr(Repr): maxlist: int @@ -91,7 +91,7 @@ class HTMLDoc(Doc): contents: str, width: int = ..., prelude: str = ..., - marginalia: Optional[str] = ..., + marginalia: str | None = ..., gap: str = ..., ) -> str: ... def bigsection(self, title: str, *args: Any) -> str: ... @@ -105,20 +105,20 @@ class HTMLDoc(Doc): def markup( self, text: str, - escape: Optional[Callable[[str], str]] = ..., + escape: Callable[[str], str] | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., ) -> str: ... def formattree( - self, tree: List[Union[Tuple[type, Tuple[type, ...]], List[Any]]], modname: str, parent: Optional[type] = ... + self, tree: List[Tuple[type, Tuple[type, ...]] | List[Any]], modname: str, parent: type | None = ... ) -> str: ... - def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored: Any) -> str: ... + def docmodule(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... def docclass( self, object: object, - name: Optional[str] = ..., - mod: Optional[str] = ..., + name: str | None = ..., + mod: str | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., *ignored: Any, @@ -127,22 +127,22 @@ class HTMLDoc(Doc): def docroutine( self, object: object, - name: Optional[str] = ..., - mod: Optional[str] = ..., + name: str | None = ..., + mod: str | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., - cl: Optional[type] = ..., + cl: type | None = ..., *ignored: Any, ) -> str: ... def docproperty( - self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored: Any + self, object: object, name: str | None = ..., mod: str | None = ..., cl: Any | None = ..., *ignored: Any ) -> str: ... - def docother(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored: Any) -> str: ... + def docother(self, object: object, name: str | None = ..., mod: Any | None = ..., *ignored: Any) -> str: ... def docdata( - self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored: Any + self, object: object, name: str | None = ..., mod: Any | None = ..., cl: Any | None = ..., *ignored: Any ) -> str: ... - def index(self, dir: str, shadowed: Optional[MutableMapping[str, bool]] = ...) -> str: ... + def index(self, dir: str, shadowed: MutableMapping[str, bool] | None = ...) -> str: ... def filelink(self, url: str, path: str) -> str: ... class TextRepr(Repr): @@ -164,31 +164,31 @@ class TextDoc(Doc): def section(self, title: str, contents: str) -> str: ... def formattree( self, - tree: List[Union[Tuple[type, Tuple[type, ...]], List[Any]]], + tree: List[Tuple[type, Tuple[type, ...]] | List[Any]], modname: str, - parent: Optional[type] = ..., + parent: type | None = ..., prefix: str = ..., ) -> str: ... - def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored: Any) -> str: ... - def docclass(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored: Any) -> str: ... + def docmodule(self, object: object, name: str | None = ..., mod: Any | None = ..., *ignored: Any) -> str: ... + def docclass(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... def formatvalue(self, object: object) -> str: ... def docroutine( - self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored: Any + self, object: object, name: str | None = ..., mod: str | None = ..., cl: Any | None = ..., *ignored: Any ) -> str: ... def docproperty( - self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored: Any + self, object: object, name: str | None = ..., mod: Any | None = ..., cl: Any | None = ..., *ignored: Any ) -> str: ... def docdata( - self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored: Any + self, object: object, name: str | None = ..., mod: str | None = ..., cl: Any | None = ..., *ignored: Any ) -> str: ... def docother( self, object: object, - name: Optional[str] = ..., - mod: Optional[str] = ..., - parent: Optional[str] = ..., - maxlen: Optional[int] = ..., - doc: Optional[Any] = ..., + name: str | None = ..., + mod: str | None = ..., + parent: str | None = ..., + maxlen: int | None = ..., + doc: Any | None = ..., *ignored: Any, ) -> str: ... @@ -207,22 +207,22 @@ html: HTMLDoc class _OldStyleClass: ... -def resolve(thing: Union[str, object], forceload: bool = ...) -> Optional[Tuple[object, str]]: ... -def render_doc(thing: Union[str, object], title: str = ..., forceload: bool = ..., renderer: Optional[Doc] = ...) -> str: ... +def resolve(thing: str | object, forceload: bool = ...) -> Tuple[object, str] | None: ... +def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Doc | None = ...) -> str: ... def doc( - thing: Union[str, object], title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ... + thing: str | object, title: str = ..., forceload: bool = ..., output: SupportsWrite[str] | None = ... ) -> None: ... -def writedoc(thing: Union[str, object], forceload: bool = ...) -> None: ... -def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> None: ... +def writedoc(thing: str | object, forceload: bool = ...) -> None: ... +def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... class Helper: - keywords: Dict[str, Union[str, Tuple[str, str]]] + keywords: Dict[str, str | Tuple[str, str]] symbols: Dict[str, str] - topics: Dict[str, Union[str, Tuple[str, ...]]] - def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> None: ... + topics: Dict[str, str | Tuple[str, ...]] + def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... input: IO[str] output: IO[str] - def __call__(self, request: Union[str, Helper, object] = ...) -> None: ... + def __call__(self, request: str | Helper | object = ...) -> None: ... def interact(self) -> None: ... def getline(self, prompt: str) -> str: ... def help(self, request: Any) -> None: ... @@ -250,10 +250,10 @@ class ModuleScanner: quit: bool def run( self, - callback: Callable[[Optional[str], str, str], None], - key: Optional[Any] = ..., - completer: Optional[Callable[[], None]] = ..., - onerror: Optional[Callable[[str], None]] = ..., + callback: Callable[[str | None, str, str], None], + key: Any | None = ..., + completer: Callable[[], None] | None = ..., + onerror: Callable[[str], None] | None = ..., ) -> None: ... def apropos(key: str) -> None: ... diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index c58958d15085..cdb9bec1e63e 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -22,12 +22,12 @@ XML_PARAM_ENTITY_PARSING_ALWAYS: int _Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] class XMLParserType(object): - def Parse(self, __data: Union[str, bytes], __isfinal: bool = ...) -> int: ... + def Parse(self, __data: str | bytes, __isfinal: bool = ...) -> int: ... def ParseFile(self, __file: SupportsRead[bytes]) -> int: ... def SetBase(self, __base: str) -> None: ... - def GetBase(self) -> Optional[str]: ... - def GetInputContext(self) -> Optional[bytes]: ... - def ExternalEntityParserCreate(self, __context: Optional[str], __encoding: str = ...) -> XMLParserType: ... + def GetBase(self) -> str | None: ... + def GetInputContext(self) -> bytes | None: ... + def ExternalEntityParserCreate(self, __context: str | None, __encoding: str = ...) -> XMLParserType: ... def SetParamEntityParsing(self, __flag: int) -> int: ... def UseForeignDTD(self, __flag: bool = ...) -> None: ... buffer_size: int @@ -43,37 +43,31 @@ class XMLParserType(object): CurrentByteIndex: int CurrentColumnNumber: int CurrentLineNumber: int - XmlDeclHandler: Optional[Callable[[str, Optional[str], int], Any]] - StartDoctypeDeclHandler: Optional[Callable[[str, Optional[str], Optional[str], bool], Any]] - EndDoctypeDeclHandler: Optional[Callable[[], Any]] - ElementDeclHandler: Optional[Callable[[str, _Model], Any]] - AttlistDeclHandler: Optional[Callable[[str, str, str, Optional[str], bool], Any]] - StartElementHandler: Optional[ - Union[ - Callable[[str, Dict[str, str]], Any], - Callable[[str, List[str]], Any], - Callable[[str, Union[Dict[str, str]], List[str]], Any], - ] - ] - EndElementHandler: Optional[Callable[[str], Any]] - ProcessingInstructionHandler: Optional[Callable[[str, str], Any]] - CharacterDataHandler: Optional[Callable[[str], Any]] - UnparsedEntityDeclHandler: Optional[Callable[[str, Optional[str], str, Optional[str], str], Any]] - EntityDeclHandler: Optional[Callable[[str, bool, Optional[str], Optional[str], str, Optional[str], Optional[str]], Any]] - NotationDeclHandler: Optional[Callable[[str, Optional[str], str, Optional[str]], Any]] - StartNamespaceDeclHandler: Optional[Callable[[str, str], Any]] - EndNamespaceDeclHandler: Optional[Callable[[str], Any]] - CommentHandler: Optional[Callable[[str], Any]] - StartCdataSectionHandler: Optional[Callable[[], Any]] - EndCdataSectionHandler: Optional[Callable[[], Any]] - DefaultHandler: Optional[Callable[[str], Any]] - DefaultHandlerExpand: Optional[Callable[[str], Any]] - NotStandaloneHandler: Optional[Callable[[], int]] - ExternalEntityRefHandler: Optional[Callable[[str, Optional[str], Optional[str], Optional[str]], int]] + XmlDeclHandler: Callable[[str, str | None, int], Any] | None + StartDoctypeDeclHandler: Callable[[str, str | None, str | None, bool], Any] | None + EndDoctypeDeclHandler: Callable[[], Any] | None + ElementDeclHandler: Callable[[str, _Model], Any] | None + AttlistDeclHandler: Callable[[str, str, str, str | None, bool], Any] | None + StartElementHandler: Callable[[str, Dict[str, str]], Any] | Callable[[str, List[str]], Any] | Callable[[str, Dict[str, str], List[str]], Any] | None + EndElementHandler: Callable[[str], Any] | None + ProcessingInstructionHandler: Callable[[str, str], Any] | None + CharacterDataHandler: Callable[[str], Any] | None + UnparsedEntityDeclHandler: Callable[[str, str | None, str, str | None, str], Any] | None + EntityDeclHandler: Callable[[str, bool, str | None, str | None, str, str | None, str | None], Any] | None + NotationDeclHandler: Callable[[str, str | None, str, str | None], Any] | None + StartNamespaceDeclHandler: Callable[[str, str], Any] | None + EndNamespaceDeclHandler: Callable[[str], Any] | None + CommentHandler: Callable[[str], Any] | None + StartCdataSectionHandler: Callable[[], Any] | None + EndCdataSectionHandler: Callable[[], Any] | None + DefaultHandler: Callable[[str], Any] | None + DefaultHandlerExpand: Callable[[str], Any] | None + NotStandaloneHandler: Callable[[], int] | None + ExternalEntityRefHandler: Callable[[str, str | None, str | None, str | None], int] | None def ErrorString(__code: int) -> str: ... # intern is undocumented def ParserCreate( - encoding: Optional[str] = ..., namespace_separator: Optional[str] = ..., intern: Optional[Dict[str, Any]] = ... + encoding: str | None = ..., namespace_separator: str | None = ..., intern: Dict[str, Any] | None = ... ) -> XMLParserType: ... diff --git a/stdlib/queue.pyi b/stdlib/queue.pyi index 82fde5989d34..5884d4e18f46 100644 --- a/stdlib/queue.pyi +++ b/stdlib/queue.pyi @@ -23,10 +23,10 @@ class Queue(Generic[_T]): def _init(self, maxsize: int) -> None: ... def empty(self) -> bool: ... def full(self) -> bool: ... - def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ... + def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... def get_nowait(self) -> _T: ... def _get(self) -> _T: ... - def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ... + def put(self, item: _T, block: bool = ..., timeout: float | None = ...) -> None: ... def put_nowait(self, item: _T) -> None: ... def _put(self, item: _T) -> None: ... def join(self) -> None: ... @@ -43,9 +43,9 @@ if sys.version_info >= (3, 7): class SimpleQueue(Generic[_T]): def __init__(self) -> None: ... def empty(self) -> bool: ... - def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ... + def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... def get_nowait(self) -> _T: ... - def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ... + def put(self, item: _T, block: bool = ..., timeout: float | None = ...) -> None: ... def put_nowait(self, item: _T) -> None: ... def qsize(self) -> int: ... if sys.version_info >= (3, 9): diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 152dc906eab1..b7b5b2577591 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -12,7 +12,7 @@ class Random(_random.Random): def getstate(self) -> Tuple[Any, ...]: ... def setstate(self, state: Tuple[Any, ...]) -> None: ... def getrandbits(self, __k: int) -> int: ... - def randrange(self, start: int, stop: Optional[int] = ..., step: int = ...) -> int: ... + def randrange(self, start: int, stop: int | None = ..., step: int = ...) -> int: ... def randint(self, a: int, b: int) -> int: ... if sys.version_info >= (3, 9): def randbytes(self, n: int) -> bytes: ... @@ -20,21 +20,21 @@ class Random(_random.Random): def choices( self, population: Sequence[_T], - weights: Optional[Sequence[Union[float, Fraction]]] = ..., + weights: Sequence[float | Fraction] | None = ..., *, - cum_weights: Optional[Sequence[Union[float, Fraction]]] = ..., + cum_weights: Sequence[float | Fraction] | None = ..., k: int = ..., ) -> list[_T]: ... - def shuffle(self, x: MutableSequence[Any], random: Optional[Callable[[], float]] = ...) -> None: ... + def shuffle(self, x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ... if sys.version_info >= (3, 9): def sample( - self, population: Union[Sequence[_T], Set[_T]], k: int, *, counts: Optional[Iterable[_T]] = ... + self, population: Sequence[_T] | Set[_T], k: int, *, counts: Iterable[_T] | None = ... ) -> list[_T]: ... else: - def sample(self, population: Union[Sequence[_T], Set[_T]], k: int) -> list[_T]: ... + def sample(self, population: Sequence[_T] | Set[_T], k: int) -> list[_T]: ... def random(self) -> float: ... def uniform(self, a: float, b: float) -> float: ... - def triangular(self, low: float = ..., high: float = ..., mode: Optional[float] = ...) -> float: ... + def triangular(self, low: float = ..., high: float = ..., mode: float | None = ...) -> float: ... def betavariate(self, alpha: float, beta: float) -> float: ... def expovariate(self, lambd: float) -> float: ... def gammavariate(self, alpha: float, beta: float) -> float: ... @@ -55,7 +55,7 @@ def seed(a: Any = ..., version: int = ...) -> None: ... def getstate() -> object: ... def setstate(state: object) -> None: ... def getrandbits(__k: int) -> int: ... -def randrange(start: int, stop: Union[None, int] = ..., step: int = ...) -> int: ... +def randrange(start: int, stop: None | int = ..., step: int = ...) -> int: ... def randint(a: int, b: int) -> int: ... if sys.version_info >= (3, 9): @@ -64,22 +64,22 @@ if sys.version_info >= (3, 9): def choice(seq: Sequence[_T]) -> _T: ... def choices( population: Sequence[_T], - weights: Optional[Sequence[float]] = ..., + weights: Sequence[float] | None = ..., *, - cum_weights: Optional[Sequence[float]] = ..., + cum_weights: Sequence[float] | None = ..., k: int = ..., ) -> list[_T]: ... -def shuffle(x: MutableSequence[Any], random: Optional[Callable[[], float]] = ...) -> None: ... +def shuffle(x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ... if sys.version_info >= (3, 9): - def sample(population: Union[Sequence[_T], Set[_T]], k: int, *, counts: Optional[Iterable[_T]] = ...) -> list[_T]: ... + def sample(population: Sequence[_T] | Set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ... else: - def sample(population: Union[Sequence[_T], Set[_T]], k: int) -> list[_T]: ... + def sample(population: Sequence[_T] | Set[_T], k: int) -> list[_T]: ... def random() -> float: ... def uniform(a: float, b: float) -> float: ... -def triangular(low: float = ..., high: float = ..., mode: Optional[float] = ...) -> float: ... +def triangular(low: float = ..., high: float = ..., mode: float | None = ...) -> float: ... def betavariate(alpha: float, beta: float) -> float: ... def expovariate(lambd: float) -> float: ... def gammavariate(alpha: float, beta: float) -> float: ... diff --git a/stdlib/re.pyi b/stdlib/re.pyi index 3f2490ae4e11..b1bae4aac875 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -56,23 +56,23 @@ def compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]: ... @overload def compile(pattern: Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ... @overload -def search(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... +def search(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ... @overload -def search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... +def search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ... @overload -def match(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... +def match(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ... @overload -def match(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... +def match(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ... # New in Python 3.4 @overload -def fullmatch(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... +def fullmatch(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ... @overload -def fullmatch(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... +def fullmatch(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ... @overload -def split(pattern: AnyStr, string: AnyStr, maxsplit: int = ..., flags: _FlagsType = ...) -> List[Union[AnyStr, Any]]: ... +def split(pattern: AnyStr, string: AnyStr, maxsplit: int = ..., flags: _FlagsType = ...) -> List[AnyStr | Any]: ... @overload -def split(pattern: Pattern[AnyStr], string: AnyStr, maxsplit: int = ..., flags: _FlagsType = ...) -> List[Union[AnyStr, Any]]: ... +def split(pattern: Pattern[AnyStr], string: AnyStr, maxsplit: int = ..., flags: _FlagsType = ...) -> List[AnyStr | Any]: ... @overload def findall(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> List[Any]: ... @overload @@ -114,4 +114,4 @@ def subn( ) -> Tuple[AnyStr, int]: ... def escape(pattern: AnyStr) -> AnyStr: ... def purge() -> None: ... -def template(pattern: Union[AnyStr, Pattern[AnyStr]], flags: _FlagsType = ...) -> Pattern[AnyStr]: ... +def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ... diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index 39f0001d048b..2de749b2c216 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -5,13 +5,13 @@ _CompleterT = Optional[Callable[[str, int], Optional[str]]] _CompDispT = Optional[Callable[[str, Sequence[str], int], None]] def parse_and_bind(__string: str) -> None: ... -def read_init_file(__filename: Optional[StrOrBytesPath] = ...) -> None: ... +def read_init_file(__filename: StrOrBytesPath | None = ...) -> None: ... def get_line_buffer() -> str: ... def insert_text(__string: str) -> None: ... def redisplay() -> None: ... -def read_history_file(__filename: Optional[StrOrBytesPath] = ...) -> None: ... -def write_history_file(__filename: Optional[StrOrBytesPath] = ...) -> None: ... -def append_history_file(__nelements: int, __filename: Optional[StrOrBytesPath] = ...) -> None: ... +def read_history_file(__filename: StrOrBytesPath | None = ...) -> None: ... +def write_history_file(__filename: StrOrBytesPath | None = ...) -> None: ... +def append_history_file(__nelements: int, __filename: StrOrBytesPath | None = ...) -> None: ... def get_history_length() -> int: ... def set_history_length(__length: int) -> None: ... def clear_history() -> None: ... @@ -21,8 +21,8 @@ def remove_history_item(__pos: int) -> None: ... def replace_history_item(__pos: int, __line: str) -> None: ... def add_history(__string: str) -> None: ... def set_auto_history(__enabled: bool) -> None: ... -def set_startup_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... -def set_pre_input_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... +def set_startup_hook(__function: Callable[[], None] | None = ...) -> None: ... +def set_pre_input_hook(__function: Callable[[], None] | None = ...) -> None: ... def set_completer(__function: _CompleterT = ...) -> None: ... def get_completer() -> _CompleterT: ... def get_completion_type() -> int: ... diff --git a/stdlib/rlcompleter.pyi b/stdlib/rlcompleter.pyi index 8afb5b1ef628..f7e3cf1b8c4a 100644 --- a/stdlib/rlcompleter.pyi +++ b/stdlib/rlcompleter.pyi @@ -1,5 +1,5 @@ from typing import Any, Dict, Optional class Completer: - def __init__(self, namespace: Optional[Dict[str, Any]] = ...) -> None: ... - def complete(self, text: str, state: int) -> Optional[str]: ... + def __init__(self, namespace: Dict[str, Any] | None = ...) -> None: ... + def complete(self, text: str, state: int) -> str | None: ... diff --git a/stdlib/runpy.pyi b/stdlib/runpy.pyi index 7df9bee7b557..5915ee7815ac 100644 --- a/stdlib/runpy.pyi +++ b/stdlib/runpy.pyi @@ -16,6 +16,6 @@ class _ModifiedArgv0: def __exit__(self, *args: Any) -> None: ... def run_module( - mod_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: Optional[str] = ..., alter_sys: bool = ... + mod_name: str, init_globals: Dict[str, Any] | None = ..., run_name: str | None = ..., alter_sys: bool = ... ) -> Dict[str, Any]: ... -def run_path(path_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: Optional[str] = ...) -> Dict[str, Any]: ... +def run_path(path_name: str, init_globals: Dict[str, Any] | None = ..., run_name: str | None = ...) -> Dict[str, Any]: ... diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index 379d5a5186d9..05d81aa69ee2 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -25,7 +25,7 @@ class scheduler: argument: Tuple[Any, ...] = ..., kwargs: Dict[str, Any] = ..., ) -> Event: ... - def run(self, blocking: bool = ...) -> Optional[float]: ... + def run(self, blocking: bool = ...) -> float | None: ... def cancel(self, event: Event) -> None: ... def empty(self) -> bool: ... @property diff --git a/stdlib/secrets.pyi b/stdlib/secrets.pyi index 84b2fea8379a..bcf9bf1526d1 100644 --- a/stdlib/secrets.pyi +++ b/stdlib/secrets.pyi @@ -7,6 +7,6 @@ _T = TypeVar("_T") def randbelow(exclusive_upper_bound: int) -> int: ... def randbits(k: int) -> int: ... def choice(seq: Sequence[_T]) -> _T: ... -def token_bytes(nbytes: Optional[int] = ...) -> bytes: ... -def token_hex(nbytes: Optional[int] = ...) -> str: ... -def token_urlsafe(nbytes: Optional[int] = ...) -> str: ... +def token_bytes(nbytes: int | None = ...) -> bytes: ... +def token_hex(nbytes: int | None = ...) -> str: ... +def token_urlsafe(nbytes: int | None = ...) -> str: ... diff --git a/stdlib/select.pyi b/stdlib/select.pyi index 0cdbaa5f735a..f9887bd8281d 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -22,10 +22,10 @@ class poll: def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ... + def poll(self, timeout: float | None = ...) -> List[Tuple[int, int]]: ... def select( - __rlist: Iterable[Any], __wlist: Iterable[Any], __xlist: Iterable[Any], __timeout: Optional[float] = ... + __rlist: Iterable[Any], __wlist: Iterable[Any], __xlist: Iterable[Any], __timeout: float | None = ... ) -> Tuple[List[Any], List[Any], List[Any]]: ... error = OSError @@ -54,7 +54,7 @@ if sys.platform != "linux" and sys.platform != "win32": def __init__(self) -> None: ... def close(self) -> None: ... def control( - self, __changelist: Optional[Iterable[kevent]], __maxevents: int, __timeout: Optional[float] = ... + self, __changelist: Iterable[kevent] | None, __maxevents: int, __timeout: float | None = ... ) -> List[kevent]: ... def fileno(self) -> int: ... @classmethod @@ -104,9 +104,9 @@ if sys.platform == "linux": def __enter__(self: Self) -> Self: ... def __exit__( self, - exc_type: Optional[Type[BaseException]] = ..., - exc_val: Optional[BaseException] = ..., - exc_tb: Optional[TracebackType] = ..., + exc_type: Type[BaseException] | None = ..., + exc_val: BaseException | None = ..., + exc_tb: TracebackType | None = ..., ) -> None: ... def close(self) -> None: ... closed: bool @@ -114,7 +114,7 @@ if sys.platform == "linux": def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: Optional[float] = ..., maxevents: int = ...) -> List[Tuple[int, int]]: ... + def poll(self, timeout: float | None = ..., maxevents: int = ...) -> List[Tuple[int, int]]: ... @classmethod def fromfd(cls, __fd: FileDescriptorLike) -> epoll: ... EPOLLERR: int @@ -140,4 +140,4 @@ if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ... + def poll(self, timeout: float | None = ...) -> List[Tuple[int, int]]: ... diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index ade59f47e1bf..74f3b60513bd 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -21,7 +21,7 @@ class BaseSelector(metaclass=ABCMeta): def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... def modify(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... @abstractmethod - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def close(self) -> None: ... def get_key(self, fileobj: FileDescriptorLike) -> SelectorKey: ... @abstractmethod @@ -32,14 +32,14 @@ class BaseSelector(metaclass=ABCMeta): class SelectSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... if sys.platform != "win32": class PollSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... if sys.platform == "linux": @@ -47,25 +47,25 @@ if sys.platform == "linux": def fileno(self) -> int: ... def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class DevpollSelector(BaseSelector): def fileno(self) -> int: ... def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class KqueueSelector(BaseSelector): def fileno(self) -> int: ... def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... class DefaultSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ... - def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def select(self, timeout: float | None = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... diff --git a/stdlib/shelve.pyi b/stdlib/shelve.pyi index 40f08e6c3022..45ec2120f5f0 100644 --- a/stdlib/shelve.pyi +++ b/stdlib/shelve.pyi @@ -8,20 +8,20 @@ _VT = TypeVar("_VT") class Shelf(MutableMapping[str, _VT]): def __init__( - self, dict: MutableMapping[bytes, bytes], protocol: Optional[int] = ..., writeback: bool = ..., keyencoding: str = ... + self, dict: MutableMapping[bytes, bytes], protocol: int | None = ..., writeback: bool = ..., keyencoding: str = ... ) -> None: ... def __iter__(self) -> Iterator[str]: ... def __len__(self) -> int: ... @overload - def get(self, key: str) -> Optional[_VT]: ... + def get(self, key: str) -> _VT | None: ... @overload - def get(self, key: str, default: _T) -> Union[_VT, _T]: ... + def get(self, key: str, default: _T) -> _VT | _T: ... def __getitem__(self, key: str) -> _VT: ... def __setitem__(self, key: str, value: _VT) -> None: ... def __delitem__(self, key: str) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def close(self) -> None: ... def sync(self) -> None: ... @@ -34,6 +34,6 @@ class BsdDbShelf(Shelf[_VT]): def last(self) -> tuple[str, _VT]: ... class DbfilenameShelf(Shelf[_VT]): - def __init__(self, filename: str, flag: str = ..., protocol: Optional[int] = ..., writeback: bool = ...) -> None: ... + def __init__(self, filename: str, flag: str = ..., protocol: int | None = ..., writeback: bool = ...) -> None: ... -def open(filename: str, flag: str = ..., protocol: Optional[int] = ..., writeback: bool = ...) -> Shelf[object]: ... +def open(filename: str, flag: str = ..., protocol: int | None = ..., writeback: bool = ...) -> Shelf[object]: ... diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index 741f516dcfdc..f74e8de78276 100644 --- a/stdlib/shlex.pyi +++ b/stdlib/shlex.pyi @@ -28,10 +28,10 @@ class shlex(Iterable[str]): punctuation_chars: str def __init__( self, - instream: Optional[Union[str, TextIO]] = ..., - infile: Optional[str] = ..., + instream: str | TextIO | None = ..., + infile: str | None = ..., posix: bool = ..., - punctuation_chars: Union[bool, str] = ..., + punctuation_chars: bool | str = ..., ) -> None: ... def get_token(self) -> str: ... def push_token(self, tok: str) -> None: ... @@ -40,6 +40,6 @@ class shlex(Iterable[str]): # TODO argument types def push_source(self, newstream: Any, newfile: Any = ...) -> None: ... def pop_source(self) -> None: ... - def error_leader(self, infile: Optional[str] = ..., lineno: Optional[int] = ...) -> None: ... + def error_leader(self, infile: str | None = ..., lineno: int | None = ...) -> None: ... def __iter__(self: _SLT) -> _SLT: ... def __next__(self) -> str: ... diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index ad077df80d07..e8d8324793b7 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -28,7 +28,7 @@ if sys.version_info >= (3, 8): src: StrPath, dst: StrPath, symlinks: bool = ..., - ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ..., + ignore: None | Callable[[str, List[str]], Iterable[str]] | Callable[[StrPath, List[str]], Iterable[str]] = ..., copy_function: Callable[[str, str], None] = ..., ignore_dangling_symlinks: bool = ..., dirs_exist_ok: bool = ..., @@ -39,13 +39,13 @@ else: src: StrPath, dst: StrPath, symlinks: bool = ..., - ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ..., + ignore: None | Callable[[str, List[str]], Iterable[str]] | Callable[[StrPath, List[str]], Iterable[str]] = ..., copy_function: Callable[[str, str], None] = ..., ignore_dangling_symlinks: bool = ..., ) -> _PathReturn: ... def rmtree( - path: Union[bytes, StrPath], ignore_errors: bool = ..., onerror: Optional[Callable[[Any, Any, Any], Any]] = ... + path: bytes | StrPath, ignore_errors: bool = ..., onerror: Callable[[Any, Any, Any], Any] | None = ... ) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] @@ -63,46 +63,46 @@ class _ntuple_diskusage(NamedTuple): free: int def disk_usage(path: StrPath) -> _ntuple_diskusage: ... -def chown(path: StrPath, user: Optional[Union[str, int]] = ..., group: Optional[Union[str, int]] = ...) -> None: ... +def chown(path: StrPath, user: str | int | None = ..., group: str | int | None = ...) -> None: ... if sys.version_info >= (3, 8): @overload - def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ... + def which(cmd: StrPath, mode: int = ..., path: StrPath | None = ...) -> str | None: ... @overload - def which(cmd: bytes, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[bytes]: ... + def which(cmd: bytes, mode: int = ..., path: StrPath | None = ...) -> bytes | None: ... else: - def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ... + def which(cmd: StrPath, mode: int = ..., path: StrPath | None = ...) -> str | None: ... def make_archive( base_name: str, format: str, - root_dir: Optional[StrPath] = ..., - base_dir: Optional[StrPath] = ..., + root_dir: StrPath | None = ..., + base_dir: StrPath | None = ..., verbose: bool = ..., dry_run: bool = ..., - owner: Optional[str] = ..., - group: Optional[str] = ..., - logger: Optional[Any] = ..., + owner: str | None = ..., + group: str | None = ..., + logger: Any | None = ..., ) -> str: ... def get_archive_formats() -> List[Tuple[str, str]]: ... def register_archive_format( name: str, function: Callable[..., Any], - extra_args: Optional[Sequence[Union[Tuple[str, Any], List[Any]]]] = ..., + extra_args: Sequence[Tuple[str, Any] | List[Any]] | None = ..., description: str = ..., ) -> None: ... def unregister_archive_format(name: str) -> None: ... if sys.version_info >= (3, 7): - def unpack_archive(filename: StrPath, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ... + def unpack_archive(filename: StrPath, extract_dir: StrPath | None = ..., format: str | None = ...) -> None: ... else: # See http://bugs.python.org/issue30218 - def unpack_archive(filename: str, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ... + def unpack_archive(filename: str, extract_dir: StrPath | None = ..., format: str | None = ...) -> None: ... def register_unpack_format( - name: str, extensions: List[str], function: Any, extra_args: Optional[Sequence[Tuple[str, Any]]] = ..., description: str = ... + name: str, extensions: List[str], function: Any, extra_args: Sequence[Tuple[str, Any]] | None = ..., description: str = ... ) -> None: ... def unregister_unpack_format(name: str) -> None: ... def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ... diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index d54b22d57c0a..21ad232c7189 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -166,7 +166,7 @@ if sys.platform != "win32": def getsignal(__signalnum: _SIGNUM) -> _HANDLER: ... if sys.version_info >= (3, 8): - def strsignal(__signalnum: _SIGNUM) -> Optional[str]: ... + def strsignal(__signalnum: _SIGNUM) -> str | None: ... def valid_signals() -> Set[Signals]: ... def raise_signal(__signalnum: _SIGNUM) -> None: ... @@ -191,5 +191,5 @@ if sys.platform != "win32": def sigpending() -> Any: ... def sigwait(__sigset: Iterable[int]) -> _SIGNUM: ... if sys.platform != "darwin": - def sigtimedwait(sigset: Iterable[int], timeout: float) -> Optional[struct_siginfo]: ... + def sigtimedwait(sigset: Iterable[int], timeout: float) -> struct_siginfo | None: ... def sigwaitinfo(sigset: Iterable[int]) -> struct_siginfo: ... diff --git a/stdlib/site.pyi b/stdlib/site.pyi index db7bbefcc794..d9f8da8a7e2d 100644 --- a/stdlib/site.pyi +++ b/stdlib/site.pyi @@ -1,12 +1,12 @@ from typing import Iterable, List, Optional PREFIXES: List[str] -ENABLE_USER_SITE: Optional[bool] -USER_SITE: Optional[str] -USER_BASE: Optional[str] +ENABLE_USER_SITE: bool | None +USER_SITE: str | None +USER_BASE: str | None def main() -> None: ... -def addsitedir(sitedir: str, known_paths: Optional[Iterable[str]] = ...) -> None: ... -def getsitepackages(prefixes: Optional[Iterable[str]] = ...) -> List[str]: ... +def addsitedir(sitedir: str, known_paths: Iterable[str] | None = ...) -> None: ... +def getsitepackages(prefixes: Iterable[str] | None = ...) -> List[str]: ... def getuserbase() -> str: ... def getusersitepackages() -> str: ... diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index 313e722163c0..75c7755b5b66 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -34,7 +34,7 @@ class SMTPChannel(asynchat.async_chat): conn: socket.socket, addr: Any, data_size_limit: int = ..., - map: Optional[asyncore._maptype] = ..., + map: asyncore._maptype | None = ..., enable_SMTPUTF8: bool = ..., decode_data: bool = ..., ) -> None: ... @@ -64,23 +64,23 @@ class SMTPServer(asyncore.dispatcher): localaddr: _Address, remoteaddr: _Address, data_size_limit: int = ..., - map: Optional[asyncore._maptype] = ..., + map: asyncore._maptype | None = ..., enable_SMTPUTF8: bool = ..., decode_data: bool = ..., ) -> None: ... def handle_accepted(self, conn: socket.socket, addr: Any) -> None: ... def process_message( - self, peer: _Address, mailfrom: str, rcpttos: List[str], data: Union[bytes, str], **kwargs: Any - ) -> Optional[str]: ... + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: bytes | str, **kwargs: Any + ) -> str | None: ... class DebuggingServer(SMTPServer): ... class PureProxy(SMTPServer): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[str], data: Union[bytes, str] - ) -> Optional[str]: ... + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: bytes | str + ) -> str | None: ... class MailmanProxy(PureProxy): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[str], data: Union[bytes, str] - ) -> Optional[str]: ... + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: bytes | str + ) -> str | None: ... diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 5d0ab420ee28..d72e98af1e89 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -23,9 +23,9 @@ class SMTPServerDisconnected(SMTPException): ... class SMTPResponseException(SMTPException): smtp_code: int - smtp_error: Union[bytes, str] - args: Union[Tuple[int, Union[bytes, str]], Tuple[int, bytes, str]] - def __init__(self, code: int, msg: Union[bytes, str]) -> None: ... + smtp_error: bytes | str + args: Tuple[int, bytes | str] | Tuple[int, bytes, str] + def __init__(self, code: int, msg: bytes | str) -> None: ... class SMTPSenderRefused(SMTPResponseException): smtp_code: int @@ -49,40 +49,40 @@ def quotedata(data: str) -> str: ... class _AuthObject(Protocol): @overload - def __call__(self, challenge: None = ...) -> Optional[str]: ... + def __call__(self, challenge: None = ...) -> str | None: ... @overload def __call__(self, challenge: bytes) -> str: ... class SMTP: debuglevel: int = ... - sock: Optional[socket] = ... + sock: socket | None = ... # Type of file should match what socket.makefile() returns - file: Optional[Any] = ... - helo_resp: Optional[bytes] = ... + file: Any | None = ... + helo_resp: bytes | None = ... ehlo_msg: str = ... - ehlo_resp: Optional[bytes] = ... + ehlo_resp: bytes | None = ... does_esmtp: bool = ... default_port: int = ... timeout: float esmtp_features: Dict[str, str] command_encoding: str - source_address: Optional[_SourceAddress] + source_address: _SourceAddress | None local_hostname: str def __init__( self, host: str = ..., port: int = ..., - local_hostname: Optional[str] = ..., + local_hostname: str | None = ..., timeout: float = ..., - source_address: Optional[_SourceAddress] = ..., + source_address: _SourceAddress | None = ..., ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None ) -> None: ... def set_debuglevel(self, debuglevel: int) -> None: ... - def connect(self, host: str = ..., port: int = ..., source_address: Optional[_SourceAddress] = ...) -> _Reply: ... - def send(self, s: Union[bytes, str]) -> None: ... + def connect(self, host: str = ..., port: int = ..., source_address: _SourceAddress | None = ...) -> _Reply: ... + def send(self, s: bytes | str) -> None: ... def putcmd(self, cmd: str, args: str = ...) -> None: ... def getreply(self) -> _Reply: ... def docmd(self, cmd: str, args: str = ...) -> _Reply: ... @@ -94,7 +94,7 @@ class SMTP: def noop(self) -> _Reply: ... def mail(self, sender: str, options: Sequence[str] = ...) -> _Reply: ... def rcpt(self, recip: str, options: Sequence[str] = ...) -> _Reply: ... - def data(self, msg: Union[bytes, str]) -> _Reply: ... + def data(self, msg: bytes | str) -> _Reply: ... def verify(self, address: str) -> _Reply: ... vrfy = verify def expn(self, address: str) -> _Reply: ... @@ -106,25 +106,25 @@ class SMTP: def auth_cram_md5(self, challenge: None = ...) -> None: ... @overload def auth_cram_md5(self, challenge: bytes) -> str: ... - def auth_plain(self, challenge: Optional[bytes] = ...) -> str: ... - def auth_login(self, challenge: Optional[bytes] = ...) -> str: ... + def auth_plain(self, challenge: bytes | None = ...) -> str: ... + def auth_login(self, challenge: bytes | None = ...) -> str: ... def login(self, user: str, password: str, *, initial_response_ok: bool = ...) -> _Reply: ... def starttls( - self, keyfile: Optional[str] = ..., certfile: Optional[str] = ..., context: Optional[SSLContext] = ... + self, keyfile: str | None = ..., certfile: str | None = ..., context: SSLContext | None = ... ) -> _Reply: ... def sendmail( self, from_addr: str, - to_addrs: Union[str, Sequence[str]], - msg: Union[bytes, str], + to_addrs: str | Sequence[str], + msg: bytes | str, mail_options: Sequence[str] = ..., rcpt_options: Sequence[str] = ..., ) -> _SendErrs: ... def send_message( self, msg: _Message, - from_addr: Optional[str] = ..., - to_addrs: Optional[Union[str, Sequence[str]]] = ..., + from_addr: str | None = ..., + to_addrs: str | Sequence[str] | None = ..., mail_options: Sequence[str] = ..., rcpt_options: Sequence[str] = ..., ) -> _SendErrs: ... @@ -133,19 +133,19 @@ class SMTP: class SMTP_SSL(SMTP): default_port: int = ... - keyfile: Optional[str] - certfile: Optional[str] + keyfile: str | None + certfile: str | None context: SSLContext def __init__( self, host: str = ..., port: int = ..., - local_hostname: Optional[str] = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., + local_hostname: str | None = ..., + keyfile: str | None = ..., + certfile: str | None = ..., timeout: float = ..., - source_address: Optional[_SourceAddress] = ..., - context: Optional[SSLContext] = ..., + source_address: _SourceAddress | None = ..., + context: SSLContext | None = ..., ) -> None: ... LMTP_PORT: int @@ -155,6 +155,6 @@ class LMTP(SMTP): self, host: str = ..., port: int = ..., - local_hostname: Optional[str] = ..., - source_address: Optional[_SourceAddress] = ..., + local_hostname: str | None = ..., + source_address: _SourceAddress | None = ..., ) -> None: ... diff --git a/stdlib/sndhdr.pyi b/stdlib/sndhdr.pyi index 4f8ab2652b93..adeb283ffc95 100644 --- a/stdlib/sndhdr.pyi +++ b/stdlib/sndhdr.pyi @@ -6,7 +6,7 @@ class SndHeaders(NamedTuple): framerate: int nchannels: int nframes: int - sampwidth: Union[int, str] + sampwidth: int | str -def what(filename: StrOrBytesPath) -> Optional[SndHeaders]: ... -def whathdr(filename: StrOrBytesPath) -> Optional[SndHeaders]: ... +def what(filename: StrOrBytesPath) -> SndHeaders | None: ... +def whathdr(filename: StrOrBytesPath) -> SndHeaders | None: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 6bc1ae62fa16..c6261df9686a 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -540,10 +540,10 @@ if sys.platform == "win32": class socket(_socket.socket): def __init__( self, - family: Union[AddressFamily, int] = ..., - type: Union[SocketKind, int] = ..., + family: AddressFamily | int = ..., + type: SocketKind | int = ..., proto: int = ..., - fileno: Optional[int] = ..., + fileno: int | None = ..., ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: object) -> None: ... @@ -555,23 +555,23 @@ class socket(_socket.socket): def makefile( self, mode: Literal["r", "w", "rw", "wr", ""] = ..., - buffering: Optional[int] = ..., + buffering: int | None = ..., *, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> TextIO: ... @overload def makefile( self, mode: Literal["b", "rb", "br", "wb", "bw", "rwb", "rbw", "wrb", "wbr", "brw", "bwr"], - buffering: Optional[int] = ..., + buffering: int | None = ..., *, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> BinaryIO: ... - def sendfile(self, file: BinaryIO, offset: int = ..., count: Optional[int] = ...) -> int: ... + def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ... @property def family(self) -> AddressFamily: ... # type: ignore @property @@ -585,7 +585,7 @@ if sys.platform != "win32": if sys.version_info >= (3, 9): # flags and address appear to be unused in send_fds and recv_fds def send_fds( - sock: socket, buffers: Iterable[bytes], fds: Union[bytes, Iterable[int]], flags: int = ..., address: None = ... + sock: socket, buffers: Iterable[bytes], fds: bytes | Iterable[int], flags: int = ..., address: None = ... ) -> int: ... def recv_fds(sock: socket, bufsize: int, maxfds: int, flags: int = ...) -> tuple[bytes, list[int], int, Any]: ... @@ -597,13 +597,13 @@ if sys.platform == "win32": else: def socketpair( # type: ignore - family: Union[int, AddressFamily, None] = ..., type: Union[SocketType, int] = ..., proto: int = ... + family: int | AddressFamily | None = ..., type: SocketType | int = ..., proto: int = ... ) -> tuple[socket, socket]: ... class SocketIO(RawIOBase): def __init__(self, sock: socket, mode: Literal["r", "w", "rw", "rb", "wb", "rwb"]) -> None: ... - def readinto(self, b: WriteableBuffer) -> Optional[int]: ... - def write(self, b: ReadableBuffer) -> Optional[int]: ... + def readinto(self, b: WriteableBuffer) -> int | None: ... + def write(self, b: ReadableBuffer) -> int | None: ... @property def name(self) -> int: ... # return value is really "int" @property @@ -611,23 +611,23 @@ class SocketIO(RawIOBase): def getfqdn(name: str = ...) -> str: ... def create_connection( - address: tuple[Optional[str], int], - timeout: Optional[float] = ..., # noqa: F811 - source_address: Optional[tuple[Union[bytearray, bytes, str], int]] = ..., + address: tuple[str | None, int], + timeout: float | None = ..., # noqa: F811 + source_address: tuple[bytearray | bytes | str, int] | None = ..., ) -> socket: ... if sys.version_info >= (3, 8): def has_dualstack_ipv6() -> bool: ... def create_server( - address: _Address, *, family: int = ..., backlog: Optional[int] = ..., reuse_port: bool = ..., dualstack_ipv6: bool = ... + address: _Address, *, family: int = ..., backlog: int | None = ..., reuse_port: bool = ..., dualstack_ipv6: bool = ... ) -> socket: ... # the 5th tuple item is an address def getaddrinfo( - host: Optional[Union[bytearray, bytes, str]], - port: Union[str, int, None], + host: bytearray | bytes | str | None, + port: str | int | None, family: int = ..., type: int = ..., proto: int = ..., flags: int = ..., -) -> list[tuple[AddressFamily, SocketKind, int, str, Union[tuple[str, int], tuple[str, int, int, int]]]]: ... +) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ... diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index 1403d9cee0ed..97fd2fb7a632 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -16,7 +16,7 @@ class BaseServer: allow_reuse_address: bool request_queue_size: int socket_type: int - timeout: Optional[float] + timeout: float | None def __init__(self, server_address: Any, RequestHandlerClass: Callable[..., BaseRequestHandler]) -> None: ... def fileno(self) -> int: ... def handle_request(self) -> None: ... @@ -33,7 +33,7 @@ class BaseServer: def verify_request(self, request: _RequestType, client_address: _AddressType) -> bool: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def service_actions(self) -> None: ... def shutdown_request(self, request: _RequestType) -> None: ... # undocumented @@ -73,22 +73,22 @@ if sys.platform != "win32": class UnixStreamServer(BaseServer): def __init__( self, - server_address: Union[str, bytes], + server_address: str | bytes, RequestHandlerClass: Callable[..., BaseRequestHandler], bind_and_activate: bool = ..., ) -> None: ... class UnixDatagramServer(BaseServer): def __init__( self, - server_address: Union[str, bytes], + server_address: str | bytes, RequestHandlerClass: Callable[..., BaseRequestHandler], bind_and_activate: bool = ..., ) -> None: ... if sys.platform != "win32": class ForkingMixIn: - timeout: Optional[float] # undocumented - active_children: Optional[Set[int]] # undocumented + timeout: float | None # undocumented + active_children: Set[int] | None # undocumented max_children: int # undocumented if sys.version_info >= (3, 7): block_on_close: bool @@ -135,7 +135,7 @@ class BaseRequestHandler: class StreamRequestHandler(BaseRequestHandler): rbufsize: ClassVar[int] # Undocumented wbufsize: ClassVar[int] # Undocumented - timeout: ClassVar[Optional[float]] # Undocumented + timeout: ClassVar[float | None] # Undocumented disable_nagle_algorithm: ClassVar[bool] # Undocumented connection: _socket # Undocumented rfile: BinaryIO diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 3fb72de659d2..cc86500acf84 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -69,28 +69,28 @@ if sys.version_info >= (3, 7): database: StrOrBytesPath, timeout: float = ..., detect_types: int = ..., - isolation_level: Optional[str] = ..., + isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., + factory: Type[Connection] | None = ..., cached_statements: int = ..., uri: bool = ..., ) -> Connection: ... else: def connect( - database: Union[bytes, str], + database: bytes | str, timeout: float = ..., detect_types: int = ..., - isolation_level: Optional[str] = ..., + isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., + factory: Type[Connection] | None = ..., cached_statements: int = ..., uri: bool = ..., ) -> Connection: ... def enable_callback_tracebacks(__enable: bool) -> None: ... def enable_shared_cache(enable: int) -> None: ... -def register_adapter(__type: Type[_T], __caster: Callable[[_T], Union[int, float, str, bytes]]) -> None: ... +def register_adapter(__type: Type[_T], __caster: Callable[[_T], int | float | str | bytes]) -> None: ... def register_converter(__name: str, __converter: Callable[[bytes], Any]) -> None: ... if sys.version_info < (3, 8): @@ -128,11 +128,11 @@ class Connection(object): def create_function(self, name: str, narg: int, func: Any, *, deterministic: bool = ...) -> None: ... else: def create_function(self, name: str, num_params: int, func: Any) -> None: ... - def cursor(self, cursorClass: Optional[type] = ...) -> Cursor: ... + def cursor(self, cursorClass: type | None = ...) -> Cursor: ... def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this def executemany(self, __sql: str, __parameters: Iterable[Iterable[Any]]) -> Cursor: ... - def executescript(self, __sql_script: Union[bytes, str]) -> Cursor: ... + def executescript(self, __sql_script: bytes | str) -> Cursor: ... def interrupt(self, *args: Any, **kwargs: Any) -> None: ... def iterdump(self, *args: Any, **kwargs: Any) -> Generator[str, None, None]: ... def rollback(self, *args: Any, **kwargs: Any) -> None: ... @@ -153,13 +153,13 @@ class Connection(object): target: Connection, *, pages: int = ..., - progress: Optional[Callable[[int, int, int], object]] = ..., + progress: Callable[[int, int, int], object] | None = ..., name: str = ..., sleep: float = ..., ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, t: Optional[type], exc: Optional[BaseException], tb: Optional[Any]) -> None: ... + def __exit__(self, t: type | None, exc: BaseException | None, tb: Any | None) -> None: ... class Cursor(Iterator[Any]): arraysize: Any @@ -175,9 +175,9 @@ class Cursor(Iterator[Any]): def close(self, *args: Any, **kwargs: Any) -> None: ... def execute(self, __sql: str, __parameters: Iterable[Any] = ...) -> Cursor: ... def executemany(self, __sql: str, __seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ... - def executescript(self, __sql_script: Union[bytes, str]) -> Cursor: ... + def executescript(self, __sql_script: bytes | str) -> Cursor: ... def fetchall(self) -> List[Any]: ... - def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ... + def fetchmany(self, size: int | None = ...) -> List[Any]: ... def fetchone(self) -> Any: ... def setinputsizes(self, *args: Any, **kwargs: Any) -> None: ... def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/stdlib/sre_compile.pyi b/stdlib/sre_compile.pyi index 492a194f1a26..3fc27f798299 100644 --- a/stdlib/sre_compile.pyi +++ b/stdlib/sre_compile.pyi @@ -20,4 +20,4 @@ MAXCODE: int def dis(code: List[_NamedIntConstant]) -> None: ... def isstring(obj: Any) -> bool: ... -def compile(p: Union[str, bytes, SubPattern], flags: int = ...) -> Pattern[Any]: ... +def compile(p: str | bytes | SubPattern, flags: int = ...) -> Pattern[Any]: ... diff --git a/stdlib/sre_constants.pyi b/stdlib/sre_constants.pyi index 07a308e6f67b..0de1dca8c16e 100644 --- a/stdlib/sre_constants.pyi +++ b/stdlib/sre_constants.pyi @@ -5,11 +5,11 @@ MAGIC: int class error(Exception): msg: str - pattern: Optional[Union[str, bytes]] - pos: Optional[int] + pattern: str | bytes | None + pos: int | None lineno: int colno: int - def __init__(self, msg: str, pattern: Optional[Union[str, bytes]] = ..., pos: Optional[int] = ...) -> None: ... + def __init__(self, msg: str, pattern: str | bytes | None = ..., pos: int | None = ...) -> None: ... class _NamedIntConstant(int): name: Any diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index 4c7b6157d8a9..afc3745f06b8 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -10,7 +10,7 @@ HEXDIGITS: FrozenSet[str] ASCIILETTERS: FrozenSet[str] WHITESPACE: FrozenSet[str] ESCAPES: Dict[str, Tuple[_NIC, int]] -CATEGORIES: Dict[str, Union[Tuple[_NIC, _NIC], Tuple[_NIC, List[Tuple[_NIC, _NIC]]]]] +CATEGORIES: Dict[str, Tuple[_NIC, _NIC] | Tuple[_NIC, List[Tuple[_NIC, _NIC]]]] FLAGS: Dict[str, int] GLOBAL_FLAGS: int @@ -19,8 +19,8 @@ class Verbose(Exception): ... class _State: flags: int groupdict: Dict[str, int] - groupwidths: List[Optional[int]] - lookbehindgroups: Optional[int] + groupwidths: List[int | None] + lookbehindgroups: int | None def __init__(self) -> None: ... @property def groups(self) -> int: ... @@ -43,19 +43,19 @@ _CodeType = Tuple[_NIC, _AvType] class SubPattern: data: List[_CodeType] - width: Optional[int] + width: int | None if sys.version_info >= (3, 8): state: State - def __init__(self, state: State, data: Optional[List[_CodeType]] = ...) -> None: ... + def __init__(self, state: State, data: List[_CodeType] | None = ...) -> None: ... else: pattern: Pattern - def __init__(self, pattern: Pattern, data: Optional[List[_CodeType]] = ...) -> None: ... + def __init__(self, pattern: Pattern, data: List[_CodeType] | None = ...) -> None: ... def dump(self, level: int = ...) -> None: ... def __len__(self) -> int: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... - def __getitem__(self, index: Union[int, slice]) -> Union[SubPattern, _CodeType]: ... - def __setitem__(self, index: Union[int, slice], code: _CodeType) -> None: ... + def __delitem__(self, index: int | slice) -> None: ... + def __getitem__(self, index: int | slice) -> SubPattern | _CodeType: ... + def __setitem__(self, index: int | slice, code: _CodeType) -> None: ... def insert(self, index: int, code: _CodeType) -> None: ... def append(self, code: _CodeType) -> None: ... def getwidth(self) -> int: ... @@ -65,10 +65,10 @@ class Tokenizer: string: Any decoded_string: str index: int - next: Optional[str] + next: str | None def __init__(self, string: Any) -> None: ... def match(self, char: str) -> bool: ... - def get(self) -> Optional[str]: ... + def get(self) -> str | None: ... def getwhile(self, n: int, charset: Iterable[str]) -> str: ... if sys.version_info >= (3, 8): def getuntil(self, terminator: str, name: str) -> str: ... @@ -80,19 +80,19 @@ class Tokenizer: def seek(self, index: int) -> None: ... def error(self, msg: str, offset: int = ...) -> _Error: ... -def fix_flags(src: Union[str, bytes], flags: int) -> int: ... +def fix_flags(src: str | bytes, flags: int) -> int: ... _TemplateType = Tuple[List[Tuple[int, int]], List[Optional[str]]] _TemplateByteType = Tuple[List[Tuple[int, int]], List[Optional[bytes]]] if sys.version_info >= (3, 8): - def parse(str: str, flags: int = ..., state: Optional[State] = ...) -> SubPattern: ... + def parse(str: str, flags: int = ..., state: State | None = ...) -> SubPattern: ... @overload def parse_template(source: str, state: _Pattern[Any]) -> _TemplateType: ... @overload def parse_template(source: bytes, state: _Pattern[Any]) -> _TemplateByteType: ... else: - def parse(str: str, flags: int = ..., pattern: Optional[Pattern] = ...) -> SubPattern: ... + def parse(str: str, flags: int = ..., pattern: Pattern | None = ...) -> SubPattern: ... @overload def parse_template(source: str, pattern: _Pattern[Any]) -> _TemplateType: ... @overload diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 4ca507d625ad..dfa978715fc6 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -19,7 +19,7 @@ class _Cipher(TypedDict): alg_bits: int auth: str description: str - digest: Optional[str] + digest: str | None id: int kea: str name: str @@ -47,18 +47,18 @@ else: def wrap_socket( sock: socket.socket, - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., + keyfile: str | None = ..., + certfile: str | None = ..., server_side: bool = ..., cert_reqs: int = ..., ssl_version: int = ..., - ca_certs: Optional[str] = ..., + ca_certs: str | None = ..., do_handshake_on_connect: bool = ..., suppress_ragged_eofs: bool = ..., - ciphers: Optional[str] = ..., + ciphers: str | None = ..., ) -> SSLSocket: ... def create_default_context( - purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[str, bytes, None] = ... + purpose: Any = ..., *, cafile: str | None = ..., capath: str | None = ..., cadata: str | bytes | None = ... ) -> SSLContext: ... if sys.version_info >= (3, 7): @@ -68,25 +68,25 @@ if sys.version_info >= (3, 7): cert_reqs: int = ..., check_hostname: bool = ..., purpose: Any = ..., - certfile: Optional[str] = ..., - keyfile: Optional[str] = ..., - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[str, bytes, None] = ..., + certfile: str | None = ..., + keyfile: str | None = ..., + cafile: str | None = ..., + capath: str | None = ..., + cadata: str | bytes | None = ..., ) -> SSLContext: ... else: def _create_unverified_context( protocol: int = ..., *, - cert_reqs: Optional[int] = ..., + cert_reqs: int | None = ..., check_hostname: bool = ..., purpose: Any = ..., - certfile: Optional[str] = ..., - keyfile: Optional[str] = ..., - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[str, bytes, None] = ..., + certfile: str | None = ..., + keyfile: str | None = ..., + cafile: str | None = ..., + capath: str | None = ..., + cadata: str | bytes | None = ..., ) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] @@ -98,7 +98,7 @@ def RAND_egd(path: str) -> None: ... def RAND_add(__s: bytes, __entropy: float) -> None: ... def match_hostname(cert: _PeerCertRetType, hostname: str) -> None: ... def cert_time_to_seconds(cert_time: str) -> int: ... -def get_server_certificate(addr: Tuple[str, int], ssl_version: int = ..., ca_certs: Optional[str] = ...) -> str: ... +def get_server_certificate(addr: Tuple[str, int], ssl_version: int = ..., ca_certs: str | None = ...) -> str: ... def DER_cert_to_PEM_cert(der_cert_bytes: bytes) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... @@ -286,40 +286,40 @@ class Purpose(_ASN1Object, enum.Enum): class SSLSocket(socket.socket): context: SSLContext server_side: bool - server_hostname: Optional[str] - session: Optional[SSLSession] - session_reused: Optional[bool] + server_hostname: str | None + session: SSLSession | None + session_reused: bool | None if sys.version_info < (3, 7): def __init__( self, - sock: Optional[socket.socket] = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., + sock: socket.socket | None = ..., + keyfile: str | None = ..., + certfile: str | None = ..., server_side: bool = ..., cert_reqs: int = ..., ssl_version: int = ..., - ca_certs: Optional[str] = ..., + ca_certs: str | None = ..., do_handshake_on_connect: bool = ..., family: int = ..., type: int = ..., proto: int = ..., - fileno: Optional[int] = ..., + fileno: int | None = ..., suppress_ragged_eofs: bool = ..., - npn_protocols: Optional[Iterable[str]] = ..., - ciphers: Optional[str] = ..., - server_hostname: Optional[str] = ..., - _context: Optional[SSLContext] = ..., - _session: Optional[Any] = ..., + npn_protocols: Iterable[str] | None = ..., + ciphers: str | None = ..., + server_hostname: str | None = ..., + _context: SSLContext | None = ..., + _session: Any | None = ..., ) -> None: ... else: def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def connect(self, addr: Union[socket._Address, bytes]) -> None: ... - def connect_ex(self, addr: Union[socket._Address, bytes]) -> int: ... + def connect(self, addr: socket._Address | bytes) -> None: ... + def connect_ex(self, addr: socket._Address | bytes) -> int: ... def recv(self, buflen: int = ..., flags: int = ...) -> bytes: ... - def recv_into(self, buffer: WriteableBuffer, nbytes: Optional[int] = ..., flags: int = ...) -> int: ... + def recv_into(self, buffer: WriteableBuffer, nbytes: int | None = ..., flags: int = ...) -> int: ... def recvfrom(self, buflen: int = ..., flags: int = ...) -> tuple[bytes, socket._RetAddress]: ... def recvfrom_into( - self, buffer: WriteableBuffer, nbytes: Optional[int] = ..., flags: int = ... + self, buffer: WriteableBuffer, nbytes: int | None = ..., flags: int = ... ) -> tuple[int, socket._RetAddress]: ... def send(self, data: ReadableBuffer, flags: int = ...) -> int: ... def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ... @@ -327,27 +327,27 @@ class SSLSocket(socket.socket): def sendto(self, data: ReadableBuffer, flags_or_addr: socket._Address) -> int: ... @overload def sendto( - self, data: ReadableBuffer, flags_or_addr: Union[int, socket._Address], addr: Optional[socket._Address] = ... + self, data: ReadableBuffer, flags_or_addr: int | socket._Address, addr: socket._Address | None = ... ) -> int: ... def shutdown(self, how: int) -> None: ... - def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... + def read(self, len: int = ..., buffer: bytearray | None = ...) -> bytes: ... def write(self, data: bytes) -> int: ... def do_handshake(self, block: bool = ...) -> None: ... # block is undocumented @overload - def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ... + def getpeercert(self, binary_form: Literal[False] = ...) -> _PeerCertRetDictType | None: ... @overload - def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ... + def getpeercert(self, binary_form: Literal[True]) -> bytes | None: ... @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... - def cipher(self) -> Optional[Tuple[str, str, int]]: ... - def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... - def compression(self) -> Optional[str]: ... - def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... - def selected_alpn_protocol(self) -> Optional[str]: ... - def selected_npn_protocol(self) -> Optional[str]: ... + def cipher(self) -> Tuple[str, str, int] | None: ... + def shared_ciphers(self) -> List[Tuple[str, str, int]] | None: ... + def compression(self) -> str | None: ... + def get_channel_binding(self, cb_type: str = ...) -> bytes | None: ... + def selected_alpn_protocol(self) -> str | None: ... + def selected_npn_protocol(self) -> str | None: ... def accept(self) -> Tuple[SSLSocket, socket._RetAddress]: ... def unwrap(self) -> socket.socket: ... - def version(self) -> Optional[str]: ... + def version(self) -> str | None: ... def pending(self) -> int: ... if sys.version_info >= (3, 8): def verify_client_post_handshake(self) -> None: ... @@ -373,7 +373,7 @@ class SSLContext: hostname_checks_common_name: bool maximum_version: TLSVersion minimum_version: TLSVersion - sni_callback: Optional[Callable[[SSLObject, str, SSLContext], Union[None, int]]] + sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None sslobject_class: ClassVar[Type[SSLObject]] sslsocket_class: ClassVar[Type[SSLSocket]] if sys.version_info >= (3, 8): @@ -383,22 +383,22 @@ class SSLContext: def __init__(self, protocol: int = ...) -> None: ... def cert_store_stats(self) -> Dict[str, int]: ... def load_cert_chain( - self, certfile: StrPath, keyfile: Optional[StrPath] = ..., password: Optional[_PasswordType] = ... + self, certfile: StrPath, keyfile: StrPath | None = ..., password: _PasswordType | None = ... ) -> None: ... def load_default_certs(self, purpose: Purpose = ...) -> None: ... def load_verify_locations( - self, cafile: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., cadata: Union[str, bytes, None] = ... + self, cafile: StrPath | None = ..., capath: StrPath | None = ..., cadata: str | bytes | None = ... ) -> None: ... - def get_ca_certs(self, binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ... + def get_ca_certs(self, binary_form: bool = ...) -> List[_PeerCertRetDictType] | List[bytes]: ... def get_ciphers(self) -> list[_Cipher]: ... def set_default_verify_paths(self) -> None: ... def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... if sys.version_info >= (3, 7): - def set_servername_callback(self, server_name_callback: Optional[_SrvnmeCbType]) -> None: ... + def set_servername_callback(self, server_name_callback: _SrvnmeCbType | None) -> None: ... else: - def set_servername_callback(self, __method: Optional[_SrvnmeCbType]) -> None: ... + def set_servername_callback(self, __method: _SrvnmeCbType | None) -> None: ... def load_dh_params(self, __path: str) -> None: ... def set_ecdh_curve(self, __name: str) -> None: ... def wrap_socket( @@ -407,49 +407,49 @@ class SSLContext: server_side: bool = ..., do_handshake_on_connect: bool = ..., suppress_ragged_eofs: bool = ..., - server_hostname: Optional[str] = ..., - session: Optional[SSLSession] = ..., + server_hostname: str | None = ..., + session: SSLSession | None = ..., ) -> SSLSocket: ... def wrap_bio( self, incoming: MemoryBIO, outgoing: MemoryBIO, server_side: bool = ..., - server_hostname: Optional[str] = ..., - session: Optional[SSLSession] = ..., + server_hostname: str | None = ..., + session: SSLSession | None = ..., ) -> SSLObject: ... def session_stats(self) -> Dict[str, int]: ... class SSLObject: context: SSLContext server_side: bool - server_hostname: Optional[str] - session: Optional[SSLSession] + server_hostname: str | None + session: SSLSession | None session_reused: bool if sys.version_info >= (3, 7): def __init__(self, *args: Any, **kwargs: Any) -> None: ... else: def __init__( - self, sslobj: Any, owner: Optional[Union[SSLSocket, SSLObject]] = ..., session: Optional[Any] = ... + self, sslobj: Any, owner: SSLSocket | SSLObject | None = ..., session: Any | None = ... ) -> None: ... - def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... + def read(self, len: int = ..., buffer: bytearray | None = ...) -> bytes: ... def write(self, data: bytes) -> int: ... @overload - def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ... + def getpeercert(self, binary_form: Literal[False] = ...) -> _PeerCertRetDictType | None: ... @overload - def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ... + def getpeercert(self, binary_form: Literal[True]) -> bytes | None: ... @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... - def selected_alpn_protocol(self) -> Optional[str]: ... - def selected_npn_protocol(self) -> Optional[str]: ... - def cipher(self) -> Optional[Tuple[str, str, int]]: ... - def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... - def compression(self) -> Optional[str]: ... + def selected_alpn_protocol(self) -> str | None: ... + def selected_npn_protocol(self) -> str | None: ... + def cipher(self) -> Tuple[str, str, int] | None: ... + def shared_ciphers(self) -> List[Tuple[str, str, int]] | None: ... + def compression(self) -> str | None: ... def pending(self) -> int: ... def do_handshake(self) -> None: ... def unwrap(self) -> None: ... - def version(self) -> Optional[str]: ... - def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... + def version(self) -> str | None: ... + def get_channel_binding(self, cb_type: str = ...) -> bytes | None: ... if sys.version_info >= (3, 8): def verify_client_post_handshake(self) -> None: ... diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 305bb39616ce..ad22bba4b3f0 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -21,7 +21,7 @@ if sys.version_info >= (3, 8): def mean(data: Iterable[_NumberT]) -> _NumberT: ... if sys.version_info >= (3, 10): - def harmonic_mean(data: Iterable[_NumberT], weights: Optional[Iterable[_Number]] = ...) -> _NumberT: ... + def harmonic_mean(data: Iterable[_NumberT], weights: Iterable[_Number] | None = ...) -> _NumberT: ... else: def harmonic_mean(data: Iterable[_NumberT]) -> _NumberT: ... @@ -35,14 +35,14 @@ def mode(data: Iterable[_HashableT]) -> _HashableT: ... if sys.version_info >= (3, 8): def multimode(data: Iterable[_HashableT]) -> List[_HashableT]: ... -def pstdev(data: Iterable[_NumberT], mu: Optional[_NumberT] = ...) -> _NumberT: ... -def pvariance(data: Iterable[_NumberT], mu: Optional[_NumberT] = ...) -> _NumberT: ... +def pstdev(data: Iterable[_NumberT], mu: _NumberT | None = ...) -> _NumberT: ... +def pvariance(data: Iterable[_NumberT], mu: _NumberT | None = ...) -> _NumberT: ... if sys.version_info >= (3, 8): def quantiles(data: Iterable[_NumberT], *, n: int = ..., method: str = ...) -> List[_NumberT]: ... -def stdev(data: Iterable[_NumberT], xbar: Optional[_NumberT] = ...) -> _NumberT: ... -def variance(data: Iterable[_NumberT], xbar: Optional[_NumberT] = ...) -> _NumberT: ... +def stdev(data: Iterable[_NumberT], xbar: _NumberT | None = ...) -> _NumberT: ... +def variance(data: Iterable[_NumberT], xbar: _NumberT | None = ...) -> _NumberT: ... if sys.version_info >= (3, 8): class NormalDist: @@ -59,7 +59,7 @@ if sys.version_info >= (3, 8): def variance(self) -> float: ... @classmethod def from_samples(cls: Type[_T], data: Iterable[SupportsFloat]) -> _T: ... - def samples(self, n: int, *, seed: Optional[Any] = ...) -> List[float]: ... + def samples(self, n: int, *, seed: Any | None = ...) -> List[float]: ... def pdf(self, x: float) -> float: ... def cdf(self, x: float) -> float: ... def inv_cdf(self, p: float) -> float: ... @@ -67,14 +67,14 @@ if sys.version_info >= (3, 8): def quantiles(self, n: int = ...) -> List[float]: ... if sys.version_info >= (3, 9): def zscore(self, x: float) -> float: ... - def __add__(self, x2: Union[float, NormalDist]) -> NormalDist: ... - def __sub__(self, x2: Union[float, NormalDist]) -> NormalDist: ... + def __add__(self, x2: float | NormalDist) -> NormalDist: ... + def __sub__(self, x2: float | NormalDist) -> NormalDist: ... def __mul__(self, x2: float) -> NormalDist: ... def __truediv__(self, x2: float) -> NormalDist: ... def __pos__(self) -> NormalDist: ... def __neg__(self) -> NormalDist: ... __radd__ = __add__ - def __rsub__(self, x2: Union[float, NormalDist]) -> NormalDist: ... + def __rsub__(self, x2: float | NormalDist) -> NormalDist: ... __rmul__ = __mul__ def __hash__(self) -> int: ... diff --git a/stdlib/string.pyi b/stdlib/string.pyi index a39e64dd32ca..e7156105f94e 100644 --- a/stdlib/string.pyi +++ b/stdlib/string.pyi @@ -10,7 +10,7 @@ punctuation: str printable: str whitespace: str -def capwords(s: str, sep: Optional[str] = ...) -> str: ... +def capwords(s: str, sep: str | None = ...) -> str: ... class Template: template: str @@ -22,9 +22,9 @@ class Template: class Formatter: def format(self, __format_string: str, *args: Any, **kwargs: Any) -> str: ... def vformat(self, format_string: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> str: ... - def parse(self, format_string: str) -> Iterable[Tuple[str, Optional[str], Optional[str], Optional[str]]]: ... + def parse(self, format_string: str) -> Iterable[Tuple[str, str | None, str | None, str | None]]: ... def get_field(self, field_name: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... - def get_value(self, key: Union[int, str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... - def check_unused_args(self, used_args: Sequence[Union[int, str]], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... + def get_value(self, key: int | str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... + def check_unused_args(self, used_args: Sequence[int | str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... def format_field(self, value: Any, format_spec: str) -> Any: ... def convert_field(self, value: Any, conversion: str) -> Any: ... diff --git a/stdlib/struct.pyi b/stdlib/struct.pyi index ddda120254c8..7799e7dec62e 100644 --- a/stdlib/struct.pyi +++ b/stdlib/struct.pyi @@ -4,12 +4,12 @@ from typing import Any, Iterator, Tuple, Union class error(Exception): ... -def pack(fmt: Union[str, bytes], *v: Any) -> bytes: ... -def pack_into(fmt: Union[str, bytes], buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... -def unpack(__format: Union[str, bytes], __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... -def unpack_from(__format: Union[str, bytes], buffer: ReadableBuffer, offset: int = ...) -> Tuple[Any, ...]: ... -def iter_unpack(__format: Union[str, bytes], __buffer: ReadableBuffer) -> Iterator[Tuple[Any, ...]]: ... -def calcsize(__format: Union[str, bytes]) -> int: ... +def pack(fmt: str | bytes, *v: Any) -> bytes: ... +def pack_into(fmt: str | bytes, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... +def unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... +def unpack_from(__format: str | bytes, buffer: ReadableBuffer, offset: int = ...) -> Tuple[Any, ...]: ... +def iter_unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Iterator[Tuple[Any, ...]]: ... +def calcsize(__format: str | bytes) -> int: ... class Struct: if sys.version_info >= (3, 7): @@ -17,7 +17,7 @@ class Struct: else: format: bytes size: int - def __init__(self, format: Union[str, bytes]) -> None: ... + def __init__(self, format: str | bytes) -> None: ... def pack(self, *v: Any) -> bytes: ... def pack_into(self, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ... def unpack(self, __buffer: ReadableBuffer) -> Tuple[Any, ...]: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 73e97ccb79f0..80517ff9e0c7 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -59,7 +59,7 @@ class CompletedProcess(Generic[_T]): # and writing all the overloads would be horrific. stdout: _T stderr: _T - def __init__(self, args: _CMD, returncode: int, stdout: Optional[_T] = ..., stderr: Optional[_T] = ...) -> None: ... + def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ... def check_returncode(self) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -70,15 +70,15 @@ if sys.version_info >= (3, 7): def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -88,25 +88,25 @@ if sys.version_info >= (3, 7): *, capture_output: bool = ..., check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + input: str | None = ..., text: Literal[True], - timeout: Optional[float] = ..., + timeout: float | None = ..., ) -> CompletedProcess[str]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -117,24 +117,24 @@ if sys.version_info >= (3, 7): capture_output: bool = ..., check: bool = ..., encoding: str, - errors: Optional[str] = ..., - input: Optional[str] = ..., - text: Optional[bool] = ..., - timeout: Optional[float] = ..., + errors: str | None = ..., + input: str | None = ..., + text: bool | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[str]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -144,25 +144,25 @@ if sys.version_info >= (3, 7): *, capture_output: bool = ..., check: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., errors: str, - input: Optional[str] = ..., - text: Optional[bool] = ..., - timeout: Optional[float] = ..., + input: str | None = ..., + text: bool | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[str]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., *, universal_newlines: Literal[True], startupinfo: Any = ..., @@ -173,25 +173,25 @@ if sys.version_info >= (3, 7): # where the *real* keyword only args start capture_output: bool = ..., check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[str] = ..., - text: Optional[bool] = ..., - timeout: Optional[float] = ..., + encoding: str | None = ..., + errors: str | None = ..., + input: str | None = ..., + text: bool | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[str]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -203,23 +203,23 @@ if sys.version_info >= (3, 7): check: bool = ..., encoding: None = ..., errors: None = ..., - input: Optional[bytes] = ..., + input: bytes | None = ..., text: Literal[None, False] = ..., - timeout: Optional[float] = ..., + timeout: float | None = ..., ) -> CompletedProcess[bytes]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -229,11 +229,11 @@ if sys.version_info >= (3, 7): *, capture_output: bool = ..., check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[_TXT] = ..., - text: Optional[bool] = ..., - timeout: Optional[float] = ..., + encoding: str | None = ..., + errors: str | None = ..., + input: _TXT | None = ..., + text: bool | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[Any]: ... else: @@ -242,15 +242,15 @@ else: def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -260,23 +260,23 @@ else: *, check: bool = ..., encoding: str, - errors: Optional[str] = ..., - input: Optional[str] = ..., - timeout: Optional[float] = ..., + errors: str | None = ..., + input: str | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[str]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -285,24 +285,24 @@ else: pass_fds: Any = ..., *, check: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., errors: str, - input: Optional[str] = ..., - timeout: Optional[float] = ..., + input: str | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[str]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., *, universal_newlines: Literal[True], startupinfo: Any = ..., @@ -312,24 +312,24 @@ else: pass_fds: Any = ..., # where the *real* keyword only args start check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[str] = ..., - timeout: Optional[float] = ..., + encoding: str | None = ..., + errors: str | None = ..., + input: str | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[str]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -340,22 +340,22 @@ else: check: bool = ..., encoding: None = ..., errors: None = ..., - input: Optional[bytes] = ..., - timeout: Optional[float] = ..., + input: bytes | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[bytes]: ... @overload def run( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -364,25 +364,25 @@ else: pass_fds: Any = ..., *, check: bool = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - input: Optional[_TXT] = ..., - timeout: Optional[float] = ..., + encoding: str | None = ..., + errors: str | None = ..., + input: _TXT | None = ..., + timeout: float | None = ..., ) -> CompletedProcess[Any]: ... # Same args as Popen.__init__ def call( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -390,7 +390,7 @@ def call( start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., + timeout: float | None = ..., ) -> int: ... # Same args as Popen.__init__ @@ -401,18 +401,18 @@ def check_call( stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., - timeout: Optional[float] = ..., + timeout: float | None = ..., ) -> int: ... if sys.version_info >= (3, 7): @@ -421,14 +421,14 @@ if sys.version_info >= (3, 7): def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -436,24 +436,24 @@ if sys.version_info >= (3, 7): start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., + encoding: str | None = ..., + errors: str | None = ..., text: Literal[True], ) -> str: ... @overload def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -461,24 +461,24 @@ if sys.version_info >= (3, 7): start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., encoding: str, - errors: Optional[str] = ..., - text: Optional[bool] = ..., + errors: str | None = ..., + text: bool | None = ..., ) -> str: ... @overload def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -486,24 +486,24 @@ if sys.version_info >= (3, 7): start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., - encoding: Optional[str] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., + encoding: str | None = ..., errors: str, - text: Optional[bool] = ..., + text: bool | None = ..., ) -> str: ... @overload def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., *, universal_newlines: Literal[True], startupinfo: Any = ..., @@ -512,24 +512,24 @@ if sys.version_info >= (3, 7): start_new_session: bool = ..., pass_fds: Any = ..., # where the real keyword only ones start - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - text: Optional[bool] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., + encoding: str | None = ..., + errors: str | None = ..., + text: bool | None = ..., ) -> str: ... @overload def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -537,8 +537,8 @@ if sys.version_info >= (3, 7): start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., encoding: None = ..., errors: None = ..., text: Literal[None, False] = ..., @@ -547,14 +547,14 @@ if sys.version_info >= (3, 7): def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -562,11 +562,11 @@ if sys.version_info >= (3, 7): start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - text: Optional[bool] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., + encoding: str | None = ..., + errors: str | None = ..., + text: bool | None = ..., ) -> Any: ... # morally: -> _TXT else: @@ -574,14 +574,14 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -589,23 +589,23 @@ else: start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., encoding: str, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> str: ... @overload def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -613,23 +613,23 @@ else: start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., - encoding: Optional[str] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., + encoding: str | None = ..., errors: str, ) -> str: ... @overload def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., @@ -637,23 +637,23 @@ else: pass_fds: Any = ..., *, universal_newlines: Literal[True], - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., + encoding: str | None = ..., + errors: str | None = ..., ) -> str: ... @overload def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -661,8 +661,8 @@ else: start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., encoding: None = ..., errors: None = ..., ) -> bytes: ... @@ -670,14 +670,14 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -685,10 +685,10 @@ else: start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., - input: Optional[_TXT] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + timeout: float | None = ..., + input: _TXT | None = ..., + encoding: str | None = ..., + errors: str | None = ..., ) -> Any: ... # morally: -> _TXT PIPE: int @@ -698,11 +698,11 @@ DEVNULL: int class SubprocessError(Exception): ... class TimeoutExpired(SubprocessError): - def __init__(self, cmd: _CMD, timeout: float, output: Optional[_TXT] = ..., stderr: Optional[_TXT] = ...) -> None: ... + def __init__(self, cmd: _CMD, timeout: float, output: _TXT | None = ..., stderr: _TXT | None = ...) -> None: ... # morally: _CMD cmd: Any timeout: float - # morally: Optional[_TXT] + # morally: _TXT | None output: Any stdout: Any stderr: Any @@ -711,19 +711,19 @@ class CalledProcessError(SubprocessError): returncode: int # morally: _CMD cmd: Any - # morally: Optional[_TXT] + # morally: _TXT | None output: Any - # morally: Optional[_TXT] + # morally: _TXT | None stdout: Any stderr: Any - def __init__(self, returncode: int, cmd: _CMD, output: Optional[_TXT] = ..., stderr: Optional[_TXT] = ...) -> None: ... + def __init__(self, returncode: int, cmd: _CMD, output: _TXT | None = ..., stderr: _TXT | None = ...) -> None: ... class Popen(Generic[AnyStr]): args: _CMD - stdin: Optional[IO[AnyStr]] - stdout: Optional[IO[AnyStr]] - stderr: Optional[IO[AnyStr]] + stdin: IO[AnyStr] | None + stdout: IO[AnyStr] | None + stderr: IO[AnyStr] | None pid: int returncode: int universal_newlines: bool @@ -738,49 +738,49 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, - text: Optional[bool] = ..., + text: bool | None = ..., encoding: str, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> Popen[str]: ... @overload def __new__( cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, - text: Optional[bool] = ..., - encoding: Optional[str] = ..., + text: bool | None = ..., + encoding: str | None = ..., errors: str, ) -> Popen[str]: ... @overload @@ -788,68 +788,68 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., *, universal_newlines: Literal[True], - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., # where the *real* keyword only args start - text: Optional[bool] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + text: bool | None = ..., + encoding: str | None = ..., + errors: str | None = ..., ) -> Popen[str]: ... @overload def __new__( cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, text: Literal[True], - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., ) -> Popen[str]: ... @overload def __new__( cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: Literal[False] = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., @@ -864,25 +864,25 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, - text: Optional[bool] = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + text: bool | None = ..., + encoding: str | None = ..., + errors: str | None = ..., ) -> Popen[Any]: ... else: @overload @@ -890,47 +890,47 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, encoding: str, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> Popen[str]: ... @overload def __new__( cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, - encoding: Optional[str] = ..., + encoding: str | None = ..., errors: str, ) -> Popen[str]: ... @overload @@ -938,42 +938,42 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., *, universal_newlines: Literal[True], - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., # where the *real* keyword only args start - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., ) -> Popen[str]: ... @overload def __new__( cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: Literal[False] = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., @@ -987,35 +987,35 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., ) -> Popen[Any]: ... - def poll(self) -> Optional[int]: ... + def poll(self) -> int | None: ... if sys.version_info >= (3, 7): - def wait(self, timeout: Optional[float] = ...) -> int: ... + def wait(self, timeout: float | None = ...) -> int: ... else: - def wait(self, timeout: Optional[float] = ..., endtime: Optional[float] = ...) -> int: ... + def wait(self, timeout: float | None = ..., endtime: float | None = ...) -> int: ... # Return str/bytes def communicate( self, - input: Optional[AnyStr] = ..., - timeout: Optional[float] = ..., + input: AnyStr | None = ..., + timeout: float | None = ..., # morally this should be optional ) -> Tuple[AnyStr, AnyStr]: ... def send_signal(self, sig: int) -> None: ... @@ -1023,7 +1023,7 @@ class Popen(Generic[AnyStr]): def kill(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -1040,16 +1040,16 @@ if sys.platform == "win32": self, *, dwFlags: int = ..., - hStdInput: Optional[Any] = ..., - hStdOutput: Optional[Any] = ..., - hStdError: Optional[Any] = ..., + hStdInput: Any | None = ..., + hStdOutput: Any | None = ..., + hStdError: Any | None = ..., wShowWindow: int = ..., - lpAttributeList: Optional[Mapping[str, Any]] = ..., + lpAttributeList: Mapping[str, Any] | None = ..., ) -> None: ... dwFlags: int - hStdInput: Optional[Any] - hStdOutput: Optional[Any] - hStdError: Optional[Any] + hStdInput: Any | None + hStdOutput: Any | None + hStdError: Any | None wShowWindow: int if sys.version_info >= (3, 7): lpAttributeList: Mapping[str, Any] diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index 04a6832d8b44..228d5e19e2d3 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -33,7 +33,7 @@ class Au_read: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... - def getfp(self) -> Optional[IO[bytes]]: ... + def getfp(self) -> IO[bytes] | None: ... def rewind(self) -> None: ... def close(self) -> None: ... def tell(self) -> int: ... @@ -47,7 +47,7 @@ class Au_read: def getmarkers(self) -> None: ... def getmark(self, id: Any) -> NoReturn: ... def setpos(self, pos: int) -> None: ... - def readframes(self, nframes: int) -> Optional[bytes]: ... + def readframes(self, nframes: int) -> bytes | None: ... class Au_write: def __init__(self, f: _File) -> None: ... @@ -73,7 +73,7 @@ class Au_write: def close(self) -> None: ... # Returns a Au_read if mode is rb and Au_write if mode is wb -def open(f: _File, mode: Optional[str] = ...) -> Any: ... +def open(f: _File, mode: str | None = ...) -> Any: ... if sys.version_info < (3, 9): openfp = open diff --git a/stdlib/symtable.pyi b/stdlib/symtable.pyi index ea6ed55719c7..7e5fe3975165 100644 --- a/stdlib/symtable.pyi +++ b/stdlib/symtable.pyi @@ -30,10 +30,10 @@ class Class(SymbolTable): class Symbol(object): if sys.version_info >= (3, 8): def __init__( - self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ..., *, module_scope: bool = ... + self, name: str, flags: int, namespaces: Sequence[SymbolTable] | None = ..., *, module_scope: bool = ... ) -> None: ... else: - def __init__(self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ...) -> None: ... + def __init__(self, name: str, flags: int, namespaces: Sequence[SymbolTable] | None = ...) -> None: ... def get_name(self) -> str: ... def is_referenced(self) -> bool: ... def is_parameter(self) -> bool: ... diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index 5f0f4ab99534..9ec01c71cfea 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -33,10 +33,10 @@ _PathSequence = Sequence[Union[bytes, str]] # Unlike importlib.abc.MetaPathFinder, invalidate_caches() might not exist (see python docs) class _MetaPathFinder(Protocol): - def find_module(self, fullname: str, path: Optional[_PathSequence]) -> Optional[Loader]: ... + def find_module(self, fullname: str, path: _PathSequence | None) -> Loader | None: ... def find_spec( - self, fullname: str, path: Optional[_PathSequence], target: Optional[ModuleType] = ... - ) -> Optional[ModuleSpec]: ... + self, fullname: str, path: _PathSequence | None, target: ModuleType | None = ... + ) -> ModuleSpec | None: ... # ----- sys variables ----- if sys.platform != "win32": @@ -56,9 +56,9 @@ exec_prefix: str executable: str float_repr_style: str hexversion: int -last_type: Optional[Type[BaseException]] -last_value: Optional[BaseException] -last_traceback: Optional[TracebackType] +last_type: Type[BaseException] | None +last_value: BaseException | None +last_traceback: TracebackType | None maxsize: int maxunicode: int meta_path: List[_MetaPathFinder] @@ -67,13 +67,13 @@ if sys.version_info >= (3, 10): orig_argv: List[str] path: List[str] path_hooks: List[Any] # TODO precise type; function, path to finder -path_importer_cache: Dict[str, Optional[PathEntryFinder]] +path_importer_cache: Dict[str, PathEntryFinder | None] platform: str if sys.version_info >= (3, 9): platlibdir: str prefix: str if sys.version_info >= (3, 8): - pycache_prefix: Optional[str] + pycache_prefix: str | None ps1: str ps2: str stdin: TextIO @@ -189,13 +189,13 @@ def getswitchinterval() -> float: ... _ProfileFunc = Callable[[FrameType, str, Any], Any] -def getprofile() -> Optional[_ProfileFunc]: ... -def setprofile(profilefunc: Optional[_ProfileFunc]) -> None: ... +def getprofile() -> _ProfileFunc | None: ... +def setprofile(profilefunc: _ProfileFunc | None) -> None: ... _TraceFunc = Callable[[FrameType, str, Any], Optional[Callable[[FrameType, str, Any], Any]]] -def gettrace() -> Optional[_TraceFunc]: ... -def settrace(tracefunc: Optional[_TraceFunc]) -> None: ... +def gettrace() -> _TraceFunc | None: ... +def settrace(tracefunc: _TraceFunc | None) -> None: ... class _WinVersion(Tuple[int, int, int, int, str, int, int, int, int, Tuple[int, int, int]]): major: int @@ -234,10 +234,10 @@ if sys.version_info >= (3, 8): # not exported by sys class UnraisableHookArgs: exc_type: Type[BaseException] - exc_value: Optional[BaseException] - exc_traceback: Optional[TracebackType] - err_msg: Optional[str] - object: Optional[_object] + exc_value: BaseException | None + exc_traceback: TracebackType | None + err_msg: str | None + object: _object | None unraisablehook: Callable[[UnraisableHookArgs], Any] def addaudithook(hook: Callable[[str, Tuple[Any, ...]], Any]) -> None: ... def audit(__event: str, *args: Any) -> None: ... diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index c5f00ee9ea08..8f4df8b47c8c 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -1,17 +1,17 @@ from typing import IO, Any, Dict, List, Optional, Tuple, overload -def get_config_var(name: str) -> Optional[str]: ... +def get_config_var(name: str) -> str | None: ... @overload def get_config_vars() -> Dict[str, Any]: ... @overload def get_config_vars(arg: str, *args: str) -> List[Any]: ... def get_scheme_names() -> Tuple[str, ...]: ... def get_path_names() -> Tuple[str, ...]: ... -def get_path(name: str, scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> str: ... -def get_paths(scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> Dict[str, str]: ... +def get_path(name: str, scheme: str = ..., vars: Dict[str, Any] | None = ..., expand: bool = ...) -> str: ... +def get_paths(scheme: str = ..., vars: Dict[str, Any] | None = ..., expand: bool = ...) -> Dict[str, str]: ... def get_python_version() -> str: ... def get_platform() -> str: ... def is_python_build(check_home: bool = ...) -> bool: ... -def parse_config_h(fp: IO[Any], vars: Optional[Dict[str, Any]] = ...) -> Dict[str, Any]: ... +def parse_config_h(fp: IO[Any], vars: Dict[str, Any] | None = ...) -> Dict[str, Any]: ... def get_config_h_filename() -> str: ... def get_makefile_filename() -> str: ... diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 9101a19888f4..b0c3bce26fe9 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -72,21 +72,21 @@ PAX_NAME_FIELDS: Set[str] ENCODING: str def open( - name: Optional[StrOrBytesPath] = ..., + name: StrOrBytesPath | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., # depends on mode + fileobj: IO[bytes] | None = ..., # depends on mode bufsize: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., - compresslevel: Optional[int] = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., + compresslevel: int | None = ..., ) -> TarFile: ... class ExFileObject(io.BufferedReader): @@ -94,180 +94,180 @@ class ExFileObject(io.BufferedReader): class TarFile: OPEN_METH: Mapping[str, str] - name: Optional[StrOrBytesPath] + name: StrOrBytesPath | None mode: Literal["r", "a", "w", "x"] - fileobj: Optional[_Fileobj] - format: Optional[int] + fileobj: _Fileobj | None + format: int | None tarinfo: Type[TarInfo] - dereference: Optional[bool] - ignore_zeros: Optional[bool] - encoding: Optional[str] + dereference: bool | None + ignore_zeros: bool | None + encoding: str | None errors: str fileobject: Type[ExFileObject] - pax_headers: Optional[Mapping[str, str]] - debug: Optional[int] - errorlevel: Optional[int] + pax_headers: Mapping[str, str] | None + debug: int | None + errorlevel: int | None offset: int # undocumented def __init__( self, - name: Optional[StrOrBytesPath] = ..., + name: StrOrBytesPath | None = ..., mode: Literal["r", "a", "w", "x"] = ..., - fileobj: Optional[_Fileobj] = ..., - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + fileobj: _Fileobj | None = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., - copybufsize: Optional[int] = ..., # undocumented + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., + copybufsize: int | None = ..., # undocumented ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[TarInfo]: ... @classmethod def open( cls: Type[_TF], - name: Optional[StrOrBytesPath] = ..., + name: StrOrBytesPath | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., # depends on mode + fileobj: IO[bytes] | None = ..., # depends on mode bufsize: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> _TF: ... @classmethod def taropen( cls: Type[_TF], - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["r", "a", "w", "x"] = ..., - fileobj: Optional[_Fileobj] = ..., + fileobj: _Fileobj | None = ..., *, compresslevel: int = ..., - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> _TF: ... @overload @classmethod def gzopen( cls: Type[_TF], - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["r"] = ..., - fileobj: Optional[_GzipReadableFileobj] = ..., + fileobj: _GzipReadableFileobj | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> _TF: ... @overload @classmethod def gzopen( cls: Type[_TF], - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["w", "x"], - fileobj: Optional[_GzipWritableFileobj] = ..., + fileobj: _GzipWritableFileobj | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> _TF: ... @overload @classmethod def bz2open( cls: Type[_TF], - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["w", "x"], - fileobj: Optional[_Bz2WritableFileobj] = ..., + fileobj: _Bz2WritableFileobj | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> _TF: ... @overload @classmethod def bz2open( cls: Type[_TF], - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["r"] = ..., - fileobj: Optional[_Bz2ReadableFileobj] = ..., + fileobj: _Bz2ReadableFileobj | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> _TF: ... @classmethod def xzopen( cls: Type[_TF], - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["r", "w", "x"] = ..., - fileobj: Optional[IO[bytes]] = ..., - preset: Optional[int] = ..., + fileobj: IO[bytes] | None = ..., + preset: int | None = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> _TF: ... def getmember(self, name: str) -> TarInfo: ... def getmembers(self) -> List[TarInfo]: ... def getnames(self) -> List[str]: ... - def list(self, verbose: bool = ..., *, members: Optional[List[TarInfo]] = ...) -> None: ... - def next(self) -> Optional[TarInfo]: ... + def list(self, verbose: bool = ..., *, members: List[TarInfo] | None = ...) -> None: ... + def next(self) -> TarInfo | None: ... def extractall( - self, path: StrOrBytesPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, numeric_owner: bool = ... + self, path: StrOrBytesPath = ..., members: Iterable[TarInfo] | None = ..., *, numeric_owner: bool = ... ) -> None: ... def extract( - self, member: Union[str, TarInfo], path: StrOrBytesPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ... + self, member: str | TarInfo, path: StrOrBytesPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ... ) -> None: ... def _extract_member( self, tarinfo: TarInfo, targetpath: str, set_attrs: bool = ..., numeric_owner: bool = ... ) -> None: ... # undocumented - def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... + def extractfile(self, member: str | TarInfo) -> IO[bytes] | None: ... def makedir(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented def makefile(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented def makeunknown(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented @@ -281,29 +281,29 @@ class TarFile: def add( self, name: StrPath, - arcname: Optional[StrPath] = ..., + arcname: StrPath | None = ..., recursive: bool = ..., *, - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., + filter: Callable[[TarInfo], TarInfo | None] | None = ..., ) -> None: ... else: def add( self, name: StrPath, - arcname: Optional[StrPath] = ..., + arcname: StrPath | None = ..., recursive: bool = ..., - exclude: Optional[Callable[[str], bool]] = ..., + exclude: Callable[[str], bool] | None = ..., *, - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., + filter: Callable[[TarInfo], TarInfo | None] | None = ..., ) -> None: ... - def addfile(self, tarinfo: TarInfo, fileobj: Optional[IO[bytes]] = ...) -> None: ... + def addfile(self, tarinfo: TarInfo, fileobj: IO[bytes] | None = ...) -> None: ... def gettarinfo( - self, name: Optional[str] = ..., arcname: Optional[str] = ..., fileobj: Optional[IO[bytes]] = ... + self, name: str | None = ..., arcname: str | None = ..., fileobj: IO[bytes] | None = ... ) -> TarInfo: ... def close(self) -> None: ... if sys.version_info >= (3, 9): - def is_tarfile(name: Union[StrOrBytesPath, IO[bytes]]) -> bool: ... + def is_tarfile(name: StrOrBytesPath | IO[bytes]) -> bool: ... else: def is_tarfile(name: StrOrBytesPath) -> bool: ... @@ -328,8 +328,8 @@ class TarInfo: devminor: int offset: int offset_data: int - sparse: Optional[bytes] - tarfile: Optional[TarFile] + sparse: bytes | None + tarfile: TarFile | None mode: int type: bytes linkname: str @@ -347,15 +347,15 @@ class TarInfo: def linkpath(self) -> str: ... @linkpath.setter def linkpath(self, linkname: str) -> None: ... - def get_info(self) -> Mapping[str, Union[str, int, bytes, Mapping[str, str]]]: ... - def tobuf(self, format: Optional[int] = ..., encoding: Optional[str] = ..., errors: str = ...) -> bytes: ... + def get_info(self) -> Mapping[str, str | int | bytes | Mapping[str, str]]: ... + def tobuf(self, format: int | None = ..., encoding: str | None = ..., errors: str = ...) -> bytes: ... def create_ustar_header( - self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str + self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str ) -> bytes: ... def create_gnu_header( - self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str + self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str ) -> bytes: ... - def create_pax_header(self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str) -> bytes: ... + def create_pax_header(self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str) -> bytes: ... @classmethod def create_pax_global_header(cls, pax_headers: Mapping[str, str]) -> bytes: ... def isfile(self) -> bool: ... diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index 9910e7cd195a..dd852a051f02 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -82,8 +82,8 @@ EXOPL: bytes NOOPT: bytes class Telnet: - host: Optional[str] # undocumented - def __init__(self, host: Optional[str] = ..., port: int = ..., timeout: float = ...) -> None: ... + host: str | None # undocumented + def __init__(self, host: str | None = ..., port: int = ..., timeout: float = ...) -> None: ... def open(self, host: str, port: int = ..., timeout: float = ...) -> None: ... def msg(self, msg: str, *args: Any) -> None: ... def set_debuglevel(self, debuglevel: int) -> None: ... @@ -91,7 +91,7 @@ class Telnet: def get_socket(self) -> socket.socket: ... def fileno(self) -> int: ... def write(self, buffer: bytes) -> None: ... - def read_until(self, match: bytes, timeout: Optional[float] = ...) -> bytes: ... + def read_until(self, match: bytes, timeout: float | None = ...) -> bytes: ... def read_all(self) -> bytes: ... def read_some(self) -> bytes: ... def read_very_eager(self) -> bytes: ... @@ -99,7 +99,7 @@ class Telnet: def read_lazy(self) -> bytes: ... def read_very_lazy(self) -> bytes: ... def read_sb_data(self) -> bytes: ... - def set_option_negotiation_callback(self, callback: Optional[Callable[[socket.socket, bytes, bytes], Any]]) -> None: ... + def set_option_negotiation_callback(self, callback: Callable[[socket.socket, bytes, bytes], Any] | None) -> None: ... def process_rawq(self) -> None: ... def rawq_getchar(self) -> bytes: ... def fill_rawq(self) -> None: ... @@ -108,7 +108,7 @@ class Telnet: def mt_interact(self) -> None: ... def listener(self) -> None: ... def expect( - self, list: Sequence[Union[Pattern[bytes], bytes]], timeout: Optional[float] = ... - ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... + self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = ... + ) -> Tuple[int, Match[bytes] | None, bytes]: ... def __enter__(self: Self) -> Self: ... def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index db45db67f21d..b552875b2e96 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -10,7 +10,7 @@ if sys.version_info >= (3, 9): # global variables TMP_MAX: int -tempdir: Optional[str] +tempdir: str | None template: str _DirT = Union[AnyStr, os.PathLike[AnyStr]] @@ -20,40 +20,40 @@ if sys.version_info >= (3, 8): def NamedTemporaryFile( mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> _TemporaryFileWrapper[str]: ... @overload def NamedTemporaryFile( mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> _TemporaryFileWrapper[bytes]: ... @overload def NamedTemporaryFile( mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> _TemporaryFileWrapper[Any]: ... else: @@ -61,33 +61,33 @@ else: def NamedTemporaryFile( mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[str]: ... @overload def NamedTemporaryFile( mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[bytes]: ... @overload def NamedTemporaryFile( mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[Any]: ... @@ -99,68 +99,68 @@ else: def TemporaryFile( mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> IO[str]: ... @overload def TemporaryFile( mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> IO[bytes]: ... @overload def TemporaryFile( mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> IO[Any]: ... else: @overload def TemporaryFile( mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"], buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., ) -> IO[str]: ... @overload def TemporaryFile( mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., ) -> IO[bytes]: ... @overload def TemporaryFile( mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., - dir: Optional[_DirT[AnyStr]] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., + dir: _DirT[AnyStr] | None = ..., ) -> IO[Any]: ... class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): @@ -170,8 +170,8 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): def __init__(self, file: IO[AnyStr], name: str, delete: bool = ...) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None + ) -> bool | None: ... def __getattr__(self, name: str) -> Any: ... def close(self) -> None: ... # These methods don't exist directly on this object, but @@ -197,7 +197,7 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): def seek(self, offset: int, whence: int = ...) -> int: ... def seekable(self) -> bool: ... def tell(self) -> int: ... - def truncate(self, size: Optional[int] = ...) -> int: ... + def truncate(self, size: int | None = ...) -> int: ... def writable(self) -> bool: ... def write(self, s: AnyStr) -> int: ... def writelines(self, lines: Iterable[AnyStr]) -> None: ... @@ -217,13 +217,13 @@ class SpooledTemporaryFile(IO[AnyStr]): max_size: int = ..., mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[str] = ..., - prefix: Optional[str] = ..., - dir: Optional[str] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: str | None = ..., + prefix: str | None = ..., + dir: str | None = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> None: ... @overload def __init__( @@ -231,13 +231,13 @@ class SpooledTemporaryFile(IO[AnyStr]): max_size: int = ..., mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"] = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[str] = ..., - prefix: Optional[str] = ..., - dir: Optional[str] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: str | None = ..., + prefix: str | None = ..., + dir: str | None = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> None: ... @overload def __init__( @@ -245,16 +245,16 @@ class SpooledTemporaryFile(IO[AnyStr]): max_size: int = ..., mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[str] = ..., - prefix: Optional[str] = ..., - dir: Optional[str] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: str | None = ..., + prefix: str | None = ..., + dir: str | None = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> None: ... @property - def errors(self) -> Optional[str]: ... + def errors(self) -> str | None: ... else: @overload def __init__( @@ -262,11 +262,11 @@ class SpooledTemporaryFile(IO[AnyStr]): max_size: int = ..., mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[str] = ..., - prefix: Optional[str] = ..., - dir: Optional[str] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: str | None = ..., + prefix: str | None = ..., + dir: str | None = ..., ) -> None: ... @overload def __init__( @@ -274,11 +274,11 @@ class SpooledTemporaryFile(IO[AnyStr]): max_size: int = ..., mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"] = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[str] = ..., - prefix: Optional[str] = ..., - dir: Optional[str] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: str | None = ..., + prefix: str | None = ..., + dir: str | None = ..., ) -> None: ... @overload def __init__( @@ -286,17 +286,17 @@ class SpooledTemporaryFile(IO[AnyStr]): max_size: int = ..., mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[str] = ..., - prefix: Optional[str] = ..., - dir: Optional[str] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: str | None = ..., + prefix: str | None = ..., + dir: str | None = ..., ) -> None: ... def rollover(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... # These methods are copied from the abstract methods of IO, because # SpooledTemporaryFile implements IO. # See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918. @@ -309,7 +309,7 @@ class SpooledTemporaryFile(IO[AnyStr]): def readlines(self, hint: int = ...) -> List[AnyStr]: ... def seek(self, offset: int, whence: int = ...) -> int: ... def tell(self) -> int: ... - def truncate(self, size: Optional[int] = ...) -> int: ... + def truncate(self, size: int | None = ...) -> int: ... def write(self, s: AnyStr) -> int: ... def writelines(self, iterable: Iterable[AnyStr]) -> None: ... def __iter__(self) -> Iterator[AnyStr]: ... @@ -327,12 +327,12 @@ class TemporaryDirectory(Generic[AnyStr]): def __init__(self: TemporaryDirectory[str], suffix: None = ..., prefix: None = ..., dir: None = ...) -> None: ... @overload def __init__( - self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ... + self, suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ... ) -> None: ... def cleanup(self) -> None: ... def __enter__(self) -> AnyStr: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -341,16 +341,16 @@ class TemporaryDirectory(Generic[AnyStr]): def mkstemp() -> Tuple[int, str]: ... @overload def mkstemp( - suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., text: bool = ... + suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ..., text: bool = ... ) -> Tuple[int, AnyStr]: ... @overload def mkdtemp() -> str: ... @overload -def mkdtemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ... +def mkdtemp(suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ...) -> AnyStr: ... @overload def mktemp() -> str: ... @overload -def mktemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ... +def mktemp(suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ...) -> AnyStr: ... def gettempdirb() -> bytes: ... def gettempprefixb() -> bytes: ... def gettempdir() -> str: ... diff --git a/stdlib/textwrap.pyi b/stdlib/textwrap.pyi index 0fd80bcb6cff..70308adc49d2 100644 --- a/stdlib/textwrap.pyi +++ b/stdlib/textwrap.pyi @@ -11,7 +11,7 @@ class TextWrapper: break_long_words: bool = ... break_on_hyphens: bool = ... tabsize: int = ... - max_lines: Optional[int] = ... + max_lines: int | None = ... placeholder: str = ... # Attributes not present in documentation @@ -35,7 +35,7 @@ class TextWrapper: break_on_hyphens: bool = ..., tabsize: int = ..., *, - max_lines: Optional[int] = ..., + max_lines: int | None = ..., placeholder: str = ..., ) -> None: ... # Private methods *are* part of the documented API for subclasses. @@ -97,4 +97,4 @@ def shorten( placeholder: str = ..., ) -> str: ... def dedent(text: str) -> str: ... -def indent(text: str, prefix: str, predicate: Optional[Callable[[str], bool]] = ...) -> str: ... +def indent(text: str, prefix: str, predicate: Callable[[str], bool] | None = ...) -> str: ... diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index de75375056e0..47246fe05f0e 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -21,7 +21,7 @@ if sys.version_info >= (3, 8): from _thread import get_native_id as get_native_id def settrace(func: _TF) -> None: ... -def setprofile(func: Optional[_PF]) -> None: ... +def setprofile(func: _PF | None) -> None: ... def stack_size(size: int = ...) -> int: ... TIMEOUT_MAX: float @@ -35,26 +35,26 @@ class local(object): class Thread: name: str - ident: Optional[int] + ident: int | None daemon: bool def __init__( self, group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., + target: Callable[..., Any] | None = ..., + name: str | None = ..., args: Iterable[Any] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., + kwargs: Mapping[str, Any] | None = ..., *, - daemon: Optional[bool] = ..., + daemon: bool | None = ..., ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... - def join(self, timeout: Optional[float] = ...) -> None: ... + def join(self, timeout: float | None = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: str) -> None: ... if sys.version_info >= (3, 8): @property - def native_id(self) -> Optional[int]: ... # only available on some platforms + def native_id(self) -> int | None: ... # only available on some platforms def is_alive(self) -> bool: ... if sys.version_info < (3, 9): def isAlive(self) -> bool: ... @@ -67,8 +67,8 @@ class Lock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -77,23 +77,23 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock class Condition: - def __init__(self, lock: Union[Lock, _RLock, None] = ...) -> None: ... + def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> bool: ... - def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ... + def wait(self, timeout: float | None = ...) -> bool: ... + def wait_for(self, predicate: Callable[[], _T], timeout: float | None = ...) -> _T: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -101,10 +101,10 @@ class Condition: class Semaphore: def __init__(self, value: int = ...) -> None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... + def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... + def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... if sys.version_info >= (3, 9): def release(self, n: int = ...) -> None: ... else: @@ -117,7 +117,7 @@ class Event: def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> bool: ... + def wait(self, timeout: float | None = ...) -> bool: ... if sys.version_info >= (3, 8): from _thread import _excepthook, _ExceptHookArgs @@ -130,8 +130,8 @@ class Timer(Thread): self, interval: float, function: Callable[..., Any], - args: Optional[Iterable[Any]] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., + args: Iterable[Any] | None = ..., + kwargs: Mapping[str, Any] | None = ..., ) -> None: ... def cancel(self) -> None: ... @@ -139,8 +139,8 @@ class Barrier: parties: int n_waiting: int broken: bool - def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> int: ... + def __init__(self, parties: int, action: Callable[[], None] | None = ..., timeout: float | None = ...) -> None: ... + def wait(self, timeout: float | None = ...) -> int: ... def reset(self) -> None: ... def abort(self) -> None: ... diff --git a/stdlib/time.pyi b/stdlib/time.pyi index 48111fba1f79..e50cf4549b55 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -51,20 +51,12 @@ class _struct_time(NamedTuple): class struct_time(_struct_time): def __init__( self, - o: Union[ - Tuple[int, int, int, int, int, int, int, int, int], - Tuple[int, int, int, int, int, int, int, int, int, str], - Tuple[int, int, int, int, int, int, int, int, int, str, int], - ], + o: Tuple[int, int, int, int, int, int, int, int, int] | Tuple[int, int, int, int, int, int, int, int, int, str] | Tuple[int, int, int, int, int, int, int, int, int, str, int], _arg: Any = ..., ) -> None: ... def __new__( cls, - o: Union[ - Tuple[int, int, int, int, int, int, int, int, int], - Tuple[int, int, int, int, int, int, int, int, int, str], - Tuple[int, int, int, int, int, int, int, int, int, str, int], - ], + o: Tuple[int, int, int, int, int, int, int, int, int] | Tuple[int, int, int, int, int, int, int, int, int, str] | Tuple[int, int, int, int, int, int, int, int, int, str, int], _arg: Any = ..., ) -> struct_time: ... @property @@ -72,17 +64,17 @@ class struct_time(_struct_time): @property def tm_gmtoff(self) -> int: ... -def asctime(t: Union[_TimeTuple, struct_time] = ...) -> str: ... +def asctime(t: _TimeTuple | struct_time = ...) -> str: ... if sys.version_info < (3, 8): def clock() -> float: ... -def ctime(secs: Optional[float] = ...) -> str: ... -def gmtime(secs: Optional[float] = ...) -> struct_time: ... -def localtime(secs: Optional[float] = ...) -> struct_time: ... -def mktime(t: Union[_TimeTuple, struct_time]) -> float: ... +def ctime(secs: float | None = ...) -> str: ... +def gmtime(secs: float | None = ...) -> struct_time: ... +def localtime(secs: float | None = ...) -> struct_time: ... +def mktime(t: _TimeTuple | struct_time) -> float: ... def sleep(secs: float) -> None: ... -def strftime(format: str, t: Union[_TimeTuple, struct_time] = ...) -> str: ... +def strftime(format: str, t: _TimeTuple | struct_time = ...) -> str: ... def strptime(string: str, format: str = ...) -> struct_time: ... def time() -> float: ... diff --git a/stdlib/timeit.pyi b/stdlib/timeit.pyi index 18ab9bd93db4..7375b61091d1 100644 --- a/stdlib/timeit.pyi +++ b/stdlib/timeit.pyi @@ -7,15 +7,15 @@ default_timer: _Timer class Timer: def __init__( - self, stmt: _Stmt = ..., setup: _Stmt = ..., timer: _Timer = ..., globals: Optional[Dict[str, Any]] = ... + self, stmt: _Stmt = ..., setup: _Stmt = ..., timer: _Timer = ..., globals: Dict[str, Any] | None = ... ) -> None: ... - def print_exc(self, file: Optional[IO[str]] = ...) -> None: ... + def print_exc(self, file: IO[str] | None = ...) -> None: ... def timeit(self, number: int = ...) -> float: ... def repeat(self, repeat: int = ..., number: int = ...) -> List[float]: ... - def autorange(self, callback: Optional[Callable[[int, float], Any]] = ...) -> Tuple[int, float]: ... + def autorange(self, callback: Callable[[int, float], Any] | None = ...) -> Tuple[int, float]: ... def timeit( - stmt: _Stmt = ..., setup: _Stmt = ..., timer: _Timer = ..., number: int = ..., globals: Optional[Dict[str, Any]] = ... + stmt: _Stmt = ..., setup: _Stmt = ..., timer: _Timer = ..., number: int = ..., globals: Dict[str, Any] | None = ... ) -> float: ... def repeat( stmt: _Stmt = ..., @@ -23,9 +23,9 @@ def repeat( timer: _Timer = ..., repeat: int = ..., number: int = ..., - globals: Optional[Dict[str, Any]] = ..., + globals: Dict[str, Any] | None = ..., ) -> List[float]: ... _timerFunc = Callable[[], float] -def main(args: Optional[Sequence[str]] = ..., *, _wrap_timer: Optional[Callable[[_timerFunc], _timerFunc]] = ...) -> None: ... +def main(args: Sequence[str] | None = ..., *, _wrap_timer: Callable[[_timerFunc], _timerFunc] | None = ...) -> None: ... diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 51e402df5b4f..71931e7525ac 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -80,7 +80,7 @@ EXCEPTION = _tkinter.EXCEPTION # actually want _ScreenUnits instead. # # - If you think that Callable[something] is an appropriate type for -# something, then you may actually want Union[Callable[something], str], +# something, then you may actually want Callable[something] | str, # because it's often possible to specify a string of Tcl code. # # - Some options can be set only in __init__, but all options are available @@ -175,7 +175,7 @@ class Event(Generic[_W_co]): height: int width: int keycode: int - state: Union[int, str] + state: int | str time: int x: int y: int @@ -194,7 +194,7 @@ def NoDefaultRoot(): ... _TraceMode = Literal["array", "read", "write", "unset"] class Variable: - def __init__(self, master: Optional[Misc] = ..., value: Optional[Any] = ..., name: Optional[str] = ...) -> None: ... + def __init__(self, master: Misc | None = ..., value: Any | None = ..., name: str | None = ...) -> None: ... def set(self, value: Any) -> None: ... initialize = set def get(self) -> Any: ... @@ -207,25 +207,25 @@ class Variable: trace = trace_variable # deprecated class StringVar(Variable): - def __init__(self, master: Optional[Misc] = ..., value: Optional[str] = ..., name: Optional[str] = ...) -> None: ... + def __init__(self, master: Misc | None = ..., value: str | None = ..., name: str | None = ...) -> None: ... def set(self, value: str) -> None: ... initialize = set def get(self) -> str: ... class IntVar(Variable): - def __init__(self, master: Optional[Misc] = ..., value: Optional[int] = ..., name: Optional[str] = ...) -> None: ... + def __init__(self, master: Misc | None = ..., value: int | None = ..., name: str | None = ...) -> None: ... def set(self, value: int) -> None: ... initialize = set def get(self) -> int: ... class DoubleVar(Variable): - def __init__(self, master: Optional[Misc] = ..., value: Optional[float] = ..., name: Optional[str] = ...) -> None: ... + def __init__(self, master: Misc | None = ..., value: float | None = ..., name: str | None = ...) -> None: ... def set(self, value: float) -> None: ... initialize = set def get(self) -> float: ... class BooleanVar(Variable): - def __init__(self, master: Optional[Misc] = ..., value: Optional[bool] = ..., name: Optional[str] = ...) -> None: ... + def __init__(self, master: Misc | None = ..., value: bool | None = ..., name: str | None = ...) -> None: ... def set(self, value: bool) -> None: ... initialize = set def get(self) -> bool: ... @@ -238,18 +238,18 @@ getdouble: Any def getboolean(s): ... class Misc: - master: Optional[Misc] + master: Misc | None tk: _tkinter.TkappType children: Dict[str, Widget] def destroy(self) -> None: ... def deletecommand(self, name: str) -> None: ... - def tk_strictMotif(self, boolean: Optional[Any] = ...): ... + def tk_strictMotif(self, boolean: Any | None = ...): ... def tk_bisque(self): ... def tk_setPalette(self, *args, **kw): ... - def wait_variable(self, name: Union[str, Variable] = ...) -> None: ... + def wait_variable(self, name: str | Variable = ...) -> None: ... waitvar = wait_variable - def wait_window(self, window: Optional[Misc] = ...) -> None: ... - def wait_visibility(self, window: Optional[Misc] = ...) -> None: ... + def wait_window(self, window: Misc | None = ...) -> None: ... + def wait_visibility(self, window: Misc | None = ...) -> None: ... def setvar(self, name: str = ..., value: str = ...): ... def getvar(self, name: str = ...): ... def getint(self, s): ... @@ -258,20 +258,20 @@ class Misc: def focus_set(self) -> None: ... focus = focus_set def focus_force(self) -> None: ... - def focus_get(self) -> Optional[Misc]: ... - def focus_displayof(self) -> Optional[Misc]: ... - def focus_lastfor(self) -> Optional[Misc]: ... + def focus_get(self) -> Misc | None: ... + def focus_displayof(self) -> Misc | None: ... + def focus_lastfor(self) -> Misc | None: ... def tk_focusFollowsMouse(self) -> None: ... - def tk_focusNext(self) -> Optional[Misc]: ... - def tk_focusPrev(self) -> Optional[Misc]: ... + def tk_focusNext(self) -> Misc | None: ... + def tk_focusPrev(self) -> Misc | None: ... @overload def after(self, ms: int, func: None = ...) -> None: ... @overload - def after(self, ms: Union[int, Literal["idle"]], func: Callable[..., Any], *args: Any) -> str: ... + def after(self, ms: int | Literal["idle"], func: Callable[..., Any], *args: Any) -> str: ... # after_idle is essentially partialmethod(after, "idle") def after_idle(self, func: Callable[..., Any], *args: Any) -> str: ... def after_cancel(self, id: str) -> None: ... - def bell(self, displayof: Union[Literal[0], Misc, None] = ...): ... + def bell(self, displayof: Literal[0] | Misc | None = ...): ... def clipboard_get(self, *, displayof: Misc = ..., type: str = ...) -> str: ... def clipboard_clear(self, *, displayof: Misc = ...) -> None: ... def clipboard_append(self, string: str, *, displayof: Misc = ..., format: str = ..., type: str = ...): ... @@ -280,38 +280,38 @@ class Misc: def grab_set(self): ... def grab_set_global(self): ... def grab_status(self): ... - def option_add(self, pattern, value, priority: Optional[Any] = ...): ... + def option_add(self, pattern, value, priority: Any | None = ...): ... def option_clear(self): ... def option_get(self, name, className): ... - def option_readfile(self, fileName, priority: Optional[Any] = ...): ... + def option_readfile(self, fileName, priority: Any | None = ...): ... def selection_clear(self, **kw): ... def selection_get(self, **kw): ... def selection_handle(self, command, **kw): ... def selection_own(self, **kw): ... def selection_own_get(self, **kw): ... def send(self, interp, cmd, *args): ... - def lower(self, belowThis: Optional[Any] = ...): ... - def tkraise(self, aboveThis: Optional[Any] = ...): ... + def lower(self, belowThis: Any | None = ...): ... + def tkraise(self, aboveThis: Any | None = ...): ... lift = tkraise - def winfo_atom(self, name: str, displayof: Union[Literal[0], Misc, None] = ...): ... - def winfo_atomname(self, id: int, displayof: Union[Literal[0], Misc, None] = ...): ... + def winfo_atom(self, name: str, displayof: Literal[0] | Misc | None = ...): ... + def winfo_atomname(self, id: int, displayof: Literal[0] | Misc | None = ...): ... def winfo_cells(self) -> int: ... def winfo_children(self) -> List[Widget]: ... # Widget because it can't be Toplevel or Tk def winfo_class(self) -> str: ... def winfo_colormapfull(self) -> bool: ... - def winfo_containing(self, rootX: int, rootY: int, displayof: Union[Literal[0], Misc, None] = ...) -> Optional[Misc]: ... + def winfo_containing(self, rootX: int, rootY: int, displayof: Literal[0] | Misc | None = ...) -> Misc | None: ... def winfo_depth(self) -> int: ... def winfo_exists(self) -> bool: ... def winfo_fpixels(self, number: _ScreenUnits) -> float: ... def winfo_geometry(self) -> str: ... def winfo_height(self) -> int: ... def winfo_id(self) -> int: ... - def winfo_interps(self, displayof: Union[Literal[0], Misc, None] = ...) -> Tuple[str, ...]: ... + def winfo_interps(self, displayof: Literal[0] | Misc | None = ...) -> Tuple[str, ...]: ... def winfo_ismapped(self) -> bool: ... def winfo_manager(self) -> str: ... def winfo_name(self) -> str: ... def winfo_parent(self) -> str: ... # return value needs nametowidget() - def winfo_pathname(self, id: int, displayof: Union[Literal[0], Misc, None] = ...): ... + def winfo_pathname(self, id: int, displayof: Literal[0] | Misc | None = ...): ... def winfo_pixels(self, number: _ScreenUnits) -> int: ... def winfo_pointerx(self) -> int: ... def winfo_pointerxy(self) -> Tuple[int, int]: ... @@ -330,7 +330,7 @@ class Misc: def winfo_screenvisual(self) -> str: ... def winfo_screenwidth(self) -> int: ... def winfo_server(self) -> str: ... - def winfo_toplevel(self) -> Union[Tk, Toplevel]: ... + def winfo_toplevel(self) -> Tk | Toplevel: ... def winfo_viewable(self) -> bool: ... def winfo_visual(self) -> str: ... def winfo_visualid(self) -> str: ... @@ -344,64 +344,64 @@ class Misc: def winfo_y(self) -> int: ... def update(self) -> None: ... def update_idletasks(self) -> None: ... - def bindtags(self, tagList: Optional[Any] = ...): ... + def bindtags(self, tagList: Any | None = ...): ... # bind with isinstance(func, str) doesn't return anything, but all other # binds do. The default value of func is not str. @overload def bind( - self, sequence: Optional[str] = ..., func: Optional[Callable[[Event[Misc]], Any]] = ..., add: Optional[bool] = ... + self, sequence: str | None = ..., func: Callable[[Event[Misc]], Any] | None = ..., add: bool | None = ... ) -> str: ... @overload - def bind(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ... + def bind(self, sequence: str | None, func: str, add: bool | None = ...) -> None: ... @overload - def bind(self, *, func: str, add: Optional[bool] = ...) -> None: ... + def bind(self, *, func: str, add: bool | None = ...) -> None: ... # There's no way to know what type of widget bind_all and bind_class # callbacks will get, so those are Misc. @overload def bind_all( - self, sequence: Optional[str] = ..., func: Optional[Callable[[Event[Misc]], Any]] = ..., add: Optional[bool] = ... + self, sequence: str | None = ..., func: Callable[[Event[Misc]], Any] | None = ..., add: bool | None = ... ) -> str: ... @overload - def bind_all(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ... + def bind_all(self, sequence: str | None, func: str, add: bool | None = ...) -> None: ... @overload - def bind_all(self, *, func: str, add: Optional[bool] = ...) -> None: ... + def bind_all(self, *, func: str, add: bool | None = ...) -> None: ... @overload def bind_class( self, className: str, - sequence: Optional[str] = ..., - func: Optional[Callable[[Event[Misc]], Any]] = ..., - add: Optional[bool] = ..., + sequence: str | None = ..., + func: Callable[[Event[Misc]], Any] | None = ..., + add: bool | None = ..., ) -> str: ... @overload - def bind_class(self, className: str, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ... + def bind_class(self, className: str, sequence: str | None, func: str, add: bool | None = ...) -> None: ... @overload - def bind_class(self, className: str, *, func: str, add: Optional[bool] = ...) -> None: ... - def unbind(self, sequence: str, funcid: Optional[str] = ...) -> None: ... + def bind_class(self, className: str, *, func: str, add: bool | None = ...) -> None: ... + def unbind(self, sequence: str, funcid: str | None = ...) -> None: ... def unbind_all(self, sequence: str) -> None: ... def unbind_class(self, className: str, sequence: str) -> None: ... def mainloop(self, n: int = ...) -> None: ... def quit(self): ... - def nametowidget(self, name: Union[str, Misc, _tkinter.Tcl_Obj]) -> Any: ... + def nametowidget(self, name: str | Misc | _tkinter.Tcl_Obj) -> Any: ... def register( - self, func: Callable[..., Any], subst: Optional[Callable[..., Sequence[Any]]] = ..., needcleanup: int = ... + self, func: Callable[..., Any], subst: Callable[..., Sequence[Any]] | None = ..., needcleanup: int = ... ) -> str: ... def keys(self) -> List[str]: ... @overload - def pack_propagate(self, flag: bool) -> Optional[bool]: ... + def pack_propagate(self, flag: bool) -> bool | None: ... @overload def pack_propagate(self) -> None: ... propagate = pack_propagate - def grid_anchor(self, anchor: Optional[_Anchor] = ...) -> None: ... + def grid_anchor(self, anchor: _Anchor | None = ...) -> None: ... anchor = grid_anchor @overload def grid_bbox( self, column: None = ..., row: None = ..., col2: None = ..., row2: None = ... - ) -> Optional[Tuple[int, int, int, int]]: ... + ) -> Tuple[int, int, int, int] | None: ... @overload - def grid_bbox(self, column: int, row: int, col2: None = ..., row2: None = ...) -> Optional[Tuple[int, int, int, int]]: ... + def grid_bbox(self, column: int, row: int, col2: None = ..., row2: None = ...) -> Tuple[int, int, int, int] | None: ... @overload - def grid_bbox(self, column: int, row: int, col2: int, row2: int) -> Optional[Tuple[int, int, int, int]]: ... + def grid_bbox(self, column: int, row: int, col2: int, row2: int) -> Tuple[int, int, int, int] | None: ... bbox = grid_bbox def grid_columnconfigure(self, index, cnf=..., **kw): ... # TODO def grid_rowconfigure(self, index, cnf=..., **kw): ... # TODO @@ -416,7 +416,7 @@ class Misc: size = grid_size # Widget because Toplevel or Tk is never a slave def pack_slaves(self) -> List[Widget]: ... - def grid_slaves(self, row: Optional[int] = ..., column: Optional[int] = ...) -> List[Widget]: ... + def grid_slaves(self, row: int | None = ..., column: int | None = ...) -> List[Widget]: ... def place_slaves(self) -> List[Widget]: ... slaves = pack_slaves def event_add(self, virtual: str, *sequences: str) -> None: ... @@ -425,7 +425,7 @@ class Misc: self, sequence: str, *, - above: Union[Misc, int] = ..., + above: Misc | int = ..., borderwidth: _ScreenUnits = ..., button: int = ..., count: int = ..., @@ -439,13 +439,13 @@ class Misc: mode: str = ..., override: bool = ..., place: Literal["PlaceOnTop", "PlaceOnBottom"] = ..., - root: Union[Misc, int] = ..., + root: Misc | int = ..., rootx: _ScreenUnits = ..., rooty: _ScreenUnits = ..., sendevent: bool = ..., serial: int = ..., - state: Union[int, str] = ..., - subwindow: Union[Misc, int] = ..., + state: int | str = ..., + subwindow: Misc | int = ..., time: int = ..., warp: bool = ..., width: _ScreenUnits = ..., @@ -453,7 +453,7 @@ class Misc: x: _ScreenUnits = ..., y: _ScreenUnits = ..., ) -> None: ... - def event_info(self, virtual: Optional[str] = ...) -> Tuple[str, ...]: ... + def event_info(self, virtual: str | None = ...) -> Tuple[str, ...]: ... def image_names(self) -> Tuple[str, ...]: ... def image_types(self) -> Tuple[str, ...]: ... # See #4363 and #4891 @@ -486,7 +486,7 @@ class Wm: @overload def wm_aspect( self, minNumer: None = ..., minDenom: None = ..., maxNumer: None = ..., maxDenom: None = ... - ) -> Optional[Tuple[int, int, int, int]]: ... + ) -> Tuple[int, int, int, int] | None: ... aspect = wm_aspect @overload def wm_attributes(self) -> Tuple[Any, ...]: ... @@ -495,7 +495,7 @@ class Wm: @overload def wm_attributes(self, __option: str, __value: Any, *__other_option_value_pairs: Any) -> None: ... attributes = wm_attributes - def wm_client(self, name: Optional[str] = ...) -> str: ... + def wm_client(self, name: str | None = ...) -> str: ... client = wm_client @overload def wm_colormapwindows(self) -> List[Misc]: ... @@ -504,12 +504,12 @@ class Wm: @overload def wm_colormapwindows(self, __first_wlist_item: Misc, *other_wlist_items: Misc) -> None: ... colormapwindows = wm_colormapwindows - def wm_command(self, value: Optional[str] = ...) -> str: ... + def wm_command(self, value: str | None = ...) -> str: ... command = wm_command # Some of these always return empty string, but return type is set to None to prevent accidentally using it def wm_deiconify(self) -> None: ... deiconify = wm_deiconify - def wm_focusmodel(self, model: Optional[Any] = ...): ... + def wm_focusmodel(self, model: Any | None = ...): ... focusmodel = wm_focusmodel def wm_forget(self, window: Wm) -> None: ... forget = wm_forget @@ -522,27 +522,27 @@ class Wm: geometry = wm_geometry def wm_grid( self, - baseWidth: Optional[Any] = ..., - baseHeight: Optional[Any] = ..., - widthInc: Optional[Any] = ..., - heightInc: Optional[Any] = ..., + baseWidth: Any | None = ..., + baseHeight: Any | None = ..., + widthInc: Any | None = ..., + heightInc: Any | None = ..., ): ... grid = wm_grid - def wm_group(self, pathName: Optional[Any] = ...): ... + def wm_group(self, pathName: Any | None = ...): ... group = wm_group - def wm_iconbitmap(self, bitmap: Optional[Any] = ..., default: Optional[Any] = ...): ... + def wm_iconbitmap(self, bitmap: Any | None = ..., default: Any | None = ...): ... iconbitmap = wm_iconbitmap def wm_iconify(self) -> None: ... iconify = wm_iconify - def wm_iconmask(self, bitmap: Optional[Any] = ...): ... + def wm_iconmask(self, bitmap: Any | None = ...): ... iconmask = wm_iconmask - def wm_iconname(self, newName: Optional[Any] = ...): ... + def wm_iconname(self, newName: Any | None = ...): ... iconname = wm_iconname def wm_iconphoto(self, default: bool, __image1: Image, *args: Image) -> None: ... iconphoto = wm_iconphoto - def wm_iconposition(self, x: Optional[Any] = ..., y: Optional[Any] = ...): ... + def wm_iconposition(self, x: Any | None = ..., y: Any | None = ...): ... iconposition = wm_iconposition - def wm_iconwindow(self, pathName: Optional[Any] = ...): ... + def wm_iconwindow(self, pathName: Any | None = ...): ... iconwindow = wm_iconwindow def wm_manage(self, widget): ... manage = wm_manage @@ -557,14 +557,14 @@ class Wm: def wm_minsize(self, width: int, height: int) -> None: ... minsize = wm_minsize @overload - def wm_overrideredirect(self, boolean: None = ...) -> Optional[bool]: ... # returns True or None + def wm_overrideredirect(self, boolean: None = ...) -> bool | None: ... # returns True or None @overload def wm_overrideredirect(self, boolean: bool) -> None: ... overrideredirect = wm_overrideredirect - def wm_positionfrom(self, who: Optional[Any] = ...): ... + def wm_positionfrom(self, who: Any | None = ...): ... positionfrom = wm_positionfrom @overload - def wm_protocol(self, name: str, func: Union[Callable[[], Any], str]) -> None: ... + def wm_protocol(self, name: str, func: Callable[[], Any] | str) -> None: ... @overload def wm_protocol(self, name: str, func: None = ...) -> str: ... @overload @@ -575,7 +575,7 @@ class Wm: @overload def wm_resizable(self, width: bool, height: bool) -> None: ... resizable = wm_resizable - def wm_sizefrom(self, who: Optional[Any] = ...): ... + def wm_sizefrom(self, who: Any | None = ...): ... sizefrom = wm_sizefrom @overload def wm_state(self, newstate: None = ...) -> str: ... @@ -590,7 +590,7 @@ class Wm: @overload def wm_transient(self, master: None = ...) -> _tkinter.Tcl_Obj: ... @overload - def wm_transient(self, master: Union[Wm, _tkinter.Tcl_Obj]) -> None: ... + def wm_transient(self, master: Wm | _tkinter.Tcl_Obj) -> None: ... transient = wm_transient def wm_withdraw(self) -> None: ... withdraw = wm_withdraw @@ -602,17 +602,17 @@ class Tk(Misc, Wm): master: None def __init__( self, - screenName: Optional[str] = ..., - baseName: Optional[str] = ..., + screenName: str | None = ..., + baseName: str | None = ..., className: str = ..., useTk: bool = ..., sync: bool = ..., - use: Optional[str] = ..., + use: str | None = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -630,7 +630,7 @@ class Tk(Misc, Wm): relief: _Relief = ..., takefocus: _TakeFocusValue = ..., width: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -672,7 +672,7 @@ class Tk(Misc, Wm): wantobjects: Any willdispatch: Any -def Tcl(screenName: Optional[Any] = ..., baseName: Optional[Any] = ..., className: str = ..., useTk: bool = ...): ... +def Tcl(screenName: Any | None = ..., baseName: Any | None = ..., className: str = ..., useTk: bool = ...): ... _InMiscTotal = TypedDict("_InMiscTotal", {"in": Misc}) _InMiscNonTotal = TypedDict("_InMiscNonTotal", {"in": Misc}, total=False) @@ -687,8 +687,8 @@ class _PackInfo(_InMiscTotal): # can be specified in pack(). ipadx: int ipady: int - padx: Union[int, Tuple[int, int]] - pady: Union[int, Tuple[int, int]] + padx: int | Tuple[int, int] + pady: int | Tuple[int, int] class Pack: # _PackInfo is not the valid type for cnf because pad stuff accepts any @@ -697,7 +697,7 @@ class Pack: # replaced by **kwargs. def pack_configure( self, - cnf: Optional[Mapping[str, Any]] = ..., + cnf: Mapping[str, Any] | None = ..., *, after: Misc = ..., anchor: _Anchor = ..., @@ -707,8 +707,8 @@ class Pack: side: Literal["left", "right", "top", "bottom"] = ..., ipadx: _ScreenUnits = ..., ipady: _ScreenUnits = ..., - padx: Union[_ScreenUnits, Tuple[_ScreenUnits, _ScreenUnits]] = ..., - pady: Union[_ScreenUnits, Tuple[_ScreenUnits, _ScreenUnits]] = ..., + padx: _ScreenUnits | Tuple[_ScreenUnits, _ScreenUnits] = ..., + pady: _ScreenUnits | Tuple[_ScreenUnits, _ScreenUnits] = ..., in_: Misc = ..., **kw: Any, # allow keyword argument named 'in', see #4836 ) -> None: ... @@ -741,7 +741,7 @@ class _PlaceInfo(_InMiscNonTotal): # empty dict if widget hasn't been placed class Place: def place_configure( self, - cnf: Optional[Mapping[str, Any]] = ..., + cnf: Mapping[str, Any] | None = ..., *, anchor: _Anchor = ..., bordermode: Literal["inside", "outside", "ignore"] = ..., @@ -750,10 +750,10 @@ class Place: x: _ScreenUnits = ..., y: _ScreenUnits = ..., # str allowed for compatibility with place_info() - relheight: Union[str, float] = ..., - relwidth: Union[str, float] = ..., - relx: Union[str, float] = ..., - rely: Union[str, float] = ..., + relheight: str | float = ..., + relwidth: str | float = ..., + relx: str | float = ..., + rely: str | float = ..., in_: Misc = ..., **kw: Any, # allow keyword argument named 'in', see #4836 ) -> None: ... @@ -776,14 +776,14 @@ class _GridInfo(_InMiscNonTotal): # empty dict if widget hasn't been gridded rowspan: int ipadx: int ipady: int - padx: Union[int, Tuple[int, int]] - pady: Union[int, Tuple[int, int]] + padx: int | Tuple[int, int] + pady: int | Tuple[int, int] sticky: str # consists of letters 'n', 's', 'w', 'e', no repeats, may be empty class Grid: def grid_configure( self, - cnf: Optional[Mapping[str, Any]] = ..., + cnf: Mapping[str, Any] | None = ..., *, column: int = ..., columnspan: int = ..., @@ -791,8 +791,8 @@ class Grid: rowspan: int = ..., ipadx: _ScreenUnits = ..., ipady: _ScreenUnits = ..., - padx: Union[_ScreenUnits, Tuple[_ScreenUnits, _ScreenUnits]] = ..., - pady: Union[_ScreenUnits, Tuple[_ScreenUnits, _ScreenUnits]] = ..., + padx: _ScreenUnits | Tuple[_ScreenUnits, _ScreenUnits] = ..., + pady: _ScreenUnits | Tuple[_ScreenUnits, _ScreenUnits] = ..., sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty in_: Misc = ..., **kw: Any, # allow keyword argument named 'in', see #4836 @@ -835,12 +835,12 @@ class Widget(BaseWidget, Pack, Place, Grid): # widgets don't. @overload def bind( - self: _W, sequence: Optional[str] = ..., func: Optional[Callable[[Event[_W]], Any]] = ..., add: Optional[bool] = ... + self: _W, sequence: str | None = ..., func: Callable[[Event[_W]], Any] | None = ..., add: bool | None = ... ) -> str: ... @overload - def bind(self, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ... + def bind(self, sequence: str | None, func: str, add: bool | None = ...) -> None: ... @overload - def bind(self, *, func: str, add: Optional[bool] = ...) -> None: ... + def bind(self, *, func: str, add: bool | None = ...) -> None: ... class Toplevel(BaseWidget, Wm): # Toplevel and Tk have the same options because they correspond to the same @@ -848,8 +848,8 @@ class Toplevel(BaseWidget, Wm): # copy/pasted here instead of aliasing as 'config = Tk.config'. def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -857,7 +857,7 @@ class Toplevel(BaseWidget, Wm): border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., class_: str = ..., - colormap: Union[Literal["new", ""], Misc] = ..., + colormap: Literal["new", ""] | Misc = ..., container: bool = ..., cursor: _Cursor = ..., height: _ScreenUnits = ..., @@ -872,13 +872,13 @@ class Toplevel(BaseWidget, Wm): screen: str = ..., # can't be changed after creating widget takefocus: _TakeFocusValue = ..., use: int = ..., - visual: Union[str, Tuple[str, int]] = ..., + visual: str | Tuple[str, int] = ..., width: _ScreenUnits = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -896,7 +896,7 @@ class Toplevel(BaseWidget, Wm): relief: _Relief = ..., takefocus: _TakeFocusValue = ..., width: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -904,8 +904,8 @@ class Toplevel(BaseWidget, Wm): class Button(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -941,7 +941,7 @@ class Button(Widget): repeatinterval: int = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., # We allow the textvariable to be any Variable, not necessarly # StringVar. This is useful for e.g. a button that displays the value # of an IntVar. @@ -953,7 +953,7 @@ class Button(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -986,12 +986,12 @@ class Button(Widget): repeatinterval: int = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., underline: int = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -1001,8 +1001,8 @@ class Button(Widget): class Canvas(Widget, XView, YView): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1028,7 +1028,7 @@ class Canvas(Widget, XView, YView): relief: _Relief = ..., # Setting scrollregion to None doesn't reset it back to empty, # but setting it to () does. - scrollregion: Union[Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], Tuple[()]] = ..., + scrollregion: Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | Tuple[()] = ..., selectbackground: _Color = ..., selectborderwidth: _ScreenUnits = ..., selectforeground: _Color = ..., @@ -1044,7 +1044,7 @@ class Canvas(Widget, XView, YView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1065,7 +1065,7 @@ class Canvas(Widget, XView, YView): insertwidth: _ScreenUnits = ..., offset: Any = ..., # undocumented relief: _Relief = ..., - scrollregion: Union[Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], Tuple[()]] = ..., + scrollregion: Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | Tuple[()] = ..., selectbackground: _Color = ..., selectborderwidth: _ScreenUnits = ..., selectforeground: _Color = ..., @@ -1076,7 +1076,7 @@ class Canvas(Widget, XView, YView): xscrollincrement: _ScreenUnits = ..., yscrollcommand: _XYScrollCommand = ..., yscrollincrement: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -1084,7 +1084,7 @@ class Canvas(Widget, XView, YView): def addtag_above(self, newtag, tagOrId): ... def addtag_all(self, newtag): ... def addtag_below(self, newtag, tagOrId): ... - def addtag_closest(self, newtag, x, y, halo: Optional[Any] = ..., start: Optional[Any] = ...): ... + def addtag_closest(self, newtag, x, y, halo: Any | None = ..., start: Any | None = ...): ... def addtag_enclosed(self, newtag, x1, y1, x2, y2): ... def addtag_overlapping(self, newtag, x1, y1, x2, y2): ... def addtag_withtag(self, newtag, tagOrId): ... @@ -1092,18 +1092,18 @@ class Canvas(Widget, XView, YView): @overload def tag_bind( self, - tagOrId: Union[str, int], - sequence: Optional[str] = ..., - func: Optional[Callable[[Event[Canvas]], Any]] = ..., - add: Optional[bool] = ..., + tagOrId: str | int, + sequence: str | None = ..., + func: Callable[[Event[Canvas]], Any] | None = ..., + add: bool | None = ..., ) -> str: ... @overload - def tag_bind(self, tagOrId: Union[str, int], sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ... + def tag_bind(self, tagOrId: str | int, sequence: str | None, func: str, add: bool | None = ...) -> None: ... @overload - def tag_bind(self, tagOrId: Union[str, int], *, func: str, add: Optional[bool] = ...) -> None: ... - def tag_unbind(self, tagOrId: Union[str, int], sequence: str, funcid: Optional[str] = ...) -> None: ... - def canvasx(self, screenx, gridspacing: Optional[Any] = ...): ... - def canvasy(self, screeny, gridspacing: Optional[Any] = ...): ... + def tag_bind(self, tagOrId: str | int, *, func: str, add: bool | None = ...) -> None: ... + def tag_unbind(self, tagOrId: str | int, sequence: str, funcid: str | None = ...) -> None: ... + def canvasx(self, screenx, gridspacing: Any | None = ...): ... + def canvasy(self, screeny, gridspacing: Any | None = ...): ... @overload def coords(self) -> list[float]: ... @overload @@ -1256,7 +1256,7 @@ class Canvas(Widget, XView, YView): state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., tags: str | _TkinterSequence[str] = ..., - text: Union[float, str] = ..., + text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... def create_window( @@ -1272,19 +1272,19 @@ class Canvas(Widget, XView, YView): window: Widget = ..., ) -> _CanvasItemId: ... def dchars(self, *args): ... - def delete(self, *tagsOrCanvasIds: Union[str, _CanvasItemId]) -> None: ... + def delete(self, *tagsOrCanvasIds: str | _CanvasItemId) -> None: ... @overload def dtag(self, __tag: str, __tag_to_delete: str | None = ...) -> None: ... @overload def dtag(self, __id: _CanvasItemId, __tag_to_delete: str) -> None: ... def find(self, *args): ... - def find_above(self, tagOrId: Union[str, _CanvasItemId]): ... + def find_above(self, tagOrId: str | _CanvasItemId): ... def find_all(self): ... - def find_below(self, tagOrId: Union[str, _CanvasItemId]): ... - def find_closest(self, x, y, halo: Optional[Any] = ..., start: Optional[Any] = ...): ... + def find_below(self, tagOrId: str | _CanvasItemId): ... + def find_closest(self, x, y, halo: Any | None = ..., start: Any | None = ...): ... def find_enclosed(self, x1, y1, x2, y2): ... def find_overlapping(self, x1, y1, x2, y2): ... - def find_withtag(self, tagOrId: Union[str, _CanvasItemId]): ... + def find_withtag(self, tagOrId: str | _CanvasItemId): ... def focus(self, *args): ... def gettags(self, __tagOrId: str | _CanvasItemId) -> Tuple[str, ...]: ... def icursor(self, *args): ... @@ -1299,7 +1299,7 @@ class Canvas(Widget, XView, YView): def move(self, *args): ... if sys.version_info >= (3, 8): def moveto( - self, tagOrId: Union[str, _CanvasItemId], x: Union[Literal[""], float] = ..., y: Union[Literal[""], float] = ... + self, tagOrId: str | _CanvasItemId, x: Literal[""] | float = ..., y: Literal[""] | float = ... ) -> None: ... def postscript(self, cnf=..., **kw): ... # tkinter does: @@ -1325,8 +1325,8 @@ class Canvas(Widget, XView, YView): class Checkbutton(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1373,19 +1373,19 @@ class Checkbutton(Widget): selectimage: _ImageSpec = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., tristateimage: _ImageSpec = ..., tristatevalue: Any = ..., underline: int = ..., - variable: Union[Variable, Literal[""]] = ..., + variable: Variable | Literal[""] = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1421,15 +1421,15 @@ class Checkbutton(Widget): selectimage: _ImageSpec = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., tristateimage: _ImageSpec = ..., tristatevalue: Any = ..., underline: int = ..., - variable: Union[Variable, Literal[""]] = ..., + variable: Variable | Literal[""] = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -1444,8 +1444,8 @@ _EntryIndex = Union[str, int] # "INDICES" in manual page class Entry(Widget, XView): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1489,7 +1489,7 @@ class Entry(Widget, XView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1528,7 +1528,7 @@ class Entry(Widget, XView): vcmd: _EntryValidateCommand = ..., width: int = ..., xscrollcommand: _XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -1555,8 +1555,8 @@ class Entry(Widget, XView): class Frame(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1564,7 +1564,7 @@ class Frame(Widget): border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., class_: str = ..., - colormap: Union[Literal["new", ""], Misc] = ..., + colormap: Literal["new", ""] | Misc = ..., container: bool = ..., cursor: _Cursor = ..., height: _ScreenUnits = ..., @@ -1576,13 +1576,13 @@ class Frame(Widget): pady: _ScreenUnits = ..., relief: _Relief = ..., takefocus: _TakeFocusValue = ..., - visual: Union[str, Tuple[str, int]] = ..., + visual: str | Tuple[str, int] = ..., width: _ScreenUnits = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1599,7 +1599,7 @@ class Frame(Widget): relief: _Relief = ..., takefocus: _TakeFocusValue = ..., width: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -1607,8 +1607,8 @@ class Frame(Widget): class Label(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1637,7 +1637,7 @@ class Label(Widget): relief: _Relief = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., underline: int = ..., width: _ScreenUnits = ..., @@ -1646,7 +1646,7 @@ class Label(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1674,12 +1674,12 @@ class Label(Widget): relief: _Relief = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., underline: int = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -1687,8 +1687,8 @@ class Label(Widget): class Listbox(Widget, XView, YView): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activestyle: Literal["dotbox", "none", "underline"] = ..., background: _Color = ..., @@ -1738,7 +1738,7 @@ class Listbox(Widget, XView, YView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activestyle: Literal["dotbox", "none", "underline"] = ..., background: _Color = ..., @@ -1769,15 +1769,15 @@ class Listbox(Widget, XView, YView): width: int = ..., xscrollcommand: _XYScrollCommand = ..., yscrollcommand: _XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def activate(self, index): ... def bbox(self, index): ... def curselection(self): ... - def delete(self, first, last: Optional[Any] = ...): ... - def get(self, first, last: Optional[Any] = ...): ... + def delete(self, first, last: Any | None = ...): ... + def get(self, first, last: Any | None = ...): ... def index(self, index): ... def insert(self, index, *elements): ... def nearest(self, y): ... @@ -1786,15 +1786,15 @@ class Listbox(Widget, XView, YView): def see(self, index): ... def selection_anchor(self, index): ... select_anchor: Any - def selection_clear(self, first, last: Optional[Any] = ...): ... # type: ignore + def selection_clear(self, first, last: Any | None = ...): ... # type: ignore select_clear: Any def selection_includes(self, index): ... select_includes: Any - def selection_set(self, first, last: Optional[Any] = ...): ... + def selection_set(self, first, last: Any | None = ...): ... select_set: Any def size(self): ... def itemcget(self, index, option): ... - def itemconfigure(self, index, cnf: Optional[Any] = ..., **kw): ... + def itemconfigure(self, index, cnf: Any | None = ..., **kw): ... itemconfig: Any _MenuIndex = Union[str, int] @@ -1802,8 +1802,8 @@ _MenuIndex = Union[str, int] class Menu(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeborderwidth: _ScreenUnits = ..., @@ -1819,7 +1819,7 @@ class Menu(Widget): font: _FontDescription = ..., foreground: _Color = ..., name: str = ..., - postcommand: Union[Callable[[], Any], str] = ..., + postcommand: Callable[[], Any] | str = ..., relief: _Relief = ..., selectcolor: _Color = ..., takefocus: _TakeFocusValue = ..., @@ -1827,14 +1827,14 @@ class Menu(Widget): # I guess tearoffcommand arguments are supposed to be widget objects, # but they are widget name strings. Use nametowidget() to handle the # arguments of tearoffcommand. - tearoffcommand: Union[Callable[[str, str], Any], str] = ..., + tearoffcommand: Callable[[str, str], Any] | str = ..., title: str = ..., type: Literal["menubar", "tearoff", "normal"] = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeborderwidth: _ScreenUnits = ..., @@ -1849,15 +1849,15 @@ class Menu(Widget): fg: _Color = ..., font: _FontDescription = ..., foreground: _Color = ..., - postcommand: Union[Callable[[], Any], str] = ..., + postcommand: Callable[[], Any] | str = ..., relief: _Relief = ..., selectcolor: _Color = ..., takefocus: _TakeFocusValue = ..., tearoff: bool = ..., - tearoffcommand: Union[Callable[[str, str], Any], str] = ..., + tearoffcommand: Callable[[str, str], Any] | str = ..., title: str = ..., type: Literal["menubar", "tearoff", "normal"] = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -1867,7 +1867,7 @@ class Menu(Widget): def insert(self, index, itemType, cnf=..., **kw): ... # docstring says "Internal function." def add_cascade( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1875,7 +1875,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Union[Callable[[], Any], str] = ..., + command: Callable[[], Any] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -1888,7 +1888,7 @@ class Menu(Widget): ) -> None: ... def add_checkbutton( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1896,7 +1896,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Union[Callable[[], Any], str] = ..., + command: Callable[[], Any] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -1914,7 +1914,7 @@ class Menu(Widget): ) -> None: ... def add_command( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1922,7 +1922,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Union[Callable[[], Any], str] = ..., + command: Callable[[], Any] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -1934,7 +1934,7 @@ class Menu(Widget): ) -> None: ... def add_radiobutton( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1942,7 +1942,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Union[Callable[[], Any], str] = ..., + command: Callable[[], Any] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -1957,11 +1957,11 @@ class Menu(Widget): value: Any = ..., variable: Variable = ..., ) -> None: ... - def add_separator(self, cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ...) -> None: ... + def add_separator(self, cnf: Dict[str, Any] | None = ..., *, background: _Color = ...) -> None: ... def insert_cascade( self, index: _MenuIndex, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1969,7 +1969,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Union[Callable[[], Any], str] = ..., + command: Callable[[], Any] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -1983,7 +1983,7 @@ class Menu(Widget): def insert_checkbutton( self, index: _MenuIndex, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1991,7 +1991,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Union[Callable[[], Any], str] = ..., + command: Callable[[], Any] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2010,7 +2010,7 @@ class Menu(Widget): def insert_command( self, index: _MenuIndex, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -2018,7 +2018,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Union[Callable[[], Any], str] = ..., + command: Callable[[], Any] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2031,7 +2031,7 @@ class Menu(Widget): def insert_radiobutton( self, index: _MenuIndex, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -2039,7 +2039,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Union[Callable[[], Any], str] = ..., + command: Callable[[], Any] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2054,7 +2054,7 @@ class Menu(Widget): value: Any = ..., variable: Variable = ..., ) -> None: ... - def insert_separator(self, index: _MenuIndex, cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ...) -> None: ... + def insert_separator(self, index: _MenuIndex, cnf: Dict[str, Any] | None = ..., *, background: _Color = ...) -> None: ... def delete(self, index1: _MenuIndex, index2: _MenuIndex | None = ...) -> None: ... def entrycget(self, index: _MenuIndex, option: str) -> Any: ... def entryconfigure( @@ -2072,8 +2072,8 @@ class Menu(Widget): class Menubutton(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -2105,7 +2105,7 @@ class Menubutton(Widget): relief: _Relief = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., underline: int = ..., width: _ScreenUnits = ..., @@ -2114,7 +2114,7 @@ class Menubutton(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -2145,12 +2145,12 @@ class Menubutton(Widget): relief: _Relief = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., underline: int = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -2158,8 +2158,8 @@ class Menubutton(Widget): class Message(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, anchor: _Anchor = ..., aspect: int = ..., @@ -2181,7 +2181,7 @@ class Message(Widget): pady: _ScreenUnits = ..., relief: _Relief = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., # there's width but no height width: _ScreenUnits = ..., @@ -2189,7 +2189,7 @@ class Message(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, anchor: _Anchor = ..., aspect: int = ..., @@ -2210,10 +2210,10 @@ class Message(Widget): pady: _ScreenUnits = ..., relief: _Relief = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., width: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -2221,8 +2221,8 @@ class Message(Widget): class Radiobutton(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -2257,20 +2257,20 @@ class Radiobutton(Widget): selectimage: _ImageSpec = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., tristateimage: _ImageSpec = ..., tristatevalue: Any = ..., underline: int = ..., value: Any = ..., - variable: Union[Variable, Literal[""]] = ..., + variable: Variable | Literal[""] = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -2304,16 +2304,16 @@ class Radiobutton(Widget): selectimage: _ImageSpec = ..., state: Literal["normal", "active", "disabled"] = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: Variable = ..., tristateimage: _ImageSpec = ..., tristatevalue: Any = ..., underline: int = ..., value: Any = ..., - variable: Union[Variable, Literal[""]] = ..., + variable: Variable | Literal[""] = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -2325,8 +2325,8 @@ class Radiobutton(Widget): class Scale(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., background: _Color = ..., @@ -2336,7 +2336,7 @@ class Scale(Widget): border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., # don't know why the callback gets string instead of float - command: Union[str, Callable[[str], Any]] = ..., + command: str | Callable[[str], Any] = ..., cursor: _Cursor = ..., digits: int = ..., fg: _Color = ..., @@ -2362,13 +2362,13 @@ class Scale(Widget): tickinterval: float = ..., to: float = ..., troughcolor: _Color = ..., - variable: Union[IntVar, DoubleVar] = ..., + variable: IntVar | DoubleVar = ..., width: _ScreenUnits = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., background: _Color = ..., @@ -2377,7 +2377,7 @@ class Scale(Widget): bigincrement: float = ..., border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - command: Union[str, Callable[[str], Any]] = ..., + command: str | Callable[[str], Any] = ..., cursor: _Cursor = ..., digits: int = ..., fg: _Color = ..., @@ -2402,22 +2402,22 @@ class Scale(Widget): tickinterval: float = ..., to: float = ..., troughcolor: _Color = ..., - variable: Union[IntVar, DoubleVar] = ..., + variable: IntVar | DoubleVar = ..., width: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def get(self): ... def set(self, value): ... - def coords(self, value: Optional[Any] = ...): ... + def coords(self, value: Any | None = ...): ... def identify(self, x, y): ... class Scrollbar(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activerelief: _Relief = ..., @@ -2430,7 +2430,7 @@ class Scrollbar(Widget): # 'SCROLLING COMMANDS' in scrollbar man page. There doesn't seem to # be any way to specify an overloaded callback function, so we say # that it can take any args while it can't in reality. - command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ..., + command: Callable[..., Tuple[float, float] | None] | str = ..., cursor: _Cursor = ..., elementborderwidth: _ScreenUnits = ..., highlightbackground: _Color = ..., @@ -2449,7 +2449,7 @@ class Scrollbar(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activerelief: _Relief = ..., @@ -2458,7 +2458,7 @@ class Scrollbar(Widget): bg: _Color = ..., border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ..., + command: Callable[..., Tuple[float, float] | None] | str = ..., cursor: _Cursor = ..., elementborderwidth: _ScreenUnits = ..., highlightbackground: _Color = ..., @@ -2472,11 +2472,11 @@ class Scrollbar(Widget): takefocus: _TakeFocusValue = ..., troughcolor: _Color = ..., width: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def activate(self, index: Optional[Any] = ...): ... + def activate(self, index: Any | None = ...): ... def delta(self, deltax, deltay): ... def fraction(self, x, y): ... def identify(self, x, y): ... @@ -2488,8 +2488,8 @@ _TextIndex = Union[_tkinter.Tcl_Obj, str, float, Misc] class Text(Widget, XView, YView): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, autoseparators: bool = ..., background: _Color = ..., @@ -2499,7 +2499,7 @@ class Text(Widget, XView, YView): border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., cursor: _Cursor = ..., - endline: Union[int, Literal[""]] = ..., + endline: int | Literal[""] = ..., exportselection: bool = ..., fg: _Color = ..., font: _FontDescription = ..., @@ -2530,10 +2530,10 @@ class Text(Widget, XView, YView): spacing1: _ScreenUnits = ..., spacing2: _ScreenUnits = ..., spacing3: _ScreenUnits = ..., - startline: Union[int, Literal[""]] = ..., + startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., # Literal inside Tuple doesn't actually work - tabs: Union[_ScreenUnits, str, Tuple[Union[_ScreenUnits, str], ...]] = ..., + tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2545,7 +2545,7 @@ class Text(Widget, XView, YView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, autoseparators: bool = ..., background: _Color = ..., @@ -2555,7 +2555,7 @@ class Text(Widget, XView, YView): border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., cursor: _Cursor = ..., - endline: Union[int, Literal[""]] = ..., + endline: int | Literal[""] = ..., exportselection: bool = ..., fg: _Color = ..., font: _FontDescription = ..., @@ -2582,9 +2582,9 @@ class Text(Widget, XView, YView): spacing1: _ScreenUnits = ..., spacing2: _ScreenUnits = ..., spacing3: _ScreenUnits = ..., - startline: Union[int, Literal[""]] = ..., + startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., - tabs: Union[_ScreenUnits, str, Tuple[Union[_ScreenUnits, str], ...]] = ..., + tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2592,24 +2592,24 @@ class Text(Widget, XView, YView): wrap: Literal["none", "char", "word"] = ..., xscrollcommand: _XYScrollCommand = ..., yscrollcommand: _XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def bbox(self, index: _TextIndex) -> Optional[Tuple[int, int, int, int]]: ... # type: ignore + def bbox(self, index: _TextIndex) -> Tuple[int, int, int, int] | None: ... # type: ignore def compare(self, index1: _TextIndex, op: Literal["<", "<=", "==", ">=", ">", "!="], index2: _TextIndex) -> bool: ... def count(self, index1, index2, *args): ... # TODO @overload def debug(self, boolean: None = ...) -> bool: ... @overload def debug(self, boolean: bool) -> None: ... - def delete(self, index1: _TextIndex, index2: Optional[_TextIndex] = ...) -> None: ... - def dlineinfo(self, index: _TextIndex) -> Optional[Tuple[int, int, int, int, int]]: ... + def delete(self, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... + def dlineinfo(self, index: _TextIndex) -> Tuple[int, int, int, int, int] | None: ... @overload def dump( self, index1: _TextIndex, - index2: Optional[_TextIndex] = ..., + index2: _TextIndex | None = ..., command: None = ..., *, all: bool = ..., @@ -2623,8 +2623,8 @@ class Text(Widget, XView, YView): def dump( self, index1: _TextIndex, - index2: Optional[_TextIndex], - command: Union[Callable[[str, str, str], Any], str], + index2: _TextIndex | None, + command: Callable[[str, str, str], Any] | str, *, all: bool = ..., image: bool = ..., @@ -2637,9 +2637,9 @@ class Text(Widget, XView, YView): def dump( self, index1: _TextIndex, - index2: Optional[_TextIndex] = ..., + index2: _TextIndex | None = ..., *, - command: Union[Callable[[str, str, str], Any], str], + command: Callable[[str, str, str], Any] | str, all: bool = ..., image: bool = ..., mark: bool = ..., @@ -2656,14 +2656,14 @@ class Text(Widget, XView, YView): def edit_reset(self) -> None: ... # actually returns empty string def edit_separator(self) -> None: ... # actually returns empty string def edit_undo(self) -> None: ... # actually returns empty string - def get(self, index1: _TextIndex, index2: Optional[_TextIndex] = ...) -> str: ... + def get(self, index1: _TextIndex, index2: _TextIndex | None = ...) -> str: ... # TODO: image_* methods def image_cget(self, index, option): ... - def image_configure(self, index, cnf: Optional[Any] = ..., **kw): ... + def image_configure(self, index, cnf: Any | None = ..., **kw): ... def image_create(self, index, cnf=..., **kw): ... def image_names(self): ... def index(self, index: _TextIndex) -> str: ... - def insert(self, index: _TextIndex, chars: str, *args: Union[str, _TkinterSequence[str]]) -> None: ... + def insert(self, index: _TextIndex, chars: str, *args: str | _TkinterSequence[str]) -> None: ... @overload def mark_gravity(self, markName: str, direction: None = ...) -> Literal["left", "right"]: ... @overload @@ -2671,44 +2671,44 @@ class Text(Widget, XView, YView): def mark_names(self) -> Tuple[str, ...]: ... def mark_set(self, markName: str, index: _TextIndex) -> None: ... def mark_unset(self, *markNames: str) -> None: ... - def mark_next(self, index: _TextIndex) -> Optional[str]: ... - def mark_previous(self, index: _TextIndex) -> Optional[str]: ... + def mark_next(self, index: _TextIndex) -> str | None: ... + def mark_previous(self, index: _TextIndex) -> str | None: ... # **kw of peer_create is same as the kwargs of Text.__init__ - def peer_create(self, newPathName: Union[str, Text], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def peer_create(self, newPathName: str | Text, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def peer_names(self) -> Tuple[_tkinter.Tcl_Obj, ...]: ... - def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: Union[str, _TkinterSequence[str]]) -> None: ... + def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | _TkinterSequence[str]) -> None: ... def scan_mark(self, x: int, y: int) -> None: ... def scan_dragto(self, x: int, y: int) -> None: ... def search( self, pattern: str, index: _TextIndex, - stopindex: Optional[_TextIndex] = ..., - forwards: Optional[bool] = ..., - backwards: Optional[bool] = ..., - exact: Optional[bool] = ..., - regexp: Optional[bool] = ..., - nocase: Optional[bool] = ..., - count: Optional[Variable] = ..., - elide: Optional[bool] = ..., + stopindex: _TextIndex | None = ..., + forwards: bool | None = ..., + backwards: bool | None = ..., + exact: bool | None = ..., + regexp: bool | None = ..., + nocase: bool | None = ..., + count: Variable | None = ..., + elide: bool | None = ..., ) -> str: ... # returns empty string for not found def see(self, index: _TextIndex) -> None: ... def tag_add(self, tagName: str, index1: _TextIndex, *args: _TextIndex) -> None: ... # tag_bind stuff is very similar to Canvas @overload def tag_bind( - self, tagName: str, sequence: Optional[str], func: Optional[Callable[[Event[Text]], Any]], add: Optional[bool] = ... + self, tagName: str, sequence: str | None, func: Callable[[Event[Text]], Any] | None, add: bool | None = ... ) -> str: ... @overload - def tag_bind(self, tagName: str, sequence: Optional[str], func: str, add: Optional[bool] = ...) -> None: ... - def tag_unbind(self, tagName: str, sequence: str, funcid: Optional[str] = ...) -> None: ... + def tag_bind(self, tagName: str, sequence: str | None, func: str, add: bool | None = ...) -> None: ... + def tag_unbind(self, tagName: str, sequence: str, funcid: str | None = ...) -> None: ... # allowing any string for cget instead of just Literals because there's no other way to look up tag options def tag_cget(self, tagName: str, option: str) -> Any: ... @overload def tag_configure( self, tagName: str, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bgstipple: _Bitmap = ..., @@ -2738,33 +2738,33 @@ class Text(Widget, XView, YView): underline: bool = ..., underlinefg: _Color = ..., wrap: Literal["none", "char", "word"] = ..., # be careful with "none" vs None - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def tag_configure(self, tagName: str, cnf: str) -> Tuple[str, str, str, Any, Any]: ... tag_config = tag_configure def tag_delete(self, __first_tag_name: str, *tagNames: str) -> None: ... # error if no tag names given - def tag_lower(self, tagName: str, belowThis: Optional[str] = ...) -> None: ... - def tag_names(self, index: Optional[_TextIndex] = ...) -> Tuple[str, ...]: ... + def tag_lower(self, tagName: str, belowThis: str | None = ...) -> None: ... + def tag_names(self, index: _TextIndex | None = ...) -> Tuple[str, ...]: ... def tag_nextrange( - self, tagName: str, index1: _TextIndex, index2: Optional[_TextIndex] = ... - ) -> Union[Tuple[str, str], Tuple[()]]: ... + self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ... + ) -> Tuple[str, str] | Tuple[()]: ... def tag_prevrange( - self, tagName: str, index1: _TextIndex, index2: Optional[_TextIndex] = ... - ) -> Union[Tuple[str, str], Tuple[()]]: ... - def tag_raise(self, tagName: str, aboveThis: Optional[str] = ...) -> None: ... + self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ... + ) -> Tuple[str, str] | Tuple[()]: ... + def tag_raise(self, tagName: str, aboveThis: str | None = ...) -> None: ... def tag_ranges(self, tagName: str) -> Tuple[_tkinter.Tcl_Obj, ...]: ... # tag_remove and tag_delete are different - def tag_remove(self, tagName: str, index1: _TextIndex, index2: Optional[_TextIndex] = ...) -> None: ... + def tag_remove(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... # TODO: window_* methods def window_cget(self, index, option): ... - def window_configure(self, index, cnf: Optional[Any] = ..., **kw): ... + def window_configure(self, index, cnf: Any | None = ..., **kw): ... window_config = window_configure def window_create(self, index, cnf=..., **kw): ... def window_names(self): ... def yview_pickplace(self, *what): ... # deprecated class _setit: - def __init__(self, var, value, callback: Optional[Any] = ...): ... + def __init__(self, var, value, callback: Any | None = ...): ... def __call__(self, *args): ... # manual page: tk_optionMenu @@ -2774,12 +2774,12 @@ class OptionMenu(Menubutton): def __init__( # differs from other widgets self, - master: Optional[Misc], + master: Misc | None, variable: StringVar, value: str, *values: str, # kwarg only from now on - command: Optional[Callable[[StringVar], Any]] = ..., + command: Callable[[StringVar], Any] | None = ..., ) -> None: ... # configure, config, cget are inherited from Menubutton # destroy and __getitem__ are overrided, signature does not change @@ -2793,7 +2793,7 @@ class Image: name: Any tk: _tkinter.TkappType def __init__( - self, imgtype, name: Optional[Any] = ..., cnf=..., master: Optional[Union[Misc, _tkinter.TkappType]] = ..., **kw + self, imgtype, name: Any | None = ..., cnf=..., master: Misc | _tkinter.TkappType | None = ..., **kw ): ... def __del__(self): ... def __setitem__(self, key, value): ... @@ -2807,27 +2807,27 @@ class Image: class PhotoImage(Image): def __init__( self, - name: Optional[str] = ..., + name: str | None = ..., cnf: Dict[str, Any] = ..., - master: Optional[Union[Misc, _tkinter.TkappType]] = ..., + master: Misc | _tkinter.TkappType | None = ..., *, - data: Union[str, bytes] = ..., # not same as data argument of put() + data: str | bytes = ..., # not same as data argument of put() format: str = ..., file: StrOrBytesPath = ..., gamma: float = ..., height: int = ..., - palette: Union[int, str] = ..., + palette: int | str = ..., width: int = ..., ) -> None: ... def configure( self, *, - data: Union[str, bytes] = ..., + data: str | bytes = ..., format: str = ..., file: StrOrBytesPath = ..., gamma: float = ..., height: int = ..., - palette: Union[int, str] = ..., + palette: int | str = ..., width: int = ..., ) -> None: ... config = configure @@ -2835,14 +2835,14 @@ class PhotoImage(Image): def cget(self, option: str) -> str: ... def __getitem__(self, key: str) -> str: ... # always string: image['height'] can be '0' def copy(self) -> PhotoImage: ... - def zoom(self, x: int, y: Union[int, Literal[""]] = ...) -> PhotoImage: ... - def subsample(self, x: int, y: Union[int, Literal[""]] = ...) -> PhotoImage: ... + def zoom(self, x: int, y: int | Literal[""] = ...) -> PhotoImage: ... + def subsample(self, x: int, y: int | Literal[""] = ...) -> PhotoImage: ... def get(self, x: int, y: int) -> Tuple[int, int, int]: ... def put( - self, data: Union[str, _TkinterSequence[str], _TkinterSequence2D[_Color]], to: Optional[Tuple[int, int]] = ... + self, data: str | _TkinterSequence[str] | _TkinterSequence2D[_Color], to: Tuple[int, int] | None = ... ) -> None: ... def write( - self, filename: StrOrBytesPath, format: Optional[str] = ..., from_coords: Optional[Tuple[int, int]] = ... + self, filename: StrOrBytesPath, format: str | None = ..., from_coords: Tuple[int, int] | None = ... ) -> None: ... if sys.version_info >= (3, 8): def transparency_get(self, x: int, y: int) -> bool: ... @@ -2851,12 +2851,12 @@ class PhotoImage(Image): class BitmapImage(Image): def __init__( self, - name: Optional[Any] = ..., + name: Any | None = ..., cnf: Dict[str, Any] = ..., - master: Optional[Union[Misc, _tkinter.TkappType]] = ..., + master: Misc | _tkinter.TkappType | None = ..., *, background: _Color = ..., - data: Union[str, bytes] = ..., + data: str | bytes = ..., file: StrOrBytesPath = ..., foreground: _Color = ..., maskdata: str = ..., @@ -2869,8 +2869,8 @@ def image_types() -> Tuple[str, ...]: ... class Spinbox(Widget, XView): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., background: _Color = ..., @@ -2883,7 +2883,7 @@ class Spinbox(Widget, XView): buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., # percent substitutions don't seem to be supported, it's similar to Entry's validion stuff - command: Union[Callable[[], Any], str, _TkinterSequence[str]] = ..., + command: Callable[[], Any] | str | _TkinterSequence[str] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -2928,7 +2928,7 @@ class Spinbox(Widget, XView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., background: _Color = ..., @@ -2940,7 +2940,7 @@ class Spinbox(Widget, XView): buttoncursor: _Cursor = ..., buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., - command: Union[Callable[[], Any], str, _TkinterSequence[str]] = ..., + command: Callable[[], Any] | str | _TkinterSequence[str] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -2980,12 +2980,12 @@ class Spinbox(Widget, XView): width: int = ..., wrap: bool = ..., xscrollcommand: _XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, index): ... - def delete(self, first, last: Optional[Any] = ...): ... + def delete(self, first, last: Any | None = ...): ... def get(self): ... def icursor(self, index): ... def identify(self, x, y): ... @@ -2999,7 +2999,7 @@ class Spinbox(Widget, XView): def selection(self, *args: Any) -> Tuple[int, ...]: ... def selection_adjust(self, index): ... def selection_clear(self): ... - def selection_element(self, element: Optional[Any] = ...): ... + def selection_element(self, element: Any | None = ...): ... if sys.version_info >= (3, 8): def selection_from(self, index: int) -> None: ... def selection_present(self) -> None: ... @@ -3009,8 +3009,8 @@ class Spinbox(Widget, XView): class LabelFrame(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -3018,7 +3018,7 @@ class LabelFrame(Widget): border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., class_: str = ..., - colormap: Union[Literal["new", ""], Misc] = ..., + colormap: Literal["new", ""] | Misc = ..., container: bool = ..., # undocumented cursor: _Cursor = ..., fg: _Color = ..., @@ -3036,14 +3036,14 @@ class LabelFrame(Widget): pady: _ScreenUnits = ..., relief: _Relief = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., - visual: Union[str, Tuple[str, int]] = ..., + text: float | str = ..., + visual: str | Tuple[str, int] = ..., width: _ScreenUnits = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -3064,9 +3064,9 @@ class LabelFrame(Widget): pady: _ScreenUnits = ..., relief: _Relief = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., width: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -3074,8 +3074,8 @@ class LabelFrame(Widget): class PanedWindow(Widget): def __init__( self, - master: Optional[Misc] = ..., - cnf: Optional[Dict[str, Any]] = ..., + master: Misc | None = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -3103,7 +3103,7 @@ class PanedWindow(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -3126,7 +3126,7 @@ class PanedWindow(Widget): sashwidth: _ScreenUnits = ..., showhandle: bool = ..., width: _ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -3143,6 +3143,6 @@ class PanedWindow(Widget): def sash_mark(self, index): ... def sash_place(self, index, x, y): ... def panecget(self, child, option): ... - def paneconfigure(self, tagOrId, cnf: Optional[Any] = ..., **kw): ... + def paneconfigure(self, tagOrId, cnf: Any | None = ..., **kw): ... paneconfig: Any def panes(self): ... diff --git a/stdlib/tkinter/colorchooser.pyi b/stdlib/tkinter/colorchooser.pyi index c99c16f0e3bf..23b31f34b17d 100644 --- a/stdlib/tkinter/colorchooser.pyi +++ b/stdlib/tkinter/colorchooser.pyi @@ -5,5 +5,5 @@ class Chooser(Dialog): command: ClassVar[str] def askcolor( - color: Optional[Union[str, bytes]] = ..., **options: Any -) -> Union[Tuple[None, None], Tuple[Tuple[float, float, float], str]]: ... + color: str | bytes | None = ..., **options: Any +) -> Tuple[None, None] | Tuple[Tuple[float, float, float], str]: ... diff --git a/stdlib/tkinter/commondialog.pyi b/stdlib/tkinter/commondialog.pyi index 8efefe468b04..91c4b2d5d739 100644 --- a/stdlib/tkinter/commondialog.pyi +++ b/stdlib/tkinter/commondialog.pyi @@ -1,8 +1,8 @@ from typing import Any, ClassVar, Mapping, Optional class Dialog: - command: ClassVar[Optional[str]] = ... - master: Optional[Any] = ... + command: ClassVar[str | None] = ... + master: Any | None = ... options: Mapping[str, Any] = ... - def __init__(self, master: Optional[Any] = ..., **options) -> None: ... + def __init__(self, master: Any | None = ..., **options) -> None: ... def show(self, **options) -> Any: ... diff --git a/stdlib/tkinter/dialog.pyi b/stdlib/tkinter/dialog.pyi index d02036a64f10..cf0c0cd3b013 100644 --- a/stdlib/tkinter/dialog.pyi +++ b/stdlib/tkinter/dialog.pyi @@ -6,5 +6,5 @@ DIALOG_ICON: str class Dialog(Widget): widgetName: str = ... num: int = ... - def __init__(self, master: Optional[Any] = ..., cnf: Mapping[str, Any] = ..., **kw) -> None: ... + def __init__(self, master: Any | None = ..., cnf: Mapping[str, Any] = ..., **kw) -> None: ... def destroy(self) -> None: ... diff --git a/stdlib/tkinter/dnd.pyi b/stdlib/tkinter/dnd.pyi index 71d8d3e5c4f4..a27a43871c2b 100644 --- a/stdlib/tkinter/dnd.pyi +++ b/stdlib/tkinter/dnd.pyi @@ -2,14 +2,14 @@ from tkinter import Event, Misc, Tk, Widget from typing import ClassVar, Optional, Protocol class _DndSource(Protocol): - def dnd_end(self, target: Optional[Widget], event: Optional[Event[Misc]]) -> None: ... + def dnd_end(self, target: Widget | None, event: Event[Misc] | None) -> None: ... class DndHandler: - root: ClassVar[Optional[Tk]] + root: ClassVar[Tk | None] def __init__(self, source: _DndSource, event: Event[Misc]) -> None: ... - def cancel(self, event: Optional[Event[Misc]] = ...) -> None: ... - def finish(self, event: Optional[Event[Misc]], commit: int = ...) -> None: ... + def cancel(self, event: Event[Misc] | None = ...) -> None: ... + def finish(self, event: Event[Misc] | None, commit: int = ...) -> None: ... def on_motion(self, event: Event[Misc]) -> None: ... def on_release(self, event: Event[Misc]) -> None: ... -def dnd_start(source, event) -> Optional[DndHandler]: ... +def dnd_start(source, event) -> DndHandler | None: ... diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index 885a1373ea93..84084591be5b 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -8,7 +8,7 @@ dialogstates: Dict[Any, Tuple[Any, Any]] class FileDialog: title: str = ... master: Any = ... - directory: Optional[Any] = ... + directory: Any | None = ... top: Toplevel = ... botframe: Frame = ... selection: Entry = ... @@ -22,21 +22,21 @@ class FileDialog: filter_button: Button = ... cancel_button: Button = ... def __init__( - self, master, title: Optional[Any] = ... + self, master, title: Any | None = ... ) -> None: ... # title is usually a str or None, but e.g. int doesn't raise en exception either - how: Optional[Any] = ... - def go(self, dir_or_file: Any = ..., pattern: str = ..., default: str = ..., key: Optional[Any] = ...): ... - def quit(self, how: Optional[Any] = ...) -> None: ... + how: Any | None = ... + def go(self, dir_or_file: Any = ..., pattern: str = ..., default: str = ..., key: Any | None = ...): ... + def quit(self, how: Any | None = ...) -> None: ... def dirs_double_event(self, event) -> None: ... def dirs_select_event(self, event) -> None: ... def files_double_event(self, event) -> None: ... def files_select_event(self, event) -> None: ... def ok_event(self, event) -> None: ... def ok_command(self) -> None: ... - def filter_command(self, event: Optional[Any] = ...) -> None: ... + def filter_command(self, event: Any | None = ...) -> None: ... def get_filter(self): ... def get_selection(self): ... - def cancel_command(self, event: Optional[Any] = ...) -> None: ... + def cancel_command(self, event: Any | None = ...) -> None: ... def set_filter(self, dir, pat) -> None: ... def set_selection(self, file) -> None: ... diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index e1733d5c2a88..9f1f526d6947 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -32,9 +32,9 @@ class Font: self, # In tkinter, 'root' refers to tkinter.Tk by convention, but the code # actually works with any tkinter widget so we use tkinter.Misc. - root: Optional[tkinter.Misc] = ..., - font: Optional[_FontDescription] = ..., - name: Optional[str] = ..., + root: tkinter.Misc | None = ..., + font: _FontDescription | None = ..., + name: str | None = ..., exists: bool = ..., *, family: str = ..., @@ -59,19 +59,19 @@ class Font: def cget(self, option: str) -> Any: ... __getitem__ = cget @overload - def actual(self, option: Literal["family"], displayof: Optional[tkinter.Misc] = ...) -> str: ... + def actual(self, option: Literal["family"], displayof: tkinter.Misc | None = ...) -> str: ... @overload - def actual(self, option: Literal["size"], displayof: Optional[tkinter.Misc] = ...) -> int: ... + def actual(self, option: Literal["size"], displayof: tkinter.Misc | None = ...) -> int: ... @overload - def actual(self, option: Literal["weight"], displayof: Optional[tkinter.Misc] = ...) -> Literal["normal", "bold"]: ... + def actual(self, option: Literal["weight"], displayof: tkinter.Misc | None = ...) -> Literal["normal", "bold"]: ... @overload - def actual(self, option: Literal["slant"], displayof: Optional[tkinter.Misc] = ...) -> Literal["roman", "italic"]: ... + def actual(self, option: Literal["slant"], displayof: tkinter.Misc | None = ...) -> Literal["roman", "italic"]: ... @overload - def actual(self, option: Literal["underline", "overstrike"], displayof: Optional[tkinter.Misc] = ...) -> bool: ... + def actual(self, option: Literal["underline", "overstrike"], displayof: tkinter.Misc | None = ...) -> bool: ... @overload - def actual(self, option: None, displayof: Optional[tkinter.Misc] = ...) -> _FontDict: ... + def actual(self, option: None, displayof: tkinter.Misc | None = ...) -> _FontDict: ... @overload - def actual(self, *, displayof: Optional[tkinter.Misc] = ...) -> _FontDict: ... + def actual(self, *, displayof: tkinter.Misc | None = ...) -> _FontDict: ... def config( self, *, @@ -81,22 +81,22 @@ class Font: slant: Literal["roman", "italic"] = ..., underline: bool = ..., overstrike: bool = ..., - ) -> Optional[_FontDict]: ... + ) -> _FontDict | None: ... configure = config def copy(self) -> Font: ... @overload - def metrics(self, __option: Literal["ascent", "descent", "linespace"], *, displayof: Optional[tkinter.Misc] = ...) -> int: ... + def metrics(self, __option: Literal["ascent", "descent", "linespace"], *, displayof: tkinter.Misc | None = ...) -> int: ... @overload - def metrics(self, __option: Literal["fixed"], *, displayof: Optional[tkinter.Misc] = ...) -> bool: ... + def metrics(self, __option: Literal["fixed"], *, displayof: tkinter.Misc | None = ...) -> bool: ... @overload - def metrics(self, *, displayof: Optional[tkinter.Misc] = ...) -> _MetricsDict: ... - def measure(self, text: str, displayof: Optional[tkinter.Misc] = ...) -> int: ... + def metrics(self, *, displayof: tkinter.Misc | None = ...) -> _MetricsDict: ... + def measure(self, text: str, displayof: tkinter.Misc | None = ...) -> int: ... -def families(root: Optional[tkinter.Misc] = ..., displayof: Optional[tkinter.Misc] = ...) -> Tuple[str, ...]: ... -def names(root: Optional[tkinter.Misc] = ...) -> Tuple[str, ...]: ... +def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> Tuple[str, ...]: ... +def names(root: tkinter.Misc | None = ...) -> Tuple[str, ...]: ... if sys.version_info >= (3, 10): - def nametofont(name: str, root: Optional[tkinter.Misc] = ...) -> Font: ... + def nametofont(name: str, root: tkinter.Misc | None = ...) -> Font: ... else: def nametofont(name: str) -> Font: ... diff --git a/stdlib/tkinter/messagebox.pyi b/stdlib/tkinter/messagebox.pyi index b291a45e87c9..bcc3e9dae69f 100644 --- a/stdlib/tkinter/messagebox.pyi +++ b/stdlib/tkinter/messagebox.pyi @@ -21,11 +21,11 @@ NO: str class Message(Dialog): command: ClassVar[str] = ... -def showinfo(title: Optional[str] = ..., message: Optional[str] = ..., **options: Any) -> str: ... -def showwarning(title: Optional[str] = ..., message: Optional[str] = ..., **options: Any) -> str: ... -def showerror(title: Optional[str] = ..., message: Optional[str] = ..., **options: Any) -> str: ... -def askquestion(title: Optional[str] = ..., message: Optional[str] = ..., **options: Any) -> str: ... -def askokcancel(title: Optional[str] = ..., message: Optional[str] = ..., **options: Any) -> bool: ... -def askyesno(title: Optional[str] = ..., message: Optional[str] = ..., **options: Any) -> bool: ... -def askyesnocancel(title: Optional[str] = ..., message: Optional[str] = ..., **options: Any) -> Optional[bool]: ... -def askretrycancel(title: Optional[str] = ..., message: Optional[str] = ..., **options: Any) -> bool: ... +def showinfo(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ... +def showwarning(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ... +def showerror(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ... +def askquestion(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ... +def askokcancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ... +def askyesno(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ... +def askyesnocancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool | None: ... +def askretrycancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ... diff --git a/stdlib/tkinter/scrolledtext.pyi b/stdlib/tkinter/scrolledtext.pyi index b82863d88947..83632fd12fe6 100644 --- a/stdlib/tkinter/scrolledtext.pyi +++ b/stdlib/tkinter/scrolledtext.pyi @@ -5,4 +5,4 @@ from typing import Any, Optional class ScrolledText(Text): frame: Frame vbar: Scrollbar - def __init__(self, master: Optional[Misc] = ..., **kwargs: Any) -> None: ... + def __init__(self, master: Misc | None = ..., **kwargs: Any) -> None: ... diff --git a/stdlib/tkinter/simpledialog.pyi b/stdlib/tkinter/simpledialog.pyi index b29bb7bfc153..a4cd2ba42ebb 100644 --- a/stdlib/tkinter/simpledialog.pyi +++ b/stdlib/tkinter/simpledialog.pyi @@ -2,26 +2,26 @@ from tkinter import Event, Misc, Toplevel from typing import Any, List, Optional class Dialog(Toplevel): - def __init__(self, parent: Optional[Misc], title: Optional[str] = ...) -> None: ... + def __init__(self, parent: Misc | None, title: str | None = ...) -> None: ... def body(self, master) -> None: ... def buttonbox(self): ... class SimpleDialog: def __init__( self, - master: Optional[Misc], + master: Misc | None, text: str = ..., buttons: List[str] = ..., - default: Optional[int] = ..., - cancel: Optional[int] = ..., - title: Optional[str] = ..., - class_: Optional[str] = ..., + default: int | None = ..., + cancel: int | None = ..., + title: str | None = ..., + class_: str | None = ..., ) -> None: ... - def go(self) -> Optional[int]: ... + def go(self) -> int | None: ... def return_event(self, event: Event[Misc]) -> None: ... def wm_delete_window(self) -> None: ... def done(self, num: int) -> None: ... -def askfloat(title: Optional[str], prompt: str, **kwargs: Any) -> float: ... -def askinteger(title: Optional[str], prompt: str, **kwargs: Any) -> int: ... -def askstring(title: Optional[str], prompt: str, **kwargs: Any) -> str: ... +def askfloat(title: str | None, prompt: str, **kwargs: Any) -> float: ... +def askinteger(title: str | None, prompt: str, **kwargs: Any) -> int: ... +def askstring(title: str | None, prompt: str, **kwargs: Any) -> str: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 78493900f119..d5d8e987a07f 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -37,22 +37,22 @@ TCL_ALL_EVENTS: Literal[0] class tixCommand: def tix_addbitmapdir(self, directory: str) -> None: ... def tix_cget(self, option: str) -> Any: ... - def tix_configure(self, cnf: Optional[Dict[str, Any]] = ..., **kw: Any) -> Any: ... - def tix_filedialog(self, dlgclass: Optional[str] = ...) -> str: ... + def tix_configure(self, cnf: Dict[str, Any] | None = ..., **kw: Any) -> Any: ... + def tix_filedialog(self, dlgclass: str | None = ...) -> str: ... def tix_getbitmap(self, name: str) -> str: ... def tix_getimage(self, name: str) -> str: ... def tix_option_get(self, name: str) -> Any: ... - def tix_resetoptions(self, newScheme: str, newFontSet: str, newScmPrio: Optional[str] = ...) -> None: ... + def tix_resetoptions(self, newScheme: str, newFontSet: str, newScmPrio: str | None = ...) -> None: ... class Tk(tkinter.Tk, tixCommand): - def __init__(self, screenName: Optional[str] = ..., baseName: Optional[str] = ..., className: str = ...): ... + def __init__(self, screenName: str | None = ..., baseName: str | None = ..., className: str = ...): ... class TixWidget(tkinter.Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., - widgetName: Optional[str] = ..., - static_options: Optional[List[str]] = ..., + master: tkinter.Misc | None = ..., + widgetName: str | None = ..., + static_options: List[str] | None = ..., cnf: Dict[str, Any] = ..., kw: Dict[str, Any] = ..., ) -> None: ... @@ -62,7 +62,7 @@ class TixWidget(tkinter.Widget): def subwidgets_all(self) -> List[tkinter.Widget]: ... def config_all(self, option: Any, value: Any) -> None: ... def image_create( - self, imgtype: str, cnf: Dict[str, Any] = ..., master: Optional[tkinter.Widget] = ..., **kw: Any + self, imgtype: str, cnf: Dict[str, Any] = ..., master: tkinter.Widget | None = ..., **kw: Any ) -> None: ... def image_delete(self, imgname: str) -> None: ... @@ -73,7 +73,7 @@ class TixSubWidget(TixWidget): class DisplayStyle: def __init__( - self, itemtype: str, cnf: Dict[str, Any] = ..., *, master: Optional[tkinter.Widget] = ..., **kw: Any + self, itemtype: str, cnf: Dict[str, Any] = ..., *, master: tkinter.Widget | None = ..., **kw: Any ) -> None: ... def __getitem__(self, key: str) -> Any: ... def __setitem__(self, key: str, value: Any) -> None: ... @@ -81,39 +81,39 @@ class DisplayStyle: def config(self, cnf: Dict[str, Any] = ..., **kw: Any) -> Any: ... class Balloon(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def bind_widget(self, widget: tkinter.Widget, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def unbind_widget(self, widget: tkinter.Widget) -> None: ... class ButtonBox(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add(self, name: str, cnf: Dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... def invoke(self, name: str) -> None: ... class ComboBox(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add_history(self, str: str) -> None: ... def append_history(self, str: str) -> None: ... def insert(self, index: int, str: str) -> None: ... def pick(self, index: int) -> None: ... class Control(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def decrement(self) -> None: ... def increment(self) -> None: ... def invoke(self) -> None: ... class LabelEntry(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... class LabelFrame(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... class Meter(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... class OptionMenu(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add_command(self, name: str, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add_separator(self, name: str, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def delete(self, name: str) -> None: ... @@ -121,59 +121,59 @@ class OptionMenu(TixWidget): def enable(self, name: str) -> None: ... class PopupMenu(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def bind_widget(self, widget: tkinter.Widget) -> None: ... def unbind_widget(self, widget: tkinter.Widget) -> None: ... def post_widget(self, widget: tkinter.Widget, x: int, y: int) -> None: ... class Select(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add(self, name: str, cnf: Dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... def invoke(self, name: str) -> None: ... class StdButtonBox(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def invoke(self, name: str) -> None: ... class DirList(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def chdir(self, dir: str) -> None: ... class DirTree(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def chdir(self, dir: str) -> None: ... class DirSelectDialog(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def popup(self) -> None: ... def popdown(self) -> None: ... class DirSelectBox(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... class ExFileSelectBox(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def filter(self) -> None: ... def invoke(self) -> None: ... class FileSelectBox(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def apply_filter(self) -> None: ... def invoke(self) -> None: ... class FileEntry(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def invoke(self) -> None: ... def file_dialog(self) -> None: ... class HList(TixWidget, tkinter.XView, tkinter.YView): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add(self, entry: str, cnf: Dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... - def add_child(self, parent: Optional[str] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... + def add_child(self, parent: str | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... def anchor_set(self, entry: str) -> None: ... def anchor_clear(self) -> None: ... # FIXME: Overload, certain combos return, others don't - def column_width(self, col: int = ..., width: Optional[int] = ..., chars: Optional[int] = ...) -> Optional[int]: ... + def column_width(self, col: int = ..., width: int | None = ..., chars: int | None = ...) -> int | None: ... def delete_all(self) -> None: ... def delete_entry(self, entry: str) -> None: ... def delete_offsprings(self, entry: str) -> None: ... @@ -183,7 +183,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def dropsite_set(self, index: int) -> None: ... def dropsite_clear(self) -> None: ... def header_create(self, col: int, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... - def header_configure(self, col: int, cnf: Dict[str, Any] = ..., **kw: Any) -> Optional[Any]: ... + def header_configure(self, col: int, cnf: Dict[str, Any] = ..., **kw: Any) -> Any | None: ... def header_cget(self, col: int, opt: Any) -> Any: ... def header_exists(self, col: int) -> bool: ... def header_exist(self, col: int) -> bool: ... @@ -191,14 +191,14 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def header_size(self, col: int) -> int: ... def hide_entry(self, entry: str) -> None: ... def indicator_create(self, entry: str, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... - def indicator_configure(self, entry: str, cnf: Dict[str, Any] = ..., **kw: Any) -> Optional[Any]: ... + def indicator_configure(self, entry: str, cnf: Dict[str, Any] = ..., **kw: Any) -> Any | None: ... def indicator_cget(self, entry: str, opt: Any) -> Any: ... def indicator_exists(self, entry: str) -> bool: ... def indicator_delete(self, entry: str) -> None: ... def indicator_size(self, entry: str) -> int: ... def info_anchor(self) -> str: ... def info_bbox(self, entry: str) -> Tuple[int, int, int, int]: ... - def info_children(self, entry: Optional[str] = ...) -> Tuple[str, ...]: ... + def info_children(self, entry: str | None = ...) -> Tuple[str, ...]: ... def info_data(self, entry: str) -> Any: ... def info_dragsite(self) -> str: ... def info_dropsite(self) -> str: ... @@ -209,21 +209,21 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def info_prev(self, entry: str) -> str: ... def info_selection(self) -> Tuple[str, ...]: ... def item_cget(self, entry: str, col: int, opt: Any) -> Any: ... - def item_configure(self, entry: str, col: int, cnf: Dict[str, Any] = ..., **kw: Any) -> Optional[Any]: ... + def item_configure(self, entry: str, col: int, cnf: Dict[str, Any] = ..., **kw: Any) -> Any | None: ... def item_create(self, entry: str, col: int, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def item_exists(self, entry: str, col: int) -> bool: ... def item_delete(self, entry: str, col: int) -> None: ... def entrycget(self, entry: str, opt: Any) -> Any: ... - def entryconfigure(self, entry: str, cnf: Dict[str, Any] = ..., **kw: Any) -> Optional[Any]: ... + def entryconfigure(self, entry: str, cnf: Dict[str, Any] = ..., **kw: Any) -> Any | None: ... def nearest(self, y: int) -> str: ... def see(self, entry: str) -> None: ... def selection_clear(self, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def selection_includes(self, entry: str) -> bool: ... - def selection_set(self, first: str, last: Optional[str] = ...) -> None: ... + def selection_set(self, first: str, last: str | None = ...) -> None: ... def show_entry(self, entry: str) -> None: ... class CheckList(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def autosetmode(self) -> None: ... def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... @@ -233,7 +233,7 @@ class CheckList(TixWidget): def setstatus(self, entrypath: str, mode: str = ...) -> None: ... class Tree(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def autosetmode(self) -> None: ... def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... @@ -241,12 +241,12 @@ class Tree(TixWidget): def setmode(self, entrypath: str, mode: str = ...) -> None: ... class TList(TixWidget, tkinter.XView, tkinter.YView): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def active_set(self, index: int) -> None: ... def active_clear(self) -> None: ... def anchor_set(self, index: int) -> None: ... def anchor_clear(self) -> None: ... - def delete(self, from_: int, to: Optional[int] = ...) -> None: ... + def delete(self, from_: int, to: int | None = ...) -> None: ... def dragsite_set(self, index: int) -> None: ... def dragsite_clear(self) -> None: ... def dropsite_set(self, index: int) -> None: ... @@ -264,26 +264,26 @@ class TList(TixWidget, tkinter.XView, tkinter.YView): def see(self, index: int) -> None: ... def selection_clear(self, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def selection_includes(self, index: int) -> bool: ... - def selection_set(self, first: int, last: Optional[int] = ...) -> None: ... + def selection_set(self, first: int, last: int | None = ...) -> None: ... class PanedWindow(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add(self, name: str, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def delete(self, name: str) -> None: ... def forget(self, name: str) -> None: ... # type: ignore def panecget(self, entry: str, opt: Any) -> Any: ... - def paneconfigure(self, entry: str, cnf: Dict[str, Any] = ..., **kw: Any) -> Optional[Any]: ... + def paneconfigure(self, entry: str, cnf: Dict[str, Any] = ..., **kw: Any) -> Any | None: ... def panes(self) -> List[tkinter.Widget]: ... class ListNoteBook(TixWidget): - def __init__(self, master: Optional[tkinter.Widget], cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add(self, name: str, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def page(self, name: str) -> tkinter.Widget: ... def pages(self) -> List[tkinter.Widget]: ... def raise_page(self, name: str) -> None: ... class NoteBook(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def add(self, name: str, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def delete(self, name: str) -> None: ... def page(self, name: str) -> tkinter.Widget: ... @@ -292,7 +292,7 @@ class NoteBook(TixWidget): def raised(self) -> bool: ... class InputOnly(TixWidget): - def __init__(self, master: Optional[tkinter.Widget] = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... class Form: def __setitem__(self, key: str, value: Any) -> None: ... @@ -300,6 +300,6 @@ class Form: def form(self, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def check(self) -> bool: ... def forget(self) -> None: ... - def grid(self, xsize: int = ..., ysize: int = ...) -> Optional[Tuple[int, int]]: ... - def info(self, option: Optional[str] = ...) -> Any: ... + def grid(self, xsize: int = ..., ysize: int = ...) -> Tuple[int, int] | None: ... + def info(self, option: str | None = ...) -> Any: ... def slaves(self) -> List[tkinter.Widget]: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 755b2f96ff7d..c4aca1e145cd 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -6,7 +6,7 @@ from typing import Any, Callable, Dict, Optional, Tuple, Union, overload from typing_extensions import Literal, TypedDict def tclobjs_to_py(adict): ... -def setup_master(master: Optional[Any] = ...): ... +def setup_master(master: Any | None = ...): ... # from ttk_widget (aka ttk::widget) manual page, differs from tkinter._Compound _TtkCompound = Literal["text", "image", tkinter._Compound] @@ -14,29 +14,29 @@ _TtkCompound = Literal["text", "image", tkinter._Compound] class Style: master: Any tk: _tkinter.TkappType - def __init__(self, master: Optional[Any] = ...): ... - def configure(self, style, query_opt: Optional[Any] = ..., **kw): ... - def map(self, style, query_opt: Optional[Any] = ..., **kw): ... - def lookup(self, style, option, state: Optional[Any] = ..., default: Optional[Any] = ...): ... - def layout(self, style, layoutspec: Optional[Any] = ...): ... + def __init__(self, master: Any | None = ...): ... + def configure(self, style, query_opt: Any | None = ..., **kw): ... + def map(self, style, query_opt: Any | None = ..., **kw): ... + def lookup(self, style, option, state: Any | None = ..., default: Any | None = ...): ... + def layout(self, style, layoutspec: Any | None = ...): ... def element_create(self, elementname, etype, *args, **kw): ... def element_names(self): ... def element_options(self, elementname): ... - def theme_create(self, themename, parent: Optional[Any] = ..., settings: Optional[Any] = ...): ... + def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...): ... def theme_settings(self, themename, settings): ... def theme_names(self): ... - def theme_use(self, themename: Optional[Any] = ...): ... + def theme_use(self, themename: Any | None = ...): ... class Widget(tkinter.Widget): - def __init__(self, master: Optional[tkinter.Misc], widgetname, kw: Optional[Any] = ...): ... + def __init__(self, master: tkinter.Misc | None, widgetname, kw: Any | None = ...): ... def identify(self, x, y): ... - def instate(self, statespec, callback: Optional[Any] = ..., *args, **kw): ... - def state(self, statespec: Optional[Any] = ...): ... + def instate(self, statespec, callback: Any | None = ..., *args, **kw): ... + def state(self, statespec: Any | None = ...): ... class Button(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., command: tkinter._ButtonCommand = ..., @@ -49,15 +49,15 @@ class Button(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., @@ -68,11 +68,11 @@ class Button(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + width: int | Literal[""] = ..., + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -81,7 +81,7 @@ class Button(Widget): class Checkbutton(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., command: tkinter._ButtonCommand = ..., @@ -95,19 +95,19 @@ class Checkbutton(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., # Seems like variable can be empty string, but actually setting it to # empty string segfaults before Tcl 8.6.9. Search for ttk::checkbutton # here: https://sourceforge.net/projects/tcl/files/Tcl/8.6.9/tcltk-release-notes-8.6.9.txt/view variable: tkinter.Variable = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., @@ -119,12 +119,12 @@ class Checkbutton(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., variable: tkinter.Variable = ..., - width: Union[int, Literal[""]] = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + width: int | Literal[""] = ..., + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -133,8 +133,8 @@ class Checkbutton(Widget): class Entry(Widget, tkinter.Entry): def __init__( self, - master: Optional[tkinter.Misc] = ..., - widget: Optional[str] = ..., + master: tkinter.Misc | None = ..., + widget: str | None = ..., *, background: tkinter._Color = ..., # undocumented class_: str = ..., @@ -158,7 +158,7 @@ class Entry(Widget, tkinter.Entry): @overload # type: ignore def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: tkinter._Color = ..., cursor: tkinter._Cursor = ..., @@ -176,14 +176,14 @@ class Entry(Widget, tkinter.Entry): validatecommand: tkinter._EntryValidateCommand = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Entry().config is mypy error (don't know why) @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: tkinter._Color = ..., cursor: tkinter._Cursor = ..., @@ -201,7 +201,7 @@ class Entry(Widget, tkinter.Entry): validatecommand: tkinter._EntryValidateCommand = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... def bbox(self, index): ... @@ -211,7 +211,7 @@ class Entry(Widget, tkinter.Entry): class Combobox(Entry): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, background: tkinter._Color = ..., # undocumented class_: str = ..., @@ -223,7 +223,7 @@ class Combobox(Entry): invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented justify: Literal["left", "center", "right"] = ..., name: str = ..., - postcommand: Union[Callable[[], Any], str] = ..., + postcommand: Callable[[], Any] | str = ..., show: Any = ..., # undocumented state: str = ..., style: str = ..., @@ -238,7 +238,7 @@ class Combobox(Entry): @overload # type: ignore def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: tkinter._Color = ..., cursor: tkinter._Cursor = ..., @@ -248,7 +248,7 @@ class Combobox(Entry): height: int = ..., invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., - postcommand: Union[Callable[[], Any], str] = ..., + postcommand: Callable[[], Any] | str = ..., show: Any = ..., state: str = ..., style: str = ..., @@ -259,14 +259,14 @@ class Combobox(Entry): values: tkinter._TkinterSequence[str] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Combobox().config is mypy error (don't know why) @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: tkinter._Color = ..., cursor: tkinter._Cursor = ..., @@ -276,7 +276,7 @@ class Combobox(Entry): height: int = ..., invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., - postcommand: Union[Callable[[], Any], str] = ..., + postcommand: Callable[[], Any] | str = ..., show: Any = ..., state: str = ..., style: str = ..., @@ -287,16 +287,16 @@ class Combobox(Entry): values: tkinter._TkinterSequence[str] = ..., width: int = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... - def current(self, newindex: Optional[Any] = ...): ... + def current(self, newindex: Any | None = ...): ... def set(self, value): ... class Frame(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, border: tkinter._ScreenUnits = ..., borderwidth: tkinter._ScreenUnits = ..., @@ -313,7 +313,7 @@ class Frame(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, border: tkinter._ScreenUnits = ..., borderwidth: tkinter._ScreenUnits = ..., @@ -324,7 +324,7 @@ class Frame(Widget): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., width: tkinter._ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -332,7 +332,7 @@ class Frame(Widget): class Label(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, anchor: tkinter._Anchor = ..., background: tkinter._Color = ..., @@ -351,16 +351,16 @@ class Label(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., wraplength: tkinter._ScreenUnits = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, anchor: tkinter._Anchor = ..., background: tkinter._Color = ..., @@ -377,12 +377,12 @@ class Label(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., wraplength: tkinter._ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -390,7 +390,7 @@ class Label(Widget): class Labelframe(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, border: tkinter._ScreenUnits = ..., borderwidth: tkinter._ScreenUnits = ..., # undocumented @@ -404,14 +404,14 @@ class Labelframe(Widget): relief: tkinter._Relief = ..., # undocumented style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., underline: int = ..., width: tkinter._ScreenUnits = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, border: tkinter._ScreenUnits = ..., borderwidth: tkinter._ScreenUnits = ..., @@ -423,10 +423,10 @@ class Labelframe(Widget): relief: tkinter._Relief = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., underline: int = ..., width: tkinter._ScreenUnits = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -436,7 +436,7 @@ LabelFrame = Labelframe class Menubutton(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., compound: _TtkCompound = ..., @@ -449,15 +449,15 @@ class Menubutton(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, compound: _TtkCompound = ..., cursor: tkinter._Cursor = ..., @@ -468,11 +468,11 @@ class Menubutton(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + width: int | Literal[""] = ..., + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -480,7 +480,7 @@ class Menubutton(Widget): class Notebook(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., cursor: tkinter._Cursor = ..., @@ -494,7 +494,7 @@ class Notebook(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., height: int = ..., @@ -502,7 +502,7 @@ class Notebook(Widget): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., width: int = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -512,15 +512,15 @@ class Notebook(Widget): def identify(self, x, y): ... def index(self, tab_id): ... def insert(self, pos, child, **kw): ... - def select(self, tab_id: Optional[Any] = ...): ... - def tab(self, tab_id, option: Optional[Any] = ..., **kw): ... + def select(self, tab_id: Any | None = ...): ... + def tab(self, tab_id, option: Any | None = ..., **kw): ... def tabs(self): ... def enable_traversal(self): ... class Panedwindow(Widget, tkinter.PanedWindow): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., cursor: tkinter._Cursor = ..., @@ -535,41 +535,41 @@ class Panedwindow(Widget, tkinter.PanedWindow): @overload # type: ignore def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., height: int = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., width: int = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Panedwindow().config is mypy error (don't know why) @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., height: int = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., width: int = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... forget: Any def insert(self, pos, child, **kw): ... - def pane(self, pane, option: Optional[Any] = ..., **kw): ... - def sashpos(self, index, newpos: Optional[Any] = ...): ... + def pane(self, pane, option: Any | None = ..., **kw): ... + def sashpos(self, index, newpos: Any | None = ...): ... PanedWindow = Panedwindow class Progressbar(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., cursor: tkinter._Cursor = ..., @@ -582,12 +582,12 @@ class Progressbar(Widget): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., value: float = ..., - variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ..., + variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., length: tkinter._ScreenUnits = ..., @@ -598,19 +598,19 @@ class Progressbar(Widget): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., value: float = ..., - variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + variable: tkinter.IntVar | tkinter.DoubleVar = ..., + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def start(self, interval: Optional[Any] = ...): ... - def step(self, amount: Optional[Any] = ...): ... + def start(self, interval: Any | None = ...): ... + def step(self, amount: Any | None = ...): ... def stop(self): ... class Radiobutton(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., command: tkinter._ButtonCommand = ..., @@ -622,17 +622,17 @@ class Radiobutton(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., value: Any = ..., - variable: Union[tkinter.Variable, Literal[""]] = ..., - width: Union[int, Literal[""]] = ..., + variable: tkinter.Variable | Literal[""] = ..., + width: int | Literal[""] = ..., ) -> None: ... @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., @@ -642,13 +642,13 @@ class Radiobutton(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., value: Any = ..., - variable: Union[tkinter.Variable, Literal[""]] = ..., - width: Union[int, Literal[""]] = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + variable: tkinter.Variable | Literal[""] = ..., + width: int | Literal[""] = ..., + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -657,10 +657,10 @@ class Radiobutton(Widget): class Scale(Widget, tkinter.Scale): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., - command: Union[str, Callable[[str], Any]] = ..., + command: str | Callable[[str], Any] = ..., cursor: tkinter._Cursor = ..., from_: float = ..., length: tkinter._ScreenUnits = ..., @@ -671,14 +671,14 @@ class Scale(Widget, tkinter.Scale): takefocus: tkinter._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ..., + variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> None: ... @overload # type: ignore def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, - command: Union[str, Callable[[str], Any]] = ..., + command: str | Callable[[str], Any] = ..., cursor: tkinter._Cursor = ..., from_: float = ..., length: tkinter._ScreenUnits = ..., @@ -688,17 +688,17 @@ class Scale(Widget, tkinter.Scale): takefocus: tkinter._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + variable: tkinter.IntVar | tkinter.DoubleVar = ..., + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Scale().config is mypy error (don't know why) @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, - command: Union[str, Callable[[str], Any]] = ..., + command: str | Callable[[str], Any] = ..., cursor: tkinter._Cursor = ..., from_: float = ..., length: tkinter._ScreenUnits = ..., @@ -708,19 +708,19 @@ class Scale(Widget, tkinter.Scale): takefocus: tkinter._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + variable: tkinter.IntVar | tkinter.DoubleVar = ..., + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... - def get(self, x: Optional[Any] = ..., y: Optional[Any] = ...): ... + def get(self, x: Any | None = ..., y: Any | None = ...): ... class Scrollbar(Widget, tkinter.Scrollbar): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., - command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ..., + command: Callable[..., Tuple[float, float] | None] | str = ..., cursor: tkinter._Cursor = ..., name: str = ..., orient: Literal["horizontal", "vertical"] = ..., @@ -730,35 +730,35 @@ class Scrollbar(Widget, tkinter.Scrollbar): @overload # type: ignore def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, - command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ..., + command: Callable[..., Tuple[float, float] | None] | str = ..., cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Scrollbar().config is mypy error (don't know why) @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, - command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ..., + command: Callable[..., Tuple[float, float] | None] | str = ..., cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... class Separator(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., cursor: tkinter._Cursor = ..., @@ -770,13 +770,13 @@ class Separator(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -784,7 +784,7 @@ class Separator(Widget): class Sizegrip(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., cursor: tkinter._Cursor = ..., @@ -795,12 +795,12 @@ class Sizegrip(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -809,11 +809,11 @@ if sys.version_info >= (3, 7): class Spinbox(Entry): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, background: tkinter._Color = ..., # undocumented class_: str = ..., - command: Union[Callable[[], Any], str, tkinter._TkinterSequence[str]] = ..., + command: Callable[[], Any] | str | tkinter._TkinterSequence[str] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., # undocumented font: _FontDescription = ..., # undocumented @@ -840,10 +840,10 @@ if sys.version_info >= (3, 7): @overload # type: ignore def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: tkinter._Color = ..., - command: Union[Callable[[], Any], str, tkinter._TkinterSequence[str]] = ..., + command: Callable[[], Any] | str | tkinter._TkinterSequence[str] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., @@ -865,7 +865,7 @@ if sys.version_info >= (3, 7): width: int = ..., wrap: bool = ..., xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure # type: ignore @@ -904,12 +904,12 @@ _TreeviewColumnId = Union[int, str] # manual page: "COLUMN IDENTIFIERS" class Treeview(Widget, tkinter.XView, tkinter.YView): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., - columns: Union[str, tkinter._TkinterSequence[str]] = ..., + columns: str | tkinter._TkinterSequence[str] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: Union[str, tkinter._TkinterSequence[str], tkinter._TkinterSequence[int], Literal["#all"]] = ..., + displaycolumns: str | tkinter._TkinterSequence[str] | tkinter._TkinterSequence[int] | Literal["#all"] = ..., height: int = ..., name: str = ..., padding: tkinter._Padding = ..., @@ -918,7 +918,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): # # 'tree headings' is same as ['tree', 'headings'], and I wouldn't be # surprised if someone was using it. - show: Union[Literal["tree", "headings", "tree headings"], tkinter._TkinterSequence[str]] = ..., + show: Literal["tree", "headings", "tree headings"] | tkinter._TkinterSequence[str] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., @@ -927,20 +927,20 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, - columns: Union[str, tkinter._TkinterSequence[str]] = ..., + columns: str | tkinter._TkinterSequence[str] = ..., cursor: tkinter._Cursor = ..., - displaycolumns: Union[str, tkinter._TkinterSequence[str], tkinter._TkinterSequence[int], Literal["#all"]] = ..., + displaycolumns: str | tkinter._TkinterSequence[str] | tkinter._TkinterSequence[int] | Literal["#all"] = ..., height: int = ..., padding: tkinter._Padding = ..., selectmode: Literal["extended", "browse", "none"] = ..., - show: Union[Literal["tree", "headings", "tree headings"], tkinter._TkinterSequence[str]] = ..., + show: Literal["tree", "headings", "tree headings"] | tkinter._TkinterSequence[str] = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., xscrollcommand: tkinter._XYScrollCommand = ..., yscrollcommand: tkinter._XYScrollCommand = ..., - ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + ) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure @@ -1049,7 +1049,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): if sys.version_info >= (3, 8): def selection(self) -> Tuple[str, ...]: ... else: - def selection(self, selop: Optional[Any] = ..., items: Optional[Any] = ...) -> Tuple[str, ...]: ... + def selection(self, selop: Any | None = ..., items: Any | None = ...) -> Tuple[str, ...]: ... def selection_set(self, items: str | tkinter._TkinterSequence[str]) -> None: ... def selection_add(self, items: str | tkinter._TkinterSequence[str]) -> None: ... def selection_remove(self, items: str | tkinter._TkinterSequence[str]) -> None: ... @@ -1064,10 +1064,10 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): # Also, it's 'callback' instead of 'func' here. @overload def tag_bind( - self, tagname: str, sequence: Optional[str] = ..., callback: Optional[Callable[[tkinter.Event[Treeview]], Any]] = ... + self, tagname: str, sequence: str | None = ..., callback: Callable[[tkinter.Event[Treeview]], Any] | None = ... ) -> str: ... @overload - def tag_bind(self, tagname: str, sequence: Optional[str], callback: str) -> None: ... + def tag_bind(self, tagname: str, sequence: str | None, callback: str) -> None: ... @overload def tag_bind(self, tagname: str, *, callback: str) -> None: ... @overload @@ -1103,12 +1103,12 @@ class LabeledScale(Frame): # TODO: don't any-type **kw. That goes to Frame.__init__. def __init__( self, - master: Optional[tkinter.Misc] = ..., - variable: Optional[Union[tkinter.IntVar, tkinter.DoubleVar]] = ..., + master: tkinter.Misc | None = ..., + variable: tkinter.IntVar | tkinter.DoubleVar | None = ..., from_: float = ..., to: float = ..., *, - compound: Union[Literal["top"], Literal["bottom"]] = ..., + compound: Literal["top"] | Literal["bottom"] = ..., **kw: Any, ) -> None: ... # destroy is overrided, signature does not change @@ -1119,13 +1119,13 @@ class OptionMenu(Menubutton): self, master, variable, - default: Optional[str] = ..., + default: str | None = ..., *values: str, # rest of these are keyword-only because *args syntax used above style: str = ..., - direction: Union[Literal["above"], Literal["below"], Literal["left"], Literal["right"], Literal["flush"]] = ..., - command: Optional[Callable[[tkinter.StringVar], Any]] = ..., + direction: Literal["above"] | Literal["below"] | Literal["left"] | Literal["right"] | Literal["flush"] = ..., + command: Callable[[tkinter.StringVar], Any] | None = ..., ) -> None: ... # configure, config, cget, destroy are inherited from Menubutton # destroy and __setitem__ are overrided, signature does not change - def set_menu(self, default: Optional[Any] = ..., *values): ... + def set_menu(self, default: Any | None = ..., *values): ... diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index a6e6abae5037..f944cd240d1b 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -50,11 +50,11 @@ class Untokenizer: tokens: List[str] prev_row: int prev_col: int - encoding: Optional[str] + encoding: str | None def __init__(self) -> None: ... def add_whitespace(self, start: _Position) -> None: ... def untokenize(self, iterable: Iterable[_Token]) -> str: ... - def compat(self, token: Sequence[Union[int, str]], iterable: Iterable[_Token]) -> None: ... + def compat(self, token: Sequence[int | str], iterable: Iterable[_Token]) -> None: ... # the docstring says "returns bytes" but is incorrect -- # if the ENCODING token is missing, it skips the encode @@ -62,7 +62,7 @@ def untokenize(iterable: Iterable[_Token]) -> Any: ... def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ... def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... # undocumented -def open(filename: Union[StrOrBytesPath, int]) -> TextIO: ... +def open(filename: StrOrBytesPath | int) -> TextIO: ... def group(*choices: str) -> str: ... # undocumented def any(*choices: str) -> str: ... # undocumented def maybe(*choices: str) -> str: ... # undocumented diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index dc8e8751fee2..6de05c0fd3d2 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -10,16 +10,16 @@ _fileModuleFunction = Tuple[str, Optional[str], str] class CoverageResults: def __init__( self, - counts: Optional[Dict[Tuple[str, int], int]] = ..., - calledfuncs: Optional[Dict[_fileModuleFunction, int]] = ..., - infile: Optional[StrPath] = ..., - callers: Optional[Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int]] = ..., - outfile: Optional[StrPath] = ..., + counts: Dict[Tuple[str, int], int] | None = ..., + calledfuncs: Dict[_fileModuleFunction, int] | None = ..., + infile: StrPath | None = ..., + callers: Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int] | None = ..., + outfile: StrPath | None = ..., ) -> None: ... # undocumented def update(self, other: CoverageResults) -> None: ... - def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: Optional[StrPath] = ...) -> None: ... + def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: StrPath | None = ...) -> None: ... def write_results_file( - self, path: StrPath, lines: Sequence[str], lnotab: Any, lines_hit: Mapping[int, int], encoding: Optional[str] = ... + self, path: StrPath, lines: Sequence[str], lnotab: Any, lines_hit: Mapping[int, int], encoding: str | None = ... ) -> Tuple[int, int]: ... def is_ignored_filename(self, filename: str) -> bool: ... # undocumented @@ -32,16 +32,16 @@ class Trace: countcallers: int = ..., ignoremods: Sequence[str] = ..., ignoredirs: Sequence[str] = ..., - infile: Optional[StrPath] = ..., - outfile: Optional[StrPath] = ..., + infile: StrPath | None = ..., + outfile: StrPath | None = ..., timing: bool = ..., ) -> None: ... - def run(self, cmd: Union[str, types.CodeType]) -> None: ... + def run(self, cmd: str | types.CodeType) -> None: ... def runctx( self, - cmd: Union[str, types.CodeType], - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + cmd: str | types.CodeType, + globals: Mapping[str, Any] | None = ..., + locals: Mapping[str, Any] | None = ..., ) -> None: ... if sys.version_info >= (3, 9): def runfunc(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index dca5f480c3ba..6df54e1b5485 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -5,68 +5,68 @@ from typing import IO, Any, Dict, Generator, Iterable, Iterator, List, Mapping, _PT = Tuple[str, int, str, Optional[str]] -def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | None = ...) -> None: ... if sys.version_info >= (3, 10): def print_exception( - __exc: Optional[Type[BaseException]], - value: Optional[BaseException] = ..., - tb: Optional[TracebackType] = ..., - limit: Optional[int] = ..., - file: Optional[IO[str]] = ..., + __exc: Type[BaseException] | None, + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = ..., + file: IO[str] | None = ..., chain: bool = ..., ) -> None: ... else: def print_exception( - etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., - file: Optional[IO[str]] = ..., + etype: Type[BaseException] | None, + value: BaseException | None, + tb: TracebackType | None, + limit: int | None = ..., + file: IO[str] | None = ..., chain: bool = ..., ) -> None: ... -def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... -def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... -def print_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> StackSummary: ... -def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> StackSummary: ... +def print_exc(limit: int | None = ..., file: IO[str] | None = ..., chain: bool = ...) -> None: ... +def print_last(limit: int | None = ..., file: IO[str] | None = ..., chain: bool = ...) -> None: ... +def print_stack(f: FrameType | None = ..., limit: int | None = ..., file: IO[str] | None = ...) -> None: ... +def extract_tb(tb: TracebackType | None, limit: int | None = ...) -> StackSummary: ... +def extract_stack(f: FrameType | None = ..., limit: int | None = ...) -> StackSummary: ... def format_list(extracted_list: List[FrameSummary]) -> List[str]: ... # undocumented -def print_list(extracted_list: List[FrameSummary], file: Optional[SupportsWrite[str]] = ...) -> None: ... +def print_list(extracted_list: List[FrameSummary], file: SupportsWrite[str] | None = ...) -> None: ... if sys.version_info >= (3, 10): - def format_exception_only(__exc: Optional[Type[BaseException]], value: Optional[BaseException] = ...) -> List[str]: ... + def format_exception_only(__exc: Type[BaseException] | None, value: BaseException | None = ...) -> List[str]: ... else: - def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... + def format_exception_only(etype: Type[BaseException] | None, value: BaseException | None) -> List[str]: ... if sys.version_info >= (3, 10): def format_exception( - __exc: Optional[Type[BaseException]], - value: Optional[BaseException] = ..., - tb: Optional[TracebackType] = ..., - limit: Optional[int] = ..., + __exc: Type[BaseException] | None, + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = ..., chain: bool = ..., ) -> List[str]: ... else: def format_exception( - etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., + etype: Type[BaseException] | None, + value: BaseException | None, + tb: TracebackType | None, + limit: int | None = ..., chain: bool = ..., ) -> List[str]: ... -def format_exc(limit: Optional[int] = ..., chain: bool = ...) -> str: ... -def format_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[str]: ... -def format_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[str]: ... +def format_exc(limit: int | None = ..., chain: bool = ...) -> str: ... +def format_tb(tb: TracebackType | None, limit: int | None = ...) -> List[str]: ... +def format_stack(f: FrameType | None = ..., limit: int | None = ...) -> List[str]: ... def clear_frames(tb: TracebackType) -> None: ... -def walk_stack(f: Optional[FrameType]) -> Iterator[Tuple[FrameType, int]]: ... -def walk_tb(tb: Optional[TracebackType]) -> Iterator[Tuple[FrameType, int]]: ... +def walk_stack(f: FrameType | None) -> Iterator[Tuple[FrameType, int]]: ... +def walk_tb(tb: TracebackType | None) -> Iterator[Tuple[FrameType, int]]: ... class TracebackException: __cause__: TracebackException @@ -86,18 +86,18 @@ class TracebackException: exc_value: BaseException, exc_traceback: TracebackType, *, - limit: Optional[int] = ..., + limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ..., compact: bool = ..., - _seen: Optional[Set[int]] = ..., + _seen: Set[int] | None = ..., ) -> None: ... @classmethod def from_exception( cls, exc: BaseException, *, - limit: Optional[int] = ..., + limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ..., compact: bool = ..., @@ -109,14 +109,14 @@ class TracebackException: exc_value: BaseException, exc_traceback: TracebackType, *, - limit: Optional[int] = ..., + limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ..., - _seen: Optional[Set[int]] = ..., + _seen: Set[int] | None = ..., ) -> None: ... @classmethod def from_exception( - cls, exc: BaseException, *, limit: Optional[int] = ..., lookup_lines: bool = ..., capture_locals: bool = ... + cls, exc: BaseException, *, limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ... ) -> TracebackException: ... def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ... def format_exception_only(self) -> Generator[str, None, None]: ... @@ -126,7 +126,7 @@ class FrameSummary(Iterable[Any]): lineno: int name: str line: str - locals: Optional[Dict[str, str]] + locals: Dict[str, str] | None def __init__( self, filename: str, @@ -134,8 +134,8 @@ class FrameSummary(Iterable[Any]): name: str, *, lookup_line: bool = ..., - locals: Optional[Mapping[str, str]] = ..., - line: Optional[str] = ..., + locals: Mapping[str, str] | None = ..., + line: str | None = ..., ) -> None: ... # TODO: more precise typing for __getitem__ and __iter__, # for a namedtuple-like view on (filename, lineno, name, str). @@ -148,7 +148,7 @@ class StackSummary(List[FrameSummary]): cls, frame_gen: Generator[Tuple[FrameType, int], None, None], *, - limit: Optional[int] = ..., + limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ..., ) -> StackSummary: ... diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 593c4edaec65..08a694da5eb8 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -3,7 +3,7 @@ from typing import List, Optional, Sequence, Tuple, Union, overload from _tracemalloc import * -def get_object_traceback(obj: object) -> Optional[Traceback]: ... +def get_object_traceback(obj: object) -> Traceback | None: ... def take_snapshot() -> Snapshot: ... class DomainFilter: @@ -12,18 +12,18 @@ class DomainFilter: def __init__(self, inclusive: bool, domain: int) -> None: ... class Filter: - domain: Optional[int] + domain: int | None inclusive: bool - lineno: Optional[int] + lineno: int | None filename_pattern: str all_frames: bool def __init__( self, inclusive: bool, filename_pattern: str, - lineno: Optional[int] = ..., + lineno: int | None = ..., all_frames: bool = ..., - domain: Optional[int] = ..., + domain: int | None = ..., ) -> None: ... class Statistic: @@ -60,14 +60,14 @@ class Trace: class Traceback(Sequence[Frame]): if sys.version_info >= (3, 9): - total_nframe: Optional[int] - def __init__(self, frames: Sequence[_FrameTupleT], total_nframe: Optional[int] = ...) -> None: ... + total_nframe: int | None + def __init__(self, frames: Sequence[_FrameTupleT], total_nframe: int | None = ...) -> None: ... else: def __init__(self, frames: Sequence[_FrameTupleT]) -> None: ... if sys.version_info >= (3, 7): - def format(self, limit: Optional[int] = ..., most_recent_first: bool = ...) -> List[str]: ... + def format(self, limit: int | None = ..., most_recent_first: bool = ...) -> List[str]: ... else: - def format(self, limit: Optional[int] = ...) -> List[str]: ... + def format(self, limit: int | None = ...) -> List[str]: ... @overload def __getitem__(self, i: int) -> Frame: ... @overload @@ -78,7 +78,7 @@ class Snapshot: def __init__(self, traces: Sequence[_TraceTupleT], traceback_limit: int) -> None: ... def compare_to(self, old_snapshot: Snapshot, key_type: str, cumulative: bool = ...) -> List[StatisticDiff]: ... def dump(self, filename: str) -> None: ... - def filter_traces(self, filters: Sequence[Union[DomainFilter, Filter]]) -> Snapshot: ... + def filter_traces(self, filters: Sequence[DomainFilter | Filter]) -> Snapshot: ... @staticmethod def load(filename: str) -> Snapshot: ... def statistics(self, key_type: str, cumulative: bool = ...) -> List[Statistic]: ... diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index e04a96257d96..460118b34cfb 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -26,22 +26,22 @@ class TurtleScreenBase(object): yscale: float = ... def __init__(self, cv: Canvas) -> None: ... def mainloop(self) -> None: ... - def textinput(self, title: str, prompt: str) -> Optional[str]: ... + def textinput(self, title: str, prompt: str) -> str | None: ... def numinput( self, title: str, prompt: str, - default: Optional[float] = ..., - minval: Optional[float] = ..., - maxval: Optional[float] = ..., - ) -> Optional[float]: ... + default: float | None = ..., + minval: float | None = ..., + maxval: float | None = ..., + ) -> float | None: ... class Terminator(Exception): ... class TurtleGraphicsError(Exception): ... class Shape(object): - def __init__(self, type_: str, data: Union[_PolygonCoords, PhotoImage, None] = ...) -> None: ... - def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: Optional[_Color] = ...) -> None: ... + def __init__(self, type_: str, data: _PolygonCoords | PhotoImage | None = ...) -> None: ... + def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: _Color | None = ...) -> None: ... class TurtleScreen(TurtleScreenBase): def __init__(self, cv: Canvas, mode: str = ..., colormode: float = ..., delay: int = ...) -> None: ... @@ -51,7 +51,7 @@ class TurtleScreen(TurtleScreenBase): @overload def mode(self, mode: str) -> None: ... def setworldcoordinates(self, llx: float, lly: float, urx: float, ury: float) -> None: ... - def register_shape(self, name: str, shape: Union[_PolygonCoords, Shape, None] = ...) -> None: ... + def register_shape(self, name: str, shape: _PolygonCoords | Shape | None = ...) -> None: ... @overload def colormode(self, cmode: None = ...) -> float: ... @overload @@ -67,7 +67,7 @@ class TurtleScreen(TurtleScreenBase): @overload def tracer(self, n: None = ...) -> int: ... @overload - def tracer(self, n: int, delay: Optional[int] = ...) -> None: ... + def tracer(self, n: int, delay: int | None = ...) -> None: ... @overload def delay(self, delay: None = ...) -> int: ... @overload @@ -77,9 +77,9 @@ class TurtleScreen(TurtleScreenBase): def window_height(self) -> int: ... def getcanvas(self) -> Canvas: ... def getshapes(self) -> List[str]: ... - def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: Optional[Any] = ...) -> None: ... + def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... def onkey(self, fun: Callable[[], Any], key: str) -> None: ... - def listen(self, xdummy: Optional[float] = ..., ydummy: Optional[float] = ...) -> None: ... + def listen(self, xdummy: float | None = ..., ydummy: float | None = ...) -> None: ... def ontimer(self, fun: Callable[[], Any], t: int = ...) -> None: ... @overload def bgpic(self, picname: None = ...) -> str: ... @@ -89,12 +89,12 @@ class TurtleScreen(TurtleScreenBase): def screensize(self, canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> Tuple[int, int]: ... # Looks like if self.cv is not a ScrolledCanvas, this could return a tuple as well @overload - def screensize(self, canvwidth: int, canvheight: int, bg: Optional[_Color] = ...) -> None: ... + def screensize(self, canvwidth: int, canvheight: int, bg: _Color | None = ...) -> None: ... onscreenclick = onclick resetscreen = reset clearscreen = clear addshape = register_shape - def onkeypress(self, fun: Callable[[], Any], key: Optional[str] = ...) -> None: ... + def onkeypress(self, fun: Callable[[], Any], key: str | None = ...) -> None: ... onkeyrelease = onkey class TNavigator(object): @@ -121,16 +121,16 @@ class TNavigator(object): def setx(self, x: float) -> None: ... def sety(self, y: float) -> None: ... @overload - def distance(self, x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... + def distance(self, x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... @overload def distance(self, x: float, y: float) -> float: ... @overload - def towards(self, x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... + def towards(self, x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... @overload def towards(self, x: float, y: float) -> float: ... def heading(self) -> float: ... def setheading(self, to_angle: float) -> None: ... - def circle(self, radius: float, extent: Optional[float] = ..., steps: Optional[int] = ...) -> None: ... + def circle(self, radius: float, extent: float | None = ..., steps: int | None = ...) -> None: ... fd = forward bk = back backward = back @@ -187,7 +187,7 @@ class TPen(object): @overload def pen( self, - pen: Optional[_PenState] = ..., + pen: _PenState | None = ..., *, shown: bool = ..., pendown: bool = ..., @@ -212,10 +212,10 @@ _T = TypeVar("_T") class RawTurtle(TPen, TNavigator): def __init__( - self, canvas: Union[Canvas, TurtleScreen, None] = ..., shape: str = ..., undobuffersize: int = ..., visible: bool = ... + self, canvas: Canvas | TurtleScreen | None = ..., shape: str = ..., undobuffersize: int = ..., visible: bool = ... ) -> None: ... def reset(self) -> None: ... - def setundobuffer(self, size: Optional[int]) -> None: ... + def setundobuffer(self, size: int | None) -> None: ... def undobufferentries(self) -> int: ... def clear(self) -> None: ... def clone(self: _T) -> _T: ... @@ -228,7 +228,7 @@ class RawTurtle(TPen, TNavigator): def shapesize(self) -> Tuple[float, float, float]: ... # type: ignore @overload def shapesize( - self, stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ... + self, stretch_wid: float | None = ..., stretch_len: float | None = ..., outline: float | None = ... ) -> None: ... @overload def shearfactor(self, shear: None = ...) -> float: ... @@ -239,9 +239,9 @@ class RawTurtle(TPen, TNavigator): def shapetransform(self) -> Tuple[float, float, float, float]: ... # type: ignore @overload def shapetransform( - self, t11: Optional[float] = ..., t12: Optional[float] = ..., t21: Optional[float] = ..., t22: Optional[float] = ... + self, t11: float | None = ..., t12: float | None = ..., t21: float | None = ..., t22: float | None = ... ) -> None: ... - def get_shapepoly(self) -> Optional[_PolygonCoords]: ... + def get_shapepoly(self) -> _PolygonCoords | None: ... def settiltangle(self, angle: float) -> None: ... @overload def tiltangle(self, angle: None = ...) -> float: ... @@ -252,22 +252,22 @@ class RawTurtle(TPen, TNavigator): # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp(self) -> Any: ... - def clearstamp(self, stampid: Union[int, Tuple[int, ...]]) -> None: ... - def clearstamps(self, n: Optional[int] = ...) -> None: ... + def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... + def clearstamps(self, n: int | None = ...) -> None: ... def filling(self) -> bool: ... def begin_fill(self) -> None: ... def end_fill(self) -> None: ... - def dot(self, size: Optional[int] = ..., *color: _Color) -> None: ... + def dot(self, size: int | None = ..., *color: _Color) -> None: ... def write(self, arg: object, move: bool = ..., align: str = ..., font: Tuple[str, int, str] = ...) -> None: ... def begin_poly(self) -> None: ... def end_poly(self) -> None: ... - def get_poly(self) -> Optional[_PolygonCoords]: ... + def get_poly(self) -> _PolygonCoords | None: ... def getscreen(self) -> TurtleScreen: ... def getturtle(self: _T) -> _T: ... getpen = getturtle - def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: Optional[bool] = ...) -> None: ... - def onrelease(self, fun: Callable[[float, float], Any], btn: int = ..., add: Optional[bool] = ...) -> None: ... - def ondrag(self, fun: Callable[[float, float], Any], btn: int = ..., add: Optional[bool] = ...) -> None: ... + def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... + def onrelease(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... + def ondrag(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... def undo(self) -> None: ... turtlesize = shapesize @@ -276,10 +276,10 @@ class _Screen(TurtleScreen): # Note int and float are interpreted differently, hence the Union instead of just float def setup( self, - width: Union[int, float] = ..., - height: Union[int, float] = ..., - startx: Optional[int] = ..., - starty: Optional[int] = ..., + width: int | float = ..., + height: int | float = ..., + startx: int | None = ..., + starty: int | None = ..., ) -> None: ... def title(self, titlestring: str) -> None: ... def bye(self) -> None: ... @@ -307,10 +307,10 @@ def write_docstringdict(filename: str = ...) -> None: ... # Note: mainloop() was always present in the global scope, but was added to # TurtleScreenBase in Python 3.0 def mainloop() -> None: ... -def textinput(title: str, prompt: str) -> Optional[str]: ... +def textinput(title: str, prompt: str) -> str | None: ... def numinput( - title: str, prompt: str, default: Optional[float] = ..., minval: Optional[float] = ..., maxval: Optional[float] = ... -) -> Optional[float]: ... + title: str, prompt: str, default: float | None = ..., minval: float | None = ..., maxval: float | None = ... +) -> float | None: ... # Functions copied from TurtleScreen: @@ -320,7 +320,7 @@ def mode(mode: None = ...) -> str: ... @overload def mode(mode: str) -> None: ... def setworldcoordinates(llx: float, lly: float, urx: float, ury: float) -> None: ... -def register_shape(name: str, shape: Union[_PolygonCoords, Shape, None] = ...) -> None: ... +def register_shape(name: str, shape: _PolygonCoords | Shape | None = ...) -> None: ... @overload def colormode(cmode: None = ...) -> float: ... @overload @@ -336,7 +336,7 @@ def bgcolor(r: float, g: float, b: float) -> None: ... @overload def tracer(n: None = ...) -> int: ... @overload -def tracer(n: int, delay: Optional[int] = ...) -> None: ... +def tracer(n: int, delay: int | None = ...) -> None: ... @overload def delay(delay: None = ...) -> int: ... @overload @@ -346,9 +346,9 @@ def window_width() -> int: ... def window_height() -> int: ... def getcanvas() -> Canvas: ... def getshapes() -> List[str]: ... -def onclick(fun: Callable[[float, float], Any], btn: int = ..., add: Optional[Any] = ...) -> None: ... +def onclick(fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... def onkey(fun: Callable[[], Any], key: str) -> None: ... -def listen(xdummy: Optional[float] = ..., ydummy: Optional[float] = ...) -> None: ... +def listen(xdummy: float | None = ..., ydummy: float | None = ...) -> None: ... def ontimer(fun: Callable[[], Any], t: int = ...) -> None: ... @overload def bgpic(picname: None = ...) -> str: ... @@ -357,20 +357,20 @@ def bgpic(picname: str) -> None: ... @overload def screensize(canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> Tuple[int, int]: ... @overload -def screensize(canvwidth: int, canvheight: int, bg: Optional[_Color] = ...) -> None: ... +def screensize(canvwidth: int, canvheight: int, bg: _Color | None = ...) -> None: ... onscreenclick = onclick resetscreen = reset clearscreen = clear addshape = register_shape -def onkeypress(fun: Callable[[], Any], key: Optional[str] = ...) -> None: ... +def onkeypress(fun: Callable[[], Any], key: str | None = ...) -> None: ... onkeyrelease = onkey # Functions copied from _Screen: -def setup(width: float = ..., height: float = ..., startx: Optional[int] = ..., starty: Optional[int] = ...) -> None: ... +def setup(width: float = ..., height: float = ..., startx: int | None = ..., starty: int | None = ...) -> None: ... def title(titlestring: str) -> None: ... def bye() -> None: ... def exitonclick() -> None: ... @@ -395,16 +395,16 @@ def home() -> None: ... def setx(x: float) -> None: ... def sety(y: float) -> None: ... @overload -def distance(x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... +def distance(x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... @overload def distance(x: float, y: float) -> float: ... @overload -def towards(x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... +def towards(x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... @overload def towards(x: float, y: float) -> float: ... def heading() -> float: ... def setheading(to_angle: float) -> None: ... -def circle(radius: float, extent: Optional[float] = ..., steps: Optional[int] = ...) -> None: ... +def circle(radius: float, extent: float | None = ..., steps: int | None = ...) -> None: ... fd = forward bk = back @@ -461,7 +461,7 @@ def isvisible() -> bool: ... def pen() -> _PenState: ... # type: ignore @overload def pen( - pen: Optional[_PenState] = ..., + pen: _PenState | None = ..., *, shown: bool = ..., pendown: bool = ..., @@ -485,7 +485,7 @@ ht = hideturtle # Functions copied from RawTurtle: -def setundobuffer(size: Optional[int]) -> None: ... +def setundobuffer(size: int | None) -> None: ... def undobufferentries() -> int: ... @overload def shape(name: None = ...) -> str: ... @@ -496,7 +496,7 @@ def shape(name: str) -> None: ... @overload def shapesize() -> Tuple[float, float, float]: ... # type: ignore @overload -def shapesize(stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ...) -> None: ... +def shapesize(stretch_wid: float | None = ..., stretch_len: float | None = ..., outline: float | None = ...) -> None: ... @overload def shearfactor(shear: None = ...) -> float: ... @overload @@ -507,9 +507,9 @@ def shearfactor(shear: float) -> None: ... def shapetransform() -> Tuple[float, float, float, float]: ... # type: ignore @overload def shapetransform( - t11: Optional[float] = ..., t12: Optional[float] = ..., t21: Optional[float] = ..., t22: Optional[float] = ... + t11: float | None = ..., t12: float | None = ..., t21: float | None = ..., t22: float | None = ... ) -> None: ... -def get_shapepoly() -> Optional[_PolygonCoords]: ... +def get_shapepoly() -> _PolygonCoords | None: ... def settiltangle(angle: float) -> None: ... @overload def tiltangle(angle: None = ...) -> float: ... @@ -521,23 +521,23 @@ def tilt(angle: float) -> None: ... # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp() -> Any: ... -def clearstamp(stampid: Union[int, Tuple[int, ...]]) -> None: ... -def clearstamps(n: Optional[int] = ...) -> None: ... +def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... +def clearstamps(n: int | None = ...) -> None: ... def filling() -> bool: ... def begin_fill() -> None: ... def end_fill() -> None: ... -def dot(size: Optional[int] = ..., *color: _Color) -> None: ... +def dot(size: int | None = ..., *color: _Color) -> None: ... def write(arg: object, move: bool = ..., align: str = ..., font: Tuple[str, int, str] = ...) -> None: ... def begin_poly() -> None: ... def end_poly() -> None: ... -def get_poly() -> Optional[_PolygonCoords]: ... +def get_poly() -> _PolygonCoords | None: ... def getscreen() -> TurtleScreen: ... def getturtle() -> Turtle: ... getpen = getturtle -def onrelease(fun: Callable[[float, float], Any], btn: int = ..., add: Optional[Any] = ...) -> None: ... -def ondrag(fun: Callable[[float, float], Any], btn: int = ..., add: Optional[Any] = ...) -> None: ... +def onrelease(fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... +def ondrag(fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... def undo() -> None: ... turtlesize = shapesize diff --git a/stdlib/types.pyi b/stdlib/types.pyi index f55abd2209e9..878e57983327 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -174,31 +174,31 @@ class ModuleType: __name__: str __file__: str __dict__: Dict[str, Any] - __loader__: Optional[_LoaderProtocol] - __package__: Optional[str] - __spec__: Optional[ModuleSpec] - def __init__(self, name: str, doc: Optional[str] = ...) -> None: ... + __loader__: _LoaderProtocol | None + __package__: str | None + __spec__: ModuleSpec | None + def __init__(self, name: str, doc: str | None = ...) -> None: ... @final class GeneratorType(Generator[_T_co, _T_contra, _V_co]): gi_code: CodeType gi_frame: FrameType gi_running: bool - gi_yieldfrom: Optional[GeneratorType[_T_co, _T_contra, Any]] + gi_yieldfrom: GeneratorType[_T_co, _T_contra, Any] | None def __iter__(self) -> GeneratorType[_T_co, _T_contra, _V_co]: ... def __next__(self) -> _T_co: ... def close(self) -> None: ... def send(self, __arg: _T_contra) -> _T_co: ... @overload def throw( - self, __typ: Type[BaseException], __val: typing.Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: typing.BaseException | object = ..., __tb: TracebackType | None = ... ) -> _T_co: ... @overload - def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ... + def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... @final class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): - ag_await: Optional[Awaitable[Any]] + ag_await: Awaitable[Any] | None ag_frame: FrameType ag_running: bool ag_code: CodeType @@ -207,15 +207,15 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): def asend(self, __val: _T_contra) -> Awaitable[_T_co]: ... @overload def athrow( - self, __typ: Type[BaseException], __val: typing.Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: typing.BaseException | object = ..., __tb: TracebackType | None = ... ) -> Awaitable[_T_co]: ... @overload - def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ... + def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ... def aclose(self) -> Awaitable[None]: ... @final class CoroutineType: - cr_await: Optional[Any] + cr_await: Any | None cr_code: CodeType cr_frame: FrameType cr_running: bool @@ -223,10 +223,10 @@ class CoroutineType: def send(self, __arg: Any) -> Any: ... @overload def throw( - self, __typ: Type[BaseException], __val: typing.Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: typing.BaseException | object = ..., __tb: TracebackType | None = ... ) -> Any: ... @overload - def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Any: ... + def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Any: ... class _StaticFunctionType: """Fictional type to correct the type of MethodType.__func__. @@ -242,12 +242,12 @@ class _StaticFunctionType: being bound as a method. """ - def __get__(self, obj: Optional[object], type: Optional[type]) -> FunctionType: ... + def __get__(self, obj: object | None, type: type | None) -> FunctionType: ... @final class MethodType: - __closure__: Optional[Tuple[_Cell, ...]] # inherited from the added function - __defaults__: Optional[Tuple[Any, ...]] # inherited from the added function + __closure__: Tuple[_Cell, ...] | None # inherited from the added function + __defaults__: Tuple[Any, ...] | None # inherited from the added function __func__: _StaticFunctionType __self__: object __name__: str # inherited from the added function @@ -257,7 +257,7 @@ class MethodType: @final class BuiltinFunctionType: - __self__: typing.Union[object, ModuleType] + __self__: typing.object | ModuleType __name__: str __qualname__: str def __call__(self, *args: Any, **kwargs: Any) -> Any: ... @@ -299,11 +299,11 @@ if sys.version_info >= (3, 7): @final class TracebackType: if sys.version_info >= (3, 7): - def __init__(self, tb_next: Optional[TracebackType], tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ... - tb_next: Optional[TracebackType] + def __init__(self, tb_next: TracebackType | None, tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ... + tb_next: TracebackType | None else: @property - def tb_next(self) -> Optional[TracebackType]: ... + def tb_next(self) -> TracebackType | None: ... # the rest are read-only even in 3.7 @property def tb_frame(self) -> FrameType: ... @@ -314,14 +314,14 @@ class TracebackType: @final class FrameType: - f_back: Optional[FrameType] + f_back: FrameType | None f_builtins: Dict[str, Any] f_code: CodeType f_globals: Dict[str, Any] f_lasti: int f_lineno: int f_locals: Dict[str, Any] - f_trace: Optional[Callable[[FrameType, str, Any], Any]] + f_trace: Callable[[FrameType, str, Any], Any] | None if sys.version_info >= (3, 7): f_trace_lines: bool f_trace_opcodes: bool @@ -347,8 +347,8 @@ if sys.version_info >= (3, 7): def new_class( name: str, bases: Iterable[object] = ..., - kwds: Optional[Dict[str, Any]] = ..., - exec_body: Optional[Callable[[Dict[str, Any]], None]] = ..., + kwds: Dict[str, Any] | None = ..., + exec_body: Callable[[Dict[str, Any]], None] | None = ..., ) -> type: ... def resolve_bases(bases: Iterable[object]) -> Tuple[Any, ...]: ... @@ -356,12 +356,12 @@ else: def new_class( name: str, bases: Tuple[type, ...] = ..., - kwds: Optional[Dict[str, Any]] = ..., - exec_body: Optional[Callable[[Dict[str, Any]], None]] = ..., + kwds: Dict[str, Any] | None = ..., + exec_body: Callable[[Dict[str, Any]], None] | None = ..., ) -> type: ... def prepare_class( - name: str, bases: Tuple[type, ...] = ..., kwds: Optional[Dict[str, Any]] = ... + name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] | None = ... ) -> Tuple[type, Dict[str, Any], Dict[str, Any]]: ... # Actually a different type, but `property` is special and we want that too. diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index d93c7a8a1ad0..c54d582a5dc7 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -17,7 +17,7 @@ Any = object() class TypeVar: __name__: str - __bound__: Optional[Type[Any]] + __bound__: Type[Any] | None __constraints__: Tuple[Type[Any], ...] __covariant__: bool __contravariant__: bool @@ -25,7 +25,7 @@ class TypeVar: self, name: str, *constraints: Type[Any], - bound: Union[None, Type[Any], str] = ..., + bound: None | Type[Any] | str = ..., covariant: bool = ..., contravariant: bool = ..., ) -> None: ... @@ -67,11 +67,11 @@ if sys.version_info >= (3, 10): def __init__(self, origin: ParamSpec) -> None: ... class ParamSpec: __name__: str - __bound__: Optional[Type[Any]] + __bound__: Type[Any] | None __covariant__: bool __contravariant__: bool def __init__( - self, name: str, *, bound: Union[None, Type[Any], str] = ..., contravariant: bool = ..., covariant: bool = ... + self, name: str, *, bound: None | Type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ... ) -> None: ... @property def args(self) -> ParamSpecArgs: ... @@ -204,11 +204,11 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): @overload @abstractmethod def throw( - self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> _T_co: ... @overload @abstractmethod - def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ... + def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... def close(self) -> None: ... def __iter__(self) -> Generator[_T_co, _T_contra, _V_co]: ... @property @@ -218,7 +218,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): @property def gi_running(self) -> bool: ... @property - def gi_yieldfrom(self) -> Optional[Generator[Any, Any, Any]]: ... + def gi_yieldfrom(self) -> Generator[Any, Any, Any] | None: ... @runtime_checkable class Awaitable(Protocol[_T_co]): @@ -229,7 +229,7 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]): __name__: str __qualname__: str @property - def cr_await(self) -> Optional[Any]: ... + def cr_await(self) -> Any | None: ... @property def cr_code(self) -> CodeType: ... @property @@ -241,11 +241,11 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]): @overload @abstractmethod def throw( - self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> _T_co: ... @overload @abstractmethod - def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ... + def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... @abstractmethod def close(self) -> None: ... @@ -274,11 +274,11 @@ class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]): @overload @abstractmethod def athrow( - self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> Awaitable[_T_co]: ... @overload @abstractmethod - def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ... + def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ... @abstractmethod def aclose(self) -> Awaitable[None]: ... @abstractmethod @@ -358,9 +358,9 @@ class AbstractSet(_Collection[_T_co], Generic[_T_co]): def __gt__(self, s: AbstractSet[Any]) -> bool: ... def __ge__(self, s: AbstractSet[Any]) -> bool: ... def __and__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __or__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ... + def __or__(self, s: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ... def __sub__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ... + def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ... def isdisjoint(self, other: Iterable[Any]) -> bool: ... class MutableSet(AbstractSet[_T], Generic[_T]): @@ -372,9 +372,9 @@ class MutableSet(AbstractSet[_T], Generic[_T]): def clear(self) -> None: ... def pop(self) -> _T: ... def remove(self, value: _T) -> None: ... - def __ior__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ... + def __ior__(self, s: AbstractSet[_S]) -> MutableSet[_T | _S]: ... def __iand__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ... - def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ... + def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[_T | _S]: ... def __isub__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ... class MappingView(Sized): @@ -389,12 +389,12 @@ class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... if sys.version_info >= (3, 8): def __reversed__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... - def __or__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __ror__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... + def __or__(self, o: Iterable[_T]) -> Set[Tuple[_KT_co, _VT_co] | _T]: ... + def __ror__(self, o: Iterable[_T]) -> Set[Tuple[_KT_co, _VT_co] | _T]: ... def __sub__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ... def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ... - def __xor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... - def __rxor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... + def __xor__(self, o: Iterable[_T]) -> Set[Tuple[_KT_co, _VT_co] | _T]: ... + def __rxor__(self, o: Iterable[_T]) -> Set[Tuple[_KT_co, _VT_co] | _T]: ... class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented @@ -404,12 +404,12 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): def __iter__(self) -> Iterator[_KT_co]: ... if sys.version_info >= (3, 8): def __reversed__(self) -> Iterator[_KT_co]: ... - def __or__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... - def __ror__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... + def __or__(self, o: Iterable[_T]) -> Set[_KT_co | _T]: ... + def __ror__(self, o: Iterable[_T]) -> Set[_KT_co | _T]: ... def __sub__(self, o: Iterable[Any]) -> Set[_KT_co]: ... def __rsub__(self, o: Iterable[_T]) -> Set[_T]: ... - def __xor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... - def __rxor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... + def __xor__(self, o: Iterable[_T]) -> Set[_KT_co | _T]: ... + def __rxor__(self, o: Iterable[_T]) -> Set[_KT_co | _T]: ... class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented @@ -423,17 +423,17 @@ class ContextManager(Protocol[_T_co]): def __enter__(self) -> _T_co: ... def __exit__( self, - __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], - ) -> Optional[bool]: ... + __exc_type: Type[BaseException] | None, + __exc_value: BaseException | None, + __traceback: TracebackType | None, + ) -> bool | None: ... @runtime_checkable class AsyncContextManager(Protocol[_T_co]): def __aenter__(self) -> Awaitable[_T_co]: ... def __aexit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType] - ) -> Awaitable[Optional[bool]]: ... + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + ) -> Awaitable[bool | None]: ... class Mapping(_Collection[_KT], Generic[_KT, _VT_co]): # TODO: We wish the key type could also be covariant, but that doesn't work, @@ -442,9 +442,9 @@ class Mapping(_Collection[_KT], Generic[_KT, _VT_co]): def __getitem__(self, k: _KT) -> _VT_co: ... # Mixin methods @overload - def get(self, key: _KT) -> Optional[_VT_co]: ... + def get(self, key: _KT) -> _VT_co | None: ... @overload - def get(self, key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]: ... + def get(self, key: _KT, default: _VT_co | _T) -> _VT_co | _T: ... def items(self) -> AbstractSet[Tuple[_KT, _VT_co]]: ... def keys(self) -> AbstractSet[_KT]: ... def values(self) -> ValuesView[_VT_co]: ... @@ -459,7 +459,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def pop(self, key: _KT) -> _VT: ... @overload - def pop(self, key: _KT, default: Union[_VT, _T] = ...) -> Union[_VT, _T]: ... + def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ... def popitem(self) -> Tuple[_KT, _VT]: ... def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ... # 'update' used to take a Union, but using overloading is better. @@ -514,7 +514,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): @abstractmethod def tell(self) -> int: ... @abstractmethod - def truncate(self, size: Optional[int] = ...) -> int: ... + def truncate(self, size: int | None = ...) -> int: ... @abstractmethod def writable(self) -> bool: ... @abstractmethod @@ -529,8 +529,8 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): def __enter__(self) -> IO[AnyStr]: ... @abstractmethod def __exit__( - self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] - ) -> Optional[bool]: ... + self, t: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... class BinaryIO(IO[bytes]): @abstractmethod @@ -543,7 +543,7 @@ class TextIO(IO[str]): @property def encoding(self) -> str: ... @property - def errors(self) -> Optional[str]: ... + def errors(self) -> str | None: ... @property def line_buffering(self) -> int: ... # int on PyPy, bool on CPython @property @@ -556,8 +556,8 @@ class ByteString(Sequence[int], metaclass=ABCMeta): ... class Match(Generic[AnyStr]): pos: int endpos: int - lastindex: Optional[int] - lastgroup: Optional[AnyStr] + lastindex: int | None + lastgroup: AnyStr | None string: AnyStr # The regular expression object whose match() or search() method produced @@ -583,9 +583,9 @@ class Match(Generic[AnyStr]): def groupdict(self) -> dict[str, AnyStr | Any]: ... @overload def groupdict(self, default: _T) -> dict[str, AnyStr | _T]: ... - def start(self, __group: Union[int, str] = ...) -> int: ... - def end(self, __group: Union[int, str] = ...) -> int: ... - def span(self, __group: Union[int, str] = ...) -> Tuple[int, int]: ... + def start(self, __group: int | str = ...) -> int: ... + def end(self, __group: int | str = ...) -> int: ... + def span(self, __group: int | str = ...) -> Tuple[int, int]: ... @property def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented # __getitem__() returns "AnyStr" or "AnyStr | None", depending on the pattern. @@ -601,9 +601,9 @@ class Pattern(Generic[AnyStr]): groupindex: Mapping[str, int] groups: int pattern: AnyStr - def search(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Optional[Match[AnyStr]]: ... - def match(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Optional[Match[AnyStr]]: ... - def fullmatch(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Optional[Match[AnyStr]]: ... + def search(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ... + def match(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ... + def fullmatch(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ... def split(self, string: AnyStr, maxsplit: int = ...) -> list[AnyStr]: ... def findall(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> list[Any]: ... def finditer(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Iterator[Match[AnyStr]]: ... @@ -640,18 +640,18 @@ else: if sys.version_info >= (3, 9): def get_type_hints( obj: _get_type_hints_obj_allowed_types, - globalns: Optional[Dict[str, Any]] = ..., - localns: Optional[Dict[str, Any]] = ..., + globalns: Dict[str, Any] | None = ..., + localns: Dict[str, Any] | None = ..., include_extras: bool = ..., ) -> Dict[str, Any]: ... else: def get_type_hints( - obj: _get_type_hints_obj_allowed_types, globalns: Optional[Dict[str, Any]] = ..., localns: Optional[Dict[str, Any]] = ... + obj: _get_type_hints_obj_allowed_types, globalns: Dict[str, Any] | None = ..., localns: Dict[str, Any] | None = ... ) -> Dict[str, Any]: ... if sys.version_info >= (3, 8): - def get_origin(tp: Any) -> Optional[Any]: ... + def get_origin(tp: Any) -> Any | None: ... def get_args(tp: Any) -> Tuple[Any, ...]: ... @overload @@ -704,13 +704,13 @@ if sys.version_info >= (3, 7): __forward_arg__: str __forward_code__: CodeType __forward_evaluated__: bool - __forward_value__: Optional[Any] + __forward_value__: Any | None __forward_is_argument__: bool if sys.version_info >= (3, 10): def __init__(self, arg: str, is_argument: bool = ..., module: Any | None = ...) -> None: ... else: def __init__(self, arg: str, is_argument: bool = ...) -> None: ... - def _evaluate(self, globalns: Optional[Dict[str, Any]], localns: Optional[Dict[str, Any]]) -> Optional[Any]: ... + def _evaluate(self, globalns: Dict[str, Any] | None, localns: Dict[str, Any] | None) -> Any | None: ... def __eq__(self, other: Any) -> bool: ... def __hash__(self) -> int: ... def __repr__(self) -> str: ... diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 807e37ef29d6..15e283fca92d 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -74,14 +74,14 @@ OrderedDict = _Alias() def get_type_hints( obj: Callable[..., Any], - globalns: Optional[Dict[str, Any]] = ..., - localns: Optional[Dict[str, Any]] = ..., + globalns: Dict[str, Any] | None = ..., + localns: Dict[str, Any] | None = ..., include_extras: bool = ..., ) -> Dict[str, Any]: ... if sys.version_info >= (3, 7): def get_args(tp: Any) -> Tuple[Any, ...]: ... - def get_origin(tp: Any) -> Optional[Any]: ... + def get_origin(tp: Any) -> Any | None: ... Annotated: _SpecialForm = ... _AnnotatedAlias: Any = ... # undocumented @@ -103,11 +103,11 @@ else: def __init__(self, origin: ParamSpec) -> None: ... class ParamSpec: __name__: str - __bound__: Optional[Type[Any]] + __bound__: Type[Any] | None __covariant__: bool __contravariant__: bool def __init__( - self, name: str, *, bound: Union[None, Type[Any], str] = ..., contravariant: bool = ..., covariant: bool = ... + self, name: str, *, bound: None | Type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ... ) -> None: ... @property def args(self) -> ParamSpecArgs: ... diff --git a/stdlib/unicodedata.pyi b/stdlib/unicodedata.pyi index 3bc4f6f33411..3412e670b4ed 100644 --- a/stdlib/unicodedata.pyi +++ b/stdlib/unicodedata.pyi @@ -10,19 +10,19 @@ _T = TypeVar("_T") def bidirectional(__chr: str) -> str: ... def category(__chr: str) -> str: ... def combining(__chr: str) -> int: ... -def decimal(__chr: str, __default: _T = ...) -> Union[int, _T]: ... +def decimal(__chr: str, __default: _T = ...) -> int | _T: ... def decomposition(__chr: str) -> str: ... -def digit(__chr: str, __default: _T = ...) -> Union[int, _T]: ... +def digit(__chr: str, __default: _T = ...) -> int | _T: ... def east_asian_width(__chr: str) -> str: ... if sys.version_info >= (3, 8): def is_normalized(__form: str, __unistr: str) -> bool: ... -def lookup(__name: Union[str, bytes]) -> str: ... +def lookup(__name: str | bytes) -> str: ... def mirrored(__chr: str) -> int: ... -def name(__chr: str, __default: _T = ...) -> Union[str, _T]: ... +def name(__chr: str, __default: _T = ...) -> str | _T: ... def normalize(__form: str, __unistr: str) -> str: ... -def numeric(__chr: str, __default: _T = ...) -> Union[float, _T]: ... +def numeric(__chr: str, __default: _T = ...) -> float | _T: ... class UCD(object): # The methods below are constructed from the same array in C @@ -31,12 +31,12 @@ class UCD(object): def bidirectional(self, __chr: str) -> str: ... def category(self, __chr: str) -> str: ... def combining(self, __chr: str) -> int: ... - def decimal(self, __chr: str, __default: _T = ...) -> Union[int, _T]: ... + def decimal(self, __chr: str, __default: _T = ...) -> int | _T: ... def decomposition(self, __chr: str) -> str: ... - def digit(self, __chr: str, __default: _T = ...) -> Union[int, _T]: ... + def digit(self, __chr: str, __default: _T = ...) -> int | _T: ... def east_asian_width(self, __chr: str) -> str: ... - def lookup(self, __name: Union[str, bytes]) -> str: ... + def lookup(self, __name: str | bytes) -> str: ... def mirrored(self, __chr: str) -> int: ... - def name(self, __chr: str, __default: _T = ...) -> Union[str, _T]: ... + def name(self, __chr: str, __default: _T = ...) -> str | _T: ... def normalize(self, __form: str, __unistr: str) -> str: ... - def numeric(self, __chr: str, __default: _T = ...) -> Union[float, _T]: ... + def numeric(self, __chr: str, __default: _T = ...) -> float | _T: ... diff --git a/stdlib/unittest/__init__.pyi b/stdlib/unittest/__init__.pyi index b94cc8d9c1cd..6f322099b0fc 100644 --- a/stdlib/unittest/__init__.pyi +++ b/stdlib/unittest/__init__.pyi @@ -22,4 +22,4 @@ from unittest.runner import * from unittest.signals import * from unittest.suite import * -def load_tests(loader: TestLoader, tests: TestSuite, pattern: Optional[str]) -> TestSuite: ... +def load_tests(loader: TestLoader, tests: TestSuite, pattern: str | None) -> TestSuite: ... diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 79a7e79069af..767da2c6af72 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -49,7 +49,7 @@ class SkipTest(Exception): class TestCase: failureException: Type[BaseException] longMessage: bool - maxDiff: Optional[int] + maxDiff: int | None # undocumented _testMethodName: str # undocumented @@ -61,8 +61,8 @@ class TestCase: def setUpClass(cls) -> None: ... @classmethod def tearDownClass(cls) -> None: ... - def run(self, result: Optional[unittest.result.TestResult] = ...) -> Optional[unittest.result.TestResult]: ... - def __call__(self, result: Optional[unittest.result.TestResult] = ...) -> Optional[unittest.result.TestResult]: ... + def run(self, result: unittest.result.TestResult | None = ...) -> unittest.result.TestResult | None: ... + def __call__(self, result: unittest.result.TestResult | None = ...) -> unittest.result.TestResult | None: ... def skipTest(self, reason: Any) -> None: ... def subTest(self, msg: Any = ..., **params: Any) -> ContextManager[None]: ... def debug(self) -> None: ... @@ -75,10 +75,10 @@ class TestCase: def assertIsNot(self, expr1: Any, expr2: Any, msg: Any = ...) -> None: ... def assertIsNone(self, obj: Any, msg: Any = ...) -> None: ... def assertIsNotNone(self, obj: Any, msg: Any = ...) -> None: ... - def assertIn(self, member: Any, container: Union[Iterable[Any], Container[Any]], msg: Any = ...) -> None: ... - def assertNotIn(self, member: Any, container: Union[Iterable[Any], Container[Any]], msg: Any = ...) -> None: ... - def assertIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]], msg: Any = ...) -> None: ... - def assertNotIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]], msg: Any = ...) -> None: ... + def assertIn(self, member: Any, container: Iterable[Any] | Container[Any], msg: Any = ...) -> None: ... + def assertNotIn(self, member: Any, container: Iterable[Any] | Container[Any], msg: Any = ...) -> None: ... + def assertIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: Any = ...) -> None: ... + def assertNotIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: Any = ...) -> None: ... def assertGreater(self, a: Any, b: Any, msg: Any = ...) -> None: ... def assertGreaterEqual(self, a: Any, b: Any, msg: Any = ...) -> None: ... def assertLess(self, a: Any, b: Any, msg: Any = ...) -> None: ... @@ -86,20 +86,20 @@ class TestCase: @overload def assertRaises( # type: ignore self, - expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], + expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any, ) -> None: ... @overload def assertRaises( - self, expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any = ... + self, expected_exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ... ) -> _AssertRaisesContext[_E]: ... @overload def assertRaisesRegex( # type: ignore self, - expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], - expected_regex: Union[str, bytes, Pattern[str], Pattern[bytes]], + expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...], + expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, **kwargs: Any, @@ -107,27 +107,27 @@ class TestCase: @overload def assertRaisesRegex( self, - expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], - expected_regex: Union[str, bytes, Pattern[str], Pattern[bytes]], + expected_exception: Type[_E] | Tuple[Type[_E], ...], + expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertRaisesContext[_E]: ... @overload def assertWarns( # type: ignore self, - expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]], + expected_warning: Type[Warning] | Tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any, ) -> None: ... @overload def assertWarns( - self, expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]], msg: Any = ... + self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], msg: Any = ... ) -> _AssertWarnsContext: ... @overload def assertWarnsRegex( # type: ignore self, - expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]], - expected_regex: Union[str, bytes, Pattern[str], Pattern[bytes]], + expected_warning: Type[Warning] | Tuple[Type[Warning], ...], + expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, **kwargs: Any, @@ -135,48 +135,48 @@ class TestCase: @overload def assertWarnsRegex( self, - expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]], - expected_regex: Union[str, bytes, Pattern[str], Pattern[bytes]], + expected_warning: Type[Warning] | Tuple[Type[Warning], ...], + expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertWarnsContext: ... def assertLogs( - self, logger: Optional[Union[str, logging.Logger]] = ..., level: Union[int, str, None] = ... + self, logger: str | logging.Logger | None = ..., level: int | str | None = ... ) -> _AssertLogsContext: ... @overload def assertAlmostEqual( - self, first: float, second: float, places: Optional[int] = ..., msg: Any = ..., delta: Optional[float] = ... + self, first: float, second: float, places: int | None = ..., msg: Any = ..., delta: float | None = ... ) -> None: ... @overload def assertAlmostEqual( self, first: datetime.datetime, second: datetime.datetime, - places: Optional[int] = ..., + places: int | None = ..., msg: Any = ..., - delta: Optional[datetime.timedelta] = ..., + delta: datetime.timedelta | None = ..., ) -> None: ... @overload def assertNotAlmostEqual(self, first: float, second: float, *, msg: Any = ...) -> None: ... @overload - def assertNotAlmostEqual(self, first: float, second: float, places: Optional[int] = ..., msg: Any = ...) -> None: ... + def assertNotAlmostEqual(self, first: float, second: float, places: int | None = ..., msg: Any = ...) -> None: ... @overload - def assertNotAlmostEqual(self, first: float, second: float, *, msg: Any = ..., delta: Optional[float] = ...) -> None: ... + def assertNotAlmostEqual(self, first: float, second: float, *, msg: Any = ..., delta: float | None = ...) -> None: ... @overload def assertNotAlmostEqual( self, first: datetime.datetime, second: datetime.datetime, - places: Optional[int] = ..., + places: int | None = ..., msg: Any = ..., - delta: Optional[datetime.timedelta] = ..., + delta: datetime.timedelta | None = ..., ) -> None: ... - def assertRegex(self, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: Any = ...) -> None: ... - def assertNotRegex(self, text: AnyStr, unexpected_regex: Union[AnyStr, Pattern[AnyStr]], msg: Any = ...) -> None: ... + def assertRegex(self, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... + def assertNotRegex(self, text: AnyStr, unexpected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... def assertCountEqual(self, first: Iterable[Any], second: Iterable[Any], msg: Any = ...) -> None: ... def addTypeEqualityFunc(self, typeobj: Type[Any], function: Callable[..., None]) -> None: ... def assertMultiLineEqual(self, first: str, second: str, msg: Any = ...) -> None: ... def assertSequenceEqual( - self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: Optional[Type[Sequence[Any]]] = ... + self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: Type[Sequence[Any]] | None = ... ) -> None: ... def assertListEqual(self, list1: List[Any], list2: List[Any], msg: Any = ...) -> None: ... def assertTupleEqual(self, tuple1: Tuple[Any, ...], tuple2: Tuple[Any, ...], msg: Any = ...) -> None: ... @@ -186,7 +186,7 @@ class TestCase: def countTestCases(self) -> int: ... def defaultTestResult(self) -> unittest.result.TestResult: ... def id(self) -> str: ... - def shortDescription(self) -> Optional[str]: ... + def shortDescription(self) -> str | None: ... if sys.version_info >= (3, 8): def addCleanup(self, __function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... else: @@ -197,7 +197,7 @@ class TestCase: def addClassCleanup(cls, __function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... @classmethod def doClassCleanups(cls) -> None: ... - def _formatMessage(self, msg: Optional[str], standardMsg: str) -> str: ... # undocumented + def _formatMessage(self, msg: str | None, standardMsg: str) -> str: ... # undocumented def _getAssertEqualityFunc(self, first: Any, second: Any) -> Callable[..., None]: ... # undocumented # below is deprecated def failUnlessEqual(self, first: Any, second: Any, msg: Any = ...) -> None: ... @@ -210,26 +210,26 @@ class TestCase: @overload def failUnlessRaises( # type: ignore self, - exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], + exception: Type[BaseException] | Tuple[Type[BaseException], ...], callable: Callable[..., Any] = ..., *args: Any, **kwargs: Any, ) -> None: ... @overload - def failUnlessRaises(self, exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any = ...) -> _AssertRaisesContext[_E]: ... + def failUnlessRaises(self, exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... def failUnlessAlmostEqual(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... def assertAlmostEquals(self, first: float, second: float, places: int = ..., msg: Any = ..., delta: float = ...) -> None: ... def failIfAlmostEqual(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... def assertNotAlmostEquals( self, first: float, second: float, places: int = ..., msg: Any = ..., delta: float = ... ) -> None: ... - def assertRegexpMatches(self, text: AnyStr, regex: Union[AnyStr, Pattern[AnyStr]], msg: Any = ...) -> None: ... - def assertNotRegexpMatches(self, text: AnyStr, regex: Union[AnyStr, Pattern[AnyStr]], msg: Any = ...) -> None: ... + def assertRegexpMatches(self, text: AnyStr, regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... + def assertNotRegexpMatches(self, text: AnyStr, regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... @overload def assertRaisesRegexp( # type: ignore self, - exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], - expected_regex: Union[str, bytes, Pattern[str], Pattern[bytes]], + exception: Type[BaseException] | Tuple[Type[BaseException], ...], + expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, **kwargs: Any, @@ -237,8 +237,8 @@ class TestCase: @overload def assertRaisesRegexp( self, - exception: Union[Type[_E], Tuple[Type[_E], ...]], - expected_regex: Union[str, bytes, Pattern[str], Pattern[bytes]], + exception: Type[_E] | Tuple[Type[_E], ...], + expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertRaisesContext[_E]: ... def assertDictContainsSubset(self, subset: Mapping[Any, Any], dictionary: Mapping[Any, Any], msg: object = ...) -> None: ... @@ -247,9 +247,9 @@ class FunctionTestCase(TestCase): def __init__( self, testFunc: Callable[[], None], - setUp: Optional[Callable[[], None]] = ..., - tearDown: Optional[Callable[[], None]] = ..., - description: Optional[str] = ..., + setUp: Callable[[], None] | None = ..., + tearDown: Callable[[], None] | None = ..., + description: str | None = ..., ) -> None: ... def runTest(self) -> None: ... @@ -261,7 +261,7 @@ class _AssertRaisesContext(Generic[_E]): exception: _E def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -273,7 +273,7 @@ class _AssertWarnsContext: warnings: List[WarningMessage] def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _AssertLogsContext: @@ -286,5 +286,5 @@ class _AssertLogsContext: else: def __enter__(self) -> _LoggingWatcher: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 48c9f1c5f100..1102015fa117 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -14,15 +14,15 @@ class TestLoader: sortTestMethodsUsing: _SortComparisonMethod if sys.version_info >= (3, 7): - testNamePatterns: Optional[List[str]] + testNamePatterns: List[str] | None suiteClass: _SuiteClass def loadTestsFromTestCase(self, testCaseClass: Type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ... def loadTestsFromModule(self, module: ModuleType, *args: Any, pattern: Any = ...) -> unittest.suite.TestSuite: ... - def loadTestsFromName(self, name: str, module: Optional[ModuleType] = ...) -> unittest.suite.TestSuite: ... - def loadTestsFromNames(self, names: Sequence[str], module: Optional[ModuleType] = ...) -> unittest.suite.TestSuite: ... + def loadTestsFromName(self, name: str, module: ModuleType | None = ...) -> unittest.suite.TestSuite: ... + def loadTestsFromNames(self, names: Sequence[str], module: ModuleType | None = ...) -> unittest.suite.TestSuite: ... def getTestCaseNames(self, testCaseClass: Type[unittest.case.TestCase]) -> Sequence[str]: ... - def discover(self, start_dir: str, pattern: str = ..., top_level_dir: Optional[str] = ...) -> unittest.suite.TestSuite: ... + def discover(self, start_dir: str, pattern: str = ..., top_level_dir: str | None = ...) -> unittest.suite.TestSuite: ... defaultTestLoader: TestLoader @@ -31,7 +31,7 @@ if sys.version_info >= (3, 7): testCaseClass: Type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ..., - testNamePatterns: Optional[List[str]] = ..., + testNamePatterns: List[str] | None = ..., ) -> Sequence[str]: ... else: diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 5e6151eda3dd..18dbd553f577 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -7,41 +7,41 @@ from types import ModuleType from typing import Any, Iterable, List, Optional, Protocol, Type, Union class _TestRunner(Protocol): - def run(self, test: Union[unittest.suite.TestSuite, unittest.case.TestCase]) -> unittest.result.TestResult: ... + def run(self, test: unittest.suite.TestSuite | unittest.case.TestCase) -> unittest.result.TestResult: ... # not really documented class TestProgram: result: unittest.result.TestResult - module: Union[None, str, ModuleType] + module: None | str | ModuleType verbosity: int - failfast: Optional[bool] - catchbreak: Optional[bool] - buffer: Optional[bool] - progName: Optional[str] - warnings: Optional[str] + failfast: bool | None + catchbreak: bool | None + buffer: bool | None + progName: str | None + warnings: str | None if sys.version_info >= (3, 7): - testNamePatterns: Optional[List[str]] + testNamePatterns: List[str] | None def __init__( self, - module: Union[None, str, ModuleType] = ..., - defaultTest: Union[str, Iterable[str], None] = ..., - argv: Optional[List[str]] = ..., - testRunner: Union[Type[_TestRunner], _TestRunner, None] = ..., + module: None | str | ModuleType = ..., + defaultTest: str | Iterable[str] | None = ..., + argv: List[str] | None = ..., + testRunner: Type[_TestRunner] | _TestRunner | None = ..., testLoader: unittest.loader.TestLoader = ..., exit: bool = ..., verbosity: int = ..., - failfast: Optional[bool] = ..., - catchbreak: Optional[bool] = ..., - buffer: Optional[bool] = ..., - warnings: Optional[str] = ..., + failfast: bool | None = ..., + catchbreak: bool | None = ..., + buffer: bool | None = ..., + warnings: str | None = ..., *, tb_locals: bool = ..., ) -> None: ... def usageExit(self, msg: Any = ...) -> None: ... def parseArgs(self, argv: List[str]) -> None: ... if sys.version_info >= (3, 7): - def createTests(self, from_discovery: bool = ..., Loader: Optional[unittest.loader.TestLoader] = ...) -> None: ... + def createTests(self, from_discovery: bool = ..., Loader: unittest.loader.TestLoader | None = ...) -> None: ... else: def createTests(self) -> None: ... def runTests(self) -> None: ... # undocumented diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 40cb7743362a..2407be5168f4 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -42,13 +42,13 @@ DEFAULT: Any class _Call(Tuple[Any, ...]): def __new__( - cls, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ... + cls, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ... ) -> Any: ... name: Any parent: Any from_kall: Any def __init__( - self, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ... + self, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ... ) -> None: ... def __eq__(self, other: Any) -> bool: ... __ne__: Any @@ -76,16 +76,16 @@ class NonCallableMock(Base, Any): # type: ignore def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ... def __init__( self, - spec: Union[List[str], object, Type[object], None] = ..., - wraps: Optional[Any] = ..., - name: Optional[str] = ..., - spec_set: Union[List[str], object, Type[object], None] = ..., - parent: Optional[NonCallableMock] = ..., - _spec_state: Optional[Any] = ..., + spec: List[str] | object | Type[object] | None = ..., + wraps: Any | None = ..., + name: str | None = ..., + spec_set: List[str] | object | Type[object] | None = ..., + parent: NonCallableMock | None = ..., + _spec_state: Any | None = ..., _new_name: str = ..., - _new_parent: Optional[NonCallableMock] = ..., + _new_parent: NonCallableMock | None = ..., _spec_as_instance: bool = ..., - _eat_self: Optional[bool] = ..., + _eat_self: bool | None = ..., unsafe: bool = ..., **kwargs: Any, ) -> None: ... @@ -132,16 +132,16 @@ class CallableMixin(Base): side_effect: Any def __init__( self, - spec: Optional[Any] = ..., - side_effect: Optional[Any] = ..., + spec: Any | None = ..., + side_effect: Any | None = ..., return_value: Any = ..., - wraps: Optional[Any] = ..., - name: Optional[Any] = ..., - spec_set: Optional[Any] = ..., - parent: Optional[Any] = ..., - _spec_state: Optional[Any] = ..., + wraps: Any | None = ..., + name: Any | None = ..., + spec_set: Any | None = ..., + parent: Any | None = ..., + _spec_state: Any | None = ..., _new_name: Any = ..., - _new_parent: Optional[Any] = ..., + _new_parent: Any | None = ..., **kwargs: Any, ) -> None: ... def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ... @@ -168,11 +168,11 @@ class _patch(Generic[_T]): getter: Callable[[], Any], attribute: str, new: _T, - spec: Optional[Any], + spec: Any | None, create: bool, - spec_set: Optional[Any], - autospec: Optional[Any], - new_callable: Optional[Any], + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, kwargs: Mapping[str, Any], ) -> None: ... def copy(self) -> _patch[_T]: ... @@ -212,11 +212,11 @@ class _patcher: self, target: Any, new: _T, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[_T]: ... @overload @@ -224,24 +224,24 @@ class _patcher: self, target: Any, *, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, - ) -> _patch[Union[MagicMock, AsyncMock]]: ... + ) -> _patch[MagicMock | AsyncMock]: ... else: @overload def __call__( # type: ignore self, target: Any, new: _T, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[_T]: ... @overload @@ -249,11 +249,11 @@ class _patcher: self, target: Any, *, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[MagicMock]: ... if sys.version_info >= (3, 8): @@ -263,11 +263,11 @@ class _patcher: target: Any, attribute: str, new: _T, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[_T]: ... @overload @@ -276,13 +276,13 @@ class _patcher: target: Any, attribute: str, *, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, - ) -> _patch[Union[MagicMock, AsyncMock]]: ... + ) -> _patch[MagicMock | AsyncMock]: ... else: @overload def object( # type: ignore @@ -290,11 +290,11 @@ class _patcher: target: Any, attribute: str, new: _T, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[_T]: ... @overload @@ -303,21 +303,21 @@ class _patcher: target: Any, attribute: str, *, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[MagicMock]: ... def multiple( self, target: Any, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: _T, ) -> _patch[_T]: ... def stopall(self) -> None: ... @@ -346,7 +346,7 @@ if sys.version_info >= (3, 8): def assert_not_awaited(self) -> None: ... def reset_mock(self, *args: Any, **kwargs: Any) -> None: ... await_count: int - await_args: Optional[_Call] + await_args: _Call | None await_args_list: _CallList class AsyncMagicMixin(MagicMixin): def __init__(self, *args: Any, **kw: Any) -> None: ... @@ -358,7 +358,7 @@ class MagicProxy: def __init__(self, name: Any, parent: Any) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def create_mock(self) -> Any: ... - def __get__(self, obj: Any, _type: Optional[Any] = ...) -> Any: ... + def __get__(self, obj: Any, _type: Any | None = ...) -> Any: ... class _ANY: def __eq__(self, other: Any) -> bool: ... @@ -367,7 +367,7 @@ class _ANY: ANY: Any def create_autospec( - spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Optional[Any] = ..., _name: Optional[Any] = ..., **kwargs: Any + spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Any | None = ..., _name: Any | None = ..., **kwargs: Any ) -> Any: ... class _SpecState: @@ -381,13 +381,13 @@ class _SpecState: self, spec: Any, spec_set: Any = ..., - parent: Optional[Any] = ..., - name: Optional[Any] = ..., - ids: Optional[Any] = ..., + parent: Any | None = ..., + name: Any | None = ..., + ids: Any | None = ..., instance: Any = ..., ) -> None: ... -def mock_open(mock: Optional[Any] = ..., read_data: Any = ...) -> Any: ... +def mock_open(mock: Any | None = ..., read_data: Any = ...) -> Any: ... PropertyMock = Any diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 8c7ff78d6cdf..c55fc6fd969d 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -21,7 +21,7 @@ class TestResult: failfast: bool tb_locals: bool def __init__( - self, stream: Optional[TextIO] = ..., descriptions: Optional[bool] = ..., verbosity: Optional[int] = ... + self, stream: TextIO | None = ..., descriptions: bool | None = ..., verbosity: int | None = ... ) -> None: ... def printErrors(self) -> None: ... def wasSuccessful(self) -> bool: ... @@ -37,5 +37,5 @@ class TestResult: def addExpectedFailure(self, test: unittest.case.TestCase, err: _SysExcInfoType) -> None: ... def addUnexpectedSuccess(self, test: unittest.case.TestCase) -> None: ... def addSubTest( - self, test: unittest.case.TestCase, subtest: unittest.case.TestCase, err: Optional[_SysExcInfoType] + self, test: unittest.case.TestCase, subtest: unittest.case.TestCase, err: _SysExcInfoType | None ) -> None: ... diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index adb5fc50442a..a84c58849e21 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -21,15 +21,15 @@ class TextTestRunner(object): resultclass: _ResultClassType def __init__( self, - stream: Optional[TextIO] = ..., + stream: TextIO | None = ..., descriptions: bool = ..., verbosity: int = ..., failfast: bool = ..., buffer: bool = ..., - resultclass: Optional[_ResultClassType] = ..., - warnings: Optional[Type[Warning]] = ..., + resultclass: _ResultClassType | None = ..., + warnings: Type[Warning] | None = ..., *, tb_locals: bool = ..., ) -> None: ... def _makeResult(self) -> unittest.result.TestResult: ... - def run(self, test: Union[unittest.suite.TestSuite, unittest.case.TestCase]) -> unittest.result.TestResult: ... + def run(self, test: unittest.suite.TestSuite | unittest.case.TestCase) -> unittest.result.TestResult: ... diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index e7c919ef8426..103350820ec1 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -5,12 +5,12 @@ from urllib.response import addinfourl # Stubs for urllib.error class URLError(IOError): - reason: Union[str, BaseException] - def __init__(self, reason: Union[str, BaseException], filename: Optional[str] = ...) -> None: ... + reason: str | BaseException + def __init__(self, reason: str | BaseException, filename: str | None = ...) -> None: ... class HTTPError(URLError, addinfourl): code: int - def __init__(self, url: str, code: int, msg: str, hdrs: Message, fp: Optional[IO[bytes]]) -> None: ... + def __init__(self, url: str, code: int, msg: str, hdrs: Message, fp: IO[bytes] | None) -> None: ... class ContentTooShortError(URLError): content: Tuple[str, Message] diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 00bdb5109044..087536556006 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -25,10 +25,10 @@ class _ResultMixinBytes(_ResultMixinBase[str]): def decode(self, encoding: str = ..., errors: str = ...) -> _ResultMixinStr: ... class _NetlocResultMixinBase(Generic[AnyStr]): - username: Optional[AnyStr] - password: Optional[AnyStr] - hostname: Optional[AnyStr] - port: Optional[int] + username: AnyStr | None + password: AnyStr | None + hostname: AnyStr | None + port: int | None if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -80,30 +80,30 @@ class SplitResultBytes(_SplitResultBytesBase, _NetlocResultMixinBytes): ... class ParseResultBytes(_ParseResultBytesBase, _NetlocResultMixinBytes): ... def parse_qs( - qs: Optional[AnyStr], + qs: AnyStr | None, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ..., - max_num_fields: Optional[int] = ..., + max_num_fields: int | None = ..., separator: str = ..., ) -> Dict[AnyStr, List[AnyStr]]: ... def parse_qsl( - qs: Optional[AnyStr], + qs: AnyStr | None, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ..., - max_num_fields: Optional[int] = ..., + max_num_fields: int | None = ..., separator: str = ..., ) -> List[Tuple[AnyStr, AnyStr]]: ... @overload -def quote(string: str, safe: _Str = ..., encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ... +def quote(string: str, safe: _Str = ..., encoding: str | None = ..., errors: str | None = ...) -> str: ... @overload def quote(string: bytes, safe: _Str = ...) -> str: ... def quote_from_bytes(bs: bytes, safe: _Str = ...) -> str: ... @overload -def quote_plus(string: str, safe: _Str = ..., encoding: Optional[str] = ..., errors: Optional[str] = ...) -> str: ... +def quote_plus(string: str, safe: _Str = ..., encoding: str | None = ..., errors: str | None = ...) -> str: ... @overload def quote_plus(string: bytes, safe: _Str = ...) -> str: ... def unquote(string: str, encoding: str = ..., errors: str = ...) -> str: ... @@ -112,33 +112,33 @@ def unquote_plus(string: str, encoding: str = ..., errors: str = ...) -> str: .. @overload def urldefrag(url: str) -> DefragResult: ... @overload -def urldefrag(url: Optional[bytes]) -> DefragResultBytes: ... +def urldefrag(url: bytes | None) -> DefragResultBytes: ... def urlencode( - query: Union[Mapping[Any, Any], Mapping[Any, Sequence[Any]], Sequence[Tuple[Any, Any]], Sequence[Tuple[Any, Sequence[Any]]]], + query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[Tuple[Any, Any]] | Sequence[Tuple[Any, Sequence[Any]]], doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., errors: str = ..., quote_via: Callable[[str, AnyStr, str, str], str] = ..., ) -> str: ... -def urljoin(base: AnyStr, url: Optional[AnyStr], allow_fragments: bool = ...) -> AnyStr: ... +def urljoin(base: AnyStr, url: AnyStr | None, allow_fragments: bool = ...) -> AnyStr: ... @overload -def urlparse(url: str, scheme: Optional[str] = ..., allow_fragments: bool = ...) -> ParseResult: ... +def urlparse(url: str, scheme: str | None = ..., allow_fragments: bool = ...) -> ParseResult: ... @overload -def urlparse(url: Optional[bytes], scheme: Optional[bytes] = ..., allow_fragments: bool = ...) -> ParseResultBytes: ... +def urlparse(url: bytes | None, scheme: bytes | None = ..., allow_fragments: bool = ...) -> ParseResultBytes: ... @overload -def urlsplit(url: str, scheme: Optional[str] = ..., allow_fragments: bool = ...) -> SplitResult: ... +def urlsplit(url: str, scheme: str | None = ..., allow_fragments: bool = ...) -> SplitResult: ... @overload -def urlsplit(url: Optional[bytes], scheme: Optional[bytes] = ..., allow_fragments: bool = ...) -> SplitResultBytes: ... +def urlsplit(url: bytes | None, scheme: bytes | None = ..., allow_fragments: bool = ...) -> SplitResultBytes: ... @overload def urlunparse( - components: Tuple[Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr]] + components: Tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None] ) -> AnyStr: ... @overload -def urlunparse(components: Sequence[Optional[AnyStr]]) -> AnyStr: ... +def urlunparse(components: Sequence[AnyStr | None]) -> AnyStr: ... @overload def urlunsplit( - components: Tuple[Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr]] + components: Tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None] ) -> AnyStr: ... @overload -def urlunsplit(components: Sequence[Optional[AnyStr]]) -> AnyStr: ... +def urlunsplit(components: Sequence[AnyStr | None]) -> AnyStr: ... diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 32836cff0939..16059b1dd5dd 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -28,17 +28,17 @@ _T = TypeVar("_T") _UrlopenRet = Any def urlopen( - url: Union[str, Request], - data: Optional[bytes] = ..., - timeout: Optional[float] = ..., + url: str | Request, + data: bytes | None = ..., + timeout: float | None = ..., *, - cafile: Optional[str] = ..., - capath: Optional[str] = ..., + cafile: str | None = ..., + capath: str | None = ..., cadefault: bool = ..., - context: Optional[ssl.SSLContext] = ..., + context: ssl.SSLContext | None = ..., ) -> _UrlopenRet: ... def install_opener(opener: OpenerDirector) -> None: ... -def build_opener(*handlers: Union[BaseHandler, Callable[[], BaseHandler]]) -> OpenerDirector: ... +def build_opener(*handlers: BaseHandler | Callable[[], BaseHandler]) -> OpenerDirector: ... if sys.platform == "win32": from nturl2path import pathname2url as pathname2url, url2pathname as url2pathname @@ -54,7 +54,7 @@ if sys.platform == "win32" or sys.platform == "darwin": def proxy_bypass(host: str) -> Any: ... # Undocumented else: - def proxy_bypass(host: str, proxies: Optional[Mapping[str, str]] = ...) -> Any: ... # Undocumented + def proxy_bypass(host: str, proxies: Mapping[str, str] | None = ...) -> Any: ... # Undocumented class Request: @property @@ -67,20 +67,20 @@ class Request: host: str origin_req_host: str selector: str - data: Optional[bytes] + data: bytes | None headers: Dict[str, str] unredirected_hdrs: Dict[str, str] unverifiable: bool - method: Optional[str] - timeout: Optional[float] # Undocumented, only set after __init__() by OpenerDirector.open() + method: str | None + timeout: float | None # Undocumented, only set after __init__() by OpenerDirector.open() def __init__( self, url: str, - data: Optional[bytes] = ..., + data: bytes | None = ..., headers: Dict[str, str] = ..., - origin_req_host: Optional[str] = ..., + origin_req_host: str | None = ..., unverifiable: bool = ..., - method: Optional[str] = ..., + method: str | None = ..., ) -> None: ... def get_method(self) -> str: ... def add_header(self, key: str, val: str) -> None: ... @@ -90,16 +90,16 @@ class Request: def get_full_url(self) -> str: ... def set_proxy(self, host: str, type: str) -> None: ... @overload - def get_header(self, header_name: str) -> Optional[str]: ... + def get_header(self, header_name: str) -> str | None: ... @overload - def get_header(self, header_name: str, default: _T) -> Union[str, _T]: ... + def get_header(self, header_name: str, default: _T) -> str | _T: ... def header_items(self) -> List[Tuple[str, str]]: ... def has_proxy(self) -> bool: ... class OpenerDirector: addheaders: List[Tuple[str, str]] def add_handler(self, handler: BaseHandler) -> None: ... - def open(self, fullurl: Union[str, Request], data: Optional[bytes] = ..., timeout: Optional[float] = ...) -> _UrlopenRet: ... + def open(self, fullurl: str | Request, data: bytes | None = ..., timeout: float | None = ...) -> _UrlopenRet: ... def error(self, proto: str, *args: Any) -> _UrlopenRet: ... def close(self) -> None: ... @@ -120,79 +120,79 @@ class HTTPRedirectHandler(BaseHandler): inf_msg: ClassVar[str] # undocumented def redirect_request( self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage, newurl: str - ) -> Optional[Request]: ... - def http_error_301(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> Optional[_UrlopenRet]: ... - def http_error_302(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> Optional[_UrlopenRet]: ... - def http_error_303(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> Optional[_UrlopenRet]: ... - def http_error_307(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> Optional[_UrlopenRet]: ... + ) -> Request | None: ... + def http_error_301(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... + def http_error_302(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... + def http_error_303(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... + def http_error_307(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... class HTTPCookieProcessor(BaseHandler): cookiejar: CookieJar - def __init__(self, cookiejar: Optional[CookieJar] = ...) -> None: ... + def __init__(self, cookiejar: CookieJar | None = ...) -> None: ... def http_request(self, request: Request) -> Request: ... # undocumented def http_response(self, request: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented def https_request(self, request: Request) -> Request: ... # undocumented def https_response(self, request: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented class ProxyHandler(BaseHandler): - def __init__(self, proxies: Optional[Dict[str, str]] = ...) -> None: ... - def proxy_open(self, req: Request, proxy: str, type: str) -> Optional[_UrlopenRet]: ... # undocumented + def __init__(self, proxies: Dict[str, str] | None = ...) -> None: ... + def proxy_open(self, req: Request, proxy: str, type: str) -> _UrlopenRet | None: ... # undocumented # TODO add a method for every (common) proxy protocol class HTTPPasswordMgr: - def add_password(self, realm: str, uri: Union[str, Sequence[str]], user: str, passwd: str) -> None: ... - def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ... + def add_password(self, realm: str, uri: str | Sequence[str], user: str, passwd: str) -> None: ... + def find_user_password(self, realm: str, authuri: str) -> Tuple[str | None, str | None]: ... def is_suburi(self, base: str, test: str) -> bool: ... # undocumented def reduce_uri(self, uri: str, default_port: bool = ...) -> str: ... # undocumented class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): - def add_password(self, realm: Optional[str], uri: Union[str, Sequence[str]], user: str, passwd: str) -> None: ... - def find_user_password(self, realm: Optional[str], authuri: str) -> Tuple[Optional[str], Optional[str]]: ... + def add_password(self, realm: str | None, uri: str | Sequence[str], user: str, passwd: str) -> None: ... + def find_user_password(self, realm: str | None, authuri: str) -> Tuple[str | None, str | None]: ... class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm): def add_password( - self, realm: Optional[str], uri: Union[str, Sequence[str]], user: str, passwd: str, is_authenticated: bool = ... + self, realm: str | None, uri: str | Sequence[str], user: str, passwd: str, is_authenticated: bool = ... ) -> None: ... - def update_authenticated(self, uri: Union[str, Sequence[str]], is_authenticated: bool = ...) -> None: ... + def update_authenticated(self, uri: str | Sequence[str], is_authenticated: bool = ...) -> None: ... def is_authenticated(self, authuri: str) -> bool: ... class AbstractBasicAuthHandler: rx: ClassVar[Pattern[str]] # undocumented passwd: HTTPPasswordMgr - add_password: Callable[[str, Union[str, Sequence[str]], str, str], None] - def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ... + add_password: Callable[[str, str | Sequence[str], str, str], None] + def __init__(self, password_mgr: HTTPPasswordMgr | None = ...) -> None: ... def http_error_auth_reqed(self, authreq: str, host: str, req: Request, headers: HTTPMessage) -> None: ... def http_request(self, req: Request) -> Request: ... # undocumented def http_response(self, req: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented def https_request(self, req: Request) -> Request: ... # undocumented def https_response(self, req: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented - def retry_http_basic_auth(self, host: str, req: Request, realm: str) -> Optional[_UrlopenRet]: ... # undocumented + def retry_http_basic_auth(self, host: str, req: Request, realm: str) -> _UrlopenRet | None: ... # undocumented class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): auth_header: ClassVar[str] # undocumented - def http_error_401(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> Optional[_UrlopenRet]: ... + def http_error_401(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): auth_header: ClassVar[str] - def http_error_407(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> Optional[_UrlopenRet]: ... + def http_error_407(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... class AbstractDigestAuthHandler: - def __init__(self, passwd: Optional[HTTPPasswordMgr] = ...) -> None: ... + def __init__(self, passwd: HTTPPasswordMgr | None = ...) -> None: ... def reset_retry_count(self) -> None: ... def http_error_auth_reqed(self, auth_header: str, host: str, req: Request, headers: HTTPMessage) -> None: ... - def retry_http_digest_auth(self, req: Request, auth: str) -> Optional[_UrlopenRet]: ... + def retry_http_digest_auth(self, req: Request, auth: str) -> _UrlopenRet | None: ... def get_cnonce(self, nonce: str) -> str: ... def get_authorization(self, req: Request, chal: Mapping[str, str]) -> str: ... def get_algorithm_impls(self, algorithm: str) -> Tuple[Callable[[str], str], Callable[[str, str], str]]: ... - def get_entity_digest(self, data: Optional[bytes], chal: Mapping[str, str]) -> Optional[str]: ... + def get_entity_digest(self, data: bytes | None, chal: Mapping[str, str]) -> str | None: ... class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): auth_header: ClassVar[str] # undocumented - def http_error_401(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> Optional[_UrlopenRet]: ... + def http_error_401(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): auth_header: ClassVar[str] # undocumented - def http_error_407(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> Optional[_UrlopenRet]: ... + def http_error_407(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ... class AbstractHTTPHandler(BaseHandler): # undocumented def __init__(self, debuglevel: int = ...) -> None: ... @@ -206,13 +206,13 @@ class HTTPHandler(AbstractHTTPHandler): class HTTPSHandler(AbstractHTTPHandler): def __init__( - self, debuglevel: int = ..., context: Optional[ssl.SSLContext] = ..., check_hostname: Optional[bool] = ... + self, debuglevel: int = ..., context: ssl.SSLContext | None = ..., check_hostname: bool | None = ... ) -> None: ... def https_open(self, req: Request) -> HTTPResponse: ... def https_request(self, request: Request) -> Request: ... # undocumented class FileHandler(BaseHandler): - names: ClassVar[Optional[Tuple[str, ...]]] # undocumented + names: ClassVar[Tuple[str, ...] | None] # undocumented def file_open(self, req: Request) -> addinfourl: ... def get_names(self) -> Tuple[str, ...]: ... # undocumented def open_local_file(self, req: Request) -> addinfourl: ... # undocumented @@ -222,7 +222,7 @@ class DataHandler(BaseHandler): class ftpwrapper: # undocumented def __init__( - self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: Optional[float] = ..., persistent: bool = ... + self, user: str, passwd: str, host: str, port: int, dirs: str, timeout: float | None = ..., persistent: bool = ... ) -> None: ... def close(self) -> None: ... def endtransfer(self) -> None: ... @@ -255,56 +255,56 @@ class HTTPErrorProcessor(BaseHandler): def urlretrieve( url: str, - filename: Optional[StrOrBytesPath] = ..., - reporthook: Optional[Callable[[int, int, int], None]] = ..., - data: Optional[bytes] = ..., + filename: StrOrBytesPath | None = ..., + reporthook: Callable[[int, int, int], None] | None = ..., + data: bytes | None = ..., ) -> Tuple[str, HTTPMessage]: ... def urlcleanup() -> None: ... class URLopener: version: ClassVar[str] - def __init__(self, proxies: Optional[Dict[str, str]] = ..., **x509: str) -> None: ... - def open(self, fullurl: str, data: Optional[bytes] = ...) -> _UrlopenRet: ... - def open_unknown(self, fullurl: str, data: Optional[bytes] = ...) -> _UrlopenRet: ... + def __init__(self, proxies: Dict[str, str] | None = ..., **x509: str) -> None: ... + def open(self, fullurl: str, data: bytes | None = ...) -> _UrlopenRet: ... + def open_unknown(self, fullurl: str, data: bytes | None = ...) -> _UrlopenRet: ... def retrieve( self, url: str, - filename: Optional[str] = ..., - reporthook: Optional[Callable[[int, int, int], None]] = ..., - data: Optional[bytes] = ..., - ) -> Tuple[str, Optional[Message]]: ... + filename: str | None = ..., + reporthook: Callable[[int, int, int], None] | None = ..., + data: bytes | None = ..., + ) -> Tuple[str, Message | None]: ... def addheader(self, *args: Tuple[str, str]) -> None: ... # undocumented def cleanup(self) -> None: ... # undocumented def close(self) -> None: ... # undocumented def http_error( - self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: Optional[bytes] = ... + self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None = ... ) -> _UrlopenRet: ... # undocumented def http_error_default( self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage ) -> _UrlopenRet: ... # undocumented - def open_data(self, url: str, data: Optional[bytes] = ...) -> addinfourl: ... # undocumented + def open_data(self, url: str, data: bytes | None = ...) -> addinfourl: ... # undocumented def open_file(self, url: str) -> addinfourl: ... # undocumented def open_ftp(self, url: str) -> addinfourl: ... # undocumented - def open_http(self, url: str, data: Optional[bytes] = ...) -> _UrlopenRet: ... # undocumented - def open_https(self, url: str, data: Optional[bytes] = ...) -> _UrlopenRet: ... # undocumented + def open_http(self, url: str, data: bytes | None = ...) -> _UrlopenRet: ... # undocumented + def open_https(self, url: str, data: bytes | None = ...) -> _UrlopenRet: ... # undocumented def open_local_file(self, url: str) -> addinfourl: ... # undocumented - def open_unknown_proxy(self, proxy: str, fullurl: str, data: Optional[bytes] = ...) -> None: ... # undocumented + def open_unknown_proxy(self, proxy: str, fullurl: str, data: bytes | None = ...) -> None: ... # undocumented class FancyURLopener(URLopener): def prompt_user_passwd(self, host: str, realm: str) -> Tuple[str, str]: ... def get_user_passwd(self, host: str, realm: str, clear_cache: int = ...) -> Tuple[str, str]: ... # undocumented def http_error_301( - self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: Optional[bytes] = ... - ) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented + self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented def http_error_302( - self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: Optional[bytes] = ... - ) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented + self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented def http_error_303( - self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: Optional[bytes] = ... - ) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented + self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented def http_error_307( - self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: Optional[bytes] = ... - ) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented + self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented def http_error_401( self, url: str, @@ -312,9 +312,9 @@ class FancyURLopener(URLopener): errcode: int, errmsg: str, headers: HTTPMessage, - data: Optional[bytes] = ..., + data: bytes | None = ..., retry: bool = ..., - ) -> Optional[_UrlopenRet]: ... # undocumented + ) -> _UrlopenRet | None: ... # undocumented def http_error_407( self, url: str, @@ -322,24 +322,24 @@ class FancyURLopener(URLopener): errcode: int, errmsg: str, headers: HTTPMessage, - data: Optional[bytes] = ..., + data: bytes | None = ..., retry: bool = ..., - ) -> Optional[_UrlopenRet]: ... # undocumented + ) -> _UrlopenRet | None: ... # undocumented def http_error_default( self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage ) -> addinfourl: ... # undocumented def redirect_internal( - self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: Optional[bytes] - ) -> Optional[_UrlopenRet]: ... # undocumented + self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None + ) -> _UrlopenRet | None: ... # undocumented def retry_http_basic_auth( - self, url: str, realm: str, data: Optional[bytes] = ... - ) -> Optional[_UrlopenRet]: ... # undocumented + self, url: str, realm: str, data: bytes | None = ... + ) -> _UrlopenRet | None: ... # undocumented def retry_https_basic_auth( - self, url: str, realm: str, data: Optional[bytes] = ... - ) -> Optional[_UrlopenRet]: ... # undocumented + self, url: str, realm: str, data: bytes | None = ... + ) -> _UrlopenRet | None: ... # undocumented def retry_proxy_http_basic_auth( - self, url: str, realm: str, data: Optional[bytes] = ... - ) -> Optional[_UrlopenRet]: ... # undocumented + self, url: str, realm: str, data: bytes | None = ... + ) -> _UrlopenRet | None: ... # undocumented def retry_proxy_https_basic_auth( - self, url: str, realm: str, data: Optional[bytes] = ... - ) -> Optional[_UrlopenRet]: ... # undocumented + self, url: str, realm: str, data: bytes | None = ... + ) -> _UrlopenRet | None: ... # undocumented diff --git a/stdlib/urllib/response.pyi b/stdlib/urllib/response.pyi index 300105076048..c9d39ff38209 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -10,7 +10,7 @@ class addbase(BinaryIO): def __init__(self, fp: IO[bytes]) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def __iter__(self: _AIUT) -> _AIUT: ... def __next__(self) -> bytes: ... @@ -29,7 +29,7 @@ class addbase(BinaryIO): def seek(self, offset: int, whence: int = ...) -> int: ... def seekable(self) -> bool: ... def tell(self) -> int: ... - def truncate(self, size: Optional[int] = ...) -> int: ... + def truncate(self, size: int | None = ...) -> int: ... def writable(self) -> bool: ... def write(self, s: bytes) -> int: ... def writelines(self, lines: Iterable[bytes]) -> None: ... @@ -47,6 +47,6 @@ class addinfo(addbase): class addinfourl(addinfo): url: str code: int - def __init__(self, fp: IO[bytes], headers: Message, url: str, code: Optional[int] = ...) -> None: ... + def __init__(self, fp: IO[bytes], headers: Message, url: str, code: int | None = ...) -> None: ... def geturl(self) -> str: ... def getcode(self) -> int: ... diff --git a/stdlib/urllib/robotparser.pyi b/stdlib/urllib/robotparser.pyi index 382dcee0e859..1bafbae74d8b 100644 --- a/stdlib/urllib/robotparser.pyi +++ b/stdlib/urllib/robotparser.pyi @@ -13,7 +13,7 @@ class RobotFileParser: def can_fetch(self, useragent: str, url: str) -> bool: ... def mtime(self) -> int: ... def modified(self) -> None: ... - def crawl_delay(self, useragent: str) -> Optional[str]: ... - def request_rate(self, useragent: str) -> Optional[_RequestRate]: ... + def crawl_delay(self, useragent: str) -> str | None: ... + def request_rate(self, useragent: str) -> _RequestRate | None: ... if sys.version_info >= (3, 8): - def site_maps(self) -> Optional[List[str]]: ... + def site_maps(self) -> List[str] | None: ... diff --git a/stdlib/uu.pyi b/stdlib/uu.pyi index 91ce210ae96d..b613c6e791b6 100644 --- a/stdlib/uu.pyi +++ b/stdlib/uu.pyi @@ -7,10 +7,10 @@ class Error(Exception): ... if sys.version_info >= (3, 7): def encode( - in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ..., *, backtick: bool = ... + in_file: _File, out_file: _File, name: str | None = ..., mode: int | None = ..., *, backtick: bool = ... ) -> None: ... else: - def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... + def encode(in_file: _File, out_file: _File, name: str | None = ..., mode: int | None = ...) -> None: ... -def decode(in_file: _File, out_file: Optional[_File] = ..., mode: Optional[int] = ..., quiet: int = ...) -> None: ... +def decode(in_file: _File, out_file: _File | None = ..., mode: int | None = ..., quiet: int = ...) -> None: ... diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index b66b169c5ff7..ce7a0d2e877c 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -17,12 +17,12 @@ class UUID: if sys.version_info >= (3, 7): def __init__( self, - hex: Optional[str] = ..., - bytes: Optional[_Bytes] = ..., - bytes_le: Optional[_Bytes] = ..., - fields: Optional[_FieldsType] = ..., - int: Optional[_Int] = ..., - version: Optional[_Int] = ..., + hex: str | None = ..., + bytes: _Bytes | None = ..., + bytes_le: _Bytes | None = ..., + fields: _FieldsType | None = ..., + int: _Int | None = ..., + version: _Int | None = ..., *, is_safe: SafeUUID = ..., ) -> None: ... @@ -31,12 +31,12 @@ class UUID: else: def __init__( self, - hex: Optional[str] = ..., - bytes: Optional[_Bytes] = ..., - bytes_le: Optional[_Bytes] = ..., - fields: Optional[_FieldsType] = ..., - int: Optional[_Int] = ..., - version: Optional[_Int] = ..., + hex: str | None = ..., + bytes: _Bytes | None = ..., + bytes_le: _Bytes | None = ..., + fields: _FieldsType | None = ..., + int: _Int | None = ..., + version: _Int | None = ..., ) -> None: ... @property def bytes(self) -> _Bytes: ... @@ -69,7 +69,7 @@ class UUID: @property def variant(self) -> str: ... @property - def version(self) -> Optional[_Int]: ... + def version(self) -> _Int | None: ... def __int__(self) -> _Int: ... def __eq__(self, other: Any) -> bool: ... def __lt__(self, other: Any) -> bool: ... @@ -78,7 +78,7 @@ class UUID: def __ge__(self, other: Any) -> bool: ... def getnode() -> int: ... -def uuid1(node: Optional[_Int] = ..., clock_seq: Optional[_Int] = ...) -> UUID: ... +def uuid1(node: _Int | None = ..., clock_seq: _Int | None = ...) -> UUID: ... def uuid3(namespace: UUID, name: str) -> UUID: ... def uuid4() -> UUID: ... def uuid5(namespace: UUID, name: str) -> UUID: ... diff --git a/stdlib/venv/__init__.pyi b/stdlib/venv/__init__.pyi index fe49ea65655b..870bca5a3789 100644 --- a/stdlib/venv/__init__.pyi +++ b/stdlib/venv/__init__.pyi @@ -9,7 +9,7 @@ class EnvBuilder: symlinks: bool upgrade: bool with_pip: bool - prompt: Optional[str] + prompt: str | None if sys.version_info >= (3, 9): def __init__( @@ -19,7 +19,7 @@ class EnvBuilder: symlinks: bool = ..., upgrade: bool = ..., with_pip: bool = ..., - prompt: Optional[str] = ..., + prompt: str | None = ..., upgrade_deps: bool = ..., ) -> None: ... else: @@ -30,7 +30,7 @@ class EnvBuilder: symlinks: bool = ..., upgrade: bool = ..., with_pip: bool = ..., - prompt: Optional[str] = ..., + prompt: str | None = ..., ) -> None: ... def create(self, env_dir: StrOrBytesPath) -> None: ... def clear_directory(self, path: StrOrBytesPath) -> None: ... # undocumented @@ -55,7 +55,7 @@ if sys.version_info >= (3, 9): clear: bool = ..., symlinks: bool = ..., with_pip: bool = ..., - prompt: Optional[str] = ..., + prompt: str | None = ..., upgrade_deps: bool = ..., ) -> None: ... @@ -66,7 +66,7 @@ else: clear: bool = ..., symlinks: bool = ..., with_pip: bool = ..., - prompt: Optional[str] = ..., + prompt: str | None = ..., ) -> None: ... -def main(args: Optional[Sequence[str]] = ...) -> None: ... +def main(args: Sequence[str] | None = ...) -> None: ... diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index f3f606267892..e40a17746b45 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -5,15 +5,15 @@ from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit def showwarning( - message: Union[Warning, str], + message: Warning | str, category: Type[Warning], filename: str, lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., + file: TextIO | None = ..., + line: str | None = ..., ) -> None: ... def formatwarning( - message: Union[Warning, str], category: Type[Warning], filename: str, lineno: int, line: Optional[str] = ... + message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ... ) -> str: ... def filterwarnings( action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ... @@ -24,34 +24,34 @@ def resetwarnings() -> None: ... class _OptionError(Exception): ... class WarningMessage: - message: Union[Warning, str] + message: Warning | str category: Type[Warning] filename: str lineno: int - file: Optional[TextIO] - line: Optional[str] - source: Optional[Any] + file: TextIO | None + line: str | None + source: Any | None def __init__( self, - message: Union[Warning, str], + message: Warning | str, category: Type[Warning], filename: str, lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., - source: Optional[Any] = ..., + file: TextIO | None = ..., + line: str | None = ..., + source: Any | None = ..., ) -> None: ... class catch_warnings: @overload - def __new__(cls, *, record: Literal[False] = ..., module: Optional[ModuleType] = ...) -> _catch_warnings_without_records: ... + def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ...) -> _catch_warnings_without_records: ... @overload - def __new__(cls, *, record: Literal[True], module: Optional[ModuleType] = ...) -> _catch_warnings_with_records: ... + def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ... @overload - def __new__(cls, *, record: bool, module: Optional[ModuleType] = ...) -> catch_warnings: ... - def __enter__(self) -> Optional[List[WarningMessage]]: ... + def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... + def __enter__(self) -> List[WarningMessage] | None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _catch_warnings_without_records(catch_warnings): diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index cafdcd408398..b12b235518ad 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -20,7 +20,7 @@ class Wave_read: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... - def getfp(self) -> Optional[BinaryIO]: ... + def getfp(self) -> BinaryIO | None: ... def rewind(self) -> None: ... def close(self) -> None: ... def tell(self) -> int: ... @@ -63,7 +63,7 @@ class Wave_write: def close(self) -> None: ... # Returns a Wave_read if mode is rb and Wave_write if mode is wb -def open(f: _File, mode: Optional[str] = ...) -> Any: ... +def open(f: _File, mode: str | None = ...) -> Any: ... if sys.version_info < (3, 9): openfp = open diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index a4998ddc4219..d4ecf1318182 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -36,14 +36,14 @@ _VT = TypeVar("_VT") ProxyTypes: Tuple[Type[Any], ...] class WeakMethod(ref[types.MethodType]): - def __new__(cls, meth: types.MethodType, callback: Optional[Callable[[types.MethodType], Any]] = ...) -> WeakMethod: ... - def __call__(self) -> Optional[types.MethodType]: ... + def __new__(cls, meth: types.MethodType, callback: Callable[[types.MethodType], Any] | None = ...) -> WeakMethod: ... + def __call__(self) -> types.MethodType | None: ... class WeakValueDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self) -> None: ... @overload - def __init__(self, __other: Union[Mapping[_KT, _VT], Iterable[Tuple[_KT, _VT]]], **kwargs: _VT) -> None: ... + def __init__(self, __other: Mapping[_KT, _VT] | Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... @@ -69,7 +69,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self, dict: None = ...) -> None: ... @overload - def __init__(self, dict: Union[Mapping[_KT, _VT], Iterable[Tuple[_KT, _VT]]]) -> None: ... + def __init__(self, dict: Mapping[_KT, _VT] | Iterable[Tuple[_KT, _VT]]) -> None: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... @@ -86,8 +86,8 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): class finalize: def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... - def __call__(self, _: Any = ...) -> Optional[Any]: ... - def detach(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... - def peek(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... + def __call__(self, _: Any = ...) -> Any | None: ... + def detach(self) -> Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]] | None: ... + def peek(self) -> Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]] | None: ... alive: bool atexit: bool diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index bb543e2f2273..65e87c00e369 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -5,15 +5,15 @@ class Error(Exception): ... if sys.version_info >= (3, 7): def register( - name: str, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., *, preferred: bool = ... + name: str, klass: Callable[[], BaseBrowser] | None, instance: BaseBrowser | None = ..., *, preferred: bool = ... ) -> None: ... else: def register( - name: str, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... + name: str, klass: Callable[[], BaseBrowser] | None, instance: BaseBrowser | None = ..., update_tryorder: int = ... ) -> None: ... -def get(using: Optional[str] = ...) -> BaseBrowser: ... +def get(using: str | None = ...) -> BaseBrowser: ... def open(url: str, new: int = ..., autoraise: bool = ...) -> bool: ... def open_new(url: str) -> bool: ... def open_new_tab(url: str) -> bool: ... @@ -31,14 +31,14 @@ class GenericBrowser(BaseBrowser): args: List[str] name: str basename: str - def __init__(self, name: Union[str, Sequence[str]]) -> None: ... + def __init__(self, name: str | Sequence[str]) -> None: ... def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... class BackgroundBrowser(GenericBrowser): def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... class UnixBrowser(BaseBrowser): - raise_opts: Optional[List[str]] + raise_opts: List[str] | None background: bool redirect_stdout: bool remote_args: List[str] diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index ac9fcb24934b..91f5edb353d7 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -5,9 +5,9 @@ from typing import Any, Optional, Tuple, Type, Union _KeyType = Union[HKEYType, int] def CloseKey(__hkey: _KeyType) -> None: ... -def ConnectRegistry(__computer_name: Optional[str], __key: _KeyType) -> HKEYType: ... -def CreateKey(__key: _KeyType, __sub_key: Optional[str]) -> HKEYType: ... -def CreateKeyEx(key: _KeyType, sub_key: Optional[str], reserved: int = ..., access: int = ...) -> HKEYType: ... +def ConnectRegistry(__computer_name: str | None, __key: _KeyType) -> HKEYType: ... +def CreateKey(__key: _KeyType, __sub_key: str | None) -> HKEYType: ... +def CreateKeyEx(key: _KeyType, sub_key: str | None, reserved: int = ..., access: int = ...) -> HKEYType: ... def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ... def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ... def DeleteValue(__key: _KeyType, __value: str) -> None: ... @@ -19,12 +19,12 @@ def LoadKey(__key: _KeyType, __sub_key: str, __file_name: str) -> None: ... def OpenKey(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ... def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ... def QueryInfoKey(__key: _KeyType) -> Tuple[int, int, int]: ... -def QueryValue(__key: _KeyType, __sub_key: Optional[str]) -> str: ... +def QueryValue(__key: _KeyType, __sub_key: str | None) -> str: ... def QueryValueEx(__key: _KeyType, __name: str) -> Tuple[Any, int]: ... def SaveKey(__key: _KeyType, __file_name: str) -> None: ... def SetValue(__key: _KeyType, __sub_key: str, __type: int, __value: str) -> None: ... def SetValueEx( - __key: _KeyType, __value_name: Optional[str], __reserved: Any, __type: int, __value: Union[str, int] + __key: _KeyType, __value_name: str | None, __reserved: Any, __type: int, __value: str | int ) -> None: ... # reserved is ignored def DisableReflectionKey(__key: _KeyType) -> None: ... def EnableReflectionKey(__key: _KeyType) -> None: ... @@ -93,7 +93,7 @@ class HKEYType: def __int__(self) -> int: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def Close(self) -> None: ... def Detach(self) -> int: ... diff --git a/stdlib/winsound.pyi b/stdlib/winsound.pyi index be9a8c660781..91ec0b717157 100644 --- a/stdlib/winsound.pyi +++ b/stdlib/winsound.pyi @@ -21,7 +21,7 @@ if sys.platform == "win32": def Beep(frequency: int, duration: int) -> None: ... # Can actually accept anything ORed with 4, and if not it's definitely str, but that's inexpressible @overload - def PlaySound(sound: Optional[bytes], flags: Literal[4]) -> None: ... + def PlaySound(sound: bytes | None, flags: Literal[4]) -> None: ... @overload - def PlaySound(sound: Optional[Union[str, bytes]], flags: int) -> None: ... + def PlaySound(sound: str | bytes | None, flags: int) -> None: ... def MessageBeep(type: int = ...) -> None: ... diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index ba85292b8a5e..e05af4709148 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -8,7 +8,7 @@ from .util import FileWrapper _exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] -def format_date_time(timestamp: Optional[float]) -> str: ... # undocumented +def format_date_time(timestamp: float | None) -> str: ... # undocumented def read_environ() -> Dict[str, str]: ... class BaseHandler: @@ -19,14 +19,14 @@ class BaseHandler: origin_server: bool http_version: str - server_software: Optional[str] + server_software: str | None os_environ: MutableMapping[str, str] - wsgi_file_wrapper: Optional[Type[FileWrapper]] + wsgi_file_wrapper: Type[FileWrapper] | None headers_class: Type[Headers] # undocumented - traceback_limit: Optional[int] + traceback_limit: int | None error_status: str error_headers: List[Tuple[str, str]] error_body: bytes @@ -37,7 +37,7 @@ class BaseHandler: def set_content_length(self) -> None: ... def cleanup_headers(self) -> None: ... def start_response( - self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_exc_info] = ... + self, status: str, headers: List[Tuple[str, str]], exc_info: _exc_info | None = ... ) -> Callable[[bytes], None]: ... def send_preamble(self) -> None: ... def write(self, data: bytes) -> None: ... diff --git a/stdlib/wsgiref/headers.pyi b/stdlib/wsgiref/headers.pyi index 71b1ea8f9c38..2c7b9526dfee 100644 --- a/stdlib/wsgiref/headers.pyi +++ b/stdlib/wsgiref/headers.pyi @@ -5,20 +5,20 @@ _HeaderList = List[Tuple[str, str]] tspecials: Pattern[str] # undocumented class Headers: - def __init__(self, headers: Optional[_HeaderList] = ...) -> None: ... + def __init__(self, headers: _HeaderList | None = ...) -> None: ... def __len__(self) -> int: ... def __setitem__(self, name: str, val: str) -> None: ... def __delitem__(self, name: str) -> None: ... - def __getitem__(self, name: str) -> Optional[str]: ... + def __getitem__(self, name: str) -> str | None: ... def __contains__(self, name: str) -> bool: ... def get_all(self, name: str) -> List[str]: ... @overload def get(self, name: str, default: str) -> str: ... @overload - def get(self, name: str, default: Optional[str] = ...) -> Optional[str]: ... + def get(self, name: str, default: str | None = ...) -> str | None: ... def keys(self) -> List[str]: ... def values(self) -> List[str]: ... def items(self) -> _HeaderList: ... def __bytes__(self) -> bytes: ... def setdefault(self, name: str, value: str) -> str: ... - def add_header(self, _name: str, _value: Optional[str], **_params: Optional[str]) -> None: ... + def add_header(self, _name: str, _value: str | None, **_params: str | None) -> None: ... diff --git a/stdlib/wsgiref/simple_server.pyi b/stdlib/wsgiref/simple_server.pyi index 14a20bab5709..9df34cb951dc 100644 --- a/stdlib/wsgiref/simple_server.pyi +++ b/stdlib/wsgiref/simple_server.pyi @@ -13,11 +13,11 @@ class ServerHandler(SimpleHandler): # undocumented def close(self) -> None: ... class WSGIServer(HTTPServer): - application: Optional[WSGIApplication] + application: WSGIApplication | None base_environ: WSGIEnvironment # only available after call to setup_environ() def setup_environ(self) -> None: ... - def get_app(self) -> Optional[WSGIApplication]: ... - def set_app(self, application: Optional[WSGIApplication]) -> None: ... + def get_app(self) -> WSGIApplication | None: ... + def set_app(self, application: WSGIApplication | None) -> None: ... class WSGIRequestHandler(BaseHTTPRequestHandler): server_version: str diff --git a/stdlib/wsgiref/util.pyi b/stdlib/wsgiref/util.pyi index 3498f6bcea1f..65560c349484 100644 --- a/stdlib/wsgiref/util.pyi +++ b/stdlib/wsgiref/util.pyi @@ -14,6 +14,6 @@ class FileWrapper: def guess_scheme(environ: WSGIEnvironment) -> str: ... def application_uri(environ: WSGIEnvironment) -> str: ... def request_uri(environ: WSGIEnvironment, include_query: bool = ...) -> str: ... -def shift_path_info(environ: WSGIEnvironment) -> Optional[str]: ... +def shift_path_info(environ: WSGIEnvironment) -> str | None: ... def setup_testing_defaults(environ: WSGIEnvironment) -> None: ... def is_hop_by_hop(header_name: str) -> bool: ... diff --git a/stdlib/wsgiref/validate.pyi b/stdlib/wsgiref/validate.pyi index 309ca74c9150..3372f73d7991 100644 --- a/stdlib/wsgiref/validate.pyi +++ b/stdlib/wsgiref/validate.pyi @@ -36,8 +36,8 @@ class IteratorWrapper: original_iterator: Iterator[bytes] iterator: Iterator[bytes] closed: bool - check_start_response: Optional[bool] - def __init__(self, wsgi_iterator: Iterator[bytes], check_start_response: Optional[bool]) -> None: ... + check_start_response: bool | None + def __init__(self, wsgi_iterator: Iterator[bytes], check_start_response: bool | None) -> None: ... def __iter__(self) -> IteratorWrapper: ... def __next__(self) -> bytes: ... def close(self) -> None: ... diff --git a/stdlib/xml/dom/domreg.pyi b/stdlib/xml/dom/domreg.pyi index bf63ff09e106..cbd861f3709f 100644 --- a/stdlib/xml/dom/domreg.pyi +++ b/stdlib/xml/dom/domreg.pyi @@ -6,5 +6,5 @@ registered: Dict[str, Callable[[], DOMImplementation]] def registerDOMImplementation(name: str, factory: Callable[[], DOMImplementation]) -> None: ... def getDOMImplementation( - name: Optional[str] = ..., features: Union[str, Iterable[Tuple[str, Optional[str]]]] = ... + name: str | None = ..., features: str | Iterable[Tuple[str, str | None]] = ... ) -> DOMImplementation: ... diff --git a/stdlib/xml/dom/minicompat.pyi b/stdlib/xml/dom/minicompat.pyi index aa8efd03b19f..3dcfe095ea93 100644 --- a/stdlib/xml/dom/minicompat.pyi +++ b/stdlib/xml/dom/minicompat.pyi @@ -6,7 +6,7 @@ StringTypes: Tuple[Type[str]] class NodeList(List[_T]): length: int - def item(self, index: int) -> Optional[_T]: ... + def item(self, index: int) -> _T | None: ... class EmptyNodeList(Tuple[Any, ...]): length: int diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index a9ae79c01902..547e88ee490d 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -5,25 +5,25 @@ from typing import IO, Any, Optional, Union from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS from xml.sax.xmlreader import XMLReader -def parse(file: Union[str, IO[Any]], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... -def parseString(string: Union[str, bytes], parser: Optional[XMLReader] = ...): ... +def parse(file: str | IO[Any], parser: XMLReader | None = ..., bufsize: int | None = ...): ... +def parseString(string: str | bytes, parser: XMLReader | None = ...): ... def getDOMImplementation(features=...): ... class Node(xml.dom.Node): - namespaceURI: Optional[str] + namespaceURI: str | None parentNode: Any ownerDocument: Any nextSibling: Any previousSibling: Any prefix: Any if sys.version_info >= (3, 9): - def toxml(self, encoding: Optional[Any] = ..., standalone: Optional[Any] = ...): ... + def toxml(self, encoding: Any | None = ..., standalone: Any | None = ...): ... def toprettyxml( - self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ..., standalone: Optional[Any] = ... + self, indent: str = ..., newl: str = ..., encoding: Any | None = ..., standalone: Any | None = ... ): ... else: - def toxml(self, encoding: Optional[Any] = ...): ... - def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ... + def toxml(self, encoding: Any | None = ...): ... + def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Any | None = ...): ... def hasChildNodes(self) -> bool: ... def insertBefore(self, newChild, refChild): ... def appendChild(self, node): ... @@ -56,14 +56,14 @@ class Attr(Node): attributes: Any specified: bool ownerElement: Any - namespaceURI: Optional[str] + namespaceURI: str | None childNodes: Any nodeName: Any nodeValue: str value: str prefix: Any def __init__( - self, qName: str, namespaceURI: Optional[str] = ..., localName: Optional[Any] = ..., prefix: Optional[Any] = ... + self, qName: str, namespaceURI: str | None = ..., localName: Any | None = ..., prefix: Any | None = ... ) -> None: ... def unlink(self) -> None: ... @@ -76,7 +76,7 @@ class NamedNodeMap: def keys(self): ... def keysNS(self): ... def values(self): ... - def get(self, name, value: Optional[Any] = ...): ... + def get(self, name, value: Any | None = ...): ... def __len__(self) -> int: ... def __eq__(self, other: Any) -> bool: ... def __ge__(self, other: Any) -> bool: ... @@ -107,11 +107,11 @@ class Element(Node): parentNode: Any tagName: str prefix: Any - namespaceURI: Optional[str] + namespaceURI: str | None childNodes: Any nextSibling: Any def __init__( - self, tagName, namespaceURI: Optional[str] = ..., prefix: Optional[Any] = ..., localName: Optional[Any] = ... + self, tagName, namespaceURI: str | None = ..., prefix: Any | None = ..., localName: Any | None = ... ) -> None: ... def unlink(self) -> None: ... def getAttribute(self, attname): ... @@ -301,11 +301,11 @@ class Document(Node, DocumentLS): indent: str = ..., addindent: str = ..., newl: str = ..., - encoding: Optional[Any] = ..., - standalone: Optional[Any] = ..., + encoding: Any | None = ..., + standalone: Any | None = ..., ) -> None: ... else: def writexml( - self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Optional[Any] = ... + self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Any | None = ... ) -> None: ... def renameNode(self, n, namespaceURI: str, name): ... diff --git a/stdlib/xml/dom/pulldom.pyi b/stdlib/xml/dom/pulldom.pyi index 3dfd90b6eac1..65dd761bcbaa 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -12,14 +12,14 @@ IGNORABLE_WHITESPACE: str CHARACTERS: str class PullDOM(ContentHandler): - document: Optional[Any] + document: Any | None documentFactory: Any firstEvent: Any lastEvent: Any elementStack: Any push: Any pending_events: Any - def __init__(self, documentFactory: Optional[Any] = ...) -> None: ... + def __init__(self, documentFactory: Any | None = ...) -> None: ... def pop(self): ... def setDocumentLocator(self, locator) -> None: ... def startPrefixMapping(self, prefix, uri) -> None: ... @@ -66,6 +66,6 @@ class SAX2DOM(PullDOM): default_bufsize: int def parse( - stream_or_string: str | IO[bytes], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ... + stream_or_string: str | IO[bytes], parser: XMLReader | None = ..., bufsize: int | None = ... ) -> DOMEventStream: ... -def parseString(string: str, parser: Optional[XMLReader] = ...) -> DOMEventStream: ... +def parseString(string: str, parser: XMLReader | None = ...) -> DOMEventStream: ... diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 4aa0173fa82f..02bb217ecead 100644 --- a/stdlib/xml/etree/ElementInclude.pyi +++ b/stdlib/xml/etree/ElementInclude.pyi @@ -8,7 +8,7 @@ XINCLUDE_FALLBACK: str class FatalIncludeError(SyntaxError): ... -def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[str] = ...) -> Union[str, Element]: ... +def default_loader(href: str | bytes | int, parse: str, encoding: str | None = ...) -> str | Element: ... # TODO: loader is of type default_loader ie it takes a callable that has the # same signature as default_loader. But default_loader has a keyword argument @@ -16,10 +16,10 @@ def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[ if sys.version_info >= (3, 9): def include( elem: Element, - loader: Optional[Callable[..., Union[str, Element]]] = ..., - base_url: Optional[str] = ..., - max_depth: Optional[int] = ..., + loader: Callable[..., str | Element] | None = ..., + base_url: str | None = ..., + max_depth: int | None = ..., ) -> None: ... else: - def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... + def include(elem: Element, loader: Callable[..., str | Element] | None = ...) -> None: ... diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index de49ffcf1209..076cb867be70 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -7,7 +7,7 @@ _token = Tuple[str, str] _next = Callable[[], _token] _callback = Callable[[_SelectorContext, List[Element]], Generator[Element, None, None]] -def xpath_tokenizer(pattern: str, namespaces: Optional[Dict[str, str]] = ...) -> Generator[_token, None, None]: ... +def xpath_tokenizer(pattern: str, namespaces: Dict[str, str] | None = ...) -> Generator[_token, None, None]: ... def get_parent_map(context: _SelectorContext) -> Dict[Element, Element]: ... def prepare_child(next: _next, token: _token) -> _callback: ... def prepare_star(next: _next, token: _token) -> _callback: ... @@ -19,15 +19,15 @@ def prepare_predicate(next: _next, token: _token) -> _callback: ... ops: Dict[str, Callable[[_next, _token], _callback]] class _SelectorContext: - parent_map: Optional[Dict[Element, Element]] + parent_map: Dict[Element, Element] | None root: Element def __init__(self, root: Element) -> None: ... _T = TypeVar("_T") -def iterfind(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Generator[Element, None, None]: ... -def find(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Optional[Element]: ... -def findall(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... +def iterfind(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> Generator[Element, None, None]: ... +def find(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> Element | None: ... +def findall(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> List[Element]: ... def findtext( - elem: Element, path: str, default: Optional[_T] = ..., namespaces: Optional[Dict[str, str]] = ... -) -> Union[_T, str]: ... + elem: Element, path: str, default: _T | None = ..., namespaces: Dict[str, str] | None = ... +) -> _T | str: ... diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 8251071e833a..f834186c9e1d 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -35,62 +35,62 @@ def iselement(element: object) -> bool: ... if sys.version_info >= (3, 8): @overload def canonicalize( - xml_data: Optional[Union[str, bytes]] = ..., + xml_data: str | bytes | None = ..., *, out: None = ..., - from_file: Optional[_File] = ..., + from_file: _File | None = ..., with_comments: bool = ..., strip_text: bool = ..., rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., + qname_aware_tags: Iterable[str] | None = ..., + qname_aware_attrs: Iterable[str] | None = ..., + exclude_attrs: Iterable[str] | None = ..., + exclude_tags: Iterable[str] | None = ..., ) -> str: ... @overload def canonicalize( - xml_data: Optional[Union[str, bytes]] = ..., + xml_data: str | bytes | None = ..., *, out: SupportsWrite[str], - from_file: Optional[_File] = ..., + from_file: _File | None = ..., with_comments: bool = ..., strip_text: bool = ..., rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., + qname_aware_tags: Iterable[str] | None = ..., + qname_aware_attrs: Iterable[str] | None = ..., + exclude_attrs: Iterable[str] | None = ..., + exclude_tags: Iterable[str] | None = ..., ) -> None: ... class Element(MutableSequence[Element]): tag: str attrib: Dict[str, str] - text: Optional[str] - tail: Optional[str] - def __init__(self, tag: Union[str, Callable[..., Element]], attrib: Dict[str, str] = ..., **extra: str) -> None: ... + text: str | None + tail: str | None + def __init__(self, tag: str | Callable[..., Element], attrib: Dict[str, str] = ..., **extra: str) -> None: ... def append(self, __subelement: Element) -> None: ... def clear(self) -> None: ... def extend(self, __elements: Iterable[Element]) -> None: ... - def find(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Optional[Element]: ... - def findall(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... + def find(self, path: str, namespaces: Dict[str, str] | None = ...) -> Element | None: ... + def findall(self, path: str, namespaces: Dict[str, str] | None = ...) -> List[Element]: ... @overload - def findtext(self, path: str, default: None = ..., namespaces: Optional[Dict[str, str]] = ...) -> Optional[str]: ... + def findtext(self, path: str, default: None = ..., namespaces: Dict[str, str] | None = ...) -> str | None: ... @overload - def findtext(self, path: str, default: _T, namespaces: Optional[Dict[str, str]] = ...) -> Union[_T, str]: ... + def findtext(self, path: str, default: _T, namespaces: Dict[str, str] | None = ...) -> _T | str: ... @overload - def get(self, key: str, default: None = ...) -> Optional[str]: ... + def get(self, key: str, default: None = ...) -> str | None: ... @overload - def get(self, key: str, default: _T) -> Union[str, _T]: ... + def get(self, key: str, default: _T) -> str | _T: ... def insert(self, __index: int, __subelement: Element) -> None: ... def items(self) -> ItemsView[str, str]: ... - def iter(self, tag: Optional[str] = ...) -> Generator[Element, None, None]: ... - def iterfind(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Generator[Element, None, None]: ... + def iter(self, tag: str | None = ...) -> Generator[Element, None, None]: ... + def iterfind(self, path: str, namespaces: Dict[str, str] | None = ...) -> Generator[Element, None, None]: ... def itertext(self) -> Generator[str, None, None]: ... def keys(self) -> KeysView[str]: ... def makeelement(self, __tag: str, __attrib: Dict[str, str]) -> Element: ... def remove(self, __subelement: Element) -> None: ... def set(self, __key: str, __value: str) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... @overload def __getitem__(self, i: int) -> Element: ... @overload @@ -102,39 +102,39 @@ class Element(MutableSequence[Element]): def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ... if sys.version_info < (3, 9): def getchildren(self) -> List[Element]: ... - def getiterator(self, tag: Optional[str] = ...) -> List[Element]: ... + def getiterator(self, tag: str | None = ...) -> List[Element]: ... def SubElement(parent: Element, tag: str, attrib: Dict[str, str] = ..., **extra: str) -> Element: ... -def Comment(text: Optional[str] = ...) -> Element: ... -def ProcessingInstruction(target: str, text: Optional[str] = ...) -> Element: ... +def Comment(text: str | None = ...) -> Element: ... +def ProcessingInstruction(target: str, text: str | None = ...) -> Element: ... PI: Callable[..., Element] class QName: text: str - def __init__(self, text_or_uri: str, tag: Optional[str] = ...) -> None: ... + def __init__(self, text_or_uri: str, tag: str | None = ...) -> None: ... class ElementTree: - def __init__(self, element: Optional[Element] = ..., file: Optional[_File] = ...) -> None: ... + def __init__(self, element: Element | None = ..., file: _File | None = ...) -> None: ... def getroot(self) -> Element: ... - def parse(self, source: _File, parser: Optional[XMLParser] = ...) -> Element: ... - def iter(self, tag: Optional[str] = ...) -> Generator[Element, None, None]: ... + def parse(self, source: _File, parser: XMLParser | None = ...) -> Element: ... + def iter(self, tag: str | None = ...) -> Generator[Element, None, None]: ... if sys.version_info < (3, 9): - def getiterator(self, tag: Optional[str] = ...) -> List[Element]: ... - def find(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Optional[Element]: ... + def getiterator(self, tag: str | None = ...) -> List[Element]: ... + def find(self, path: str, namespaces: Dict[str, str] | None = ...) -> Element | None: ... @overload - def findtext(self, path: str, default: None = ..., namespaces: Optional[Dict[str, str]] = ...) -> Optional[str]: ... + def findtext(self, path: str, default: None = ..., namespaces: Dict[str, str] | None = ...) -> str | None: ... @overload - def findtext(self, path: str, default: _T, namespaces: Optional[Dict[str, str]] = ...) -> Union[_T, str]: ... - def findall(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... - def iterfind(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Generator[Element, None, None]: ... + def findtext(self, path: str, default: _T, namespaces: Dict[str, str] | None = ...) -> _T | str: ... + def findall(self, path: str, namespaces: Dict[str, str] | None = ...) -> List[Element]: ... + def iterfind(self, path: str, namespaces: Dict[str, str] | None = ...) -> Generator[Element, None, None]: ... def write( self, file_or_filename: _File, - encoding: Optional[str] = ..., - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[str] = ..., - method: Optional[str] = ..., + encoding: str | None = ..., + xml_declaration: bool | None = ..., + default_namespace: str | None = ..., + method: str | None = ..., *, short_empty_elements: bool = ..., ) -> None: ... @@ -147,110 +147,110 @@ if sys.version_info >= (3, 8): def tostring( element: Element, encoding: None = ..., - method: Optional[str] = ..., + method: str | None = ..., *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[str] = ..., + xml_declaration: bool | None = ..., + default_namespace: str | None = ..., short_empty_elements: bool = ..., ) -> bytes: ... @overload def tostring( element: Element, encoding: Literal["unicode"], - method: Optional[str] = ..., + method: str | None = ..., *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[str] = ..., + xml_declaration: bool | None = ..., + default_namespace: str | None = ..., short_empty_elements: bool = ..., ) -> str: ... @overload def tostring( element: Element, encoding: str, - method: Optional[str] = ..., + method: str | None = ..., *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[str] = ..., + xml_declaration: bool | None = ..., + default_namespace: str | None = ..., short_empty_elements: bool = ..., ) -> Any: ... @overload def tostringlist( element: Element, encoding: None = ..., - method: Optional[str] = ..., + method: str | None = ..., *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[str] = ..., + xml_declaration: bool | None = ..., + default_namespace: str | None = ..., short_empty_elements: bool = ..., ) -> List[bytes]: ... @overload def tostringlist( element: Element, encoding: Literal["unicode"], - method: Optional[str] = ..., + method: str | None = ..., *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[str] = ..., + xml_declaration: bool | None = ..., + default_namespace: str | None = ..., short_empty_elements: bool = ..., ) -> List[str]: ... @overload def tostringlist( element: Element, encoding: str, - method: Optional[str] = ..., + method: str | None = ..., *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[str] = ..., + xml_declaration: bool | None = ..., + default_namespace: str | None = ..., short_empty_elements: bool = ..., ) -> List[Any]: ... else: @overload def tostring( - element: Element, encoding: None = ..., method: Optional[str] = ..., *, short_empty_elements: bool = ... + element: Element, encoding: None = ..., method: str | None = ..., *, short_empty_elements: bool = ... ) -> bytes: ... @overload def tostring( - element: Element, encoding: Literal["unicode"], method: Optional[str] = ..., *, short_empty_elements: bool = ... + element: Element, encoding: Literal["unicode"], method: str | None = ..., *, short_empty_elements: bool = ... ) -> str: ... @overload - def tostring(element: Element, encoding: str, method: Optional[str] = ..., *, short_empty_elements: bool = ...) -> Any: ... + def tostring(element: Element, encoding: str, method: str | None = ..., *, short_empty_elements: bool = ...) -> Any: ... @overload def tostringlist( - element: Element, encoding: None = ..., method: Optional[str] = ..., *, short_empty_elements: bool = ... + element: Element, encoding: None = ..., method: str | None = ..., *, short_empty_elements: bool = ... ) -> List[bytes]: ... @overload def tostringlist( - element: Element, encoding: Literal["unicode"], method: Optional[str] = ..., *, short_empty_elements: bool = ... + element: Element, encoding: Literal["unicode"], method: str | None = ..., *, short_empty_elements: bool = ... ) -> List[str]: ... @overload def tostringlist( - element: Element, encoding: str, method: Optional[str] = ..., *, short_empty_elements: bool = ... + element: Element, encoding: str, method: str | None = ..., *, short_empty_elements: bool = ... ) -> List[Any]: ... def dump(elem: Element) -> None: ... if sys.version_info >= (3, 9): - def indent(tree: Union[Element, ElementTree], space: str = ..., level: int = ...) -> None: ... + def indent(tree: Element | ElementTree, space: str = ..., level: int = ...) -> None: ... -def parse(source: _File, parser: Optional[XMLParser] = ...) -> ElementTree: ... +def parse(source: _File, parser: XMLParser | None = ...) -> ElementTree: ... def iterparse( - source: _File, events: Optional[Sequence[str]] = ..., parser: Optional[XMLParser] = ... + source: _File, events: Sequence[str] | None = ..., parser: XMLParser | None = ... ) -> Iterator[Tuple[str, Any]]: ... class XMLPullParser: - def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: Optional[XMLParser] = ...) -> None: ... + def __init__(self, events: Sequence[str] | None = ..., *, _parser: XMLParser | None = ...) -> None: ... def feed(self, data: bytes) -> None: ... def close(self) -> None: ... def read_events(self) -> Iterator[Tuple[str, Element]]: ... -def XML(text: Union[str, bytes], parser: Optional[XMLParser] = ...) -> Element: ... -def XMLID(text: Union[str, bytes], parser: Optional[XMLParser] = ...) -> Tuple[Element, Dict[str, Element]]: ... +def XML(text: str | bytes, parser: XMLParser | None = ...) -> Element: ... +def XMLID(text: str | bytes, parser: XMLParser | None = ...) -> Tuple[Element, Dict[str, Element]]: ... # This is aliased to XML in the source. fromstring = XML -def fromstringlist(sequence: Sequence[Union[str, bytes]], parser: Optional[XMLParser] = ...) -> Element: ... +def fromstringlist(sequence: Sequence[str | bytes], parser: XMLParser | None = ...) -> Element: ... # This type is both not precise enough and too precise. The TreeBuilder # requires the elementfactory to accept tag and attrs in its args and produce @@ -264,11 +264,11 @@ def fromstringlist(sequence: Sequence[Union[str, bytes]], parser: Optional[XMLPa _ElementFactory = Callable[[Any, Dict[Any, Any]], Element] class TreeBuilder: - def __init__(self, element_factory: Optional[_ElementFactory] = ...) -> None: ... + def __init__(self, element_factory: _ElementFactory | None = ...) -> None: ... def close(self) -> Element: ... - def data(self, __data: Union[str, bytes]) -> None: ... - def start(self, __tag: Union[str, bytes], __attrs: Dict[Union[str, bytes], Union[str, bytes]]) -> Element: ... - def end(self, __tag: Union[str, bytes]) -> Element: ... + def data(self, __data: str | bytes) -> None: ... + def start(self, __tag: str | bytes, __attrs: Dict[str | bytes, str | bytes]) -> Element: ... + def end(self, __tag: str | bytes) -> Element: ... if sys.version_info >= (3, 8): class C14NWriterTarget: @@ -279,10 +279,10 @@ if sys.version_info >= (3, 8): with_comments: bool = ..., strip_text: bool = ..., rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., + qname_aware_tags: Iterable[str] | None = ..., + qname_aware_attrs: Iterable[str] | None = ..., + exclude_attrs: Iterable[str] | None = ..., + exclude_tags: Iterable[str] | None = ..., ) -> None: ... class XMLParser: @@ -292,9 +292,9 @@ class XMLParser: entity: Any version: str if sys.version_info >= (3, 8): - def __init__(self, *, target: Any = ..., encoding: Optional[str] = ...) -> None: ... + def __init__(self, *, target: Any = ..., encoding: str | None = ...) -> None: ... else: - def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> None: ... + def __init__(self, html: int = ..., target: Any = ..., encoding: str | None = ...) -> None: ... def doctype(self, __name: str, __pubid: str, __system: str) -> None: ... def close(self) -> Any: ... - def feed(self, __data: Union[str, bytes]) -> None: ... + def feed(self, __data: str | bytes) -> None: ... diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index 854a552d3e53..e778f309bb37 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -4,7 +4,7 @@ from xml.sax.handler import ContentHandler, ErrorHandler from xml.sax.xmlreader import Locator, XMLReader class SAXException(Exception): - def __init__(self, msg: str, exception: Optional[Exception] = ...) -> None: ... + def __init__(self, msg: str, exception: Exception | None = ...) -> None: ... def getMessage(self) -> str: ... def getException(self) -> Exception: ... def __getitem__(self, ix: Any) -> NoReturn: ... @@ -28,6 +28,6 @@ if sys.version_info >= (3, 8): else: def make_parser(parser_list: List[str] = ...) -> XMLReader: ... -def parse(source: Union[str, IO[str], IO[bytes]], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... -def parseString(string: Union[bytes, str], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... +def parse(source: str | IO[str] | IO[bytes], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... +def parseString(string: bytes | str, handler: ContentHandler, errorHandler: ErrorHandler | None = ...) -> None: ... def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/stdlib/xml/sax/saxutils.pyi b/stdlib/xml/sax/saxutils.pyi index 066097fb5a53..0c08198b2c87 100644 --- a/stdlib/xml/sax/saxutils.pyi +++ b/stdlib/xml/sax/saxutils.pyi @@ -11,7 +11,7 @@ def quoteattr(data: str, entities: Mapping[str, str] = ...) -> str: ... class XMLGenerator(handler.ContentHandler): def __init__( self, - out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., + out: TextIOBase | RawIOBase | StreamWriter | StreamReaderWriter | SupportsWrite[str] | None = ..., encoding: str = ..., short_empty_elements: bool = ..., ) -> None: ... @@ -28,7 +28,7 @@ class XMLGenerator(handler.ContentHandler): def processingInstruction(self, target, data): ... class XMLFilterBase(xmlreader.XMLReader): - def __init__(self, parent: Optional[xmlreader.XMLReader] = ...) -> None: ... + def __init__(self, parent: xmlreader.XMLReader | None = ...) -> None: ... def error(self, exception): ... def fatalError(self, exception): ... def warning(self, exception): ... diff --git a/stdlib/xml/sax/xmlreader.pyi b/stdlib/xml/sax/xmlreader.pyi index 9dd6b75fd52f..1cba860017a5 100644 --- a/stdlib/xml/sax/xmlreader.pyi +++ b/stdlib/xml/sax/xmlreader.pyi @@ -32,7 +32,7 @@ class Locator: def getSystemId(self): ... class InputSource: - def __init__(self, system_id: Optional[str] = ...) -> None: ... + def __init__(self, system_id: str | None = ...) -> None: ... def setPublicId(self, public_id): ... def getPublicId(self): ... def setSystemId(self, system_id): ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 8844b875950e..d67434b66df8 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -63,7 +63,7 @@ def _strftime(value: _XMLDate) -> str: ... # undocumented class DateTime: value: str # undocumented - def __init__(self, value: Union[int, str, datetime, time.struct_time, Tuple[int, ...]] = ...) -> None: ... + def __init__(self, value: int | str | datetime | time.struct_time | Tuple[int, ...] = ...) -> None: ... def __lt__(self, other: _DateTimeComparable) -> bool: ... def __le__(self, other: _DateTimeComparable) -> bool: ... def __gt__(self, other: _DateTimeComparable) -> bool: ... @@ -80,7 +80,7 @@ def _datetime_type(data: str) -> datetime: ... # undocumented class Binary: data: bytes - def __init__(self, data: Optional[bytes] = ...) -> None: ... + def __init__(self, data: bytes | None = ...) -> None: ... def decode(self, data: bytes) -> None: ... def encode(self, out: SupportsWrite[str]) -> None: ... @@ -90,7 +90,7 @@ WRAPPERS: Tuple[Type[DateTime], Type[Binary]] # undocumented class ExpatParser: # undocumented def __init__(self, target: Unmarshaller) -> None: ... - def feed(self, data: Union[str, bytes]) -> None: ... + def feed(self, data: str | bytes) -> None: ... def close(self) -> None: ... class Marshaller: @@ -101,11 +101,11 @@ class Marshaller: memo: Dict[Any, None] data: None - encoding: Optional[str] + encoding: str | None allow_none: bool - def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ... - def dumps(self, values: Union[Fault, Iterable[_Marshallable]]) -> str: ... - def __dump(self, value: Union[_Marshallable], write: Callable[[str], Any]) -> None: ... # undocumented + def __init__(self, encoding: str | None = ..., allow_none: bool = ...) -> None: ... + def dumps(self, values: Fault | Iterable[_Marshallable]) -> str: ... + def __dump(self, value: _Marshallable, write: Callable[[str], Any]) -> None: ... # undocumented def dump_nil(self, value: None, write: Callable[[str], Any]) -> None: ... def dump_bool(self, value: bool, write: Callable[[str], Any]) -> None: ... def dump_long(self, value: int, write: Callable[[str], Any]) -> None: ... @@ -124,19 +124,19 @@ class Unmarshaller: dispatch: Dict[str, Callable[[Unmarshaller, str], None]] = ... - _type: Optional[str] + _type: str | None _stack: List[_Marshallable] _marks: List[int] _data: List[str] _value: bool - _methodname: Optional[str] + _methodname: str | None _encoding: str append: Callable[[Any], None] _use_datetime: bool _use_builtin_types: bool def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ... def close(self) -> Tuple[_Marshallable, ...]: ... - def getmethodname(self) -> Optional[str]: ... + def getmethodname(self) -> str | None: ... def xml(self, encoding: str, standalone: Any) -> None: ... # Standalone is ignored def start(self, tag: str, attrs: Dict[str, str]) -> None: ... def data(self, text: str) -> None: ... @@ -180,21 +180,21 @@ class MultiCall: def __call__(self) -> MultiCallIterator: ... # A little white lie -FastMarshaller: Optional[Marshaller] -FastParser: Optional[ExpatParser] -FastUnmarshaller: Optional[Unmarshaller] +FastMarshaller: Marshaller | None +FastParser: ExpatParser | None +FastUnmarshaller: Unmarshaller | None def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[ExpatParser, Unmarshaller]: ... def dumps( - params: Union[Fault, Tuple[_Marshallable, ...]], - methodname: Optional[str] = ..., - methodresponse: Optional[bool] = ..., - encoding: Optional[str] = ..., + params: Fault | Tuple[_Marshallable, ...], + methodname: str | None = ..., + methodresponse: bool | None = ..., + encoding: str | None = ..., allow_none: bool = ..., ) -> str: ... def loads( data: str, use_datetime: bool = ..., use_builtin_types: bool = ... -) -> Tuple[Tuple[_Marshallable, ...], Optional[str]]: ... +) -> Tuple[Tuple[_Marshallable, ...], str | None]: ... def gzip_encode(data: bytes) -> bytes: ... # undocumented def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ... # undocumented @@ -216,11 +216,11 @@ class Transport: user_agent: str = ... accept_gzip_encoding: bool = ... - encode_threshold: Optional[int] = ... + encode_threshold: int | None = ... _use_datetime: bool _use_builtin_types: bool - _connection: Tuple[Optional[_HostType], Optional[http.client.HTTPConnection]] + _connection: Tuple[_HostType | None, http.client.HTTPConnection | None] _headers: List[Tuple[str, str]] _extra_headers: List[Tuple[str, str]] @@ -252,10 +252,10 @@ class SafeTransport(Transport): use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ..., - context: Optional[Any] = ..., + context: Any | None = ..., ) -> None: ... else: - def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Optional[Any] = ...) -> None: ... + def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Any | None = ...) -> None: ... def make_connection(self, host: _HostType) -> http.client.HTTPSConnection: ... class ServerProxy: @@ -271,28 +271,28 @@ class ServerProxy: def __init__( self, uri: str, - transport: Optional[Transport] = ..., - encoding: Optional[str] = ..., + transport: Transport | None = ..., + encoding: str | None = ..., verbose: bool = ..., allow_none: bool = ..., use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ..., - context: Optional[Any] = ..., + context: Any | None = ..., ) -> None: ... else: def __init__( self, uri: str, - transport: Optional[Transport] = ..., - encoding: Optional[str] = ..., + transport: Transport | None = ..., + encoding: str | None = ..., verbose: bool = ..., allow_none: bool = ..., use_datetime: bool = ..., use_builtin_types: bool = ..., *, - context: Optional[Any] = ..., + context: Any | None = ..., ) -> None: ... def __getattr__(self, name: str) -> _Method: ... @overload @@ -300,10 +300,10 @@ class ServerProxy: @overload def __call__(self, attr: Literal["transport"]) -> Transport: ... @overload - def __call__(self, attr: str) -> Union[Callable[[], None], Transport]: ... + def __call__(self, attr: str) -> Callable[[], None] | Transport: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __close(self) -> None: ... # undocumented def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ... # undocumented diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index f6a097d91d06..5faaff5e9565 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -39,27 +39,25 @@ def list_public_methods(obj: Any) -> List[str]: ... # undocumented class SimpleXMLRPCDispatcher: # undocumented funcs: Dict[str, _DispatchProtocol] - instance: Optional[Any] + instance: Any | None allow_none: bool encoding: str use_builtin_types: bool - def __init__(self, allow_none: bool = ..., encoding: Optional[str] = ..., use_builtin_types: bool = ...) -> None: ... + def __init__(self, allow_none: bool = ..., encoding: str | None = ..., use_builtin_types: bool = ...) -> None: ... def register_instance(self, instance: Any, allow_dotted_names: bool = ...) -> None: ... if sys.version_info >= (3, 7): def register_function( - self, function: Optional[_DispatchProtocol] = ..., name: Optional[str] = ... + self, function: _DispatchProtocol | None = ..., name: str | None = ... ) -> Callable[..., Any]: ... else: - def register_function(self, function: _DispatchProtocol, name: Optional[str] = ...) -> Callable[..., Any]: ... + def register_function(self, function: _DispatchProtocol, name: str | None = ...) -> Callable[..., Any]: ... def register_introspection_functions(self) -> None: ... def register_multicall_functions(self) -> None: ... def _marshaled_dispatch( self, data: str, - dispatch_method: Optional[ - Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]] - ] = ..., - path: Optional[Any] = ..., + dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ..., + path: Any | None = ..., ) -> str: ... # undocumented def system_listMethods(self) -> List[str]: ... # undocumented def system_methodSignature(self, method_name: str) -> str: ... # undocumented @@ -75,9 +73,9 @@ class SimpleXMLRPCRequestHandler(http.server.BaseHTTPRequestHandler): def accept_encodings(self) -> Dict[str, float]: ... def is_rpc_path_valid(self) -> bool: ... def do_POST(self) -> None: ... - def decode_request_content(self, data: bytes) -> Optional[bytes]: ... + def decode_request_content(self, data: bytes) -> bytes | None: ... def report_404(self) -> None: ... - def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ... + def log_request(self, code: int | str = ..., size: int | str = ...) -> None: ... class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher): @@ -89,7 +87,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher): requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ..., ) -> None: ... @@ -105,7 +103,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ..., ) -> None: ... @@ -114,20 +112,18 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Optional[ - Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]] - ] = ..., - path: Optional[Any] = ..., + dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ..., + path: Any | None = ..., ) -> str: ... class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher): - def __init__(self, allow_none: bool = ..., encoding: Optional[str] = ..., use_builtin_types: bool = ...) -> None: ... + def __init__(self, allow_none: bool = ..., encoding: str | None = ..., use_builtin_types: bool = ...) -> None: ... def handle_xmlrpc(self, request_text: str) -> None: ... def handle_get(self) -> None: ... - def handle_request(self, request_text: Optional[str] = ...) -> None: ... + def handle_request(self, request_text: str | None = ...) -> None: ... class ServerHTMLDoc(pydoc.HTMLDoc): # undocumented - def docroutine(self, object: object, name: str, mod: Optional[str] = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., cl: Optional[type] = ...) -> str: ... # type: ignore + def docroutine(self, object: object, name: str, mod: str | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., cl: type | None = ...) -> str: ... # type: ignore def docserver(self, server_name: str, package_documentation: str, methods: Dict[str, str]) -> str: ... class XMLRPCDocGenerator: # undocumented @@ -151,7 +147,7 @@ class DocXMLRPCServer(SimpleXMLRPCServer, XMLRPCDocGenerator): requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ..., ) -> None: ... diff --git a/stdlib/zipapp.pyi b/stdlib/zipapp.pyi index e1b38e9711b6..986dbe145f9a 100644 --- a/stdlib/zipapp.pyi +++ b/stdlib/zipapp.pyi @@ -9,16 +9,16 @@ class ZipAppError(ValueError): ... if sys.version_info >= (3, 7): def create_archive( source: _Path, - target: Optional[_Path] = ..., - interpreter: Optional[str] = ..., - main: Optional[str] = ..., - filter: Optional[Callable[[Path], bool]] = ..., + target: _Path | None = ..., + interpreter: str | None = ..., + main: str | None = ..., + filter: Callable[[Path], bool] | None = ..., compressed: bool = ..., ) -> None: ... else: def create_archive( - source: _Path, target: Optional[_Path] = ..., interpreter: Optional[str] = ..., main: Optional[str] = ... + source: _Path, target: _Path | None = ..., interpreter: str | None = ..., main: str | None = ... ) -> None: ... def get_interpreter(archive: _Path) -> str: ... diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 3a1f7a125f16..c839ce367614 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -32,13 +32,13 @@ class ZipExtFile(io.BufferedIOBase): if sys.version_info >= (3, 7): MAX_SEEK_READ: int = ... - newlines: Optional[List[bytes]] + newlines: List[bytes] | None mode: str name: str if sys.version_info >= (3, 7): @overload def __init__( - self, fileobj: _ClosableZipStream, mode: str, zipinfo: ZipInfo, pwd: Optional[bytes], close_fileobj: Literal[True] + self, fileobj: _ClosableZipStream, mode: str, zipinfo: ZipInfo, pwd: bytes | None, close_fileobj: Literal[True] ) -> None: ... @overload def __init__( @@ -46,7 +46,7 @@ class ZipExtFile(io.BufferedIOBase): fileobj: _ClosableZipStream, mode: str, zipinfo: ZipInfo, - pwd: Optional[bytes] = ..., + pwd: bytes | None = ..., *, close_fileobj: Literal[True], ) -> None: ... @@ -56,7 +56,7 @@ class ZipExtFile(io.BufferedIOBase): fileobj: _ZipStream, mode: str, zipinfo: ZipInfo, - pwd: Optional[bytes] = ..., + pwd: bytes | None = ..., close_fileobj: Literal[False] = ..., ) -> None: ... else: @@ -66,7 +66,7 @@ class ZipExtFile(io.BufferedIOBase): fileobj: _ClosableZipStream, mode: str, zipinfo: ZipInfo, - decrypter: Optional[Callable[[Sequence[int]], bytes]], + decrypter: Callable[[Sequence[int]], bytes] | None, close_fileobj: Literal[True], ) -> None: ... @overload @@ -75,7 +75,7 @@ class ZipExtFile(io.BufferedIOBase): fileobj: _ClosableZipStream, mode: str, zipinfo: ZipInfo, - decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., + decrypter: Callable[[Sequence[int]], bytes] | None = ..., *, close_fileobj: Literal[True], ) -> None: ... @@ -85,24 +85,24 @@ class ZipExtFile(io.BufferedIOBase): fileobj: _ZipStream, mode: str, zipinfo: ZipInfo, - decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., + decrypter: Callable[[Sequence[int]], bytes] | None = ..., close_fileobj: Literal[False] = ..., ) -> None: ... - def read(self, n: Optional[int] = ...) -> bytes: ... + def read(self, n: int | None = ...) -> bytes: ... def readline(self, limit: int = ...) -> bytes: ... # type: ignore def __repr__(self) -> str: ... def peek(self, n: int = ...) -> bytes: ... - def read1(self, n: Optional[int]) -> bytes: ... # type: ignore + def read1(self, n: int | None) -> bytes: ... # type: ignore class _Writer(Protocol): def write(self, __s: str) -> object: ... class ZipFile: - filename: Optional[str] + filename: str | None debug: int comment: bytes filelist: List[ZipInfo] - fp: Optional[IO[bytes]] + fp: IO[bytes] | None NameToInfo: Dict[str, ZipInfo] start_dir: int # undocumented compression: int # undocumented @@ -112,74 +112,74 @@ class ZipFile: if sys.version_info >= (3, 8): def __init__( self, - file: Union[StrPath, IO[bytes]], + file: StrPath | IO[bytes], mode: _ZipFileMode = ..., compression: int = ..., allowZip64: bool = ..., - compresslevel: Optional[int] = ..., + compresslevel: int | None = ..., *, strict_timestamps: bool = ..., ) -> None: ... elif sys.version_info >= (3, 7): def __init__( self, - file: Union[StrPath, IO[bytes]], + file: StrPath | IO[bytes], mode: _ZipFileMode = ..., compression: int = ..., allowZip64: bool = ..., - compresslevel: Optional[int] = ..., + compresslevel: int | None = ..., ) -> None: ... else: def __init__( - self, file: Union[StrPath, IO[bytes]], mode: str = ..., compression: int = ..., allowZip64: bool = ... + self, file: StrPath | IO[bytes], mode: str = ..., compression: int = ..., allowZip64: bool = ... ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def close(self) -> None: ... def getinfo(self, name: str) -> ZipInfo: ... def infolist(self) -> List[ZipInfo]: ... def namelist(self) -> List[str]: ... def open( - self, name: Union[str, ZipInfo], mode: Literal["r", "w"] = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ... + self, name: str | ZipInfo, mode: Literal["r", "w"] = ..., pwd: bytes | None = ..., *, force_zip64: bool = ... ) -> IO[bytes]: ... - def extract(self, member: Union[str, ZipInfo], path: Optional[StrPath] = ..., pwd: Optional[bytes] = ...) -> str: ... + def extract(self, member: str | ZipInfo, path: StrPath | None = ..., pwd: bytes | None = ...) -> str: ... def extractall( - self, path: Optional[StrPath] = ..., members: Optional[Iterable[str]] = ..., pwd: Optional[bytes] = ... + self, path: StrPath | None = ..., members: Iterable[str] | None = ..., pwd: bytes | None = ... ) -> None: ... - def printdir(self, file: Optional[_Writer] = ...) -> None: ... + def printdir(self, file: _Writer | None = ...) -> None: ... def setpassword(self, pwd: bytes) -> None: ... - def read(self, name: Union[str, ZipInfo], pwd: Optional[bytes] = ...) -> bytes: ... - def testzip(self) -> Optional[str]: ... + def read(self, name: str | ZipInfo, pwd: bytes | None = ...) -> bytes: ... + def testzip(self) -> str | None: ... if sys.version_info >= (3, 7): def write( self, filename: StrPath, - arcname: Optional[StrPath] = ..., - compress_type: Optional[int] = ..., - compresslevel: Optional[int] = ..., + arcname: StrPath | None = ..., + compress_type: int | None = ..., + compresslevel: int | None = ..., ) -> None: ... else: - def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ... + def write(self, filename: StrPath, arcname: StrPath | None = ..., compress_type: int | None = ...) -> None: ... if sys.version_info >= (3, 7): def writestr( self, - zinfo_or_arcname: Union[str, ZipInfo], - data: Union[bytes, str], - compress_type: Optional[int] = ..., - compresslevel: Optional[int] = ..., + zinfo_or_arcname: str | ZipInfo, + data: bytes | str, + compress_type: int | None = ..., + compresslevel: int | None = ..., ) -> None: ... else: def writestr( - self, zinfo_or_arcname: Union[str, ZipInfo], data: Union[bytes, str], compress_type: Optional[int] = ... + self, zinfo_or_arcname: str | ZipInfo, data: bytes | str, compress_type: int | None = ... ) -> None: ... class PyZipFile(ZipFile): def __init__( - self, file: Union[str, IO[bytes]], mode: str = ..., compression: int = ..., allowZip64: bool = ..., optimize: int = ... + self, file: str | IO[bytes], mode: str = ..., compression: int = ..., allowZip64: bool = ..., optimize: int = ... ) -> None: ... - def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ... + def writepy(self, pathname: str, basename: str = ..., filterfunc: Callable[[str], bool] | None = ...) -> None: ... class ZipInfo: filename: str @@ -203,15 +203,15 @@ class ZipInfo: def __init__(self, filename: str = ..., date_time: _DateTuple = ...) -> None: ... if sys.version_info >= (3, 8): @classmethod - def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ... + def from_file(cls, filename: StrPath, arcname: StrPath | None = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ... else: @classmethod - def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ...) -> ZipInfo: ... + def from_file(cls, filename: StrPath, arcname: StrPath | None = ...) -> ZipInfo: ... def is_dir(self) -> bool: ... - def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ... + def FileHeader(self, zip64: bool | None = ...) -> bytes: ... class _PathOpenProtocol(Protocol): - def __call__(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... + def __call__(self, mode: str = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... if sys.version_info >= (3, 8): class Path: @@ -219,9 +219,9 @@ if sys.version_info >= (3, 8): def name(self) -> str: ... @property def parent(self) -> Path: ... # undocumented - def __init__(self, root: Union[ZipFile, StrPath, IO[bytes]], at: str = ...) -> None: ... + def __init__(self, root: ZipFile | StrPath | IO[bytes], at: str = ...) -> None: ... if sys.version_info >= (3, 9): - def open(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... + def open(self, mode: str = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... else: @property def open(self) -> _PathOpenProtocol: ... @@ -231,9 +231,9 @@ if sys.version_info >= (3, 8): def exists(self) -> bool: ... def read_text( self, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., line_buffering: bool = ..., write_through: bool = ..., ) -> str: ... @@ -241,7 +241,7 @@ if sys.version_info >= (3, 8): def joinpath(self, add: StrPath) -> Path: ... # undocumented def __truediv__(self, add: StrPath) -> Path: ... -def is_zipfile(filename: Union[StrPath, IO[bytes]]) -> bool: ... +def is_zipfile(filename: StrPath | IO[bytes]) -> bool: ... ZIP_STORED: int ZIP_DEFLATED: int diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index d36653196ee3..323f23476dc1 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -11,16 +11,16 @@ class ZipImportError(ImportError): ... class zipimporter(object): archive: str prefix: str - def __init__(self, path: Union[str, bytes, os.PathLike[Any]]) -> None: ... + def __init__(self, path: str | bytes | os.PathLike[Any]) -> None: ... def find_loader( - self, fullname: str, path: Optional[str] = ... - ) -> Tuple[Optional[zipimporter], List[str]]: ... # undocumented - def find_module(self, fullname: str, path: Optional[str] = ...) -> Optional[zipimporter]: ... + self, fullname: str, path: str | None = ... + ) -> Tuple[zipimporter | None, List[str]]: ... # undocumented + def find_module(self, fullname: str, path: str | None = ...) -> zipimporter | None: ... def get_code(self, fullname: str) -> CodeType: ... def get_data(self, pathname: str) -> str: ... def get_filename(self, fullname: str) -> str: ... if sys.version_info >= (3, 7): - def get_resource_reader(self, fullname: str) -> Optional[ResourceReader]: ... # undocumented - def get_source(self, fullname: str) -> Optional[str]: ... + 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: ... def load_module(self, fullname: str) -> ModuleType: ... diff --git a/stdlib/zlib.pyi b/stdlib/zlib.pyi index c0443c5d8c60..57f8f06412f6 100644 --- a/stdlib/zlib.pyi +++ b/stdlib/zlib.pyi @@ -38,8 +38,8 @@ class _Decompress: def adler32(__data: bytes, __value: int = ...) -> int: ... def compress(__data: bytes, level: int = ...) -> bytes: ... def compressobj( - level: int = ..., method: int = ..., wbits: int = ..., memLevel: int = ..., strategy: int = ..., zdict: Optional[bytes] = ... + level: int = ..., method: int = ..., wbits: int = ..., memLevel: int = ..., strategy: int = ..., zdict: bytes | None = ... ) -> _Compress: ... -def crc32(__data: Union[array[Any], bytes], __value: int = ...) -> int: ... +def crc32(__data: array[Any] | bytes, __value: int = ...) -> int: ... def decompress(__data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... def decompressobj(wbits: int = ..., zdict: bytes = ...) -> _Decompress: ... diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 35bd142b8017..a6b2bb831bb1 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -16,14 +16,14 @@ class ZoneInfo(tzinfo): @classmethod def no_cache(cls: Type[_T], key: str) -> _T: ... @classmethod - def from_file(cls: Type[_T], __fobj: _IOBytes, key: Optional[str] = ...) -> _T: ... + def from_file(cls: Type[_T], __fobj: _IOBytes, key: str | None = ...) -> _T: ... @classmethod def clear_cache(cls, *, only_keys: Iterable[str] = ...) -> None: ... # Note: Both here and in clear_cache, the types allow the use of `str` where # a sequence of strings is required. This should be remedied if a solution # to this typing bug is found: https://github.com/python/typing/issues/256 -def reset_tzpath(to: Optional[Sequence[StrPath]] = ...) -> None: ... +def reset_tzpath(to: Sequence[StrPath] | None = ...) -> None: ... def available_timezones() -> Set[str]: ... TZPATH: Sequence[str] diff --git a/stubs/DateTimeRange/datetimerange/__init__.pyi b/stubs/DateTimeRange/datetimerange/__init__.pyi index 53372f47adfe..8535795f0d5b 100644 --- a/stubs/DateTimeRange/datetimerange/__init__.pyi +++ b/stubs/DateTimeRange/datetimerange/__init__.pyi @@ -11,8 +11,8 @@ class DateTimeRange(object): separator: str def __init__( self, - start_datetime: Optional[Union[datetime.datetime, str]] = ..., - end_datetime: Optional[Union[datetime.datetime, str]] = ..., + start_datetime: datetime.datetime | str | None = ..., + end_datetime: datetime.datetime | str | None = ..., start_time_format: str = ..., end_time_format: str = ..., ) -> None: ... @@ -22,7 +22,7 @@ class DateTimeRange(object): def __iadd__(self, other: datetime.timedelta) -> DateTimeRange: ... def __sub__(self, other: datetime.timedelta) -> DateTimeRange: ... def __isub__(self, other: datetime.timedelta) -> DateTimeRange: ... - def __contains__(self, x: Union[datetime.timedelta, DateTimeRange, str]) -> bool: ... + def __contains__(self, x: datetime.timedelta | DateTimeRange | str) -> bool: ... @property def start_datetime(self) -> datetime.datetime: ... @property @@ -36,12 +36,12 @@ class DateTimeRange(object): def get_start_time_str(self) -> str: ... def get_end_time_str(self) -> str: ... def get_timedelta_second(self) -> float: ... - def set_start_datetime(self, value: Optional[Union[datetime.datetime, str]], timezone: Optional[str] = ...) -> None: ... - def set_end_datetime(self, value: Optional[Union[datetime.datetime, str]], timezone: Optional[str] = ...) -> None: ... + def set_start_datetime(self, value: datetime.datetime | str | None, timezone: str | None = ...) -> None: ... + def set_end_datetime(self, value: datetime.datetime | str | None, timezone: str | None = ...) -> None: ... def set_time_range( - self, start: Optional[Union[datetime.datetime, str]], end: Optional[Union[datetime.datetime, str]] + self, start: datetime.datetime | str | None, end: datetime.datetime | str | None ) -> None: ... - def range(self, step: Union[datetime.timedelta, relativedelta]) -> Iterable[datetime.datetime]: ... + def range(self, step: datetime.timedelta | relativedelta) -> Iterable[datetime.datetime]: ... def intersection(self, x: DateTimeRange) -> DateTimeRange: ... def encompass(self, x: DateTimeRange) -> DateTimeRange: ... def truncate(self, percentage: float) -> None: ... diff --git a/stubs/Deprecated/deprecated/classic.pyi b/stubs/Deprecated/deprecated/classic.pyi index 5ee2352ca9e4..b80ceca86fe6 100644 --- a/stubs/Deprecated/deprecated/classic.pyi +++ b/stubs/Deprecated/deprecated/classic.pyi @@ -5,10 +5,10 @@ _F = TypeVar("_F", bound=Callable[..., Any]) class ClassicAdapter: reason: str version: str - action: Optional[str] + action: str | None category: Type[DeprecationWarning] def __init__( - self, reason: str = ..., version: str = ..., action: Optional[str] = ..., category: Type[DeprecationWarning] = ... + self, reason: str = ..., version: str = ..., action: str | None = ..., category: Type[DeprecationWarning] = ... ) -> None: ... def get_deprecated_msg(self, wrapped: Callable[..., Any], instance: object) -> str: ... def __call__(self, wrapped: _F) -> Callable[[_F], _F]: ... @@ -17,5 +17,5 @@ class ClassicAdapter: def deprecated(__wrapped: _F) -> _F: ... @overload def deprecated( - reason: str = ..., *, version: str = ..., action: Optional[str] = ..., category: Optional[Type[DeprecationWarning]] = ... + reason: str = ..., *, version: str = ..., action: str | None = ..., category: Type[DeprecationWarning] | None = ... ) -> Callable[[_F], _F]: ... diff --git a/stubs/Deprecated/deprecated/sphinx.pyi b/stubs/Deprecated/deprecated/sphinx.pyi index 41b4a22fd8b8..df1b2f0398fa 100644 --- a/stubs/Deprecated/deprecated/sphinx.pyi +++ b/stubs/Deprecated/deprecated/sphinx.pyi @@ -9,14 +9,14 @@ class SphinxAdapter(ClassicAdapter): directive: Literal["versionadded", "versionchanged", "deprecated"] reason: str version: str - action: Optional[str] + action: str | None category: Type[DeprecationWarning] def __init__( self, directive: Literal["versionadded", "versionchanged", "deprecated"], reason: str = ..., version: str = ..., - action: Optional[str] = ..., + action: str | None = ..., category: Type[DeprecationWarning] = ..., ) -> None: ... def __call__(self, wrapped: _F) -> Callable[[_F], _F]: ... @@ -27,5 +27,5 @@ def versionchanged(reason: str = ..., version: str = ...) -> Callable[[_F], _F]: def deprecated(__wrapped: _F) -> _F: ... @overload def deprecated( - reason: str = ..., *, version: str = ..., action: Optional[str] = ..., category: Optional[Type[DeprecationWarning]] = ... + reason: str = ..., *, version: str = ..., action: str | None = ..., category: Type[DeprecationWarning] | None = ... ) -> Callable[[_F], _F]: ... diff --git a/stubs/Flask/flask/app.pyi b/stubs/Flask/flask/app.pyi index 8fd6921a2116..80196b4dbbc6 100644 --- a/stubs/Flask/flask/app.pyi +++ b/stubs/Flask/flask/app.pyi @@ -48,7 +48,7 @@ class Flask(_PackageBoundObject): app_ctx_globals_class: type = ... config_class: Type[Config] = ... testing: Any = ... - secret_key: Union[Text, bytes, None] = ... + secret_key: Text | bytes | None = ... session_cookie_name: Any = ... permanent_session_lifetime: timedelta = ... send_file_max_age_default: timedelta = ... @@ -63,19 +63,19 @@ class Flask(_PackageBoundObject): session_interface: Any = ... import_name: str = ... template_folder: str = ... - root_path: Union[str, Text] = ... + root_path: str | Text = ... static_url_path: Any = ... - static_folder: Optional[str] = ... - instance_path: Union[str, Text] = ... + static_folder: str | None = ... + instance_path: str | Text = ... config: Config = ... view_functions: Any = ... error_handler_spec: Any = ... url_build_error_handlers: Any = ... - before_request_funcs: Dict[Optional[str], List[Callable[[], Any]]] = ... + before_request_funcs: Dict[str | None, List[Callable[[], Any]]] = ... before_first_request_funcs: List[Callable[[], None]] = ... - after_request_funcs: Dict[Optional[str], List[Callable[[Response], Response]]] = ... - teardown_request_funcs: Dict[Optional[str], List[Callable[[Optional[Exception]], Any]]] = ... - teardown_appcontext_funcs: List[Callable[[Optional[Exception]], Any]] = ... + after_request_funcs: Dict[str | None, List[Callable[[Response], Response]]] = ... + teardown_request_funcs: Dict[str | None, List[Callable[[Exception | None], Any]]] = ... + teardown_appcontext_funcs: List[Callable[[Exception | None], Any]] = ... url_value_preprocessors: Any = ... url_default_functions: Any = ... template_context_processors: Any = ... @@ -88,15 +88,15 @@ class Flask(_PackageBoundObject): def __init__( self, import_name: str, - static_url_path: Optional[str] = ..., - static_folder: Optional[str] = ..., - static_host: Optional[str] = ..., + static_url_path: str | None = ..., + static_folder: str | None = ..., + static_host: str | None = ..., host_matching: bool = ..., subdomain_matching: bool = ..., template_folder: str = ..., - instance_path: Optional[str] = ..., + instance_path: str | None = ..., instance_relative_config: bool = ..., - root_path: Optional[str] = ..., + root_path: str | None = ..., ) -> None: ... @property def name(self) -> str: ... @@ -112,20 +112,20 @@ class Flask(_PackageBoundObject): def got_first_request(self) -> bool: ... def make_config(self, instance_relative: bool = ...): ... def auto_find_instance_path(self): ... - def open_instance_resource(self, resource: Union[str, Text], mode: str = ...): ... + def open_instance_resource(self, resource: str | Text, mode: str = ...): ... templates_auto_reload: Any = ... def create_jinja_environment(self): ... def create_global_jinja_loader(self): ... def select_jinja_autoescape(self, filename: Any): ... def update_template_context(self, context: Any) -> None: ... def make_shell_context(self): ... - env: Optional[str] = ... + env: str | None = ... debug: bool = ... def run( self, - host: Optional[str] = ..., - port: Optional[Union[int, str]] = ..., - debug: Optional[bool] = ..., + host: str | None = ..., + port: int | str | None = ..., + debug: bool | None = ..., load_dotenv: bool = ..., **options: Any, ) -> None: ... @@ -139,28 +139,28 @@ class Flask(_PackageBoundObject): def add_url_rule( self, rule: str, - endpoint: Optional[str] = ..., + endpoint: str | None = ..., view_func: _ViewFunc = ..., - provide_automatic_options: Optional[bool] = ..., + provide_automatic_options: bool | None = ..., **options: Any, ) -> None: ... def route(self, rule: str, **options: Any) -> Callable[[_VT], _VT]: ... def endpoint(self, endpoint: str) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... def errorhandler( - self, code_or_exception: Union[int, Type[Exception]] + self, code_or_exception: int | Type[Exception] ) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... - def register_error_handler(self, code_or_exception: Union[int, Type[Exception]], f: Callable[..., Any]) -> None: ... - def template_filter(self, name: Optional[Any] = ...): ... - def add_template_filter(self, f: Any, name: Optional[Any] = ...) -> None: ... - def template_test(self, name: Optional[Any] = ...): ... - def add_template_test(self, f: Any, name: Optional[Any] = ...) -> None: ... - def template_global(self, name: Optional[Any] = ...): ... - def add_template_global(self, f: Any, name: Optional[Any] = ...) -> None: ... + def register_error_handler(self, code_or_exception: int | Type[Exception], f: Callable[..., Any]) -> None: ... + def template_filter(self, name: Any | None = ...): ... + def add_template_filter(self, f: Any, name: Any | None = ...) -> None: ... + def template_test(self, name: Any | None = ...): ... + def add_template_test(self, f: Any, name: Any | None = ...) -> None: ... + def template_global(self, name: Any | None = ...): ... + def add_template_global(self, f: Any, name: Any | None = ...) -> None: ... def before_request(self, f: Callable[[], _T]) -> Callable[[], _T]: ... def before_first_request(self, f: Callable[[], _T]) -> Callable[[], _T]: ... def after_request(self, f: Callable[[Response], Response]) -> Callable[[Response], Response]: ... - def teardown_request(self, f: Callable[[Optional[Exception]], _T]) -> Callable[[Optional[Exception]], _T]: ... - def teardown_appcontext(self, f: Callable[[Optional[Exception]], _T]) -> Callable[[Optional[Exception]], _T]: ... + def teardown_request(self, f: Callable[[Exception | None], _T]) -> Callable[[Exception | None], _T]: ... + def teardown_appcontext(self, f: Callable[[Exception | None], _T]) -> Callable[[Exception | None], _T]: ... def context_processor(self, f: Any): ... def shell_context_processor(self, f: Any): ... def url_value_preprocessor(self, f: Any): ... diff --git a/stubs/Flask/flask/blueprints.pyi b/stubs/Flask/flask/blueprints.pyi index a003452bc311..65b282e9f80c 100644 --- a/stubs/Flask/flask/blueprints.pyi +++ b/stubs/Flask/flask/blueprints.pyi @@ -17,49 +17,49 @@ class BlueprintSetupState: url_prefix: Any = ... url_defaults: Any = ... def __init__(self, blueprint: Any, app: Any, options: Any, first_registration: Any) -> None: ... - def add_url_rule(self, rule: str, endpoint: Optional[str] = ..., view_func: _ViewFunc = ..., **options: Any) -> None: ... + def add_url_rule(self, rule: str, endpoint: str | None = ..., view_func: _ViewFunc = ..., **options: Any) -> None: ... class Blueprint(_PackageBoundObject): warn_on_modifications: bool = ... json_encoder: Any = ... json_decoder: Any = ... import_name: str = ... - template_folder: Optional[str] = ... + template_folder: str | None = ... root_path: str = ... name: str = ... - url_prefix: Optional[str] = ... - subdomain: Optional[str] = ... - static_folder: Optional[str] = ... - static_url_path: Optional[str] = ... + url_prefix: str | None = ... + subdomain: str | None = ... + static_folder: str | None = ... + static_url_path: str | None = ... deferred_functions: Any = ... url_values_defaults: Any = ... - cli_group: Union[Optional[str], _Sentinel] = ... + cli_group: str | None | _Sentinel = ... def __init__( self, name: str, import_name: str, - static_folder: Optional[str] = ..., - static_url_path: Optional[str] = ..., - template_folder: Optional[str] = ..., - url_prefix: Optional[str] = ..., - subdomain: Optional[str] = ..., - url_defaults: Optional[Any] = ..., - root_path: Optional[str] = ..., - cli_group: Union[Optional[str], _Sentinel] = ..., + static_folder: str | None = ..., + static_url_path: str | None = ..., + template_folder: str | None = ..., + url_prefix: str | None = ..., + subdomain: str | None = ..., + url_defaults: Any | None = ..., + root_path: str | None = ..., + cli_group: str | None | _Sentinel = ..., ) -> None: ... def record(self, func: Any) -> None: ... def record_once(self, func: Any): ... def make_setup_state(self, app: Any, options: Any, first_registration: bool = ...): ... def register(self, app: Any, options: Any, first_registration: bool = ...) -> None: ... def route(self, rule: str, **options: Any) -> Callable[[_VT], _VT]: ... - def add_url_rule(self, rule: str, endpoint: Optional[str] = ..., view_func: _ViewFunc = ..., **options: Any) -> None: ... + def add_url_rule(self, rule: str, endpoint: str | None = ..., view_func: _ViewFunc = ..., **options: Any) -> None: ... def endpoint(self, endpoint: str) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... - def app_template_filter(self, name: Optional[Any] = ...): ... - def add_app_template_filter(self, f: Any, name: Optional[Any] = ...) -> None: ... - def app_template_test(self, name: Optional[Any] = ...): ... - def add_app_template_test(self, f: Any, name: Optional[Any] = ...) -> None: ... - def app_template_global(self, name: Optional[Any] = ...): ... - def add_app_template_global(self, f: Any, name: Optional[Any] = ...) -> None: ... + def app_template_filter(self, name: Any | None = ...): ... + def add_app_template_filter(self, f: Any, name: Any | None = ...) -> None: ... + def app_template_test(self, name: Any | None = ...): ... + def add_app_template_test(self, f: Any, name: Any | None = ...) -> None: ... + def app_template_global(self, name: Any | None = ...): ... + def add_app_template_global(self, f: Any, name: Any | None = ...) -> None: ... def before_request(self, f: Any): ... def before_app_request(self, f: Any): ... def before_app_first_request(self, f: Any): ... @@ -75,6 +75,6 @@ class Blueprint(_PackageBoundObject): def app_url_value_preprocessor(self, f: Any): ... def app_url_defaults(self, f: Any): ... def errorhandler( - self, code_or_exception: Union[int, Type[Exception]] + self, code_or_exception: int | Type[Exception] ) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... - def register_error_handler(self, code_or_exception: Union[int, Type[Exception]], f: Callable[..., Any]) -> None: ... + def register_error_handler(self, code_or_exception: int | Type[Exception], f: Callable[..., Any]) -> None: ... diff --git a/stubs/Flask/flask/cli.pyi b/stubs/Flask/flask/cli.pyi index 9083ebd5db25..cfec1e08767a 100644 --- a/stubs/Flask/flask/cli.pyi +++ b/stubs/Flask/flask/cli.pyi @@ -22,7 +22,7 @@ class ScriptInfo: app_import_path: Any = ... create_app: Any = ... data: Any = ... - def __init__(self, app_import_path: Optional[Any] = ..., create_app: Optional[Any] = ...) -> None: ... + def __init__(self, app_import_path: Any | None = ..., create_app: Any | None = ...) -> None: ... def load_app(self): ... pass_script_info: Any @@ -39,7 +39,7 @@ class FlaskGroup(AppGroup): def __init__( self, add_default_commands: bool = ..., - create_app: Optional[Any] = ..., + create_app: Any | None = ..., add_version_option: bool = ..., load_dotenv: bool = ..., **extra: Any, @@ -48,7 +48,7 @@ class FlaskGroup(AppGroup): def list_commands(self, ctx: Any): ... def main(self, *args: Any, **kwargs: Any): ... -def load_dotenv(path: Optional[Any] = ...): ... +def load_dotenv(path: Any | None = ...): ... def show_server_banner(env: Any, debug: Any, app_import_path: Any, eager_loading: Any): ... class CertParamType(click.ParamType): diff --git a/stubs/Flask/flask/config.pyi b/stubs/Flask/flask/config.pyi index 2b005422e267..a0a9be05fb6d 100644 --- a/stubs/Flask/flask/config.pyi +++ b/stubs/Flask/flask/config.pyi @@ -3,13 +3,13 @@ from typing import Any, Dict, Optional class ConfigAttribute: __name__: Any = ... get_converter: Any = ... - def __init__(self, name: Any, get_converter: Optional[Any] = ...) -> None: ... - def __get__(self, obj: Any, type: Optional[Any] = ...): ... + def __init__(self, name: Any, get_converter: Any | None = ...) -> None: ... + def __get__(self, obj: Any, type: Any | None = ...): ... def __set__(self, obj: Any, value: Any) -> None: ... class Config(Dict[str, Any]): root_path: Any = ... - def __init__(self, root_path: Any, defaults: Optional[Any] = ...) -> None: ... + def __init__(self, root_path: Any, defaults: Any | None = ...) -> None: ... def from_envvar(self, variable_name: Any, silent: bool = ...): ... def from_pyfile(self, filename: Any, silent: bool = ...): ... def from_object(self, obj: Any) -> None: ... diff --git a/stubs/Flask/flask/ctx.pyi b/stubs/Flask/flask/ctx.pyi index c3dd934a3854..5717e0ac8c89 100644 --- a/stubs/Flask/flask/ctx.pyi +++ b/stubs/Flask/flask/ctx.pyi @@ -1,9 +1,9 @@ from typing import Any, Optional class _AppCtxGlobals: - def get(self, name: Any, default: Optional[Any] = ...): ... + def get(self, name: Any, default: Any | None = ...): ... def pop(self, name: Any, default: Any = ...): ... - def setdefault(self, name: Any, default: Optional[Any] = ...): ... + def setdefault(self, name: Any, default: Any | None = ...): ... def __contains__(self, item: Any): ... def __iter__(self): ... @@ -29,7 +29,7 @@ class RequestContext: flashes: Any = ... session: Any = ... preserved: bool = ... - def __init__(self, app: Any, environ: Any, request: Optional[Any] = ...) -> None: ... + def __init__(self, app: Any, environ: Any, request: Any | None = ...) -> None: ... g: Any = ... def copy(self): ... def match_request(self) -> None: ... diff --git a/stubs/Flask/flask/helpers.pyi b/stubs/Flask/flask/helpers.pyi index 928f8837c912..c07bd8134bfa 100644 --- a/stubs/Flask/flask/helpers.pyi +++ b/stubs/Flask/flask/helpers.pyi @@ -14,13 +14,13 @@ def flash(message: Any, category: str = ...) -> None: ... def get_flashed_messages(with_categories: bool = ..., category_filter: Any = ...): ... def send_file( filename_or_fp: Any, - mimetype: Optional[Any] = ..., + mimetype: Any | None = ..., as_attachment: bool = ..., - attachment_filename: Optional[Any] = ..., + attachment_filename: Any | None = ..., add_etags: bool = ..., - cache_timeout: Optional[Any] = ..., + cache_timeout: Any | None = ..., conditional: bool = ..., - last_modified: Optional[Any] = ..., + last_modified: Any | None = ..., ) -> Response: ... def safe_join(directory: Any, *pathnames: Any): ... def send_from_directory(directory: Any, filename: Any, **options: Any) -> Response: ... @@ -33,15 +33,15 @@ class locked_cached_property: __doc__: Any = ... func: Any = ... lock: Any = ... - def __init__(self, func: Any, name: Optional[Any] = ..., doc: Optional[Any] = ...) -> None: ... - def __get__(self, obj: Any, type: Optional[Any] = ...): ... + def __init__(self, func: Any, name: Any | None = ..., doc: Any | None = ...) -> None: ... + def __get__(self, obj: Any, type: Any | None = ...): ... class _PackageBoundObject: import_name: Any = ... template_folder: Any = ... root_path: Any = ... cli: AppGroup = ... - def __init__(self, import_name: Any, template_folder: Optional[Any] = ..., root_path: Optional[Any] = ...) -> None: ... + def __init__(self, import_name: Any, template_folder: Any | None = ..., root_path: Any | None = ...) -> None: ... static_folder: Any = ... static_url_path: Any = ... @property diff --git a/stubs/Flask/flask/json/tag.pyi b/stubs/Flask/flask/json/tag.pyi index c4dcf2833a44..a4fd09acd3be 100644 --- a/stubs/Flask/flask/json/tag.pyi +++ b/stubs/Flask/flask/json/tag.pyi @@ -60,7 +60,7 @@ class TaggedJSONSerializer: tags: Any = ... order: Any = ... def __init__(self) -> None: ... - def register(self, tag_class: Any, force: bool = ..., index: Optional[Any] = ...) -> None: ... + def register(self, tag_class: Any, force: bool = ..., index: Any | None = ...) -> None: ... def tag(self, value: Any): ... def untag(self, value: Any): ... def dumps(self, value: Any): ... diff --git a/stubs/Flask/flask/sessions.pyi b/stubs/Flask/flask/sessions.pyi index 77c008b730f3..5ba26473db56 100644 --- a/stubs/Flask/flask/sessions.pyi +++ b/stubs/Flask/flask/sessions.pyi @@ -15,10 +15,10 @@ class SessionMixin(MutableMapping[str, Any], metaclass=ABCMeta): class SecureCookieSession(CallbackDict[str, Any], SessionMixin): modified: bool = ... accessed: bool = ... - def __init__(self, initial: Optional[Any] = ...) -> None: ... + def __init__(self, initial: Any | None = ...) -> None: ... def __getitem__(self, key: Any): ... - def get(self, key: Any, default: Optional[Any] = ...): ... - def setdefault(self, key: Any, default: Optional[Any] = ...): ... + def get(self, key: Any, default: Any | None = ...): ... + def setdefault(self, key: Any, default: Any | None = ...): ... class NullSession(SecureCookieSession): __setitem__: Any = ... diff --git a/stubs/Flask/flask/signals.pyi b/stubs/Flask/flask/signals.pyi index 66238d0ae912..628c340b1cb8 100644 --- a/stubs/Flask/flask/signals.pyi +++ b/stubs/Flask/flask/signals.pyi @@ -3,12 +3,12 @@ from typing import Any, Optional signals_available: bool class Namespace: - def signal(self, name: Any, doc: Optional[Any] = ...): ... + def signal(self, name: Any, doc: Any | None = ...): ... class _FakeSignal: name: Any = ... __doc__: Any = ... - def __init__(self, name: Any, doc: Optional[Any] = ...) -> None: ... + def __init__(self, name: Any, doc: Any | None = ...) -> None: ... send: Any = ... connect: Any = ... disconnect: Any = ... diff --git a/stubs/Flask/flask/templating.pyi b/stubs/Flask/flask/templating.pyi index 3f7aaae40236..7650851941ae 100644 --- a/stubs/Flask/flask/templating.pyi +++ b/stubs/Flask/flask/templating.pyi @@ -12,5 +12,5 @@ class DispatchingJinjaLoader(BaseLoader): def get_source(self, environment: Any, template: Any): ... def list_templates(self): ... -def render_template(template_name_or_list: Union[Text, Iterable[Text]], **context: Any) -> Text: ... +def render_template(template_name_or_list: Text | Iterable[Text], **context: Any) -> Text: ... def render_template_string(source: Text, **context: Any) -> Text: ... diff --git a/stubs/Flask/flask/testing.pyi b/stubs/Flask/flask/testing.pyi index c3a652413fbd..5bd42b623824 100644 --- a/stubs/Flask/flask/testing.pyi +++ b/stubs/Flask/flask/testing.pyi @@ -5,7 +5,7 @@ from click.testing import CliRunner, Result from werkzeug.test import Client, EnvironBuilder as WerkzeugEnvironBuilder # Response type for the client below. -# By default _R is Tuple[Iterable[Any], Union[Text, int], werkzeug.datastructures.Headers], however +# By default _R is Tuple[Iterable[Any], Text | int, werkzeug.datastructures.Headers], however # most commonly it is wrapped in a Reponse object. _R = TypeVar("_R") @@ -22,10 +22,10 @@ class FlaskCliRunner(CliRunner): def __init__(self, app: Any, **kwargs: Any) -> None: ... def invoke( self, - cli: Optional[BaseCommand] = ..., - args: Optional[Union[str, Iterable[str]]] = ..., - input: Optional[Union[bytes, IO[Any], Text]] = ..., - env: Optional[Mapping[str, str]] = ..., + cli: BaseCommand | None = ..., + args: str | Iterable[str] | None = ..., + input: bytes | IO[Any] | Text | None = ..., + env: Mapping[str, str] | None = ..., catch_exceptions: bool = ..., color: bool = ..., **extra: Any, @@ -37,9 +37,9 @@ class EnvironBuilder(WerkzeugEnvironBuilder): self, app: Any, path: str = ..., - base_url: Optional[Any] = ..., - subdomain: Optional[Any] = ..., - url_scheme: Optional[Any] = ..., + base_url: Any | None = ..., + subdomain: Any | None = ..., + url_scheme: Any | None = ..., *args: Any, **kwargs: Any, ) -> None: ... @@ -48,9 +48,9 @@ class EnvironBuilder(WerkzeugEnvironBuilder): def make_test_environ_builder( app: Any, path: str = ..., - base_url: Optional[Any] = ..., - subdomain: Optional[Any] = ..., - url_scheme: Optional[Any] = ..., + base_url: Any | None = ..., + subdomain: Any | None = ..., + url_scheme: Any | None = ..., *args: Any, **kwargs: Any, ): ... diff --git a/stubs/Flask/flask/wrappers.pyi b/stubs/Flask/flask/wrappers.pyi index 590bea0b5a36..1c22f6071b15 100644 --- a/stubs/Flask/flask/wrappers.pyi +++ b/stubs/Flask/flask/wrappers.pyi @@ -13,20 +13,20 @@ class JSONMixin: def on_json_loading_failed(self, e: Any) -> None: ... class Request(RequestBase, JSONMixin): - url_rule: Optional[Rule] = ... + url_rule: Rule | None = ... view_args: Dict[str, Any] = ... - routing_exception: Optional[HTTPException] = ... + routing_exception: HTTPException | None = ... # Request is making the max_content_length readonly, where it was not the # case in its supertype. # We would require something like https://github.com/python/typing/issues/241 @property - def max_content_length(self) -> Optional[int]: ... # type: ignore + def max_content_length(self) -> int | None: ... # type: ignore @property - def endpoint(self) -> Optional[str]: ... + def endpoint(self) -> str | None: ... @property - def blueprint(self) -> Optional[str]: ... + def blueprint(self) -> str | None: ... class Response(ResponseBase, JSONMixin): - default_mimetype: Optional[str] = ... + default_mimetype: str | None = ... @property def max_cookie_size(self) -> int: ... diff --git a/stubs/JACK-Client/jack/__init__.pyi b/stubs/JACK-Client/jack/__init__.pyi index 62904ecd0e04..8cdaed8637cb 100644 --- a/stubs/JACK-Client/jack/__init__.pyi +++ b/stubs/JACK-Client/jack/__init__.pyi @@ -47,8 +47,8 @@ class Client: name: str, use_exact_name: bool = ..., no_start_server: bool = ..., - servername: Optional[str] = ..., - session_id: Optional[str] = ..., + servername: str | None = ..., + session_id: str | None = ..., ) -> None: ... @property def name(self) -> str: ... @@ -78,13 +78,13 @@ class Client: def midi_inports(self) -> Ports: ... @property def midi_outports(self) -> Ports: ... - def owns(self, port: Union[str, Port]) -> bool: ... + def owns(self, port: str | Port) -> bool: ... def activate(self) -> None: ... def deactivate(self, ignore_errors: bool = ...) -> None: ... def cpu_load(self) -> float: ... def close(self, ignore_errors: bool = ...) -> None: ... - def connect(self, source: Union[str, Port], destination: Union[str, Port]) -> None: ... - def disconnect(self, source: Union[str, Port], destination: Union[str, Port]) -> None: ... + def connect(self, source: str | Port, destination: str | Port) -> None: ... + def disconnect(self, source: str | Port, destination: str | Port) -> None: ... def transport_start(self) -> None: ... def transport_stop(self) -> None: ... @property @@ -106,20 +106,20 @@ class Client: def set_samplerate_callback(self, callback: Callable[[int], None]) -> None: ... def set_client_registration_callback(self, callback: Callable[[str, bool], None]) -> None: ... def set_port_registration_callback( - self, callback: Optional[Callable[[Port, bool], None]] = ..., only_available: bool = ... + self, callback: Callable[[Port, bool], None] | None = ..., only_available: bool = ... ) -> None: ... def set_port_connect_callback( - self, callback: Optional[Callable[[Port, Port, bool], None]] = ..., only_available: bool = ... + self, callback: Callable[[Port, Port, bool], None] | None = ..., only_available: bool = ... ) -> None: ... def set_port_rename_callback( - self, callback: Optional[Callable[[Port, str, str], None]] = ..., only_available: bool = ... + self, callback: Callable[[Port, str, str], None] | None = ..., only_available: bool = ... ) -> None: ... def set_graph_order_callback(self, callback: Callable[[], None]) -> None: ... def set_xrun_callback(self, callback: Callable[[float], None]) -> None: ... - def set_sync_callback(self, callback: Optional[Callable[[int, _JackPositionT], None]]) -> None: ... + def set_sync_callback(self, callback: Callable[[int, _JackPositionT], None] | None) -> None: ... def release_timebase(self) -> None: ... def set_timebase_callback( - self, callback: Optional[Callable[[int, int, _JackPositionT, bool], None]] = ..., conditional: bool = ... + self, callback: Callable[[int, int, _JackPositionT, bool], None] | None = ..., conditional: bool = ... ) -> bool: ... def set_property_change_callback(self, callback: Callable[[int, str, int], None]) -> None: ... def get_uuid_for_client_name(self, name: str) -> str: ... @@ -137,9 +137,9 @@ class Client: can_monitor: bool = ..., is_terminal: bool = ..., ) -> List[Port]: ... - def set_property(self, subject: Union[int, str], key: str, value: Union[str, bytes], type: str = ...) -> None: ... - def remove_property(self, subject: Union[int, str], key: str) -> None: ... - def remove_properties(self, subject: Union[int, str]) -> int: ... + def set_property(self, subject: int | str, key: str, value: str | bytes, type: str = ...) -> None: ... + def remove_property(self, subject: int | str, key: str) -> None: ... + def remove_properties(self, subject: int | str) -> int: ... def remove_all_properties(self) -> None: ... class Port: @@ -181,9 +181,9 @@ class OwnPort(Port): def number_of_connections(self) -> int: ... @property def connections(self) -> List[Port]: ... - def is_connected_to(self, port: Union[str, Port]) -> bool: ... - def connect(self, port: Union[str, Port]) -> None: ... - def disconnect(self, other: Optional[Union[str, Port]] = ...) -> None: ... + def is_connected_to(self, port: str | Port) -> bool: ... + def connect(self, port: str | Port) -> None: ... + def disconnect(self, other: str | Port | None = ...) -> None: ... def unregister(self) -> None: ... def get_buffer(self) -> _CBufferType: ... def get_array(self) -> _NDArray: ... @@ -198,7 +198,7 @@ class OwnMidiPort(MidiPort, OwnPort): def lost_midi_events(self) -> int: ... def incoming_midi_events(self) -> Generator[Tuple[int, _CBufferType], None, None]: ... def clear_buffer(self) -> None: ... - def write_midi_event(self, time: int, event: Union[bytes, Sequence[int], _CBufferType]) -> None: ... + def write_midi_event(self, time: int, event: bytes | Sequence[int] | _CBufferType) -> None: ... def reserve_midi_event(self, time: int, size: int) -> _CBufferType: ... class Ports: @@ -213,7 +213,7 @@ class RingBuffer: def __init__(self, size: int) -> None: ... @property def write_space(self) -> int: ... - def write(self, data: Union[bytes, Iterable[int], _CBufferType]) -> int: ... + def write(self, data: bytes | Iterable[int] | _CBufferType) -> int: ... @property def write_buffers(self) -> Tuple[_CBufferType, _CBufferType]: ... def write_advance(self, size: int) -> None: ... @@ -225,7 +225,7 @@ class RingBuffer: def read_buffers(self) -> Tuple[_CBufferType, _CBufferType]: ... def read_advance(self, size: int) -> None: ... def mlock(self) -> None: ... - def reset(self, size: Optional[int] = ...) -> None: ... + def reset(self, size: int | None = ...) -> None: ... @property def size(self) -> int: ... @@ -265,14 +265,14 @@ class TransportState: class CallbackExit(Exception): ... -def get_property(subject: Union[int, str], key: str) -> Optional[Tuple[bytes, str]]: ... -def get_properties(subject: Union[int, str]) -> Dict[str, Tuple[bytes, str]]: ... +def get_property(subject: int | str, key: str) -> Tuple[bytes, str] | None: ... +def get_properties(subject: int | str) -> Dict[str, Tuple[bytes, str]]: ... def get_all_properties() -> Dict[str, Dict[str, Tuple[bytes, str]]]: ... def position2dict(pos: _JackPositionT) -> Dict[str, Any]: ... def version() -> Tuple[int, int, int, int]: ... def version_string() -> str: ... def client_name_size() -> int: ... def port_name_size() -> int: ... -def set_error_function(callback: Optional[Callable[[str], None]] = ...) -> None: ... -def set_info_function(callback: Optional[Callable[[str], None]] = ...) -> None: ... +def set_error_function(callback: Callable[[str], None] | None = ...) -> None: ... +def set_info_function(callback: Callable[[str], None] | None = ...) -> None: ... def client_pid(name: str) -> int: ... diff --git a/stubs/Jinja2/jinja2/_compat.pyi b/stubs/Jinja2/jinja2/_compat.pyi index 4edf9286b48f..740802bffb13 100644 --- a/stubs/Jinja2/jinja2/_compat.pyi +++ b/stubs/Jinja2/jinja2/_compat.pyi @@ -22,7 +22,7 @@ itervalues: Any iteritems: Any NativeStringIO: Any -def reraise(tp, value, tb: Optional[Any] = ...): ... +def reraise(tp, value, tb: Any | None = ...): ... ifilter: Any imap: Any diff --git a/stubs/Jinja2/jinja2/bccache.pyi b/stubs/Jinja2/jinja2/bccache.pyi index 754736a6a860..ec82a2d487aa 100644 --- a/stubs/Jinja2/jinja2/bccache.pyi +++ b/stubs/Jinja2/jinja2/bccache.pyi @@ -21,7 +21,7 @@ class BytecodeCache: def load_bytecode(self, bucket): ... def dump_bytecode(self, bucket): ... def clear(self): ... - def get_cache_key(self, name, filename: Optional[Any] = ...): ... + def get_cache_key(self, name, filename: Any | None = ...): ... def get_source_checksum(self, source): ... def get_bucket(self, environment, name, filename, source): ... def set_bucket(self, bucket): ... @@ -29,7 +29,7 @@ class BytecodeCache: class FileSystemBytecodeCache(BytecodeCache): directory: Any pattern: Any - def __init__(self, directory: Optional[Any] = ..., pattern: str = ...) -> None: ... + def __init__(self, directory: Any | None = ..., pattern: str = ...) -> None: ... def load_bytecode(self, bucket): ... def dump_bytecode(self, bucket): ... def clear(self): ... @@ -39,6 +39,6 @@ class MemcachedBytecodeCache(BytecodeCache): prefix: Any timeout: Any ignore_memcache_errors: Any - def __init__(self, client, prefix: str = ..., timeout: Optional[Any] = ..., ignore_memcache_errors: bool = ...) -> None: ... + def __init__(self, client, prefix: str = ..., timeout: Any | None = ..., ignore_memcache_errors: bool = ...) -> None: ... def load_bytecode(self, bucket): ... def dump_bytecode(self, bucket): ... diff --git a/stubs/Jinja2/jinja2/compiler.pyi b/stubs/Jinja2/jinja2/compiler.pyi index ce29f720928b..e7ad55c47b70 100644 --- a/stubs/Jinja2/jinja2/compiler.pyi +++ b/stubs/Jinja2/jinja2/compiler.pyi @@ -8,7 +8,7 @@ dict_item_iter: str unoptimize_before_dead_code: bool -def generate(node, environment, name, filename, stream: Optional[Any] = ..., defer_init: bool = ...): ... +def generate(node, environment, name, filename, stream: Any | None = ..., defer_init: bool = ...): ... def has_safe_repr(value): ... def find_undeclared(nodes, names): ... @@ -33,7 +33,7 @@ class Frame: block: Any assigned_names: Any parent: Any - def __init__(self, eval_ctx, parent: Optional[Any] = ...) -> None: ... + def __init__(self, eval_ctx, parent: Any | None = ...) -> None: ... def copy(self): ... def inspect(self, nodes): ... def find_shadowed(self, extra: Any = ...): ... @@ -91,31 +91,31 @@ class CodeGenerator(NodeVisitor): tests: Any filters: Any debug_info: Any - def __init__(self, environment, name, filename, stream: Optional[Any] = ..., defer_init: bool = ...) -> None: ... + def __init__(self, environment, name, filename, stream: Any | None = ..., defer_init: bool = ...) -> None: ... def fail(self, msg, lineno): ... def temporary_identifier(self): ... def buffer(self, frame): ... def return_buffer_contents(self, frame): ... def indent(self): ... def outdent(self, step: int = ...): ... - def start_write(self, frame, node: Optional[Any] = ...): ... + def start_write(self, frame, node: Any | None = ...): ... def end_write(self, frame): ... - def simple_write(self, s, frame, node: Optional[Any] = ...): ... + def simple_write(self, s, frame, node: Any | None = ...): ... def blockvisit(self, nodes, frame): ... def write(self, x): ... - def writeline(self, x, node: Optional[Any] = ..., extra: int = ...): ... - def newline(self, node: Optional[Any] = ..., extra: int = ...): ... - def signature(self, node, frame, extra_kwargs: Optional[Any] = ...): ... + def writeline(self, x, node: Any | None = ..., extra: int = ...): ... + def newline(self, node: Any | None = ..., extra: int = ...): ... + def signature(self, node, frame, extra_kwargs: Any | None = ...): ... def pull_locals(self, frame): ... def pull_dependencies(self, nodes): ... def unoptimize_scope(self, frame): ... def push_scope(self, frame, extra_vars: Any = ...): ... def pop_scope(self, aliases, frame): ... - def function_scoping(self, node, frame, children: Optional[Any] = ..., find_special: bool = ...): ... - def macro_body(self, node, frame, children: Optional[Any] = ...): ... + def function_scoping(self, node, frame, children: Any | None = ..., find_special: bool = ...): ... + def macro_body(self, node, frame, children: Any | None = ...): ... def macro_def(self, node, frame): ... def position(self, node): ... - def visit_Template(self, node, frame: Optional[Any] = ...): ... + def visit_Template(self, node, frame: Any | None = ...): ... def visit_Block(self, node, frame): ... def visit_Extends(self, node, frame): ... def visit_Include(self, node, frame): ... diff --git a/stubs/Jinja2/jinja2/debug.pyi b/stubs/Jinja2/jinja2/debug.pyi index f495a4d99baf..df745204e2f3 100644 --- a/stubs/Jinja2/jinja2/debug.pyi +++ b/stubs/Jinja2/jinja2/debug.pyi @@ -20,7 +20,7 @@ class ProcessedTraceback: exc_value: Any frames: Any def __init__(self, exc_type, exc_value, frames) -> None: ... - def render_as_text(self, limit: Optional[Any] = ...): ... + def render_as_text(self, limit: Any | None = ...): ... def render_as_html(self, full: bool = ...): ... @property def is_template_syntax_error(self): ... @@ -29,8 +29,8 @@ class ProcessedTraceback: @property def standard_exc_info(self): ... -def make_traceback(exc_info, source_hint: Optional[Any] = ...): ... -def translate_syntax_error(error, source: Optional[Any] = ...): ... +def make_traceback(exc_info, source_hint: Any | None = ...): ... +def translate_syntax_error(error, source: Any | None = ...): ... def translate_exception(exc_info, initial_skip: int = ...): ... def fake_exc_info(exc_info, filename, lineno): ... diff --git a/stubs/Jinja2/jinja2/defaults.pyi b/stubs/Jinja2/jinja2/defaults.pyi index e311f828836a..574b8528bb53 100644 --- a/stubs/Jinja2/jinja2/defaults.pyi +++ b/stubs/Jinja2/jinja2/defaults.pyi @@ -12,8 +12,8 @@ VARIABLE_START_STRING: str VARIABLE_END_STRING: str COMMENT_START_STRING: str COMMENT_END_STRING: str -LINE_STATEMENT_PREFIX: Optional[str] -LINE_COMMENT_PREFIX: Optional[str] +LINE_STATEMENT_PREFIX: str | None +LINE_COMMENT_PREFIX: str | None TRIM_BLOCKS: bool LSTRIP_BLOCKS: bool NEWLINE_SEQUENCE: str diff --git a/stubs/Jinja2/jinja2/environment.pyi b/stubs/Jinja2/jinja2/environment.pyi index f09c1b5e713f..31827431259d 100644 --- a/stubs/Jinja2/jinja2/environment.pyi +++ b/stubs/Jinja2/jinja2/environment.pyi @@ -63,12 +63,12 @@ class Environment: extensions: List[Any] = ..., optimized: bool = ..., undefined: Type[Undefined] = ..., - finalize: Optional[Callable[..., Any]] = ..., - autoescape: Union[bool, Callable[[str], bool]] = ..., - loader: Optional[BaseLoader] = ..., + finalize: Callable[..., Any] | None = ..., + autoescape: bool | Callable[[str], bool] = ..., + loader: BaseLoader | None = ..., cache_size: int = ..., auto_reload: bool = ..., - bytecode_cache: Optional[BytecodeCache] = ..., + bytecode_cache: BytecodeCache | None = ..., enable_async: bool = ..., ) -> None: ... def add_extension(self, extension): ... @@ -90,10 +90,10 @@ class Environment: undefined: Type[Undefined] = ..., finalize: Callable[..., Any] = ..., autoescape: bool = ..., - loader: Optional[BaseLoader] = ..., + loader: BaseLoader | None = ..., cache_size: int = ..., auto_reload: bool = ..., - bytecode_cache: Optional[BytecodeCache] = ..., + bytecode_cache: BytecodeCache | None = ..., ): ... lexer: Any def iter_extensions(self): ... @@ -103,62 +103,62 @@ class Environment: self, name, value, - args: Optional[Any] = ..., - kwargs: Optional[Any] = ..., - context: Optional[Any] = ..., - eval_ctx: Optional[Any] = ..., + args: Any | None = ..., + kwargs: Any | None = ..., + context: Any | None = ..., + eval_ctx: Any | None = ..., ): ... - def call_test(self, name, value, args: Optional[Any] = ..., kwargs: Optional[Any] = ...): ... - def parse(self, source, name: Optional[Any] = ..., filename: Optional[Any] = ...): ... - def lex(self, source, name: Optional[Any] = ..., filename: Optional[Any] = ...): ... - def preprocess(self, source: Text, name: Optional[Any] = ..., filename: Optional[Any] = ...): ... + def call_test(self, name, value, args: Any | None = ..., kwargs: Any | None = ...): ... + def parse(self, source, name: Any | None = ..., filename: Any | None = ...): ... + def lex(self, source, name: Any | None = ..., filename: Any | None = ...): ... + def preprocess(self, source: Text, name: Any | None = ..., filename: Any | None = ...): ... def compile( - self, source, name: Optional[Any] = ..., filename: Optional[Any] = ..., raw: bool = ..., defer_init: bool = ... + self, source, name: Any | None = ..., filename: Any | None = ..., raw: bool = ..., defer_init: bool = ... ): ... def compile_expression(self, source: Text, undefined_to_none: bool = ...): ... def compile_templates( self, target, - extensions: Optional[Any] = ..., - filter_func: Optional[Any] = ..., + extensions: Any | None = ..., + filter_func: Any | None = ..., zip: str = ..., - log_function: Optional[Any] = ..., + log_function: Any | None = ..., ignore_errors: bool = ..., py_compile: bool = ..., ): ... - def list_templates(self, extensions: Optional[Any] = ..., filter_func: Optional[Any] = ...): ... - def handle_exception(self, exc_info: Optional[Any] = ..., rendered: bool = ..., source_hint: Optional[Any] = ...): ... - def join_path(self, template: Union[Template, Text], parent: Text) -> Text: ... + def list_templates(self, extensions: Any | None = ..., filter_func: Any | None = ...): ... + def handle_exception(self, exc_info: Any | None = ..., rendered: bool = ..., source_hint: Any | None = ...): ... + def join_path(self, template: Template | Text, parent: Text) -> Text: ... def get_template( - self, name: Union[Template, Text], parent: Optional[Text] = ..., globals: Optional[Any] = ... + self, name: Template | Text, parent: Text | None = ..., globals: Any | None = ... ) -> Template: ... def select_template( - self, names: Sequence[Union[Template, Text]], parent: Optional[Text] = ..., globals: Optional[Dict[str, Any]] = ... + self, names: Sequence[Template | Text], parent: Text | None = ..., globals: Dict[str, Any] | None = ... ) -> Template: ... def get_or_select_template( self, - template_name_or_list: Union[Union[Template, Text], Sequence[Union[Template, Text]]], - parent: Optional[Text] = ..., - globals: Optional[Dict[str, Any]] = ..., + template_name_or_list: Template | Text | Sequence[Template | Text], + parent: Text | None = ..., + globals: Dict[str, Any] | None = ..., ) -> Template: ... def from_string( - self, source: Text, globals: Optional[Dict[str, Any]] = ..., template_class: Optional[Type[Template]] = ... + self, source: Text, globals: Dict[str, Any] | None = ..., template_class: Type[Template] | None = ... ) -> Template: ... - def make_globals(self, d: Optional[Dict[str, Any]]) -> Dict[str, Any]: ... + def make_globals(self, d: Dict[str, Any] | None) -> Dict[str, Any]: ... # Frequently added extensions are included here: # from InternationalizationExtension: - def install_gettext_translations(self, translations: Any, newstyle: Optional[bool] = ...): ... - def install_null_translations(self, newstyle: Optional[bool] = ...): ... + def install_gettext_translations(self, translations: Any, newstyle: bool | None = ...): ... + def install_null_translations(self, newstyle: bool | None = ...): ... def install_gettext_callables( - self, gettext: Callable[..., Any], ngettext: Callable[..., Any], newstyle: Optional[bool] = ... + self, gettext: Callable[..., Any], ngettext: Callable[..., Any], newstyle: bool | None = ... ): ... def uninstall_gettext_translations(self, translations: Any): ... def extract_translations(self, source: Any, gettext_functions: Any): ... newstyle_gettext: bool class Template: - name: Optional[str] - filename: Optional[str] + name: str | None + filename: str | None def __new__( cls, source, @@ -177,22 +177,22 @@ class Template: extensions: Any = ..., optimized: bool = ..., undefined: Any = ..., - finalize: Optional[Any] = ..., + finalize: Any | None = ..., autoescape: bool = ..., ): ... environment: Environment = ... @classmethod - def from_code(cls, environment, code, globals, uptodate: Optional[Any] = ...): ... + def from_code(cls, environment, code, globals, uptodate: Any | None = ...): ... @classmethod def from_module_dict(cls, environment, module_dict, globals): ... def render(self, *args, **kwargs) -> Text: ... def stream(self, *args, **kwargs) -> TemplateStream: ... def generate(self, *args, **kwargs) -> Iterator[Text]: ... def new_context( - self, vars: Optional[Dict[str, Any]] = ..., shared: bool = ..., locals: Optional[Dict[str, Any]] = ... + self, vars: Dict[str, Any] | None = ..., shared: bool = ..., locals: Dict[str, Any] | None = ... ) -> Context: ... def make_module( - self, vars: Optional[Dict[str, Any]] = ..., shared: bool = ..., locals: Optional[Dict[str, Any]] = ... + self, vars: Dict[str, Any] | None = ..., shared: bool = ..., locals: Dict[str, Any] | None = ... ) -> Context: ... @property def module(self) -> Any: ... @@ -216,7 +216,7 @@ class TemplateExpression: class TemplateStream: def __init__(self, gen) -> None: ... - def dump(self, fp, encoding: Optional[Text] = ..., errors: Text = ...): ... + def dump(self, fp, encoding: Text | None = ..., errors: Text = ...): ... buffered: bool def disable_buffering(self) -> None: ... def enable_buffering(self, size: int = ...) -> None: ... diff --git a/stubs/Jinja2/jinja2/exceptions.pyi b/stubs/Jinja2/jinja2/exceptions.pyi index 8f6be75c6d95..b9a750137511 100644 --- a/stubs/Jinja2/jinja2/exceptions.pyi +++ b/stubs/Jinja2/jinja2/exceptions.pyi @@ -1,7 +1,7 @@ from typing import Any, Optional, Text class TemplateError(Exception): - def __init__(self, message: Optional[Text] = ...) -> None: ... + def __init__(self, message: Text | None = ...) -> None: ... @property def message(self): ... def __unicode__(self): ... @@ -10,11 +10,11 @@ class TemplateNotFound(IOError, LookupError, TemplateError): message: Any name: Any templates: Any - def __init__(self, name, message: Optional[Text] = ...) -> None: ... + def __init__(self, name, message: Text | None = ...) -> None: ... class TemplatesNotFound(TemplateNotFound): templates: Any - def __init__(self, names: Any = ..., message: Optional[Text] = ...) -> None: ... + def __init__(self, names: Any = ..., message: Text | None = ...) -> None: ... class TemplateSyntaxError(TemplateError): lineno: int @@ -22,7 +22,7 @@ class TemplateSyntaxError(TemplateError): filename: Text source: Text translated: bool - def __init__(self, message: Text, lineno: int, name: Optional[Text] = ..., filename: Optional[Text] = ...) -> None: ... + def __init__(self, message: Text, lineno: int, name: Text | None = ..., filename: Text | None = ...) -> None: ... class TemplateAssertionError(TemplateSyntaxError): ... class TemplateRuntimeError(TemplateError): ... diff --git a/stubs/Jinja2/jinja2/ext.pyi b/stubs/Jinja2/jinja2/ext.pyi index cdf28922b201..4cd92f48f975 100644 --- a/stubs/Jinja2/jinja2/ext.pyi +++ b/stubs/Jinja2/jinja2/ext.pyi @@ -11,18 +11,18 @@ class Extension: environment: Any def __init__(self, environment) -> None: ... def bind(self, environment): ... - def preprocess(self, source, name, filename: Optional[Any] = ...): ... + def preprocess(self, source, name, filename: Any | None = ...): ... def filter_stream(self, stream): ... def parse(self, parser): ... - def attr(self, name, lineno: Optional[Any] = ...): ... + def attr(self, name, lineno: Any | None = ...): ... def call_method( self, name, - args: Optional[Any] = ..., - kwargs: Optional[Any] = ..., - dyn_args: Optional[Any] = ..., - dyn_kwargs: Optional[Any] = ..., - lineno: Optional[Any] = ..., + args: Any | None = ..., + kwargs: Any | None = ..., + dyn_args: Any | None = ..., + dyn_kwargs: Any | None = ..., + lineno: Any | None = ..., ): ... class InternationalizationExtension(Extension): diff --git a/stubs/Jinja2/jinja2/filters.pyi b/stubs/Jinja2/jinja2/filters.pyi index 8f0fb210aa4d..ea3f17c086cc 100644 --- a/stubs/Jinja2/jinja2/filters.pyi +++ b/stubs/Jinja2/jinja2/filters.pyi @@ -6,34 +6,34 @@ def environmentfilter(f): ... def make_attrgetter(environment, attribute): ... def do_forceescape(value): ... def do_urlencode(value): ... -def do_replace(eval_ctx, s, old, new, count: Optional[Any] = ...): ... +def do_replace(eval_ctx, s, old, new, count: Any | None = ...): ... def do_upper(s): ... def do_lower(s): ... def do_xmlattr(_eval_ctx, d, autospace: bool = ...): ... def do_capitalize(s): ... def do_title(s): ... def do_dictsort(value, case_sensitive: bool = ..., by: str = ...): ... -def do_sort(environment, value, reverse: bool = ..., case_sensitive: bool = ..., attribute: Optional[Any] = ...): ... +def do_sort(environment, value, reverse: bool = ..., case_sensitive: bool = ..., attribute: Any | None = ...): ... def do_default(value, default_value: str = ..., boolean: bool = ...): ... -def do_join(eval_ctx, value, d: str = ..., attribute: Optional[Any] = ...): ... +def do_join(eval_ctx, value, d: str = ..., attribute: Any | None = ...): ... def do_center(value, width: int = ...): ... def do_first(environment, seq): ... def do_last(environment, seq): ... def do_random(environment, seq): ... def do_filesizeformat(value, binary: bool = ...): ... def do_pprint(value, verbose: bool = ...): ... -def do_urlize(eval_ctx, value, trim_url_limit: Optional[Any] = ..., nofollow: bool = ..., target: Optional[Any] = ...): ... +def do_urlize(eval_ctx, value, trim_url_limit: Any | None = ..., nofollow: bool = ..., target: Any | None = ...): ... def do_indent(s, width: int = ..., indentfirst: bool = ...): ... def do_truncate(s, length: int = ..., killwords: bool = ..., end: str = ...): ... -def do_wordwrap(environment, s, width: int = ..., break_long_words: bool = ..., wrapstring: Optional[Any] = ...): ... +def do_wordwrap(environment, s, width: int = ..., break_long_words: bool = ..., wrapstring: Any | None = ...): ... def do_wordcount(s): ... def do_int(value, default: int = ..., base: int = ...): ... def do_float(value, default: float = ...): ... def do_format(value, *args, **kwargs): ... def do_trim(value): ... def do_striptags(value): ... -def do_slice(value, slices, fill_with: Optional[Any] = ...): ... -def do_batch(value, linecount, fill_with: Optional[Any] = ...): ... +def do_slice(value, slices, fill_with: Any | None = ...): ... +def do_batch(value, linecount, fill_with: Any | None = ...): ... def do_round(value, precision: int = ..., method: str = ...): ... def do_groupby(environment, value, attribute): ... @@ -41,7 +41,7 @@ class _GroupTuple(NamedTuple): grouper: Any list: Any -def do_sum(environment, iterable, attribute: Optional[Any] = ..., start: int = ...): ... +def do_sum(environment, iterable, attribute: Any | None = ..., start: int = ...): ... def do_list(value): ... def do_mark_safe(value): ... def do_mark_unsafe(value): ... diff --git a/stubs/Jinja2/jinja2/lexer.pyi b/stubs/Jinja2/jinja2/lexer.pyi index 88d80e69c92d..915cddc930e5 100644 --- a/stubs/Jinja2/jinja2/lexer.pyi +++ b/stubs/Jinja2/jinja2/lexer.pyi @@ -112,6 +112,6 @@ class Lexer: keep_trailing_newline: Any rules: Any def __init__(self, environment) -> None: ... - def tokenize(self, source, name: Optional[Any] = ..., filename: Optional[Any] = ..., state: Optional[Any] = ...): ... - def wrap(self, stream, name: Optional[Any] = ..., filename: Optional[Any] = ...): ... - def tokeniter(self, source, name, filename: Optional[Any] = ..., state: Optional[Any] = ...): ... + def tokenize(self, source, name: Any | None = ..., filename: Any | None = ..., state: Any | None = ...): ... + def wrap(self, stream, name: Any | None = ..., filename: Any | None = ...): ... + def tokeniter(self, source, name, filename: Any | None = ..., state: Any | None = ...): ... diff --git a/stubs/Jinja2/jinja2/loaders.pyi b/stubs/Jinja2/jinja2/loaders.pyi index 9f5cd943c0c1..d607eef66d4f 100644 --- a/stubs/Jinja2/jinja2/loaders.pyi +++ b/stubs/Jinja2/jinja2/loaders.pyi @@ -17,7 +17,7 @@ class BaseLoader: has_source_access: bool def get_source(self, environment, template): ... def list_templates(self): ... - def load(self, environment, name, globals: Optional[Any] = ...): ... + def load(self, environment, name, globals: Any | None = ...): ... class FileSystemLoader(BaseLoader): searchpath: Text @@ -48,7 +48,7 @@ class FunctionLoader(BaseLoader): def __init__(self, load_func) -> None: ... def get_source( self, environment: Environment, template: Text - ) -> Tuple[Text, Optional[Text], Optional[Callable[..., Any]]]: ... + ) -> Tuple[Text, Text | None, Callable[..., Any] | None]: ... class PrefixLoader(BaseLoader): mapping: Any @@ -56,14 +56,14 @@ class PrefixLoader(BaseLoader): def __init__(self, mapping, delimiter: str = ...) -> None: ... def get_loader(self, template): ... def get_source(self, environment: Environment, template: Text) -> Tuple[Text, Text, Callable[..., Any]]: ... - def load(self, environment, name, globals: Optional[Any] = ...): ... + def load(self, environment, name, globals: Any | None = ...): ... def list_templates(self): ... class ChoiceLoader(BaseLoader): loaders: Any def __init__(self, loaders) -> None: ... def get_source(self, environment: Environment, template: Text) -> Tuple[Text, Text, Callable[..., Any]]: ... - def load(self, environment, name, globals: Optional[Any] = ...): ... + def load(self, environment, name, globals: Any | None = ...): ... def list_templates(self): ... class _TemplateModule(ModuleType): ... @@ -77,4 +77,4 @@ class ModuleLoader(BaseLoader): def get_template_key(name): ... @staticmethod def get_module_filename(name): ... - def load(self, environment, name, globals: Optional[Any] = ...): ... + def load(self, environment, name, globals: Any | None = ...): ... diff --git a/stubs/Jinja2/jinja2/nodes.pyi b/stubs/Jinja2/jinja2/nodes.pyi index 84871975d3e2..6b5bf6966cfb 100644 --- a/stubs/Jinja2/jinja2/nodes.pyi +++ b/stubs/Jinja2/jinja2/nodes.pyi @@ -10,7 +10,7 @@ class EvalContext: environment: Any autoescape: Any volatile: bool - def __init__(self, environment, template_name: Optional[Any] = ...) -> None: ... + def __init__(self, environment, template_name: Any | None = ...) -> None: ... def save(self): ... def revert(self, old): ... @@ -21,8 +21,8 @@ class Node: attributes: Any abstract: bool def __init__(self, *fields, **attributes) -> None: ... - def iter_fields(self, exclude: Optional[Any] = ..., only: Optional[Any] = ...): ... - def iter_child_nodes(self, exclude: Optional[Any] = ..., only: Optional[Any] = ...): ... + def iter_fields(self, exclude: Any | None = ..., only: Any | None = ...): ... + def iter_child_nodes(self, exclude: Any | None = ..., only: Any | None = ...): ... def find(self, node_type): ... def find_all(self, node_type): ... def set_ctx(self, ctx): ... @@ -89,20 +89,20 @@ class AssignBlock(Stmt): class Expr(Node): abstract: bool - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... def can_assign(self): ... class BinExpr(Expr): fields: Any operator: Any abstract: bool - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class UnaryExpr(Expr): fields: Any operator: Any abstract: bool - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Name(Expr): fields: Any @@ -113,71 +113,71 @@ class Literal(Expr): class Const(Literal): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... @classmethod - def from_untrusted(cls, value, lineno: Optional[Any] = ..., environment: Optional[Any] = ...): ... + def from_untrusted(cls, value, lineno: Any | None = ..., environment: Any | None = ...): ... class TemplateData(Literal): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Tuple(Literal): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... def can_assign(self): ... class List(Literal): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Dict(Literal): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Pair(Helper): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Keyword(Helper): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class CondExpr(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Filter(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Test(Expr): fields: Any class Call(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Getitem(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... def can_assign(self): ... class Getattr(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... def can_assign(self): ... class Slice(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Concat(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Compare(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Operand(Helper): fields: Any @@ -205,11 +205,11 @@ class Pow(BinExpr): class And(BinExpr): operator: str - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Or(BinExpr): operator: str - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class Not(UnaryExpr): operator: str @@ -235,11 +235,11 @@ class InternalName(Expr): class MarkSafe(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class MarkSafeIfAutoescape(Expr): fields: Any - def as_const(self, eval_ctx: Optional[Any] = ...): ... + def as_const(self, eval_ctx: Any | None = ...): ... class ContextReference(Expr): ... class Continue(Stmt): ... diff --git a/stubs/Jinja2/jinja2/parser.pyi b/stubs/Jinja2/jinja2/parser.pyi index ae5962f64d08..ba53f6cfbcd3 100644 --- a/stubs/Jinja2/jinja2/parser.pyi +++ b/stubs/Jinja2/jinja2/parser.pyi @@ -8,13 +8,13 @@ class Parser: closed: bool extensions: Any def __init__( - self, environment, source, name: Optional[Any] = ..., filename: Optional[Any] = ..., state: Optional[Any] = ... + self, environment, source, name: Any | None = ..., filename: Any | None = ..., state: Any | None = ... ) -> None: ... - def fail(self, msg, lineno: Optional[Any] = ..., exc: Any = ...): ... - def fail_unknown_tag(self, name, lineno: Optional[Any] = ...): ... - def fail_eof(self, end_tokens: Optional[Any] = ..., lineno: Optional[Any] = ...): ... - def is_tuple_end(self, extra_end_rules: Optional[Any] = ...): ... - def free_identifier(self, lineno: Optional[Any] = ...): ... + def fail(self, msg, lineno: Any | None = ..., exc: Any = ...): ... + def fail_unknown_tag(self, name, lineno: Any | None = ...): ... + def fail_eof(self, end_tokens: Any | None = ..., lineno: Any | None = ...): ... + def is_tuple_end(self, extra_end_rules: Any | None = ...): ... + def free_identifier(self, lineno: Any | None = ...): ... def parse_statement(self): ... def parse_statements(self, end_tokens, drop_needle: bool = ...): ... def parse_set(self): ... @@ -31,7 +31,7 @@ class Parser: def parse_filter_block(self): ... def parse_macro(self): ... def parse_print(self): ... - def parse_assign_target(self, with_tuple: bool = ..., name_only: bool = ..., extra_end_rules: Optional[Any] = ...): ... + def parse_assign_target(self, with_tuple: bool = ..., name_only: bool = ..., extra_end_rules: Any | None = ...): ... def parse_expression(self, with_condexpr: bool = ...): ... def parse_condexpr(self): ... def parse_or(self): ... @@ -52,7 +52,7 @@ class Parser: self, simplified: bool = ..., with_condexpr: bool = ..., - extra_end_rules: Optional[Any] = ..., + extra_end_rules: Any | None = ..., explicit_parentheses: bool = ..., ): ... def parse_list(self): ... @@ -64,5 +64,5 @@ class Parser: def parse_call(self, node): ... def parse_filter(self, node, start_inline: bool = ...): ... def parse_test(self, node): ... - def subparse(self, end_tokens: Optional[Any] = ...): ... + def subparse(self, end_tokens: Any | None = ...): ... def parse(self): ... diff --git a/stubs/Jinja2/jinja2/runtime.pyi b/stubs/Jinja2/jinja2/runtime.pyi index 66ffe9d3e367..62ff25154c67 100644 --- a/stubs/Jinja2/jinja2/runtime.pyi +++ b/stubs/Jinja2/jinja2/runtime.pyi @@ -15,7 +15,7 @@ class TemplateReference: def __getitem__(self, name): ... class Context: - parent: Union[Context, Dict[str, Any]] + parent: Context | Dict[str, Any] vars: Dict[str, Any] environment: Environment eval_ctx: Any @@ -23,15 +23,15 @@ class Context: name: Text blocks: Dict[str, Any] def __init__( - self, environment: Environment, parent: Union[Context, Dict[str, Any]], name: Text, blocks: Dict[str, Any] + self, environment: Environment, parent: Context | Dict[str, Any], name: Text, blocks: Dict[str, Any] ) -> None: ... def super(self, name, current): ... - def get(self, key, default: Optional[Any] = ...): ... + def get(self, key, default: Any | None = ...): ... def resolve(self, key): ... def get_exported(self): ... def get_all(self): ... def call(__self, __obj, *args, **kwargs): ... - def derived(self, locals: Optional[Any] = ...): ... + def derived(self, locals: Any | None = ...): ... keys: Any values: Any items: Any @@ -51,7 +51,7 @@ class BlockReference: class LoopContext: index0: int depth0: Any - def __init__(self, iterable, recurse: Optional[Any] = ..., depth0: int = ...) -> None: ... + def __init__(self, iterable, recurse: Any | None = ..., depth0: int = ...) -> None: ... def cycle(self, *args): ... first: Any last: Any @@ -83,7 +83,7 @@ class Macro: def __call__(self, *args, **kwargs): ... class Undefined: - def __init__(self, hint: Optional[Any] = ..., obj: Any = ..., name: Optional[Any] = ..., exc: Any = ...) -> None: ... + def __init__(self, hint: Any | None = ..., obj: Any = ..., name: Any | None = ..., exc: Any = ...) -> None: ... def __getattr__(self, name): ... __add__: Any __radd__: Any @@ -118,7 +118,7 @@ class Undefined: def __nonzero__(self): ... __bool__: Any -def make_logging_undefined(logger: Optional[Any] = ..., base: Optional[Any] = ...): ... +def make_logging_undefined(logger: Any | None = ..., base: Any | None = ...): ... class DebugUndefined(Undefined): ... diff --git a/stubs/Jinja2/jinja2/utils.pyi b/stubs/Jinja2/jinja2/utils.pyi index 32e1aa091c51..591c6592e665 100644 --- a/stubs/Jinja2/jinja2/utils.pyi +++ b/stubs/Jinja2/jinja2/utils.pyi @@ -36,16 +36,16 @@ def select_autoescape( def consume(iterable: Iterable[object]) -> None: ... def clear_caches() -> None: ... def import_string(import_name: str, silent: bool = ...) -> Any: ... -def open_if_exists(filename: StrOrBytesPath, mode: str = ...) -> Optional[IO[Any]]: ... +def open_if_exists(filename: StrOrBytesPath, mode: str = ...) -> IO[Any] | None: ... def object_type_repr(obj: object) -> str: ... def pformat(obj: object, verbose: bool = ...) -> str: ... def urlize( - text: Union[Markup, Text], - trim_url_limit: Optional[int] = ..., - rel: Optional[Union[Markup, Text]] = ..., - target: Optional[Union[Markup, Text]] = ..., + text: Markup | Text, + trim_url_limit: int | None = ..., + rel: Markup | Text | None = ..., + target: Markup | Text | None = ..., ) -> str: ... -def generate_lorem_ipsum(n: int = ..., html: bool = ..., min: int = ..., max: int = ...) -> Union[Markup, str]: ... +def generate_lorem_ipsum(n: int = ..., html: bool = ..., min: int = ..., max: int = ...) -> Markup | str: ... def unicode_urlencode(obj: object, charset: str = ..., for_qs: bool = ...) -> str: ... class LRUCache: @@ -53,8 +53,8 @@ class LRUCache: def __init__(self, capacity) -> None: ... def __getnewargs__(self): ... def copy(self): ... - def get(self, key, default: Optional[Any] = ...): ... - def setdefault(self, key, default: Optional[Any] = ...): ... + def get(self, key, default: Any | None = ...): ... + def setdefault(self, key, default: Any | None = ...): ... def clear(self): ... def __contains__(self, key): ... def __len__(self): ... diff --git a/stubs/Markdown/markdown/core.pyi b/stubs/Markdown/markdown/core.pyi index 4d8dadfaac86..7db6eaf8cfb3 100644 --- a/stubs/Markdown/markdown/core.pyi +++ b/stubs/Markdown/markdown/core.pyi @@ -21,14 +21,14 @@ class Markdown: def __init__( self, *, - extensions: Optional[Sequence[Union[str, Extension]]] = ..., - extension_configs: Optional[Mapping[str, Mapping[str, Any]]] = ..., - output_format: Optional[Literal["xhtml", "html"]] = ..., - tab_length: Optional[int] = ..., + extensions: Sequence[str | Extension] | None = ..., + extension_configs: Mapping[str, Mapping[str, Any]] | None = ..., + output_format: Literal["xhtml", "html"] | None = ..., + tab_length: int | None = ..., ) -> None: ... def build_parser(self) -> Markdown: ... def registerExtensions( - self, extensions: Sequence[Union[Extension, str]], configs: Mapping[str, Mapping[str, Any]] + self, extensions: Sequence[Extension | str], configs: Mapping[str, Mapping[str, Any]] ) -> Markdown: ... def build_extension(self, ext_name: Text, configs: Mapping[str, str]) -> Extension: ... def registerExtension(self, extension: Extension) -> Markdown: ... @@ -38,26 +38,26 @@ class Markdown: def convert(self, source: Text) -> Text: ... def convertFile( self, - input: Optional[Union[str, TextIO, BinaryIO]] = ..., - output: Optional[Union[str, TextIO, BinaryIO]] = ..., - encoding: Optional[str] = ..., + input: str | TextIO | BinaryIO | None = ..., + output: str | TextIO | BinaryIO | None = ..., + encoding: str | None = ..., ) -> Markdown: ... def markdown( text: Text, *, - extensions: Optional[Sequence[Union[str, Extension]]] = ..., - extension_configs: Optional[Mapping[str, Mapping[str, Any]]] = ..., - output_format: Optional[Literal["xhtml", "html"]] = ..., - tab_length: Optional[int] = ..., + extensions: Sequence[str | Extension] | None = ..., + extension_configs: Mapping[str, Mapping[str, Any]] | None = ..., + output_format: Literal["xhtml", "html"] | None = ..., + tab_length: int | None = ..., ) -> Text: ... def markdownFromFile( *, - input: Optional[Union[str, TextIO, BinaryIO]] = ..., - output: Optional[Union[str, TextIO, BinaryIO]] = ..., - encoding: Optional[str] = ..., - extensions: Optional[Sequence[Union[str, Extension]]] = ..., - extension_configs: Optional[Mapping[str, Mapping[str, Any]]] = ..., - output_format: Optional[Literal["xhtml", "html"]] = ..., - tab_length: Optional[int] = ..., + input: str | TextIO | BinaryIO | None = ..., + output: str | TextIO | BinaryIO | None = ..., + encoding: str | None = ..., + extensions: Sequence[str | Extension] | None = ..., + extension_configs: Mapping[str, Mapping[str, Any]] | None = ..., + output_format: Literal["xhtml", "html"] | None = ..., + tab_length: int | None = ..., ) -> None: ... diff --git a/stubs/Markdown/markdown/extensions/codehilite.pyi b/stubs/Markdown/markdown/extensions/codehilite.pyi index bab370e97359..2cc87ce42aa6 100644 --- a/stubs/Markdown/markdown/extensions/codehilite.pyi +++ b/stubs/Markdown/markdown/extensions/codehilite.pyi @@ -21,16 +21,16 @@ class CodeHilite: options: Dict[str, Any] def __init__( self, - src: Optional[Any] = ..., + src: Any | None = ..., *, - linenums: Optional[Any] = ..., + linenums: Any | None = ..., guess_lang: bool = ..., css_class: str = ..., - lang: Optional[Any] = ..., + lang: Any | None = ..., style: str = ..., noclasses: bool = ..., tab_length: int = ..., - hl_lines: Optional[Any] = ..., + hl_lines: Any | None = ..., use_pygments: bool = ..., **options: Any, ) -> None: ... diff --git a/stubs/Markdown/markdown/inlinepatterns.pyi b/stubs/Markdown/markdown/inlinepatterns.pyi index f0820ff91dc6..32503352b45e 100644 --- a/stubs/Markdown/markdown/inlinepatterns.pyi +++ b/stubs/Markdown/markdown/inlinepatterns.pyi @@ -36,18 +36,18 @@ class Pattern: pattern: Any compiled_re: Any md: Any - def __init__(self, pattern, md: Optional[Any] = ...) -> None: ... + def __init__(self, pattern, md: Any | None = ...) -> None: ... @property def markdown(self): ... def getCompiledRegExp(self): ... - def handleMatch(self, m: Match[str]) -> Optional[Union[str, Element]]: ... + def handleMatch(self, m: Match[str]) -> str | Element | None: ... def type(self): ... def unescape(self, text): ... class InlineProcessor(Pattern): safe_mode: bool = ... - def __init__(self, pattern, md: Optional[Any] = ...) -> None: ... - def handleMatch(self, m: Match[str], data) -> Union[Tuple[Element, int, int], Tuple[None, None, None]]: ... # type: ignore + def __init__(self, pattern, md: Any | None = ...) -> None: ... + def handleMatch(self, m: Match[str], data) -> Tuple[Element, int, int] | Tuple[None, None, None]: ... # type: ignore class SimpleTextPattern(Pattern): ... class SimpleTextInlineProcessor(InlineProcessor): ... diff --git a/stubs/Markdown/markdown/treeprocessors.pyi b/stubs/Markdown/markdown/treeprocessors.pyi index a1725a66633b..e30689cf0d04 100644 --- a/stubs/Markdown/markdown/treeprocessors.pyi +++ b/stubs/Markdown/markdown/treeprocessors.pyi @@ -6,7 +6,7 @@ def build_treeprocessors(md, **kwargs): ... def isString(s): ... class Treeprocessor(util.Processor): - def run(self, root) -> Optional[Any]: ... + def run(self, root) -> Any | None: ... class InlineProcessor(Treeprocessor): inlinePatterns: Any @@ -14,6 +14,6 @@ class InlineProcessor(Treeprocessor): def __init__(self, md) -> None: ... stashed_nodes: Any parent_map: Any - def run(self, tree, ancestors: Optional[Any] = ...): ... + def run(self, tree, ancestors: Any | None = ...): ... class PrettifyTreeprocessor(Treeprocessor): ... diff --git a/stubs/Markdown/markdown/util.pyi b/stubs/Markdown/markdown/util.pyi index 556a8d7ebfee..98c144aa564d 100644 --- a/stubs/Markdown/markdown/util.pyi +++ b/stubs/Markdown/markdown/util.pyi @@ -24,7 +24,7 @@ class AtomicString(str): ... class Processor: md: Any - def __init__(self, md: Optional[Any] = ...) -> None: ... + def __init__(self, md: Any | None = ...) -> None: ... @property def markdown(self): ... diff --git a/stubs/MarkupSafe/markupsafe/__init__.pyi b/stubs/MarkupSafe/markupsafe/__init__.pyi index 272e4f75e4fa..4aa0e0356de1 100644 --- a/stubs/MarkupSafe/markupsafe/__init__.pyi +++ b/stubs/MarkupSafe/markupsafe/__init__.pyi @@ -7,7 +7,7 @@ from markupsafe._compat import text_type from markupsafe._native import escape as escape, escape_silent as escape_silent, soft_unicode as soft_unicode class Markup(text_type): - def __new__(cls, base: Text = ..., encoding: Optional[Text] = ..., errors: Text = ...) -> Markup: ... + def __new__(cls, base: Text = ..., encoding: Text | None = ..., errors: Text = ...) -> Markup: ... def __html__(self) -> Markup: ... def __add__(self, other: text_type) -> Markup: ... def __radd__(self, other: text_type) -> Markup: ... @@ -15,8 +15,8 @@ class Markup(text_type): def __rmul__(self, num: int) -> Markup: ... # type: ignore def __mod__(self, *args: Any) -> Markup: ... def join(self, seq: Iterable[text_type]) -> Markup: ... - def split(self, sep: Optional[text_type] = ..., maxsplit: SupportsIndex = ...) -> list[Markup]: ... # type: ignore - def rsplit(self, sep: Optional[text_type] = ..., maxsplit: SupportsIndex = ...) -> list[Markup]: ... # type: ignore + def split(self, sep: text_type | None = ..., maxsplit: SupportsIndex = ...) -> list[Markup]: ... # type: ignore + def rsplit(self, sep: text_type | None = ..., maxsplit: SupportsIndex = ...) -> list[Markup]: ... # type: ignore def splitlines(self, keepends: bool = ...) -> list[Markup]: ... # type: ignore def unescape(self) -> Text: ... def striptags(self) -> Text: ... @@ -27,7 +27,7 @@ class Markup(text_type): def format(self, *args: Any, **kwargs: Any) -> Markup: ... def __html_format__(self, format_spec: text_type) -> Markup: ... def __getslice__(self, start: int, stop: int) -> Markup: ... - def __getitem__(self, i: Union[int, slice]) -> Markup: ... + def __getitem__(self, i: int | slice) -> Markup: ... def capitalize(self) -> Markup: ... def title(self) -> Markup: ... def lower(self) -> Markup: ... @@ -36,13 +36,13 @@ class Markup(text_type): def replace(self, old: text_type, new: text_type, count: SupportsIndex = ...) -> Markup: ... def ljust(self, width: SupportsIndex, fillchar: text_type = ...) -> Markup: ... def rjust(self, width: SupportsIndex, fillchar: text_type = ...) -> Markup: ... - def lstrip(self, chars: Optional[text_type] = ...) -> Markup: ... - def rstrip(self, chars: Optional[text_type] = ...) -> Markup: ... - def strip(self, chars: Optional[text_type] = ...) -> Markup: ... + def lstrip(self, chars: text_type | None = ...) -> Markup: ... + def rstrip(self, chars: text_type | None = ...) -> Markup: ... + def strip(self, chars: text_type | None = ...) -> Markup: ... def center(self, width: SupportsIndex, fillchar: text_type = ...) -> Markup: ... def zfill(self, width: SupportsIndex) -> Markup: ... def translate( - self, table: Union[Mapping[int, Union[int, text_type, None]], Sequence[Union[int, text_type, None]]] + self, table: Mapping[int, int | text_type | None] | Sequence[int | text_type | None] ) -> Markup: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> Markup: ... diff --git a/stubs/MarkupSafe/markupsafe/_native.pyi b/stubs/MarkupSafe/markupsafe/_native.pyi index 01eb723f4ad6..b2af1190f111 100644 --- a/stubs/MarkupSafe/markupsafe/_native.pyi +++ b/stubs/MarkupSafe/markupsafe/_native.pyi @@ -3,6 +3,6 @@ from typing import Text, Union from . import Markup from ._compat import text_type -def escape(s: Union[Markup, Text]) -> Markup: ... -def escape_silent(s: Union[None, Markup, Text]) -> Markup: ... +def escape(s: Markup | Text) -> Markup: ... +def escape_silent(s: None | Markup | Text) -> Markup: ... def soft_unicode(s: Text) -> text_type: ... diff --git a/stubs/MarkupSafe/markupsafe/_speedups.pyi b/stubs/MarkupSafe/markupsafe/_speedups.pyi index 01eb723f4ad6..b2af1190f111 100644 --- a/stubs/MarkupSafe/markupsafe/_speedups.pyi +++ b/stubs/MarkupSafe/markupsafe/_speedups.pyi @@ -3,6 +3,6 @@ from typing import Text, Union from . import Markup from ._compat import text_type -def escape(s: Union[Markup, Text]) -> Markup: ... -def escape_silent(s: Union[None, Markup, Text]) -> Markup: ... +def escape(s: Markup | Text) -> Markup: ... +def escape_silent(s: None | Markup | Text) -> Markup: ... def soft_unicode(s: Text) -> text_type: ... diff --git a/stubs/PyMySQL/pymysql/cursors.pyi b/stubs/PyMySQL/pymysql/cursors.pyi index 7b95e1738da1..d06115bed272 100644 --- a/stubs/PyMySQL/pymysql/cursors.pyi +++ b/stubs/PyMySQL/pymysql/cursors.pyi @@ -18,10 +18,10 @@ class Cursor: def close(self) -> None: ... def setinputsizes(self, *args) -> None: ... def setoutputsizes(self, *args) -> None: ... - def nextset(self) -> Optional[bool]: ... + def nextset(self) -> bool | None: ... def mogrify(self, query: Text, args: object = ...) -> str: ... def execute(self, query: Text, args: object = ...) -> int: ... - def executemany(self, query: Text, args: Iterable[object]) -> Optional[int]: ... + def executemany(self, query: Text, args: Iterable[object]) -> int | None: ... def callproc(self, procname: Text, args: Iterable[Any] = ...) -> Any: ... def scroll(self, value: int, mode: Text = ...) -> None: ... def __enter__(self: _SelfT) -> _SelfT: ... diff --git a/stubs/PyYAML/yaml/__init__.pyi b/stubs/PyYAML/yaml/__init__.pyi index 1bf74c7891ae..4e8ea69bde63 100644 --- a/stubs/PyYAML/yaml/__init__.pyi +++ b/stubs/PyYAML/yaml/__init__.pyi @@ -29,14 +29,14 @@ def scan(stream, Loader=...): ... def parse(stream, Loader=...): ... def compose(stream, Loader=...): ... def compose_all(stream, Loader=...): ... -def load(stream: Union[bytes, IO[bytes], Text, IO[Text]], Loader=...) -> Any: ... -def load_all(stream: Union[bytes, IO[bytes], Text, IO[Text]], Loader=...) -> Iterator[Any]: ... -def full_load(stream: Union[bytes, IO[bytes], Text, IO[Text]]) -> Any: ... -def full_load_all(stream: Union[bytes, IO[bytes], Text, IO[Text]]) -> Iterator[Any]: ... -def safe_load(stream: Union[bytes, IO[bytes], Text, IO[Text]]) -> Any: ... -def safe_load_all(stream: Union[bytes, IO[bytes], Text, IO[Text]]) -> Iterator[Any]: ... -def unsafe_load(stream: Union[bytes, IO[bytes], Text, IO[Text]]) -> Any: ... -def unsafe_load_all(stream: Union[bytes, IO[bytes], Text, IO[Text]]) -> Iterator[Any]: ... +def load(stream: bytes | IO[bytes] | Text | IO[Text], Loader=...) -> Any: ... +def load_all(stream: bytes | IO[bytes] | Text | IO[Text], Loader=...) -> Iterator[Any]: ... +def full_load(stream: bytes | IO[bytes] | Text | IO[Text]) -> Any: ... +def full_load_all(stream: bytes | IO[bytes] | Text | IO[Text]) -> Iterator[Any]: ... +def safe_load(stream: bytes | IO[bytes] | Text | IO[Text]) -> Any: ... +def safe_load_all(stream: bytes | IO[bytes] | Text | IO[Text]) -> Iterator[Any]: ... +def unsafe_load(stream: bytes | IO[bytes] | Text | IO[Text]) -> Any: ... +def unsafe_load_all(stream: bytes | IO[bytes] | Text | IO[Text]) -> Iterator[Any]: ... def emit(events, stream=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=...): ... @overload def serialize_all( @@ -64,7 +64,7 @@ def serialize_all( width=..., allow_unicode=..., line_break=..., - encoding: Optional[_Str] = ..., + encoding: _Str | None = ..., explicit_start=..., explicit_end=..., version=..., @@ -98,7 +98,7 @@ def serialize( width=..., allow_unicode=..., line_break=..., - encoding: Optional[_Str] = ..., + encoding: _Str | None = ..., explicit_start=..., explicit_end=..., version=..., @@ -135,7 +135,7 @@ def dump_all( width=..., allow_unicode=..., line_break=..., - encoding: Optional[_Str] = ..., + encoding: _Str | None = ..., explicit_start=..., explicit_end=..., version=..., @@ -175,7 +175,7 @@ def dump( width=..., allow_unicode=..., line_break=..., - encoding: Optional[_Str] = ..., + encoding: _Str | None = ..., explicit_start=..., explicit_end=..., version=..., @@ -213,7 +213,7 @@ def safe_dump_all( width=..., allow_unicode=..., line_break=..., - encoding: Optional[_Str] = ..., + encoding: _Str | None = ..., explicit_start=..., explicit_end=..., version=..., @@ -251,7 +251,7 @@ def safe_dump( width=..., allow_unicode=..., line_break=..., - encoding: Optional[_Str] = ..., + encoding: _Str | None = ..., explicit_start=..., explicit_end=..., version=..., diff --git a/stubs/PyYAML/yaml/composer.pyi b/stubs/PyYAML/yaml/composer.pyi index c0d68bcf0a54..44bc4ad60ccf 100644 --- a/stubs/PyYAML/yaml/composer.pyi +++ b/stubs/PyYAML/yaml/composer.pyi @@ -9,10 +9,10 @@ class Composer: anchors: Dict[Any, Node] def __init__(self) -> None: ... def check_node(self) -> bool: ... - def get_node(self) -> Optional[Node]: ... - def get_single_node(self) -> Optional[Node]: ... - def compose_document(self) -> Optional[Node]: ... - def compose_node(self, parent: Optional[Node], index: int) -> Optional[Node]: ... + def get_node(self) -> Node | None: ... + def get_single_node(self) -> Node | None: ... + def compose_document(self) -> Node | None: ... + def compose_node(self, parent: Node | None, index: int) -> Node | None: ... def compose_scalar_node(self, anchor: Dict[Any, Node]) -> ScalarNode: ... def compose_sequence_node(self, anchor: Dict[Any, Node]) -> SequenceNode: ... def compose_mapping_node(self, anchor: Dict[Any, Node]) -> MappingNode: ... diff --git a/stubs/PyYAML/yaml/cyaml.pyi b/stubs/PyYAML/yaml/cyaml.pyi index 50f7af2f178c..4f0184e281f6 100644 --- a/stubs/PyYAML/yaml/cyaml.pyi +++ b/stubs/PyYAML/yaml/cyaml.pyi @@ -9,16 +9,16 @@ from yaml.serializer import Serializer _Readable = SupportsRead[Union[Text, bytes]] class CParser: - def __init__(self, stream: Union[str, bytes, _Readable]) -> None: ... + def __init__(self, stream: str | bytes | _Readable) -> None: ... class CBaseLoader(CParser, BaseConstructor, BaseResolver): - def __init__(self, stream: Union[str, bytes, _Readable]) -> None: ... + def __init__(self, stream: str | bytes | _Readable) -> None: ... class CLoader(CParser, SafeConstructor, Resolver): - def __init__(self, stream: Union[str, bytes, _Readable]) -> None: ... + def __init__(self, stream: str | bytes | _Readable) -> None: ... class CSafeLoader(CParser, SafeConstructor, Resolver): - def __init__(self, stream: Union[str, bytes, _Readable]) -> None: ... + def __init__(self, stream: str | bytes | _Readable) -> None: ... class CDangerLoader(CParser, Constructor, Resolver): ... # undocumented @@ -26,34 +26,34 @@ class CEmitter(object): def __init__( self, stream: IO[Any], - canonical: Optional[Any] = ..., - indent: Optional[int] = ..., - width: Optional[int] = ..., - allow_unicode: Optional[Any] = ..., - line_break: Optional[str] = ..., - encoding: Optional[Text] = ..., - explicit_start: Optional[Any] = ..., - explicit_end: Optional[Any] = ..., - version: Optional[Sequence[int]] = ..., - tags: Optional[Mapping[Text, Text]] = ..., + canonical: Any | None = ..., + indent: int | None = ..., + width: int | None = ..., + allow_unicode: Any | None = ..., + line_break: str | None = ..., + encoding: Text | None = ..., + explicit_start: Any | None = ..., + explicit_end: Any | None = ..., + version: Sequence[int] | None = ..., + tags: Mapping[Text, Text] | None = ..., ) -> None: ... class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): def __init__( self, stream: IO[Any], - default_style: Optional[str] = ..., - default_flow_style: Optional[bool] = ..., - canonical: Optional[Any] = ..., - indent: Optional[int] = ..., - width: Optional[int] = ..., - allow_unicode: Optional[Any] = ..., - line_break: Optional[str] = ..., - encoding: Optional[Text] = ..., - explicit_start: Optional[Any] = ..., - explicit_end: Optional[Any] = ..., - version: Optional[Sequence[int]] = ..., - tags: Optional[Mapping[Text, Text]] = ..., + default_style: str | None = ..., + default_flow_style: bool | None = ..., + canonical: Any | None = ..., + indent: int | None = ..., + width: int | None = ..., + allow_unicode: Any | None = ..., + line_break: str | None = ..., + encoding: Text | None = ..., + explicit_start: Any | None = ..., + explicit_end: Any | None = ..., + version: Sequence[int] | None = ..., + tags: Mapping[Text, Text] | None = ..., ) -> None: ... class CDumper(CEmitter, SafeRepresenter, Resolver): ... diff --git a/stubs/Pygments/pygments/__init__.pyi b/stubs/Pygments/pygments/__init__.pyi index f9bac84d8255..d6407af1babe 100644 --- a/stubs/Pygments/pygments/__init__.pyi +++ b/stubs/Pygments/pygments/__init__.pyi @@ -1,5 +1,5 @@ from typing import Any, Optional def lex(code, lexer): ... -def format(tokens, formatter, outfile: Optional[Any] = ...): ... -def highlight(code, lexer, formatter, outfile: Optional[Any] = ...): ... +def format(tokens, formatter, outfile: Any | None = ...): ... +def highlight(code, lexer, formatter, outfile: Any | None = ...): ... diff --git a/stubs/Pygments/pygments/cmdline.pyi b/stubs/Pygments/pygments/cmdline.pyi index 6cb7ee16952d..4846ec18c24e 100644 --- a/stubs/Pygments/pygments/cmdline.pyi +++ b/stubs/Pygments/pygments/cmdline.pyi @@ -4,6 +4,6 @@ from typing import Any, Optional def main_inner(parser, argns): ... class HelpFormatter(argparse.HelpFormatter): - def __init__(self, prog, indent_increment: int = ..., max_help_position: int = ..., width: Optional[Any] = ...) -> None: ... + def __init__(self, prog, indent_increment: int = ..., max_help_position: int = ..., width: Any | None = ...) -> None: ... def main(args=...): ... diff --git a/stubs/Pygments/pygments/filter.pyi b/stubs/Pygments/pygments/filter.pyi index 52fed2e60ad0..796ff59aff2f 100644 --- a/stubs/Pygments/pygments/filter.pyi +++ b/stubs/Pygments/pygments/filter.pyi @@ -4,7 +4,7 @@ from typing import Any, Optional from pygments.lexer import Lexer from pygments.token import _TokenType -def apply_filters(stream, filters, lexer: Optional[Any] = ...): ... +def apply_filters(stream, filters, lexer: Any | None = ...): ... def simplefilter(f): ... class Filter: diff --git a/stubs/Pygments/pygments/formatters/html.pyi b/stubs/Pygments/pygments/formatters/html.pyi index 05fb7783a930..b7507c499d53 100644 --- a/stubs/Pygments/pygments/formatters/html.pyi +++ b/stubs/Pygments/pygments/formatters/html.pyi @@ -31,9 +31,9 @@ class HtmlFormatter(Formatter): anchorlinenos: Any hl_lines: Any def __init__(self, **options) -> None: ... - def get_style_defs(self, arg: Optional[Any] = ...): ... - def get_token_style_defs(self, arg: Optional[Any] = ...): ... - def get_background_style_defs(self, arg: Optional[Any] = ...): ... + def get_style_defs(self, arg: Any | None = ...): ... + def get_token_style_defs(self, arg: Any | None = ...): ... + def get_background_style_defs(self, arg: Any | None = ...): ... def get_linenos_style_defs(self): ... def get_css_prefix(self, arg): ... def wrap(self, source, outfile): ... diff --git a/stubs/Pygments/pygments/formatters/terminal256.pyi b/stubs/Pygments/pygments/formatters/terminal256.pyi index 493af5d87e8f..048946e45bea 100644 --- a/stubs/Pygments/pygments/formatters/terminal256.pyi +++ b/stubs/Pygments/pygments/formatters/terminal256.pyi @@ -9,7 +9,7 @@ class EscapeSequence: underline: Any italic: Any def __init__( - self, fg: Optional[Any] = ..., bg: Optional[Any] = ..., bold: bool = ..., underline: bool = ..., italic: bool = ... + self, fg: Any | None = ..., bg: Any | None = ..., bold: bool = ..., underline: bool = ..., italic: bool = ... ) -> None: ... def escape(self, attrs): ... def color_string(self): ... diff --git a/stubs/Pygments/pygments/lexer.pyi b/stubs/Pygments/pygments/lexer.pyi index fd969e4e8c89..4b2d40cb8096 100644 --- a/stubs/Pygments/pygments/lexer.pyi +++ b/stubs/Pygments/pygments/lexer.pyi @@ -46,9 +46,9 @@ class combined(Tuple[Any]): class _PseudoMatch: def __init__(self, start, text) -> None: ... - def start(self, arg: Optional[Any] = ...): ... - def end(self, arg: Optional[Any] = ...): ... - def group(self, arg: Optional[Any] = ...): ... + def start(self, arg: Any | None = ...): ... + def end(self, arg: Any | None = ...): ... + def group(self, arg: Any | None = ...): ... def groups(self): ... def groupdict(self): ... @@ -72,7 +72,7 @@ class words(Future): def get(self): ... class RegexLexerMeta(LexerMeta): - def process_tokendef(cls, name, tokendefs: Optional[Any] = ...): ... + def process_tokendef(cls, name, tokendefs: Any | None = ...): ... def get_tokendefs(cls): ... def __call__(cls, *args, **kwds): ... @@ -86,7 +86,7 @@ class LexerContext: pos: Any end: Any stack: Any - def __init__(self, text, pos, stack: Optional[Any] = ..., end: Optional[Any] = ...) -> None: ... + def __init__(self, text, pos, stack: Any | None = ..., end: Any | None = ...) -> None: ... class ExtendedRegexLexer(RegexLexer): def get_tokens_unprocessed(self, text: str | None = ..., context: LexerContext | None = ...) -> Iterator[tuple[int, _TokenType, str]]: ... # type: ignore diff --git a/stubs/Pygments/pygments/util.pyi b/stubs/Pygments/pygments/util.pyi index 1f0b77aea19c..1dd131dbf6e0 100644 --- a/stubs/Pygments/pygments/util.pyi +++ b/stubs/Pygments/pygments/util.pyi @@ -9,10 +9,10 @@ xml_decl_re: Any class ClassNotFound(ValueError): ... class OptionError(Exception): ... -def get_choice_opt(options, optname, allowed, default: Optional[Any] = ..., normcase: bool = ...): ... -def get_bool_opt(options, optname, default: Optional[Any] = ...): ... -def get_int_opt(options, optname, default: Optional[Any] = ...): ... -def get_list_opt(options, optname, default: Optional[Any] = ...): ... +def get_choice_opt(options, optname, allowed, default: Any | None = ..., normcase: bool = ...): ... +def get_bool_opt(options, optname, default: Any | None = ...): ... +def get_int_opt(options, optname, default: Any | None = ...): ... +def get_list_opt(options, optname, default: Any | None = ...): ... def docstring_headline(obj): ... def make_analysator(f): ... def shebang_matches(text, regex): ... diff --git a/stubs/Werkzeug/werkzeug/_compat.pyi b/stubs/Werkzeug/werkzeug/_compat.pyi index f8a13f7783da..217c66cba311 100644 --- a/stubs/Werkzeug/werkzeug/_compat.pyi +++ b/stubs/Werkzeug/werkzeug/_compat.pyi @@ -44,7 +44,7 @@ def wsgi_decoding_dance(s, charset: Text = ..., errors: Text = ...): ... def wsgi_encoding_dance(s, charset: Text = ..., errors: Text = ...): ... def to_bytes(x, charset: Text = ..., errors: Text = ...): ... def to_native(x, charset: Text = ..., errors: Text = ...): ... -def reraise(tp, value, tb: Optional[Any] = ...): ... +def reraise(tp, value, tb: Any | None = ...): ... imap: Any izip: Any diff --git a/stubs/Werkzeug/werkzeug/_internal.pyi b/stubs/Werkzeug/werkzeug/_internal.pyi index ed23d7e136a5..588fb6e0f93b 100644 --- a/stubs/Werkzeug/werkzeug/_internal.pyi +++ b/stubs/Werkzeug/werkzeug/_internal.pyi @@ -13,14 +13,14 @@ class _DictAccessorProperty: def __init__( self, name, - default: Optional[Any] = ..., - load_func: Optional[Any] = ..., - dump_func: Optional[Any] = ..., - read_only: Optional[Any] = ..., - doc: Optional[Any] = ..., + default: Any | None = ..., + load_func: Any | None = ..., + dump_func: Any | None = ..., + read_only: Any | None = ..., + doc: Any | None = ..., ): ... - def __get__(self, obj, type: Optional[Any] = ...): ... + def __get__(self, obj, type: Any | None = ...): ... def __set__(self, obj, value): ... def __delete__(self, obj): ... -def _easteregg(app: Optional[Any] = ...): ... +def _easteregg(app: Any | None = ...): ... diff --git a/stubs/Werkzeug/werkzeug/_reloader.pyi b/stubs/Werkzeug/werkzeug/_reloader.pyi index be23222f6252..749940de9db9 100644 --- a/stubs/Werkzeug/werkzeug/_reloader.pyi +++ b/stubs/Werkzeug/werkzeug/_reloader.pyi @@ -4,7 +4,7 @@ class ReloaderLoop: name: Any extra_files: Any interval: float - def __init__(self, extra_files: Optional[Any] = ..., interval: float = ...): ... + def __init__(self, extra_files: Any | None = ..., interval: float = ...): ... def run(self): ... def restart_with_reloader(self): ... def trigger_reload(self, filename): ... @@ -26,4 +26,4 @@ class WatchdogReloaderLoop(ReloaderLoop): reloader_loops: Any -def run_with_reloader(main_func, extra_files: Optional[Any] = ..., interval: float = ..., reloader_type: str = ...): ... +def run_with_reloader(main_func, extra_files: Any | None = ..., interval: float = ..., reloader_type: str = ...): ... diff --git a/stubs/Werkzeug/werkzeug/contrib/atom.pyi b/stubs/Werkzeug/werkzeug/contrib/atom.pyi index d02a482966cb..950eebfb8d13 100644 --- a/stubs/Werkzeug/werkzeug/contrib/atom.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/atom.pyi @@ -22,7 +22,7 @@ class AtomFeed: generator: Any links: Any entries: Any - def __init__(self, title: Optional[Any] = ..., entries: Optional[Any] = ..., **kwargs): ... + def __init__(self, title: Any | None = ..., entries: Any | None = ..., **kwargs): ... def add(self, *args, **kwargs): ... def generate(self): ... def to_string(self): ... @@ -45,6 +45,6 @@ class FeedEntry: links: Any categories: Any xml_base: Any - def __init__(self, title: Optional[Any] = ..., content: Optional[Any] = ..., feed_url: Optional[Any] = ..., **kwargs): ... + def __init__(self, title: Any | None = ..., content: Any | None = ..., feed_url: Any | None = ..., **kwargs): ... def generate(self): ... def to_string(self): ... diff --git a/stubs/Werkzeug/werkzeug/contrib/cache.pyi b/stubs/Werkzeug/werkzeug/contrib/cache.pyi index a53bcea61248..2b24d2ec1e22 100644 --- a/stubs/Werkzeug/werkzeug/contrib/cache.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/cache.pyi @@ -7,9 +7,9 @@ class BaseCache: def delete(self, key): ... def get_many(self, *keys): ... def get_dict(self, *keys): ... - def set(self, key, value, timeout: Optional[float] = ...): ... - def add(self, key, value, timeout: Optional[float] = ...): ... - def set_many(self, mapping, timeout: Optional[float] = ...): ... + def set(self, key, value, timeout: float | None = ...): ... + def add(self, key, value, timeout: float | None = ...): ... + def set_many(self, mapping, timeout: float | None = ...): ... def delete_many(self, *keys): ... def has(self, key): ... def clear(self): ... @@ -22,20 +22,20 @@ class SimpleCache(BaseCache): clear: Any def __init__(self, threshold: int = ..., default_timeout: float = ...): ... def get(self, key): ... - def set(self, key, value, timeout: Optional[float] = ...): ... - def add(self, key, value, timeout: Optional[float] = ...): ... + def set(self, key, value, timeout: float | None = ...): ... + def add(self, key, value, timeout: float | None = ...): ... def delete(self, key): ... def has(self, key): ... class MemcachedCache(BaseCache): key_prefix: Any - def __init__(self, servers: Optional[Any] = ..., default_timeout: float = ..., key_prefix: Optional[Any] = ...): ... + def __init__(self, servers: Any | None = ..., default_timeout: float = ..., key_prefix: Any | None = ...): ... def get(self, key): ... def get_dict(self, *keys): ... - def add(self, key, value, timeout: Optional[float] = ...): ... - def set(self, key, value, timeout: Optional[float] = ...): ... + def add(self, key, value, timeout: float | None = ...): ... + def set(self, key, value, timeout: float | None = ...): ... def get_many(self, *keys): ... - def set_many(self, mapping, timeout: Optional[float] = ...): ... + def set_many(self, mapping, timeout: float | None = ...): ... def delete(self, key): ... def delete_many(self, *keys): ... def has(self, key): ... @@ -52,19 +52,19 @@ class RedisCache(BaseCache): self, host: str = ..., port: int = ..., - password: Optional[Any] = ..., + password: Any | None = ..., db: int = ..., default_timeout: float = ..., - key_prefix: Optional[Any] = ..., + key_prefix: Any | None = ..., **kwargs, ): ... def dump_object(self, value): ... def load_object(self, value): ... def get(self, key): ... def get_many(self, *keys): ... - def set(self, key, value, timeout: Optional[float] = ...): ... - def add(self, key, value, timeout: Optional[float] = ...): ... - def set_many(self, mapping, timeout: Optional[float] = ...): ... + def set(self, key, value, timeout: float | None = ...): ... + def add(self, key, value, timeout: float | None = ...): ... + def set_many(self, mapping, timeout: float | None = ...): ... def delete(self, key): ... def delete_many(self, *keys): ... def has(self, key): ... @@ -76,8 +76,8 @@ class FileSystemCache(BaseCache): def __init__(self, cache_dir, threshold: int = ..., default_timeout: float = ..., mode: int = ...): ... def clear(self): ... def get(self, key): ... - def add(self, key, value, timeout: Optional[float] = ...): ... - def set(self, key, value, timeout: Optional[float] = ...): ... + def add(self, key, value, timeout: float | None = ...): ... + def set(self, key, value, timeout: float | None = ...): ... def delete(self, key): ... def has(self, key): ... @@ -86,7 +86,7 @@ class UWSGICache(BaseCache): def __init__(self, default_timeout: float = ..., cache: str = ...): ... def get(self, key): ... def delete(self, key): ... - def set(self, key, value, timeout: Optional[float] = ...): ... - def add(self, key, value, timeout: Optional[float] = ...): ... + def set(self, key, value, timeout: float | None = ...): ... + def add(self, key, value, timeout: float | None = ...): ... def clear(self): ... def has(self, key): ... diff --git a/stubs/Werkzeug/werkzeug/contrib/fixers.pyi b/stubs/Werkzeug/werkzeug/contrib/fixers.pyi index f7605a707604..2b232c4a688c 100644 --- a/stubs/Werkzeug/werkzeug/contrib/fixers.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/fixers.pyi @@ -21,7 +21,7 @@ class HeaderRewriterFix(object): remove_headers: Set[Text] add_headers: List[Text] def __init__( - self, app: WSGIApplication, remove_headers: Optional[Iterable[Text]] = ..., add_headers: Optional[Iterable[Text]] = ... + self, app: WSGIApplication, remove_headers: Iterable[Text] | None = ..., add_headers: Iterable[Text] | None = ... ) -> None: ... def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... @@ -30,6 +30,6 @@ class InternetExplorerFix(object): fix_vary: bool fix_attach: bool def __init__(self, app: WSGIApplication, fix_vary: bool = ..., fix_attach: bool = ...) -> None: ... - def fix_headers(self, environ: WSGIEnvironment, headers: Mapping[str, str], status: Optional[Any] = ...) -> None: ... + def fix_headers(self, environ: WSGIEnvironment, headers: Mapping[str, str], status: Any | None = ...) -> None: ... def run_fixed(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... diff --git a/stubs/Werkzeug/werkzeug/contrib/iterio.pyi b/stubs/Werkzeug/werkzeug/contrib/iterio.pyi index c7ce70cd1646..baf2b6813a19 100644 --- a/stubs/Werkzeug/werkzeug/contrib/iterio.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/iterio.pyi @@ -3,23 +3,23 @@ from typing import Any, Optional, Text, Union greenlet: Any class IterIO: - def __new__(cls, obj, sentinel: Union[Text, bytes] = ...): ... + def __new__(cls, obj, sentinel: Text | bytes = ...): ... def __iter__(self): ... def tell(self): ... def isatty(self): ... def seek(self, pos, mode: int = ...): ... - def truncate(self, size: Optional[Any] = ...): ... + def truncate(self, size: Any | None = ...): ... def write(self, s): ... def writelines(self, list): ... def read(self, n: int = ...): ... def readlines(self, sizehint: int = ...): ... - def readline(self, length: Optional[Any] = ...): ... + def readline(self, length: Any | None = ...): ... def flush(self): ... def __next__(self): ... class IterI(IterIO): sentinel: Any - def __new__(cls, func, sentinel: Union[Text, bytes] = ...): ... + def __new__(cls, func, sentinel: Text | bytes = ...): ... closed: Any def close(self): ... def write(self, s): ... @@ -30,10 +30,10 @@ class IterO(IterIO): sentinel: Any closed: Any pos: Any - def __new__(cls, gen, sentinel: Union[Text, bytes] = ...): ... + def __new__(cls, gen, sentinel: Text | bytes = ...): ... def __iter__(self): ... def close(self): ... def seek(self, pos, mode: int = ...): ... def read(self, n: int = ...): ... - def readline(self, length: Optional[Any] = ...): ... + def readline(self, length: Any | None = ...): ... def readlines(self, sizehint: int = ...): ... diff --git a/stubs/Werkzeug/werkzeug/contrib/securecookie.pyi b/stubs/Werkzeug/werkzeug/contrib/securecookie.pyi index 48309b440959..8ebf6b0407ee 100644 --- a/stubs/Werkzeug/werkzeug/contrib/securecookie.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/securecookie.pyi @@ -12,28 +12,28 @@ class SecureCookie(ModificationTrackingDict[Any, Any]): quote_base64: Any secret_key: Any new: Any - def __init__(self, data: Optional[Any] = ..., secret_key: Optional[Any] = ..., new: bool = ...): ... + def __init__(self, data: Any | None = ..., secret_key: Any | None = ..., new: bool = ...): ... @property def should_save(self): ... @classmethod def quote(cls, value): ... @classmethod def unquote(cls, value): ... - def serialize(self, expires: Optional[Any] = ...): ... + def serialize(self, expires: Any | None = ...): ... @classmethod def unserialize(cls, string, secret_key): ... @classmethod - def load_cookie(cls, request, key: str = ..., secret_key: Optional[Any] = ...): ... + def load_cookie(cls, request, key: str = ..., secret_key: Any | None = ...): ... def save_cookie( self, response, key: str = ..., - expires: Optional[Any] = ..., - session_expires: Optional[Any] = ..., - max_age: Optional[Any] = ..., + expires: Any | None = ..., + session_expires: Any | None = ..., + max_age: Any | None = ..., path: str = ..., - domain: Optional[Any] = ..., - secure: Optional[Any] = ..., + domain: Any | None = ..., + secure: Any | None = ..., httponly: bool = ..., force: bool = ..., ): ... diff --git a/stubs/Werkzeug/werkzeug/contrib/sessions.pyi b/stubs/Werkzeug/werkzeug/contrib/sessions.pyi index bee2300789d0..ddc8b5126974 100644 --- a/stubs/Werkzeug/werkzeug/contrib/sessions.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/sessions.pyi @@ -5,7 +5,7 @@ from werkzeug.datastructures import CallbackDict _K = TypeVar("_K") _V = TypeVar("_V") -def generate_key(salt: Optional[Any] = ...): ... +def generate_key(salt: Any | None = ...): ... class ModificationTrackingDict(CallbackDict[_K, _V]): modified: Any @@ -22,9 +22,9 @@ class Session(ModificationTrackingDict[_K, _V]): class SessionStore: session_class: Any - def __init__(self, session_class: Optional[Any] = ...): ... + def __init__(self, session_class: Any | None = ...): ... def is_valid_key(self, key): ... - def generate_key(self, salt: Optional[Any] = ...): ... + def generate_key(self, salt: Any | None = ...): ... def new(self): ... def save(self, session): ... def save_if_modified(self, session): ... @@ -38,9 +38,9 @@ class FilesystemSessionStore(SessionStore): mode: Any def __init__( self, - path: Optional[Any] = ..., + path: Any | None = ..., filename_template: Text = ..., - session_class: Optional[Any] = ..., + session_class: Any | None = ..., renew_missing: bool = ..., mode: int = ..., ): ... @@ -66,11 +66,11 @@ class SessionMiddleware: app, store, cookie_name: str = ..., - cookie_age: Optional[Any] = ..., - cookie_expires: Optional[Any] = ..., + cookie_age: Any | None = ..., + cookie_expires: Any | None = ..., cookie_path: str = ..., - cookie_domain: Optional[Any] = ..., - cookie_secure: Optional[Any] = ..., + cookie_domain: Any | None = ..., + cookie_secure: Any | None = ..., cookie_httponly: bool = ..., environ_key: str = ..., ): ... diff --git a/stubs/Werkzeug/werkzeug/datastructures.pyi b/stubs/Werkzeug/werkzeug/datastructures.pyi index 6cf2e5ad51cc..049179d8ee3f 100644 --- a/stubs/Werkzeug/werkzeug/datastructures.pyi +++ b/stubs/Werkzeug/werkzeug/datastructures.pyi @@ -49,7 +49,7 @@ class ImmutableListMixin(Generic[_V]): def insert(self, pos: int, value: Any) -> NoReturn: ... def pop(self, index: int = ...) -> NoReturn: ... def reverse(self) -> NoReturn: ... - def sort(self, cmp: Optional[Any] = ..., key: Optional[Any] = ..., reverse: Optional[Any] = ...) -> NoReturn: ... + def sort(self, cmp: Any | None = ..., key: Any | None = ..., reverse: Any | None = ...) -> NoReturn: ... class ImmutableList(ImmutableListMixin[_V], List[_V]): ... # type: ignore @@ -58,9 +58,9 @@ class ImmutableDictMixin(object): def fromkeys(cls, *args, **kwargs): ... def __reduce_ex__(self, protocol): ... def __hash__(self) -> int: ... - def setdefault(self, key, default: Optional[Any] = ...): ... + def setdefault(self, key, default: Any | None = ...): ... def update(self, *args, **kwargs): ... - def pop(self, key, default: Optional[Any] = ...): ... + def pop(self, key, default: Any | None = ...): ... def popitem(self): ... def __setitem__(self, key, value): ... def __delitem__(self, key): ... @@ -72,11 +72,11 @@ class ImmutableMultiDictMixin(ImmutableDictMixin): def popitemlist(self): ... def poplist(self, key): ... def setlist(self, key, new_list): ... - def setlistdefault(self, key, default_list: Optional[Any] = ...): ... + def setlistdefault(self, key, default_list: Any | None = ...): ... class UpdateDictMixin(object): on_update: Any - def setdefault(self, key, default: Optional[Any] = ...): ... + def setdefault(self, key, default: Any | None = ...): ... def pop(self, key, default=...): ... __setitem__: Any __delitem__: Any @@ -86,13 +86,13 @@ class UpdateDictMixin(object): class TypeConversionDict(Dict[_K, _V]): @overload - def get(self, key: _K, *, type: None = ...) -> Optional[_V]: ... + def get(self, key: _K, *, type: None = ...) -> _V | None: ... @overload - def get(self, key: _K, default: _D, type: None = ...) -> Union[_V, _D]: ... + def get(self, key: _K, default: _D, type: None = ...) -> _V | _D: ... @overload - def get(self, key: _K, *, type: Callable[[_V], _R]) -> Optional[_R]: ... + def get(self, key: _K, *, type: Callable[[_V], _R]) -> _R | None: ... @overload - def get(self, key: _K, default: _D, type: Callable[[_V], _R]) -> Union[_R, _D]: ... + def get(self, key: _K, default: _D, type: Callable[[_V], _R]) -> _R | _D: ... class ImmutableTypeConversionDict(ImmutableDictMixin, TypeConversionDict[_K, _V]): # type: ignore def copy(self) -> TypeConversionDict[_K, _V]: ... @@ -103,14 +103,14 @@ class ViewItems: def __iter__(self): ... class MultiDict(TypeConversionDict[_K, _V]): - def __init__(self, mapping: Optional[Any] = ...): ... + def __init__(self, mapping: Any | None = ...): ... def __getitem__(self, key): ... def __setitem__(self, key, value): ... def add(self, key, value): ... - def getlist(self, key, type: Optional[Any] = ...): ... + def getlist(self, key, type: Any | None = ...): ... def setlist(self, key, new_list): ... - def setdefault(self, key, default: Optional[Any] = ...): ... - def setlistdefault(self, key, default_list: Optional[Any] = ...): ... + def setdefault(self, key, default: Any | None = ...): ... + def setlistdefault(self, key, default_list: Any | None = ...): ... def items(self, multi: bool = ...): ... def lists(self): ... def keys(self): ... @@ -118,7 +118,7 @@ class MultiDict(TypeConversionDict[_K, _V]): def values(self): ... def listvalues(self): ... def copy(self): ... - def deepcopy(self, memo: Optional[Any] = ...): ... + def deepcopy(self, memo: Any | None = ...): ... def to_dict(self, flat: bool = ...): ... def update(self, other_dict): ... def pop(self, key, default=...): ... @@ -137,7 +137,7 @@ class _omd_bucket: def unlink(self, omd): ... class OrderedMultiDict(MultiDict[_K, _V]): - def __init__(self, mapping: Optional[Any] = ...): ... + def __init__(self, mapping: Any | None = ...): ... def __eq__(self, other): ... def __ne__(self, other): ... def __reduce_ex__(self, protocol): ... @@ -151,9 +151,9 @@ class OrderedMultiDict(MultiDict[_K, _V]): def lists(self): ... def listvalues(self): ... def add(self, key, value): ... - def getlist(self, key, type: Optional[Any] = ...): ... + def getlist(self, key, type: Any | None = ...): ... def setlist(self, key, new_list): ... - def setlistdefault(self, key, default_list: Optional[Any] = ...): ... + def setlistdefault(self, key, default_list: Any | None = ...): ... def update(self, mapping): ... def poplist(self, key): ... def pop(self, key, default=...): ... @@ -161,29 +161,29 @@ class OrderedMultiDict(MultiDict[_K, _V]): def popitemlist(self): ... class Headers(object): - def __init__(self, defaults: Optional[Any] = ...): ... + def __init__(self, defaults: Any | None = ...): ... def __getitem__(self, key, _get_mode: bool = ...): ... def __eq__(self, other): ... def __ne__(self, other): ... @overload - def get(self, key: str, *, type: None = ...) -> Optional[str]: ... + def get(self, key: str, *, type: None = ...) -> str | None: ... @overload - def get(self, key: str, default: _D, type: None = ...) -> Union[str, _D]: ... + def get(self, key: str, default: _D, type: None = ...) -> str | _D: ... @overload - def get(self, key: str, *, type: Callable[[str], _R]) -> Optional[_R]: ... + def get(self, key: str, *, type: Callable[[str], _R]) -> _R | None: ... @overload - def get(self, key: str, default: _D, type: Callable[[str], _R]) -> Union[_R, _D]: ... + def get(self, key: str, default: _D, type: Callable[[str], _R]) -> _R | _D: ... @overload def get(self, key: str, *, as_bytes: bool) -> Any: ... @overload def get(self, key: str, *, type: None, as_bytes: bool) -> Any: ... @overload - def get(self, key: str, *, type: Callable[[Any], _R], as_bytes: bool) -> Optional[_R]: ... + def get(self, key: str, *, type: Callable[[Any], _R], as_bytes: bool) -> _R | None: ... @overload def get(self, key: str, default: Any, type: None, as_bytes: bool) -> Any: ... @overload - def get(self, key: str, default: _D, type: Callable[[Any], _R], as_bytes: bool) -> Union[_R, _D]: ... - def getlist(self, key, type: Optional[Any] = ..., as_bytes: bool = ...): ... + def get(self, key: str, default: _D, type: Callable[[Any], _R], as_bytes: bool) -> _R | _D: ... + def getlist(self, key, type: Any | None = ..., as_bytes: bool = ...): ... def get_all(self, name): ... def items(self, lower: bool = ...): ... def keys(self, lower: bool = ...): ... @@ -192,13 +192,13 @@ class Headers(object): def __delitem__(self, key: Any) -> None: ... def remove(self, key): ... @overload - def pop(self, key: Optional[int] = ...) -> str: ... # default is ignored, using it is an error + def pop(self, key: int | None = ...) -> str: ... # default is ignored, using it is an error @overload def pop(self, key: str) -> str: ... @overload def pop(self, key: str, default: str) -> str: ... @overload - def pop(self, key: str, default: None) -> Optional[str]: ... + def pop(self, key: str, default: None) -> str | None: ... def popitem(self): ... def __contains__(self, key): ... has_key: Any @@ -225,13 +225,13 @@ class ImmutableHeadersMixin: def extend(self, iterable): ... def insert(self, pos, value): ... @overload - def pop(self, key: Optional[int] = ...) -> str: ... # default is ignored, using it is an error + def pop(self, key: int | None = ...) -> str: ... # default is ignored, using it is an error @overload def pop(self, key: str) -> str: ... @overload def pop(self, key: str, default: str) -> str: ... @overload - def pop(self, key: str, default: None) -> Optional[str]: ... + def pop(self, key: str, default: None) -> str | None: ... def popitem(self): ... def setdefault(self, key, default): ... @@ -247,12 +247,12 @@ class EnvironHeaders(ImmutableHeadersMixin, Headers): class CombinedMultiDict(ImmutableMultiDictMixin, MultiDict[_K, _V]): # type: ignore def __reduce_ex__(self, protocol): ... dicts: Any - def __init__(self, dicts: Optional[Any] = ...): ... + def __init__(self, dicts: Any | None = ...): ... @classmethod def fromkeys(cls): ... def __getitem__(self, key): ... - def get(self, key, default: Optional[Any] = ..., type: Optional[Any] = ...): ... - def getlist(self, key, type: Optional[Any] = ...): ... + def get(self, key, default: Any | None = ..., type: Any | None = ...): ... + def getlist(self, key, type: Any | None = ...): ... def keys(self): ... __iter__: Any def items(self, multi: bool = ...): ... @@ -266,7 +266,7 @@ class CombinedMultiDict(ImmutableMultiDictMixin, MultiDict[_K, _V]): # type: ig has_key: Any class FileMultiDict(MultiDict[_K, _V]): - def add_file(self, name, file, filename: Optional[Any] = ..., content_type: Optional[Any] = ...): ... + def add_file(self, name, file, filename: Any | None = ..., content_type: Any | None = ...): ... class ImmutableDict(ImmutableDictMixin, Dict[_K, _V]): # type: ignore def copy(self): ... @@ -282,7 +282,7 @@ class ImmutableOrderedMultiDict(ImmutableMultiDictMixin, OrderedMultiDict[_K, _V class Accept(ImmutableList[Tuple[str, float]]): provided: bool - def __init__(self, values: Union[None, Accept, Iterable[Tuple[str, float]]] = ...) -> None: ... + def __init__(self, values: None | Accept | Iterable[Tuple[str, float]] = ...) -> None: ... @overload def __getitem__(self, key: SupportsIndex) -> Tuple[str, float]: ... @overload @@ -291,16 +291,16 @@ class Accept(ImmutableList[Tuple[str, float]]): def __getitem__(self, key: str) -> float: ... def quality(self, key: str) -> float: ... def __contains__(self, value: str) -> bool: ... # type: ignore - def index(self, key: Union[str, Tuple[str, float]]) -> int: ... # type: ignore - def find(self, key: Union[str, Tuple[str, float]]) -> int: ... + def index(self, key: str | Tuple[str, float]) -> int: ... # type: ignore + def find(self, key: str | Tuple[str, float]) -> int: ... def values(self) -> Iterator[str]: ... def to_header(self) -> str: ... @overload - def best_match(self, matches: Iterable[str], default: None = ...) -> Optional[str]: ... + def best_match(self, matches: Iterable[str], default: None = ...) -> str | None: ... @overload - def best_match(self, matches: Iterable[str], default: _D) -> Union[str, _D]: ... + def best_match(self, matches: Iterable[str], default: _D) -> str | _D: ... @property - def best(self) -> Optional[str]: ... + def best(self) -> str | None: ... class MIMEAccept(Accept): @property @@ -322,7 +322,7 @@ class _CacheControl(UpdateDictMixin, Dict[str, Any]): no_transform: Any on_update: Any provided: Any - def __init__(self, values=..., on_update: Optional[Any] = ...): ... + def __init__(self, values=..., on_update: Any | None = ...): ... def to_header(self): ... class RequestCacheControl(ImmutableDictMixin, _CacheControl): # type: ignore @@ -340,11 +340,11 @@ class ResponseCacheControl(_CacheControl): class CallbackDict(UpdateDictMixin, Dict[_K, _V]): on_update: Any - def __init__(self, initial: Optional[Any] = ..., on_update: Optional[Any] = ...): ... + def __init__(self, initial: Any | None = ..., on_update: Any | None = ...): ... class HeaderSet(MutableSet[str]): on_update: Any - def __init__(self, headers: Optional[Any] = ..., on_update: Optional[Any] = ...): ... + def __init__(self, headers: Any | None = ..., on_update: Any | None = ...): ... def add(self, header): ... def remove(self, header): ... def update(self, iterable): ... @@ -364,14 +364,14 @@ class HeaderSet(MutableSet[str]): class ETags(Container[str], Iterable[str]): star_tag: Any - def __init__(self, strong_etags: Optional[Any] = ..., weak_etags: Optional[Any] = ..., star_tag: bool = ...): ... + def __init__(self, strong_etags: Any | None = ..., weak_etags: Any | None = ..., star_tag: bool = ...): ... def as_set(self, include_weak: bool = ...): ... def is_weak(self, etag): ... def contains_weak(self, etag): ... def contains(self, etag): ... def contains_raw(self, etag): ... def to_header(self): ... - def __call__(self, etag: Optional[Any] = ..., data: Optional[Any] = ..., include_weak: bool = ...): ... + def __call__(self, etag: Any | None = ..., data: Any | None = ..., include_weak: bool = ...): ... def __bool__(self): ... __nonzero__: Any def __iter__(self): ... @@ -380,7 +380,7 @@ class ETags(Container[str], Iterable[str]): class IfRange: etag: Any date: Any - def __init__(self, etag: Optional[Any] = ..., date: Optional[Any] = ...): ... + def __init__(self, etag: Any | None = ..., date: Any | None = ...): ... def to_header(self): ... class Range: @@ -394,12 +394,12 @@ class Range: class ContentRange: on_update: Any - units: Optional[str] + units: str | None start: Any stop: Any length: Any - def __init__(self, units: Optional[str], start, stop, length: Optional[Any] = ..., on_update: Optional[Any] = ...): ... - def set(self, start, stop, length: Optional[Any] = ..., units: Optional[str] = ...): ... + def __init__(self, units: str | None, start, stop, length: Any | None = ..., on_update: Any | None = ...): ... + def set(self, start, stop, length: Any | None = ..., units: str | None = ...): ... def unset(self) -> None: ... def to_header(self): ... def __nonzero__(self): ... @@ -407,38 +407,38 @@ class ContentRange: class Authorization(ImmutableDictMixin, Dict[str, Any]): # type: ignore type: str - def __init__(self, auth_type: str, data: Optional[Mapping[str, Any]] = ...) -> None: ... + def __init__(self, auth_type: str, data: Mapping[str, Any] | None = ...) -> None: ... @property - def username(self) -> Optional[str]: ... + def username(self) -> str | None: ... @property - def password(self) -> Optional[str]: ... + def password(self) -> str | None: ... @property - def realm(self) -> Optional[str]: ... + def realm(self) -> str | None: ... @property - def nonce(self) -> Optional[str]: ... + def nonce(self) -> str | None: ... @property - def uri(self) -> Optional[str]: ... + def uri(self) -> str | None: ... @property - def nc(self) -> Optional[str]: ... + def nc(self) -> str | None: ... @property - def cnonce(self) -> Optional[str]: ... + def cnonce(self) -> str | None: ... @property - def response(self) -> Optional[str]: ... + def response(self) -> str | None: ... @property - def opaque(self) -> Optional[str]: ... + def opaque(self) -> str | None: ... @property - def qop(self) -> Optional[str]: ... + def qop(self) -> str | None: ... class WWWAuthenticate(UpdateDictMixin, Dict[str, Any]): on_update: Any - def __init__(self, auth_type: Optional[Any] = ..., values: Optional[Any] = ..., on_update: Optional[Any] = ...): ... + def __init__(self, auth_type: Any | None = ..., values: Any | None = ..., on_update: Any | None = ...): ... def set_basic(self, realm: str = ...): ... def set_digest( - self, realm, nonce, qop=..., opaque: Optional[Any] = ..., algorithm: Optional[Any] = ..., stale: bool = ... + self, realm, nonce, qop=..., opaque: Any | None = ..., algorithm: Any | None = ..., stale: bool = ... ): ... def to_header(self): ... @staticmethod - def auth_property(name, doc: Optional[Any] = ...): ... + def auth_property(name, doc: Any | None = ...): ... type: Any realm: Any domain: Any @@ -449,28 +449,28 @@ class WWWAuthenticate(UpdateDictMixin, Dict[str, Any]): stale: Any class FileStorage(object): - name: Optional[Text] + name: Text | None stream: IO[bytes] - filename: Optional[Text] + filename: Text | None headers: Headers def __init__( self, - stream: Optional[IO[bytes]] = ..., - filename: Union[None, Text, bytes] = ..., - name: Optional[Text] = ..., - content_type: Optional[Text] = ..., - content_length: Optional[int] = ..., - headers: Optional[Headers] = ..., + stream: IO[bytes] | None = ..., + filename: None | Text | bytes = ..., + name: Text | None = ..., + content_type: Text | None = ..., + content_length: int | None = ..., + headers: Headers | None = ..., ): ... @property - def content_type(self) -> Optional[Text]: ... + def content_type(self) -> Text | None: ... @property def content_length(self) -> int: ... @property def mimetype(self) -> str: ... @property def mimetype_params(self) -> Dict[str, str]: ... - def save(self, dst: Union[Text, SupportsWrite[bytes]], buffer_size: int = ...): ... + def save(self, dst: Text | SupportsWrite[bytes], buffer_size: int = ...): ... def close(self) -> None: ... def __nonzero__(self) -> bool: ... def __bool__(self) -> bool: ... diff --git a/stubs/Werkzeug/werkzeug/debug/__init__.pyi b/stubs/Werkzeug/werkzeug/debug/__init__.pyi index 82664dc4ab04..ece4726df295 100644 --- a/stubs/Werkzeug/werkzeug/debug/__init__.pyi +++ b/stubs/Werkzeug/werkzeug/debug/__init__.pyi @@ -32,9 +32,9 @@ class DebuggedApplication: evalex: bool = ..., request_key: str = ..., console_path: str = ..., - console_init_func: Optional[Any] = ..., + console_init_func: Any | None = ..., show_hidden_frames: bool = ..., - lodgeit_url: Optional[Any] = ..., + lodgeit_url: Any | None = ..., pin_security: bool = ..., pin_logging: bool = ..., ): ... diff --git a/stubs/Werkzeug/werkzeug/debug/console.pyi b/stubs/Werkzeug/werkzeug/debug/console.pyi index d2fc1d36fd5c..1f1298f2687a 100644 --- a/stubs/Werkzeug/werkzeug/debug/console.pyi +++ b/stubs/Werkzeug/werkzeug/debug/console.pyi @@ -36,9 +36,9 @@ class _InteractiveConsole(code.InteractiveInterpreter): def runsource(self, source): ... def runcode(self, code): ... def showtraceback(self): ... - def showsyntaxerror(self, filename: Optional[Any] = ...): ... + def showsyntaxerror(self, filename: Any | None = ...): ... def write(self, data): ... class Console: - def __init__(self, globals: Optional[Any] = ..., locals: Optional[Any] = ...): ... + def __init__(self, globals: Any | None = ..., locals: Any | None = ...): ... def eval(self, code): ... diff --git a/stubs/Werkzeug/werkzeug/debug/repr.pyi b/stubs/Werkzeug/werkzeug/debug/repr.pyi index 49559197adde..988dcc371dd6 100644 --- a/stubs/Werkzeug/werkzeug/debug/repr.pyi +++ b/stubs/Werkzeug/werkzeug/debug/repr.pyi @@ -10,7 +10,7 @@ def debug_repr(obj): ... def dump(obj=...): ... class _Helper: - def __call__(self, topic: Optional[Any] = ...): ... + def __call__(self, topic: Any | None = ...): ... helper: Any @@ -30,4 +30,4 @@ class DebugReprGenerator: def repr(self, obj): ... def dump_object(self, obj): ... def dump_locals(self, d): ... - def render_object_dump(self, items, title, repr: Optional[Any] = ...): ... + def render_object_dump(self, items, title, repr: Any | None = ...): ... diff --git a/stubs/Werkzeug/werkzeug/debug/tbtools.pyi b/stubs/Werkzeug/werkzeug/debug/tbtools.pyi index 90beed9df732..f3a7c8705993 100644 --- a/stubs/Werkzeug/werkzeug/debug/tbtools.pyi +++ b/stubs/Werkzeug/werkzeug/debug/tbtools.pyi @@ -31,10 +31,10 @@ class Traceback: def filter_hidden_frames(self): ... def is_syntax_error(self): ... def exception(self): ... - def log(self, logfile: Optional[Any] = ...): ... + def log(self, logfile: Any | None = ...): ... def paste(self): ... def render_summary(self, include_title: bool = ...): ... - def render_full(self, evalex: bool = ..., secret: Optional[Any] = ..., evalex_trusted: bool = ...): ... + def render_full(self, evalex: bool = ..., secret: Any | None = ..., evalex_trusted: bool = ...): ... def generate_plaintext_traceback(self): ... def plaintext(self): ... id: Any diff --git a/stubs/Werkzeug/werkzeug/exceptions.pyi b/stubs/Werkzeug/werkzeug/exceptions.pyi index 0a0cf3c668de..bb438d72b73c 100644 --- a/stubs/Werkzeug/werkzeug/exceptions.pyi +++ b/stubs/Werkzeug/werkzeug/exceptions.pyi @@ -9,18 +9,18 @@ class _EnvironContainer(Protocol): def environ(self) -> WSGIEnvironment: ... class HTTPException(Exception): - code: Optional[int] - description: Optional[Text] - response: Optional[Response] - def __init__(self, description: Optional[Text] = ..., response: Optional[Response] = ...) -> None: ... + code: int | None + description: Text | None + response: Response | None + def __init__(self, description: Text | None = ..., response: Response | None = ...) -> None: ... @classmethod - def wrap(cls, exception: Type[Exception], name: Optional[str] = ...) -> Any: ... + def wrap(cls, exception: Type[Exception], name: str | None = ...) -> Any: ... @property def name(self) -> str: ... - def get_description(self, environ: Optional[WSGIEnvironment] = ...) -> Text: ... - def get_body(self, environ: Optional[WSGIEnvironment] = ...) -> Text: ... - def get_headers(self, environ: Optional[WSGIEnvironment] = ...) -> List[Tuple[str, str]]: ... - def get_response(self, environ: Optional[Union[WSGIEnvironment, _EnvironContainer]] = ...) -> Response: ... + def get_description(self, environ: WSGIEnvironment | None = ...) -> Text: ... + def get_body(self, environ: WSGIEnvironment | None = ...) -> Text: ... + def get_headers(self, environ: WSGIEnvironment | None = ...) -> List[Tuple[str, str]]: ... + def get_response(self, environ: WSGIEnvironment | _EnvironContainer | None = ...) -> Response: ... def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... default_exceptions: Dict[int, Type[HTTPException]] @@ -36,12 +36,12 @@ class BadHost(BadRequest): ... class Unauthorized(HTTPException): code: int description: Text - www_authenticate: Optional[Iterable[object]] + www_authenticate: Iterable[object] | None def __init__( self, - description: Optional[Text] = ..., - response: Optional[Response] = ..., - www_authenticate: Union[None, Tuple[object, ...], List[object], object] = ..., + description: Text | None = ..., + response: Response | None = ..., + www_authenticate: None | Tuple[object, ...] | List[object] | object = ..., ) -> None: ... class Forbidden(HTTPException): @@ -56,7 +56,7 @@ class MethodNotAllowed(HTTPException): code: int description: Text valid_methods: Any - def __init__(self, valid_methods: Optional[Any] = ..., description: Optional[Any] = ...): ... + def __init__(self, valid_methods: Any | None = ..., description: Any | None = ...): ... class NotAcceptable(HTTPException): code: int @@ -99,7 +99,7 @@ class RequestedRangeNotSatisfiable(HTTPException): description: Text length: Any units: str - def __init__(self, length: Optional[Any] = ..., units: str = ..., description: Optional[Any] = ...): ... + def __init__(self, length: Any | None = ..., units: str = ..., description: Any | None = ...): ... class ExpectationFailed(HTTPException): code: int @@ -126,12 +126,12 @@ class PreconditionRequired(HTTPException): description: Text class _RetryAfter(HTTPException): - retry_after: Union[None, int, datetime.datetime] + retry_after: None | int | datetime.datetime def __init__( self, - description: Optional[Text] = ..., - response: Optional[Response] = ..., - retry_after: Union[None, int, datetime.datetime] = ..., + description: Text | None = ..., + response: Response | None = ..., + retry_after: None | int | datetime.datetime = ..., ) -> None: ... class TooManyRequests(_RetryAfter): @@ -148,7 +148,7 @@ class UnavailableForLegalReasons(HTTPException): class InternalServerError(HTTPException): def __init__( - self, description: Optional[Text] = ..., response: Optional[Response] = ..., original_exception: Optional[Exception] = ... + self, description: Text | None = ..., response: Response | None = ..., original_exception: Exception | None = ... ) -> None: ... code: int description: Text @@ -175,9 +175,9 @@ class HTTPVersionNotSupported(HTTPException): class Aborter: mapping: Any - def __init__(self, mapping: Optional[Any] = ..., extra: Optional[Any] = ...) -> None: ... - def __call__(self, code: Union[int, Response], *args: Any, **kwargs: Any) -> NoReturn: ... + def __init__(self, mapping: Any | None = ..., extra: Any | None = ...) -> None: ... + def __call__(self, code: int | Response, *args: Any, **kwargs: Any) -> NoReturn: ... -def abort(status: Union[int, Response], *args: Any, **kwargs: Any) -> NoReturn: ... +def abort(status: int | Response, *args: Any, **kwargs: Any) -> NoReturn: ... class BadRequestKeyError(BadRequest, KeyError): ... diff --git a/stubs/Werkzeug/werkzeug/formparser.pyi b/stubs/Werkzeug/werkzeug/formparser.pyi index 8cc951fa660e..8042b90bc7e5 100644 --- a/stubs/Werkzeug/werkzeug/formparser.pyi +++ b/stubs/Werkzeug/werkzeug/formparser.pyi @@ -25,20 +25,20 @@ _F = TypeVar("_F", bound=Callable[..., Any]) class _StreamFactory(Protocol): def __call__( - self, total_content_length: Optional[int], filename: str, content_type: str, content_length: Optional[int] = ... + self, total_content_length: int | None, filename: str, content_type: str, content_length: int | None = ... ) -> IO[bytes]: ... def default_stream_factory( - total_content_length: Optional[int], filename: str, content_type: str, content_length: Optional[int] = ... + total_content_length: int | None, filename: str, content_type: str, content_length: int | None = ... ) -> IO[bytes]: ... def parse_form_data( environ: WSGIEnvironment, - stream_factory: Optional[_StreamFactory] = ..., + stream_factory: _StreamFactory | None = ..., charset: Text = ..., errors: Text = ..., - max_form_memory_size: Optional[int] = ..., - max_content_length: Optional[int] = ..., - cls: Optional[Callable[[], _Dict]] = ..., + max_form_memory_size: int | None = ..., + max_content_length: int | None = ..., + cls: Callable[[], _Dict] | None = ..., silent: bool = ..., ) -> Tuple[IO[bytes], _Dict, _Dict]: ... def exhaust_stream(f: _F) -> _F: ... @@ -47,54 +47,54 @@ class FormDataParser(object): stream_factory: _StreamFactory charset: Text errors: Text - max_form_memory_size: Optional[int] - max_content_length: Optional[int] + max_form_memory_size: int | None + max_content_length: int | None cls: Callable[[], _Dict] silent: bool def __init__( self, - stream_factory: Optional[_StreamFactory] = ..., + stream_factory: _StreamFactory | None = ..., charset: Text = ..., errors: Text = ..., - max_form_memory_size: Optional[int] = ..., - max_content_length: Optional[int] = ..., - cls: Optional[Callable[[], _Dict]] = ..., + max_form_memory_size: int | None = ..., + max_content_length: int | None = ..., + cls: Callable[[], _Dict] | None = ..., silent: bool = ..., ) -> None: ... - def get_parse_func(self, mimetype: str, options: Any) -> Optional[_ParseFunc]: ... + def get_parse_func(self, mimetype: str, options: Any) -> _ParseFunc | None: ... def parse_from_environ(self, environ: WSGIEnvironment) -> Tuple[IO[bytes], _Dict, _Dict]: ... def parse( - self, stream: IO[bytes], mimetype: Text, content_length: Optional[int], options: Optional[Mapping[str, str]] = ... + self, stream: IO[bytes], mimetype: Text, content_length: int | None, options: Mapping[str, str] | None = ... ) -> Tuple[IO[bytes], _Dict, _Dict]: ... parse_functions: Dict[Text, _ParseFunc] def is_valid_multipart_boundary(boundary: str) -> bool: ... -def parse_multipart_headers(iterable: Iterable[Union[Text, bytes]]) -> Headers: ... +def parse_multipart_headers(iterable: Iterable[Text | bytes]) -> Headers: ... class MultiPartParser(object): charset: Text errors: Text - max_form_memory_size: Optional[int] + max_form_memory_size: int | None stream_factory: _StreamFactory cls: Callable[[], _Dict] buffer_size: int def __init__( self, - stream_factory: Optional[_StreamFactory] = ..., + stream_factory: _StreamFactory | None = ..., charset: Text = ..., errors: Text = ..., - max_form_memory_size: Optional[int] = ..., - cls: Optional[Callable[[], _Dict]] = ..., + max_form_memory_size: int | None = ..., + cls: Callable[[], _Dict] | None = ..., buffer_size: int = ..., ) -> None: ... def fail(self, message: Text) -> NoReturn: ... - def get_part_encoding(self, headers: Mapping[str, str]) -> Optional[str]: ... + def get_part_encoding(self, headers: Mapping[str, str]) -> str | None: ... def get_part_charset(self, headers: Mapping[str, str]) -> Text: ... def start_file_streaming( - self, filename: Union[Text, bytes], headers: Mapping[str, str], total_content_length: Optional[int] + self, filename: Text | bytes, headers: Mapping[str, str], total_content_length: int | None ) -> Tuple[Text, IO[bytes]]: ... def in_memory_threshold_reached(self, bytes: Any) -> NoReturn: ... - def validate_boundary(self, boundary: Optional[str]) -> None: ... + def validate_boundary(self, boundary: str | None) -> None: ... def parse_lines( self, file: Any, boundary: bytes, content_length: int, cap_at_buffer: bool = ... ) -> Generator[Tuple[str, Any], None, None]: ... diff --git a/stubs/Werkzeug/werkzeug/http.pyi b/stubs/Werkzeug/werkzeug/http.pyi index 55a1dbd434ae..cf1219ad1d88 100644 --- a/stubs/Werkzeug/werkzeug/http.pyi +++ b/stubs/Werkzeug/werkzeug/http.pyi @@ -46,92 +46,92 @@ _U = TypeVar("_U") HTTP_STATUS_CODES: Dict[int, str] -def wsgi_to_bytes(data: Union[bytes, Text]) -> bytes: ... +def wsgi_to_bytes(data: bytes | Text) -> bytes: ... def bytes_to_wsgi(data: bytes) -> str: ... def quote_header_value(value: Any, extra_chars: str = ..., allow_token: bool = ...) -> str: ... def unquote_header_value(value: _Str, is_filename: bool = ...) -> _Str: ... -def dump_options_header(header: Optional[_Str], options: Mapping[_Str, Any]) -> _Str: ... -def dump_header(iterable: Union[Iterable[Any], Dict[_Str, Any]], allow_token: bool = ...) -> _Str: ... +def dump_options_header(header: _Str | None, options: Mapping[_Str, Any]) -> _Str: ... +def dump_header(iterable: Iterable[Any] | Dict[_Str, Any], allow_token: bool = ...) -> _Str: ... def parse_list_header(value: _Str) -> List[_Str]: ... @overload -def parse_dict_header(value: Union[bytes, Text]) -> Dict[Text, Optional[Text]]: ... +def parse_dict_header(value: bytes | Text) -> Dict[Text, Text | None]: ... @overload -def parse_dict_header(value: Union[bytes, Text], cls: Type[_T]) -> _T: ... +def parse_dict_header(value: bytes | Text, cls: Type[_T]) -> _T: ... @overload -def parse_options_header(value: None, multiple: bool = ...) -> Tuple[str, Dict[str, Optional[str]]]: ... +def parse_options_header(value: None, multiple: bool = ...) -> Tuple[str, Dict[str, str | None]]: ... @overload -def parse_options_header(value: _Str) -> Tuple[_Str, Dict[_Str, Optional[_Str]]]: ... +def parse_options_header(value: _Str) -> Tuple[_Str, Dict[_Str, _Str | None]]: ... -# actually returns Tuple[_Str, Dict[_Str, Optional[_Str]], ...] +# actually returns Tuple[_Str, Dict[_Str, _Str | None], ...] @overload def parse_options_header(value: _Str, multiple: bool = ...) -> Tuple[Any, ...]: ... @overload -def parse_accept_header(value: Optional[Text]) -> Accept: ... +def parse_accept_header(value: Text | None) -> Accept: ... @overload -def parse_accept_header(value: Optional[_Str], cls: Callable[[Optional[List[Tuple[str, float]]]], _T]) -> _T: ... +def parse_accept_header(value: _Str | None, cls: Callable[[List[Tuple[str, float]] | None], _T]) -> _T: ... @overload def parse_cache_control_header( - value: Union[None, bytes, Text], on_update: Optional[Callable[[RequestCacheControl], Any]] = ... + value: None | bytes | Text, on_update: Callable[[RequestCacheControl], Any] | None = ... ) -> RequestCacheControl: ... @overload def parse_cache_control_header( - value: Union[None, bytes, Text], on_update: _T, cls: Callable[[Dict[Text, Optional[Text]], _T], _U] + value: None | bytes | Text, on_update: _T, cls: Callable[[Dict[Text, Text | None], _T], _U] ) -> _U: ... @overload def parse_cache_control_header( - value: Union[None, bytes, Text], *, cls: Callable[[Dict[Text, Optional[Text]], None], _U] + value: None | bytes | Text, *, cls: Callable[[Dict[Text, Text | None], None], _U] ) -> _U: ... -def parse_set_header(value: Text, on_update: Optional[Callable[[HeaderSet], Any]] = ...) -> HeaderSet: ... -def parse_authorization_header(value: Union[None, bytes, Text]) -> Optional[Authorization]: ... +def parse_set_header(value: Text, on_update: Callable[[HeaderSet], Any] | None = ...) -> HeaderSet: ... +def parse_authorization_header(value: None | bytes | Text) -> Authorization | None: ... def parse_www_authenticate_header( - value: Union[None, bytes, Text], on_update: Optional[Callable[[WWWAuthenticate], Any]] = ... + value: None | bytes | Text, on_update: Callable[[WWWAuthenticate], Any] | None = ... ) -> WWWAuthenticate: ... -def parse_if_range_header(value: Optional[Text]) -> IfRange: ... -def parse_range_header(value: Optional[Text], make_inclusive: bool = ...) -> Optional[Range]: ... +def parse_if_range_header(value: Text | None) -> IfRange: ... +def parse_range_header(value: Text | None, make_inclusive: bool = ...) -> Range | None: ... def parse_content_range_header( - value: Optional[Text], on_update: Optional[Callable[[ContentRange], Any]] = ... -) -> Optional[ContentRange]: ... + value: Text | None, on_update: Callable[[ContentRange], Any] | None = ... +) -> ContentRange | None: ... def quote_etag(etag: _Str, weak: bool = ...) -> _Str: ... -def unquote_etag(etag: Optional[_Str]) -> Tuple[Optional[_Str], Optional[_Str]]: ... -def parse_etags(value: Optional[Text]) -> ETags: ... +def unquote_etag(etag: _Str | None) -> Tuple[_Str | None, _Str | None]: ... +def parse_etags(value: Text | None) -> ETags: ... def generate_etag(data: _ETagData) -> str: ... -def parse_date(value: Optional[str]) -> Optional[datetime]: ... -def cookie_date(expires: Union[None, float, datetime] = ...) -> str: ... -def http_date(timestamp: Union[None, float, datetime] = ...) -> str: ... -def parse_age(value: Optional[SupportsInt] = ...) -> Optional[timedelta]: ... -def dump_age(age: Union[None, timedelta, SupportsInt]) -> Optional[str]: ... +def parse_date(value: str | None) -> datetime | None: ... +def cookie_date(expires: None | float | datetime = ...) -> str: ... +def http_date(timestamp: None | float | datetime = ...) -> str: ... +def parse_age(value: SupportsInt | None = ...) -> timedelta | None: ... +def dump_age(age: None | timedelta | SupportsInt) -> str | None: ... def is_resource_modified( environ: WSGIEnvironment, - etag: Optional[Text] = ..., - data: Optional[_ETagData] = ..., - last_modified: Union[None, Text, datetime] = ..., + etag: Text | None = ..., + data: _ETagData | None = ..., + last_modified: None | Text | datetime = ..., ignore_if_range: bool = ..., ) -> bool: ... -def remove_entity_headers(headers: Union[List[Tuple[Text, Text]], Headers], allowed: Iterable[Text] = ...) -> None: ... -def remove_hop_by_hop_headers(headers: Union[List[Tuple[Text, Text]], Headers]) -> None: ... +def remove_entity_headers(headers: List[Tuple[Text, Text]] | Headers, allowed: Iterable[Text] = ...) -> None: ... +def remove_hop_by_hop_headers(headers: List[Tuple[Text, Text]] | Headers) -> None: ... def is_entity_header(header: Text) -> bool: ... def is_hop_by_hop_header(header: Text) -> bool: ... @overload def parse_cookie( - header: Union[None, WSGIEnvironment, Text, bytes], charset: Text = ..., errors: Text = ... + header: None | WSGIEnvironment | Text | bytes, charset: Text = ..., errors: Text = ... ) -> TypeConversionDict[Any, Any]: ... @overload def parse_cookie( - header: Union[None, WSGIEnvironment, Text, bytes], + header: None | WSGIEnvironment | Text | bytes, charset: Text = ..., errors: Text = ..., - cls: Optional[Callable[[Iterable[Tuple[Text, Text]]], _T]] = ..., + cls: Callable[[Iterable[Tuple[Text, Text]]], _T] | None = ..., ) -> _T: ... def dump_cookie( key: _ToBytes, value: _ToBytes = ..., - max_age: Union[None, float, timedelta] = ..., - expires: Union[None, Text, float, datetime] = ..., - path: Union[None, Tuple[Any, ...], str, bytes] = ..., - domain: Union[None, str, bytes] = ..., + max_age: None | float | timedelta = ..., + expires: None | Text | float | datetime = ..., + path: None | Tuple[Any, ...] | str | bytes = ..., + domain: None | str | bytes = ..., secure: bool = ..., httponly: bool = ..., charset: Text = ..., sync_expires: bool = ..., ) -> str: ... -def is_byte_range_valid(start: Optional[int], stop: Optional[int], length: Optional[int]) -> bool: ... +def is_byte_range_valid(start: int | None, stop: int | None, length: int | None) -> bool: ... diff --git a/stubs/Werkzeug/werkzeug/local.pyi b/stubs/Werkzeug/werkzeug/local.pyi index 0fe642d8faf4..20a9120285aa 100644 --- a/stubs/Werkzeug/werkzeug/local.pyi +++ b/stubs/Werkzeug/werkzeug/local.pyi @@ -26,14 +26,14 @@ class LocalStack: class LocalManager: locals: Any ident_func: Any - def __init__(self, locals: Optional[Any] = ..., ident_func: Optional[Any] = ...): ... + def __init__(self, locals: Any | None = ..., ident_func: Any | None = ...): ... def get_ident(self): ... def cleanup(self): ... def make_middleware(self, app): ... def middleware(self, func): ... class LocalProxy: - def __init__(self, local, name: Optional[Any] = ...): ... + def __init__(self, local, name: Any | None = ...): ... @property def __dict__(self): ... def __bool__(self): ... diff --git a/stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi b/stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi index 60ea30e0c8b3..7c1ac0283375 100644 --- a/stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi @@ -4,5 +4,5 @@ from typing import Iterable, Mapping, Optional, Text class DispatcherMiddleware(object): app: WSGIApplication mounts: Mapping[Text, WSGIApplication] - def __init__(self, app: WSGIApplication, mounts: Optional[Mapping[Text, WSGIApplication]] = ...) -> None: ... + def __init__(self, app: WSGIApplication, mounts: Mapping[Text, WSGIApplication] | None = ...) -> None: ... def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... diff --git a/stubs/Werkzeug/werkzeug/middleware/lint.pyi b/stubs/Werkzeug/werkzeug/middleware/lint.pyi index 532484f67219..d3035c6daabe 100644 --- a/stubs/Werkzeug/werkzeug/middleware/lint.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/lint.pyi @@ -55,7 +55,7 @@ class LintMiddleware(object): def __init__(self, app: WSGIApplication) -> None: ... def check_environ(self, environ: WSGIEnvironment) -> None: ... def check_start_response( - self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[Tuple[Any, ...]] + self, status: str, headers: List[Tuple[str, str]], exc_info: Tuple[Any, ...] | None ) -> Tuple[int, Headers]: ... def check_headers(self, headers: Mapping[str, str]) -> None: ... def check_iterator(self, app_iter: Iterable[bytes]) -> None: ... diff --git a/stubs/Werkzeug/werkzeug/middleware/profiler.pyi b/stubs/Werkzeug/werkzeug/middleware/profiler.pyi index f309605b946e..aed6e3233e3b 100644 --- a/stubs/Werkzeug/werkzeug/middleware/profiler.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/profiler.pyi @@ -7,8 +7,8 @@ class ProfilerMiddleware(object): app: WSGIApplication, stream: IO[str] = ..., sort_by: Tuple[Text, Text] = ..., - restrictions: Iterable[Union[str, float]] = ..., - profile_dir: Optional[Text] = ..., + restrictions: Iterable[str | float] = ..., + profile_dir: Text | None = ..., filename_format: Text = ..., ) -> None: ... def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> List[bytes]: ... diff --git a/stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi b/stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi index 0522e2beb121..955b713b915f 100644 --- a/stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi @@ -12,12 +12,12 @@ class ProxyFix(object): def __init__( self, app: WSGIApplication, - num_proxies: Optional[int] = ..., + num_proxies: int | None = ..., x_for: int = ..., x_proto: int = ..., x_host: int = ..., x_port: int = ..., x_prefix: int = ..., ) -> None: ... - def get_remote_addr(self, forwarded_for: Iterable[str]) -> Optional[str]: ... + def get_remote_addr(self, forwarded_for: Iterable[str]) -> str | None: ... def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... diff --git a/stubs/Werkzeug/werkzeug/middleware/shared_data.pyi b/stubs/Werkzeug/werkzeug/middleware/shared_data.pyi index af0842d6977a..d08f6cd0f446 100644 --- a/stubs/Werkzeug/werkzeug/middleware/shared_data.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/shared_data.pyi @@ -15,8 +15,8 @@ class SharedDataMiddleware(object): def __init__( self, app: WSGIApplication, - exports: Union[Mapping[Text, _V], Iterable[Tuple[Text, _V]]], - disallow: Optional[Text] = ..., + exports: Mapping[Text, _V] | Iterable[Tuple[Text, _V]], + disallow: Text | None = ..., cache: bool = ..., cache_timeout: float = ..., fallback_mimetype: Text = ..., @@ -25,5 +25,5 @@ class SharedDataMiddleware(object): def get_file_loader(self, filename: Text) -> _Loader: ... def get_package_loader(self, package: Text, package_path: Text) -> _Loader: ... def get_directory_loader(self, directory: Text) -> _Loader: ... - def generate_etag(self, mtime: datetime.datetime, file_size: int, real_filename: Union[Text, bytes]) -> str: ... + def generate_etag(self, mtime: datetime.datetime, file_size: int, real_filename: Text | bytes) -> str: ... def __call__(self, environment: WSGIEnvironment, start_response: StartResponse) -> WSGIApplication: ... diff --git a/stubs/Werkzeug/werkzeug/routing.pyi b/stubs/Werkzeug/werkzeug/routing.pyi index a1cfe8d9f21a..983c6d5040bc 100644 --- a/stubs/Werkzeug/werkzeug/routing.pyi +++ b/stubs/Werkzeug/werkzeug/routing.pyi @@ -23,11 +23,11 @@ class BuildError(RoutingException, LookupError): endpoint: Any values: Any method: Any - adapter: Optional[MapAdapter] - def __init__(self, endpoint, values, method, adapter: Optional[MapAdapter] = ...) -> None: ... + adapter: MapAdapter | None + def __init__(self, endpoint, values, method, adapter: MapAdapter | None = ...) -> None: ... @property - def suggested(self) -> Optional[Rule]: ... - def closest_rule(self, adapter: Optional[MapAdapter]) -> Optional[Rule]: ... + def suggested(self) -> Rule | None: ... + def closest_rule(self, adapter: MapAdapter | None) -> Rule | None: ... class ValidationError(ValueError): ... @@ -80,15 +80,15 @@ class Rule(RuleFactory): def __init__( self, string, - defaults: Optional[Any] = ..., - subdomain: Optional[Any] = ..., - methods: Optional[Any] = ..., + defaults: Any | None = ..., + subdomain: Any | None = ..., + methods: Any | None = ..., build_only: bool = ..., - endpoint: Optional[Any] = ..., - strict_slashes: Optional[Any] = ..., - redirect_to: Optional[Any] = ..., + endpoint: Any | None = ..., + strict_slashes: Any | None = ..., + redirect_to: Any | None = ..., alias: bool = ..., - host: Optional[Any] = ..., + host: Any | None = ..., ): ... def empty(self): ... def get_empty_kwargs(self): ... @@ -97,10 +97,10 @@ class Rule(RuleFactory): def bind(self, map, rebind: bool = ...): ... def get_converter(self, variable_name, converter_name, args, kwargs): ... def compile(self): ... - def match(self, path, method: Optional[Any] = ...): ... + def match(self, path, method: Any | None = ...): ... def build(self, values, append_unknown: bool = ...): ... def provides_defaults_for(self, rule): ... - def suitable_for(self, values, method: Optional[Any] = ...): ... + def suitable_for(self, values, method: Any | None = ...): ... def match_compare_key(self): ... def build_compare_key(self): ... def __eq__(self, other): ... @@ -116,7 +116,7 @@ class BaseConverter: class UnicodeConverter(BaseConverter): regex: Any - def __init__(self, map, minlength: int = ..., maxlength: Optional[Any] = ..., length: Optional[Any] = ...): ... + def __init__(self, map, minlength: int = ..., maxlength: Any | None = ..., length: Any | None = ...): ... class AnyConverter(BaseConverter): regex: Any @@ -131,7 +131,7 @@ class NumberConverter(BaseConverter): fixed_digits: Any min: Any max: Any - def __init__(self, map, fixed_digits: int = ..., min: Optional[Any] = ..., max: Optional[Any] = ...): ... + def __init__(self, map, fixed_digits: int = ..., min: Any | None = ..., max: Any | None = ...): ... def to_python(self, value): ... def to_url(self, value) -> str: ... @@ -142,7 +142,7 @@ class IntegerConverter(NumberConverter): class FloatConverter(NumberConverter): regex: Any num_convert: Any - def __init__(self, map, min: Optional[Any] = ..., max: Optional[Any] = ...): ... + def __init__(self, map, min: Any | None = ..., max: Any | None = ...): ... class UUIDConverter(BaseConverter): regex: Any @@ -164,31 +164,31 @@ class Map: sort_key: Any def __init__( self, - rules: Optional[Any] = ..., + rules: Any | None = ..., default_subdomain: str = ..., charset: Text = ..., strict_slashes: bool = ..., redirect_defaults: bool = ..., - converters: Optional[Any] = ..., + converters: Any | None = ..., sort_parameters: bool = ..., - sort_key: Optional[Any] = ..., + sort_key: Any | None = ..., encoding_errors: Text = ..., host_matching: bool = ..., ): ... def is_endpoint_expecting(self, endpoint, *arguments): ... - def iter_rules(self, endpoint: Optional[Any] = ...): ... + def iter_rules(self, endpoint: Any | None = ...): ... def add(self, rulefactory): ... def bind( self, server_name, - script_name: Optional[Any] = ..., - subdomain: Optional[Any] = ..., + script_name: Any | None = ..., + subdomain: Any | None = ..., url_scheme: str = ..., default_method: str = ..., - path_info: Optional[Any] = ..., - query_args: Optional[Any] = ..., + path_info: Any | None = ..., + query_args: Any | None = ..., ): ... - def bind_to_environ(self, environ, server_name: Optional[Any] = ..., subdomain: Optional[Any] = ...): ... + def bind_to_environ(self, environ, server_name: Any | None = ..., subdomain: Any | None = ...): ... def update(self): ... class MapAdapter: @@ -201,30 +201,30 @@ class MapAdapter: default_method: Any query_args: Any def __init__( - self, map, server_name, script_name, subdomain, url_scheme, path_info, default_method, query_args: Optional[Any] = ... + self, map, server_name, script_name, subdomain, url_scheme, path_info, default_method, query_args: Any | None = ... ): ... def dispatch( - self, view_func, path_info: Optional[Any] = ..., method: Optional[Any] = ..., catch_http_exceptions: bool = ... + self, view_func, path_info: Any | None = ..., method: Any | None = ..., catch_http_exceptions: bool = ... ): ... def match( self, - path_info: Optional[Any] = ..., - method: Optional[Any] = ..., + path_info: Any | None = ..., + method: Any | None = ..., return_rule: bool = ..., - query_args: Optional[Any] = ..., + query_args: Any | None = ..., ): ... - def test(self, path_info: Optional[Any] = ..., method: Optional[Any] = ...): ... - def allowed_methods(self, path_info: Optional[Any] = ...): ... + def test(self, path_info: Any | None = ..., method: Any | None = ...): ... + def allowed_methods(self, path_info: Any | None = ...): ... def get_host(self, domain_part): ... def get_default_redirect(self, rule, method, values, query_args): ... def encode_query_args(self, query_args): ... - def make_redirect_url(self, path_info, query_args: Optional[Any] = ..., domain_part: Optional[Any] = ...): ... + def make_redirect_url(self, path_info, query_args: Any | None = ..., domain_part: Any | None = ...): ... def make_alias_redirect_url(self, path, endpoint, values, method, query_args): ... def build( self, endpoint, - values: Optional[Any] = ..., - method: Optional[Any] = ..., + values: Any | None = ..., + method: Any | None = ..., force_external: bool = ..., append_unknown: bool = ..., ): ... diff --git a/stubs/Werkzeug/werkzeug/script.pyi b/stubs/Werkzeug/werkzeug/script.pyi index a6420e23925a..6f9c4f280232 100644 --- a/stubs/Werkzeug/werkzeug/script.pyi +++ b/stubs/Werkzeug/werkzeug/script.pyi @@ -3,12 +3,12 @@ from typing import Any, Optional argument_types: Any converters: Any -def run(namespace: Optional[Any] = ..., action_prefix: str = ..., args: Optional[Any] = ...): ... +def run(namespace: Any | None = ..., action_prefix: str = ..., args: Any | None = ...): ... def fail(message, code: int = ...): ... def find_actions(namespace, action_prefix): ... def print_usage(actions): ... def analyse_action(func): ... -def make_shell(init_func: Optional[Any] = ..., banner: Optional[Any] = ..., use_ipython: bool = ...): ... +def make_shell(init_func: Any | None = ..., banner: Any | None = ..., use_ipython: bool = ...): ... def make_runserver( app_factory, hostname: str = ..., @@ -18,7 +18,7 @@ def make_runserver( use_evalex: bool = ..., threaded: bool = ..., processes: int = ..., - static_files: Optional[Any] = ..., - extra_files: Optional[Any] = ..., - ssl_context: Optional[Any] = ..., + static_files: Any | None = ..., + extra_files: Any | None = ..., + ssl_context: Any | None = ..., ): ... diff --git a/stubs/Werkzeug/werkzeug/security.pyi b/stubs/Werkzeug/werkzeug/security.pyi index fcb2652fcb86..8ba8ac531517 100644 --- a/stubs/Werkzeug/werkzeug/security.pyi +++ b/stubs/Werkzeug/werkzeug/security.pyi @@ -3,8 +3,8 @@ from typing import Any, Optional SALT_CHARS: Any DEFAULT_PBKDF2_ITERATIONS: Any -def pbkdf2_hex(data, salt, iterations=..., keylen: Optional[Any] = ..., hashfunc: Optional[Any] = ...): ... -def pbkdf2_bin(data, salt, iterations=..., keylen: Optional[Any] = ..., hashfunc: Optional[Any] = ...): ... +def pbkdf2_hex(data, salt, iterations=..., keylen: Any | None = ..., hashfunc: Any | None = ...): ... +def pbkdf2_bin(data, salt, iterations=..., keylen: Any | None = ..., hashfunc: Any | None = ...): ... def safe_str_cmp(a, b): ... def gen_salt(length): ... def generate_password_hash(password, method: str = ..., salt_length: int = ...): ... diff --git a/stubs/Werkzeug/werkzeug/serving.pyi b/stubs/Werkzeug/werkzeug/serving.pyi index 1df2b29e0bd2..5ad65258c491 100644 --- a/stubs/Werkzeug/werkzeug/serving.pyi +++ b/stubs/Werkzeug/werkzeug/serving.pyi @@ -33,10 +33,10 @@ class WSGIRequestHandler(BaseHTTPRequestHandler): def run_wsgi(self): ... def handle(self): ... def initiate_shutdown(self): ... - def connection_dropped(self, error, environ: Optional[Any] = ...): ... + def connection_dropped(self, error, environ: Any | None = ...): ... raw_requestline: Any def handle_one_request(self): ... - def send_response(self, code, message: Optional[Any] = ...): ... + def send_response(self, code, message: Any | None = ...): ... def version_string(self): ... def address_string(self): ... def port_integer(self): ... @@ -47,17 +47,17 @@ class WSGIRequestHandler(BaseHTTPRequestHandler): BaseRequestHandler: Any -def generate_adhoc_ssl_pair(cn: Optional[Any] = ...): ... -def make_ssl_devcert(base_path, host: Optional[Any] = ..., cn: Optional[Any] = ...): ... +def generate_adhoc_ssl_pair(cn: Any | None = ...): ... +def make_ssl_devcert(base_path, host: Any | None = ..., cn: Any | None = ...): ... def generate_adhoc_ssl_context(): ... -def load_ssl_context(cert_file, pkey_file: Optional[Any] = ..., protocol: Optional[Any] = ...): ... +def load_ssl_context(cert_file, pkey_file: Any | None = ..., protocol: Any | None = ...): ... class _SSLContext: def __init__(self, protocol): ... - def load_cert_chain(self, certfile, keyfile: Optional[Any] = ..., password: Optional[Any] = ...): ... + def load_cert_chain(self, certfile, keyfile: Any | None = ..., password: Any | None = ...): ... def wrap_socket(self, sock, **kwargs): ... -def is_ssl_error(error: Optional[Any] = ...): ... +def is_ssl_error(error: Any | None = ...): ... def select_ip_version(host, port): ... class BaseWSGIServer(HTTPServer): @@ -78,10 +78,10 @@ class BaseWSGIServer(HTTPServer): host, port, app, - handler: Optional[Any] = ..., + handler: Any | None = ..., passthrough_errors: bool = ..., - ssl_context: Optional[Any] = ..., - fd: Optional[Any] = ..., + ssl_context: Any | None = ..., + fd: Any | None = ..., ): ... def log(self, type, message, *args): ... def serve_forever(self): ... @@ -101,22 +101,22 @@ class ForkingWSGIServer(ForkingMixIn, BaseWSGIServer): port, app, processes: int = ..., - handler: Optional[Any] = ..., + handler: Any | None = ..., passthrough_errors: bool = ..., - ssl_context: Optional[Any] = ..., - fd: Optional[Any] = ..., + ssl_context: Any | None = ..., + fd: Any | None = ..., ): ... def make_server( - host: Optional[Any] = ..., - port: Optional[Any] = ..., - app: Optional[Any] = ..., + host: Any | None = ..., + port: Any | None = ..., + app: Any | None = ..., threaded: bool = ..., processes: int = ..., - request_handler: Optional[Any] = ..., + request_handler: Any | None = ..., passthrough_errors: bool = ..., - ssl_context: Optional[Any] = ..., - fd: Optional[Any] = ..., + ssl_context: Any | None = ..., + fd: Any | None = ..., ): ... def is_running_from_reloader(): ... def run_simple( @@ -126,15 +126,15 @@ def run_simple( use_reloader: bool = ..., use_debugger: bool = ..., use_evalex: bool = ..., - extra_files: Optional[Any] = ..., + extra_files: Any | None = ..., reloader_interval: int = ..., reloader_type: str = ..., threaded: bool = ..., processes: int = ..., - request_handler: Optional[Any] = ..., - static_files: Optional[Any] = ..., + request_handler: Any | None = ..., + static_files: Any | None = ..., passthrough_errors: bool = ..., - ssl_context: Optional[Any] = ..., + ssl_context: Any | None = ..., ): ... def run_with_reloader(*args, **kwargs): ... def main(): ... diff --git a/stubs/Werkzeug/werkzeug/test.pyi b/stubs/Werkzeug/werkzeug/test.pyi index 19bb5740dd76..3ac0f49424aa 100644 --- a/stubs/Werkzeug/werkzeug/test.pyi +++ b/stubs/Werkzeug/werkzeug/test.pyi @@ -11,16 +11,16 @@ else: from urllib2 import Request as U2Request def stream_encode_multipart( - values, use_tempfile: int = ..., threshold=..., boundary: Optional[Any] = ..., charset: Text = ... + values, use_tempfile: int = ..., threshold=..., boundary: Any | None = ..., charset: Text = ... ): ... -def encode_multipart(values, boundary: Optional[Any] = ..., charset: Text = ...): ... -def File(fd, filename: Optional[Any] = ..., mimetype: Optional[Any] = ...): ... +def encode_multipart(values, boundary: Any | None = ..., charset: Text = ...): ... +def File(fd, filename: Any | None = ..., mimetype: Any | None = ...): ... class _TestCookieHeaders: headers: Any def __init__(self, headers): ... def getheaders(self, name): ... - def get_all(self, name, default: Optional[Any] = ...): ... + def get_all(self, name, default: Any | None = ...): ... class _TestCookieResponse: headers: Any @@ -55,20 +55,20 @@ class EnvironBuilder: def __init__( self, path: str = ..., - base_url: Optional[Any] = ..., - query_string: Optional[Any] = ..., + base_url: Any | None = ..., + query_string: Any | None = ..., method: str = ..., - input_stream: Optional[Any] = ..., - content_type: Optional[Any] = ..., - content_length: Optional[Any] = ..., - errors_stream: Optional[Any] = ..., + input_stream: Any | None = ..., + content_type: Any | None = ..., + content_length: Any | None = ..., + errors_stream: Any | None = ..., multithread: bool = ..., multiprocess: bool = ..., run_once: bool = ..., - headers: Optional[Any] = ..., - data: Optional[Any] = ..., - environ_base: Optional[Any] = ..., - environ_overrides: Optional[Any] = ..., + headers: Any | None = ..., + data: Any | None = ..., + environ_base: Any | None = ..., + environ_overrides: Any | None = ..., charset: Text = ..., ): ... form: Any @@ -80,23 +80,23 @@ class EnvironBuilder: def __del__(self) -> None: ... def close(self) -> None: ... def get_environ(self) -> WSGIEnvironment: ... - def get_request(self, cls: Optional[Any] = ...): ... + def get_request(self, cls: Any | None = ...): ... class ClientRedirectError(Exception): ... # Response type for the client below. -# By default _R is Tuple[Iterable[Any], Union[Text, int], datastructures.Headers] +# By default _R is Tuple[Iterable[Any], Text | int, datastructures.Headers] _R = TypeVar("_R") class Client(Generic[_R]): application: Any - response_wrapper: Optional[Type[_R]] + response_wrapper: Type[_R] | None cookie_jar: Any allow_subdomain_redirects: Any def __init__( self, application, - response_wrapper: Optional[Type[_R]] = ..., + response_wrapper: Type[_R] | None = ..., use_cookies: bool = ..., allow_subdomain_redirects: bool = ..., ): ... @@ -105,15 +105,15 @@ class Client(Generic[_R]): server_name, key, value: str = ..., - max_age: Optional[Any] = ..., - expires: Optional[Any] = ..., + max_age: Any | None = ..., + expires: Any | None = ..., path: str = ..., - domain: Optional[Any] = ..., - secure: Optional[Any] = ..., + domain: Any | None = ..., + secure: Any | None = ..., httponly: bool = ..., charset: Text = ..., ): ... - def delete_cookie(self, server_name, key, path: str = ..., domain: Optional[Any] = ...): ... + def delete_cookie(self, server_name, key, path: str = ..., domain: Any | None = ...): ... def run_wsgi_app(self, environ, buffered: bool = ...): ... def resolve_redirect(self, response, new_location, environ, buffered: bool = ...): ... @overload diff --git a/stubs/Werkzeug/werkzeug/urls.pyi b/stubs/Werkzeug/werkzeug/urls.pyi index 6ca710a71a18..84a7fb74e227 100644 --- a/stubs/Werkzeug/werkzeug/urls.pyi +++ b/stubs/Werkzeug/werkzeug/urls.pyi @@ -31,7 +31,7 @@ class BaseURL(_URLTuple): def decode_netloc(self): ... def to_uri_tuple(self): ... def to_iri_tuple(self): ... - def get_file_location(self, pathformat: Optional[Any] = ...): ... + def get_file_location(self, pathformat: Any | None = ...): ... class URL(BaseURL): def encode_netloc(self): ... @@ -41,7 +41,7 @@ class BytesURL(BaseURL): def encode_netloc(self): ... def decode(self, charset: Text = ..., errors: Text = ...): ... -def url_parse(url, scheme: Optional[Any] = ..., allow_fragments: bool = ...): ... +def url_parse(url, scheme: Any | None = ..., allow_fragments: bool = ...): ... def url_quote(string, charset: Text = ..., errors: Text = ..., safe: str = ..., unsafe: str = ...): ... def url_quote_plus(string, charset: Text = ..., errors: Text = ..., safe: str = ...): ... def url_unparse(components): ... @@ -57,7 +57,7 @@ def url_decode( include_empty: bool = ..., errors: Text = ..., separator: str = ..., - cls: Optional[Any] = ..., + cls: Any | None = ..., ): ... def url_decode_stream( stream, @@ -66,20 +66,20 @@ def url_decode_stream( include_empty: bool = ..., errors: Text = ..., separator: str = ..., - cls: Optional[Any] = ..., - limit: Optional[Any] = ..., + cls: Any | None = ..., + limit: Any | None = ..., return_iterator: bool = ..., ): ... def url_encode( - obj, charset: Text = ..., encode_keys: bool = ..., sort: bool = ..., key: Optional[Any] = ..., separator: bytes = ... + obj, charset: Text = ..., encode_keys: bool = ..., sort: bool = ..., key: Any | None = ..., separator: bytes = ... ): ... def url_encode_stream( obj, - stream: Optional[Any] = ..., + stream: Any | None = ..., charset: Text = ..., encode_keys: bool = ..., sort: bool = ..., - key: Optional[Any] = ..., + key: Any | None = ..., separator: bytes = ..., ): ... def url_join(base, url, allow_fragments: bool = ...): ... @@ -89,6 +89,6 @@ class Href: charset: Text sort: Any key: Any - def __init__(self, base: str = ..., charset: Text = ..., sort: bool = ..., key: Optional[Any] = ...): ... + def __init__(self, base: str = ..., charset: Text = ..., sort: bool = ..., key: Any | None = ...): ... def __getattr__(self, name): ... def __call__(self, *path, **query): ... diff --git a/stubs/Werkzeug/werkzeug/useragents.pyi b/stubs/Werkzeug/werkzeug/useragents.pyi index 5356e3ff0562..47dee0a008c3 100644 --- a/stubs/Werkzeug/werkzeug/useragents.pyi +++ b/stubs/Werkzeug/werkzeug/useragents.pyi @@ -8,10 +8,10 @@ class UserAgentParser: class UserAgent: string: Any - platform: Optional[str] - browser: Optional[str] - version: Optional[str] - language: Optional[str] + platform: str | None + browser: str | None + version: str | None + language: str | None def __init__(self, environ_or_string): ... def to_header(self): ... def __nonzero__(self): ... diff --git a/stubs/Werkzeug/werkzeug/utils.pyi b/stubs/Werkzeug/werkzeug/utils.pyi index 62075cbf3135..cbbb37dba20d 100644 --- a/stubs/Werkzeug/werkzeug/utils.pyi +++ b/stubs/Werkzeug/werkzeug/utils.pyi @@ -8,9 +8,9 @@ class cached_property(property): __module__: Any __doc__: Any func: Any - def __init__(self, func, name: Optional[Any] = ..., doc: Optional[Any] = ...): ... + def __init__(self, func, name: Any | None = ..., doc: Any | None = ...): ... def __set__(self, obj, value): ... - def __get__(self, obj, type: Optional[Any] = ...): ... + def __get__(self, obj, type: Any | None = ...): ... class environ_property(_DictAccessorProperty): read_only: Any @@ -30,7 +30,7 @@ xhtml: Any def get_content_type(mimetype, charset): ... def format_string(string, context): ... def secure_filename(filename: Text) -> Text: ... -def escape(s, quote: Optional[Any] = ...): ... +def escape(s, quote: Any | None = ...): ... def unescape(s): ... # 'redirect' returns a werkzeug Response, unless you give it @@ -51,7 +51,7 @@ class ArgumentValidationError(ValueError): missing: Any extra: Any extra_positional: Any - def __init__(self, missing: Optional[Any] = ..., extra: Optional[Any] = ..., extra_positional: Optional[Any] = ...): ... + def __init__(self, missing: Any | None = ..., extra: Any | None = ..., extra_positional: Any | None = ...): ... class ImportStringError(ImportError): import_name: Any diff --git a/stubs/Werkzeug/werkzeug/wrappers.pyi b/stubs/Werkzeug/werkzeug/wrappers.pyi index 3eb059504e5d..e4bb49146883 100644 --- a/stubs/Werkzeug/werkzeug/wrappers.pyi +++ b/stubs/Werkzeug/werkzeug/wrappers.pyi @@ -37,13 +37,13 @@ from .useragents import UserAgent class BaseRequest: charset: str encoding_errors: str - max_content_length: Optional[int] + max_content_length: int | None max_form_memory_size: int parameter_storage_class: Type[Any] list_storage_class: Type[Any] dict_storage_class: Type[Any] form_data_parser_class: Type[Any] - trusted_hosts: Optional[Sequence[Text]] + trusted_hosts: Sequence[Text] | None disable_data_descriptor: Any environ: WSGIEnvironment = ... shallow: Any @@ -110,7 +110,7 @@ _SelfT = TypeVar("_SelfT", bound=BaseResponse) class BaseResponse: charset: str default_status: int - default_mimetype: Optional[str] + default_mimetype: str | None implicit_sequence_conversion: bool autocorrect_location_header: bool automatically_set_content_length: bool @@ -121,16 +121,16 @@ class BaseResponse: response: Iterable[bytes] def __init__( self, - response: Optional[Union[str, bytes, bytearray, Iterable[str], Iterable[bytes]]] = ..., - status: Optional[Union[Text, int]] = ..., - headers: Optional[Union[Headers, Mapping[Text, Text], Sequence[Tuple[Text, Text]]]] = ..., - mimetype: Optional[Text] = ..., - content_type: Optional[Text] = ..., + response: str | bytes | bytearray | Iterable[str] | Iterable[bytes] | None = ..., + status: Text | int | None = ..., + headers: Headers | Mapping[Text, Text] | Sequence[Tuple[Text, Text]] | None = ..., + mimetype: Text | None = ..., + content_type: Text | None = ..., direct_passthrough: bool = ..., ) -> None: ... def call_on_close(self, func: _OnCloseT) -> _OnCloseT: ... @classmethod - def force_type(cls: Type[_SelfT], response: object, environ: Optional[WSGIEnvironment] = ...) -> _SelfT: ... + def force_type(cls: Type[_SelfT], response: object, environ: WSGIEnvironment | None = ...) -> _SelfT: ... @classmethod def from_app(cls: Type[_SelfT], app: Any, environ: WSGIEnvironment, buffered: bool = ...) -> _SelfT: ... @overload @@ -139,24 +139,24 @@ class BaseResponse: def get_data(self, as_text: Literal[True]) -> Text: ... @overload def get_data(self, as_text: bool) -> Any: ... - def set_data(self, value: Union[bytes, Text]) -> None: ... + def set_data(self, value: bytes | Text) -> None: ... data: Any - def calculate_content_length(self) -> Optional[int]: ... + def calculate_content_length(self) -> int | None: ... def make_sequence(self) -> None: ... def iter_encoded(self) -> Iterator[bytes]: ... def set_cookie( self, key: str, - value: Union[str, bytes] = ..., - max_age: Union[float, timedelta, None] = ..., - expires: Optional[Union[int, datetime]] = ..., + value: str | bytes = ..., + max_age: float | timedelta | None = ..., + expires: int | datetime | None = ..., path: str = ..., - domain: Optional[str] = ..., + domain: str | None = ..., secure: bool = ..., httponly: bool = ..., - samesite: Optional[str] = ..., + samesite: str | None = ..., ) -> None: ... - def delete_cookie(self, key, path: str = ..., domain: Optional[Any] = ...): ... + def delete_cookie(self, key, path: str = ..., domain: Any | None = ...): ... @property def is_streamed(self) -> bool: ... @property @@ -204,7 +204,7 @@ class UserAgentMixin: class AuthorizationMixin: @property - def authorization(self) -> Optional[Authorization]: ... + def authorization(self) -> Authorization | None: ... class StreamOnlyMixin: disable_data_descriptor: Any @@ -214,7 +214,7 @@ class ETagResponseMixin: @property def cache_control(self): ... status_code: Any - def make_conditional(self, request_or_environ, accept_ranges: bool = ..., complete_length: Optional[Any] = ...): ... + def make_conditional(self, request_or_environ, accept_ranges: bool = ..., complete_length: Any | None = ...): ... def add_etag(self, overwrite: bool = ..., weak: bool = ...): ... def set_etag(self, etag, weak: bool = ...): ... def get_etag(self): ... @@ -241,19 +241,19 @@ class ResponseStreamMixin: class CommonRequestDescriptorsMixin: @property - def content_type(self) -> Optional[str]: ... + def content_type(self) -> str | None: ... @property - def content_length(self) -> Optional[int]: ... + def content_length(self) -> int | None: ... @property - def content_encoding(self) -> Optional[str]: ... + def content_encoding(self) -> str | None: ... @property - def content_md5(self) -> Optional[str]: ... + def content_md5(self) -> str | None: ... @property - def referrer(self) -> Optional[str]: ... + def referrer(self) -> str | None: ... @property - def date(self) -> Optional[datetime]: ... + def date(self) -> datetime | None: ... @property - def max_forwards(self) -> Optional[int]: ... + def max_forwards(self) -> int | None: ... @property def mimetype(self) -> str: ... @property @@ -262,23 +262,23 @@ class CommonRequestDescriptorsMixin: def pragma(self) -> HeaderSet: ... class CommonResponseDescriptorsMixin: - mimetype: Optional[str] = ... + mimetype: str | None = ... @property def mimetype_params(self) -> MutableMapping[str, str]: ... - location: Optional[str] = ... - age: Any = ... # get: Optional[datetime.timedelta] - content_type: Optional[str] = ... - content_length: Optional[int] = ... - content_location: Optional[str] = ... - content_encoding: Optional[str] = ... - content_md5: Optional[str] = ... - date: Any = ... # get: Optional[datetime.datetime] - expires: Any = ... # get: Optional[datetime.datetime] - last_modified: Any = ... # get: Optional[datetime.datetime] - retry_after: Any = ... # get: Optional[datetime.datetime] - vary: Optional[str] = ... - content_language: Optional[str] = ... - allow: Optional[str] = ... + location: str | None = ... + age: Any = ... # get: datetime.timedelta | None + content_type: str | None = ... + content_length: int | None = ... + content_location: str | None = ... + content_encoding: str | None = ... + content_md5: str | None = ... + date: Any = ... # get: datetime.datetime | None + expires: Any = ... # get: datetime.datetime | None + last_modified: Any = ... # get: datetime.datetime | None + retry_after: Any = ... # get: datetime.datetime | None + vary: str | None = ... + content_language: str | None = ... + allow: str | None = ... class WWWAuthenticateMixin: @property diff --git a/stubs/Werkzeug/werkzeug/wsgi.pyi b/stubs/Werkzeug/werkzeug/wsgi.pyi index ea6bb85cd875..1804242cbc09 100644 --- a/stubs/Werkzeug/werkzeug/wsgi.pyi +++ b/stubs/Werkzeug/werkzeug/wsgi.pyi @@ -8,11 +8,11 @@ from .middleware.shared_data import SharedDataMiddleware as SharedDataMiddleware def responder(f): ... def get_current_url( - environ, root_only: bool = ..., strip_querystring: bool = ..., host_only: bool = ..., trusted_hosts: Optional[Any] = ... + environ, root_only: bool = ..., strip_querystring: bool = ..., host_only: bool = ..., trusted_hosts: Any | None = ... ): ... def host_is_trusted(hostname, trusted_list): ... -def get_host(environ, trusted_hosts: Optional[Any] = ...): ... -def get_content_length(environ: WSGIEnvironment) -> Optional[int]: ... +def get_host(environ, trusted_hosts: Any | None = ...): ... +def get_content_length(environ: WSGIEnvironment) -> int | None: ... def get_input_stream(environ: WSGIEnvironment, safe_fallback: bool = ...) -> InputStream: ... def get_query_string(environ): ... def get_path_info(environ, charset: Text = ..., errors: Text = ...): ... @@ -24,7 +24,7 @@ def extract_path_info( ): ... class ClosingIterator: - def __init__(self, iterable, callbacks: Optional[Any] = ...): ... + def __init__(self, iterable, callbacks: Any | None = ...): ... def __iter__(self): ... def __next__(self): ... def close(self): ... @@ -38,7 +38,7 @@ class FileWrapper: def close(self) -> None: ... def seekable(self) -> bool: ... def seek(self, offset: int, whence: int = ...) -> None: ... - def tell(self) -> Optional[int]: ... + def tell(self) -> int | None: ... def __iter__(self) -> FileWrapper: ... def __next__(self) -> bytes: ... @@ -50,13 +50,13 @@ class _RangeWrapper: read_length: Any seekable: Any end_reached: Any - def __init__(self, iterable, start_byte: int = ..., byte_range: Optional[Any] = ...): ... + def __init__(self, iterable, start_byte: int = ..., byte_range: Any | None = ...): ... def __iter__(self): ... def __next__(self): ... def close(self): ... -def make_line_iter(stream, limit: Optional[Any] = ..., buffer_size=..., cap_at_buffer: bool = ...): ... -def make_chunk_iter(stream, separator, limit: Optional[Any] = ..., buffer_size=..., cap_at_buffer: bool = ...): ... +def make_line_iter(stream, limit: Any | None = ..., buffer_size=..., cap_at_buffer: bool = ...): ... +def make_chunk_iter(stream, separator, limit: Any | None = ..., buffer_size=..., cap_at_buffer: bool = ...): ... class LimitedStream: limit: Any @@ -67,8 +67,8 @@ class LimitedStream: def on_exhausted(self): ... def on_disconnect(self): ... def exhaust(self, chunk_size=...): ... - def read(self, size: Optional[Any] = ...): ... - def readline(self, size: Optional[Any] = ...): ... - def readlines(self, size: Optional[Any] = ...): ... + def read(self, size: Any | None = ...): ... + def readline(self, size: Any | None = ...): ... + def readlines(self, size: Any | None = ...): ... def tell(self): ... def __next__(self): ... diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index a6197fbad6ac..94152daad1f4 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -16,7 +16,7 @@ class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]): def __init__(self, coro: Coroutine[_T_co, _T_contra, _V_co]) -> None: ... def send(self, value: _T_contra) -> _T_co: ... def throw( - self, typ: Type[BaseException], val: Union[BaseException, object] = ..., tb: Optional[TracebackType] = ... + self, typ: Type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ... ) -> _T_co: ... def close(self) -> None: ... @property @@ -32,5 +32,5 @@ class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]): async def __anext__(self) -> _V_co: ... async def __aenter__(self) -> _V_co: ... async def __aexit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index 9b6a62dca589..9e8bd975f0c3 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -5,17 +5,17 @@ from typing import Optional, Sequence, Union, overload _FdOrAnyPath = Union[int, StrOrBytesPath] -async def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ... +async def stat(path: _FdOrAnyPath, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> stat_result: ... async def rename( - src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ... + src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ... ) -> None: ... -async def remove(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... -async def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... -async def rmdir(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... +async def remove(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... +async def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ... +async def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... if sys.platform != "win32": @overload - async def sendfile(__out_fd: int, __in_fd: int, offset: Optional[int], count: int) -> int: ... + async def sendfile(__out_fd: int, __in_fd: int, offset: int | None, count: int) -> int: ... @overload async def sendfile( __out_fd: int, diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index ce0a52824a47..8035c5a43200 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -23,14 +23,14 @@ def open( file: _OpenFile, mode: OpenTextMode = ..., buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., *, - loop: Optional[AbstractEventLoop] = ..., - executor: Optional[Any] = ..., + loop: AbstractEventLoop | None = ..., + executor: Any | None = ..., ) -> AiofilesContextManager[None, None, AsyncTextIOWrapper]: ... # Unbuffered binary: returns a FileIO @@ -43,26 +43,26 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., *, - loop: Optional[AbstractEventLoop] = ..., - executor: Optional[Any] = ..., + loop: AbstractEventLoop | None = ..., + executor: Any | None = ..., ) -> AiofilesContextManager[None, None, AsyncFileIO]: ... # Buffered binary reading/updating: AsyncBufferedReader @overload def open( file: _OpenFile, - mode: Union[OpenBinaryModeReading, OpenBinaryModeUpdating], + mode: OpenBinaryModeReading | OpenBinaryModeUpdating, buffering: Literal[-1, 1] = ..., encoding: None = ..., errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., *, - loop: Optional[AbstractEventLoop] = ..., - executor: Optional[Any] = ..., + loop: AbstractEventLoop | None = ..., + executor: Any | None = ..., ) -> AiofilesContextManager[None, None, AsyncBufferedReader]: ... # Buffered binary writing: AsyncBufferedIOBase @@ -75,10 +75,10 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., *, - loop: Optional[AbstractEventLoop] = ..., - executor: Optional[Any] = ..., + loop: AbstractEventLoop | None = ..., + executor: Any | None = ..., ) -> AiofilesContextManager[None, None, AsyncBufferedIOBase]: ... # Buffering cannot be determined: fall back to _UnknownAsyncBinaryIO @@ -91,8 +91,8 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., *, - loop: Optional[AbstractEventLoop] = ..., - executor: Optional[Any] = ..., + loop: AbstractEventLoop | None = ..., + executor: Any | None = ..., ) -> AiofilesContextManager[None, None, _UnknownAsyncBinaryIO]: ... diff --git a/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/stubs/aiofiles/aiofiles/threadpool/binary.pyi index 1da36f688f67..88261b989a0b 100644 --- a/stubs/aiofiles/aiofiles/threadpool/binary.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/binary.pyi @@ -9,13 +9,13 @@ class _UnknownAsyncBinaryIO(AsyncBase[bytes]): async def flush(self) -> None: ... async def isatty(self) -> bool: ... async def read(self, __size: int = ...) -> bytes: ... - async def readinto(self, __buffer: WriteableBuffer) -> Optional[int]: ... - async def readline(self, __size: Optional[int] = ...) -> bytes: ... + async def readinto(self, __buffer: WriteableBuffer) -> int | None: ... + async def readline(self, __size: int | None = ...) -> bytes: ... async def readlines(self, __hint: int = ...) -> List[bytes]: ... async def seek(self, __offset: int, __whence: int = ...) -> int: ... async def seekable(self) -> bool: ... async def tell(self) -> int: ... - async def truncate(self, __size: Optional[int] = ...) -> int: ... + async def truncate(self, __size: int | None = ...) -> int: ... async def writable(self) -> bool: ... async def write(self, __b: ReadableBuffer) -> int: ... async def writelines(self, __lines: Iterable[ReadableBuffer]) -> None: ... @@ -26,7 +26,7 @@ class _UnknownAsyncBinaryIO(AsyncBase[bytes]): @property def mode(self) -> str: ... @property - def name(self) -> Union[StrOrBytesPath, int]: ... + def name(self) -> StrOrBytesPath | int: ... class AsyncBufferedIOBase(_UnknownAsyncBinaryIO): async def read1(self, __size: int = ...) -> bytes: ... diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index 3c087464ef91..57eeb8667b3c 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -7,13 +7,13 @@ class AsyncTextIOWrapper(AsyncBase[str]): async def close(self) -> None: ... async def flush(self) -> None: ... async def isatty(self) -> bool: ... - async def read(self, __size: Optional[int] = ...) -> str: ... + async def read(self, __size: int | None = ...) -> str: ... async def readline(self, __size: int = ...) -> str: ... async def readlines(self, __hint: int = ...) -> List[str]: ... async def seek(self, __offset: int, __whence: int = ...) -> int: ... async def seekable(self) -> bool: ... async def tell(self) -> int: ... - async def truncate(self, __size: Optional[int] = ...) -> int: ... + async def truncate(self, __size: int | None = ...) -> int: ... async def writable(self) -> bool: ... async def write(self, __b: str) -> int: ... async def writelines(self, __lines: Iterable[str]) -> None: ... @@ -27,12 +27,12 @@ class AsyncTextIOWrapper(AsyncBase[str]): @property def encoding(self) -> str: ... @property - def errors(self) -> Optional[str]: ... + def errors(self) -> str | None: ... @property def line_buffering(self) -> bool: ... @property - def newlines(self) -> Union[str, Tuple[str, ...], None]: ... + def newlines(self) -> str | Tuple[str, ...] | None: ... @property - def name(self) -> Union[StrOrBytesPath, int]: ... + def name(self) -> StrOrBytesPath | int: ... @property def mode(self) -> str: ... diff --git a/stubs/atomicwrites/atomicwrites/__init__.pyi b/stubs/atomicwrites/atomicwrites/__init__.pyi index d479ea43003d..69636df39481 100644 --- a/stubs/atomicwrites/atomicwrites/__init__.pyi +++ b/stubs/atomicwrites/atomicwrites/__init__.pyi @@ -8,7 +8,7 @@ class AtomicWriter(object): def __init__(self, path: StrOrBytesPath, mode: Text = ..., overwrite: bool = ...) -> None: ... def open(self) -> ContextManager[IO[Any]]: ... def _open(self, get_fileobject: Callable[..., IO[AnyStr]]) -> ContextManager[IO[AnyStr]]: ... - def get_fileobject(self, dir: Optional[StrOrBytesPath] = ..., **kwargs: Any) -> IO[Any]: ... + def get_fileobject(self, dir: StrOrBytesPath | None = ..., **kwargs: Any) -> IO[Any]: ... def sync(self, f: IO[Any]) -> None: ... def commit(self, f: IO[Any]) -> None: ... def rollback(self, f: IO[Any]) -> None: ... diff --git a/stubs/bleach/bleach/__init__.pyi b/stubs/bleach/bleach/__init__.pyi index ef0341e67850..a61b389ad2e6 100644 --- a/stubs/bleach/bleach/__init__.pyi +++ b/stubs/bleach/bleach/__init__.pyi @@ -26,5 +26,5 @@ def clean( strip_comments: bool = ..., ) -> Text: ... def linkify( - text: Text, callbacks: Iterable[_Callback] = ..., skip_tags: Optional[Container[Text]] = ..., parse_email: bool = ... + text: Text, callbacks: Iterable[_Callback] = ..., skip_tags: Container[Text] | None = ..., parse_email: bool = ... ) -> Text: ... diff --git a/stubs/bleach/bleach/html5lib_shim.pyi b/stubs/bleach/bleach/html5lib_shim.pyi index b9949db04242..01adb4a4cdd0 100644 --- a/stubs/bleach/bleach/html5lib_shim.pyi +++ b/stubs/bleach/bleach/html5lib_shim.pyi @@ -13,14 +13,14 @@ class HTMLSerializer(object): # actually html5lib.serializer.HTMLSerializer def __getattr__(self, __name: Text) -> Any: ... # incomplete class BleachHTMLParser(HTMLParser): - tags: Optional[List[Text]] + tags: List[Text] | None strip: bool consume_entities: bool - def __init__(self, tags: Optional[Iterable[Text]], strip: bool, consume_entities: bool, **kwargs) -> None: ... + def __init__(self, tags: Iterable[Text] | None, strip: bool, consume_entities: bool, **kwargs) -> None: ... class BleachHTMLSerializer(HTMLSerializer): escape_rcdata: bool def escape_base_amp(self, stoken: Text) -> Generator[Text, None, None]: ... - def serialize(self, treewalker, encoding: Optional[Text] = ...) -> Generator[Text, None, None]: ... + def serialize(self, treewalker, encoding: Text | None = ...) -> Generator[Text, None, None]: ... def __getattr__(__name: Text) -> Any: ... # incomplete diff --git a/stubs/bleach/bleach/linkifier.pyi b/stubs/bleach/bleach/linkifier.pyi index 1e51b504c066..4f5f32851f0d 100644 --- a/stubs/bleach/bleach/linkifier.pyi +++ b/stubs/bleach/bleach/linkifier.pyi @@ -24,11 +24,11 @@ class Linker(object): def __init__( self, callbacks: Iterable[_Callback] = ..., - skip_tags: Optional[Container[Text]] = ..., + skip_tags: Container[Text] | None = ..., parse_email: bool = ..., url_re: Pattern[Text] = ..., email_re: Pattern[Text] = ..., - recognized_tags: Optional[Container[Text]] = ..., + recognized_tags: Container[Text] | None = ..., ) -> None: ... def linkify(self, text: Text) -> Text: ... diff --git a/stubs/bleach/bleach/sanitizer.pyi b/stubs/bleach/bleach/sanitizer.pyi index 4fce63f8fa90..88c094af38dd 100644 --- a/stubs/bleach/bleach/sanitizer.pyi +++ b/stubs/bleach/bleach/sanitizer.pyi @@ -33,7 +33,7 @@ class Cleaner(object): protocols: Container[Text] = ..., strip: bool = ..., strip_comments: bool = ..., - filters: Optional[Iterable[_Filter]] = ..., + filters: Iterable[_Filter] | None = ..., ) -> None: ... def clean(self, text: Text) -> Text: ... diff --git a/stubs/boto/boto/__init__.pyi b/stubs/boto/boto/__init__.pyi index c298f74c5643..fe6573fcfa54 100644 --- a/stubs/boto/boto/__init__.pyi +++ b/stubs/boto/boto/__init__.pyi @@ -20,80 +20,80 @@ class NullHandler(logging.Handler): log: Any perflog: Any -def set_file_logger(name, filepath, level: Any = ..., format_string: Optional[Any] = ...): ... -def set_stream_logger(name, level: Any = ..., format_string: Optional[Any] = ...): ... -def connect_sqs(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... +def set_file_logger(name, filepath, level: Any = ..., format_string: Any | None = ...): ... +def set_stream_logger(name, level: Any = ..., format_string: Any | None = ...): ... +def connect_sqs(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_s3( - aws_access_key_id: Optional[Text] = ..., aws_secret_access_key: Optional[Text] = ..., **kwargs + aws_access_key_id: Text | None = ..., aws_secret_access_key: Text | None = ..., **kwargs ) -> S3Connection: ... -def connect_gs(gs_access_key_id: Optional[Any] = ..., gs_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_ec2(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_elb(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_autoscale(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_cloudwatch(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_sdb(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_fps(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_mturk(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_cloudfront(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_vpc(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_rds(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_rds2(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_emr(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_sns(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_iam(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_route53(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_cloudformation(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... +def connect_gs(gs_access_key_id: Any | None = ..., gs_secret_access_key: Any | None = ..., **kwargs): ... +def connect_ec2(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_elb(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_autoscale(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_cloudwatch(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_sdb(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_fps(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_mturk(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_cloudfront(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_vpc(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_rds(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_rds2(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_emr(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_sns(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_iam(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_route53(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_cloudformation(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_euca( - host: Optional[Any] = ..., - aws_access_key_id: Optional[Any] = ..., - aws_secret_access_key: Optional[Any] = ..., + host: Any | None = ..., + aws_access_key_id: Any | None = ..., + aws_secret_access_key: Any | None = ..., port: int = ..., path: str = ..., is_secure: bool = ..., **kwargs, ): ... -def connect_glacier(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_ec2_endpoint(url, aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... +def connect_glacier(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_ec2_endpoint(url, aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_walrus( - host: Optional[Any] = ..., - aws_access_key_id: Optional[Any] = ..., - aws_secret_access_key: Optional[Any] = ..., + host: Any | None = ..., + aws_access_key_id: Any | None = ..., + aws_secret_access_key: Any | None = ..., port: int = ..., path: str = ..., is_secure: bool = ..., **kwargs, ): ... -def connect_ses(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_sts(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... +def connect_ses(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_sts(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_ia( - ia_access_key_id: Optional[Any] = ..., ia_secret_access_key: Optional[Any] = ..., is_secure: bool = ..., **kwargs + ia_access_key_id: Any | None = ..., ia_secret_access_key: Any | None = ..., is_secure: bool = ..., **kwargs ): ... -def connect_dynamodb(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_swf(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_cloudsearch(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... +def connect_dynamodb(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_swf(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_cloudsearch(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_cloudsearch2( - aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., sign_request: bool = ..., **kwargs + aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., sign_request: bool = ..., **kwargs ): ... -def connect_cloudsearchdomain(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_beanstalk(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_elastictranscoder(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_opsworks(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_redshift(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_support(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_cloudtrail(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_directconnect(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_kinesis(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_logs(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_route53domains(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_cognito_identity(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_cognito_sync(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_kms(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_awslambda(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_codedeploy(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_configservice(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_cloudhsm(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_ec2containerservice(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... -def connect_machinelearning(aws_access_key_id: Optional[Any] = ..., aws_secret_access_key: Optional[Any] = ..., **kwargs): ... +def connect_cloudsearchdomain(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_beanstalk(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_elastictranscoder(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_opsworks(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_redshift(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_support(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_cloudtrail(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_directconnect(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_kinesis(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_logs(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_route53domains(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_cognito_identity(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_cognito_sync(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_kms(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_awslambda(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_codedeploy(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_configservice(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_cloudhsm(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_ec2containerservice(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... +def connect_machinelearning(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def storage_uri( uri_str, default_scheme: str = ..., diff --git a/stubs/boto/boto/auth.pyi b/stubs/boto/boto/auth.pyi index f59955010872..a58b22104ece 100644 --- a/stubs/boto/boto/auth.pyi +++ b/stubs/boto/boto/auth.pyi @@ -45,7 +45,7 @@ class HmacAuthV4Handler(AuthHandler, HmacKeys): capability: Any service_name: Any region_name: Any - def __init__(self, host, config, provider, service_name: Optional[Any] = ..., region_name: Optional[Any] = ...) -> None: ... + def __init__(self, host, config, provider, service_name: Any | None = ..., region_name: Any | None = ...) -> None: ... def headers_to_sign(self, http_request): ... def host_header(self, host, http_request): ... def query_string(self, http_request): ... @@ -78,7 +78,7 @@ class S3HmacAuthV4Handler(HmacAuthV4Handler, AuthHandler): def mangle_path_and_params(self, req): ... def payload(self, http_request): ... def add_auth(self, req, **kwargs): ... - def presign(self, req, expires, iso_date: Optional[Any] = ...): ... + def presign(self, req, expires, iso_date: Any | None = ...): ... class STSAnonHandler(AuthHandler): capability: Any @@ -104,6 +104,6 @@ class POSTPathQSV2AuthHandler(QuerySignatureV2AuthHandler, AuthHandler): capability: Any def add_auth(self, req, **kwargs): ... -def get_auth_handler(host, config, provider, requested_capability: Optional[Any] = ...): ... +def get_auth_handler(host, config, provider, requested_capability: Any | None = ...): ... def detect_potential_sigv4(func): ... def detect_potential_s3sigv4(func): ... diff --git a/stubs/boto/boto/connection.pyi b/stubs/boto/boto/connection.pyi index 425e56de09f6..8e79c4a216ac 100644 --- a/stubs/boto/boto/connection.pyi +++ b/stubs/boto/boto/connection.pyi @@ -42,7 +42,7 @@ class HTTPRequest: class HTTPResponse(http_client.HTTPResponse): def __init__(self, *args, **kwargs) -> None: ... - def read(self, amt: Optional[Any] = ...): ... + def read(self, amt: Any | None = ...): ... class AWSAuthConnection: suppress_consec_slashes: Any @@ -67,22 +67,22 @@ class AWSAuthConnection: def __init__( self, host, - aws_access_key_id: Optional[Any] = ..., - aws_secret_access_key: Optional[Any] = ..., + aws_access_key_id: Any | None = ..., + aws_secret_access_key: Any | None = ..., is_secure: bool = ..., - port: Optional[Any] = ..., - proxy: Optional[Any] = ..., - proxy_port: Optional[Any] = ..., - proxy_user: Optional[Any] = ..., - proxy_pass: Optional[Any] = ..., + port: Any | None = ..., + proxy: Any | None = ..., + proxy_port: Any | None = ..., + proxy_user: Any | None = ..., + proxy_pass: Any | None = ..., debug: int = ..., - https_connection_factory: Optional[Any] = ..., + https_connection_factory: Any | None = ..., path: str = ..., provider: str = ..., - security_token: Optional[Any] = ..., + security_token: Any | None = ..., suppress_consec_slashes: bool = ..., validate_certs: bool = ..., - profile_name: Optional[Any] = ..., + profile_name: Any | None = ..., ) -> None: ... auth_region_name: Any @property @@ -100,7 +100,7 @@ class AWSAuthConnection: @property def profile_name(self): ... def get_path(self, path: str = ...): ... - def server_name(self, port: Optional[Any] = ...): ... + def server_name(self, port: Any | None = ...): ... proxy: Any proxy_port: Any proxy_user: Any @@ -112,8 +112,8 @@ class AWSAuthConnection: def skip_proxy(self, host): ... def new_http_connection(self, host, port, is_secure): ... def put_http_connection(self, host, port, is_secure, connection): ... - def proxy_ssl(self, host: Optional[Any] = ..., port: Optional[Any] = ...): ... - def prefix_proxy_to_path(self, path, host: Optional[Any] = ...): ... + def proxy_ssl(self, host: Any | None = ..., port: Any | None = ...): ... + def prefix_proxy_to_path(self, path, host: Any | None = ...): ... def get_proxy_auth_header(self): ... def get_proxy_url_with_auth(self): ... def set_host_header(self, request): ... @@ -123,23 +123,23 @@ class AWSAuthConnection: method, path, auth_path, - params: Optional[Any] = ..., - headers: Optional[Any] = ..., + params: Any | None = ..., + headers: Any | None = ..., data: str = ..., - host: Optional[Any] = ..., + host: Any | None = ..., ): ... def make_request( self, method, path, - headers: Optional[Any] = ..., + headers: Any | None = ..., data: str = ..., - host: Optional[Any] = ..., - auth_path: Optional[Any] = ..., - sender: Optional[Any] = ..., - override_num_retries: Optional[Any] = ..., - params: Optional[Any] = ..., - retry_handler: Optional[Any] = ..., + host: Any | None = ..., + auth_path: Any | None = ..., + sender: Any | None = ..., + override_num_retries: Any | None = ..., + params: Any | None = ..., + retry_handler: Any | None = ..., ): ... def close(self): ... @@ -148,27 +148,27 @@ class AWSQueryConnection(AWSAuthConnection): ResponseError: Any def __init__( self, - aws_access_key_id: Optional[Any] = ..., - aws_secret_access_key: Optional[Any] = ..., + aws_access_key_id: Any | None = ..., + aws_secret_access_key: Any | None = ..., is_secure: bool = ..., - port: Optional[Any] = ..., - proxy: Optional[Any] = ..., - proxy_port: Optional[Any] = ..., - proxy_user: Optional[Any] = ..., - proxy_pass: Optional[Any] = ..., - host: Optional[Any] = ..., + port: Any | None = ..., + proxy: Any | None = ..., + proxy_port: Any | None = ..., + proxy_user: Any | None = ..., + proxy_pass: Any | None = ..., + host: Any | None = ..., debug: int = ..., - https_connection_factory: Optional[Any] = ..., + https_connection_factory: Any | None = ..., path: str = ..., - security_token: Optional[Any] = ..., + security_token: Any | None = ..., validate_certs: bool = ..., - profile_name: Optional[Any] = ..., + profile_name: Any | None = ..., provider: str = ..., ) -> None: ... def get_utf8_value(self, value): ... - def make_request(self, action, params: Optional[Any] = ..., path: str = ..., verb: str = ..., *args, **kwargs): ... # type: ignore # https://github.com/python/mypy/issues/1237 + def make_request(self, action, params: Any | None = ..., path: str = ..., verb: str = ..., *args, **kwargs): ... # type: ignore # https://github.com/python/mypy/issues/1237 def build_list_params(self, params, items, label): ... def build_complex_list_params(self, params, items, label, names): ... - def get_list(self, action, params, markers, path: str = ..., parent: Optional[Any] = ..., verb: str = ...): ... - def get_object(self, action, params, cls, path: str = ..., parent: Optional[Any] = ..., verb: str = ...): ... - def get_status(self, action, params, path: str = ..., parent: Optional[Any] = ..., verb: str = ...): ... + def get_list(self, action, params, markers, path: str = ..., parent: Any | None = ..., verb: str = ...): ... + def get_object(self, action, params, cls, path: str = ..., parent: Any | None = ..., verb: str = ...): ... + def get_status(self, action, params, path: str = ..., parent: Any | None = ..., verb: str = ...): ... diff --git a/stubs/boto/boto/exception.pyi b/stubs/boto/boto/exception.pyi index a8db84c13131..a6a6b0a9e363 100644 --- a/stubs/boto/boto/exception.pyi +++ b/stubs/boto/boto/exception.pyi @@ -19,7 +19,7 @@ class BotoServerError(StandardError): error_code: Any message: str box_usage: Any - def __init__(self, status, reason, body: Optional[Any] = ..., *args) -> None: ... + def __init__(self, status, reason, body: Any | None = ..., *args) -> None: ... def __getattr__(self, name): ... def __setattr__(self, name, value): ... def startElement(self, name, attrs, connection): ... @@ -31,13 +31,13 @@ class ConsoleOutput: timestamp: Any comment: Any output: Any - def __init__(self, parent: Optional[Any] = ...) -> None: ... + def __init__(self, parent: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... class StorageCreateError(BotoServerError): bucket: Any - def __init__(self, status, reason, body: Optional[Any] = ...) -> None: ... + def __init__(self, status, reason, body: Any | None = ...) -> None: ... def endElement(self, name, value, connection): ... class S3CreateError(StorageCreateError): ... @@ -49,7 +49,7 @@ class GSCopyError(StorageCopyError): ... class SQSError(BotoServerError): detail: Any type: Any - def __init__(self, status, reason, body: Optional[Any] = ...) -> None: ... + def __init__(self, status, reason, body: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -59,7 +59,7 @@ class SQSDecodeError(BotoClientError): class StorageResponseError(BotoServerError): resource: Any - def __init__(self, status, reason, body: Optional[Any] = ...) -> None: ... + def __init__(self, status, reason, body: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -68,7 +68,7 @@ class GSResponseError(StorageResponseError): ... class EC2ResponseError(BotoServerError): errors: Any - def __init__(self, status, reason, body: Optional[Any] = ...) -> None: ... + def __init__(self, status, reason, body: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... request_id: Any def endElement(self, name, value, connection): ... @@ -79,7 +79,7 @@ class JSONResponseError(BotoServerError): body: Any error_message: Any error_code: Any - def __init__(self, status, reason, body: Optional[Any] = ..., *args) -> None: ... + def __init__(self, status, reason, body: Any | None = ..., *args) -> None: ... class DynamoDBResponseError(JSONResponseError): ... class SWFResponseError(JSONResponseError): ... @@ -89,7 +89,7 @@ class _EC2Error: connection: Any error_code: Any error_message: Any - def __init__(self, connection: Optional[Any] = ...) -> None: ... + def __init__(self, connection: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -140,7 +140,7 @@ class TooManyRecordsException(Exception): class PleaseRetryException(Exception): message: Any response: Any - def __init__(self, message, response: Optional[Any] = ...) -> None: ... + def __init__(self, message, response: Any | None = ...) -> None: ... class InvalidInstanceMetadataError(Exception): MSG: str diff --git a/stubs/boto/boto/kms/layer1.pyi b/stubs/boto/boto/kms/layer1.pyi index 86c5724533b8..dd3b0df6830c 100644 --- a/stubs/boto/boto/kms/layer1.pyi +++ b/stubs/boto/boto/kms/layer1.pyi @@ -11,72 +11,72 @@ class KMSConnection(AWSQueryConnection): ResponseError: Type[Exception] region: Any def __init__(self, **kwargs) -> None: ... - def create_alias(self, alias_name: str, target_key_id: str) -> Optional[Dict[str, Any]]: ... + def create_alias(self, alias_name: str, target_key_id: str) -> Dict[str, Any] | None: ... def create_grant( self, key_id: str, grantee_principal: str, - retiring_principal: Optional[str] = ..., - operations: Optional[List[str]] = ..., - constraints: Optional[Dict[str, Dict[str, str]]] = ..., - grant_tokens: Optional[List[str]] = ..., - ) -> Optional[Dict[str, Any]]: ... + retiring_principal: str | None = ..., + operations: List[str] | None = ..., + constraints: Dict[str, Dict[str, str]] | None = ..., + grant_tokens: List[str] | None = ..., + ) -> Dict[str, Any] | None: ... def create_key( - self, policy: Optional[str] = ..., description: Optional[str] = ..., key_usage: Optional[str] = ... - ) -> Optional[Dict[str, Any]]: ... + self, policy: str | None = ..., description: str | None = ..., key_usage: str | None = ... + ) -> Dict[str, Any] | None: ... def decrypt( self, ciphertext_blob: bytes, - encryption_context: Optional[Mapping[str, Any]] = ..., - grant_tokens: Optional[List[str]] = ..., - ) -> Optional[Dict[str, Any]]: ... - def delete_alias(self, alias_name: str) -> Optional[Dict[str, Any]]: ... - def describe_key(self, key_id: str) -> Optional[Dict[str, Any]]: ... - def disable_key(self, key_id: str) -> Optional[Dict[str, Any]]: ... - def disable_key_rotation(self, key_id: str) -> Optional[Dict[str, Any]]: ... - def enable_key(self, key_id: str) -> Optional[Dict[str, Any]]: ... - def enable_key_rotation(self, key_id: str) -> Optional[Dict[str, Any]]: ... + encryption_context: Mapping[str, Any] | None = ..., + grant_tokens: List[str] | None = ..., + ) -> Dict[str, Any] | None: ... + def delete_alias(self, alias_name: str) -> Dict[str, Any] | None: ... + def describe_key(self, key_id: str) -> Dict[str, Any] | None: ... + def disable_key(self, key_id: str) -> Dict[str, Any] | None: ... + def disable_key_rotation(self, key_id: str) -> Dict[str, Any] | None: ... + def enable_key(self, key_id: str) -> Dict[str, Any] | None: ... + def enable_key_rotation(self, key_id: str) -> Dict[str, Any] | None: ... def encrypt( self, key_id: str, plaintext: bytes, - encryption_context: Optional[Mapping[str, Any]] = ..., - grant_tokens: Optional[List[str]] = ..., - ) -> Optional[Dict[str, Any]]: ... + encryption_context: Mapping[str, Any] | None = ..., + grant_tokens: List[str] | None = ..., + ) -> Dict[str, Any] | None: ... def generate_data_key( self, key_id: str, - encryption_context: Optional[Mapping[str, Any]] = ..., - number_of_bytes: Optional[int] = ..., - key_spec: Optional[str] = ..., - grant_tokens: Optional[List[str]] = ..., - ) -> Optional[Dict[str, Any]]: ... + encryption_context: Mapping[str, Any] | None = ..., + number_of_bytes: int | None = ..., + key_spec: str | None = ..., + grant_tokens: List[str] | None = ..., + ) -> Dict[str, Any] | None: ... def generate_data_key_without_plaintext( self, key_id: str, - encryption_context: Optional[Mapping[str, Any]] = ..., - key_spec: Optional[str] = ..., - number_of_bytes: Optional[int] = ..., - grant_tokens: Optional[List[str]] = ..., - ) -> Optional[Dict[str, Any]]: ... - def generate_random(self, number_of_bytes: Optional[int] = ...) -> Optional[Dict[str, Any]]: ... - def get_key_policy(self, key_id: str, policy_name: str) -> Optional[Dict[str, Any]]: ... - def get_key_rotation_status(self, key_id: str) -> Optional[Dict[str, Any]]: ... - def list_aliases(self, limit: Optional[int] = ..., marker: Optional[str] = ...) -> Optional[Dict[str, Any]]: ... - def list_grants(self, key_id: str, limit: Optional[int] = ..., marker: Optional[str] = ...) -> Optional[Dict[str, Any]]: ... + encryption_context: Mapping[str, Any] | None = ..., + key_spec: str | None = ..., + number_of_bytes: int | None = ..., + grant_tokens: List[str] | None = ..., + ) -> Dict[str, Any] | None: ... + def generate_random(self, number_of_bytes: int | None = ...) -> Dict[str, Any] | None: ... + def get_key_policy(self, key_id: str, policy_name: str) -> Dict[str, Any] | None: ... + def get_key_rotation_status(self, key_id: str) -> Dict[str, Any] | None: ... + def list_aliases(self, limit: int | None = ..., marker: str | None = ...) -> Dict[str, Any] | None: ... + def list_grants(self, key_id: str, limit: int | None = ..., marker: str | None = ...) -> Dict[str, Any] | None: ... def list_key_policies( - self, key_id: str, limit: Optional[int] = ..., marker: Optional[str] = ... - ) -> Optional[Dict[str, Any]]: ... - def list_keys(self, limit: Optional[int] = ..., marker: Optional[str] = ...) -> Optional[Dict[str, Any]]: ... - def put_key_policy(self, key_id: str, policy_name: str, policy: str) -> Optional[Dict[str, Any]]: ... + self, key_id: str, limit: int | None = ..., marker: str | None = ... + ) -> Dict[str, Any] | None: ... + def list_keys(self, limit: int | None = ..., marker: str | None = ...) -> Dict[str, Any] | None: ... + def put_key_policy(self, key_id: str, policy_name: str, policy: str) -> Dict[str, Any] | None: ... def re_encrypt( self, ciphertext_blob: bytes, destination_key_id: str, - source_encryption_context: Optional[Mapping[str, Any]] = ..., - destination_encryption_context: Optional[Mapping[str, Any]] = ..., - grant_tokens: Optional[List[str]] = ..., - ) -> Optional[Dict[str, Any]]: ... - def retire_grant(self, grant_token: str) -> Optional[Dict[str, Any]]: ... - def revoke_grant(self, key_id: str, grant_id: str) -> Optional[Dict[str, Any]]: ... - def update_key_description(self, key_id: str, description: str) -> Optional[Dict[str, Any]]: ... + source_encryption_context: Mapping[str, Any] | None = ..., + destination_encryption_context: Mapping[str, Any] | None = ..., + grant_tokens: List[str] | None = ..., + ) -> Dict[str, Any] | None: ... + def retire_grant(self, grant_token: str) -> Dict[str, Any] | None: ... + def revoke_grant(self, key_id: str, grant_id: str) -> Dict[str, Any] | None: ... + def update_key_description(self, key_id: str, description: str) -> Dict[str, Any] | None: ... diff --git a/stubs/boto/boto/plugin.pyi b/stubs/boto/boto/plugin.pyi index e7d5f1bca7aa..013827641344 100644 --- a/stubs/boto/boto/plugin.pyi +++ b/stubs/boto/boto/plugin.pyi @@ -5,5 +5,5 @@ class Plugin: @classmethod def is_capable(cls, requested_capability): ... -def get_plugin(cls, requested_capability: Optional[Any] = ...): ... +def get_plugin(cls, requested_capability: Any | None = ...): ... def load_plugins(config): ... diff --git a/stubs/boto/boto/regioninfo.pyi b/stubs/boto/boto/regioninfo.pyi index 20322edbc8f1..2270fd3c804f 100644 --- a/stubs/boto/boto/regioninfo.pyi +++ b/stubs/boto/boto/regioninfo.pyi @@ -3,7 +3,7 @@ from typing import Any, Optional def load_endpoint_json(path): ... def merge_endpoints(defaults, additions): ... def load_regions(): ... -def get_regions(service_name, region_cls: Optional[Any] = ..., connection_cls: Optional[Any] = ...): ... +def get_regions(service_name, region_cls: Any | None = ..., connection_cls: Any | None = ...): ... class RegionInfo: connection: Any @@ -12,10 +12,10 @@ class RegionInfo: connection_cls: Any def __init__( self, - connection: Optional[Any] = ..., - name: Optional[Any] = ..., - endpoint: Optional[Any] = ..., - connection_cls: Optional[Any] = ..., + connection: Any | None = ..., + name: Any | None = ..., + endpoint: Any | None = ..., + connection_cls: Any | None = ..., ) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... diff --git a/stubs/boto/boto/s3/__init__.pyi b/stubs/boto/boto/s3/__init__.pyi index 05f4b8ab3ac6..247cc68d5da1 100644 --- a/stubs/boto/boto/s3/__init__.pyi +++ b/stubs/boto/boto/s3/__init__.pyi @@ -8,9 +8,9 @@ from .connection import S3Connection class S3RegionInfo(RegionInfo): def connect( self, - name: Optional[Text] = ..., - endpoint: Optional[str] = ..., - connection_cls: Optional[Type[AWSAuthConnection]] = ..., + name: Text | None = ..., + endpoint: str | None = ..., + connection_cls: Type[AWSAuthConnection] | None = ..., **kw_params, ) -> S3Connection: ... diff --git a/stubs/boto/boto/s3/acl.pyi b/stubs/boto/boto/s3/acl.pyi index 2afabb751bf1..cccaba4daeb4 100644 --- a/stubs/boto/boto/s3/acl.pyi +++ b/stubs/boto/boto/s3/acl.pyi @@ -9,19 +9,19 @@ class Policy: parent: Any namespace: Any acl: ACL - def __init__(self, parent: Optional[Any] = ...) -> None: ... + def __init__(self, parent: Any | None = ...) -> None: ... owner: User - def startElement(self, name: Text, attrs: Dict[str, Any], connection: S3Connection) -> Union[None, User, ACL]: ... + def startElement(self, name: Text, attrs: Dict[str, Any], connection: S3Connection) -> None | User | ACL: ... def endElement(self, name: Text, value: Any, connection: S3Connection) -> None: ... def to_xml(self) -> str: ... class ACL: policy: Policy grants: List[Grant] - def __init__(self, policy: Optional[Policy] = ...) -> None: ... + def __init__(self, policy: Policy | None = ...) -> None: ... def add_grant(self, grant: Grant) -> None: ... def add_email_grant(self, permission: Text, email_address: Text) -> None: ... - def add_user_grant(self, permission: Text, user_id: Text, display_name: Optional[Text] = ...) -> None: ... + def add_user_grant(self, permission: Text, user_id: Text, display_name: Text | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name: Text, value: Any, connection: S3Connection) -> None: ... def to_xml(self) -> str: ... @@ -36,12 +36,12 @@ class Grant: type: Text def __init__( self, - permission: Optional[Text] = ..., - type: Optional[Text] = ..., - id: Optional[Text] = ..., - display_name: Optional[Text] = ..., - uri: Optional[Text] = ..., - email_address: Optional[Text] = ..., + permission: Text | None = ..., + type: Text | None = ..., + id: Text | None = ..., + display_name: Text | None = ..., + uri: Text | None = ..., + email_address: Text | None = ..., ) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name: Text, value: Any, connection: S3Connection) -> None: ... diff --git a/stubs/boto/boto/s3/bucket.pyi b/stubs/boto/boto/s3/bucket.pyi index 7e61cba54a45..413b73aa2dea 100644 --- a/stubs/boto/boto/s3/bucket.pyi +++ b/stubs/boto/boto/s3/bucket.pyi @@ -21,7 +21,7 @@ class Bucket: connection: S3Connection key_class: Type[Key] def __init__( - self, connection: Optional[S3Connection] = ..., name: Optional[Text] = ..., key_class: Type[Key] = ... + self, connection: S3Connection | None = ..., name: Text | None = ..., key_class: Type[Key] = ... ) -> None: ... def __iter__(self): ... def __contains__(self, key_name) -> bool: ... @@ -29,13 +29,13 @@ class Bucket: creation_date: Any def endElement(self, name, value, connection): ... def set_key_class(self, key_class): ... - def lookup(self, key_name, headers: Optional[Dict[Text, Text]] = ...): ... + def lookup(self, key_name, headers: Dict[Text, Text] | None = ...): ... def get_key( self, key_name, - headers: Optional[Dict[Text, Text]] = ..., - version_id: Optional[Any] = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., + version_id: Any | None = ..., + response_headers: Dict[Text, Text] | None = ..., validate: bool = ..., ) -> Key: ... def list( @@ -43,8 +43,8 @@ class Bucket: prefix: Text = ..., delimiter: Text = ..., marker: Text = ..., - headers: Optional[Dict[Text, Text]] = ..., - encoding_type: Optional[Any] = ..., + headers: Dict[Text, Text] | None = ..., + encoding_type: Any | None = ..., ) -> BucketListResultSet: ... def list_versions( self, @@ -52,136 +52,136 @@ class Bucket: delimiter: str = ..., key_marker: str = ..., version_id_marker: str = ..., - headers: Optional[Dict[Text, Text]] = ..., - encoding_type: Optional[Text] = ..., + headers: Dict[Text, Text] | None = ..., + encoding_type: Text | None = ..., ) -> BucketListResultSet: ... def list_multipart_uploads( self, key_marker: str = ..., upload_id_marker: str = ..., - headers: Optional[Dict[Text, Text]] = ..., - encoding_type: Optional[Any] = ..., + headers: Dict[Text, Text] | None = ..., + encoding_type: Any | None = ..., ): ... def validate_kwarg_names(self, kwargs, names): ... - def get_all_keys(self, headers: Optional[Dict[Text, Text]] = ..., **params): ... - def get_all_versions(self, headers: Optional[Dict[Text, Text]] = ..., **params): ... + def get_all_keys(self, headers: Dict[Text, Text] | None = ..., **params): ... + def get_all_versions(self, headers: Dict[Text, Text] | None = ..., **params): ... def validate_get_all_versions_params(self, params): ... - def get_all_multipart_uploads(self, headers: Optional[Dict[Text, Text]] = ..., **params): ... - def new_key(self, key_name: Optional[Any] = ...): ... + def get_all_multipart_uploads(self, headers: Dict[Text, Text] | None = ..., **params): ... + def new_key(self, key_name: Any | None = ...): ... def generate_url( self, expires_in, method: str = ..., - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., force_http: bool = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + response_headers: Dict[Text, Text] | None = ..., expires_in_absolute: bool = ..., ): ... - def delete_keys(self, keys, quiet: bool = ..., mfa_token: Optional[Any] = ..., headers: Optional[Dict[Text, Text]] = ...): ... + def delete_keys(self, keys, quiet: bool = ..., mfa_token: Any | None = ..., headers: Dict[Text, Text] | None = ...): ... def delete_key( - self, key_name, headers: Optional[Dict[Text, Text]] = ..., version_id: Optional[Any] = ..., mfa_token: Optional[Any] = ... + self, key_name, headers: Dict[Text, Text] | None = ..., version_id: Any | None = ..., mfa_token: Any | None = ... ): ... def copy_key( self, new_key_name, src_bucket_name, src_key_name, - metadata: Optional[Any] = ..., - src_version_id: Optional[Any] = ..., + metadata: Any | None = ..., + src_version_id: Any | None = ..., storage_class: str = ..., preserve_acl: bool = ..., encrypt_key: bool = ..., - headers: Optional[Dict[Text, Text]] = ..., - query_args: Optional[Any] = ..., + headers: Dict[Text, Text] | None = ..., + query_args: Any | None = ..., ): ... def set_canned_acl( - self, acl_str, key_name: str = ..., headers: Optional[Dict[Text, Text]] = ..., version_id: Optional[Any] = ... + self, acl_str, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ... ): ... - def get_xml_acl(self, key_name: str = ..., headers: Optional[Dict[Text, Text]] = ..., version_id: Optional[Any] = ...): ... + def get_xml_acl(self, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ...): ... def set_xml_acl( self, acl_str, key_name: str = ..., - headers: Optional[Dict[Text, Text]] = ..., - version_id: Optional[Any] = ..., + headers: Dict[Text, Text] | None = ..., + version_id: Any | None = ..., query_args: str = ..., ): ... def set_acl( - self, acl_or_str, key_name: str = ..., headers: Optional[Dict[Text, Text]] = ..., version_id: Optional[Any] = ... + self, acl_or_str, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ... ): ... - def get_acl(self, key_name: str = ..., headers: Optional[Dict[Text, Text]] = ..., version_id: Optional[Any] = ...): ... + def get_acl(self, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ...): ... def set_subresource( - self, subresource, value, key_name: str = ..., headers: Optional[Dict[Text, Text]] = ..., version_id: Optional[Any] = ... + self, subresource, value, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ... ): ... def get_subresource( - self, subresource, key_name: str = ..., headers: Optional[Dict[Text, Text]] = ..., version_id: Optional[Any] = ... + self, subresource, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ... ): ... - def make_public(self, recursive: bool = ..., headers: Optional[Dict[Text, Text]] = ...): ... - def add_email_grant(self, permission, email_address, recursive: bool = ..., headers: Optional[Dict[Text, Text]] = ...): ... + def make_public(self, recursive: bool = ..., headers: Dict[Text, Text] | None = ...): ... + def add_email_grant(self, permission, email_address, recursive: bool = ..., headers: Dict[Text, Text] | None = ...): ... def add_user_grant( self, permission, user_id, recursive: bool = ..., - headers: Optional[Dict[Text, Text]] = ..., - display_name: Optional[Any] = ..., + headers: Dict[Text, Text] | None = ..., + display_name: Any | None = ..., ): ... - def list_grants(self, headers: Optional[Dict[Text, Text]] = ...): ... + def list_grants(self, headers: Dict[Text, Text] | None = ...): ... def get_location(self): ... - def set_xml_logging(self, logging_str, headers: Optional[Dict[Text, Text]] = ...): ... + def set_xml_logging(self, logging_str, headers: Dict[Text, Text] | None = ...): ... def enable_logging( - self, target_bucket, target_prefix: str = ..., grants: Optional[Any] = ..., headers: Optional[Dict[Text, Text]] = ... + self, target_bucket, target_prefix: str = ..., grants: Any | None = ..., headers: Dict[Text, Text] | None = ... ): ... - def disable_logging(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_logging_status(self, headers: Optional[Dict[Text, Text]] = ...): ... - def set_as_logging_target(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_request_payment(self, headers: Optional[Dict[Text, Text]] = ...): ... - def set_request_payment(self, payer: str = ..., headers: Optional[Dict[Text, Text]] = ...): ... + def disable_logging(self, headers: Dict[Text, Text] | None = ...): ... + def get_logging_status(self, headers: Dict[Text, Text] | None = ...): ... + def set_as_logging_target(self, headers: Dict[Text, Text] | None = ...): ... + def get_request_payment(self, headers: Dict[Text, Text] | None = ...): ... + def set_request_payment(self, payer: str = ..., headers: Dict[Text, Text] | None = ...): ... def configure_versioning( - self, versioning, mfa_delete: bool = ..., mfa_token: Optional[Any] = ..., headers: Optional[Dict[Text, Text]] = ... + self, versioning, mfa_delete: bool = ..., mfa_token: Any | None = ..., headers: Dict[Text, Text] | None = ... ): ... - def get_versioning_status(self, headers: Optional[Dict[Text, Text]] = ...): ... - def configure_lifecycle(self, lifecycle_config, headers: Optional[Dict[Text, Text]] = ...): ... - def get_lifecycle_config(self, headers: Optional[Dict[Text, Text]] = ...): ... - def delete_lifecycle_configuration(self, headers: Optional[Dict[Text, Text]] = ...): ... + def get_versioning_status(self, headers: Dict[Text, Text] | None = ...): ... + def configure_lifecycle(self, lifecycle_config, headers: Dict[Text, Text] | None = ...): ... + def get_lifecycle_config(self, headers: Dict[Text, Text] | None = ...): ... + def delete_lifecycle_configuration(self, headers: Dict[Text, Text] | None = ...): ... def configure_website( self, - suffix: Optional[Any] = ..., - error_key: Optional[Any] = ..., - redirect_all_requests_to: Optional[Any] = ..., - routing_rules: Optional[Any] = ..., - headers: Optional[Dict[Text, Text]] = ..., + suffix: Any | None = ..., + error_key: Any | None = ..., + redirect_all_requests_to: Any | None = ..., + routing_rules: Any | None = ..., + headers: Dict[Text, Text] | None = ..., ): ... - def set_website_configuration(self, config, headers: Optional[Dict[Text, Text]] = ...): ... - def set_website_configuration_xml(self, xml, headers: Optional[Dict[Text, Text]] = ...): ... - def get_website_configuration(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_website_configuration_obj(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_website_configuration_with_xml(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_website_configuration_xml(self, headers: Optional[Dict[Text, Text]] = ...): ... - def delete_website_configuration(self, headers: Optional[Dict[Text, Text]] = ...): ... + def set_website_configuration(self, config, headers: Dict[Text, Text] | None = ...): ... + def set_website_configuration_xml(self, xml, headers: Dict[Text, Text] | None = ...): ... + def get_website_configuration(self, headers: Dict[Text, Text] | None = ...): ... + def get_website_configuration_obj(self, headers: Dict[Text, Text] | None = ...): ... + def get_website_configuration_with_xml(self, headers: Dict[Text, Text] | None = ...): ... + def get_website_configuration_xml(self, headers: Dict[Text, Text] | None = ...): ... + def delete_website_configuration(self, headers: Dict[Text, Text] | None = ...): ... def get_website_endpoint(self): ... - def get_policy(self, headers: Optional[Dict[Text, Text]] = ...): ... - def set_policy(self, policy, headers: Optional[Dict[Text, Text]] = ...): ... - def delete_policy(self, headers: Optional[Dict[Text, Text]] = ...): ... - def set_cors_xml(self, cors_xml, headers: Optional[Dict[Text, Text]] = ...): ... - def set_cors(self, cors_config, headers: Optional[Dict[Text, Text]] = ...): ... - def get_cors_xml(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_cors(self, headers: Optional[Dict[Text, Text]] = ...): ... - def delete_cors(self, headers: Optional[Dict[Text, Text]] = ...): ... + def get_policy(self, headers: Dict[Text, Text] | None = ...): ... + def set_policy(self, policy, headers: Dict[Text, Text] | None = ...): ... + def delete_policy(self, headers: Dict[Text, Text] | None = ...): ... + def set_cors_xml(self, cors_xml, headers: Dict[Text, Text] | None = ...): ... + def set_cors(self, cors_config, headers: Dict[Text, Text] | None = ...): ... + def get_cors_xml(self, headers: Dict[Text, Text] | None = ...): ... + def get_cors(self, headers: Dict[Text, Text] | None = ...): ... + def delete_cors(self, headers: Dict[Text, Text] | None = ...): ... def initiate_multipart_upload( self, key_name, - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., reduced_redundancy: bool = ..., - metadata: Optional[Any] = ..., + metadata: Any | None = ..., encrypt_key: bool = ..., - policy: Optional[Any] = ..., + policy: Any | None = ..., ): ... - def complete_multipart_upload(self, key_name, upload_id, xml_body, headers: Optional[Dict[Text, Text]] = ...): ... - def cancel_multipart_upload(self, key_name, upload_id, headers: Optional[Dict[Text, Text]] = ...): ... - def delete(self, headers: Optional[Dict[Text, Text]] = ...): ... + def complete_multipart_upload(self, key_name, upload_id, xml_body, headers: Dict[Text, Text] | None = ...): ... + def cancel_multipart_upload(self, key_name, upload_id, headers: Dict[Text, Text] | None = ...): ... + def delete(self, headers: Dict[Text, Text] | None = ...): ... def get_tags(self): ... def get_xml_tags(self): ... - def set_xml_tags(self, tag_str, headers: Optional[Dict[Text, Text]] = ..., query_args: str = ...): ... - def set_tags(self, tags, headers: Optional[Dict[Text, Text]] = ...): ... - def delete_tags(self, headers: Optional[Dict[Text, Text]] = ...): ... + def set_xml_tags(self, tag_str, headers: Dict[Text, Text] | None = ..., query_args: str = ...): ... + def set_tags(self, tags, headers: Dict[Text, Text] | None = ...): ... + def delete_tags(self, headers: Dict[Text, Text] | None = ...): ... diff --git a/stubs/boto/boto/s3/bucketlistresultset.pyi b/stubs/boto/boto/s3/bucketlistresultset.pyi index 9a50278a3282..801bf2615f57 100644 --- a/stubs/boto/boto/s3/bucketlistresultset.pyi +++ b/stubs/boto/boto/s3/bucketlistresultset.pyi @@ -7,8 +7,8 @@ def bucket_lister( prefix: str = ..., delimiter: str = ..., marker: str = ..., - headers: Optional[Any] = ..., - encoding_type: Optional[Any] = ..., + headers: Any | None = ..., + encoding_type: Any | None = ..., ): ... class BucketListResultSet(Iterable[Key]): @@ -20,12 +20,12 @@ class BucketListResultSet(Iterable[Key]): encoding_type: Any def __init__( self, - bucket: Optional[Any] = ..., + bucket: Any | None = ..., prefix: str = ..., delimiter: str = ..., marker: str = ..., - headers: Optional[Any] = ..., - encoding_type: Optional[Any] = ..., + headers: Any | None = ..., + encoding_type: Any | None = ..., ) -> None: ... def __iter__(self) -> Iterator[Key]: ... @@ -35,8 +35,8 @@ def versioned_bucket_lister( delimiter: str = ..., key_marker: str = ..., version_id_marker: str = ..., - headers: Optional[Any] = ..., - encoding_type: Optional[Any] = ..., + headers: Any | None = ..., + encoding_type: Any | None = ..., ): ... class VersionedBucketListResultSet: @@ -49,18 +49,18 @@ class VersionedBucketListResultSet: encoding_type: Any def __init__( self, - bucket: Optional[Any] = ..., + bucket: Any | None = ..., prefix: str = ..., delimiter: str = ..., key_marker: str = ..., version_id_marker: str = ..., - headers: Optional[Any] = ..., - encoding_type: Optional[Any] = ..., + headers: Any | None = ..., + encoding_type: Any | None = ..., ) -> None: ... def __iter__(self) -> Iterator[Key]: ... def multipart_upload_lister( - bucket, key_marker: str = ..., upload_id_marker: str = ..., headers: Optional[Any] = ..., encoding_type: Optional[Any] = ... + bucket, key_marker: str = ..., upload_id_marker: str = ..., headers: Any | None = ..., encoding_type: Any | None = ... ): ... class MultiPartUploadListResultSet: @@ -71,10 +71,10 @@ class MultiPartUploadListResultSet: encoding_type: Any def __init__( self, - bucket: Optional[Any] = ..., + bucket: Any | None = ..., key_marker: str = ..., upload_id_marker: str = ..., - headers: Optional[Any] = ..., - encoding_type: Optional[Any] = ..., + headers: Any | None = ..., + encoding_type: Any | None = ..., ) -> None: ... def __iter__(self): ... diff --git a/stubs/boto/boto/s3/bucketlogging.pyi b/stubs/boto/boto/s3/bucketlogging.pyi index 4eaa1abc834d..8c5c6d368c30 100644 --- a/stubs/boto/boto/s3/bucketlogging.pyi +++ b/stubs/boto/boto/s3/bucketlogging.pyi @@ -4,7 +4,7 @@ class BucketLogging: target: Any prefix: Any grants: Any - def __init__(self, target: Optional[Any] = ..., prefix: Optional[Any] = ..., grants: Optional[Any] = ...) -> None: ... + def __init__(self, target: Any | None = ..., prefix: Any | None = ..., grants: Any | None = ...) -> None: ... def add_grant(self, grant): ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... diff --git a/stubs/boto/boto/s3/connection.pyi b/stubs/boto/boto/s3/connection.pyi index 7cb5f7b8e349..3db4349ceb94 100644 --- a/stubs/boto/boto/s3/connection.pyi +++ b/stubs/boto/boto/s3/connection.pyi @@ -52,26 +52,26 @@ class S3Connection(AWSAuthConnection): anon: Any def __init__( self, - aws_access_key_id: Optional[Any] = ..., - aws_secret_access_key: Optional[Any] = ..., + aws_access_key_id: Any | None = ..., + aws_secret_access_key: Any | None = ..., is_secure: bool = ..., - port: Optional[Any] = ..., - proxy: Optional[Any] = ..., - proxy_port: Optional[Any] = ..., - proxy_user: Optional[Any] = ..., - proxy_pass: Optional[Any] = ..., + port: Any | None = ..., + proxy: Any | None = ..., + proxy_port: Any | None = ..., + proxy_user: Any | None = ..., + proxy_pass: Any | None = ..., host: Any = ..., debug: int = ..., - https_connection_factory: Optional[Any] = ..., + https_connection_factory: Any | None = ..., calling_format: Any = ..., path: str = ..., provider: str = ..., bucket_class: Type[Bucket] = ..., - security_token: Optional[Any] = ..., + security_token: Any | None = ..., suppress_consec_slashes: bool = ..., anon: bool = ..., - validate_certs: Optional[Any] = ..., - profile_name: Optional[Any] = ..., + validate_certs: Any | None = ..., + profile_name: Any | None = ..., ) -> None: ... def __iter__(self): ... def __contains__(self, bucket_name): ... @@ -82,14 +82,14 @@ class S3Connection(AWSAuthConnection): bucket_name, key, expires_in: int = ..., - acl: Optional[Any] = ..., - success_action_redirect: Optional[Any] = ..., - max_content_length: Optional[Any] = ..., + acl: Any | None = ..., + success_action_redirect: Any | None = ..., + max_content_length: Any | None = ..., http_method: str = ..., - fields: Optional[Any] = ..., - conditions: Optional[Any] = ..., + fields: Any | None = ..., + conditions: Any | None = ..., storage_class: str = ..., - server_side_encryption: Optional[Any] = ..., + server_side_encryption: Any | None = ..., ): ... def generate_url_sigv4( self, @@ -97,11 +97,11 @@ class S3Connection(AWSAuthConnection): method, bucket: str = ..., key: str = ..., - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., force_http: bool = ..., - response_headers: Optional[Dict[Text, Text]] = ..., - version_id: Optional[Any] = ..., - iso_date: Optional[Any] = ..., + response_headers: Dict[Text, Text] | None = ..., + version_id: Any | None = ..., + iso_date: Any | None = ..., ): ... def generate_url( self, @@ -109,20 +109,20 @@ class S3Connection(AWSAuthConnection): method, bucket: str = ..., key: str = ..., - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., query_auth: bool = ..., force_http: bool = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + response_headers: Dict[Text, Text] | None = ..., expires_in_absolute: bool = ..., - version_id: Optional[Any] = ..., + version_id: Any | None = ..., ): ... - def get_all_buckets(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_canonical_user_id(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_bucket(self, bucket_name: Text, validate: bool = ..., headers: Optional[Dict[Text, Text]] = ...) -> Bucket: ... - def head_bucket(self, bucket_name, headers: Optional[Dict[Text, Text]] = ...): ... - def lookup(self, bucket_name, validate: bool = ..., headers: Optional[Dict[Text, Text]] = ...): ... + def get_all_buckets(self, headers: Dict[Text, Text] | None = ...): ... + def get_canonical_user_id(self, headers: Dict[Text, Text] | None = ...): ... + def get_bucket(self, bucket_name: Text, validate: bool = ..., headers: Dict[Text, Text] | None = ...) -> Bucket: ... + def head_bucket(self, bucket_name, headers: Dict[Text, Text] | None = ...): ... + def lookup(self, bucket_name, validate: bool = ..., headers: Dict[Text, Text] | None = ...): ... def create_bucket( - self, bucket_name, headers: Optional[Dict[Text, Text]] = ..., location: Any = ..., policy: Optional[Any] = ... + self, bucket_name, headers: Dict[Text, Text] | None = ..., location: Any = ..., policy: Any | None = ... ): ... - def delete_bucket(self, bucket, headers: Optional[Dict[Text, Text]] = ...): ... - def make_request(self, method, bucket: str = ..., key: str = ..., headers: Optional[Any] = ..., data: str = ..., query_args: Optional[Any] = ..., sender: Optional[Any] = ..., override_num_retries: Optional[Any] = ..., retry_handler: Optional[Any] = ..., *args, **kwargs): ... # type: ignore # https://github.com/python/mypy/issues/1237 + def delete_bucket(self, bucket, headers: Dict[Text, Text] | None = ...): ... + def make_request(self, method, bucket: str = ..., key: str = ..., headers: Any | None = ..., data: str = ..., query_args: Any | None = ..., sender: Any | None = ..., override_num_retries: Any | None = ..., retry_handler: Any | None = ..., *args, **kwargs): ... # type: ignore # https://github.com/python/mypy/issues/1237 diff --git a/stubs/boto/boto/s3/cors.pyi b/stubs/boto/boto/s3/cors.pyi index 45fe04a642e8..9fd8d8cafc4c 100644 --- a/stubs/boto/boto/s3/cors.pyi +++ b/stubs/boto/boto/s3/cors.pyi @@ -9,12 +9,12 @@ class CORSRule: expose_header: Any def __init__( self, - allowed_method: Optional[Any] = ..., - allowed_origin: Optional[Any] = ..., - id: Optional[Any] = ..., - allowed_header: Optional[Any] = ..., - max_age_seconds: Optional[Any] = ..., - expose_header: Optional[Any] = ..., + allowed_method: Any | None = ..., + allowed_origin: Any | None = ..., + id: Any | None = ..., + allowed_header: Any | None = ..., + max_age_seconds: Any | None = ..., + expose_header: Any | None = ..., ) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -28,8 +28,8 @@ class CORSConfiguration(List[CORSRule]): self, allowed_method, allowed_origin, - id: Optional[Any] = ..., - allowed_header: Optional[Any] = ..., - max_age_seconds: Optional[Any] = ..., - expose_header: Optional[Any] = ..., + id: Any | None = ..., + allowed_header: Any | None = ..., + max_age_seconds: Any | None = ..., + expose_header: Any | None = ..., ): ... diff --git a/stubs/boto/boto/s3/deletemarker.pyi b/stubs/boto/boto/s3/deletemarker.pyi index b2955c01398c..59d6748f743d 100644 --- a/stubs/boto/boto/s3/deletemarker.pyi +++ b/stubs/boto/boto/s3/deletemarker.pyi @@ -7,6 +7,6 @@ class DeleteMarker: is_latest: bool last_modified: Any owner: Any - def __init__(self, bucket: Optional[Any] = ..., name: Optional[Any] = ...) -> None: ... + def __init__(self, bucket: Any | None = ..., name: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... diff --git a/stubs/boto/boto/s3/key.pyi b/stubs/boto/boto/s3/key.pyi index 179b49479293..7537f48f6842 100644 --- a/stubs/boto/boto/s3/key.pyi +++ b/stubs/boto/boto/s3/key.pyi @@ -30,7 +30,7 @@ class Key: ongoing_restore: Any expiry_date: Any local_hashes: Any - def __init__(self, bucket: Optional[Any] = ..., name: Optional[Any] = ...) -> None: ... + def __init__(self, bucket: Any | None = ..., name: Any | None = ...) -> None: ... def __iter__(self): ... @property def provider(self): ... @@ -45,30 +45,30 @@ class Key: def handle_addl_headers(self, headers): ... def open_read( self, - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., query_args: str = ..., - override_num_retries: Optional[Any] = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + override_num_retries: Any | None = ..., + response_headers: Dict[Text, Text] | None = ..., ): ... - def open_write(self, headers: Optional[Dict[Text, Text]] = ..., override_num_retries: Optional[Any] = ...): ... + def open_write(self, headers: Dict[Text, Text] | None = ..., override_num_retries: Any | None = ...): ... def open( self, mode: str = ..., - headers: Optional[Dict[Text, Text]] = ..., - query_args: Optional[Any] = ..., - override_num_retries: Optional[Any] = ..., + headers: Dict[Text, Text] | None = ..., + query_args: Any | None = ..., + override_num_retries: Any | None = ..., ): ... closed: bool def close(self, fast: bool = ...): ... def next(self): ... __next__: Any def read(self, size: int = ...): ... - def change_storage_class(self, new_storage_class, dst_bucket: Optional[Any] = ..., validate_dst_bucket: bool = ...): ... + def change_storage_class(self, new_storage_class, dst_bucket: Any | None = ..., validate_dst_bucket: bool = ...): ... def copy( self, dst_bucket, dst_key, - metadata: Optional[Any] = ..., + metadata: Any | None = ..., reduced_redundancy: bool = ..., preserve_acl: bool = ..., encrypt_key: bool = ..., @@ -76,158 +76,158 @@ class Key: ): ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... - def exists(self, headers: Optional[Dict[Text, Text]] = ...): ... - def delete(self, headers: Optional[Dict[Text, Text]] = ...): ... + def exists(self, headers: Dict[Text, Text] | None = ...): ... + def delete(self, headers: Dict[Text, Text] | None = ...): ... def get_metadata(self, name): ... def set_metadata(self, name, value): ... def update_metadata(self, d): ... - def set_acl(self, acl_str, headers: Optional[Dict[Text, Text]] = ...): ... - def get_acl(self, headers: Optional[Dict[Text, Text]] = ...): ... - def get_xml_acl(self, headers: Optional[Dict[Text, Text]] = ...): ... - def set_xml_acl(self, acl_str, headers: Optional[Dict[Text, Text]] = ...): ... - def set_canned_acl(self, acl_str, headers: Optional[Dict[Text, Text]] = ...): ... + def set_acl(self, acl_str, headers: Dict[Text, Text] | None = ...): ... + def get_acl(self, headers: Dict[Text, Text] | None = ...): ... + def get_xml_acl(self, headers: Dict[Text, Text] | None = ...): ... + def set_xml_acl(self, acl_str, headers: Dict[Text, Text] | None = ...): ... + def set_canned_acl(self, acl_str, headers: Dict[Text, Text] | None = ...): ... def get_redirect(self): ... - def set_redirect(self, redirect_location, headers: Optional[Dict[Text, Text]] = ...): ... - def make_public(self, headers: Optional[Dict[Text, Text]] = ...): ... + def set_redirect(self, redirect_location, headers: Dict[Text, Text] | None = ...): ... + def make_public(self, headers: Dict[Text, Text] | None = ...): ... def generate_url( self, expires_in, method: str = ..., - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., query_auth: bool = ..., force_http: bool = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + response_headers: Dict[Text, Text] | None = ..., expires_in_absolute: bool = ..., - version_id: Optional[Any] = ..., - policy: Optional[Any] = ..., + version_id: Any | None = ..., + policy: Any | None = ..., reduced_redundancy: bool = ..., encrypt_key: bool = ..., ): ... def send_file( self, fp, - headers: Optional[Dict[Text, Text]] = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + headers: Dict[Text, Text] | None = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., - query_args: Optional[Any] = ..., + query_args: Any | None = ..., chunked_transfer: bool = ..., - size: Optional[Any] = ..., + size: Any | None = ..., ): ... def should_retry(self, response, chunked_transfer: bool = ...): ... - def compute_md5(self, fp, size: Optional[Any] = ...): ... + def compute_md5(self, fp, size: Any | None = ...): ... def set_contents_from_stream( self, fp, - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., replace: bool = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., - policy: Optional[Any] = ..., + policy: Any | None = ..., reduced_redundancy: bool = ..., - query_args: Optional[Any] = ..., - size: Optional[Any] = ..., + query_args: Any | None = ..., + size: Any | None = ..., ): ... def set_contents_from_file( self, fp, - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., replace: bool = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., - policy: Optional[Any] = ..., - md5: Optional[Any] = ..., + policy: Any | None = ..., + md5: Any | None = ..., reduced_redundancy: bool = ..., - query_args: Optional[Any] = ..., + query_args: Any | None = ..., encrypt_key: bool = ..., - size: Optional[Any] = ..., + size: Any | None = ..., rewind: bool = ..., ): ... def set_contents_from_filename( self, filename, - headers: Optional[Dict[Text, Text]] = ..., + headers: Dict[Text, Text] | None = ..., replace: bool = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., - policy: Optional[Any] = ..., - md5: Optional[Any] = ..., + policy: Any | None = ..., + md5: Any | None = ..., reduced_redundancy: bool = ..., encrypt_key: bool = ..., ): ... def set_contents_from_string( self, - string_data: Union[Text, bytes], - headers: Optional[Dict[Text, Text]] = ..., + string_data: Text | bytes, + headers: Dict[Text, Text] | None = ..., replace: bool = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., - policy: Optional[Any] = ..., - md5: Optional[Any] = ..., + policy: Any | None = ..., + md5: Any | None = ..., reduced_redundancy: bool = ..., encrypt_key: bool = ..., ) -> None: ... def get_file( self, fp, - headers: Optional[Dict[Text, Text]] = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + headers: Dict[Text, Text] | None = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., torrent: bool = ..., - version_id: Optional[Any] = ..., - override_num_retries: Optional[Any] = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + version_id: Any | None = ..., + override_num_retries: Any | None = ..., + response_headers: Dict[Text, Text] | None = ..., ): ... def get_torrent_file( - self, fp, headers: Optional[Dict[Text, Text]] = ..., cb: Optional[Callable[[int, int], Any]] = ..., num_cb: int = ... + self, fp, headers: Dict[Text, Text] | None = ..., cb: Callable[[int, int], Any] | None = ..., num_cb: int = ... ): ... def get_contents_to_file( self, fp, - headers: Optional[Dict[Text, Text]] = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + headers: Dict[Text, Text] | None = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., torrent: bool = ..., - version_id: Optional[Any] = ..., - res_download_handler: Optional[Any] = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + version_id: Any | None = ..., + res_download_handler: Any | None = ..., + response_headers: Dict[Text, Text] | None = ..., ): ... def get_contents_to_filename( self, filename, - headers: Optional[Dict[Text, Text]] = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + headers: Dict[Text, Text] | None = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., torrent: bool = ..., - version_id: Optional[Any] = ..., - res_download_handler: Optional[Any] = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + version_id: Any | None = ..., + res_download_handler: Any | None = ..., + response_headers: Dict[Text, Text] | None = ..., ): ... @overload def get_contents_as_string( self, - headers: Optional[Dict[Text, Text]] = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + headers: Dict[Text, Text] | None = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., torrent: bool = ..., - version_id: Optional[Any] = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + version_id: Any | None = ..., + response_headers: Dict[Text, Text] | None = ..., encoding: None = ..., ) -> bytes: ... @overload def get_contents_as_string( self, - headers: Optional[Dict[Text, Text]] = ..., - cb: Optional[Callable[[int, int], Any]] = ..., + headers: Dict[Text, Text] | None = ..., + cb: Callable[[int, int], Any] | None = ..., num_cb: int = ..., torrent: bool = ..., - version_id: Optional[Any] = ..., - response_headers: Optional[Dict[Text, Text]] = ..., + version_id: Any | None = ..., + response_headers: Dict[Text, Text] | None = ..., *, encoding: Text, ) -> Text: ... - def add_email_grant(self, permission, email_address, headers: Optional[Dict[Text, Text]] = ...): ... + def add_email_grant(self, permission, email_address, headers: Dict[Text, Text] | None = ...): ... def add_user_grant( - self, permission, user_id, headers: Optional[Dict[Text, Text]] = ..., display_name: Optional[Any] = ... + self, permission, user_id, headers: Dict[Text, Text] | None = ..., display_name: Any | None = ... ): ... - def set_remote_metadata(self, metadata_plus, metadata_minus, preserve_acl, headers: Optional[Dict[Text, Text]] = ...): ... - def restore(self, days, headers: Optional[Dict[Text, Text]] = ...): ... + def set_remote_metadata(self, metadata_plus, metadata_minus, preserve_acl, headers: Dict[Text, Text] | None = ...): ... + def restore(self, days, headers: Dict[Text, Text] | None = ...): ... diff --git a/stubs/boto/boto/s3/lifecycle.pyi b/stubs/boto/boto/s3/lifecycle.pyi index f34c112ed012..4ccc9fd41c20 100644 --- a/stubs/boto/boto/s3/lifecycle.pyi +++ b/stubs/boto/boto/s3/lifecycle.pyi @@ -8,11 +8,11 @@ class Rule: transition: Any def __init__( self, - id: Optional[Any] = ..., - prefix: Optional[Any] = ..., - status: Optional[Any] = ..., - expiration: Optional[Any] = ..., - transition: Optional[Any] = ..., + id: Any | None = ..., + prefix: Any | None = ..., + status: Any | None = ..., + expiration: Any | None = ..., + transition: Any | None = ..., ) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -21,7 +21,7 @@ class Rule: class Expiration: days: Any date: Any - def __init__(self, days: Optional[Any] = ..., date: Optional[Any] = ...) -> None: ... + def __init__(self, days: Any | None = ..., date: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... @@ -30,7 +30,7 @@ class Transition: days: Any date: Any storage_class: Any - def __init__(self, days: Optional[Any] = ..., date: Optional[Any] = ..., storage_class: Optional[Any] = ...) -> None: ... + def __init__(self, days: Any | None = ..., date: Any | None = ..., storage_class: Any | None = ...) -> None: ... def to_xml(self): ... class Transitions(List[Transition]): @@ -43,7 +43,7 @@ class Transitions(List[Transition]): def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... - def add_transition(self, days: Optional[Any] = ..., date: Optional[Any] = ..., storage_class: Optional[Any] = ...): ... + def add_transition(self, days: Any | None = ..., date: Any | None = ..., storage_class: Any | None = ...): ... @property def days(self): ... @property @@ -57,9 +57,9 @@ class Lifecycle(List[Rule]): def to_xml(self): ... def add_rule( self, - id: Optional[Any] = ..., + id: Any | None = ..., prefix: str = ..., status: str = ..., - expiration: Optional[Any] = ..., - transition: Optional[Any] = ..., + expiration: Any | None = ..., + transition: Any | None = ..., ): ... diff --git a/stubs/boto/boto/s3/multidelete.pyi b/stubs/boto/boto/s3/multidelete.pyi index b7f91651b0da..a72f2d359575 100644 --- a/stubs/boto/boto/s3/multidelete.pyi +++ b/stubs/boto/boto/s3/multidelete.pyi @@ -7,10 +7,10 @@ class Deleted: delete_marker_version_id: Any def __init__( self, - key: Optional[Any] = ..., - version_id: Optional[Any] = ..., + key: Any | None = ..., + version_id: Any | None = ..., delete_marker: bool = ..., - delete_marker_version_id: Optional[Any] = ..., + delete_marker_version_id: Any | None = ..., ) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -21,7 +21,7 @@ class Error: code: Any message: Any def __init__( - self, key: Optional[Any] = ..., version_id: Optional[Any] = ..., code: Optional[Any] = ..., message: Optional[Any] = ... + self, key: Any | None = ..., version_id: Any | None = ..., code: Any | None = ..., message: Any | None = ... ) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -30,6 +30,6 @@ class MultiDeleteResult: bucket: Any deleted: Any errors: Any - def __init__(self, bucket: Optional[Any] = ...) -> None: ... + def __init__(self, bucket: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... diff --git a/stubs/boto/boto/s3/multipart.pyi b/stubs/boto/boto/s3/multipart.pyi index f7dd85d43b61..4fcb84b937ca 100644 --- a/stubs/boto/boto/s3/multipart.pyi +++ b/stubs/boto/boto/s3/multipart.pyi @@ -8,7 +8,7 @@ class CompleteMultiPartUpload: etag: Any version_id: Any encrypted: Any - def __init__(self, bucket: Optional[Any] = ...) -> None: ... + def __init__(self, bucket: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -18,11 +18,11 @@ class Part: last_modified: Any etag: Any size: Any - def __init__(self, bucket: Optional[Any] = ...) -> None: ... + def __init__(self, bucket: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... -def part_lister(mpupload, part_number_marker: Optional[Any] = ...): ... +def part_lister(mpupload, part_number_marker: Any | None = ...): ... class MultiPartUpload: bucket: Any @@ -37,34 +37,34 @@ class MultiPartUpload: next_part_number_marker: Any max_parts: Any is_truncated: bool - def __init__(self, bucket: Optional[Any] = ...) -> None: ... + def __init__(self, bucket: Any | None = ...) -> None: ... def __iter__(self): ... def to_xml(self): ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def get_all_parts( - self, max_parts: Optional[Any] = ..., part_number_marker: Optional[Any] = ..., encoding_type: Optional[Any] = ... + self, max_parts: Any | None = ..., part_number_marker: Any | None = ..., encoding_type: Any | None = ... ): ... def upload_part_from_file( self, fp, part_num, - headers: Optional[Any] = ..., + headers: Any | None = ..., replace: bool = ..., - cb: Optional[Any] = ..., + cb: Any | None = ..., num_cb: int = ..., - md5: Optional[Any] = ..., - size: Optional[Any] = ..., + md5: Any | None = ..., + size: Any | None = ..., ): ... def copy_part_from_key( self, src_bucket_name, src_key_name, part_num, - start: Optional[Any] = ..., - end: Optional[Any] = ..., - src_version_id: Optional[Any] = ..., - headers: Optional[Any] = ..., + start: Any | None = ..., + end: Any | None = ..., + src_version_id: Any | None = ..., + headers: Any | None = ..., ): ... def complete_upload(self): ... def cancel_upload(self): ... diff --git a/stubs/boto/boto/s3/prefix.pyi b/stubs/boto/boto/s3/prefix.pyi index de8f3a34d500..f3596b9832e3 100644 --- a/stubs/boto/boto/s3/prefix.pyi +++ b/stubs/boto/boto/s3/prefix.pyi @@ -3,7 +3,7 @@ from typing import Any, Optional class Prefix: bucket: Any name: Any - def __init__(self, bucket: Optional[Any] = ..., name: Optional[Any] = ...) -> None: ... + def __init__(self, bucket: Any | None = ..., name: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @property diff --git a/stubs/boto/boto/s3/tagging.pyi b/stubs/boto/boto/s3/tagging.pyi index 15553e7c7853..c751e4b6a1e6 100644 --- a/stubs/boto/boto/s3/tagging.pyi +++ b/stubs/boto/boto/s3/tagging.pyi @@ -3,7 +3,7 @@ from typing import Any, List, Optional class Tag: key: Any value: Any - def __init__(self, key: Optional[Any] = ..., value: Optional[Any] = ...) -> None: ... + def __init__(self, key: Any | None = ..., value: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... diff --git a/stubs/boto/boto/s3/user.pyi b/stubs/boto/boto/s3/user.pyi index c5cc11c617b2..ef4ca26287e0 100644 --- a/stubs/boto/boto/s3/user.pyi +++ b/stubs/boto/boto/s3/user.pyi @@ -4,7 +4,7 @@ class User: type: Any id: Any display_name: Any - def __init__(self, parent: Optional[Any] = ..., id: str = ..., display_name: str = ...) -> None: ... + def __init__(self, parent: Any | None = ..., id: str = ..., display_name: str = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self, element_name: str = ...): ... diff --git a/stubs/boto/boto/s3/website.pyi b/stubs/boto/boto/s3/website.pyi index ef871f03593a..5c67f0b6690e 100644 --- a/stubs/boto/boto/s3/website.pyi +++ b/stubs/boto/boto/s3/website.pyi @@ -9,10 +9,10 @@ class WebsiteConfiguration: routing_rules: Any def __init__( self, - suffix: Optional[Any] = ..., - error_key: Optional[Any] = ..., - redirect_all_requests_to: Optional[Any] = ..., - routing_rules: Optional[Any] = ..., + suffix: Any | None = ..., + error_key: Any | None = ..., + redirect_all_requests_to: Any | None = ..., + routing_rules: Any | None = ..., ) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... @@ -21,7 +21,7 @@ class WebsiteConfiguration: class _XMLKeyValue: translator: Any container: Any - def __init__(self, translator, container: Optional[Any] = ...) -> None: ... + def __init__(self, translator, container: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... @@ -30,7 +30,7 @@ class RedirectLocation(_XMLKeyValue): TRANSLATOR: Any hostname: Any protocol: Any - def __init__(self, hostname: Optional[Any] = ..., protocol: Optional[Any] = ...) -> None: ... + def __init__(self, hostname: Any | None = ..., protocol: Any | None = ...) -> None: ... def to_xml(self): ... class RoutingRules(List[RoutingRule]): @@ -42,26 +42,26 @@ class RoutingRules(List[RoutingRule]): class RoutingRule: condition: Any redirect: Any - def __init__(self, condition: Optional[Any] = ..., redirect: Optional[Any] = ...) -> None: ... + def __init__(self, condition: Any | None = ..., redirect: Any | None = ...) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... def to_xml(self): ... @classmethod - def when(cls, key_prefix: Optional[Any] = ..., http_error_code: Optional[Any] = ...): ... + def when(cls, key_prefix: Any | None = ..., http_error_code: Any | None = ...): ... def then_redirect( self, - hostname: Optional[Any] = ..., - protocol: Optional[Any] = ..., - replace_key: Optional[Any] = ..., - replace_key_prefix: Optional[Any] = ..., - http_redirect_code: Optional[Any] = ..., + hostname: Any | None = ..., + protocol: Any | None = ..., + replace_key: Any | None = ..., + replace_key_prefix: Any | None = ..., + http_redirect_code: Any | None = ..., ): ... class Condition(_XMLKeyValue): TRANSLATOR: Any key_prefix: Any http_error_code: Any - def __init__(self, key_prefix: Optional[Any] = ..., http_error_code: Optional[Any] = ...) -> None: ... + def __init__(self, key_prefix: Any | None = ..., http_error_code: Any | None = ...) -> None: ... def to_xml(self): ... class Redirect(_XMLKeyValue): @@ -73,10 +73,10 @@ class Redirect(_XMLKeyValue): http_redirect_code: Any def __init__( self, - hostname: Optional[Any] = ..., - protocol: Optional[Any] = ..., - replace_key: Optional[Any] = ..., - replace_key_prefix: Optional[Any] = ..., - http_redirect_code: Optional[Any] = ..., + hostname: Any | None = ..., + protocol: Any | None = ..., + replace_key: Any | None = ..., + replace_key_prefix: Any | None = ..., + http_redirect_code: Any | None = ..., ) -> None: ... def to_xml(self): ... diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index c32370ad9250..58256034a8ee 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -55,31 +55,31 @@ _LockType = Any # TODO replace this with _thread.LockType once stubs exist JSONDecodeError: Type[ValueError] qsa_of_interest: List[str] -def unquote_v(nv: str) -> Union[str, Tuple[str, str]]: ... +def unquote_v(nv: str) -> str | Tuple[str, str]: ... def canonical_string( method: str, path: str, - headers: Mapping[str, Optional[str]], - expires: Optional[int] = ..., - provider: Optional[_Provider] = ..., + headers: Mapping[str, str | None], + expires: int | None = ..., + provider: _Provider | None = ..., ) -> str: ... def merge_meta( - headers: Mapping[str, str], metadata: Mapping[str, str], provider: Optional[_Provider] = ... + headers: Mapping[str, str], metadata: Mapping[str, str], provider: _Provider | None = ... ) -> Mapping[str, str]: ... -def get_aws_metadata(headers: Mapping[str, str], provider: Optional[_Provider] = ...) -> Mapping[str, str]: ... -def retry_url(url: str, retry_on_404: bool = ..., num_retries: int = ..., timeout: Optional[int] = ...) -> str: ... +def get_aws_metadata(headers: Mapping[str, str], provider: _Provider | None = ...) -> Mapping[str, str]: ... +def retry_url(url: str, retry_on_404: bool = ..., num_retries: int = ..., timeout: int | None = ...) -> str: ... class LazyLoadMetadata(Dict[_KT, _VT]): - def __init__(self, url: str, num_retries: int, timeout: Optional[int] = ...) -> None: ... + def __init__(self, url: str, num_retries: int, timeout: int | None = ...) -> None: ... def get_instance_metadata( - version: str = ..., url: str = ..., data: str = ..., timeout: Optional[int] = ..., num_retries: int = ... -) -> Optional[LazyLoadMetadata[Any, Any]]: ... + version: str = ..., url: str = ..., data: str = ..., timeout: int | None = ..., num_retries: int = ... +) -> LazyLoadMetadata[Any, Any] | None: ... def get_instance_identity( - version: str = ..., url: str = ..., timeout: Optional[int] = ..., num_retries: int = ... -) -> Optional[Mapping[str, Any]]: ... + version: str = ..., url: str = ..., timeout: int | None = ..., num_retries: int = ... +) -> Mapping[str, Any] | None: ... def get_instance_userdata( - version: str = ..., sep: Optional[str] = ..., url: str = ..., timeout: Optional[int] = ..., num_retries: int = ... + version: str = ..., sep: str | None = ..., url: str = ..., timeout: int | None = ..., num_retries: int = ... ) -> Mapping[str, str]: ... ISO8601: str @@ -87,14 +87,14 @@ ISO8601_MS: str RFC1123: str LOCALE_LOCK: _LockType -def setlocale(name: Union[str, Tuple[str, str]]) -> ContextManager[str]: ... -def get_ts(ts: Optional[time.struct_time] = ...) -> str: ... +def setlocale(name: str | Tuple[str, str]) -> ContextManager[str]: ... +def get_ts(ts: time.struct_time | None = ...) -> str: ... def parse_ts(ts: str) -> datetime.datetime: ... -def find_class(module_name: str, class_name: Optional[str] = ...) -> Optional[Type[Any]]: ... +def find_class(module_name: str, class_name: str | None = ...) -> Type[Any] | None: ... def update_dme(username: str, password: str, dme_id: str, ip_address: str) -> str: ... def fetch_file( - uri: str, file: Optional[IO[str]] = ..., username: Optional[str] = ..., password: Optional[str] = ... -) -> Optional[IO[str]]: ... + uri: str, file: IO[str] | None = ..., username: str | None = ..., password: str | None = ... +) -> IO[str] | None: ... class ShellCommand: exit_code: int @@ -103,13 +103,13 @@ class ShellCommand: wait: bool fail_fast: bool def __init__( - self, command: subprocess._CMD, wait: bool = ..., fail_fast: bool = ..., cwd: Optional[subprocess._TXT] = ... + self, command: subprocess._CMD, wait: bool = ..., fail_fast: bool = ..., cwd: subprocess._TXT | None = ... ) -> None: ... process: subprocess.Popen[Any] - def run(self, cwd: Optional[subprocess._CMD] = ...) -> Optional[int]: ... + def run(self, cwd: subprocess._CMD | None = ...) -> int | None: ... def setReadOnly(self, value) -> None: ... - def getStatus(self) -> Optional[int]: ... - status: Optional[int] + def getStatus(self) -> int | None: ... + status: int | None def getOutput(self) -> str: ... output: str @@ -122,15 +122,15 @@ class AuthSMTPHandler(logging.handlers.SMTPHandler): class LRUCache(Dict[_KT, _VT]): class _Item: - previous: Optional[LRUCache._Item] - next: Optional[LRUCache._Item] + previous: LRUCache._Item | None + next: LRUCache._Item | None key = ... value = ... def __init__(self, key, value) -> None: ... _dict: Dict[_KT, LRUCache._Item] capacity: int - head: Optional[LRUCache._Item] - tail: Optional[LRUCache._Item] + head: LRUCache._Item | None + tail: LRUCache._Item | None def __init__(self, capacity: int) -> None: ... # This exists to work around Password.str's name shadowing the str type @@ -138,18 +138,18 @@ _str = str class Password: hashfunc: Callable[[bytes], _HashType] - str: Optional[_str] - def __init__(self, str: Optional[_str] = ..., hashfunc: Optional[Callable[[bytes], _HashType]] = ...) -> None: ... - def set(self, value: Union[bytes, _str]) -> None: ... + str: _str | None + def __init__(self, str: _str | None = ..., hashfunc: Callable[[bytes], _HashType] | None = ...) -> None: ... + def set(self, value: bytes | _str) -> None: ... def __eq__(self, other: Any) -> bool: ... def __len__(self) -> int: ... def notify( subject: str, - body: Optional[str] = ..., - html_body: Optional[Union[Sequence[str], str]] = ..., - to_string: Optional[str] = ..., - attachments: Optional[Iterable[_Message]] = ..., + body: str | None = ..., + html_body: Sequence[str] | str | None = ..., + to_string: str | None = ..., + attachments: Iterable[_Message] | None = ..., append_instance_id: bool = ..., ) -> None: ... def get_utf8_value(value: str) -> bytes: ... @@ -159,12 +159,12 @@ def write_mime_multipart( content: List[Tuple[str, str]], compress: bool = ..., deftype: str = ..., delimiter: str = ... ) -> str: ... def guess_mime_type(content: str, deftype: str) -> str: ... -def compute_md5(fp: IO[Any], buf_size: int = ..., size: Optional[int] = ...) -> Tuple[str, str, int]: ... +def compute_md5(fp: IO[Any], buf_size: int = ..., size: int | None = ...) -> Tuple[str, str, int]: ... def compute_hash( - fp: IO[Any], buf_size: int = ..., size: Optional[int] = ..., hash_algorithm: Any = ... + fp: IO[Any], buf_size: int = ..., size: int | None = ..., hash_algorithm: Any = ... ) -> Tuple[str, str, int]: ... -def find_matching_headers(name: str, headers: Mapping[str, Optional[str]]) -> List[str]: ... -def merge_headers_by_name(name: str, headers: Mapping[str, Optional[str]]) -> str: ... +def find_matching_headers(name: str, headers: Mapping[str, str | None]) -> List[str]: ... +def merge_headers_by_name(name: str, headers: Mapping[str, str | None]) -> str: ... class RequestHook: def handle_request_data( diff --git a/stubs/cachetools/cachetools/cache.pyi b/stubs/cachetools/cachetools/cache.pyi index fe13a5e387d7..1bb565aaab80 100644 --- a/stubs/cachetools/cachetools/cache.pyi +++ b/stubs/cachetools/cachetools/cache.pyi @@ -6,7 +6,7 @@ _KT = TypeVar("_KT") _VT = TypeVar("_VT") class Cache(DefaultMapping[_KT, _VT], Generic[_KT, _VT]): - def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> None: ... + def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ... def __getitem__(self, key: _KT) -> _VT: ... def __setitem__(self, key: _KT, value: _VT) -> None: ... def __delitem__(self, key: _KT) -> None: ... diff --git a/stubs/cachetools/cachetools/decorators.pyi b/stubs/cachetools/cachetools/decorators.pyi index 4a89b58888c6..a7ecc9f5b9a0 100644 --- a/stubs/cachetools/cachetools/decorators.pyi +++ b/stubs/cachetools/cachetools/decorators.pyi @@ -4,10 +4,10 @@ from typing import Any, Callable, ContextManager, MutableMapping, Optional, Type _KT = TypeVar("_KT") def cached( - cache: Optional[MutableMapping[_KT, Any]], key: Callable[..., _KT] = ..., lock: Optional[ContextManager[Any]] = ... + cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ... ) -> IdentityFunction: ... def cachedmethod( - cache: Callable[[Any], Optional[MutableMapping[_KT, Any]]], + cache: Callable[[Any], MutableMapping[_KT, Any] | None], key: Callable[..., _KT] = ..., - lock: Optional[ContextManager[Any]] = ..., + lock: ContextManager[Any] | None = ..., ) -> IdentityFunction: ... diff --git a/stubs/cachetools/cachetools/func.pyi b/stubs/cachetools/cachetools/func.pyi index 87dfbd12bca5..b0e568f3b9dd 100644 --- a/stubs/cachetools/cachetools/func.pyi +++ b/stubs/cachetools/cachetools/func.pyi @@ -6,6 +6,6 @@ _T = TypeVar("_T") def lfu_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ... def lru_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ... def rr_cache( - maxsize: float = ..., choice: Optional[Callable[[Sequence[_T]], _T]] = ..., typed: bool = ... + maxsize: float = ..., choice: Callable[[Sequence[_T]], _T] | None = ..., typed: bool = ... ) -> IdentityFunction: ... def ttl_cache(maxsize: float = ..., ttl: float = ..., timer: float = ..., typed: bool = ...) -> IdentityFunction: ... diff --git a/stubs/cachetools/cachetools/lfu.pyi b/stubs/cachetools/cachetools/lfu.pyi index 93da665d9187..1016e395f013 100644 --- a/stubs/cachetools/cachetools/lfu.pyi +++ b/stubs/cachetools/cachetools/lfu.pyi @@ -6,7 +6,7 @@ _KT = TypeVar("_KT") _VT = TypeVar("_VT") class LFUCache(Cache[_KT, _VT]): - def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> None: ... + def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ... def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ... def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ... def __delitem__(self, key: _KT, cache_delitem: Callable[[_KT], None] = ...) -> None: ... diff --git a/stubs/cachetools/cachetools/lru.pyi b/stubs/cachetools/cachetools/lru.pyi index cac87ef3e777..c476c02237db 100644 --- a/stubs/cachetools/cachetools/lru.pyi +++ b/stubs/cachetools/cachetools/lru.pyi @@ -6,7 +6,7 @@ _KT = TypeVar("_KT") _VT = TypeVar("_VT") class LRUCache(Cache[_KT, _VT]): - def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> None: ... + def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ... def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ... def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ... def __delitem__(self, key: _KT, cache_delitem: Callable[[_KT], None] = ...) -> None: ... diff --git a/stubs/cachetools/cachetools/rr.pyi b/stubs/cachetools/cachetools/rr.pyi index c1acdb2feef4..c6daabf12441 100644 --- a/stubs/cachetools/cachetools/rr.pyi +++ b/stubs/cachetools/cachetools/rr.pyi @@ -9,8 +9,8 @@ class RRCache(Cache[_KT, _VT]): def __init__( self, maxsize: float, - choice: Optional[Callable[[Sequence[_KT]], _KT]] = ..., - getsizeof: Optional[Callable[[_VT], float]] = ..., + choice: Callable[[Sequence[_KT]], _KT] | None = ..., + getsizeof: Callable[[_VT], float] | None = ..., ) -> None: ... def __getitem__(self, key: _KT) -> _VT: ... def __setitem__(self, key: _KT, value: _VT) -> None: ... diff --git a/stubs/cachetools/cachetools/ttl.pyi b/stubs/cachetools/cachetools/ttl.pyi index fb539aaa5978..9e8373618593 100644 --- a/stubs/cachetools/cachetools/ttl.pyi +++ b/stubs/cachetools/cachetools/ttl.pyi @@ -7,7 +7,7 @@ _VT = TypeVar("_VT") class TTLCache(Cache[_KT, _VT]): def __init__( - self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: Optional[Callable[[_VT], float]] = ... + self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: Callable[[_VT], float] | None = ... ) -> None: ... def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ... def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ... @@ -20,4 +20,4 @@ class TTLCache(Cache[_KT, _VT]): def timer(self) -> Callable[[], float]: ... @property def ttl(self) -> float: ... - def expire(self, time: Optional[float] = ...) -> None: ... + def expire(self, time: float | None = ...) -> None: ... diff --git a/stubs/characteristic/characteristic/__init__.pyi b/stubs/characteristic/characteristic/__init__.pyi index e014cd9e042e..213f6f0b6f46 100644 --- a/stubs/characteristic/characteristic/__init__.pyi +++ b/stubs/characteristic/characteristic/__init__.pyi @@ -1,9 +1,9 @@ from typing import Any, AnyStr, Callable, Dict, Optional, Sequence, Type, TypeVar, Union -def with_repr(attrs: Sequence[Union[AnyStr, Attribute]]) -> Callable[..., Any]: ... -def with_cmp(attrs: Sequence[Union[AnyStr, Attribute]]) -> Callable[..., Any]: ... -def with_init(attrs: Sequence[Union[AnyStr, Attribute]]) -> Callable[..., Any]: ... -def immutable(attrs: Sequence[Union[AnyStr, Attribute]]) -> Callable[..., Any]: ... +def with_repr(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... +def with_cmp(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... +def with_init(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... +def immutable(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... def strip_leading_underscores(attribute_name: AnyStr) -> AnyStr: ... NOTHING = Any @@ -11,13 +11,13 @@ NOTHING = Any _T = TypeVar("_T") def attributes( - attrs: Sequence[Union[AnyStr, Attribute]], + attrs: Sequence[AnyStr | Attribute], apply_with_cmp: bool = ..., apply_with_init: bool = ..., apply_with_repr: bool = ..., apply_immutable: bool = ..., - store_attributes: Optional[Callable[[type, Attribute], Any]] = ..., - **kw: Optional[Dict[Any, Any]], + store_attributes: Callable[[type, Attribute], Any] | None = ..., + **kw: Dict[Any, Any] | None, ) -> Callable[[Type[_T]], Type[_T]]: ... class Attribute: @@ -29,7 +29,7 @@ class Attribute: exclude_from_repr: bool = ..., exclude_from_immutable: bool = ..., default_value: Any = ..., - default_factory: Optional[Callable[[None], Any]] = ..., - instance_of: Optional[Any] = ..., - init_aliaser: Optional[Callable[[AnyStr], AnyStr]] = ..., + default_factory: Callable[[None], Any] | None = ..., + instance_of: Any | None = ..., + init_aliaser: Callable[[AnyStr], AnyStr] | None = ..., ) -> None: ... diff --git a/stubs/chardet/chardet/universaldetector.pyi b/stubs/chardet/chardet/universaldetector.pyi index 08d2c479b6a6..c186f4d18413 100644 --- a/stubs/chardet/chardet/universaldetector.pyi +++ b/stubs/chardet/chardet/universaldetector.pyi @@ -8,9 +8,9 @@ class _FinalResultType(TypedDict): language: str class _IntermediateResultType(TypedDict): - encoding: Optional[str] + encoding: str | None confidence: float - language: Optional[str] + language: str | None class UniversalDetector(object): MINIMUM_THRESHOLD: float diff --git a/stubs/click-spinner/click_spinner/__init__.pyi b/stubs/click-spinner/click_spinner/__init__.pyi index f32f72453588..c2e840a6f8c7 100644 --- a/stubs/click-spinner/click_spinner/__init__.pyi +++ b/stubs/click-spinner/click_spinner/__init__.pyi @@ -16,15 +16,15 @@ class Spinner(object): beep: bool force: bool stream: _Stream - stop_running: Optional[threading.Event] - spin_thread: Optional[threading.Thread] + stop_running: threading.Event | None + spin_thread: threading.Thread | None def __init__(self, beep: bool, disable: bool, force: bool, stream: _Stream) -> None: ... def start(self) -> None: ... def stop(self) -> None: ... def init_spin(self) -> None: ... def __enter__(self) -> Spinner: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> Literal[False]: ... def spinner(beep: bool, disable: bool, force: bool, stream: _Stream) -> Spinner: ... diff --git a/stubs/click/click/_termui_impl.pyi b/stubs/click/click/_termui_impl.pyi index 4f8036cdb85a..19003f807c4d 100644 --- a/stubs/click/click/_termui_impl.pyi +++ b/stubs/click/click/_termui_impl.pyi @@ -8,10 +8,10 @@ class ProgressBar(Generic[_T]): def finish(self) -> None: ... def __enter__(self) -> ProgressBar[_T]: ... def __exit__( - self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType] + self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> None: ... def __iter__(self) -> ProgressBar[_T]: ... def next(self) -> _T: ... def __next__(self) -> _T: ... - length: Optional[int] + length: int | None label: str diff --git a/stubs/click/click/core.pyi b/stubs/click/click/core.pyi index e655f515a44c..b7ff86f743fa 100644 --- a/stubs/click/click/core.pyi +++ b/stubs/click/click/core.pyi @@ -21,53 +21,53 @@ from click.parser import OptionParser _CC = TypeVar("_CC", bound=Callable[[], Any]) def invoke_param_callback( - callback: Callable[[Context, Parameter, Optional[str]], Any], ctx: Context, param: Parameter, value: Optional[str] + callback: Callable[[Context, Parameter, str | None], Any], ctx: Context, param: Parameter, value: str | None ) -> Any: ... -def augment_usage_errors(ctx: Context, param: Optional[Parameter] = ...) -> ContextManager[None]: ... +def augment_usage_errors(ctx: Context, param: Parameter | None = ...) -> ContextManager[None]: ... def iter_params_for_processing( invocation_order: Sequence[Parameter], declaration_order: Iterable[Parameter] ) -> Iterable[Parameter]: ... class Context: - parent: Optional[Context] + parent: Context | None command: Command - info_name: Optional[str] + info_name: str | None params: Dict[Any, Any] args: List[str] protected_args: List[str] obj: Any - default_map: Optional[Mapping[str, Any]] - invoked_subcommand: Optional[str] - terminal_width: Optional[int] - max_content_width: Optional[int] + default_map: Mapping[str, Any] | None + invoked_subcommand: str | None + terminal_width: int | None + max_content_width: int | None allow_extra_args: bool allow_interspersed_args: bool ignore_unknown_options: bool help_option_names: List[str] - token_normalize_func: Optional[Callable[[str], str]] + token_normalize_func: Callable[[str], str] | None resilient_parsing: bool - auto_envvar_prefix: Optional[str] - color: Optional[bool] + auto_envvar_prefix: str | None + color: bool | None _meta: Dict[str, Any] _close_callbacks: List[Any] _depth: int def __init__( self, command: Command, - parent: Optional[Context] = ..., - info_name: Optional[str] = ..., - obj: Optional[Any] = ..., - auto_envvar_prefix: Optional[str] = ..., - default_map: Optional[Mapping[str, Any]] = ..., - terminal_width: Optional[int] = ..., - max_content_width: Optional[int] = ..., + parent: Context | None = ..., + info_name: str | None = ..., + obj: Any | None = ..., + auto_envvar_prefix: str | None = ..., + default_map: Mapping[str, Any] | None = ..., + terminal_width: int | None = ..., + max_content_width: int | None = ..., resilient_parsing: bool = ..., - allow_extra_args: Optional[bool] = ..., - allow_interspersed_args: Optional[bool] = ..., - ignore_unknown_options: Optional[bool] = ..., - help_option_names: Optional[List[str]] = ..., - token_normalize_func: Optional[Callable[[str], str]] = ..., - color: Optional[bool] = ..., + allow_extra_args: bool | None = ..., + allow_interspersed_args: bool | None = ..., + ignore_unknown_options: bool | None = ..., + help_option_names: List[str] | None = ..., + token_normalize_func: Callable[[str], str] | None = ..., + color: bool | None = ..., ) -> None: ... @property def meta(self) -> Dict[str, Any]: ... @@ -83,11 +83,11 @@ class Context: def lookup_default(self, name: str) -> Any: ... def fail(self, message: str) -> NoReturn: ... def abort(self) -> NoReturn: ... - def exit(self, code: Union[int, str] = ...) -> NoReturn: ... + def exit(self, code: int | str = ...) -> NoReturn: ... def get_usage(self) -> str: ... def get_help(self) -> str: ... - def invoke(self, callback: Union[Command, Callable[..., Any]], *args: Any, **kwargs: Any) -> Any: ... - def forward(self, callback: Union[Command, Callable[..., Any]], *args: Any, **kwargs: Any) -> Any: ... + def invoke(self, callback: Command | Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... + def forward(self, callback: Command | Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... class BaseCommand: allow_extra_args: bool @@ -95,28 +95,28 @@ class BaseCommand: ignore_unknown_options: bool name: str context_settings: Dict[Any, Any] - def __init__(self, name: str, context_settings: Optional[Dict[Any, Any]] = ...) -> None: ... + def __init__(self, name: str, context_settings: Dict[Any, Any] | None = ...) -> None: ... def get_usage(self, ctx: Context) -> str: ... def get_help(self, ctx: Context) -> str: ... - def make_context(self, info_name: str, args: List[str], parent: Optional[Context] = ..., **extra: Any) -> Context: ... + def make_context(self, info_name: str, args: List[str], parent: Context | None = ..., **extra: Any) -> Context: ... def parse_args(self, ctx: Context, args: List[str]) -> List[str]: ... def invoke(self, ctx: Context) -> Any: ... def main( self, - args: Optional[List[str]] = ..., - prog_name: Optional[str] = ..., - complete_var: Optional[str] = ..., + args: List[str] | None = ..., + prog_name: str | None = ..., + complete_var: str | None = ..., standalone_mode: bool = ..., **extra: Any, ) -> Any: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class Command(BaseCommand): - callback: Optional[Callable[..., Any]] + callback: Callable[..., Any] | None params: List[Parameter] - help: Optional[str] - epilog: Optional[str] - short_help: Optional[str] + help: str | None + epilog: str | None + short_help: str | None options_metavar: str add_help_option: bool no_args_is_help: bool @@ -125,12 +125,12 @@ class Command(BaseCommand): def __init__( self, name: str, - context_settings: Optional[Dict[Any, Any]] = ..., - callback: Optional[Callable[..., Any]] = ..., - params: Optional[List[Parameter]] = ..., - help: Optional[str] = ..., - epilog: Optional[str] = ..., - short_help: Optional[str] = ..., + context_settings: Dict[Any, Any] | None = ..., + callback: Callable[..., Any] | None = ..., + params: List[Parameter] | None = ..., + help: str | None = ..., + epilog: str | None = ..., + short_help: str | None = ..., options_metavar: str = ..., add_help_option: bool = ..., no_args_is_help: bool = ..., @@ -141,7 +141,7 @@ class Command(BaseCommand): def format_usage(self, ctx: Context, formatter: HelpFormatter) -> None: ... def collect_usage_pieces(self, ctx: Context) -> List[str]: ... def get_help_option_names(self, ctx: Context) -> Set[str]: ... - def get_help_option(self, ctx: Context) -> Optional[Option]: ... + def get_help_option(self, ctx: Context) -> Option | None: ... def make_parser(self, ctx: Context) -> OptionParser: ... def get_short_help_str(self, limit: int = ...) -> str: ... def format_help(self, ctx: Context, formatter: HelpFormatter) -> None: ... @@ -160,46 +160,46 @@ class MultiCommand(Command): result_callback: Callable[..., Any] def __init__( self, - name: Optional[str] = ..., + name: str | None = ..., invoke_without_command: bool = ..., - no_args_is_help: Optional[bool] = ..., - subcommand_metavar: Optional[str] = ..., + no_args_is_help: bool | None = ..., + subcommand_metavar: str | None = ..., chain: bool = ..., - result_callback: Optional[Callable[..., Any]] = ..., + result_callback: Callable[..., Any] | None = ..., **attrs: Any, ) -> None: ... def resultcallback(self, replace: bool = ...) -> Callable[[_F], _F]: ... def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None: ... def resolve_command(self, ctx: Context, args: List[str]) -> Tuple[str, Command, List[str]]: ... - def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]: ... + def get_command(self, ctx: Context, cmd_name: str) -> Command | None: ... def list_commands(self, ctx: Context) -> Iterable[str]: ... class Group(MultiCommand): commands: Dict[str, Command] - def __init__(self, name: Optional[str] = ..., commands: Optional[Dict[str, Command]] = ..., **attrs: Any) -> None: ... - def add_command(self, cmd: Command, name: Optional[str] = ...) -> None: ... + def __init__(self, name: str | None = ..., commands: Dict[str, Command] | None = ..., **attrs: Any) -> None: ... + def add_command(self, cmd: Command, name: str | None = ...) -> None: ... def command(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], Command]: ... def group(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], Group]: ... class CommandCollection(MultiCommand): sources: List[MultiCommand] - def __init__(self, name: Optional[str] = ..., sources: Optional[List[MultiCommand]] = ..., **attrs: Any) -> None: ... + def __init__(self, name: str | None = ..., sources: List[MultiCommand] | None = ..., **attrs: Any) -> None: ... def add_source(self, multi_cmd: MultiCommand) -> None: ... class _ParamType: name: str is_composite: bool - envvar_list_splitter: Optional[str] - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> Any: ... + envvar_list_splitter: str | None + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> Any: ... def get_metavar(self, param: Parameter) -> str: ... def get_missing_message(self, param: Parameter) -> str: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> Any: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> Any: ... def split_envvar_value(self, rv: str) -> List[str]: ... - def fail(self, message: str, param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> NoReturn: ... + def fail(self, message: str, param: Parameter | None = ..., ctx: Context | None = ...) -> NoReturn: ... # This type is here to resolve https://github.com/python/mypy/issues/5275 _ConvertibleType = Union[ - type, _ParamType, Tuple[Union[type, _ParamType], ...], Callable[[str], Any], Callable[[Optional[str]], Any] + type, _ParamType, Tuple[type | _ParamType, ...], Callable[[str], Any], Callable[[str | None], Any] ] class Parameter: @@ -209,26 +209,26 @@ class Parameter: secondary_opts: List[str] type: _ParamType required: bool - callback: Optional[Callable[[Context, Parameter, str], Any]] + callback: Callable[[Context, Parameter, str], Any] | None nargs: int multiple: bool expose_value: bool default: Any is_eager: bool - metavar: Optional[str] - envvar: Union[str, List[str], None] + metavar: str | None + envvar: str | List[str] | None def __init__( self, - param_decls: Optional[Iterable[str]] = ..., - type: Optional[_ConvertibleType] = ..., + param_decls: Iterable[str] | None = ..., + type: _ConvertibleType | None = ..., required: bool = ..., - default: Optional[Any] = ..., - callback: Optional[Callable[[Context, Parameter, str], Any]] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + default: Any | None = ..., + callback: Callable[[Context, Parameter, str], Any] | None = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., ) -> None: ... @property def human_readable_name(self) -> str: ... @@ -241,7 +241,7 @@ class Parameter: def value_is_missing(self, value: Any) -> bool: ... def full_process_value(self, ctx: Context, value: Any) -> Any: ... def resolve_envvar_value(self, ctx: Context) -> str: ... - def value_from_envvar(self, ctx: Context) -> Union[str, List[str]]: ... + def value_from_envvar(self, ctx: Context) -> str | List[str]: ... def handle_parse_result(self, ctx: Context, opts: Dict[str, Any], args: List[str]) -> Tuple[Any, List[str]]: ... def get_help_record(self, ctx: Context) -> Tuple[str, str]: ... def get_usage_pieces(self, ctx: Context) -> List[str]: ... @@ -257,25 +257,25 @@ class Option(Parameter): count: bool multiple: bool allow_from_autoenv: bool - help: Optional[str] + help: str | None hidden: bool show_default: bool show_choices: bool show_envvar: bool def __init__( self, - param_decls: Optional[Iterable[str]] = ..., + param_decls: Iterable[str] | None = ..., show_default: bool = ..., - prompt: Union[bool, str] = ..., + prompt: bool | str = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., - is_flag: Optional[bool] = ..., - flag_value: Optional[Any] = ..., + is_flag: bool | None = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., - type: Optional[_ConvertibleType] = ..., - help: Optional[str] = ..., + type: _ConvertibleType | None = ..., + help: str | None = ..., hidden: bool = ..., show_choices: bool = ..., show_envvar: bool = ..., @@ -284,4 +284,4 @@ class Option(Parameter): def prompt_for_value(self, ctx: Context) -> Any: ... class Argument(Parameter): - def __init__(self, param_decls: Optional[Iterable[str]] = ..., required: Optional[bool] = ..., **attrs: Any) -> None: ... + def __init__(self, param_decls: Iterable[str] | None = ..., required: bool | None = ..., **attrs: Any) -> None: ... diff --git a/stubs/click/click/decorators.pyi b/stubs/click/click/decorators.pyi index ce0b834e3178..84447ad77691 100644 --- a/stubs/click/click/decorators.pyi +++ b/stubs/click/click/decorators.pyi @@ -17,13 +17,13 @@ def make_pass_decorator(object_type: type, ensure: bool = ...) -> IdentityFuncti # arguments from core.pyi to help with type checking. def command( - name: Optional[str] = ..., - cls: Optional[Type[Command]] = ..., + name: str | None = ..., + cls: Type[Command] | None = ..., # Command - context_settings: Optional[Dict[Any, Any]] = ..., - help: Optional[str] = ..., - epilog: Optional[str] = ..., - short_help: Optional[str] = ..., + context_settings: Dict[Any, Any] | None = ..., + help: str | None = ..., + epilog: str | None = ..., + short_help: str | None = ..., options_metavar: str = ..., add_help_option: bool = ..., no_args_is_help: bool = ..., @@ -34,20 +34,20 @@ def command( # This inherits attrs from Group, MultiCommand and Command. def group( - name: Optional[str] = ..., + name: str | None = ..., cls: Type[Command] = ..., # Group - commands: Optional[Dict[str, Command]] = ..., + commands: Dict[str, Command] | None = ..., # MultiCommand invoke_without_command: bool = ..., - no_args_is_help: Optional[bool] = ..., - subcommand_metavar: Optional[str] = ..., + no_args_is_help: bool | None = ..., + subcommand_metavar: str | None = ..., chain: bool = ..., - result_callback: Optional[Callable[..., Any]] = ..., + result_callback: Callable[..., Any] | None = ..., # Command - help: Optional[str] = ..., - epilog: Optional[str] = ..., - short_help: Optional[str] = ..., + help: str | None = ..., + epilog: str | None = ..., + short_help: str | None = ..., options_metavar: str = ..., add_help_option: bool = ..., hidden: bool = ..., @@ -59,44 +59,44 @@ def argument( *param_decls: Text, cls: Type[Argument] = ..., # Argument - required: Optional[bool] = ..., + required: bool | None = ..., # Parameter - type: Optional[_ConvertibleType] = ..., - default: Optional[Any] = ..., - callback: Optional[_Callback] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + type: _ConvertibleType | None = ..., + default: Any | None = ..., + callback: _Callback | None = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., - autocompletion: Optional[Callable[[Context, List[str], str], Iterable[Union[str, Tuple[str, str]]]]] = ..., + envvar: str | List[str] | None = ..., + autocompletion: Callable[[Context, List[str], str], Iterable[str | Tuple[str, str]]] | None = ..., ) -> IdentityFunction: ... @overload def option( *param_decls: Text, cls: Type[Option] = ..., # Option - show_default: Union[bool, Text] = ..., - prompt: Union[bool, Text] = ..., + show_default: bool | Text = ..., + prompt: bool | Text = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., - is_flag: Optional[bool] = ..., - flag_value: Optional[Any] = ..., + is_flag: bool | None = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., - type: Optional[_ConvertibleType] = ..., - help: Optional[Text] = ..., + type: _ConvertibleType | None = ..., + help: Text | None = ..., show_choices: bool = ..., # Parameter - default: Optional[Any] = ..., + default: Any | None = ..., required: bool = ..., - callback: Optional[_Callback] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + callback: _Callback | None = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., # User-defined **kwargs: Any, ) -> IdentityFunction: ... @@ -105,27 +105,27 @@ def option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: Union[bool, Text] = ..., - prompt: Union[bool, Text] = ..., + show_default: bool | Text = ..., + prompt: bool | Text = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., - is_flag: Optional[bool] = ..., - flag_value: Optional[Any] = ..., + is_flag: bool | None = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., type: _T = ..., - help: Optional[str] = ..., + help: str | None = ..., show_choices: bool = ..., # Parameter - default: Optional[Any] = ..., + default: Any | None = ..., required: bool = ..., - callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + callback: Callable[[Context, Option | Parameter, bool | int | str], _T] | None = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., # User-defined **kwargs: Any, ) -> IdentityFunction: ... @@ -134,27 +134,27 @@ def option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: Union[bool, Text] = ..., - prompt: Union[bool, Text] = ..., + show_default: bool | Text = ..., + prompt: bool | Text = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., - is_flag: Optional[bool] = ..., - flag_value: Optional[Any] = ..., + is_flag: bool | None = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., type: Type[str] = ..., - help: Optional[str] = ..., + help: str | None = ..., show_choices: bool = ..., # Parameter - default: Optional[Any] = ..., + default: Any | None = ..., required: bool = ..., - callback: Callable[[Context, Union[Option, Parameter], str], Any] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + callback: Callable[[Context, Option | Parameter, str], Any] = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., # User-defined **kwargs: Any, ) -> IdentityFunction: ... @@ -163,27 +163,27 @@ def option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: Union[bool, Text] = ..., - prompt: Union[bool, Text] = ..., + show_default: bool | Text = ..., + prompt: bool | Text = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., - is_flag: Optional[bool] = ..., - flag_value: Optional[Any] = ..., + is_flag: bool | None = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., type: Type[int] = ..., - help: Optional[str] = ..., + help: str | None = ..., show_choices: bool = ..., # Parameter - default: Optional[Any] = ..., + default: Any | None = ..., required: bool = ..., - callback: Callable[[Context, Union[Option, Parameter], int], Any] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + callback: Callable[[Context, Option | Parameter, int], Any] = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., # User-defined **kwargs: Any, ) -> IdentityFunction: ... @@ -191,102 +191,102 @@ def confirmation_option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: Union[bool, Text] = ..., - prompt: Union[bool, Text] = ..., + show_default: bool | Text = ..., + prompt: bool | Text = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., is_flag: bool = ..., - flag_value: Optional[Any] = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., - type: Optional[_ConvertibleType] = ..., + type: _ConvertibleType | None = ..., help: str = ..., show_choices: bool = ..., # Parameter - default: Optional[Any] = ..., - callback: Optional[_Callback] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + default: Any | None = ..., + callback: _Callback | None = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., ) -> IdentityFunction: ... def password_option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: Union[bool, Text] = ..., - prompt: Union[bool, Text] = ..., + show_default: bool | Text = ..., + prompt: bool | Text = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., - is_flag: Optional[bool] = ..., - flag_value: Optional[Any] = ..., + is_flag: bool | None = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., - type: Optional[_ConvertibleType] = ..., - help: Optional[str] = ..., + type: _ConvertibleType | None = ..., + help: str | None = ..., show_choices: bool = ..., # Parameter - default: Optional[Any] = ..., - callback: Optional[_Callback] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + default: Any | None = ..., + callback: _Callback | None = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., ) -> IdentityFunction: ... def version_option( - version: Optional[Union[str, Version]] = ..., + version: str | Version | None = ..., *param_decls: str, cls: Type[Option] = ..., # Option - prog_name: Optional[str] = ..., - message: Optional[str] = ..., - show_default: Union[bool, Text] = ..., - prompt: Union[bool, Text] = ..., + prog_name: str | None = ..., + message: str | None = ..., + show_default: bool | Text = ..., + prompt: bool | Text = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., is_flag: bool = ..., - flag_value: Optional[Any] = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., - type: Optional[_ConvertibleType] = ..., + type: _ConvertibleType | None = ..., help: str = ..., show_choices: bool = ..., # Parameter - default: Optional[Any] = ..., - callback: Optional[_Callback] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + default: Any | None = ..., + callback: _Callback | None = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., ) -> IdentityFunction: ... def help_option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: Union[bool, Text] = ..., - prompt: Union[bool, Text] = ..., + show_default: bool | Text = ..., + prompt: bool | Text = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., is_flag: bool = ..., - flag_value: Optional[Any] = ..., + flag_value: Any | None = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., - type: Optional[_ConvertibleType] = ..., + type: _ConvertibleType | None = ..., help: str = ..., show_choices: bool = ..., # Parameter - default: Optional[Any] = ..., - callback: Optional[_Callback] = ..., - nargs: Optional[int] = ..., - metavar: Optional[str] = ..., + default: Any | None = ..., + callback: _Callback | None = ..., + nargs: int | None = ..., + metavar: str | None = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: Optional[Union[str, List[str]]] = ..., + envvar: str | List[str] | None = ..., ) -> IdentityFunction: ... diff --git a/stubs/click/click/exceptions.pyi b/stubs/click/click/exceptions.pyi index 9b8235825794..acf6534171f5 100644 --- a/stubs/click/click/exceptions.pyi +++ b/stubs/click/click/exceptions.pyi @@ -7,54 +7,54 @@ class ClickException(Exception): message: str def __init__(self, message: str) -> None: ... def format_message(self) -> str: ... - def show(self, file: Optional[Any] = ...) -> None: ... + def show(self, file: Any | None = ...) -> None: ... class UsageError(ClickException): - ctx: Optional[Context] - cmd: Optional[Command] - def __init__(self, message: str, ctx: Optional[Context] = ...) -> None: ... - def show(self, file: Optional[IO[Any]] = ...) -> None: ... + ctx: Context | None + cmd: Command | None + def __init__(self, message: str, ctx: Context | None = ...) -> None: ... + def show(self, file: IO[Any] | None = ...) -> None: ... class BadParameter(UsageError): - param: Optional[Parameter] - param_hint: Optional[str] + param: Parameter | None + param_hint: str | None def __init__( - self, message: str, ctx: Optional[Context] = ..., param: Optional[Parameter] = ..., param_hint: Optional[str] = ... + self, message: str, ctx: Context | None = ..., param: Parameter | None = ..., param_hint: str | None = ... ) -> None: ... class MissingParameter(BadParameter): param_type: str # valid values: 'parameter', 'option', 'argument' def __init__( self, - message: Optional[str] = ..., - ctx: Optional[Context] = ..., - param: Optional[Parameter] = ..., - param_hint: Optional[str] = ..., - param_type: Optional[str] = ..., + message: str | None = ..., + ctx: Context | None = ..., + param: Parameter | None = ..., + param_hint: str | None = ..., + param_type: str | None = ..., ) -> None: ... class NoSuchOption(UsageError): option_name: str - possibilities: Optional[List[str]] + possibilities: List[str] | None def __init__( self, option_name: str, - message: Optional[str] = ..., - possibilities: Optional[List[str]] = ..., - ctx: Optional[Context] = ..., + message: str | None = ..., + possibilities: List[str] | None = ..., + ctx: Context | None = ..., ) -> None: ... class BadOptionUsage(UsageError): option_name: str - def __init__(self, option_name: str, message: str, ctx: Optional[Context] = ...) -> None: ... + def __init__(self, option_name: str, message: str, ctx: Context | None = ...) -> None: ... class BadArgumentUsage(UsageError): - def __init__(self, message: str, ctx: Optional[Context] = ...) -> None: ... + def __init__(self, message: str, ctx: Context | None = ...) -> None: ... class FileError(ClickException): ui_filename: str filename: str - def __init__(self, filename: str, hint: Optional[str] = ...) -> None: ... + def __init__(self, filename: str, hint: str | None = ...) -> None: ... class Abort(RuntimeError): ... diff --git a/stubs/click/click/formatting.pyi b/stubs/click/click/formatting.pyi index bcc25e61fb55..9378469acece 100644 --- a/stubs/click/click/formatting.pyi +++ b/stubs/click/click/formatting.pyi @@ -1,6 +1,6 @@ from typing import ContextManager, Generator, Iterable, List, Optional, Tuple -FORCED_WIDTH: Optional[int] +FORCED_WIDTH: int | None def measure_table(rows: Iterable[Iterable[str]]) -> Tuple[int, ...]: ... def iter_rows(rows: Iterable[Iterable[str]], col_count: int) -> Generator[Tuple[str, ...], None, None]: ... @@ -10,10 +10,10 @@ def wrap_text( class HelpFormatter: indent_increment: int - width: Optional[int] + width: int | None current_indent: int buffer: List[str] - def __init__(self, indent_increment: int = ..., width: Optional[int] = ..., max_width: Optional[int] = ...) -> None: ... + def __init__(self, indent_increment: int = ..., width: int | None = ..., max_width: int | None = ...) -> None: ... def write(self, string: str) -> None: ... def indent(self) -> None: ... def dedent(self) -> None: ... diff --git a/stubs/click/click/globals.pyi b/stubs/click/click/globals.pyi index 64b399d481be..5b6ba9543aef 100644 --- a/stubs/click/click/globals.pyi +++ b/stubs/click/click/globals.pyi @@ -5,4 +5,4 @@ from click.core import Context def get_current_context(silent: bool = ...) -> Context: ... def push_context(ctx: Context) -> None: ... def pop_context() -> None: ... -def resolve_color_default(color: Optional[bool] = ...) -> Optional[bool]: ... +def resolve_color_default(color: bool | None = ...) -> bool | None: ... diff --git a/stubs/click/click/parser.pyi b/stubs/click/click/parser.pyi index fdcc2eaf7ccf..5e15d9e71c88 100644 --- a/stubs/click/click/parser.pyi +++ b/stubs/click/click/parser.pyi @@ -2,7 +2,7 @@ from typing import Any, Dict, Iterable, List, Optional, Set, Tuple from click.core import Context -def _unpack_args(args: Iterable[str], nargs_spec: Iterable[int]) -> Tuple[Tuple[Optional[Tuple[str, ...]], ...], List[str]]: ... +def _unpack_args(args: Iterable[str], nargs_spec: Iterable[int]) -> Tuple[Tuple[Tuple[str, ...] | None, ...], List[str]]: ... def split_opt(opt: str) -> Tuple[str, str]: ... def normalize_opt(opt: str, ctx: Context) -> str: ... def split_arg_string(string: str) -> List[str]: ... @@ -20,10 +20,10 @@ class Option: self, opts: Iterable[str], dest: str, - action: Optional[str] = ..., + action: str | None = ..., nargs: int = ..., - const: Optional[Any] = ..., - obj: Optional[Any] = ..., + const: Any | None = ..., + obj: Any | None = ..., ) -> None: ... @property def takes_value(self) -> bool: ... @@ -33,7 +33,7 @@ class Argument: dest: str nargs: int obj: Any - def __init__(self, dest: str, nargs: int = ..., obj: Optional[Any] = ...) -> None: ... + def __init__(self, dest: str, nargs: int = ..., obj: Any | None = ...) -> None: ... def process(self, value: Any, state: ParsingState) -> None: ... class ParsingState: @@ -44,22 +44,22 @@ class ParsingState: def __init__(self, rargs: List[str]) -> None: ... class OptionParser: - ctx: Optional[Context] + ctx: Context | None allow_interspersed_args: bool ignore_unknown_options: bool _short_opt: Dict[str, Option] _long_opt: Dict[str, Option] _opt_prefixes: Set[str] _args: List[Argument] - def __init__(self, ctx: Optional[Context] = ...) -> None: ... + def __init__(self, ctx: Context | None = ...) -> None: ... def add_option( self, opts: Iterable[str], dest: str, - action: Optional[str] = ..., + action: str | None = ..., nargs: int = ..., - const: Optional[Any] = ..., - obj: Optional[Any] = ..., + const: Any | None = ..., + obj: Any | None = ..., ) -> None: ... - def add_argument(self, dest: str, nargs: int = ..., obj: Optional[Any] = ...) -> None: ... + def add_argument(self, dest: str, nargs: int = ..., obj: Any | None = ...) -> None: ... def parse_args(self, args: List[str]) -> Tuple[Dict[str, Any], List[str], List[Any]]: ... diff --git a/stubs/click/click/termui.pyi b/stubs/click/click/termui.pyi index fdaf35636509..da32f93c1d98 100644 --- a/stubs/click/click/termui.pyi +++ b/stubs/click/click/termui.pyi @@ -4,14 +4,14 @@ from click._termui_impl import ProgressBar as _ProgressBar from click.core import _ConvertibleType def hidden_prompt_func(prompt: str) -> str: ... -def _build_prompt(text: str, suffix: str, show_default: bool = ..., default: Optional[str] = ...) -> str: ... +def _build_prompt(text: str, suffix: str, show_default: bool = ..., default: str | None = ...) -> str: ... def prompt( text: str, - default: Optional[str] = ..., + default: str | None = ..., hide_input: bool = ..., confirmation_prompt: bool = ..., - type: Optional[_ConvertibleType] = ..., - value_proc: Optional[Callable[[Optional[str]], Any]] = ..., + type: _ConvertibleType | None = ..., + value_proc: Callable[[str | None], Any] | None = ..., prompt_suffix: str = ..., show_default: bool = ..., err: bool = ..., @@ -22,7 +22,7 @@ def confirm( ) -> bool: ... def get_terminal_size() -> Tuple[int, int]: ... def echo_via_pager( - text_or_generator: Union[str, Iterable[str], Callable[[], Generator[str, None, None]]], color: Optional[bool] = ... + text_or_generator: str | Iterable[str] | Callable[[], Generator[str, None, None]], color: bool | None = ... ) -> None: ... _T = TypeVar("_T") @@ -30,74 +30,74 @@ _T = TypeVar("_T") @overload def progressbar( iterable: Iterable[_T], - length: Optional[int] = ..., - label: Optional[str] = ..., + length: int | None = ..., + label: str | None = ..., show_eta: bool = ..., - show_percent: Optional[bool] = ..., + show_percent: bool | None = ..., show_pos: bool = ..., - item_show_func: Optional[Callable[[_T], str]] = ..., + item_show_func: Callable[[_T], str] | None = ..., fill_char: str = ..., empty_char: str = ..., bar_template: str = ..., info_sep: str = ..., width: int = ..., - file: Optional[IO[Any]] = ..., - color: Optional[bool] = ..., + file: IO[Any] | None = ..., + color: bool | None = ..., ) -> _ProgressBar[_T]: ... @overload def progressbar( iterable: None = ..., - length: Optional[int] = ..., - label: Optional[str] = ..., + length: int | None = ..., + label: str | None = ..., show_eta: bool = ..., - show_percent: Optional[bool] = ..., + show_percent: bool | None = ..., show_pos: bool = ..., - item_show_func: Optional[Callable[[Any], str]] = ..., + item_show_func: Callable[[Any], str] | None = ..., fill_char: str = ..., empty_char: str = ..., bar_template: str = ..., info_sep: str = ..., width: int = ..., - file: Optional[IO[Any]] = ..., - color: Optional[bool] = ..., + file: IO[Any] | None = ..., + color: bool | None = ..., ) -> _ProgressBar[int]: ... def clear() -> None: ... def style( text: Text, - fg: Optional[Text] = ..., - bg: Optional[Text] = ..., - bold: Optional[bool] = ..., - dim: Optional[bool] = ..., - underline: Optional[bool] = ..., - blink: Optional[bool] = ..., - reverse: Optional[bool] = ..., + fg: Text | None = ..., + bg: Text | None = ..., + bold: bool | None = ..., + dim: bool | None = ..., + underline: bool | None = ..., + blink: bool | None = ..., + reverse: bool | None = ..., reset: bool = ..., ) -> str: ... def unstyle(text: Text) -> str: ... # Styling options copied from style() for nicer type checking. def secho( - message: Optional[str] = ..., - file: Optional[IO[Any]] = ..., + message: str | None = ..., + file: IO[Any] | None = ..., nl: bool = ..., err: bool = ..., - color: Optional[bool] = ..., - fg: Optional[str] = ..., - bg: Optional[str] = ..., - bold: Optional[bool] = ..., - dim: Optional[bool] = ..., - underline: Optional[bool] = ..., - blink: Optional[bool] = ..., - reverse: Optional[bool] = ..., + color: bool | None = ..., + fg: str | None = ..., + bg: str | None = ..., + bold: bool | None = ..., + dim: bool | None = ..., + underline: bool | None = ..., + blink: bool | None = ..., + reverse: bool | None = ..., reset: bool = ..., ) -> None: ... def edit( - text: Optional[str] = ..., - editor: Optional[str] = ..., - env: Optional[str] = ..., + text: str | None = ..., + editor: str | None = ..., + env: str | None = ..., require_save: bool = ..., extension: str = ..., - filename: Optional[str] = ..., + filename: str | None = ..., ) -> str: ... def launch(url: str, wait: bool = ..., locate: bool = ...) -> int: ... def getchar(echo: bool = ...) -> Text: ... diff --git a/stubs/click/click/testing.pyi b/stubs/click/click/testing.pyi index 18ae5ea208b2..cd399cffd603 100644 --- a/stubs/click/click/testing.pyi +++ b/stubs/click/click/testing.pyi @@ -14,13 +14,13 @@ class EchoingStdin: def readlines(self) -> List[bytes]: ... def __iter__(self) -> Iterable[bytes]: ... -def make_input_stream(input: Optional[Union[bytes, Text, IO[Any]]], charset: Text) -> BinaryIO: ... +def make_input_stream(input: bytes | Text | IO[Any] | None, charset: Text) -> BinaryIO: ... class Result: runner: CliRunner exit_code: int exception: Any - exc_info: Optional[Any] + exc_info: Any | None stdout_bytes: bytes stderr_bytes: bytes def __init__( @@ -30,7 +30,7 @@ class Result: stderr_bytes: bytes, exit_code: int, exception: Any, - exc_info: Optional[Any] = ..., + exc_info: Any | None = ..., ) -> None: ... @property def output(self) -> Text: ... @@ -46,22 +46,22 @@ class CliRunner: mix_stderr: bool def __init__( self, - charset: Optional[Text] = ..., - env: Optional[Mapping[str, str]] = ..., + charset: Text | None = ..., + env: Mapping[str, str] | None = ..., echo_stdin: bool = ..., mix_stderr: bool = ..., ) -> None: ... def get_default_prog_name(self, cli: BaseCommand) -> str: ... - def make_env(self, overrides: Optional[Mapping[str, str]] = ...) -> Dict[str, str]: ... + def make_env(self, overrides: Mapping[str, str] | None = ...) -> Dict[str, str]: ... def isolation( - self, input: Optional[Union[bytes, Text, IO[Any]]] = ..., env: Optional[Mapping[str, str]] = ..., color: bool = ... - ) -> ContextManager[Tuple[io.BytesIO, Union[io.BytesIO, Literal[False]]]]: ... + self, input: bytes | Text | IO[Any] | None = ..., env: Mapping[str, str] | None = ..., color: bool = ... + ) -> ContextManager[Tuple[io.BytesIO, io.BytesIO | Literal[False]]]: ... def invoke( self, cli: BaseCommand, - args: Optional[Union[str, Iterable[str]]] = ..., - input: Optional[Union[bytes, Text, IO[Any]]] = ..., - env: Optional[Mapping[str, str]] = ..., + args: str | Iterable[str] | None = ..., + input: bytes | Text | IO[Any] | None = ..., + env: Mapping[str, str] | None = ..., catch_exceptions: bool = ..., color: bool = ..., **extra: Any, diff --git a/stubs/click/click/types.pyi b/stubs/click/click/types.pyi index d4db0256132c..2b9fe305f85d 100644 --- a/stubs/click/click/types.pyi +++ b/stubs/click/click/types.pyi @@ -7,8 +7,8 @@ from click.core import Context, Parameter, _ConvertibleType, _ParamType ParamType = _ParamType class BoolParamType(ParamType): - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> bool: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> bool: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> bool: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> bool: ... class CompositeParamType(ParamType): arity: int @@ -20,35 +20,35 @@ class Choice(ParamType): class DateTime(ParamType): formats: Sequence[str] - def __init__(self, formats: Optional[Sequence[str]] = ...) -> None: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> datetime.datetime: ... + def __init__(self, formats: Sequence[str] | None = ...) -> None: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> datetime.datetime: ... class FloatParamType(ParamType): - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> float: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> float: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> float: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> float: ... class FloatRange(FloatParamType): - min: Optional[float] - max: Optional[float] + min: float | None + max: float | None clamp: bool - def __init__(self, min: Optional[float] = ..., max: Optional[float] = ..., clamp: bool = ...) -> None: ... + def __init__(self, min: float | None = ..., max: float | None = ..., clamp: bool = ...) -> None: ... class File(ParamType): mode: str - encoding: Optional[str] - errors: Optional[str] - lazy: Optional[bool] + encoding: str | None + errors: str | None + lazy: bool | None atomic: bool def __init__( self, mode: Text = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - lazy: Optional[bool] = ..., - atomic: Optional[bool] = ..., + encoding: str | None = ..., + errors: str | None = ..., + lazy: bool | None = ..., + atomic: bool | None = ..., ) -> None: ... - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> IO[Any]: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> IO[Any]: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> IO[Any]: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> IO[Any]: ... def resolve_lazy_flag(self, value: str) -> bool: ... _F = TypeVar("_F") # result of the function @@ -57,18 +57,18 @@ _Func = Callable[[Optional[str]], _F] class FuncParamType(ParamType, Generic[_F]): func: _Func[_F] def __init__(self, func: _Func[_F]) -> None: ... - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> _F: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> _F: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> _F: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> _F: ... class IntParamType(ParamType): - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> int: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> int: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> int: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> int: ... class IntRange(IntParamType): - min: Optional[int] - max: Optional[int] + min: int | None + max: int | None clamp: bool - def __init__(self, min: Optional[int] = ..., max: Optional[int] = ..., clamp: bool = ...) -> None: ... + def __init__(self, min: int | None = ..., max: int | None = ..., clamp: bool = ...) -> None: ... _PathType = TypeVar("_PathType", str, bytes) _PathTypeBound = Union[Type[str], Type[bytes]] @@ -81,7 +81,7 @@ class Path(ParamType): readable: bool resolve_path: bool allow_dash: bool - type: Optional[_PathTypeBound] + type: _PathTypeBound | None def __init__( self, exists: bool = ..., @@ -91,29 +91,29 @@ class Path(ParamType): readable: bool = ..., resolve_path: bool = ..., allow_dash: bool = ..., - path_type: Optional[Type[_PathType]] = ..., + path_type: Type[_PathType] | None = ..., ) -> None: ... - def coerce_path_result(self, rv: Union[str, bytes]) -> _PathType: ... - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> _PathType: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> _PathType: ... + def coerce_path_result(self, rv: str | bytes) -> _PathType: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> _PathType: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> _PathType: ... class StringParamType(ParamType): - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> str: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> str: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> str: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> str: ... class Tuple(CompositeParamType): types: List[ParamType] def __init__(self, types: Iterable[Any]) -> None: ... - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> Tuple: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> Tuple: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> Tuple: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> Tuple: ... class UnprocessedParamType(ParamType): ... class UUIDParameterType(ParamType): - def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> uuid.UUID: ... - def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> uuid.UUID: ... + def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> uuid.UUID: ... + def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> uuid.UUID: ... -def convert_type(ty: Optional[_ConvertibleType], default: Optional[Any] = ...) -> ParamType: ... +def convert_type(ty: _ConvertibleType | None, default: Any | None = ...) -> ParamType: ... # parameter type shortcuts diff --git a/stubs/click/click/utils.pyi b/stubs/click/click/utils.pyi index c0ae9e254219..240e8ebf0b6e 100644 --- a/stubs/click/click/utils.pyi +++ b/stubs/click/click/utils.pyi @@ -11,18 +11,18 @@ def make_default_short_help(help: str, max_length: int = ...) -> str: ... class LazyFile(object): name: str mode: str - encoding: Optional[str] + encoding: str | None errors: str atomic: bool def __init__( - self, filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., atomic: bool = ... + self, filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., atomic: bool = ... ) -> None: ... def open(self) -> IO[Any]: ... def close(self) -> None: ... def close_intelligently(self) -> None: ... def __enter__(self) -> LazyFile: ... def __exit__( - self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType] + self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[Any]: ... @@ -31,18 +31,18 @@ class KeepOpenFile(Generic[AnyStr]): def __init__(self, file: IO[AnyStr]) -> None: ... def __enter__(self) -> KeepOpenFile[AnyStr]: ... def __exit__( - self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType] + self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[AnyStr]: ... def echo( - message: object = ..., file: Optional[IO[Text]] = ..., nl: bool = ..., err: bool = ..., color: Optional[bool] = ... + message: object = ..., file: IO[Text] | None = ..., nl: bool = ..., err: bool = ..., color: bool | None = ... ) -> None: ... def get_binary_stream(name: str) -> IO[bytes]: ... -def get_text_stream(name: str, encoding: Optional[str] = ..., errors: str = ...) -> IO[str]: ... +def get_text_stream(name: str, encoding: str | None = ..., errors: str = ...) -> IO[str]: ... def open_file( - filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., lazy: bool = ..., atomic: bool = ... -) -> Any: ... # really Union[IO, LazyFile, KeepOpenFile] + filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., lazy: bool = ..., atomic: bool = ... +) -> Any: ... # really IO | LazyFile | KeepOpenFile def get_os_args() -> List[str]: ... def format_filename(filename: str, shorten: bool = ...) -> str: ... def get_app_dir(app_name: str, roaming: bool = ..., force_posix: bool = ...) -> str: ... diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index 5006b08ab41c..df8dc1759db2 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -33,7 +33,7 @@ class AnsiToWin32: win32_calls: _WinTermCallDict = ... on_stderr: bool = ... def __init__( - self, wrapped: TextIO, convert: Optional[bool] = ..., strip: Optional[bool] = ..., autoreset: bool = ... + self, wrapped: TextIO, convert: bool | None = ..., strip: bool | None = ..., autoreset: bool = ... ) -> None: ... def should_wrap(self) -> bool: ... def get_win32_calls(self) -> _WinTermCallDict: ... diff --git a/stubs/colorama/colorama/initialise.pyi b/stubs/colorama/colorama/initialise.pyi index 4f7d7427c5c6..fd21d53eae65 100644 --- a/stubs/colorama/colorama/initialise.pyi +++ b/stubs/colorama/colorama/initialise.pyi @@ -2,17 +2,17 @@ from typing import Any, ContextManager, Optional, TextIO, Union from .ansitowin32 import StreamWrapper -orig_stdout: Optional[TextIO] -orig_stderr: Optional[TextIO] -wrapped_stdout: Union[TextIO, StreamWrapper] -wrapped_stderr: Union[TextIO, StreamWrapper] +orig_stdout: TextIO | None +orig_stderr: TextIO | None +wrapped_stdout: TextIO | StreamWrapper +wrapped_stderr: TextIO | StreamWrapper atexit_done: bool def reset_all() -> None: ... -def init(autoreset: bool = ..., convert: Optional[bool] = ..., strip: Optional[bool] = ..., wrap: bool = ...) -> None: ... +def init(autoreset: bool = ..., convert: bool | None = ..., strip: bool | None = ..., wrap: bool = ...) -> None: ... def deinit() -> None: ... def colorama_text(*args: Any, **kwargs: Any) -> ContextManager[None]: ... def reinit() -> None: ... def wrap_stream( - stream: TextIO, convert: Optional[bool], strip: Optional[bool], autoreset: bool, wrap: bool -) -> Union[TextIO, StreamWrapper]: ... + stream: TextIO, convert: bool | None, strip: bool | None, autoreset: bool, wrap: bool +) -> TextIO | StreamWrapper: ... diff --git a/stubs/colorama/colorama/winterm.pyi b/stubs/colorama/colorama/winterm.pyi index 0947d33f0af0..f97c91a38c5d 100644 --- a/stubs/colorama/colorama/winterm.pyi +++ b/stubs/colorama/colorama/winterm.pyi @@ -21,13 +21,13 @@ if sys.platform == "win32": def __init__(self) -> None: ... def get_attrs(self) -> int: ... def set_attrs(self, value: int) -> None: ... - def reset_all(self, on_stderr: Optional[bool] = ...) -> None: ... - def fore(self, fore: Optional[int] = ..., light: bool = ..., on_stderr: bool = ...) -> None: ... - def back(self, back: Optional[int] = ..., light: bool = ..., on_stderr: bool = ...) -> None: ... - def style(self, style: Optional[int] = ..., on_stderr: bool = ...) -> None: ... - def set_console(self, attrs: Optional[int] = ..., on_stderr: bool = ...) -> None: ... + def reset_all(self, on_stderr: bool | None = ...) -> None: ... + def fore(self, fore: int | None = ..., light: bool = ..., on_stderr: bool = ...) -> None: ... + def back(self, back: int | None = ..., light: bool = ..., on_stderr: bool = ...) -> None: ... + def style(self, style: int | None = ..., on_stderr: bool = ...) -> None: ... + def set_console(self, attrs: int | None = ..., on_stderr: bool = ...) -> None: ... def get_position(self, handle: int) -> win32.COORD: ... - def set_cursor_position(self, position: Optional[win32.COORD] = ..., on_stderr: bool = ...) -> None: ... + def set_cursor_position(self, position: win32.COORD | None = ..., on_stderr: bool = ...) -> None: ... def cursor_adjust(self, x: int, y: int, on_stderr: bool = ...) -> None: ... def erase_screen(self, mode: int = ..., on_stderr: bool = ...) -> None: ... def erase_line(self, mode: int = ..., on_stderr: bool = ...) -> None: ... diff --git a/stubs/croniter/croniter.pyi b/stubs/croniter/croniter.pyi index 293825e01e2b..0d4c9f9a7bf6 100644 --- a/stubs/croniter/croniter.pyi +++ b/stubs/croniter/croniter.pyi @@ -16,26 +16,26 @@ class croniter(Iterator[Any]): ALPHACONV: Tuple[Dict[str, Any], ...] LOWMAP: Tuple[Dict[int, Any], ...] bad_length: str - tzinfo: Optional[datetime.tzinfo] + tzinfo: datetime.tzinfo | None cur: float expanded: List[List[str]] start_time: float dst_start_time: float nth_weekday_of_month: Dict[str, Any] def __init__( - self, expr_format: Text, start_time: Optional[Union[float, datetime.datetime]] = ..., ret_type: Optional[_RetType] = ... + self, expr_format: Text, start_time: float | datetime.datetime | None = ..., ret_type: _RetType | None = ... ) -> None: ... # Most return value depend on ret_type, which can be passed in both as a method argument and as # a constructor argument. - def get_next(self, ret_type: Optional[_RetType] = ...) -> Any: ... - def get_prev(self, ret_type: Optional[_RetType] = ...) -> Any: ... - def get_current(self, ret_type: Optional[_RetType] = ...) -> Any: ... + def get_next(self, ret_type: _RetType | None = ...) -> Any: ... + def get_prev(self, ret_type: _RetType | None = ...) -> Any: ... + def get_current(self, ret_type: _RetType | None = ...) -> Any: ... def __iter__(self: _SelfT) -> _SelfT: ... - def __next__(self, ret_type: Optional[_RetType] = ...) -> Any: ... - def next(self, ret_type: Optional[_RetType] = ...) -> Any: ... - def all_next(self, ret_type: Optional[_RetType] = ...) -> Iterator[Any]: ... - def all_prev(self, ret_type: Optional[_RetType] = ...) -> Iterator[Any]: ... - def iter(self, ret_type: Optional[_RetType] = ...) -> Iterator[Any]: ... + def __next__(self, ret_type: _RetType | None = ...) -> Any: ... + def next(self, ret_type: _RetType | None = ...) -> Any: ... + def all_next(self, ret_type: _RetType | None = ...) -> Iterator[Any]: ... + def all_prev(self, ret_type: _RetType | None = ...) -> Iterator[Any]: ... + def iter(self, ret_type: _RetType | None = ...) -> Iterator[Any]: ... def is_leap(self, year: int) -> bool: ... @classmethod def expand(cls, expr_format: Text) -> Tuple[List[List[str]], Dict[str, Any]]: ... diff --git a/stubs/cryptography/cryptography/fernet.pyi b/stubs/cryptography/cryptography/fernet.pyi index bdd985aed7ca..ec91ed0f4d15 100644 --- a/stubs/cryptography/cryptography/fernet.pyi +++ b/stubs/cryptography/cryptography/fernet.pyi @@ -3,11 +3,11 @@ from typing import List, Optional, Text, Union class InvalidToken(Exception): ... class Fernet(object): - def __init__(self, key: Union[bytes, Text]) -> None: ... - def decrypt(self, token: bytes, ttl: Optional[int] = ...) -> bytes: ... + def __init__(self, key: bytes | Text) -> None: ... + def decrypt(self, token: bytes, ttl: int | None = ...) -> bytes: ... # decrypt_at_time accepts None ttl at runtime but it's an implementtion detail and it doesn't really # make sense for the client code to use it like that, so the parameter is typed as int as opposed to - # Optional[int]. + # int | None. def decrypt_at_time(self, token: bytes, ttl: int, current_time: int) -> bytes: ... def encrypt(self, data: bytes) -> bytes: ... def encrypt_at_time(self, data: bytes, current_time: int) -> bytes: ... @@ -17,7 +17,7 @@ class Fernet(object): class MultiFernet(object): def __init__(self, fernets: List[Fernet]) -> None: ... - def decrypt(self, token: bytes, ttl: Optional[int] = ...) -> bytes: ... + def decrypt(self, token: bytes, ttl: int | None = ...) -> bytes: ... # See a note above on the typing of the ttl parameter. def decrypt_at_time(self, token: bytes, ttl: int, current_time: int) -> bytes: ... def encrypt(self, data: bytes) -> bytes: ... diff --git a/stubs/cryptography/cryptography/hazmat/backends/interfaces.pyi b/stubs/cryptography/cryptography/hazmat/backends/interfaces.pyi index 14bc3f38a5f2..f225f12baa90 100644 --- a/stubs/cryptography/cryptography/hazmat/backends/interfaces.pyi +++ b/stubs/cryptography/cryptography/hazmat/backends/interfaces.pyi @@ -60,13 +60,13 @@ class DERSerializationBackend(metaclass=ABCMeta): @abstractmethod def load_der_parameters(self, data: bytes) -> Any: ... @abstractmethod - def load_der_private_key(self, data: bytes, password: Optional[bytes]) -> Any: ... + def load_der_private_key(self, data: bytes, password: bytes | None) -> Any: ... @abstractmethod def load_der_public_key(self, data: bytes) -> Any: ... class DHBackend(metaclass=ABCMeta): @abstractmethod - def dh_parameters_supported(self, p: int, g: int, q: Optional[int]) -> bool: ... + def dh_parameters_supported(self, p: int, g: int, q: int | None) -> bool: ... @abstractmethod def dh_x942_serialization_supported(self) -> bool: ... @abstractmethod @@ -140,7 +140,7 @@ class PEMSerializationBackend(metaclass=ABCMeta): @abstractmethod def load_pem_parameters(self, data: bytes) -> Any: ... @abstractmethod - def load_pem_private_key(self, data: bytes, password: Optional[bytes]) -> Any: ... + def load_pem_private_key(self, data: bytes, password: bytes | None) -> Any: ... @abstractmethod def load_pem_public_key(self, data: bytes) -> Any: ... @@ -165,21 +165,21 @@ class X509Backend(metaclass=ABCMeta): def create_x509_certificate( self, builder: CertificateBuilder, - private_key: Union[DSAPrivateKey, EllipticCurvePrivateKey, RSAPrivateKey], + private_key: DSAPrivateKey | EllipticCurvePrivateKey | RSAPrivateKey, algorithm: HashAlgorithm, ) -> Certificate: ... @abstractmethod def create_x509_crl( self, builder: CertificateRevocationListBuilder, - private_key: Union[DSAPrivateKey, EllipticCurvePrivateKey, RSAPrivateKey], + private_key: DSAPrivateKey | EllipticCurvePrivateKey | RSAPrivateKey, algorithm: HashAlgorithm, ) -> CertificateRevocationList: ... @abstractmethod def create_x509_csr( self, builder: CertificateSigningRequestBuilder, - private_key: Union[DSAPrivateKey, EllipticCurvePrivateKey, RSAPrivateKey], + private_key: DSAPrivateKey | EllipticCurvePrivateKey | RSAPrivateKey, algorithm: HashAlgorithm, ) -> CertificateSigningRequest: ... @abstractmethod diff --git a/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi b/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi index 9fd46444e55f..f0d9955bd52b 100644 --- a/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi +++ b/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi @@ -1,6 +1,6 @@ from typing import Any, Optional class Binding(object): - ffi: Optional[Any] - lib: Optional[Any] + ffi: Any | None + lib: Any | None def init_static_locks(self) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi index 87dd3481ec8b..22d1b6c54607 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi @@ -27,8 +27,8 @@ class DHParameterNumbers(object): def g(self) -> int: ... @property def q(self) -> int: ... - def __init__(self, p: int, g: int, q: Optional[int]) -> None: ... - def parameters(self, backend: Optional[DHBackend] = ...) -> DHParameters: ... + def __init__(self, p: int, g: int, q: int | None) -> None: ... + def parameters(self, backend: DHBackend | None = ...) -> DHParameters: ... class DHPrivateKey(metaclass=ABCMeta): key_size: int @@ -53,7 +53,7 @@ class DHPrivateNumbers(object): @property def x(self) -> int: ... def __init__(self, x: int, public_numbers: DHPublicNumbers) -> None: ... - def private_key(self, backend: Optional[DHBackend] = ...) -> DHPrivateKey: ... + def private_key(self, backend: DHBackend | None = ...) -> DHPrivateKey: ... class DHPublicKey(metaclass=ABCMeta): @property @@ -74,6 +74,6 @@ class DHPublicNumbers(object): @property def y(self) -> int: ... def __init__(self, y: int, parameter_numbers: DHParameterNumbers) -> None: ... - def public_key(self, backend: Optional[DHBackend] = ...) -> DHPublicKey: ... + def public_key(self, backend: DHBackend | None = ...) -> DHPublicKey: ... -def generate_parameters(generator: int, key_size: int, backend: Optional[DHBackend] = ...) -> DHParameters: ... +def generate_parameters(generator: int, key_size: int, backend: DHBackend | None = ...) -> DHParameters: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi index 2a2323d9e07e..3580c910e3d7 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi @@ -23,7 +23,7 @@ class DSAParameterNumbers(object): @property def g(self) -> int: ... def __init__(self, p: int, q: int, g: int) -> None: ... - def parameters(self, backend: Optional[DSABackend] = ...) -> DSAParameters: ... + def parameters(self, backend: DSABackend | None = ...) -> DSAParameters: ... class DSAPrivateKey(metaclass=ABCMeta): @property @@ -34,7 +34,7 @@ class DSAPrivateKey(metaclass=ABCMeta): @abstractmethod def public_key(self) -> DSAPublicKey: ... @abstractmethod - def sign(self, data: bytes, algorithm: Union[HashAlgorithm, Prehashed]) -> bytes: ... + def sign(self, data: bytes, algorithm: HashAlgorithm | Prehashed) -> bytes: ... class DSAPrivateKeyWithSerialization(DSAPrivateKey): @abstractmethod @@ -61,10 +61,10 @@ class DSAPublicKey(metaclass=ABCMeta): def public_numbers(self) -> DSAPublicNumbers: ... @abstractmethod def verifier( - self, signature: bytes, signature_algorithm: Union[HashAlgorithm, Prehashed] + self, signature: bytes, signature_algorithm: HashAlgorithm | Prehashed ) -> AsymmetricVerificationContext: ... @abstractmethod - def verify(self, signature: bytes, data: bytes, algorithm: Union[HashAlgorithm, Prehashed]) -> None: ... + def verify(self, signature: bytes, data: bytes, algorithm: HashAlgorithm | Prehashed) -> None: ... DSAPublicKeyWithSerialization = DSAPublicKey @@ -75,5 +75,5 @@ class DSAPublicNumbers(object): def parameter_numbers(self) -> DSAParameterNumbers: ... def __init__(self, y: int, parameter_numbers: DSAParameterNumbers) -> None: ... -def generate_parameters(key_size: int, backend: Optional[DSABackend] = ...) -> DSAParameters: ... -def generate_private_key(key_size: int, backend: Optional[DSABackend] = ...) -> DSAPrivateKey: ... +def generate_parameters(key_size: int, backend: DSABackend | None = ...) -> DSAParameters: ... +def generate_private_key(key_size: int, backend: DSABackend | None = ...) -> DSAPrivateKey: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi index cfdd031fa27b..7cee69646258 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi @@ -141,7 +141,7 @@ class EllipticCurvePrivateNumbers(object): @property def public_numbers(self) -> EllipticCurvePublicNumbers: ... def __init__(self, private_value: int, public_numbers: EllipticCurvePublicNumbers) -> None: ... - def private_key(self, backend: Optional[EllipticCurveBackend] = ...) -> EllipticCurvePrivateKey: ... + def private_key(self, backend: EllipticCurveBackend | None = ...) -> EllipticCurvePrivateKey: ... class EllipticCurvePublicKey(metaclass=ABCMeta): @property @@ -175,22 +175,22 @@ class EllipticCurvePublicNumbers(object): def __init__(self, x: int, y: int, curve: EllipticCurve) -> None: ... @classmethod def from_encoded_point(cls, curve: EllipticCurve, data: bytes) -> EllipticCurvePublicNumbers: ... - def public_key(self, backend: Optional[EllipticCurveBackend] = ...) -> EllipticCurvePublicKey: ... + def public_key(self, backend: EllipticCurveBackend | None = ...) -> EllipticCurvePublicKey: ... class EllipticCurveSignatureAlgorithm(metaclass=ABCMeta): @property @abstractmethod - def algorithm(self) -> Union[HashAlgorithm, Prehashed]: ... + def algorithm(self) -> HashAlgorithm | Prehashed: ... class ECDH(object): ... class ECDSA(EllipticCurveSignatureAlgorithm): - def __init__(self, algorithm: Union[HashAlgorithm, Prehashed]): ... + def __init__(self, algorithm: HashAlgorithm | Prehashed): ... @property - def algorithm(self) -> Union[HashAlgorithm, Prehashed]: ... + def algorithm(self) -> HashAlgorithm | Prehashed: ... def derive_private_key( - private_value: int, curve: EllipticCurve, backend: Optional[EllipticCurveBackend] = ... + private_value: int, curve: EllipticCurve, backend: EllipticCurveBackend | None = ... ) -> EllipticCurvePrivateKey: ... -def generate_private_key(curve: EllipticCurve, backend: Optional[EllipticCurveBackend] = ...) -> EllipticCurvePrivateKey: ... +def generate_private_key(curve: EllipticCurve, backend: EllipticCurveBackend | None = ...) -> EllipticCurvePrivateKey: ... def get_curve_for_oid(oid: ObjectIdentifier) -> EllipticCurve: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi index 233cf4fd7fa6..c12c34ac49ce 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi @@ -12,7 +12,7 @@ class MGF1(object): def __init__(self, algorithm: HashAlgorithm) -> None: ... class OAEP(AsymmetricPadding): - def __init__(self, mgf: MGF1, algorithm: HashAlgorithm, label: Optional[bytes]) -> None: ... + def __init__(self, mgf: MGF1, algorithm: HashAlgorithm, label: bytes | None) -> None: ... @property def name(self) -> str: ... @@ -22,6 +22,6 @@ class PKCS1v15(AsymmetricPadding): class PSS(AsymmetricPadding): MAX_LENGTH: ClassVar[object] - def __init__(self, mgf: MGF1, salt_length: Union[int, object]) -> None: ... + def __init__(self, mgf: MGF1, salt_length: int | object) -> None: ... @property def name(self) -> str: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi index 35acc5b13448..8af772c44f66 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi @@ -17,7 +17,7 @@ class RSAPrivateKey(metaclass=ABCMeta): @abstractmethod def public_key(self) -> RSAPublicKey: ... @abstractmethod - def sign(self, data: bytes, padding: AsymmetricPadding, algorithm: Union[HashAlgorithm, Prehashed]) -> bytes: ... + def sign(self, data: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed) -> bytes: ... class RSAPrivateKeyWithSerialization(RSAPrivateKey): @abstractmethod @@ -39,17 +39,17 @@ class RSAPublicKey(metaclass=ABCMeta): def public_numbers(self) -> RSAPublicNumbers: ... @abstractmethod def verifier( - self, signature: bytes, padding: AsymmetricPadding, algorithm: Union[HashAlgorithm, Prehashed] + self, signature: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed ) -> AsymmetricVerificationContext: ... @abstractmethod def verify( - self, signature: bytes, data: bytes, padding: AsymmetricPadding, algorithm: Union[HashAlgorithm, Prehashed] + self, signature: bytes, data: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed ) -> None: ... RSAPublicKeyWithSerialization = RSAPublicKey def generate_private_key( - public_exponent: int, key_size: int, backend: Optional[RSABackend] = ... + public_exponent: int, key_size: int, backend: RSABackend | None = ... ) -> RSAPrivateKeyWithSerialization: ... def rsa_crt_iqmp(p: int, q: int) -> int: ... def rsa_crt_dmp1(private_exponent: int, p: int) -> int: ... @@ -72,7 +72,7 @@ class RSAPrivateNumbers(object): def iqmp(self) -> int: ... @property def public_numbers(self) -> RSAPublicNumbers: ... - def private_key(self, backend: Optional[RSABackend] = ...) -> RSAPrivateKey: ... + def private_key(self, backend: RSABackend | None = ...) -> RSAPrivateKey: ... class RSAPublicNumbers(object): def __init__(self, e: int, n: int) -> None: ... @@ -80,4 +80,4 @@ class RSAPublicNumbers(object): def e(self) -> int: ... @property def n(self) -> int: ... - def public_key(self, backend: Optional[RSABackend] = ...) -> RSAPublicKey: ... + def public_key(self, backend: RSABackend | None = ...) -> RSAPublicKey: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi index 08f4c746735f..0cf569aca838 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi @@ -23,7 +23,7 @@ class BlockCipherAlgorithm(metaclass=ABCMeta): def block_size(self) -> int: ... class Cipher(object): - def __init__(self, algorithm: CipherAlgorithm, mode: Optional[Mode], backend: Optional[CipherBackend] = ...) -> None: ... + def __init__(self, algorithm: CipherAlgorithm, mode: Mode | None, backend: CipherBackend | None = ...) -> None: ... def decryptor(self) -> CipherContext: ... def encryptor(self) -> CipherContext: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi index 68b3dc19a965..fe74280e5993 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi @@ -1,22 +1,22 @@ from typing import Optional class AESCCM(object): - def __init__(self, key: bytes, tag_length: Optional[int]) -> None: ... - def decrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ... - def encrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ... + def __init__(self, key: bytes, tag_length: int | None) -> None: ... + def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ... + def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ... @classmethod def generate_key(cls, bit_length: int) -> bytes: ... class AESGCM(object): def __init__(self, key: bytes) -> None: ... - def decrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ... - def encrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ... + def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ... + def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ... @classmethod def generate_key(cls, bit_length: int) -> bytes: ... class ChaCha20Poly1305(object): def __init__(self, key: bytes) -> None: ... - def decrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ... - def encrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ... + def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ... + def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ... @classmethod def generate_key(cls) -> bytes: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyi index 633f3b169c89..98e6e693ba28 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyi @@ -68,7 +68,7 @@ class ECB(Mode): def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ... class GCM(Mode, ModeWithInitializationVector, ModeWithAuthenticationTag): - def __init__(self, initialization_vector: bytes, tag: Optional[bytes], min_tag_length: Optional[int]) -> None: ... + def __init__(self, initialization_vector: bytes, tag: bytes | None, min_tag_length: int | None) -> None: ... @property def initialization_vector(self) -> bytes: ... @property diff --git a/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi b/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi index 60c30134308f..11cd34711e3e 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi @@ -4,7 +4,7 @@ from cryptography.hazmat.backends.interfaces import CMACBackend from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm class CMAC(object): - def __init__(self, algorithm: BlockCipherAlgorithm, backend: Optional[CMACBackend] = ...) -> None: ... + def __init__(self, algorithm: BlockCipherAlgorithm, backend: CMACBackend | None = ...) -> None: ... def copy(self) -> CMAC: ... def finalize(self) -> bytes: ... def update(self, data: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi b/stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi index d6e31dc0128c..f0a426a7957f 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi @@ -38,7 +38,7 @@ class SHAKE256(HashAlgorithm): def __init__(self, digest_size: int) -> None: ... class Hash(HashContext): - def __init__(self, algorithm: HashAlgorithm, backend: Optional[HashBackend] = ...): ... + def __init__(self, algorithm: HashAlgorithm, backend: HashBackend | None = ...): ... def copy(self) -> Hash: ... def finalize(self) -> bytes: ... def update(self, data: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi b/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi index 15420ca2c28d..2e63a96c459e 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi @@ -4,7 +4,7 @@ from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm class HMAC(object): - def __init__(self, key: bytes, algorithm: HashAlgorithm, backend: Optional[HMACBackend] = ...) -> None: ... + def __init__(self, key: bytes, algorithm: HashAlgorithm, backend: HMACBackend | None = ...) -> None: ... def copy(self) -> HMAC: ... def finalize(self) -> bytes: ... def update(self, msg: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi index 7e0b36ff7a0c..d1964dd22e9a 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi @@ -6,7 +6,7 @@ from cryptography.hazmat.primitives.kdf import KeyDerivationFunction class ConcatKDFHash(KeyDerivationFunction): def __init__( - self, algorithm: HashAlgorithm, length: int, otherinfo: Optional[bytes], backend: Optional[HashBackend] = ... + self, algorithm: HashAlgorithm, length: int, otherinfo: bytes | None, backend: HashBackend | None = ... ): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... @@ -16,9 +16,9 @@ class ConcatKDFHMAC(KeyDerivationFunction): self, algorithm: HashAlgorithm, length: int, - salt: Optional[bytes], - otherinfo: Optional[bytes], - backend: Optional[HMACBackend] = ..., + salt: bytes | None, + otherinfo: bytes | None, + backend: HMACBackend | None = ..., ): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi index 16997ab51f84..5c497400c1c2 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi @@ -9,14 +9,14 @@ class HKDF(KeyDerivationFunction): self, algorithm: HashAlgorithm, length: int, - salt: Optional[bytes], - info: Optional[bytes], - backend: Optional[HMACBackend] = ..., + salt: bytes | None, + info: bytes | None, + backend: HMACBackend | None = ..., ): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... class HKDFExpand(KeyDerivationFunction): - def __init__(self, algorithm: HashAlgorithm, length: int, info: Optional[bytes], backend: Optional[HMACBackend] = ...): ... + def __init__(self, algorithm: HashAlgorithm, length: int, info: bytes | None, backend: HMACBackend | None = ...): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi index 1e8b69eb702e..3bff4fb0830b 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi @@ -21,10 +21,10 @@ class KBKDFHMAC(KeyDerivationFunction): rlen: int, llen: int, location: CounterLocation, - label: Optional[bytes], - context: Optional[bytes], - fixed: Optional[bytes], - backend: Optional[HMACBackend] = ..., + label: bytes | None, + context: bytes | None, + fixed: bytes | None, + backend: HMACBackend | None = ..., ): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi index 8953cf973db2..58411b85ea29 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi @@ -6,7 +6,7 @@ from cryptography.hazmat.primitives.kdf import KeyDerivationFunction class PBKDF2HMAC(KeyDerivationFunction): def __init__( - self, algorithm: HashAlgorithm, length: int, salt: bytes, iterations: int, backend: Optional[PBKDF2HMACBackend] = ... + self, algorithm: HashAlgorithm, length: int, salt: bytes, iterations: int, backend: PBKDF2HMACBackend | None = ... ): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi index 7f24125f28b6..0d5169658a1f 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi @@ -4,6 +4,6 @@ from cryptography.hazmat.backends.interfaces import ScryptBackend from cryptography.hazmat.primitives.kdf import KeyDerivationFunction class Scrypt(KeyDerivationFunction): - def __init__(self, salt: bytes, length: int, n: int, r: int, p: int, backend: Optional[ScryptBackend] = ...): ... + def __init__(self, salt: bytes, length: int, n: int, r: int, p: int, backend: ScryptBackend | None = ...): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi index 80aa289c3b46..7e655a6fd639 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi @@ -6,7 +6,7 @@ from cryptography.hazmat.primitives.kdf import KeyDerivationFunction class X963KDF(KeyDerivationFunction): def __init__( - self, algorithm: HashAlgorithm, length: int, sharedinfo: Optional[bytes], backend: Optional[HashBackend] = ... + self, algorithm: HashAlgorithm, length: int, sharedinfo: bytes | None, backend: HashBackend | None = ... ): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi b/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi index 6aa3e64bd435..bf08ecc0ccef 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi @@ -2,9 +2,9 @@ from typing import Optional from cryptography.hazmat.backends.interfaces import CipherBackend -def aes_key_wrap(wrapping_key: bytes, key_to_wrap: bytes, backend: Optional[CipherBackend] = ...) -> bytes: ... -def aes_key_wrap_with_padding(wrapping_key: bytes, key_to_wrap: bytes, backend: Optional[CipherBackend] = ...) -> bytes: ... -def aes_key_unwrap(wrapping_key: bytes, wrapped_key: bytes, backend: Optional[CipherBackend] = ...) -> bytes: ... -def aes_key_unwrap_with_padding(wrapping_key: bytes, wrapped_key: bytes, backend: Optional[CipherBackend] = ...) -> bytes: ... +def aes_key_wrap(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend | None = ...) -> bytes: ... +def aes_key_wrap_with_padding(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend | None = ...) -> bytes: ... +def aes_key_unwrap(wrapping_key: bytes, wrapped_key: bytes, backend: CipherBackend | None = ...) -> bytes: ... +def aes_key_unwrap_with_padding(wrapping_key: bytes, wrapped_key: bytes, backend: CipherBackend | None = ...) -> bytes: ... class InvalidUnwrap(Exception): ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/serialization/__init__.pyi b/stubs/cryptography/cryptography/hazmat/primitives/serialization/__init__.pyi index 1eedc9480d01..61960c881cbf 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/serialization/__init__.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/serialization/__init__.pyi @@ -11,20 +11,20 @@ from cryptography.hazmat.backends.interfaces import ( ) def load_pem_private_key( - data: bytes, password: Optional[bytes], backend: Optional[PEMSerializationBackend] = ... -) -> Any: ... # actually Union[RSAPrivateKey, DSAPrivateKey, DHPrivateKey, EllipticCurvePrivateKey] + data: bytes, password: bytes | None, backend: PEMSerializationBackend | None = ... +) -> Any: ... # actually RSAPrivateKey | DSAPrivateKey | DHPrivateKey | EllipticCurvePrivateKey def load_pem_public_key( - data: bytes, backend: Optional[PEMSerializationBackend] = ... -) -> Any: ... # actually Union[RSAPublicKey, DSAPublicKey, DHPublicKey, EllipticCurvePublicKey] + data: bytes, backend: PEMSerializationBackend | None = ... +) -> Any: ... # actually RSAPublicKey | DSAPublicKey | DHPublicKey | EllipticCurvePublicKey def load_der_private_key( - data: bytes, password: Optional[bytes], backend: Optional[DERSerializationBackend] = ... -) -> Any: ... # actually Union[RSAPrivateKey, DSAPrivateKey, DHPrivateKey, EllipticCurvePrivateKey] + data: bytes, password: bytes | None, backend: DERSerializationBackend | None = ... +) -> Any: ... # actually RSAPrivateKey | DSAPrivateKey | DHPrivateKey | EllipticCurvePrivateKey def load_der_public_key( - data: bytes, backend: Optional[DERSerializationBackend] = ... -) -> Any: ... # actually Union[RSAPublicKey, DSAPublicKey, DHPublicKey, EllipticCurvePublicKey] + data: bytes, backend: DERSerializationBackend | None = ... +) -> Any: ... # actually RSAPublicKey | DSAPublicKey | DHPublicKey | EllipticCurvePublicKey def load_ssh_public_key( - data: bytes, backend: Union[RSABackend, DSABackend, EllipticCurveBackend, None] = ... -) -> Any: ... # actually Union[RSAPublicKey, DSAPublicKey, DHPublicKey, EllipticCurvePublicKey, Ed25519PublicKey] + data: bytes, backend: RSABackend | DSABackend | EllipticCurveBackend | None = ... +) -> Any: ... # actually RSAPublicKey | DSAPublicKey | DHPublicKey | EllipticCurvePublicKey | Ed25519PublicKey class Encoding(Enum): PEM: str diff --git a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs12.pyi b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs12.pyi index 101eb26fe243..cde76ee63238 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs12.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs12.pyi @@ -7,12 +7,12 @@ from cryptography.hazmat.primitives.serialization import KeySerializationEncrypt from cryptography.x509 import Certificate def load_key_and_certificates( - data: bytes, password: Optional[bytes], backend: Optional[Any] = ... -) -> Tuple[Optional[Any], Optional[Certificate], List[Certificate]]: ... + data: bytes, password: bytes | None, backend: Any | None = ... +) -> Tuple[Any | None, Certificate | None, List[Certificate]]: ... def serialize_key_and_certificates( name: bytes, - key: Union[RSAPrivateKeyWithSerialization, EllipticCurvePrivateKeyWithSerialization, DSAPrivateKeyWithSerialization], - cert: Optional[Certificate], - cas: Optional[List[Certificate]], + key: RSAPrivateKeyWithSerialization | EllipticCurvePrivateKeyWithSerialization | DSAPrivateKeyWithSerialization, + cert: Certificate | None, + cas: List[Certificate] | None, enc: KeySerializationEncryption, ) -> bytes: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi index 582d9a74c21f..1973fc03153f 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi @@ -23,8 +23,8 @@ class PKCS7SignatureBuilder: def add_signer( self, certificate: Certificate, - private_key: Union[RSAPrivateKey, EllipticCurvePrivateKey], - hash_algorithm: Union[SHA1, SHA224, SHA256, SHA384, SHA512], + private_key: RSAPrivateKey | EllipticCurvePrivateKey, + hash_algorithm: SHA1 | SHA224 | SHA256 | SHA384 | SHA512, ) -> PKCS7SignatureBuilder: ... def add_certificate(self, certificate: Certificate) -> PKCS7SignatureBuilder: ... - def sign(self, encoding: Encoding, options: Iterable[PKCS7Options], backend: Optional[Any] = ...) -> bytes: ... + def sign(self, encoding: Encoding, options: Iterable[PKCS7Options], backend: Any | None = ...) -> bytes: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi index c1e5607e0947..a5eb582f8614 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi @@ -9,9 +9,9 @@ class HOTP(object): key: bytes, length: int, algorithm: HashAlgorithm, - backend: Optional[HMACBackend] = ..., + backend: HMACBackend | None = ..., enforce_key_length: bool = ..., ): ... def generate(self, counter: int) -> bytes: ... - def get_provisioning_uri(self, account_name: str, counter: int, issuer: Optional[str]) -> str: ... + def get_provisioning_uri(self, account_name: str, counter: int, issuer: str | None) -> str: ... def verify(self, hotp: bytes, counter: int) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi index 1525910879ba..9730043b05f3 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi @@ -10,9 +10,9 @@ class TOTP(object): length: int, algorithm: HashAlgorithm, time_step: int, - backend: Optional[HMACBackend] = ..., + backend: HMACBackend | None = ..., enforce_key_length: bool = ..., ): ... def generate(self, time: int) -> bytes: ... - def get_provisioning_uri(self, account_name: str, issuer: Optional[str]) -> str: ... + def get_provisioning_uri(self, account_name: str, issuer: str | None) -> str: ... def verify(self, totp: bytes, time: int) -> None: ... diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index 316e0ecc7109..7f12e6b040ed 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -119,11 +119,11 @@ class RelativeDistinguishedName(object): class Name(object): rdns: List[RelativeDistinguishedName] - def __init__(self, attributes: Sequence[Union[NameAttribute, RelativeDistinguishedName]]) -> None: ... + def __init__(self, attributes: Sequence[NameAttribute | RelativeDistinguishedName]) -> None: ... def __iter__(self) -> Generator[NameAttribute, None, None]: ... def __len__(self) -> int: ... def get_attributes_for_oid(self, oid: ObjectIdentifier) -> List[NameAttribute]: ... - def public_bytes(self, backend: Optional[X509Backend] = ...) -> bytes: ... + def public_bytes(self, backend: X509Backend | None = ...) -> bytes: ... def rfc4514_string(self) -> str: ... class Version(Enum): @@ -147,32 +147,32 @@ class Certificate(metaclass=ABCMeta): @abstractmethod def public_bytes(self, encoding: Encoding) -> bytes: ... @abstractmethod - def public_key(self) -> Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey]: ... + def public_key(self) -> DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey: ... class CertificateBuilder(object): def __init__( self, - issuer_name: Optional[Name] = ..., - subject_name: Optional[Name] = ..., - public_key: Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey, None] = ..., - serial_number: Optional[int] = ..., - not_valid_before: Optional[datetime.datetime] = ..., - not_valid_after: Optional[datetime.datetime] = ..., - extensions: Optional[Iterable[ExtensionType]] = ..., + issuer_name: Name | None = ..., + subject_name: Name | None = ..., + public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey | None = ..., + serial_number: int | None = ..., + not_valid_before: datetime.datetime | None = ..., + not_valid_after: datetime.datetime | None = ..., + extensions: Iterable[ExtensionType] | None = ..., ) -> None: ... def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateBuilder: ... def issuer_name(self, name: Name) -> CertificateBuilder: ... def not_valid_after(self, time: datetime.datetime) -> CertificateBuilder: ... def not_valid_before(self, time: datetime.datetime) -> CertificateBuilder: ... def public_key( - self, public_key: Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey] + self, public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey ) -> CertificateBuilder: ... def serial_number(self, serial_number: int) -> CertificateBuilder: ... def sign( self, - private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey], - algorithm: Optional[HashAlgorithm], - backend: Optional[X509Backend] = ..., + private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey, + algorithm: HashAlgorithm | None, + backend: X509Backend | None = ..., ) -> Certificate: ... def subject_name(self, name: Name) -> CertificateBuilder: ... @@ -191,7 +191,7 @@ class CertificateRevocationList(metaclass=ABCMeta): def get_revoked_certificate_by_serial_number(self, serial_number: int) -> RevokedCertificate: ... @abstractmethod def is_signature_valid( - self, public_key: Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey] + self, public_key: DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey ) -> bool: ... @abstractmethod def public_bytes(self, encoding: Encoding) -> bytes: ... @@ -204,9 +204,9 @@ class CertificateRevocationListBuilder(object): def next_update(self, time: datetime.datetime) -> CertificateRevocationListBuilder: ... def sign( self, - private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey], - algorithm: Optional[HashAlgorithm], - backend: Optional[X509Backend] = ..., + private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey, + algorithm: HashAlgorithm | None, + backend: X509Backend | None = ..., ) -> CertificateRevocationList: ... class CertificateSigningRequest(metaclass=ABCMeta): @@ -220,16 +220,16 @@ class CertificateSigningRequest(metaclass=ABCMeta): @abstractmethod def public_bytes(self, encoding: Encoding) -> bytes: ... @abstractmethod - def public_key(self) -> Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey]: ... + def public_key(self) -> DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey: ... class CertificateSigningRequestBuilder(object): def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateSigningRequestBuilder: ... def subject_name(self, name: Name) -> CertificateSigningRequestBuilder: ... def sign( self, - private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey], - algorithm: Optional[HashAlgorithm], - backend: Optional[X509Backend] = ..., + private_key: DSAPrivateKey | Ed25519PrivateKey | Ed448PrivateKey | EllipticCurvePrivateKey | RSAPrivateKey, + algorithm: HashAlgorithm | None, + backend: X509Backend | None = ..., ) -> CertificateSigningRequest: ... class RevokedCertificate(metaclass=ABCMeta): @@ -239,7 +239,7 @@ class RevokedCertificate(metaclass=ABCMeta): class RevokedCertificateBuilder(object): def add_extension(self, extension: ExtensionType, critical: bool) -> RevokedCertificateBuilder: ... - def build(self, backend: Optional[X509Backend] = ...) -> RevokedCertificate: ... + def build(self, backend: X509Backend | None = ...) -> RevokedCertificate: ... def revocation_date(self, time: datetime.datetime) -> RevokedCertificateBuilder: ... def serial_number(self, serial_number: int) -> RevokedCertificateBuilder: ... @@ -257,8 +257,8 @@ class DNSName(GeneralName): def __init__(self, value: Text) -> None: ... class IPAddress(GeneralName): - value: Union[IPv4Address, IPv6Address, IPv4Network, IPv6Network] - def __init__(self, value: Union[IPv4Address, IPv6Address, IPv4Network, IPv6Network]) -> None: ... + value: IPv4Address | IPv6Address | IPv4Network | IPv6Network + def __init__(self, value: IPv4Address | IPv6Address | IPv4Network | IPv6Network) -> None: ... class OtherName(GeneralName): type_id: ObjectIdentifier @@ -317,18 +317,18 @@ class AuthorityKeyIdentifier(ExtensionType): @property def key_identifier(self) -> bytes: ... @property - def authority_cert_issuer(self) -> Optional[List[GeneralName]]: ... + def authority_cert_issuer(self) -> List[GeneralName] | None: ... @property - def authority_cert_serial_number(self) -> Optional[int]: ... + def authority_cert_serial_number(self) -> int | None: ... def __init__( self, key_identifier: bytes, - authority_cert_issuer: Optional[Iterable[GeneralName]], - authority_cert_serial_number: Optional[int], + authority_cert_issuer: Iterable[GeneralName] | None, + authority_cert_serial_number: int | None, ) -> None: ... @classmethod def from_issuer_public_key( - cls, public_key: Union[RSAPublicKey, DSAPublicKey, EllipticCurvePublicKey, Ed25519PublicKey, Ed448PublicKey] + cls, public_key: RSAPublicKey | DSAPublicKey | EllipticCurvePublicKey | Ed25519PublicKey | Ed448PublicKey ) -> AuthorityKeyIdentifier: ... @classmethod def from_issuer_subject_key_identifier(cls, ski: SubjectKeyIdentifier) -> AuthorityKeyIdentifier: ... @@ -339,7 +339,7 @@ class SubjectKeyIdentifier(ExtensionType): def __init__(self, digest: bytes) -> None: ... @classmethod def from_public_key( - cls, public_key: Union[RSAPublicKey, DSAPublicKey, EllipticCurvePublicKey, Ed25519PublicKey, Ed448PublicKey] + cls, public_key: RSAPublicKey | DSAPublicKey | EllipticCurvePublicKey | Ed25519PublicKey | Ed448PublicKey ) -> SubjectKeyIdentifier: ... class AccessDescription: @@ -365,8 +365,8 @@ class BasicConstraints(ExtensionType): @property def ca(self) -> bool: ... @property - def path_length(self) -> Optional[int]: ... - def __init__(self, ca: bool, path_length: Optional[int]) -> None: ... + def path_length(self) -> int | None: ... + def __init__(self, ca: bool, path_length: int | None) -> None: ... class KeyUsage(ExtensionType): @property @@ -411,10 +411,10 @@ class UnrecognizedExtension(ExtensionType): def value(self) -> bytes: ... def __init__(self, oid: ObjectIdentifier, value: bytes) -> None: ... -def load_der_x509_certificate(data: bytes, backend: Optional[X509Backend] = ...) -> Certificate: ... -def load_pem_x509_certificate(data: bytes, backend: Optional[X509Backend] = ...) -> Certificate: ... -def load_der_x509_crl(data: bytes, backend: Optional[X509Backend] = ...) -> CertificateRevocationList: ... -def load_pem_x509_crl(data: bytes, backend: Optional[X509Backend] = ...) -> CertificateRevocationList: ... -def load_der_x509_csr(data: bytes, backend: Optional[X509Backend] = ...) -> CertificateSigningRequest: ... -def load_pem_x509_csr(data: bytes, backend: Optional[X509Backend] = ...) -> CertificateSigningRequest: ... +def load_der_x509_certificate(data: bytes, backend: X509Backend | None = ...) -> Certificate: ... +def load_pem_x509_certificate(data: bytes, backend: X509Backend | None = ...) -> Certificate: ... +def load_der_x509_crl(data: bytes, backend: X509Backend | None = ...) -> CertificateRevocationList: ... +def load_pem_x509_crl(data: bytes, backend: X509Backend | None = ...) -> CertificateRevocationList: ... +def load_der_x509_csr(data: bytes, backend: X509Backend | None = ...) -> CertificateSigningRequest: ... +def load_pem_x509_csr(data: bytes, backend: X509Backend | None = ...) -> CertificateSigningRequest: ... def __getattr__(name: str) -> Any: ... # incomplete diff --git a/stubs/cryptography/cryptography/x509/oid.pyi b/stubs/cryptography/cryptography/x509/oid.pyi index 5168feeddd59..5687c1c9690d 100644 --- a/stubs/cryptography/cryptography/x509/oid.pyi +++ b/stubs/cryptography/cryptography/x509/oid.pyi @@ -103,4 +103,4 @@ class CertificatePoliciesOID: _OID_NAMES: Dict[ObjectIdentifier, str] = ... -_SIG_OIDS_TO_HASH: Dict[ObjectIdentifier, Optional[HashAlgorithm]] = ... +_SIG_OIDS_TO_HASH: Dict[ObjectIdentifier, HashAlgorithm | None] = ... diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index eb7e5e26a057..587c26391ec0 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -33,7 +33,7 @@ class Field(Generic[_T]): default: _T default_factory: Callable[[], _T] repr: bool - hash: Optional[bool] + hash: bool | None init: bool compare: bool metadata: Mapping[str, Any] @@ -48,9 +48,9 @@ def field( default: _T, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., ) -> _T: ... @overload def field( @@ -58,18 +58,18 @@ def field( default_factory: Callable[[], _T], init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., ) -> _T: ... @overload def field( *, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., ) -> Any: ... def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... def is_dataclass(obj: Any) -> bool: ... @@ -82,10 +82,10 @@ class InitVar(Generic[_T]): def make_dataclass( cls_name: str, - fields: Iterable[Union[str, Tuple[str, type], Tuple[str, type, Field[Any]]]], + fields: Iterable[str | Tuple[str, type] | Tuple[str, type, Field[Any]]], *, bases: Tuple[type, ...] = ..., - namespace: Optional[Dict[str, Any]] = ..., + namespace: Dict[str, Any] | None = ..., init: bool = ..., repr: bool = ..., eq: bool = ..., diff --git a/stubs/dateparser/dateparser.pyi b/stubs/dateparser/dateparser.pyi index dcb053ebdfb6..1603fcbd24e5 100644 --- a/stubs/dateparser/dateparser.pyi +++ b/stubs/dateparser/dateparser.pyi @@ -5,10 +5,10 @@ __version__: str def parse( date_string: str, - date_formats: Optional[Union[List[str], Tuple[str], Set[str]]] = ..., - languages: Optional[Union[List[str], Tuple[str], Set[str]]] = ..., - locales: Optional[Union[List[str], Tuple[str], Set[str]]] = ..., - region: Optional[str] = ..., - settings: Optional[Mapping[str, Any]] = ..., -) -> Optional[datetime.datetime]: ... + date_formats: List[str] | Tuple[str] | Set[str] | None = ..., + languages: List[str] | Tuple[str] | Set[str] | None = ..., + locales: List[str] | Tuple[str] | Set[str] | None = ..., + region: str | None = ..., + settings: Mapping[str, Any] | None = ..., +) -> datetime.datetime | None: ... def __getattr__(name: str) -> Any: ... # incomplete diff --git a/stubs/decorator/decorator.pyi b/stubs/decorator/decorator.pyi index 28f52a735a33..f660544ea331 100644 --- a/stubs/decorator/decorator.pyi +++ b/stubs/decorator/decorator.pyi @@ -12,8 +12,8 @@ if sys.version_info >= (3,): else: class FullArgSpec(NamedTuple): args: List[str] - varargs: Optional[str] - varkw: Optional[str] + varargs: str | None + varkw: str | None defaults: Tuple[Any, ...] kwonlyargs: List[str] kwonlydefaults: Dict[str, Any] @@ -30,31 +30,31 @@ DEF: Pattern[str] class FunctionMaker(object): args: List[Text] - varargs: Optional[Text] - varkw: Optional[Text] + varargs: Text | None + varkw: Text | None defaults: Tuple[Any, ...] kwonlyargs: List[Text] - kwonlydefaults: Optional[Text] - shortsignature: Optional[Text] + kwonlydefaults: Text | None + shortsignature: Text | None name: Text - doc: Optional[Text] - module: Optional[Text] + doc: Text | None + module: Text | None annotations: Dict[Text, Any] signature: Text dict: Dict[Text, Any] def __init__( self, - func: Optional[Callable[..., Any]] = ..., - name: Optional[Text] = ..., - signature: Optional[Text] = ..., - defaults: Optional[Tuple[Any, ...]] = ..., - doc: Optional[Text] = ..., - module: Optional[Text] = ..., - funcdict: Optional[Dict[Text, Any]] = ..., + func: Callable[..., Any] | None = ..., + name: Text | None = ..., + signature: Text | None = ..., + defaults: Tuple[Any, ...] | None = ..., + doc: Text | None = ..., + module: Text | None = ..., + funcdict: Dict[Text, Any] | None = ..., ) -> None: ... def update(self, func: Any, **kw: Any) -> None: ... def make( - self, src_templ: Text, evaldict: Optional[Dict[Text, Any]] = ..., addsource: bool = ..., **attrs: Any + self, src_templ: Text, evaldict: Dict[Text, Any] | None = ..., addsource: bool = ..., **attrs: Any ) -> Callable[..., Any]: ... @classmethod def create( @@ -62,16 +62,16 @@ class FunctionMaker(object): obj: Any, body: Text, evaldict: Dict[Text, Any], - defaults: Optional[Tuple[Any, ...]] = ..., - doc: Optional[Text] = ..., - module: Optional[Text] = ..., + defaults: Tuple[Any, ...] | None = ..., + doc: Text | None = ..., + module: Text | None = ..., addsource: bool = ..., **attrs: Any, ) -> Callable[..., Any]: ... def decorate(func: _Func, caller: Callable[..., Any], extras: Any = ...) -> _Func: ... def decorator( - caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ... + caller: Callable[..., Any], _func: Callable[..., Any] | None = ... ) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ... class ContextManager(_GeneratorContextManager[_T]): diff --git a/stubs/docopt/docopt.pyi b/stubs/docopt/docopt.pyi index 10292ed7995f..06eccd44448f 100644 --- a/stubs/docopt/docopt.pyi +++ b/stubs/docopt/docopt.pyi @@ -5,5 +5,5 @@ __version__: str _Argv = Union[Iterable[str], str] def docopt( - doc: str, argv: Optional[_Argv] = ..., help: bool = ..., version: Optional[Any] = ..., options_first: bool = ... -) -> dict[str, Any]: ... # Really should be dict[str, Union[str, bool]] + doc: str, argv: _Argv | None = ..., help: bool = ..., version: Any | None = ..., options_first: bool = ... +) -> dict[str, Any]: ... # Really should be dict[str, str | bool] diff --git a/stubs/docutils/docutils/__init__.pyi b/stubs/docutils/docutils/__init__.pyi index c90ca74f17aa..4d7cdc5c9ae1 100644 --- a/stubs/docutils/docutils/__init__.pyi +++ b/stubs/docutils/docutils/__init__.pyi @@ -24,11 +24,11 @@ class DataError(ApplicationError): ... class SettingsSpec: settings_spec: ClassVar[Tuple[Any, ...]] - settings_defaults: ClassVar[Optional[dict[Any, Any]]] - settings_default_overrides: ClassVar[Optional[dict[Any, Any]]] + settings_defaults: ClassVar[dict[Any, Any] | None] + settings_default_overrides: ClassVar[dict[Any, Any] | None] relative_path_settings: ClassVar[Tuple[Any, ...]] - config_section: ClassVar[Optional[str]] - config_section_dependencies: ClassVar[Optional[Tuple[str, ...]]] + config_section: ClassVar[str | None] + config_section_dependencies: ClassVar[Tuple[str, ...] | None] class TransformSpec: def get_transforms(self) -> list[Any]: ... @@ -36,6 +36,6 @@ class TransformSpec: unknown_reference_resolvers: ClassVar[list[Any]] class Component(SettingsSpec, TransformSpec): - component_type: ClassVar[Optional[str]] + component_type: ClassVar[str | None] supported: ClassVar[Tuple[str, ...]] def supports(self, format: str) -> bool: ... diff --git a/stubs/docutils/docutils/frontend.pyi b/stubs/docutils/docutils/frontend.pyi index ea3eed086c03..554b2afa676e 100644 --- a/stubs/docutils/docutils/frontend.pyi +++ b/stubs/docutils/docutils/frontend.pyi @@ -9,41 +9,41 @@ __docformat__: str def store_multiple(option, opt, value, parser, *args, **kwargs) -> None: ... def read_config_file(option, opt, value, parser) -> None: ... -def validate_encoding(setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ...): ... +def validate_encoding(setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ...): ... def validate_encoding_error_handler( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ): ... def validate_encoding_and_error_handler( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ): ... def validate_boolean( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> bool: ... def validate_nonnegative_int( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> int: ... def validate_threshold( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> int: ... def validate_colon_separated_string_list( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> list[str]: ... def validate_comma_separated_list( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> list[str]: ... def validate_url_trailing_slash( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> str: ... def validate_dependency_file( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> DependencyList: ... def validate_strip_class( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ): ... def validate_smartquotes_locales( - setting, value, option_parser, config_parser: Optional[Any] = ..., config_section: Optional[Any] = ... + setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> list[tuple[str, str]]: ... -def make_paths_absolute(pathdict, keys, base_path: Optional[Any] = ...) -> None: ... +def make_paths_absolute(pathdict, keys, base_path: Any | None = ...) -> None: ... def make_one_path_absolute(base_path, path) -> str: ... def filter_settings_spec(settings_spec, *exclude, **replace) -> Tuple[Any, ...]: ... diff --git a/stubs/docutils/docutils/io.pyi b/stubs/docutils/docutils/io.pyi index 556b54792da4..635b1686bcc1 100644 --- a/stubs/docutils/docutils/io.pyi +++ b/stubs/docutils/docutils/io.pyi @@ -8,22 +8,22 @@ __docformat__: str class InputError(IOError): ... class OutputError(IOError): ... -def check_encoding(stream: Any, encoding: str) -> Optional[bool]: ... +def check_encoding(stream: Any, encoding: str) -> bool | None: ... class Input(TransformSpec): component_type: ClassVar[str] - default_source_path: ClassVar[Optional[str]] + default_source_path: ClassVar[str | None] def read(self) -> Any: ... def __getattr__(self, name: str) -> Any: ... # incomplete class Output(TransformSpec): component_type: ClassVar[str] - default_destination_path: ClassVar[Optional[str]] + default_destination_path: ClassVar[str | None] def __init__( self, - destination: Optional[Any] = ..., - destination_path: Optional[Any] = ..., - encoding: Optional[str] = ..., + destination: Any | None = ..., + destination_path: Any | None = ..., + encoding: str | None = ..., error_handler: str = ..., ) -> None: ... def write(self, data: str) -> Any: ... # returns bytes or str @@ -32,18 +32,18 @@ class Output(TransformSpec): class FileInput(Input): def __init__( self, - source: Optional[Any] = ..., - source_path: Optional[Any] = ..., - encoding: Optional[str] = ..., + source: Any | None = ..., + source_path: Any | None = ..., + encoding: str | None = ..., error_handler: str = ..., autoclose: bool = ..., - mode: Union[OpenTextModeReading, OpenBinaryModeReading] = ..., + mode: OpenTextModeReading | OpenBinaryModeReading = ..., ) -> None: ... def readlines(self) -> list[str]: ... def close(self) -> None: ... class FileOutput(Output): - mode: ClassVar[Union[OpenTextModeWriting, OpenBinaryModeWriting]] + mode: ClassVar[OpenTextModeWriting | OpenBinaryModeWriting] def __getattr__(self, name: str) -> Any: ... # incomplete class BinaryFileOutput(FileOutput): ... @@ -53,7 +53,7 @@ class StringInput(Input): class StringOutput(Output): default_destination_path: ClassVar[str] - destination: Union[str, bytes] # only defined after call to write() + destination: str | bytes # only defined after call to write() class NullInput(Input): default_source_path: ClassVar[str] diff --git a/stubs/docutils/docutils/parsers/rst/__init__.pyi b/stubs/docutils/docutils/parsers/rst/__init__.pyi index cbece715fd96..76de43d97a99 100644 --- a/stubs/docutils/docutils/parsers/rst/__init__.pyi +++ b/stubs/docutils/docutils/parsers/rst/__init__.pyi @@ -8,7 +8,7 @@ class Parser(parsers.Parser): initial_state: Literal["Body", "RFC2822Body"] state_classes: Any inliner: Any - def __init__(self, rfc2822: bool = ..., inliner: Optional[Any] = ...) -> None: ... + def __init__(self, rfc2822: bool = ..., inliner: Any | None = ...) -> None: ... class DirectiveError(Exception): level: Any diff --git a/stubs/docutils/docutils/utils/__init__.pyi b/stubs/docutils/docutils/utils/__init__.pyi index 0cf19f68f2cc..5cd3e66222fc 100644 --- a/stubs/docutils/docutils/utils/__init__.pyi +++ b/stubs/docutils/docutils/utils/__init__.pyi @@ -7,9 +7,9 @@ _list = list class DependencyList: list: _list[str] - file: Optional[FileOutput] - def __init__(self, output_file: Optional[str] = ..., dependencies: Iterable[str] = ...) -> None: ... - def set_output(self, output_file: Optional[str]) -> None: ... + file: FileOutput | None + def __init__(self, output_file: str | None = ..., dependencies: Iterable[str] = ...) -> None: ... + def set_output(self, output_file: str | None) -> None: ... def add(self, *filenames: str) -> None: ... def close(self) -> None: ... diff --git a/stubs/emoji/emoji/core.pyi b/stubs/emoji/emoji/core.pyi index 8fcd223d6f86..54c19e1b10ad 100644 --- a/stubs/emoji/emoji/core.pyi +++ b/stubs/emoji/emoji/core.pyi @@ -12,6 +12,6 @@ def emojize( ) -> str: ... def demojize(string: str, use_aliases: bool = ..., delimiters: Tuple[str, str] = ..., language: str = ...) -> str: ... def get_emoji_regexp(language: str = ...) -> Pattern[Text]: ... -def emoji_lis(string: str, language: str = ...) -> List[Dict[str, Union[int, str]]]: ... +def emoji_lis(string: str, language: str = ...) -> List[Dict[str, int | str]]: ... def distinct_emoji_lis(string: str) -> List[str]: ... def emoji_count(string: str) -> int: ... diff --git a/stubs/filelock/filelock/__init__.pyi b/stubs/filelock/filelock/__init__.pyi index 5d5fcc235b5c..a5b2eb9d285b 100644 --- a/stubs/filelock/filelock/__init__.pyi +++ b/stubs/filelock/filelock/__init__.pyi @@ -13,24 +13,24 @@ class _Acquire_ReturnProxy: def __init__(self, lock: str) -> None: ... def __enter__(self) -> str: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], traceback: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None ) -> None: ... class BaseFileLock: - def __init__(self, lock_file: str, timeout: Union[float, int, str] = ...) -> None: ... + def __init__(self, lock_file: str, timeout: float | int | str = ...) -> None: ... @property def lock_file(self) -> str: ... @property def timeout(self) -> float: ... @timeout.setter - def timeout(self, value: Union[int, str, float]) -> None: ... # type: ignore + def timeout(self, value: int | str | float) -> None: ... # type: ignore @property def is_locked(self) -> bool: ... - def acquire(self, timeout: Optional[float] = ..., poll_intervall: float = ...) -> _Acquire_ReturnProxy: ... + def acquire(self, timeout: float | None = ..., poll_intervall: float = ...) -> _Acquire_ReturnProxy: ... def release(self, force: bool = ...) -> None: ... def __enter__(self) -> BaseFileLock: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], traceback: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None ) -> None: ... def __del__(self) -> None: ... diff --git a/stubs/first/first.pyi b/stubs/first/first.pyi index 2e5096ba1eee..7e5591b4f83a 100644 --- a/stubs/first/first.pyi +++ b/stubs/first/first.pyi @@ -4,10 +4,10 @@ _T = TypeVar("_T") _S = TypeVar("_S") @overload -def first(iterable: Iterable[_T]) -> Optional[_T]: ... +def first(iterable: Iterable[_T]) -> _T | None: ... @overload -def first(iterable: Iterable[_T], default: _S) -> Union[_T, _S]: ... +def first(iterable: Iterable[_T], default: _S) -> _T | _S: ... @overload -def first(iterable: Iterable[_T], default: _S, key: Optional[Callable[[_T], Any]]) -> Union[_T, _S]: ... +def first(iterable: Iterable[_T], default: _S, key: Callable[[_T], Any] | None) -> _T | _S: ... @overload -def first(iterable: Iterable[_T], *, key: Optional[Callable[[_T], Any]]) -> Optional[_T]: ... +def first(iterable: Iterable[_T], *, key: Callable[[_T], Any] | None) -> _T | None: ... diff --git a/stubs/geoip2/geoip2/database.pyi b/stubs/geoip2/geoip2/database.pyi index eec539d65fe0..f589128ce631 100644 --- a/stubs/geoip2/geoip2/database.pyi +++ b/stubs/geoip2/geoip2/database.pyi @@ -11,9 +11,9 @@ class Reader: def __enter__(self) -> Reader: ... def __exit__( self, - exc_type: Optional[Type[BaseException]] = ..., - exc_val: Optional[BaseException] = ..., - exc_tb: Optional[TracebackType] = ..., + exc_type: Type[BaseException] | None = ..., + exc_val: BaseException | None = ..., + exc_tb: TracebackType | None = ..., ) -> None: ... def country(self, ip_address: Text) -> Country: ... def city(self, ip_address: Text) -> City: ... diff --git a/stubs/geoip2/geoip2/errors.pyi b/stubs/geoip2/geoip2/errors.pyi index 5e2997d3c078..912858685382 100644 --- a/stubs/geoip2/geoip2/errors.pyi +++ b/stubs/geoip2/geoip2/errors.pyi @@ -5,9 +5,9 @@ class AddressNotFoundError(GeoIP2Error): ... class AuthenticationError(GeoIP2Error): ... class HTTPError(GeoIP2Error): - http_status: Optional[int] - uri: Optional[Text] - def __init__(self, message: Text, http_status: Optional[int] = ..., uri: Optional[Text] = ...) -> None: ... + http_status: int | None + uri: Text | None + def __init__(self, message: Text, http_status: int | None = ..., uri: Text | None = ...) -> None: ... class InvalidRequestError(GeoIP2Error): ... class OutOfQueriesError(GeoIP2Error): ... diff --git a/stubs/geoip2/geoip2/models.pyi b/stubs/geoip2/geoip2/models.pyi index 96af74b8b34b..1e07d613b67f 100644 --- a/stubs/geoip2/geoip2/models.pyi +++ b/stubs/geoip2/geoip2/models.pyi @@ -33,30 +33,30 @@ class AnonymousIP(SimpleModel): is_hosting_provider: bool is_public_proxy: bool is_tor_exit_node: bool - ip_address: Optional[Text] + ip_address: Text | None raw: _RawResponse def __init__(self, raw: _RawResponse) -> None: ... class ASN(SimpleModel): - autonomous_system_number: Optional[int] - autonomous_system_organization: Optional[Text] - ip_address: Optional[Text] + autonomous_system_number: int | None + autonomous_system_organization: Text | None + ip_address: Text | None raw: _RawResponse def __init__(self, raw: _RawResponse) -> None: ... class ConnectionType(SimpleModel): - connection_type: Optional[Text] - ip_address: Optional[Text] + connection_type: Text | None + ip_address: Text | None raw: _RawResponse def __init__(self, raw: _RawResponse) -> None: ... class Domain(SimpleModel): - domain: Optional[Text] - ip_address: Optional[Text] - raw: Optional[Text] + domain: Text | None + ip_address: Text | None + raw: Text | None def __init__(self, raw: _RawResponse) -> None: ... class ISP(ASN): - isp: Optional[Text] - organization: Optional[Text] + isp: Text | None + organization: Text | None def __init__(self, raw: _RawResponse) -> None: ... diff --git a/stubs/itsdangerous/itsdangerous.pyi b/stubs/itsdangerous/itsdangerous.pyi index 84f596116d0e..793a90c7bb46 100644 --- a/stubs/itsdangerous/itsdangerous.pyi +++ b/stubs/itsdangerous/itsdangerous.pyi @@ -3,35 +3,35 @@ from typing import IO, Any, Callable, Generator, Mapping, MutableMapping, Option _serializer = Any # must be an object that has "dumps" and "loads" attributes (e.g. the json module) -def want_bytes(s: Union[Text, bytes], encoding: Text = ..., errors: Text = ...) -> bytes: ... +def want_bytes(s: Text | bytes, encoding: Text = ..., errors: Text = ...) -> bytes: ... class BadData(Exception): message: str def __init__(self, message: str) -> None: ... class BadPayload(BadData): - original_error: Optional[Exception] - def __init__(self, message: str, original_error: Optional[Exception] = ...) -> None: ... + original_error: Exception | None + def __init__(self, message: str, original_error: Exception | None = ...) -> None: ... class BadSignature(BadData): - payload: Optional[Any] - def __init__(self, message: str, payload: Optional[Any] = ...) -> None: ... + payload: Any | None + def __init__(self, message: str, payload: Any | None = ...) -> None: ... class BadTimeSignature(BadSignature): - date_signed: Optional[int] - def __init__(self, message: str, payload: Optional[Any] = ..., date_signed: Optional[int] = ...) -> None: ... + date_signed: int | None + def __init__(self, message: str, payload: Any | None = ..., date_signed: int | None = ...) -> None: ... class BadHeader(BadSignature): header: Any original_error: Any def __init__( - self, message: str, payload: Optional[Any] = ..., header: Optional[Any] = ..., original_error: Optional[Any] = ... + self, message: str, payload: Any | None = ..., header: Any | None = ..., original_error: Any | None = ... ) -> None: ... class SignatureExpired(BadTimeSignature): ... -def base64_encode(string: Union[Text, bytes]) -> bytes: ... -def base64_decode(string: Union[Text, bytes]) -> bytes: ... +def base64_encode(string: Text | bytes) -> bytes: ... +def base64_decode(string: Text | bytes) -> bytes: ... class SigningAlgorithm(object): def get_signature(self, key: bytes, value: bytes) -> bytes: ... @@ -43,7 +43,7 @@ class NoneAlgorithm(SigningAlgorithm): class HMACAlgorithm(SigningAlgorithm): default_digest_method: Callable[..., Any] digest_method: Callable[..., Any] - def __init__(self, digest_method: Optional[Callable[..., Any]] = ...) -> None: ... + def __init__(self, digest_method: Callable[..., Any] | None = ...) -> None: ... def get_signature(self, key: bytes, value: bytes) -> bytes: ... class Signer(object): @@ -52,34 +52,34 @@ class Signer(object): secret_key: bytes sep: bytes - salt: Union[Text, bytes] + salt: Text | bytes key_derivation: str digest_method: Callable[..., Any] algorithm: SigningAlgorithm def __init__( self, - secret_key: Union[Text, bytes], - salt: Optional[Union[Text, bytes]] = ..., - sep: Optional[Union[Text, bytes]] = ..., - key_derivation: Optional[str] = ..., - digest_method: Optional[Callable[..., Any]] = ..., - algorithm: Optional[SigningAlgorithm] = ..., + secret_key: Text | bytes, + salt: Text | bytes | None = ..., + sep: Text | bytes | None = ..., + key_derivation: str | None = ..., + digest_method: Callable[..., Any] | None = ..., + algorithm: SigningAlgorithm | None = ..., ) -> None: ... def derive_key(self) -> bytes: ... - def get_signature(self, value: Union[Text, bytes]) -> bytes: ... - def sign(self, value: Union[Text, bytes]) -> bytes: ... - def verify_signature(self, value: bytes, sig: Union[Text, bytes]) -> bool: ... - def unsign(self, signed_value: Union[Text, bytes]) -> bytes: ... - def validate(self, signed_value: Union[Text, bytes]) -> bool: ... + def get_signature(self, value: Text | bytes) -> bytes: ... + def sign(self, value: Text | bytes) -> bytes: ... + def verify_signature(self, value: bytes, sig: Text | bytes) -> bool: ... + def unsign(self, signed_value: Text | bytes) -> bytes: ... + def validate(self, signed_value: Text | bytes) -> bool: ... class TimestampSigner(Signer): def get_timestamp(self) -> int: ... def timestamp_to_datetime(self, ts: float) -> datetime: ... - def sign(self, value: Union[Text, bytes]) -> bytes: ... + def sign(self, value: Text | bytes) -> bytes: ... def unsign( - self, value: Union[Text, bytes], max_age: Optional[int] = ..., return_timestamp: bool = ... - ) -> Any: ... # morally -> Union[bytes, Tuple[bytes, datetime]] - def validate(self, signed_value: Union[Text, bytes], max_age: Optional[int] = ...) -> bool: ... + self, value: Text | bytes, max_age: int | None = ..., return_timestamp: bool = ... + ) -> Any: ... # morally -> bytes | Tuple[bytes, datetime] + def validate(self, signed_value: Text | bytes, max_age: int | None = ...) -> bool: ... class Serializer(object): default_serializer: _serializer = ... @@ -93,33 +93,33 @@ class Serializer(object): signer_kwargs: MutableMapping[str, Any] def __init__( self, - secret_key: Union[Text, bytes], - salt: Optional[Union[Text, bytes]] = ..., - serializer: Optional[_serializer] = ..., - signer: Optional[Callable[..., Signer]] = ..., - signer_kwargs: Optional[MutableMapping[str, Any]] = ..., + secret_key: Text | bytes, + salt: Text | bytes | None = ..., + serializer: _serializer | None = ..., + signer: Callable[..., Signer] | None = ..., + signer_kwargs: MutableMapping[str, Any] | None = ..., ) -> None: ... - def load_payload(self, payload: bytes, serializer: Optional[_serializer] = ...) -> Any: ... + def load_payload(self, payload: bytes, serializer: _serializer | None = ...) -> Any: ... def dump_payload(self, obj: Any) -> bytes: ... - def make_signer(self, salt: Optional[Union[Text, bytes]] = ...) -> Signer: ... - def iter_unsigners(self, salt: Optional[Union[Text, bytes]] = ...) -> Generator[Any, None, None]: ... - def dumps(self, obj: Any, salt: Optional[Union[Text, bytes]] = ...) -> Any: ... # morally -> Union[str, bytes] - def dump(self, obj: Any, f: IO[Any], salt: Optional[Union[Text, bytes]] = ...) -> None: ... - def loads(self, s: Union[Text, bytes], salt: Optional[Union[Text, bytes]] = ...) -> Any: ... - def load(self, f: IO[Any], salt: Optional[Union[Text, bytes]] = ...) -> Any: ... - def loads_unsafe(self, s: Union[Text, bytes], salt: Optional[Union[Text, bytes]] = ...) -> Tuple[bool, Optional[Any]]: ... - def load_unsafe(self, f: IO[Any], salt: Optional[Union[Text, bytes]] = ...) -> Tuple[bool, Optional[Any]]: ... + def make_signer(self, salt: Text | bytes | None = ...) -> Signer: ... + def iter_unsigners(self, salt: Text | bytes | None = ...) -> Generator[Any, None, None]: ... + def dumps(self, obj: Any, salt: Text | bytes | None = ...) -> Any: ... # morally -> str | bytes + def dump(self, obj: Any, f: IO[Any], salt: Text | bytes | None = ...) -> None: ... + def loads(self, s: Text | bytes, salt: Text | bytes | None = ...) -> Any: ... + def load(self, f: IO[Any], salt: Text | bytes | None = ...) -> Any: ... + def loads_unsafe(self, s: Text | bytes, salt: Text | bytes | None = ...) -> Tuple[bool, Any | None]: ... + def load_unsafe(self, f: IO[Any], salt: Text | bytes | None = ...) -> Tuple[bool, Any | None]: ... class TimedSerializer(Serializer): def loads( self, - s: Union[Text, bytes], - salt: Optional[Union[Text, bytes]] = ..., - max_age: Optional[int] = ..., + s: Text | bytes, + salt: Text | bytes | None = ..., + max_age: int | None = ..., return_timestamp: bool = ..., - ) -> Any: ... # morally -> Union[Any, Tuple[Any, datetime]] + ) -> Any: ... # morally -> Any | Tuple[Any, datetime] def loads_unsafe( - self, s: Union[Text, bytes], salt: Optional[Union[Text, bytes]] = ..., max_age: Optional[int] = ... + self, s: Text | bytes, salt: Text | bytes | None = ..., max_age: int | None = ... ) -> Tuple[bool, Any]: ... class JSONWebSignatureSerializer(Serializer): @@ -131,28 +131,28 @@ class JSONWebSignatureSerializer(Serializer): algorithm: SigningAlgorithm def __init__( self, - secret_key: Union[Text, bytes], - salt: Optional[Union[Text, bytes]] = ..., - serializer: Optional[_serializer] = ..., - signer: Optional[Callable[..., Signer]] = ..., - signer_kwargs: Optional[MutableMapping[str, Any]] = ..., - algorithm_name: Optional[Text] = ..., + secret_key: Text | bytes, + salt: Text | bytes | None = ..., + serializer: _serializer | None = ..., + signer: Callable[..., Signer] | None = ..., + signer_kwargs: MutableMapping[str, Any] | None = ..., + algorithm_name: Text | None = ..., ) -> None: ... def load_payload( - self, payload: Union[Text, bytes], serializer: Optional[_serializer] = ..., return_header: bool = ... - ) -> Any: ... # morally -> Union[Any, Tuple[Any, MutableMapping[str, Any]]] + self, payload: Text | bytes, serializer: _serializer | None = ..., return_header: bool = ... + ) -> Any: ... # morally -> Any | Tuple[Any, MutableMapping[str, Any]] def dump_payload(self, header: Mapping[str, Any], obj: Any) -> bytes: ... # type: ignore def make_algorithm(self, algorithm_name: Text) -> SigningAlgorithm: ... - def make_signer(self, salt: Optional[Union[Text, bytes]] = ..., algorithm: SigningAlgorithm = ...) -> Signer: ... - def make_header(self, header_fields: Optional[Mapping[str, Any]]) -> MutableMapping[str, Any]: ... + def make_signer(self, salt: Text | bytes | None = ..., algorithm: SigningAlgorithm = ...) -> Signer: ... + def make_header(self, header_fields: Mapping[str, Any] | None) -> MutableMapping[str, Any]: ... def dumps( - self, obj: Any, salt: Optional[Union[Text, bytes]] = ..., header_fields: Optional[Mapping[str, Any]] = ... + self, obj: Any, salt: Text | bytes | None = ..., header_fields: Mapping[str, Any] | None = ... ) -> bytes: ... def loads( - self, s: Union[Text, bytes], salt: Optional[Union[Text, bytes]] = ..., return_header: bool = ... - ) -> Any: ... # morally -> Union[Any, Tuple[Any, MutableMapping[str, Any]]] + self, s: Text | bytes, salt: Text | bytes | None = ..., return_header: bool = ... + ) -> Any: ... # morally -> Any | Tuple[Any, MutableMapping[str, Any]] def loads_unsafe( - self, s: Union[Text, bytes], salt: Optional[Union[Text, bytes]] = ..., return_header: bool = ... + self, s: Text | bytes, salt: Text | bytes | None = ..., return_header: bool = ... ) -> Tuple[bool, Any]: ... class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer): @@ -160,24 +160,24 @@ class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer): expires_in: int def __init__( self, - secret_key: Union[Text, bytes], - expires_in: Optional[int] = ..., - salt: Optional[Union[Text, bytes]] = ..., - serializer: Optional[_serializer] = ..., - signer: Optional[Callable[..., Signer]] = ..., - signer_kwargs: Optional[MutableMapping[str, Any]] = ..., - algorithm_name: Optional[Text] = ..., + secret_key: Text | bytes, + expires_in: int | None = ..., + salt: Text | bytes | None = ..., + serializer: _serializer | None = ..., + signer: Callable[..., Signer] | None = ..., + signer_kwargs: MutableMapping[str, Any] | None = ..., + algorithm_name: Text | None = ..., ) -> None: ... - def make_header(self, header_fields: Optional[Mapping[str, Any]]) -> MutableMapping[str, Any]: ... + def make_header(self, header_fields: Mapping[str, Any] | None) -> MutableMapping[str, Any]: ... def loads( - self, s: Union[Text, bytes], salt: Optional[Union[Text, bytes]] = ..., return_header: bool = ... - ) -> Any: ... # morally -> Union[Any, Tuple[Any, MutableMapping[str, Any]]] - def get_issue_date(self, header: Mapping[str, Any]) -> Optional[datetime]: ... + self, s: Text | bytes, salt: Text | bytes | None = ..., return_header: bool = ... + ) -> Any: ... # morally -> Any | Tuple[Any, MutableMapping[str, Any]] + def get_issue_date(self, header: Mapping[str, Any]) -> datetime | None: ... def now(self) -> int: ... class _URLSafeSerializerMixin(object): default_serializer: _serializer = ... - def load_payload(self, payload: bytes, serializer: Optional[_serializer] = ...) -> Any: ... + def load_payload(self, payload: bytes, serializer: _serializer | None = ...) -> Any: ... def dump_payload(self, obj: Any) -> bytes: ... class URLSafeSerializer(_URLSafeSerializerMixin, Serializer): ... diff --git a/stubs/maxminddb/maxminddb/reader.pyi b/stubs/maxminddb/maxminddb/reader.pyi index b6cfb1730fd7..0d4aa5dffdda 100644 --- a/stubs/maxminddb/maxminddb/reader.pyi +++ b/stubs/maxminddb/maxminddb/reader.pyi @@ -6,15 +6,15 @@ class Reader: closed: bool = ... def __init__(self, database: bytes, mode: int = ...) -> None: ... def metadata(self) -> Metadata: ... - def get(self, ip_address: Union[Text, IPv4Address, IPv6Address]) -> Optional[Any]: ... - def get_with_prefix_len(self, ip_address: Union[Text, IPv4Address, IPv6Address]) -> Tuple[Optional[Any], int]: ... + def get(self, ip_address: Text | IPv4Address | IPv6Address) -> Any | None: ... + def get_with_prefix_len(self, ip_address: Text | IPv4Address | IPv6Address) -> Tuple[Any | None, int]: ... def close(self) -> None: ... def __enter__(self) -> Reader: ... def __exit__( self, - exc_type: Optional[Type[BaseException]] = ..., - exc_val: Optional[BaseException] = ..., - exc_tb: Optional[TracebackType] = ..., + exc_type: Type[BaseException] | None = ..., + exc_val: BaseException | None = ..., + exc_tb: TracebackType | None = ..., ) -> None: ... class Metadata: diff --git a/stubs/mock/mock.pyi b/stubs/mock/mock.pyi index 4e02c5f06b33..83cd0e0defcc 100644 --- a/stubs/mock/mock.pyi +++ b/stubs/mock/mock.pyi @@ -42,13 +42,13 @@ DEFAULT: Any class _Call(Tuple[Any, ...]): def __new__( - cls, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ... + cls, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ... ) -> Any: ... name: Any parent: Any from_kall: Any def __init__( - self, value: Any = ..., name: Optional[Any] = ..., parent: Optional[Any] = ..., two: bool = ..., from_kall: bool = ... + self, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ... ) -> None: ... def __eq__(self, other: Any) -> bool: ... __ne__: Any @@ -76,16 +76,16 @@ class NonCallableMock(Base, Any): # type: ignore def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ... def __init__( self, - spec: Union[List[str], object, Type[object], None] = ..., - wraps: Optional[Any] = ..., - name: Optional[str] = ..., - spec_set: Union[List[str], object, Type[object], None] = ..., - parent: Optional[NonCallableMock] = ..., - _spec_state: Optional[Any] = ..., + spec: List[str] | object | Type[object] | None = ..., + wraps: Any | None = ..., + name: str | None = ..., + spec_set: List[str] | object | Type[object] | None = ..., + parent: NonCallableMock | None = ..., + _spec_state: Any | None = ..., _new_name: str = ..., - _new_parent: Optional[NonCallableMock] = ..., + _new_parent: NonCallableMock | None = ..., _spec_as_instance: bool = ..., - _eat_self: Optional[bool] = ..., + _eat_self: bool | None = ..., unsafe: bool = ..., **kwargs: Any, ) -> None: ... @@ -135,16 +135,16 @@ class CallableMixin(Base): side_effect: Any def __init__( self, - spec: Optional[Any] = ..., - side_effect: Optional[Any] = ..., + spec: Any | None = ..., + side_effect: Any | None = ..., return_value: Any = ..., - wraps: Optional[Any] = ..., - name: Optional[Any] = ..., - spec_set: Optional[Any] = ..., - parent: Optional[Any] = ..., - _spec_state: Optional[Any] = ..., + wraps: Any | None = ..., + name: Any | None = ..., + spec_set: Any | None = ..., + parent: Any | None = ..., + _spec_state: Any | None = ..., _new_name: Any = ..., - _new_parent: Optional[Any] = ..., + _new_parent: Any | None = ..., **kwargs: Any, ) -> None: ... def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ... @@ -167,15 +167,15 @@ class _patch(Generic[_T]): if sys.version_info >= (3, 8): @overload def __init__( - self: _patch[Union[MagicMock, AsyncMock]], + self: _patch[MagicMock | AsyncMock], getter: Callable[[], Any], attribute: str, *, - spec: Optional[Any], + spec: Any | None, create: bool, - spec_set: Optional[Any], - autospec: Optional[Any], - new_callable: Optional[Any], + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, kwargs: Mapping[str, Any], ) -> None: ... # This overload also covers the case, where new==DEFAULT. In this case, self is _patch[Any]. @@ -187,11 +187,11 @@ class _patch(Generic[_T]): getter: Callable[[], Any], attribute: str, new: _T, - spec: Optional[Any], + spec: Any | None, create: bool, - spec_set: Optional[Any], - autospec: Optional[Any], - new_callable: Optional[Any], + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, kwargs: Mapping[str, Any], ) -> None: ... else: @@ -201,11 +201,11 @@ class _patch(Generic[_T]): getter: Callable[[], Any], attribute: str, *, - spec: Optional[Any], + spec: Any | None, create: bool, - spec_set: Optional[Any], - autospec: Optional[Any], - new_callable: Optional[Any], + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, kwargs: Mapping[str, Any], ) -> None: ... @overload @@ -214,11 +214,11 @@ class _patch(Generic[_T]): getter: Callable[[], Any], attribute: str, new: _T, - spec: Optional[Any], + spec: Any | None, create: bool, - spec_set: Optional[Any], - autospec: Optional[Any], - new_callable: Optional[Any], + spec_set: Any | None, + autospec: Any | None, + new_callable: Any | None, kwargs: Mapping[str, Any], ) -> None: ... def copy(self) -> _patch[_T]: ... @@ -255,13 +255,13 @@ class _patcher: self, target: Any, *, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, - ) -> _patch[Union[MagicMock, AsyncMock]]: ... + ) -> _patch[MagicMock | AsyncMock]: ... # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any]. # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock], # but that's impossible with the current type system. @@ -270,11 +270,11 @@ class _patcher: self, target: Any, new: _T, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[_T]: ... else: @@ -283,11 +283,11 @@ class _patcher: self, target: Any, *, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[MagicMock]: ... @overload @@ -295,11 +295,11 @@ class _patcher: self, target: Any, new: _T, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[_T]: ... if sys.version_info >= (3, 8): @@ -309,24 +309,24 @@ class _patcher: target: Any, attribute: Text, *, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, - ) -> _patch[Union[MagicMock, AsyncMock]]: ... + ) -> _patch[MagicMock | AsyncMock]: ... @overload def object( self, target: Any, attribute: Text, new: _T = ..., - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[_T]: ... else: @@ -336,11 +336,11 @@ class _patcher: target: Any, attribute: Text, *, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[MagicMock]: ... @overload @@ -349,21 +349,21 @@ class _patcher: target: Any, attribute: Text, new: _T = ..., - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: Any, ) -> _patch[_T]: ... def multiple( self, target: Any, - spec: Optional[Any] = ..., + spec: Any | None = ..., create: bool = ..., - spec_set: Optional[Any] = ..., - autospec: Optional[Any] = ..., - new_callable: Optional[Any] = ..., + spec_set: Any | None = ..., + autospec: Any | None = ..., + new_callable: Any | None = ..., **kwargs: _T, ) -> _patch[_T]: ... def stopall(self) -> None: ... @@ -392,7 +392,7 @@ if sys.version_info >= (3, 8): def assert_not_awaited(self) -> None: ... def reset_mock(self, *args: Any, **kwargs: Any) -> None: ... await_count: int - await_args: Optional[_Call] + await_args: _Call | None await_args_list: _CallList class AsyncMagicMixin(MagicMixin): def __init__(self, *args: Any, **kw: Any) -> None: ... @@ -404,7 +404,7 @@ class MagicProxy: def __init__(self, name: Any, parent: Any) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def create_mock(self) -> Any: ... - def __get__(self, obj: Any, _type: Optional[Any] = ...) -> Any: ... + def __get__(self, obj: Any, _type: Any | None = ...) -> Any: ... class _ANY: def __eq__(self, other: Any) -> bool: ... @@ -413,7 +413,7 @@ class _ANY: ANY: Any def create_autospec( - spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Optional[Any] = ..., _name: Optional[Any] = ..., **kwargs: Any + spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Any | None = ..., _name: Any | None = ..., **kwargs: Any ) -> Any: ... class _SpecState: @@ -427,13 +427,13 @@ class _SpecState: self, spec: Any, spec_set: Any = ..., - parent: Optional[Any] = ..., - name: Optional[Any] = ..., - ids: Optional[Any] = ..., + parent: Any | None = ..., + name: Any | None = ..., + ids: Any | None = ..., instance: Any = ..., ) -> None: ... -def mock_open(mock: Optional[Any] = ..., read_data: Any = ...) -> Any: ... +def mock_open(mock: Any | None = ..., read_data: Any = ...) -> Any: ... PropertyMock = Any diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index a7bd0711f6d5..52d00ad67c17 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -26,10 +26,10 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): def __delitem__(self, k: NoReturn) -> None: ... def TypedDict(typename: str, fields: Dict[str, Type[Any]], total: bool = ...) -> Type[Dict[str, Any]]: ... -def Arg(type: _T = ..., name: Optional[str] = ...) -> _T: ... -def DefaultArg(type: _T = ..., name: Optional[str] = ...) -> _T: ... -def NamedArg(type: _T = ..., name: Optional[str] = ...) -> _T: ... -def DefaultNamedArg(type: _T = ..., name: Optional[str] = ...) -> _T: ... +def Arg(type: _T = ..., name: str | None = ...) -> _T: ... +def DefaultArg(type: _T = ..., name: str | None = ...) -> _T: ... +def NamedArg(type: _T = ..., name: str | None = ...) -> _T: ... +def DefaultNamedArg(type: _T = ..., name: str | None = ...) -> _T: ... def VarArg(type: _T = ...) -> _T: ... def KwArg(type: _T = ...) -> _T: ... diff --git a/stubs/nmap/nmap/nmap.pyi b/stubs/nmap/nmap/nmap.pyi index 5e4be5adca24..80b6e0ad6646 100644 --- a/stubs/nmap/nmap/nmap.pyi +++ b/stubs/nmap/nmap/nmap.pyi @@ -54,10 +54,10 @@ class PortScanner(object): def get_nmap_last_output(self) -> Text: ... def nmap_version(self) -> Tuple[int, int]: ... def listscan(self, hosts: str = ...) -> List[str]: ... - def scan(self, hosts: Text = ..., ports: Optional[Text] = ..., arguments: Text = ..., sudo: bool = ...) -> _Result: ... + def scan(self, hosts: Text = ..., ports: Text | None = ..., arguments: Text = ..., sudo: bool = ...) -> _Result: ... def analyse_nmap_xml_scan( self, - nmap_xml_output: Optional[str] = ..., + nmap_xml_output: str | None = ..., nmap_err: str = ..., nmap_err_keep_trace: str = ..., nmap_warn_keep_trace: str = ..., @@ -71,7 +71,7 @@ class PortScanner(object): def csv(self) -> str: ... def __scan_progressive__( - self: object, hosts: Text, ports: Text, arguments: Text, callback: Optional[_Callback], sudo: bool + self: object, hosts: Text, ports: Text, arguments: Text, callback: _Callback | None, sudo: bool ) -> None: ... class PortScannerAsync(object): @@ -80,22 +80,22 @@ class PortScannerAsync(object): def scan( self, hosts: Text = ..., - ports: Optional[Text] = ..., + ports: Text | None = ..., arguments: Text = ..., - callback: Optional[_Callback] = ..., + callback: _Callback | None = ..., sudo: bool = ..., ) -> None: ... def stop(self) -> None: ... - def wait(self, timeout: Optional[int] = ...) -> None: ... + def wait(self, timeout: int | None = ...) -> None: ... def still_scanning(self) -> bool: ... class PortScannerYield(PortScannerAsync): def __init__(self) -> None: ... def scan( # type: ignore - self, hosts: str = ..., ports: Optional[str] = ..., arguments: str = ..., sudo: bool = ... + self, hosts: str = ..., ports: str | None = ..., arguments: str = ..., sudo: bool = ... ) -> Iterator[Tuple[str, _Result]]: ... def stop(self) -> None: ... - def wait(self, timeout: Optional[int] = ...) -> None: ... + def wait(self, timeout: int | None = ...) -> None: ... def still_scanning(self) -> None: ... # type: ignore class PortScannerHostDict(Dict[str, Any]): diff --git a/stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi b/stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi index feef3434527d..2feebdd63683 100644 --- a/stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi +++ b/stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi @@ -3,7 +3,7 @@ from typing import Any, Optional log: Any def signature_base_string(http_method: str, base_str_uri: str, normalized_encoded_request_parameters: str) -> str: ... -def base_string_uri(uri: str, host: Optional[str] = ...) -> str: ... +def base_string_uri(uri: str, host: str | None = ...) -> str: ... def collect_parameters( uri_query: str = ..., body: Any | None = ..., @@ -19,7 +19,7 @@ def sign_hmac_sha256_with_client(sig_base_str, client): ... def verify_hmac_sha256(request, client_secret: Any | None = ..., resource_owner_secret: Any | None = ...): ... def sign_hmac_sha256(base_string, client_secret, resource_owner_secret): ... def sign_hmac_sha512_with_client(sig_base_str: str, client): ... -def verify_hmac_sha512(request, client_secret: Optional[str] = ..., resource_owner_secret: Optional[str] = ...): ... +def verify_hmac_sha512(request, client_secret: str | None = ..., resource_owner_secret: str | None = ...): ... def sign_rsa_sha1_with_client(sig_base_str, client): ... def verify_rsa_sha1(request, rsa_public_key: str): ... def sign_rsa_sha1(base_string, rsa_private_key): ... diff --git a/stubs/orjson/orjson.pyi b/stubs/orjson/orjson.pyi index 3fcbd7b668ce..35387cecef56 100644 --- a/stubs/orjson/orjson.pyi +++ b/stubs/orjson/orjson.pyi @@ -2,8 +2,8 @@ from typing import Any, Callable, Optional, Union __version__: str -def dumps(__obj: Any, default: Optional[Callable[[Any], Any]] = ..., option: Optional[int] = ...) -> bytes: ... -def loads(__obj: Union[bytes, bytearray, str]) -> Any: ... +def dumps(__obj: Any, default: Callable[[Any], Any] | None = ..., option: int | None = ...) -> bytes: ... +def loads(__obj: bytes | bytearray | str) -> Any: ... class JSONDecodeError(ValueError): ... class JSONEncodeError(TypeError): ... diff --git a/stubs/paramiko/paramiko/_winapi.pyi b/stubs/paramiko/paramiko/_winapi.pyi index 8c421fd0ab81..f3a31bd006cd 100644 --- a/stubs/paramiko/paramiko/_winapi.pyi +++ b/stubs/paramiko/paramiko/_winapi.pyi @@ -7,9 +7,9 @@ from typing import Any, Optional, Type, TypeVar if sys.platform == "win32": _T = TypeVar("_T") - def format_system_message(errno: int) -> Optional[str]: ... + def format_system_message(errno: int) -> str | None: ... class WindowsError(builtins.WindowsError): - def __init__(self, value: Optional[int] = ...) -> None: ... + def __init__(self, value: int | None = ...) -> None: ... @property def message(self) -> str: ... @property @@ -31,13 +31,13 @@ if sys.platform == "win32": pos: int filemap: Any = ... view: Any = ... - def __init__(self, name: str, length: int, security_attributes: Optional[Any] = ...) -> None: ... + def __init__(self, name: str, length: int, security_attributes: Any | None = ...) -> None: ... def __enter__(self: _T) -> _T: ... def seek(self, pos: int) -> None: ... def write(self, msg: bytes) -> None: ... def read(self, n: int) -> bytes: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, tb: TracebackType | None ) -> None: ... READ_CONTROL: int STANDARD_RIGHTS_REQUIRED: int @@ -82,4 +82,4 @@ if sys.platform == "win32": def GetTokenInformation(token: Any, information_class: Any) -> Any: ... def OpenProcessToken(proc_handle: Any, access: Any) -> Any: ... def get_current_user() -> TOKEN_USER: ... - def get_security_attributes_for_user(user: Optional[TOKEN_USER] = ...) -> SECURITY_ATTRIBUTES: ... + def get_security_attributes_for_user(user: TOKEN_USER | None = ...) -> SECURITY_ATTRIBUTES: ... diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index 58edc088e01c..e8e20726f329 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -9,22 +9,22 @@ _InteractiveCallback = Callable[[str, str, List[Tuple[str, bool]]], List[str]] class AuthHandler: transport: Transport - username: Optional[str] + username: str | None authenticated: bool - auth_event: Optional[Event] + auth_event: Event | None auth_method: str - banner: Optional[str] - password: Optional[str] - private_key: Optional[PKey] - interactive_handler: Optional[_InteractiveCallback] - submethods: Optional[str] - auth_username: Optional[str] + banner: str | None + password: str | None + private_key: PKey | None + interactive_handler: _InteractiveCallback | None + submethods: str | None + auth_username: str | None auth_fail_count: int - gss_host: Optional[str] + gss_host: str | None gss_deleg_creds: bool def __init__(self, transport: Transport) -> None: ... def is_authenticated(self) -> bool: ... - def get_username(self) -> Optional[str]: ... + def get_username(self) -> str | None: ... def auth_none(self, username: str, event: Event) -> None: ... def auth_publickey(self, username: str, key: PKey, event: Event) -> None: ... def auth_password(self, username: str, password: str, event: Event) -> None: ... diff --git a/stubs/paramiko/paramiko/ber.pyi b/stubs/paramiko/paramiko/ber.pyi index 700ebd1616ad..dd14ce7bdfce 100644 --- a/stubs/paramiko/paramiko/ber.pyi +++ b/stubs/paramiko/paramiko/ber.pyi @@ -7,10 +7,10 @@ class BER: idx: int def __init__(self, content: bytes = ...) -> None: ... def asbytes(self) -> bytes: ... - def decode(self) -> Union[None, int, List[int]]: ... - def decode_next(self) -> Union[None, int, List[int]]: ... + def decode(self) -> None | int | List[int]: ... + def decode_next(self) -> None | int | List[int]: ... @staticmethod - def decode_sequence(data: bytes) -> List[Union[int, List[int]]]: ... + def decode_sequence(data: bytes) -> List[int | List[int]]: ... def encode_tlv(self, ident: int, val: bytes) -> None: ... def encode(self, x: Any) -> None: ... @staticmethod diff --git a/stubs/paramiko/paramiko/buffered_pipe.pyi b/stubs/paramiko/paramiko/buffered_pipe.pyi index e29b65de6f63..4e1ad59afac3 100644 --- a/stubs/paramiko/paramiko/buffered_pipe.pyi +++ b/stubs/paramiko/paramiko/buffered_pipe.pyi @@ -10,7 +10,7 @@ class BufferedPipe(Generic[_T]): def set_event(self, event: Event) -> None: ... def feed(self, data: _T) -> None: ... def read_ready(self) -> bool: ... - def read(self, nbytes: int, timeout: Optional[float] = ...) -> _T: ... + def read(self, nbytes: int, timeout: float | None = ...) -> _T: ... def empty(self) -> _T: ... def close(self) -> None: ... def __len__(self) -> int: ... diff --git a/stubs/paramiko/paramiko/channel.pyi b/stubs/paramiko/paramiko/channel.pyi index f8a27410ecaf..ed4f8f44c537 100644 --- a/stubs/paramiko/paramiko/channel.pyi +++ b/stubs/paramiko/paramiko/channel.pyi @@ -14,13 +14,13 @@ def open_only(func: _F) -> Callable[[_F], _F]: ... class Channel(ClosingContextManager): chanid: int remote_chanid: int - transport: Optional[Transport] + transport: Transport | None active: bool eof_received: int eof_sent: int in_buffer: BufferedPipe[Any] in_stderr_buffer: BufferedPipe[Any] - timeout: Optional[float] + timeout: float | None closed: bool ultra_debug: bool lock: Lock @@ -55,10 +55,10 @@ class Channel(ClosingContextManager): def request_x11( self, screen_number: int = ..., - auth_protocol: Optional[str] = ..., - auth_cookie: Optional[str] = ..., + auth_protocol: str | None = ..., + auth_cookie: str | None = ..., single_connection: bool = ..., - handler: Optional[Callable[[Channel, Tuple[str, int]], None]] = ..., + handler: Callable[[Channel, Tuple[str, int]], None] | None = ..., ) -> bytes: ... def request_forward_agent(self, handler: Callable[[Channel], None]) -> bool: ... def get_transport(self) -> Transport: ... @@ -66,8 +66,8 @@ class Channel(ClosingContextManager): def get_name(self) -> str: ... def get_id(self) -> int: ... def set_combine_stderr(self, combine: bool) -> bool: ... - def settimeout(self, timeout: Optional[float]) -> None: ... - def gettimeout(self) -> Optional[float]: ... + def settimeout(self, timeout: float | None) -> None: ... + def gettimeout(self) -> float | None: ... def setblocking(self, blocking: bool) -> None: ... def getpeername(self) -> str: ... def close(self) -> None: ... diff --git a/stubs/paramiko/paramiko/client.pyi b/stubs/paramiko/paramiko/client.pyi index a66775e7c88d..3798a355f9c2 100644 --- a/stubs/paramiko/paramiko/client.pyi +++ b/stubs/paramiko/paramiko/client.pyi @@ -10,43 +10,43 @@ from paramiko.util import ClosingContextManager class SSHClient(ClosingContextManager): def __init__(self) -> None: ... - def load_system_host_keys(self, filename: Optional[str] = ...) -> None: ... + def load_system_host_keys(self, filename: str | None = ...) -> None: ... def load_host_keys(self, filename: str) -> None: ... def save_host_keys(self, filename: str) -> None: ... def get_host_keys(self) -> HostKeys: ... def set_log_channel(self, name: str) -> None: ... - def set_missing_host_key_policy(self, policy: Union[Type[MissingHostKeyPolicy], MissingHostKeyPolicy]) -> None: ... + def set_missing_host_key_policy(self, policy: Type[MissingHostKeyPolicy] | MissingHostKeyPolicy) -> None: ... def connect( self, hostname: str, port: int = ..., - username: Optional[str] = ..., - password: Optional[str] = ..., - pkey: Optional[PKey] = ..., - key_filename: Optional[str] = ..., - timeout: Optional[float] = ..., + username: str | None = ..., + password: str | None = ..., + pkey: PKey | None = ..., + key_filename: str | None = ..., + timeout: float | None = ..., allow_agent: bool = ..., look_for_keys: bool = ..., compress: bool = ..., - sock: Optional[socket] = ..., + sock: socket | None = ..., gss_auth: bool = ..., gss_kex: bool = ..., gss_deleg_creds: bool = ..., - gss_host: Optional[str] = ..., - banner_timeout: Optional[float] = ..., - auth_timeout: Optional[float] = ..., + gss_host: str | None = ..., + banner_timeout: float | None = ..., + auth_timeout: float | None = ..., gss_trust_dns: bool = ..., - passphrase: Optional[str] = ..., - disabled_algorithms: Optional[Dict[str, Iterable[str]]] = ..., + passphrase: str | None = ..., + disabled_algorithms: Dict[str, Iterable[str]] | None = ..., ) -> None: ... def close(self) -> None: ... def exec_command( self, command: str, bufsize: int = ..., - timeout: Optional[float] = ..., + timeout: float | None = ..., get_pty: bool = ..., - environment: Optional[Dict[str, str]] = ..., + environment: Dict[str, str] | None = ..., ) -> Tuple[ChannelStdinFile, ChannelFile, ChannelStderrFile]: ... def invoke_shell( self, @@ -55,10 +55,10 @@ class SSHClient(ClosingContextManager): height: int = ..., width_pixels: int = ..., height_pixels: int = ..., - environment: Optional[Mapping[str, str]] = ..., + environment: Mapping[str, str] | None = ..., ) -> Channel: ... def open_sftp(self) -> SFTPClient: ... - def get_transport(self) -> Optional[Transport]: ... + def get_transport(self) -> Transport | None: ... class MissingHostKeyPolicy: def missing_host_key(self, client: SSHClient, hostname: str, key: PKey) -> None: ... diff --git a/stubs/paramiko/paramiko/config.pyi b/stubs/paramiko/paramiko/config.pyi index 5367be4305ad..a738f6cb6450 100644 --- a/stubs/paramiko/paramiko/config.pyi +++ b/stubs/paramiko/paramiko/config.pyi @@ -20,10 +20,10 @@ class SSHConfig: def get_hostnames(self) -> Set[str]: ... class LazyFqdn: - fqdn: Optional[str] + fqdn: str | None config: SSHConfig - host: Optional[str] - def __init__(self, config: SSHConfigDict, host: Optional[str] = ...) -> None: ... + host: str | None + def __init__(self, config: SSHConfigDict, host: str | None = ...) -> None: ... class SSHConfigDict(Dict[str, str]): def __init__(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/stubs/paramiko/paramiko/dsskey.pyi b/stubs/paramiko/paramiko/dsskey.pyi index a790cdec8012..8baf6aaa590b 100644 --- a/stubs/paramiko/paramiko/dsskey.pyi +++ b/stubs/paramiko/paramiko/dsskey.pyi @@ -4,21 +4,21 @@ from paramiko.message import Message from paramiko.pkey import PKey class DSSKey(PKey): - p: Optional[int] - q: Optional[int] - g: Optional[int] - y: Optional[int] - x: Optional[int] + p: int | None + q: int | None + g: int | None + y: int | None + x: int | None public_blob: None size: int def __init__( self, - msg: Optional[Message] = ..., - data: Optional[bytes] = ..., - filename: Optional[str] = ..., - password: Optional[str] = ..., - vals: Optional[Tuple[int, int, int, int]] = ..., - file_obj: Optional[IO[str]] = ..., + msg: Message | None = ..., + data: bytes | None = ..., + filename: str | None = ..., + password: str | None = ..., + vals: Tuple[int, int, int, int] | None = ..., + file_obj: IO[str] | None = ..., ) -> None: ... def asbytes(self) -> bytes: ... def __hash__(self) -> int: ... @@ -27,7 +27,7 @@ class DSSKey(PKey): def can_sign(self) -> bool: ... def sign_ssh_data(self, data: bytes) -> Message: ... def verify_ssh_sig(self, data: bytes, msg: Message) -> bool: ... - def write_private_key_file(self, filename: str, password: Optional[str] = ...) -> None: ... - def write_private_key(self, file_obj: IO[str], password: Optional[str] = ...) -> None: ... + def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ... + def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... @staticmethod - def generate(bits: int = ..., progress_func: Optional[Callable[..., Any]] = ...) -> DSSKey: ... + def generate(bits: int = ..., progress_func: Callable[..., Any] | None = ...) -> DSSKey: ... diff --git a/stubs/paramiko/paramiko/ecdsakey.pyi b/stubs/paramiko/paramiko/ecdsakey.pyi index 763dd9742fe5..b1ca8ae74f40 100644 --- a/stubs/paramiko/paramiko/ecdsakey.pyi +++ b/stubs/paramiko/paramiko/ecdsakey.pyi @@ -17,23 +17,23 @@ class _ECDSACurveSet: ecdsa_curves: Sequence[_ECDSACurve] def __init__(self, ecdsa_curves: Sequence[_ECDSACurve]) -> None: ... def get_key_format_identifier_list(self) -> List[str]: ... - def get_by_curve_class(self, curve_class: Type[Any]) -> Optional[_ECDSACurve]: ... - def get_by_key_format_identifier(self, key_format_identifier: str) -> Optional[_ECDSACurve]: ... - def get_by_key_length(self, key_length: int) -> Optional[_ECDSACurve]: ... + def get_by_curve_class(self, curve_class: Type[Any]) -> _ECDSACurve | None: ... + def get_by_key_format_identifier(self, key_format_identifier: str) -> _ECDSACurve | None: ... + def get_by_key_length(self, key_length: int) -> _ECDSACurve | None: ... class ECDSAKey(PKey): verifying_key: EllipticCurvePublicKey signing_key: EllipticCurvePrivateKey public_blob: None - ecdsa_curve: Optional[_ECDSACurve] + ecdsa_curve: _ECDSACurve | None def __init__( self, - msg: Optional[Message] = ..., - data: Optional[bytes] = ..., - filename: Optional[str] = ..., - password: Optional[str] = ..., - vals: Optional[Tuple[EllipticCurvePrivateKey, EllipticCurvePublicKey]] = ..., - file_obj: Optional[IO[str]] = ..., + msg: Message | None = ..., + data: bytes | None = ..., + filename: str | None = ..., + password: str | None = ..., + vals: Tuple[EllipticCurvePrivateKey, EllipticCurvePublicKey] | None = ..., + file_obj: IO[str] | None = ..., validate_point: bool = ..., ) -> None: ... @classmethod @@ -45,9 +45,9 @@ class ECDSAKey(PKey): def can_sign(self) -> bool: ... def sign_ssh_data(self, data: bytes) -> Message: ... def verify_ssh_sig(self, data: bytes, msg: Message) -> bool: ... - def write_private_key_file(self, filename: str, password: Optional[str] = ...) -> None: ... - def write_private_key(self, file_obj: IO[str], password: Optional[str] = ...) -> None: ... + def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ... + def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... @classmethod def generate( - cls, curve: EllipticCurve = ..., progress_func: Optional[Callable[..., Any]] = ..., bits: Optional[int] = ... + cls, curve: EllipticCurve = ..., progress_func: Callable[..., Any] | None = ..., bits: int | None = ... ) -> ECDSAKey: ... diff --git a/stubs/paramiko/paramiko/ed25519key.pyi b/stubs/paramiko/paramiko/ed25519key.pyi index 75fab8420599..73bb2b69cdca 100644 --- a/stubs/paramiko/paramiko/ed25519key.pyi +++ b/stubs/paramiko/paramiko/ed25519key.pyi @@ -7,11 +7,11 @@ class Ed25519Key(PKey): public_blob: None def __init__( self, - msg: Optional[Message] = ..., - data: Optional[bytes] = ..., - filename: Optional[str] = ..., - password: Optional[str] = ..., - file_obj: Optional[IO[str]] = ..., + msg: Message | None = ..., + data: bytes | None = ..., + filename: str | None = ..., + password: str | None = ..., + file_obj: IO[str] | None = ..., ) -> None: ... def asbytes(self) -> bytes: ... def __hash__(self) -> int: ... diff --git a/stubs/paramiko/paramiko/file.pyi b/stubs/paramiko/paramiko/file.pyi index 38587045dd37..2e2732ea2f6b 100644 --- a/stubs/paramiko/paramiko/file.pyi +++ b/stubs/paramiko/paramiko/file.pyi @@ -15,7 +15,7 @@ class BufferedFile(ClosingContextManager, Generic[AnyStr]): FLAG_LINE_BUFFERED: int FLAG_UNIVERSAL_NEWLINE: int - newlines: Union[None, AnyStr, Tuple[AnyStr, ...]] + newlines: None | AnyStr | Tuple[AnyStr, ...] def __init__(self) -> None: ... def __del__(self) -> None: ... def __iter__(self) -> BufferedFile[Any]: ... @@ -26,9 +26,9 @@ class BufferedFile(ClosingContextManager, Generic[AnyStr]): def writable(self) -> bool: ... def seekable(self) -> bool: ... def readinto(self, buff: bytearray) -> int: ... - def read(self, size: Optional[int] = ...) -> bytes: ... - def readline(self, size: Optional[int] = ...) -> AnyStr: ... - def readlines(self, sizehint: Optional[int] = ...) -> List[AnyStr]: ... + def read(self, size: int | None = ...) -> bytes: ... + def readline(self, size: int | None = ...) -> AnyStr: ... + def readlines(self, sizehint: int | None = ...) -> List[AnyStr]: ... def seek(self, offset: int, whence: int = ...) -> None: ... def tell(self) -> int: ... def write(self, data: AnyStr) -> None: ... diff --git a/stubs/paramiko/paramiko/hostkeys.pyi b/stubs/paramiko/paramiko/hostkeys.pyi index 9d3ade5120ee..f307cc5dcba7 100644 --- a/stubs/paramiko/paramiko/hostkeys.pyi +++ b/stubs/paramiko/paramiko/hostkeys.pyi @@ -13,11 +13,11 @@ class _SubDict(MutableMapping[str, PKey]): def keys(self) -> List[str]: ... # type: ignore class HostKeys(MutableMapping[str, _SubDict]): - def __init__(self, filename: Optional[str] = ...) -> None: ... + def __init__(self, filename: str | None = ...) -> None: ... def add(self, hostname: str, keytype: str, key: PKey) -> None: ... def load(self, filename: str) -> None: ... def save(self, filename: str) -> None: ... - def lookup(self, hostname: str) -> Optional[_SubDict]: ... + def lookup(self, hostname: str) -> _SubDict | None: ... def check(self, hostname: str, key: PKey) -> bool: ... def clear(self) -> None: ... def __iter__(self) -> Iterator[str]: ... @@ -28,7 +28,7 @@ class HostKeys(MutableMapping[str, _SubDict]): def keys(self) -> List[str]: ... # type: ignore def values(self) -> List[_SubDict]: ... # type: ignore @staticmethod - def hash_host(hostname: str, salt: Optional[str] = ...) -> str: ... + def hash_host(hostname: str, salt: str | None = ...) -> str: ... class InvalidHostKey(Exception): line: str @@ -39,7 +39,7 @@ class HostKeyEntry: valid: bool hostnames: str key: PKey - def __init__(self, hostnames: Optional[List[str]] = ..., key: Optional[PKey] = ...) -> None: ... + def __init__(self, hostnames: List[str] | None = ..., key: PKey | None = ...) -> None: ... @classmethod - def from_line(cls, line: str, lineno: Optional[int] = ...) -> Optional[HostKeyEntry]: ... - def to_line(self) -> Optional[str]: ... + def from_line(cls, line: str, lineno: int | None = ...) -> HostKeyEntry | None: ... + def to_line(self) -> str | None: ... diff --git a/stubs/paramiko/paramiko/kex_curve25519.pyi b/stubs/paramiko/paramiko/kex_curve25519.pyi index 03e76bbe8bf3..6d03704b39f3 100644 --- a/stubs/paramiko/paramiko/kex_curve25519.pyi +++ b/stubs/paramiko/paramiko/kex_curve25519.pyi @@ -17,7 +17,7 @@ c_MSG_KEXECDH_REPLY: bytes class KexCurve25519: hash_algo: Callable[[ReadableBuffer], _Hash] transport: Transport - key: Optional[X25519PrivateKey] + key: X25519PrivateKey | None def __init__(self, transport: Transport) -> None: ... @classmethod def is_available(cls) -> bool: ... diff --git a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi index 5d6bf1cad3d1..70be59d25ae5 100644 --- a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi +++ b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi @@ -19,9 +19,9 @@ class KexNistp256: hash_algo: Callable[[ReadableBuffer], _Hash] curve: EllipticCurve transport: Transport - P: Union[int, EllipticCurvePrivateKey] - Q_C: Optional[EllipticCurvePublicKey] - Q_S: Optional[EllipticCurvePublicKey] + P: int | EllipticCurvePrivateKey + Q_C: EllipticCurvePublicKey | None + Q_S: EllipticCurvePublicKey | None def __init__(self, transport: Transport) -> None: ... def start_kex(self) -> None: ... def parse_next(self, ptype: int, m: Message) -> None: ... diff --git a/stubs/paramiko/paramiko/kex_gex.pyi b/stubs/paramiko/paramiko/kex_gex.pyi index 32e4a401dc2a..36f2b27432d0 100644 --- a/stubs/paramiko/paramiko/kex_gex.pyi +++ b/stubs/paramiko/paramiko/kex_gex.pyi @@ -23,12 +23,12 @@ class KexGex: preferred_bits: int hash_algo: Callable[[ReadableBuffer], _Hash] = ... transport: Transport - p: Optional[int] - q: Optional[int] - g: Optional[int] - x: Optional[int] - e: Optional[int] - f: Optional[int] + p: int | None + q: int | None + g: int | None + x: int | None + e: int | None + f: int | None old_style: bool def __init__(self, transport: Transport) -> None: ... def start_kex(self, _test_old_style: bool = ...) -> None: ... diff --git a/stubs/paramiko/paramiko/kex_gss.pyi b/stubs/paramiko/paramiko/kex_gss.pyi index 255aee3dcb5c..c38b2be3afcb 100644 --- a/stubs/paramiko/paramiko/kex_gss.pyi +++ b/stubs/paramiko/paramiko/kex_gss.pyi @@ -28,7 +28,7 @@ class KexGSSGroup1: NAME: str transport: Transport kexgss: _SSH_GSSAuth - gss_host: Optional[str] + gss_host: str | None x: int e: int f: int @@ -48,13 +48,13 @@ class KexGSSGex: preferred_bits: int transport: Transport kexgss: _SSH_GSSAuth - gss_host: Optional[str] - p: Optional[int] - q: Optional[int] - g: Optional[int] - x: Optional[int] - e: Optional[int] - f: Optional[int] + gss_host: str | None + p: int | None + q: int | None + g: int | None + x: int | None + e: int | None + f: int | None old_style: bool def __init__(self, transport: Transport) -> None: ... def start_kex(self) -> None: ... diff --git a/stubs/paramiko/paramiko/message.pyi b/stubs/paramiko/paramiko/message.pyi index 5f43304d469c..05c3111fe3b8 100644 --- a/stubs/paramiko/paramiko/message.pyi +++ b/stubs/paramiko/paramiko/message.pyi @@ -14,7 +14,7 @@ class Message: big_int: int packet: BytesIO seqno: int # only when packet.Packetizer.read_message() is used - def __init__(self, content: Optional[bytes] = ...) -> None: ... + def __init__(self, content: bytes | None = ...) -> None: ... def asbytes(self) -> bytes: ... def rewind(self) -> None: ... def get_remainder(self) -> bytes: ... diff --git a/stubs/paramiko/paramiko/pkey.pyi b/stubs/paramiko/paramiko/pkey.pyi index 16ff5ea1366e..50bc1ea3a1aa 100644 --- a/stubs/paramiko/paramiko/pkey.pyi +++ b/stubs/paramiko/paramiko/pkey.pyi @@ -9,10 +9,10 @@ def _unpad_openssh(data: bytes) -> bytes: ... _PK = TypeVar("_PK", bound=PKey) class PKey: - public_blob: Optional[PublicBlob] + public_blob: PublicBlob | None BEGIN_TAG: Pattern[str] END_TAG: Pattern[str] - def __init__(self, msg: Optional[Message] = ..., data: Optional[str] = ...) -> None: ... + def __init__(self, msg: Message | None = ..., data: str | None = ...) -> None: ... def asbytes(self) -> bytes: ... def __cmp__(self, other: object) -> int: ... def __eq__(self, other: object) -> bool: ... @@ -24,18 +24,18 @@ class PKey: def sign_ssh_data(self, data: bytes) -> Message: ... def verify_ssh_sig(self, data: bytes, msg: Message) -> bool: ... @classmethod - def from_private_key_file(cls: Type[_PK], filename: str, password: Optional[str] = ...) -> _PK: ... + def from_private_key_file(cls: Type[_PK], filename: str, password: str | None = ...) -> _PK: ... @classmethod - def from_private_key(cls: Type[_PK], file_obj: IO[str], password: Optional[str] = ...) -> _PK: ... - def write_private_key_file(self, filename: str, password: Optional[str] = ...) -> None: ... - def write_private_key(self, file_obj: IO[str], password: Optional[str] = ...) -> None: ... - def load_certificate(self, value: Union[Message, str]) -> None: ... + def from_private_key(cls: Type[_PK], file_obj: IO[str], password: str | None = ...) -> _PK: ... + def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ... + def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... + def load_certificate(self, value: Message | str) -> None: ... class PublicBlob: key_type: str key_blob: str comment: str - def __init__(self, type_: str, blob: bytes, comment: Optional[str] = ...) -> None: ... + def __init__(self, type_: str, blob: bytes, comment: str | None = ...) -> None: ... @classmethod def from_file(cls, filename: str) -> PublicBlob: ... @classmethod diff --git a/stubs/paramiko/paramiko/proxy.pyi b/stubs/paramiko/paramiko/proxy.pyi index 7070f0e72b08..fb50e6288c6a 100644 --- a/stubs/paramiko/paramiko/proxy.pyi +++ b/stubs/paramiko/paramiko/proxy.pyi @@ -6,7 +6,7 @@ from paramiko.util import ClosingContextManager class ProxyCommand(ClosingContextManager): cmd: List[str] process: Popen[Any] - timeout: Optional[float] + timeout: float | None def __init__(self, command_line: str) -> None: ... def send(self, content: bytes) -> int: ... def recv(self, size: int) -> bytes: ... diff --git a/stubs/paramiko/paramiko/py3compat.pyi b/stubs/paramiko/paramiko/py3compat.pyi index 94256ec5cf51..06b60eac0c71 100644 --- a/stubs/paramiko/paramiko/py3compat.pyi +++ b/stubs/paramiko/paramiko/py3compat.pyi @@ -5,11 +5,11 @@ _T = TypeVar("_T") PY2: bool -string_types: Union[Type[Any], Sequence[Type[Any]]] -text_type: Union[Type[Any], Sequence[Type[Any]]] -bytes_types: Union[Type[Any], Sequence[Type[Any]]] +string_types: Type[Any] | Sequence[Type[Any]] +text_type: Type[Any] | Sequence[Type[Any]] +bytes_types: Type[Any] | Sequence[Type[Any]] bytes = bytes -integer_types: Union[Type[Any], Sequence[Type[Any]]] +integer_types: Type[Any] | Sequence[Type[Any]] long = int def input(prompt: Any) -> str: ... @@ -29,12 +29,12 @@ else: StringIO = cStringIO.StringIO BytesIO = StringIO -def byte_ord(c: Union[int, str]) -> int: ... +def byte_ord(c: int | str) -> int: ... def byte_chr(c: int) -> bytes: ... def byte_mask(c: int, mask: int) -> bytes: ... -def b(s: Union[bytes, str], encoding: str = ...) -> bytes: ... -def u(s: Union[bytes, str], encoding: str = ...) -> Text: ... -def b2s(s: Union[bytes, str]) -> str: ... +def b(s: bytes | str, encoding: str = ...) -> bytes: ... +def u(s: bytes | str, encoding: str = ...) -> Text: ... +def b2s(s: bytes | str) -> str: ... def is_callable(c: Any) -> bool: ... def next(c: Iterable[_T]) -> _T: ... diff --git a/stubs/paramiko/paramiko/rsakey.pyi b/stubs/paramiko/paramiko/rsakey.pyi index f0920d4a0de0..85b949c202c8 100644 --- a/stubs/paramiko/paramiko/rsakey.pyi +++ b/stubs/paramiko/paramiko/rsakey.pyi @@ -5,16 +5,16 @@ from paramiko.message import Message from paramiko.pkey import PKey class RSAKey(PKey): - key: Union[None, RSAPublicKey, RSAPrivateKey] + key: None | RSAPublicKey | RSAPrivateKey public_blob: None def __init__( self, - msg: Optional[Message] = ..., - data: Optional[bytes] = ..., - filename: Optional[str] = ..., - password: Optional[str] = ..., - key: Union[None, RSAPublicKey, RSAPrivateKey] = ..., - file_obj: Optional[IO[str]] = ..., + msg: Message | None = ..., + data: bytes | None = ..., + filename: str | None = ..., + password: str | None = ..., + key: None | RSAPublicKey | RSAPrivateKey = ..., + file_obj: IO[str] | None = ..., ) -> None: ... @property def size(self) -> int: ... @@ -27,7 +27,7 @@ class RSAKey(PKey): def can_sign(self) -> bool: ... def sign_ssh_data(self, data: bytes) -> Message: ... def verify_ssh_sig(self, data: bytes, msg: Message) -> bool: ... - def write_private_key_file(self, filename: str, password: Optional[str] = ...) -> None: ... - def write_private_key(self, file_obj: IO[str], password: Optional[str] = ...) -> None: ... + def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ... + def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... @staticmethod - def generate(bits: int, progress_func: Optional[Callable[..., Any]] = ...) -> RSAKey: ... + def generate(bits: int, progress_func: Callable[..., Any] | None = ...) -> RSAKey: ... diff --git a/stubs/paramiko/paramiko/server.pyi b/stubs/paramiko/paramiko/server.pyi index 584fb62fbc99..fcf3a6d4f067 100644 --- a/stubs/paramiko/paramiko/server.pyi +++ b/stubs/paramiko/paramiko/server.pyi @@ -12,14 +12,14 @@ class ServerInterface: def check_auth_none(self, username: str) -> int: ... def check_auth_password(self, username: str, password: str) -> int: ... def check_auth_publickey(self, username: str, key: PKey) -> int: ... - def check_auth_interactive(self, username: str, submethods: str) -> Union[int, InteractiveQuery]: ... - def check_auth_interactive_response(self, responses: List[str]) -> Union[int, InteractiveQuery]: ... - def check_auth_gssapi_with_mic(self, username: str, gss_authenticated: int = ..., cc_file: Optional[str] = ...) -> int: ... - def check_auth_gssapi_keyex(self, username: str, gss_authenticated: int = ..., cc_file: Optional[str] = ...) -> int: ... + def check_auth_interactive(self, username: str, submethods: str) -> int | InteractiveQuery: ... + def check_auth_interactive_response(self, responses: List[str]) -> int | InteractiveQuery: ... + def check_auth_gssapi_with_mic(self, username: str, gss_authenticated: int = ..., cc_file: str | None = ...) -> int: ... + def check_auth_gssapi_keyex(self, username: str, gss_authenticated: int = ..., cc_file: str | None = ...) -> int: ... def enable_auth_gssapi(self) -> bool: ... def check_port_forward_request(self, address: str, port: int) -> int: ... def cancel_port_forward_request(self, address: str, port: int) -> None: ... - def check_global_request(self, kind: str, msg: Message) -> Union[bool, Tuple[Any, ...]]: ... + def check_global_request(self, kind: str, msg: Message) -> bool | Tuple[Any, ...]: ... def check_channel_pty_request( self, channel: Channel, term: str, width: int, height: int, pixelwidth: int, pixelheight: int, modes: str ) -> bool: ... @@ -35,13 +35,13 @@ class ServerInterface: def check_channel_forward_agent_request(self, channel: Channel) -> bool: ... def check_channel_direct_tcpip_request(self, chanid: int, origin: Tuple[str, int], destination: Tuple[str, int]) -> int: ... def check_channel_env_request(self, channel: Channel, name: str, value: str) -> bool: ... - def get_banner(self) -> Tuple[Optional[str], Optional[str]]: ... + def get_banner(self) -> Tuple[str | None, str | None]: ... class InteractiveQuery: name: str instructions: str prompts: List[Tuple[str, bool]] - def __init__(self, name: str = ..., instructions: str = ..., *prompts: Union[str, Tuple[str, bool]]) -> None: ... + def __init__(self, name: str = ..., instructions: str = ..., *prompts: str | Tuple[str, bool]) -> None: ... def add_prompt(self, prompt: str, echo: bool = ...) -> None: ... class SubsystemHandler(threading.Thread): diff --git a/stubs/paramiko/paramiko/sftp.pyi b/stubs/paramiko/paramiko/sftp.pyi index d7a9ad7f8dc1..e1423fbb85c2 100644 --- a/stubs/paramiko/paramiko/sftp.pyi +++ b/stubs/paramiko/paramiko/sftp.pyi @@ -56,6 +56,6 @@ class SFTPError(Exception): ... class BaseSFTP: logger: Logger - sock: Optional[Channel] + sock: Channel | None ultra_debug: bool def __init__(self) -> None: ... diff --git a/stubs/paramiko/paramiko/sftp_attr.pyi b/stubs/paramiko/paramiko/sftp_attr.pyi index 97f534a7d212..a876e7d89bd6 100644 --- a/stubs/paramiko/paramiko/sftp_attr.pyi +++ b/stubs/paramiko/paramiko/sftp_attr.pyi @@ -7,16 +7,16 @@ class SFTPAttributes: FLAG_PERMISSIONS: int FLAG_AMTIME: int FLAG_EXTENDED: int - st_size: Optional[int] - st_uid: Optional[int] - st_gid: Optional[int] - st_mode: Optional[int] - st_atime: Optional[int] - st_mtime: Optional[int] + st_size: int | None + st_uid: int | None + st_gid: int | None + st_mode: int | None + st_atime: int | None + st_mtime: int | None filename: str # only when from_stat() is used longname: str # only when from_stat() is used attr: Dict[str, str] def __init__(self) -> None: ... @classmethod - def from_stat(cls, obj: stat_result, filename: Optional[str] = ...) -> SFTPAttributes: ... + def from_stat(cls, obj: stat_result, filename: str | None = ...) -> SFTPAttributes: ... def asbytes(self) -> bytes: ... diff --git a/stubs/paramiko/paramiko/sftp_client.pyi b/stubs/paramiko/paramiko/sftp_client.pyi index 26d041f8c37f..d39eb7392705 100644 --- a/stubs/paramiko/paramiko/sftp_client.pyi +++ b/stubs/paramiko/paramiko/sftp_client.pyi @@ -20,48 +20,48 @@ class SFTPClient(BaseSFTP, ClosingContextManager): def __init__(self, sock: Channel) -> None: ... @classmethod def from_transport( - cls, t: Transport, window_size: Optional[int] = ..., max_packet_size: Optional[int] = ... - ) -> Optional[SFTPClient]: ... + cls, t: Transport, window_size: int | None = ..., max_packet_size: int | None = ... + ) -> SFTPClient | None: ... def close(self) -> None: ... - def get_channel(self) -> Optional[Channel]: ... + def get_channel(self) -> Channel | None: ... def listdir(self, path: str = ...) -> List[str]: ... def listdir_attr(self, path: str = ...) -> List[SFTPAttributes]: ... - def listdir_iter(self, path: Union[bytes, Text] = ..., read_aheads: int = ...) -> Iterator[SFTPAttributes]: ... - def open(self, filename: Union[bytes, Text], mode: str = ..., bufsize: int = ...) -> SFTPFile: ... + def listdir_iter(self, path: bytes | Text = ..., read_aheads: int = ...) -> Iterator[SFTPAttributes]: ... + def open(self, filename: bytes | Text, mode: str = ..., bufsize: int = ...) -> SFTPFile: ... file = open - def remove(self, path: Union[bytes, Text]) -> None: ... + def remove(self, path: bytes | Text) -> None: ... unlink = remove - def rename(self, oldpath: Union[bytes, Text], newpath: Union[bytes, Text]) -> None: ... - def posix_rename(self, oldpath: Union[bytes, Text], newpath: Union[bytes, Text]) -> None: ... - def mkdir(self, path: Union[bytes, Text], mode: int = ...) -> None: ... - def rmdir(self, path: Union[bytes, Text]) -> None: ... - def stat(self, path: Union[bytes, Text]) -> SFTPAttributes: ... - def lstat(self, path: Union[bytes, Text]) -> SFTPAttributes: ... - def symlink(self, source: Union[bytes, Text], dest: Union[bytes, Text]) -> None: ... - def chmod(self, path: Union[bytes, Text], mode: int) -> None: ... - def chown(self, path: Union[bytes, Text], uid: int, gid: int) -> None: ... - def utime(self, path: Union[bytes, Text], times: Optional[Tuple[float, float]]) -> None: ... - def truncate(self, path: Union[bytes, Text], size: int) -> None: ... - def readlink(self, path: Union[bytes, Text]) -> Optional[Text]: ... - def normalize(self, path: Union[bytes, Text]) -> Text: ... - def chdir(self, path: Union[None, bytes, Text] = ...) -> None: ... - def getcwd(self) -> Optional[Text]: ... + def rename(self, oldpath: bytes | Text, newpath: bytes | Text) -> None: ... + def posix_rename(self, oldpath: bytes | Text, newpath: bytes | Text) -> None: ... + def mkdir(self, path: bytes | Text, mode: int = ...) -> None: ... + def rmdir(self, path: bytes | Text) -> None: ... + def stat(self, path: bytes | Text) -> SFTPAttributes: ... + def lstat(self, path: bytes | Text) -> SFTPAttributes: ... + def symlink(self, source: bytes | Text, dest: bytes | Text) -> None: ... + def chmod(self, path: bytes | Text, mode: int) -> None: ... + def chown(self, path: bytes | Text, uid: int, gid: int) -> None: ... + def utime(self, path: bytes | Text, times: Tuple[float, float] | None) -> None: ... + def truncate(self, path: bytes | Text, size: int) -> None: ... + def readlink(self, path: bytes | Text) -> Text | None: ... + def normalize(self, path: bytes | Text) -> Text: ... + def chdir(self, path: None | bytes | Text = ...) -> None: ... + def getcwd(self) -> Text | None: ... def putfo( self, fl: IO[bytes], - remotepath: Union[bytes, Text], + remotepath: bytes | Text, file_size: int = ..., - callback: Optional[_Callback] = ..., + callback: _Callback | None = ..., confirm: bool = ..., ) -> SFTPAttributes: ... def put( self, - localpath: Union[bytes, Text], - remotepath: Union[bytes, Text], - callback: Optional[_Callback] = ..., + localpath: bytes | Text, + remotepath: bytes | Text, + callback: _Callback | None = ..., confirm: bool = ..., ) -> SFTPAttributes: ... - def getfo(self, remotepath: Union[bytes, Text], fl: IO[bytes], callback: Optional[_Callback] = ...) -> int: ... - def get(self, remotepath: Union[bytes, Text], localpath: Union[bytes, Text], callback: Optional[_Callback] = ...) -> None: ... + def getfo(self, remotepath: bytes | Text, fl: IO[bytes], callback: _Callback | None = ...) -> int: ... + def get(self, remotepath: bytes | Text, localpath: bytes | Text, callback: _Callback | None = ...) -> None: ... class SFTP(SFTPClient): ... diff --git a/stubs/paramiko/paramiko/sftp_file.pyi b/stubs/paramiko/paramiko/sftp_file.pyi index 52411e9dd332..3b216d27586b 100644 --- a/stubs/paramiko/paramiko/sftp_file.pyi +++ b/stubs/paramiko/paramiko/sftp_file.pyi @@ -21,9 +21,9 @@ class SFTPFile(BufferedFile[Any]): def stat(self) -> SFTPAttributes: ... def chmod(self, mode: int) -> None: ... def chown(self, uid: int, gid: int) -> None: ... - def utime(self, times: Optional[Tuple[float, float]]) -> None: ... + def utime(self, times: Tuple[float, float] | None) -> None: ... def truncate(self, size: int) -> None: ... def check(self, hash_algorithm: str, offset: int = ..., length: int = ..., block_size: int = ...) -> bytes: ... def set_pipelined(self, pipelined: bool = ...) -> None: ... - def prefetch(self, file_size: Optional[int] = ...) -> None: ... + def prefetch(self, file_size: int | None = ...) -> None: ... def readv(self, chunks: Sequence[Tuple[int, int]]) -> Iterator[bytes]: ... diff --git a/stubs/paramiko/paramiko/sftp_handle.pyi b/stubs/paramiko/paramiko/sftp_handle.pyi index b288cb9033db..03d0daba59da 100644 --- a/stubs/paramiko/paramiko/sftp_handle.pyi +++ b/stubs/paramiko/paramiko/sftp_handle.pyi @@ -6,7 +6,7 @@ from paramiko.util import ClosingContextManager class SFTPHandle(ClosingContextManager): def __init__(self, flags: int = ...) -> None: ... def close(self) -> None: ... - def read(self, offset: int, length: int) -> Union[bytes, int]: ... + def read(self, offset: int, length: int) -> bytes | int: ... def write(self, offset: int, data: bytes) -> int: ... - def stat(self) -> Union[int, SFTPAttributes]: ... + def stat(self) -> int | SFTPAttributes: ... def chattr(self, attr: SFTPAttributes) -> int: ... diff --git a/stubs/paramiko/paramiko/sftp_server.pyi b/stubs/paramiko/paramiko/sftp_server.pyi index 7c0cb9de1900..553ec1de368d 100644 --- a/stubs/paramiko/paramiko/sftp_server.pyi +++ b/stubs/paramiko/paramiko/sftp_server.pyi @@ -16,7 +16,7 @@ class SFTPServer(BaseSFTP, SubsystemHandler): file_table: Dict[bytes, SFTPHandle] folder_table: Dict[bytes, SFTPHandle] server: SFTPServerInterface - sock: Optional[Channel] + sock: Channel | None def __init__( self, channel: Channel, name: str, server: ServerInterface, sftp_si: Type[SFTPServerInterface], *largs: Any, **kwargs: Any ) -> None: ... diff --git a/stubs/paramiko/paramiko/sftp_si.pyi b/stubs/paramiko/paramiko/sftp_si.pyi index 849051814b4c..eaaddccbc491 100644 --- a/stubs/paramiko/paramiko/sftp_si.pyi +++ b/stubs/paramiko/paramiko/sftp_si.pyi @@ -8,10 +8,10 @@ class SFTPServerInterface: def __init__(self, server: ServerInterface, *largs: Any, **kwargs: Any) -> None: ... def session_started(self) -> None: ... def session_ended(self) -> None: ... - def open(self, path: str, flags: int, attr: SFTPAttributes) -> Union[SFTPHandle, int]: ... - def list_folder(self, path: str) -> Union[List[SFTPAttributes], int]: ... - def stat(self, path: str) -> Union[SFTPAttributes, int]: ... - def lstat(self, path: str) -> Union[SFTPAttributes, int]: ... + def open(self, path: str, flags: int, attr: SFTPAttributes) -> SFTPHandle | int: ... + def list_folder(self, path: str) -> List[SFTPAttributes] | int: ... + def stat(self, path: str) -> SFTPAttributes | int: ... + def lstat(self, path: str) -> SFTPAttributes | int: ... def remove(self, path: str) -> int: ... def rename(self, oldpath: str, newpath: str) -> int: ... def posix_rename(self, oldpath: str, newpath: str) -> int: ... @@ -19,5 +19,5 @@ class SFTPServerInterface: def rmdir(self, path: str) -> int: ... def chattr(self, path: str, attr: SFTPAttributes) -> int: ... def canonicalize(self, path: str) -> str: ... - def readlink(self, path: str) -> Union[str, int]: ... + def readlink(self, path: str) -> str | int: ... def symlink(self, target_path: str, path: str) -> int: ... diff --git a/stubs/paramiko/paramiko/ssh_exception.pyi b/stubs/paramiko/paramiko/ssh_exception.pyi index d9ba145f25f8..844ba6e5625e 100644 --- a/stubs/paramiko/paramiko/ssh_exception.pyi +++ b/stubs/paramiko/paramiko/ssh_exception.pyi @@ -33,9 +33,9 @@ class ProxyCommandFailure(SSHException): def __init__(self, command: str, error: str) -> None: ... class NoValidConnectionsError(socket.error): - errors: Mapping[Union[Tuple[str, int], Tuple[str, int, int, int]], Exception] - def __init__(self, errors: Mapping[Union[Tuple[str, int], Tuple[str, int, int, int]], Exception]) -> None: ... - def __reduce__(self) -> Tuple[type, Tuple[Mapping[Union[Tuple[str, int], Tuple[str, int, int, int]], Exception]]]: ... + errors: Mapping[Tuple[str, int] | Tuple[str, int, int, int], Exception] + def __init__(self, errors: Mapping[Tuple[str, int] | Tuple[str, int, int, int], Exception]) -> None: ... + def __reduce__(self) -> Tuple[type, Tuple[Mapping[Tuple[str, int] | Tuple[str, int, int, int], Exception]]]: ... class CouldNotCanonicalize(SSHException): ... class ConfigParseError(SSHException): ... diff --git a/stubs/paramiko/paramiko/ssh_gss.pyi b/stubs/paramiko/paramiko/ssh_gss.pyi index 40657d47213f..df52bae88cc2 100644 --- a/stubs/paramiko/paramiko/ssh_gss.pyi +++ b/stubs/paramiko/paramiko/ssh_gss.pyi @@ -16,11 +16,11 @@ class _SSH_GSSAuth: class _SSH_GSSAPI_OLD(_SSH_GSSAuth): def __init__(self, auth_method: str, gss_deleg_creds: bool) -> None: ... def ssh_init_sec_context( - self, target: str, desired_mech: Optional[str] = ..., username: Optional[str] = ..., recv_token: Optional[str] = ... - ) -> Optional[str]: ... + self, target: str, desired_mech: str | None = ..., username: str | None = ..., recv_token: str | None = ... + ) -> str | None: ... def ssh_get_mic(self, session_id: bytes, gss_kex: bool = ...) -> Any: ... - def ssh_accept_sec_context(self, hostname: str, recv_token: str, username: Optional[str] = ...) -> Optional[str]: ... - def ssh_check_mic(self, mic_token: str, session_id: bytes, username: Optional[str] = ...) -> None: ... + def ssh_accept_sec_context(self, hostname: str, recv_token: str, username: str | None = ...) -> str | None: ... + def ssh_check_mic(self, mic_token: str, session_id: bytes, username: str | None = ...) -> None: ... @property def credentials_delegated(self) -> bool: ... def save_client_creds(self, client_token: str) -> None: ... @@ -30,11 +30,11 @@ _SSH_GSSAPI = _SSH_GSSAPI_OLD class _SSH_GSSAPI_NEW(_SSH_GSSAuth): def __init__(self, auth_method: str, gss_deleg_creds: bool) -> None: ... def ssh_init_sec_context( - self, target: str, desired_mech: Optional[str] = ..., username: Optional[str] = ..., recv_token: Optional[str] = ... + self, target: str, desired_mech: str | None = ..., username: str | None = ..., recv_token: str | None = ... ) -> str: ... def ssh_get_mic(self, session_id: bytes, gss_kex: bool = ...) -> Any: ... - def ssh_accept_sec_context(self, hostname: str, recv_token: str, username: Optional[str] = ...) -> Optional[str]: ... - def ssh_check_mic(self, mic_token: str, session_id: bytes, username: Optional[str] = ...) -> None: ... + def ssh_accept_sec_context(self, hostname: str, recv_token: str, username: str | None = ...) -> str | None: ... + def ssh_check_mic(self, mic_token: str, session_id: bytes, username: str | None = ...) -> None: ... @property def credentials_delegated(self) -> bool: ... def save_client_creds(self, client_token: str) -> None: ... @@ -42,11 +42,11 @@ class _SSH_GSSAPI_NEW(_SSH_GSSAuth): class _SSH_SSPI(_SSH_GSSAuth): def __init__(self, auth_method: str, gss_deleg_creds: bool) -> None: ... def ssh_init_sec_context( - self, target: str, desired_mech: Optional[str] = ..., username: Optional[str] = ..., recv_token: Optional[str] = ... + self, target: str, desired_mech: str | None = ..., username: str | None = ..., recv_token: str | None = ... ) -> str: ... def ssh_get_mic(self, session_id: bytes, gss_kex: bool = ...) -> Any: ... - def ssh_accept_sec_context(self, hostname: str, username: str, recv_token: str) -> Optional[str]: ... - def ssh_check_mic(self, mic_token: str, session_id: bytes, username: Optional[str] = ...) -> None: ... + def ssh_accept_sec_context(self, hostname: str, username: str, recv_token: str) -> str | None: ... + def ssh_check_mic(self, mic_token: str, session_id: bytes, username: str | None = ...) -> None: ... @property def credentials_delegated(self) -> bool: ... def save_client_creds(self, client_token: str) -> None: ... diff --git a/stubs/paramiko/paramiko/transport.pyi b/stubs/paramiko/paramiko/transport.pyi index 204a408e96f4..9d9378ca4687 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -22,25 +22,25 @@ class _KexEngine(Protocol): class Transport(Thread, ClosingContextManager): active: bool - hostname: Optional[str] + hostname: str | None sock: socket packetizer: Packetizer local_version: str remote_version: str local_cipher: str - local_kex_init: Optional[bytes] - local_mac: Optional[str] - local_compression: Optional[str] - session_id: Optional[bytes] - host_key_type: Optional[str] - host_key: Optional[PKey] + local_kex_init: bytes | None + local_mac: str | None + local_compression: str | None + session_id: bytes | None + host_key_type: str | None + host_key: PKey | None use_gss_kex: bool gss_kex_used: bool - kexgss_ctxt: Optional[_SSH_GSSAuth] + kexgss_ctxt: _SSH_GSSAuth | None gss_host: str - kex_engine: Optional[_KexEngine] - H: Optional[bytes] - K: Optional[int] + kex_engine: _KexEngine | None + H: bytes | None + K: int | None initial_kex_done: bool in_kex: bool authenticated: bool @@ -49,21 +49,21 @@ class Transport(Thread, ClosingContextManager): channels_seen: Dict[int, bool] default_max_packet_size: int default_window_size: int - saved_exception: Optional[Exception] + saved_exception: Exception | None clear_to_send: Event clear_to_send_lock: Lock clear_to_send_timeout: float log_name: str logger: Logger - auth_handler: Optional[AuthHandler] - global_response: Optional[Message] - completion_event: Optional[Event] + auth_handler: AuthHandler | None + global_response: Message | None + completion_event: Event | None banner_timeout: float handshake_timeout: float auth_timeout: float - disabled_algorithms: Optional[Dict[str, Iterable[str]]] + disabled_algorithms: Dict[str, Iterable[str]] | None server_mode: bool - server_object: Optional[ServerInterface] + server_object: ServerInterface | None server_key_dict: Dict[str, PKey] server_accepts: List[Channel] server_accept_cv: Condition @@ -71,12 +71,12 @@ class Transport(Thread, ClosingContextManager): sys: ModuleType def __init__( self, - sock: Union[str, Tuple[str, int], socket], + sock: str | Tuple[str, int] | socket, default_window_size: int = ..., default_max_packet_size: int = ..., gss_kex: bool = ..., gss_deleg_creds: bool = ..., - disabled_algorithms: Optional[Dict[str, Iterable[str]]] = ..., + disabled_algorithms: Dict[str, Iterable[str]] | None = ..., ) -> None: ... @property def preferred_ciphers(self) -> Sequence[str]: ... @@ -90,18 +90,18 @@ class Transport(Thread, ClosingContextManager): def preferred_compression(self) -> Sequence[str]: ... def atfork(self) -> None: ... def get_security_options(self) -> SecurityOptions: ... - def set_gss_host(self, gss_host: Optional[str], trust_dns: bool = ..., gssapi_requested: bool = ...) -> None: ... - def start_client(self, event: Optional[Event] = ..., timeout: Optional[float] = ...) -> None: ... - def start_server(self, event: Event = ..., server: Optional[ServerInterface] = ...) -> None: ... + def set_gss_host(self, gss_host: str | None, trust_dns: bool = ..., gssapi_requested: bool = ...) -> None: ... + def start_client(self, event: Event | None = ..., timeout: float | None = ...) -> None: ... + def start_server(self, event: Event = ..., server: ServerInterface | None = ...) -> None: ... def add_server_key(self, key: PKey) -> None: ... - def get_server_key(self) -> Optional[PKey]: ... + def get_server_key(self) -> PKey | None: ... @staticmethod - def load_server_moduli(filename: Optional[str] = ...) -> bool: ... + def load_server_moduli(filename: str | None = ...) -> bool: ... def close(self) -> None: ... def get_remote_server_key(self) -> PKey: ... def is_active(self) -> bool: ... def open_session( - self, window_size: Optional[int] = ..., max_packet_size: Optional[int] = ..., timeout: Optional[float] = ... + self, window_size: int | None = ..., max_packet_size: int | None = ..., timeout: float | None = ... ) -> Channel: ... def open_x11_channel(self, src_addr: _Addr = ...) -> Channel: ... def open_forward_agent_channel(self) -> Channel: ... @@ -109,45 +109,45 @@ class Transport(Thread, ClosingContextManager): def open_channel( self, kind: str, - dest_addr: Optional[_Addr] = ..., - src_addr: Optional[_Addr] = ..., - window_size: Optional[int] = ..., - max_packet_size: Optional[int] = ..., - timeout: Optional[float] = ..., + dest_addr: _Addr | None = ..., + src_addr: _Addr | None = ..., + window_size: int | None = ..., + max_packet_size: int | None = ..., + timeout: float | None = ..., ) -> Channel: ... def request_port_forward( - self, address: str, port: int, handler: Optional[Callable[[Channel, _Addr, _Addr], None]] = ... + self, address: str, port: int, handler: Callable[[Channel, _Addr, _Addr], None] | None = ... ) -> int: ... def cancel_port_forward(self, address: str, port: int) -> None: ... - def open_sftp_client(self) -> Optional[SFTPClient]: ... + def open_sftp_client(self) -> SFTPClient | None: ... def send_ignore(self, byte_count: int = ...) -> None: ... def renegotiate_keys(self) -> None: ... def set_keepalive(self, interval: int) -> None: ... - def global_request(self, kind: str, data: Optional[Iterable[Any]] = ..., wait: bool = ...) -> Optional[Message]: ... - def accept(self, timeout: Optional[float] = ...) -> Optional[Channel]: ... + def global_request(self, kind: str, data: Iterable[Any] | None = ..., wait: bool = ...) -> Message | None: ... + def accept(self, timeout: float | None = ...) -> Channel | None: ... def connect( self, - hostkey: Optional[PKey] = ..., + hostkey: PKey | None = ..., username: str = ..., - password: Optional[str] = ..., - pkey: Optional[PKey] = ..., - gss_host: Optional[str] = ..., + password: str | None = ..., + pkey: PKey | None = ..., + gss_host: str | None = ..., gss_auth: bool = ..., gss_kex: bool = ..., gss_deleg_creds: bool = ..., gss_trust_dns: bool = ..., ) -> None: ... - def get_exception(self) -> Optional[Exception]: ... + def get_exception(self) -> Exception | None: ... def set_subsystem_handler(self, name: str, handler: Type[SubsystemHandler], *larg: Any, **kwarg: Any) -> None: ... def is_authenticated(self) -> bool: ... - def get_username(self) -> Optional[str]: ... - def get_banner(self) -> Optional[bytes]: ... + def get_username(self) -> str | None: ... + def get_banner(self) -> bytes | None: ... def auth_none(self, username: str) -> List[str]: ... - def auth_password(self, username: str, password: str, event: Optional[Event] = ..., fallback: bool = ...) -> List[str]: ... - def auth_publickey(self, username: str, key: PKey, event: Optional[Event] = ...) -> List[str]: ... + def auth_password(self, username: str, password: str, event: Event | None = ..., fallback: bool = ...) -> List[str]: ... + def auth_publickey(self, username: str, key: PKey, event: Event | None = ...) -> List[str]: ... def auth_interactive(self, username: str, handler: _InteractiveCallback, submethods: str = ...) -> List[str]: ... def auth_interactive_dumb( - self, username: str, handler: Optional[_InteractiveCallback] = ..., submethods: str = ... + self, username: str, handler: _InteractiveCallback | None = ..., submethods: str = ... ) -> List[str]: ... def auth_gssapi_with_mic(self, username: str, gss_host: str, gss_deleg_creds: bool) -> List[str]: ... def auth_gssapi_keyex(self, username: str) -> List[str]: ... diff --git a/stubs/paramiko/paramiko/util.pyi b/stubs/paramiko/paramiko/util.pyi index 71ee303bdfe9..4f57876b003e 100644 --- a/stubs/paramiko/paramiko/util.pyi +++ b/stubs/paramiko/paramiko/util.pyi @@ -28,7 +28,7 @@ def format_binary_line(data: bytes) -> str: ... def safe_string(s: bytes) -> bytes: ... def bit_length(n: int) -> int: ... def tb_strings() -> List[str]: ... -def generate_key_bytes(hash_alg: Type[_Hash], salt: bytes, key: Union[bytes, str], nbytes: int) -> bytes: ... +def generate_key_bytes(hash_alg: Type[_Hash], salt: bytes, key: bytes | str, nbytes: int) -> bytes: ... def load_host_keys(filename: str) -> HostKeys: ... def parse_ssh_config(file_obj: IO[str]) -> SSHConfig: ... def lookup_ssh_host_config(hostname: str, config: SSHConfig) -> SSHConfigDict: ... @@ -46,7 +46,7 @@ def constant_time_bytes_eq(a: AnyStr, b: AnyStr) -> bool: ... class ClosingContextManager: def __enter__(self: _TC) -> _TC: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def clamp_value(minimum: int, val: int, maximum: int) -> int: ... diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index ea4442877abb..661f72901b47 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -19,7 +19,7 @@ def pofile(pofile: Text, **kwargs: Any) -> POFile: ... def mofile(mofile: Text, *, klass: Type[_TM], **kwargs: Any) -> _TM: ... @overload def mofile(mofile: Text, **kwargs: Any) -> MOFile: ... -def detect_encoding(file: Union[bytes, Text], binary_mode: bool = ...) -> str: ... +def detect_encoding(file: bytes | Text, binary_mode: bool = ...) -> str: ... def escape(st: Text) -> Text: ... def unescape(st: Text) -> Text: ... @@ -38,8 +38,8 @@ class _BaseFile(List[_TB]): def append(self, entry: _TB) -> None: ... def insert(self, index: SupportsIndex, entry: _TB) -> None: ... def metadata_as_entry(self) -> POEntry: ... - def save(self, fpath: Optional[Text] = ..., repr_method: str = ...) -> None: ... - def find(self, st: Text, by: str = ..., include_obsolete_entries: bool = ..., msgctxt: bool = ...) -> Optional[_TB]: ... + def save(self, fpath: Text | None = ..., repr_method: str = ...) -> None: ... + def find(self, st: Text, by: str = ..., include_obsolete_entries: bool = ..., msgctxt: bool = ...) -> _TB | None: ... def ordered_metadata(self) -> list[tuple[Text, Text]]: ... def to_binary(self) -> bytes: ... @@ -56,11 +56,11 @@ class POFile(_BaseFile[POEntry]): class MOFile(_BaseFile[MOEntry]): MAGIC: int MAGIC_SWAPPED: int - magic_number: Optional[int] + magic_number: int | None version: int def __init__(self, *args: Any, **kwargs: Any) -> None: ... def save_as_pofile(self, fpath: str) -> None: ... - def save(self, fpath: Optional[Text] = ...) -> None: ... # type: ignore # binary file does not allow argument repr_method + def save(self, fpath: Text | None = ...) -> None: ... # type: ignore # binary file does not allow argument repr_method def percent_translated(self) -> int: ... def translated_entries(self) -> List[MOEntry]: ... def untranslated_entries(self) -> List[MOEntry]: ... @@ -84,10 +84,10 @@ class POEntry(_BaseEntry): tcomment: Text occurrences: List[Tuple[str, int]] flags: List[Text] - previous_msgctxt: Optional[Text] - previous_msgid: Optional[Text] - previous_msgid_plural: Optional[Text] - linenum: Optional[int] + previous_msgctxt: Text | None + previous_msgid: Text | None + previous_msgid_plural: Text | None + linenum: int | None def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __unicode__(self, wrapwidth: int = ...) -> Text: ... def __cmp__(self, other: POEntry) -> int: ... @@ -110,9 +110,9 @@ class MOEntry(_BaseEntry): tcomment: Text occurrences: List[Tuple[str, int]] flags: List[Text] - previous_msgctxt: Optional[Text] - previous_msgid: Optional[Text] - previous_msgid_plural: Optional[Text] + previous_msgctxt: Text | None + previous_msgid: Text | None + previous_msgid_plural: Text | None def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __hash__(self) -> int: ... @@ -123,7 +123,7 @@ class _POFileParser(Generic[_TP]): current_line: int current_entry: POEntry current_state: str - current_token: Optional[str] + current_token: str | None msgstr_index: int entry_obsolete: int def __init__(self, pofile: Text, *args: Any, **kwargs: Any) -> None: ... diff --git a/stubs/protobuf/google/protobuf/api_pb2.pyi b/stubs/protobuf/google/protobuf/api_pb2.pyi index 10d183c44b2a..8f61763c54ab 100644 --- a/stubs/protobuf/google/protobuf/api_pb2.pyi +++ b/stubs/protobuf/google/protobuf/api_pb2.pyi @@ -72,11 +72,11 @@ class Api(google.protobuf.message.Message): def __init__(self, *, name : typing.Text = ..., - methods : typing.Optional[typing.Iterable[global___Method]] = ..., - options : typing.Optional[typing.Iterable[google.protobuf.type_pb2.Option]] = ..., + methods : typing.typing.Iterable[global___Method] | None = ..., + options : typing.typing.Iterable[google.protobuf.type_pb2.Option] | None = ..., version : typing.Text = ..., - source_context : typing.Optional[google.protobuf.source_context_pb2.SourceContext] = ..., - mixins : typing.Optional[typing.Iterable[global___Mixin]] = ..., + source_context : typing.google.protobuf.source_context_pb2.SourceContext | None = ..., + mixins : typing.typing.Iterable[global___Mixin] | None = ..., syntax : google.protobuf.type_pb2.Syntax.V = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"source_context",b"source_context"]) -> builtins.bool: ... @@ -115,7 +115,7 @@ class Method(google.protobuf.message.Message): request_streaming : builtins.bool = ..., response_type_url : typing.Text = ..., response_streaming : builtins.bool = ..., - options : typing.Optional[typing.Iterable[google.protobuf.type_pb2.Option]] = ..., + options : typing.typing.Iterable[google.protobuf.type_pb2.Option] | None = ..., syntax : google.protobuf.type_pb2.Syntax.V = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options",u"request_streaming",b"request_streaming",u"request_type_url",b"request_type_url",u"response_streaming",b"response_streaming",u"response_type_url",b"response_type_url",u"syntax",b"syntax"]) -> None: ... diff --git a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi index 012d8956ba77..cfb0a90ab5d2 100644 --- a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi +++ b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi @@ -28,10 +28,10 @@ class Version(google.protobuf.message.Message): suffix: typing.Text = ... def __init__(self, *, - major : typing.Optional[builtins.int] = ..., - minor : typing.Optional[builtins.int] = ..., - patch : typing.Optional[builtins.int] = ..., - suffix : typing.Optional[typing.Text] = ..., + major : typing.builtins.int | None = ..., + minor : typing.builtins.int | None = ..., + patch : typing.builtins.int | None = ..., + suffix : typing.typing.Text | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"major",b"major",u"minor",b"minor",u"patch",b"patch",u"suffix",b"suffix"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"major",b"major",u"minor",b"minor",u"patch",b"patch",u"suffix",b"suffix"]) -> None: ... @@ -72,10 +72,10 @@ class CodeGeneratorRequest(google.protobuf.message.Message): def compiler_version(self) -> global___Version: ... def __init__(self, *, - file_to_generate : typing.Optional[typing.Iterable[typing.Text]] = ..., - parameter : typing.Optional[typing.Text] = ..., - proto_file : typing.Optional[typing.Iterable[google.protobuf.descriptor_pb2.FileDescriptorProto]] = ..., - compiler_version : typing.Optional[global___Version] = ..., + file_to_generate : typing.typing.Iterable[typing.Text] | None = ..., + parameter : typing.typing.Text | None = ..., + proto_file : typing.typing.Iterable[google.protobuf.descriptor_pb2.FileDescriptorProto] | None = ..., + compiler_version : typing.global___Version | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"compiler_version",b"compiler_version",u"parameter",b"parameter"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"compiler_version",b"compiler_version",u"file_to_generate",b"file_to_generate",u"parameter",b"parameter",u"proto_file",b"proto_file"]) -> None: ... @@ -163,10 +163,10 @@ class CodeGeneratorResponse(google.protobuf.message.Message): def generated_code_info(self) -> google.protobuf.descriptor_pb2.GeneratedCodeInfo: ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - insertion_point : typing.Optional[typing.Text] = ..., - content : typing.Optional[typing.Text] = ..., - generated_code_info : typing.Optional[google.protobuf.descriptor_pb2.GeneratedCodeInfo] = ..., + name : typing.typing.Text | None = ..., + insertion_point : typing.typing.Text | None = ..., + content : typing.typing.Text | None = ..., + generated_code_info : typing.google.protobuf.descriptor_pb2.GeneratedCodeInfo | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"content",b"content",u"generated_code_info",b"generated_code_info",u"insertion_point",b"insertion_point",u"name",b"name"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"content",b"content",u"generated_code_info",b"generated_code_info",u"insertion_point",b"insertion_point",u"name",b"name"]) -> None: ... @@ -190,9 +190,9 @@ class CodeGeneratorResponse(google.protobuf.message.Message): def file(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___CodeGeneratorResponse.File]: ... def __init__(self, *, - error : typing.Optional[typing.Text] = ..., - supported_features : typing.Optional[builtins.int] = ..., - file : typing.Optional[typing.Iterable[global___CodeGeneratorResponse.File]] = ..., + error : typing.typing.Text | None = ..., + supported_features : typing.builtins.int | None = ..., + file : typing.typing.Iterable[global___CodeGeneratorResponse.File] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"error",b"error",u"supported_features",b"supported_features"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"error",b"error",u"file",b"file",u"supported_features",b"supported_features"]) -> None: ... diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index 2a8a5b11f2b0..300aab9e3640 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -21,7 +21,7 @@ class FileDescriptorSet(google.protobuf.message.Message): def file(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___FileDescriptorProto]: ... def __init__(self, *, - file : typing.Optional[typing.Iterable[global___FileDescriptorProto]] = ..., + file : typing.typing.Iterable[global___FileDescriptorProto] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"file",b"file"]) -> None: ... global___FileDescriptorSet = FileDescriptorSet @@ -77,18 +77,18 @@ class FileDescriptorProto(google.protobuf.message.Message): syntax: typing.Text = ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - package : typing.Optional[typing.Text] = ..., - dependency : typing.Optional[typing.Iterable[typing.Text]] = ..., - public_dependency : typing.Optional[typing.Iterable[builtins.int]] = ..., - weak_dependency : typing.Optional[typing.Iterable[builtins.int]] = ..., - message_type : typing.Optional[typing.Iterable[global___DescriptorProto]] = ..., - enum_type : typing.Optional[typing.Iterable[global___EnumDescriptorProto]] = ..., - service : typing.Optional[typing.Iterable[global___ServiceDescriptorProto]] = ..., - extension : typing.Optional[typing.Iterable[global___FieldDescriptorProto]] = ..., - options : typing.Optional[global___FileOptions] = ..., - source_code_info : typing.Optional[global___SourceCodeInfo] = ..., - syntax : typing.Optional[typing.Text] = ..., + name : typing.typing.Text | None = ..., + package : typing.typing.Text | None = ..., + dependency : typing.typing.Iterable[typing.Text] | None = ..., + public_dependency : typing.typing.Iterable[builtins.int] | None = ..., + weak_dependency : typing.typing.Iterable[builtins.int] | None = ..., + message_type : typing.typing.Iterable[global___DescriptorProto] | None = ..., + enum_type : typing.typing.Iterable[global___EnumDescriptorProto] | None = ..., + service : typing.typing.Iterable[global___ServiceDescriptorProto] | None = ..., + extension : typing.typing.Iterable[global___FieldDescriptorProto] | None = ..., + options : typing.global___FileOptions | None = ..., + source_code_info : typing.global___SourceCodeInfo | None = ..., + syntax : typing.typing.Text | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options",u"package",b"package",u"source_code_info",b"source_code_info",u"syntax",b"syntax"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"dependency",b"dependency",u"enum_type",b"enum_type",u"extension",b"extension",u"message_type",b"message_type",u"name",b"name",u"options",b"options",u"package",b"package",u"public_dependency",b"public_dependency",u"service",b"service",u"source_code_info",b"source_code_info",u"syntax",b"syntax",u"weak_dependency",b"weak_dependency"]) -> None: ... @@ -110,9 +110,9 @@ class DescriptorProto(google.protobuf.message.Message): def options(self) -> global___ExtensionRangeOptions: ... def __init__(self, *, - start : typing.Optional[builtins.int] = ..., - end : typing.Optional[builtins.int] = ..., - options : typing.Optional[global___ExtensionRangeOptions] = ..., + start : typing.builtins.int | None = ..., + end : typing.builtins.int | None = ..., + options : typing.global___ExtensionRangeOptions | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"end",b"end",u"options",b"options",u"start",b"start"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"end",b"end",u"options",b"options",u"start",b"start"]) -> None: ... @@ -130,8 +130,8 @@ class DescriptorProto(google.protobuf.message.Message): end: builtins.int = ... def __init__(self, *, - start : typing.Optional[builtins.int] = ..., - end : typing.Optional[builtins.int] = ..., + start : typing.builtins.int | None = ..., + end : typing.builtins.int | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"end",b"end",u"start",b"start"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"end",b"end",u"start",b"start"]) -> None: ... @@ -169,16 +169,16 @@ class DescriptorProto(google.protobuf.message.Message): def reserved_name(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - field : typing.Optional[typing.Iterable[global___FieldDescriptorProto]] = ..., - extension : typing.Optional[typing.Iterable[global___FieldDescriptorProto]] = ..., - nested_type : typing.Optional[typing.Iterable[global___DescriptorProto]] = ..., - enum_type : typing.Optional[typing.Iterable[global___EnumDescriptorProto]] = ..., - extension_range : typing.Optional[typing.Iterable[global___DescriptorProto.ExtensionRange]] = ..., - oneof_decl : typing.Optional[typing.Iterable[global___OneofDescriptorProto]] = ..., - options : typing.Optional[global___MessageOptions] = ..., - reserved_range : typing.Optional[typing.Iterable[global___DescriptorProto.ReservedRange]] = ..., - reserved_name : typing.Optional[typing.Iterable[typing.Text]] = ..., + name : typing.typing.Text | None = ..., + field : typing.typing.Iterable[global___FieldDescriptorProto] | None = ..., + extension : typing.typing.Iterable[global___FieldDescriptorProto] | None = ..., + nested_type : typing.typing.Iterable[global___DescriptorProto] | None = ..., + enum_type : typing.typing.Iterable[global___EnumDescriptorProto] | None = ..., + extension_range : typing.typing.Iterable[global___DescriptorProto.ExtensionRange] | None = ..., + oneof_decl : typing.typing.Iterable[global___OneofDescriptorProto] | None = ..., + options : typing.global___MessageOptions | None = ..., + reserved_range : typing.typing.Iterable[global___DescriptorProto.ReservedRange] | None = ..., + reserved_name : typing.typing.Iterable[typing.Text] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"enum_type",b"enum_type",u"extension",b"extension",u"extension_range",b"extension_range",u"field",b"field",u"name",b"name",u"nested_type",b"nested_type",u"oneof_decl",b"oneof_decl",u"options",b"options",u"reserved_name",b"reserved_name",u"reserved_range",b"reserved_range"]) -> None: ... @@ -192,7 +192,7 @@ class ExtensionRangeOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... global___ExtensionRangeOptions = ExtensionRangeOptions @@ -354,17 +354,17 @@ class FieldDescriptorProto(google.protobuf.message.Message): proto3_optional: builtins.bool = ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - number : typing.Optional[builtins.int] = ..., - label : typing.Optional[global___FieldDescriptorProto.Label.V] = ..., - type : typing.Optional[global___FieldDescriptorProto.Type.V] = ..., - type_name : typing.Optional[typing.Text] = ..., - extendee : typing.Optional[typing.Text] = ..., - default_value : typing.Optional[typing.Text] = ..., - oneof_index : typing.Optional[builtins.int] = ..., - json_name : typing.Optional[typing.Text] = ..., - options : typing.Optional[global___FieldOptions] = ..., - proto3_optional : typing.Optional[builtins.bool] = ..., + name : typing.typing.Text | None = ..., + number : typing.builtins.int | None = ..., + label : typing.global___FieldDescriptorProto.Label.V | None = ..., + type : typing.global___FieldDescriptorProto.Type.V | None = ..., + type_name : typing.typing.Text | None = ..., + extendee : typing.typing.Text | None = ..., + default_value : typing.typing.Text | None = ..., + oneof_index : typing.builtins.int | None = ..., + json_name : typing.typing.Text | None = ..., + options : typing.global___FieldOptions | None = ..., + proto3_optional : typing.builtins.bool | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"default_value",b"default_value",u"extendee",b"extendee",u"json_name",b"json_name",u"label",b"label",u"name",b"name",u"number",b"number",u"oneof_index",b"oneof_index",u"options",b"options",u"proto3_optional",b"proto3_optional",u"type",b"type",u"type_name",b"type_name"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"default_value",b"default_value",u"extendee",b"extendee",u"json_name",b"json_name",u"label",b"label",u"name",b"name",u"number",b"number",u"oneof_index",b"oneof_index",u"options",b"options",u"proto3_optional",b"proto3_optional",u"type",b"type",u"type_name",b"type_name"]) -> None: ... @@ -380,8 +380,8 @@ class OneofDescriptorProto(google.protobuf.message.Message): def options(self) -> global___OneofOptions: ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - options : typing.Optional[global___OneofOptions] = ..., + name : typing.typing.Text | None = ..., + options : typing.global___OneofOptions | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> None: ... @@ -406,8 +406,8 @@ class EnumDescriptorProto(google.protobuf.message.Message): end: builtins.int = ... def __init__(self, *, - start : typing.Optional[builtins.int] = ..., - end : typing.Optional[builtins.int] = ..., + start : typing.builtins.int | None = ..., + end : typing.builtins.int | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"end",b"end",u"start",b"start"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"end",b"end",u"start",b"start"]) -> None: ... @@ -433,11 +433,11 @@ class EnumDescriptorProto(google.protobuf.message.Message): def reserved_name(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - value : typing.Optional[typing.Iterable[global___EnumValueDescriptorProto]] = ..., - options : typing.Optional[global___EnumOptions] = ..., - reserved_range : typing.Optional[typing.Iterable[global___EnumDescriptorProto.EnumReservedRange]] = ..., - reserved_name : typing.Optional[typing.Iterable[typing.Text]] = ..., + name : typing.typing.Text | None = ..., + value : typing.typing.Iterable[global___EnumValueDescriptorProto] | None = ..., + options : typing.global___EnumOptions | None = ..., + reserved_range : typing.typing.Iterable[global___EnumDescriptorProto.EnumReservedRange] | None = ..., + reserved_name : typing.typing.Iterable[typing.Text] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options",u"reserved_name",b"reserved_name",u"reserved_range",b"reserved_range",u"value",b"value"]) -> None: ... @@ -455,9 +455,9 @@ class EnumValueDescriptorProto(google.protobuf.message.Message): def options(self) -> global___EnumValueOptions: ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - number : typing.Optional[builtins.int] = ..., - options : typing.Optional[global___EnumValueOptions] = ..., + name : typing.typing.Text | None = ..., + number : typing.builtins.int | None = ..., + options : typing.global___EnumValueOptions | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"number",b"number",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"number",b"number",u"options",b"options"]) -> None: ... @@ -476,9 +476,9 @@ class ServiceDescriptorProto(google.protobuf.message.Message): def options(self) -> global___ServiceOptions: ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - method : typing.Optional[typing.Iterable[global___MethodDescriptorProto]] = ..., - options : typing.Optional[global___ServiceOptions] = ..., + name : typing.typing.Text | None = ..., + method : typing.typing.Iterable[global___MethodDescriptorProto] | None = ..., + options : typing.global___ServiceOptions | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"method",b"method",u"name",b"name",u"options",b"options"]) -> None: ... @@ -506,12 +506,12 @@ class MethodDescriptorProto(google.protobuf.message.Message): server_streaming: builtins.bool = ... def __init__(self, *, - name : typing.Optional[typing.Text] = ..., - input_type : typing.Optional[typing.Text] = ..., - output_type : typing.Optional[typing.Text] = ..., - options : typing.Optional[global___MethodOptions] = ..., - client_streaming : typing.Optional[builtins.bool] = ..., - server_streaming : typing.Optional[builtins.bool] = ..., + name : typing.typing.Text | None = ..., + input_type : typing.typing.Text | None = ..., + output_type : typing.typing.Text | None = ..., + options : typing.global___MethodOptions | None = ..., + client_streaming : typing.builtins.bool | None = ..., + server_streaming : typing.builtins.bool | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"client_streaming",b"client_streaming",u"input_type",b"input_type",u"name",b"name",u"options",b"options",u"output_type",b"output_type",u"server_streaming",b"server_streaming"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"client_streaming",b"client_streaming",u"input_type",b"input_type",u"name",b"name",u"options",b"options",u"output_type",b"output_type",u"server_streaming",b"server_streaming"]) -> None: ... @@ -682,27 +682,27 @@ class FileOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - java_package : typing.Optional[typing.Text] = ..., - java_outer_classname : typing.Optional[typing.Text] = ..., - java_multiple_files : typing.Optional[builtins.bool] = ..., - java_generate_equals_and_hash : typing.Optional[builtins.bool] = ..., - java_string_check_utf8 : typing.Optional[builtins.bool] = ..., - optimize_for : typing.Optional[global___FileOptions.OptimizeMode.V] = ..., - go_package : typing.Optional[typing.Text] = ..., - cc_generic_services : typing.Optional[builtins.bool] = ..., - java_generic_services : typing.Optional[builtins.bool] = ..., - py_generic_services : typing.Optional[builtins.bool] = ..., - php_generic_services : typing.Optional[builtins.bool] = ..., - deprecated : typing.Optional[builtins.bool] = ..., - cc_enable_arenas : typing.Optional[builtins.bool] = ..., - objc_class_prefix : typing.Optional[typing.Text] = ..., - csharp_namespace : typing.Optional[typing.Text] = ..., - swift_prefix : typing.Optional[typing.Text] = ..., - php_class_prefix : typing.Optional[typing.Text] = ..., - php_namespace : typing.Optional[typing.Text] = ..., - php_metadata_namespace : typing.Optional[typing.Text] = ..., - ruby_package : typing.Optional[typing.Text] = ..., - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + java_package : typing.typing.Text | None = ..., + java_outer_classname : typing.typing.Text | None = ..., + java_multiple_files : typing.builtins.bool | None = ..., + java_generate_equals_and_hash : typing.builtins.bool | None = ..., + java_string_check_utf8 : typing.builtins.bool | None = ..., + optimize_for : typing.global___FileOptions.OptimizeMode.V | None = ..., + go_package : typing.typing.Text | None = ..., + cc_generic_services : typing.builtins.bool | None = ..., + java_generic_services : typing.builtins.bool | None = ..., + py_generic_services : typing.builtins.bool | None = ..., + php_generic_services : typing.builtins.bool | None = ..., + deprecated : typing.builtins.bool | None = ..., + cc_enable_arenas : typing.builtins.bool | None = ..., + objc_class_prefix : typing.typing.Text | None = ..., + csharp_namespace : typing.typing.Text | None = ..., + swift_prefix : typing.typing.Text | None = ..., + php_class_prefix : typing.typing.Text | None = ..., + php_namespace : typing.typing.Text | None = ..., + php_metadata_namespace : typing.typing.Text | None = ..., + ruby_package : typing.typing.Text | None = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"cc_enable_arenas",b"cc_enable_arenas",u"cc_generic_services",b"cc_generic_services",u"csharp_namespace",b"csharp_namespace",u"deprecated",b"deprecated",u"go_package",b"go_package",u"java_generate_equals_and_hash",b"java_generate_equals_and_hash",u"java_generic_services",b"java_generic_services",u"java_multiple_files",b"java_multiple_files",u"java_outer_classname",b"java_outer_classname",u"java_package",b"java_package",u"java_string_check_utf8",b"java_string_check_utf8",u"objc_class_prefix",b"objc_class_prefix",u"optimize_for",b"optimize_for",u"php_class_prefix",b"php_class_prefix",u"php_generic_services",b"php_generic_services",u"php_metadata_namespace",b"php_metadata_namespace",u"php_namespace",b"php_namespace",u"py_generic_services",b"py_generic_services",u"ruby_package",b"ruby_package",u"swift_prefix",b"swift_prefix"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"cc_enable_arenas",b"cc_enable_arenas",u"cc_generic_services",b"cc_generic_services",u"csharp_namespace",b"csharp_namespace",u"deprecated",b"deprecated",u"go_package",b"go_package",u"java_generate_equals_and_hash",b"java_generate_equals_and_hash",u"java_generic_services",b"java_generic_services",u"java_multiple_files",b"java_multiple_files",u"java_outer_classname",b"java_outer_classname",u"java_package",b"java_package",u"java_string_check_utf8",b"java_string_check_utf8",u"objc_class_prefix",b"objc_class_prefix",u"optimize_for",b"optimize_for",u"php_class_prefix",b"php_class_prefix",u"php_generic_services",b"php_generic_services",u"php_metadata_namespace",b"php_metadata_namespace",u"php_namespace",b"php_namespace",u"py_generic_services",b"py_generic_services",u"ruby_package",b"ruby_package",u"swift_prefix",b"swift_prefix",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -770,11 +770,11 @@ class MessageOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - message_set_wire_format : typing.Optional[builtins.bool] = ..., - no_standard_descriptor_accessor : typing.Optional[builtins.bool] = ..., - deprecated : typing.Optional[builtins.bool] = ..., - map_entry : typing.Optional[builtins.bool] = ..., - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + message_set_wire_format : typing.builtins.bool | None = ..., + no_standard_descriptor_accessor : typing.builtins.bool | None = ..., + deprecated : typing.builtins.bool | None = ..., + map_entry : typing.builtins.bool | None = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"map_entry",b"map_entry",u"message_set_wire_format",b"message_set_wire_format",u"no_standard_descriptor_accessor",b"no_standard_descriptor_accessor"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"map_entry",b"map_entry",u"message_set_wire_format",b"message_set_wire_format",u"no_standard_descriptor_accessor",b"no_standard_descriptor_accessor",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -889,13 +889,13 @@ class FieldOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - ctype : typing.Optional[global___FieldOptions.CType.V] = ..., - packed : typing.Optional[builtins.bool] = ..., - jstype : typing.Optional[global___FieldOptions.JSType.V] = ..., - lazy : typing.Optional[builtins.bool] = ..., - deprecated : typing.Optional[builtins.bool] = ..., - weak : typing.Optional[builtins.bool] = ..., - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + ctype : typing.global___FieldOptions.CType.V | None = ..., + packed : typing.builtins.bool | None = ..., + jstype : typing.global___FieldOptions.JSType.V | None = ..., + lazy : typing.builtins.bool | None = ..., + deprecated : typing.builtins.bool | None = ..., + weak : typing.builtins.bool | None = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"ctype",b"ctype",u"deprecated",b"deprecated",u"jstype",b"jstype",u"lazy",b"lazy",u"packed",b"packed",u"weak",b"weak"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"ctype",b"ctype",u"deprecated",b"deprecated",u"jstype",b"jstype",u"lazy",b"lazy",u"packed",b"packed",u"uninterpreted_option",b"uninterpreted_option",u"weak",b"weak"]) -> None: ... @@ -909,7 +909,7 @@ class OneofOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... global___OneofOptions = OneofOptions @@ -932,9 +932,9 @@ class EnumOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - allow_alias : typing.Optional[builtins.bool] = ..., - deprecated : typing.Optional[builtins.bool] = ..., - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + allow_alias : typing.builtins.bool | None = ..., + deprecated : typing.builtins.bool | None = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"allow_alias",b"allow_alias",u"deprecated",b"deprecated"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"allow_alias",b"allow_alias",u"deprecated",b"deprecated",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -954,8 +954,8 @@ class EnumValueOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - deprecated : typing.Optional[builtins.bool] = ..., - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + deprecated : typing.builtins.bool | None = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -980,8 +980,8 @@ class ServiceOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - deprecated : typing.Optional[builtins.bool] = ..., - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + deprecated : typing.builtins.bool | None = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -1029,9 +1029,9 @@ class MethodOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - deprecated : typing.Optional[builtins.bool] = ..., - idempotency_level : typing.Optional[global___MethodOptions.IdempotencyLevel.V] = ..., - uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., + deprecated : typing.builtins.bool | None = ..., + idempotency_level : typing.global___MethodOptions.IdempotencyLevel.V | None = ..., + uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"idempotency_level",b"idempotency_level"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"idempotency_level",b"idempotency_level",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -1058,8 +1058,8 @@ class UninterpretedOption(google.protobuf.message.Message): is_extension: builtins.bool = ... def __init__(self, *, - name_part : typing.Optional[typing.Text] = ..., - is_extension : typing.Optional[builtins.bool] = ..., + name_part : typing.typing.Text | None = ..., + is_extension : typing.builtins.bool | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"is_extension",b"is_extension",u"name_part",b"name_part"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"is_extension",b"is_extension",u"name_part",b"name_part"]) -> None: ... @@ -1083,13 +1083,13 @@ class UninterpretedOption(google.protobuf.message.Message): aggregate_value: typing.Text = ... def __init__(self, *, - name : typing.Optional[typing.Iterable[global___UninterpretedOption.NamePart]] = ..., - identifier_value : typing.Optional[typing.Text] = ..., - positive_int_value : typing.Optional[builtins.int] = ..., - negative_int_value : typing.Optional[builtins.int] = ..., - double_value : typing.Optional[builtins.float] = ..., - string_value : typing.Optional[builtins.bytes] = ..., - aggregate_value : typing.Optional[typing.Text] = ..., + name : typing.typing.Iterable[global___UninterpretedOption.NamePart] | None = ..., + identifier_value : typing.typing.Text | None = ..., + positive_int_value : typing.builtins.int | None = ..., + negative_int_value : typing.builtins.int | None = ..., + double_value : typing.builtins.float | None = ..., + string_value : typing.builtins.bytes | None = ..., + aggregate_value : typing.typing.Text | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"aggregate_value",b"aggregate_value",u"double_value",b"double_value",u"identifier_value",b"identifier_value",u"negative_int_value",b"negative_int_value",u"positive_int_value",b"positive_int_value",u"string_value",b"string_value"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"aggregate_value",b"aggregate_value",u"double_value",b"double_value",u"identifier_value",b"identifier_value",u"name",b"name",u"negative_int_value",b"negative_int_value",u"positive_int_value",b"positive_int_value",u"string_value",b"string_value"]) -> None: ... @@ -1194,11 +1194,11 @@ class SourceCodeInfo(google.protobuf.message.Message): def leading_detached_comments(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ... def __init__(self, *, - path : typing.Optional[typing.Iterable[builtins.int]] = ..., - span : typing.Optional[typing.Iterable[builtins.int]] = ..., - leading_comments : typing.Optional[typing.Text] = ..., - trailing_comments : typing.Optional[typing.Text] = ..., - leading_detached_comments : typing.Optional[typing.Iterable[typing.Text]] = ..., + path : typing.typing.Iterable[builtins.int] | None = ..., + span : typing.typing.Iterable[builtins.int] | None = ..., + leading_comments : typing.typing.Text | None = ..., + trailing_comments : typing.typing.Text | None = ..., + leading_detached_comments : typing.typing.Iterable[typing.Text] | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"leading_comments",b"leading_comments",u"trailing_comments",b"trailing_comments"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"leading_comments",b"leading_comments",u"leading_detached_comments",b"leading_detached_comments",u"path",b"path",u"span",b"span",u"trailing_comments",b"trailing_comments"]) -> None: ... @@ -1251,7 +1251,7 @@ class SourceCodeInfo(google.protobuf.message.Message): def location(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___SourceCodeInfo.Location]: ... def __init__(self, *, - location : typing.Optional[typing.Iterable[global___SourceCodeInfo.Location]] = ..., + location : typing.typing.Iterable[global___SourceCodeInfo.Location] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"location",b"location"]) -> None: ... global___SourceCodeInfo = SourceCodeInfo @@ -1282,10 +1282,10 @@ class GeneratedCodeInfo(google.protobuf.message.Message): end: builtins.int = ... def __init__(self, *, - path : typing.Optional[typing.Iterable[builtins.int]] = ..., - source_file : typing.Optional[typing.Text] = ..., - begin : typing.Optional[builtins.int] = ..., - end : typing.Optional[builtins.int] = ..., + path : typing.typing.Iterable[builtins.int] | None = ..., + source_file : typing.typing.Text | None = ..., + begin : typing.builtins.int | None = ..., + end : typing.builtins.int | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"begin",b"begin",u"end",b"end",u"source_file",b"source_file"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"begin",b"begin",u"end",b"end",u"path",b"path",u"source_file",b"source_file"]) -> None: ... @@ -1297,7 +1297,7 @@ class GeneratedCodeInfo(google.protobuf.message.Message): def annotation(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___GeneratedCodeInfo.Annotation]: ... def __init__(self, *, - annotation : typing.Optional[typing.Iterable[global___GeneratedCodeInfo.Annotation]] = ..., + annotation : typing.typing.Iterable[global___GeneratedCodeInfo.Annotation] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"annotation",b"annotation"]) -> None: ... global___GeneratedCodeInfo = GeneratedCodeInfo diff --git a/stubs/protobuf/google/protobuf/descriptor_pool.pyi b/stubs/protobuf/google/protobuf/descriptor_pool.pyi index aabe9d9dca0a..124be8f24e96 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pool.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pool.pyi @@ -1,8 +1,8 @@ from typing import Any, Optional class DescriptorPool: - def __new__(cls, descriptor_db: Optional[Any] = ...): ... - def __init__(self, descriptor_db: Optional[Any] = ...) -> None: ... + def __new__(cls, descriptor_db: Any | None = ...): ... + def __init__(self, descriptor_db: Any | None = ...) -> None: ... def Add(self, file_desc_proto): ... def AddSerializedFile(self, serialized_file_desc_proto): ... def AddDescriptor(self, desc): ... diff --git a/stubs/protobuf/google/protobuf/field_mask_pb2.pyi b/stubs/protobuf/google/protobuf/field_mask_pb2.pyi index efa622a680f8..78c801a101fc 100644 --- a/stubs/protobuf/google/protobuf/field_mask_pb2.pyi +++ b/stubs/protobuf/google/protobuf/field_mask_pb2.pyi @@ -219,7 +219,7 @@ class FieldMask(google.protobuf.message.Message, google.protobuf.internal.well_k def paths(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ... def __init__(self, *, - paths : typing.Optional[typing.Iterable[typing.Text]] = ..., + paths : typing.typing.Iterable[typing.Text] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"paths",b"paths"]) -> None: ... global___FieldMask = FieldMask diff --git a/stubs/protobuf/google/protobuf/internal/containers.pyi b/stubs/protobuf/google/protobuf/internal/containers.pyi index 5e54051b6afa..dabb6dd69a6c 100644 --- a/stubs/protobuf/google/protobuf/internal/containers.pyi +++ b/stubs/protobuf/google/protobuf/internal/containers.pyi @@ -31,7 +31,7 @@ class BaseContainer(Sequence[_T]): def __ne__(self, other: object) -> bool: ... def __hash__(self) -> int: ... def __repr__(self) -> str: ... - def sort(self, *, key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...) -> None: ... + def sort(self, *, key: Callable[[_T], Any] | None = ..., reverse: bool = ...) -> None: ... @overload def __getitem__(self, key: int) -> _T: ... @overload @@ -41,7 +41,7 @@ class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]): def __init__(self, message_listener: MessageListener, message_descriptor: Descriptor) -> None: ... def append(self, value: _ScalarV) -> None: ... def insert(self, key: int, value: _ScalarV) -> None: ... - def extend(self, elem_seq: Optional[Iterable[_ScalarV]]) -> None: ... + def extend(self, elem_seq: Iterable[_ScalarV] | None) -> None: ... def MergeFrom(self: _M, other: _M) -> None: ... def remove(self, elem: _ScalarV) -> None: ... def pop(self, key: int = ...) -> _ScalarV: ... @@ -51,7 +51,7 @@ class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]): def __setitem__(self, key: slice, value: Iterable[_ScalarV]) -> None: ... def __getslice__(self, start: int, stop: int) -> List[_ScalarV]: ... def __setslice__(self, start: int, stop: int, values: Iterable[_ScalarV]) -> None: ... - def __delitem__(self, key: Union[int, slice]) -> None: ... + def __delitem__(self, key: int | slice) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __eq__(self, other: object) -> bool: ... @@ -65,7 +65,7 @@ class RepeatedCompositeFieldContainer(BaseContainer[_MessageV]): def remove(self, elem: _MessageV) -> None: ... def pop(self, key: int = ...) -> _MessageV: ... def __getslice__(self, start: int, stop: int) -> List[_MessageV]: ... - def __delitem__(self, key: Union[int, slice]) -> None: ... + def __delitem__(self, key: int | slice) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __eq__(self, other: object) -> bool: ... diff --git a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi index 486e367eaa15..0495df6347dc 100644 --- a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi +++ b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi @@ -7,7 +7,7 @@ from google.protobuf.message import Message _ContainerMessageT = TypeVar("_ContainerMessageT", bound=Message) _ExtenderMessageT = TypeVar( "_ExtenderMessageT", - bound=Union[Message, RepeatedScalarFieldContainer[Any], RepeatedCompositeFieldContainer[Any], bool, int, float, Text, bytes], + bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | int | float | Text | bytes, ) class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ... diff --git a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi index 6b6b95a197cf..fad401e227ea 100644 --- a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +++ b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi @@ -7,7 +7,7 @@ class ParseError(Error): ... class Any: type_url: tAny = ... value: tAny = ... - def Pack(self, msg: tAny, type_url_prefix: bytes = ..., deterministic: Optional[tAny] = ...) -> None: ... + def Pack(self, msg: tAny, type_url_prefix: bytes = ..., deterministic: tAny | None = ...) -> None: ... def Unpack(self, msg: tAny): ... def TypeName(self): ... def Is(self, descriptor: tAny): ... @@ -58,7 +58,7 @@ class FieldMask: ) -> None: ... class _FieldMaskTree: - def __init__(self, field_mask: Optional[tAny] = ...) -> None: ... + def __init__(self, field_mask: tAny | None = ...) -> None: ... def MergeFromFieldMask(self, field_mask: tAny) -> None: ... def AddPath(self, path: tAny): ... def ToFieldMask(self, field_mask: tAny) -> None: ... diff --git a/stubs/protobuf/google/protobuf/json_format.pyi b/stubs/protobuf/google/protobuf/json_format.pyi index 75fda13431a6..7ab8a721414b 100644 --- a/stubs/protobuf/google/protobuf/json_format.pyi +++ b/stubs/protobuf/google/protobuf/json_format.pyi @@ -16,23 +16,23 @@ def MessageToJson( indent: int = ..., sort_keys: bool = ..., use_integers_for_enums: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., - float_precision: Optional[int] = ..., + descriptor_pool: DescriptorPool | None = ..., + float_precision: int | None = ..., ) -> str: ... def MessageToDict( message: Message, including_default_value_fields: bool = ..., preserving_proto_field_name: bool = ..., use_integers_for_enums: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., - float_precision: Optional[int] = ..., + descriptor_pool: DescriptorPool | None = ..., + float_precision: int | None = ..., ) -> Dict[Text, Any]: ... def Parse( - text: Union[bytes, Text], + text: bytes | Text, message: _MessageT, ignore_unknown_fields: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., + descriptor_pool: DescriptorPool | None = ..., ) -> _MessageT: ... def ParseDict( - js_dict: Any, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: Optional[DescriptorPool] = ... + js_dict: Any, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: DescriptorPool | None = ... ) -> _MessageT: ... diff --git a/stubs/protobuf/google/protobuf/message_factory.pyi b/stubs/protobuf/google/protobuf/message_factory.pyi index d8a42d30bc65..d619740ced07 100644 --- a/stubs/protobuf/google/protobuf/message_factory.pyi +++ b/stubs/protobuf/google/protobuf/message_factory.pyi @@ -7,7 +7,7 @@ from google.protobuf.message import Message class MessageFactory: pool: Any - def __init__(self, pool: Optional[DescriptorPool] = ...) -> None: ... + def __init__(self, pool: DescriptorPool | None = ...) -> None: ... def GetPrototype(self, descriptor: Descriptor) -> Type[Message]: ... def GetMessages(self, files: Iterable[str]) -> Dict[str, Type[Message]]: ... diff --git a/stubs/protobuf/google/protobuf/service.pyi b/stubs/protobuf/google/protobuf/service.pyi index 4874d5356ded..afe0cc9a1bc5 100644 --- a/stubs/protobuf/google/protobuf/service.pyi +++ b/stubs/protobuf/google/protobuf/service.pyi @@ -14,15 +14,15 @@ class Service: method_descriptor: MethodDescriptor, rpc_controller: RpcController, request: Message, - done: Optional[Callable[[Message], None]], - ) -> Optional[Future[Message]]: ... + done: Callable[[Message], None] | None, + ) -> Future[Message] | None: ... def GetRequestClass(self, method_descriptor: MethodDescriptor) -> Type[Message]: ... def GetResponseClass(self, method_descriptor: MethodDescriptor) -> Type[Message]: ... class RpcController: def Reset(self) -> None: ... def Failed(self) -> bool: ... - def ErrorText(self) -> Optional[Text]: ... + def ErrorText(self) -> Text | None: ... def StartCancel(self) -> None: ... def SetFailed(self, reason: Text) -> None: ... def IsCanceled(self) -> bool: ... @@ -35,5 +35,5 @@ class RpcChannel: rpc_controller: RpcController, request: Message, response_class: Type[Message], - done: Optional[Callable[[Message], None]], - ) -> Optional[Future[Message]]: ... + done: Callable[[Message], None] | None, + ) -> Future[Message] | None: ... diff --git a/stubs/protobuf/google/protobuf/struct_pb2.pyi b/stubs/protobuf/google/protobuf/struct_pb2.pyi index d6f93a3d179b..9956cf6f4fe9 100644 --- a/stubs/protobuf/google/protobuf/struct_pb2.pyi +++ b/stubs/protobuf/google/protobuf/struct_pb2.pyi @@ -51,7 +51,7 @@ class Struct(google.protobuf.message.Message, google.protobuf.internal.well_know def __init__(self, *, key : typing.Text = ..., - value : typing.Optional[global___Value] = ..., + value : typing.global___Value | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"value",b"value"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"key",b"key",u"value",b"value"]) -> None: ... @@ -62,7 +62,7 @@ class Struct(google.protobuf.message.Message, google.protobuf.internal.well_know def fields(self) -> google.protobuf.internal.containers.MessageMap[typing.Text, global___Value]: ... def __init__(self, *, - fields : typing.Optional[typing.Mapping[typing.Text, global___Value]] = ..., + fields : typing.typing.Mapping[typing.Text, global___Value] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"fields",b"fields"]) -> None: ... global___Struct = Struct @@ -101,12 +101,12 @@ class Value(google.protobuf.message.Message): number_value : builtins.float = ..., string_value : typing.Text = ..., bool_value : builtins.bool = ..., - struct_value : typing.Optional[global___Struct] = ..., - list_value : typing.Optional[global___ListValue] = ..., + struct_value : typing.global___Struct | None = ..., + list_value : typing.global___ListValue | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"bool_value",b"bool_value",u"kind",b"kind",u"list_value",b"list_value",u"null_value",b"null_value",u"number_value",b"number_value",u"string_value",b"string_value",u"struct_value",b"struct_value"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"bool_value",b"bool_value",u"kind",b"kind",u"list_value",b"list_value",u"null_value",b"null_value",u"number_value",b"number_value",u"string_value",b"string_value",u"struct_value",b"struct_value"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions.Literal[u"kind",b"kind"]) -> typing.Optional[typing_extensions.Literal["null_value","number_value","string_value","bool_value","struct_value","list_value"]]: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal[u"kind",b"kind"]) -> typing.typing_extensions.Literal["null_value","number_value","string_value","bool_value","struct_value","list_value"] | None: ... global___Value = Value # `ListValue` is a wrapper around a repeated field of values. @@ -120,7 +120,7 @@ class ListValue(google.protobuf.message.Message, google.protobuf.internal.well_k def values(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Value]: ... def __init__(self, *, - values : typing.Optional[typing.Iterable[global___Value]] = ..., + values : typing.typing.Iterable[global___Value] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"values",b"values"]) -> None: ... global___ListValue = ListValue diff --git a/stubs/protobuf/google/protobuf/symbol_database.pyi b/stubs/protobuf/google/protobuf/symbol_database.pyi index 09e32e9de2f7..e1a4a4b3b76b 100644 --- a/stubs/protobuf/google/protobuf/symbol_database.pyi +++ b/stubs/protobuf/google/protobuf/symbol_database.pyi @@ -5,7 +5,7 @@ from google.protobuf.message import Message from google.protobuf.message_factory import MessageFactory class SymbolDatabase(MessageFactory): - def RegisterMessage(self, message: Union[Type[Message], Message]) -> Union[Type[Message], Message]: ... + def RegisterMessage(self, message: Type[Message] | Message) -> Type[Message] | Message: ... def RegisterMessageDescriptor(self, message_descriptor: Descriptor) -> None: ... def RegisterEnumDescriptor(self, enum_descriptor: EnumDescriptor) -> EnumDescriptor: ... def RegisterServiceDescriptor(self, service_descriptor: ServiceDescriptor) -> None: ... diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index 7fe57b6429f3..8e36b7a9a562 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -14,9 +14,9 @@ _M = TypeVar("_M", bound=Message) # message type (of self) class Error(Exception): ... class ParseError(Error): - def __init__(self, message: Optional[str] = ..., line: Optional[int] = ..., column: Optional[int] = ...) -> None: ... - def GetLine(self) -> Optional[int]: ... - def GetColumn(self) -> Optional[int]: ... + def __init__(self, message: str | None = ..., line: int | None = ..., column: int | None = ...) -> None: ... + def GetLine(self) -> int | None: ... + def GetColumn(self) -> int | None: ... class TextWriter: def __init__(self, as_utf8: bool) -> None: ... @@ -33,12 +33,12 @@ def MessageToString( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: Optional[str] = ..., - double_format: Optional[str] = ..., + float_format: str | None = ..., + double_format: str | None = ..., use_field_number: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., + descriptor_pool: DescriptorPool | None = ..., indent: int = ..., - message_formatter: Optional[_MessageFormatter] = ..., + message_formatter: _MessageFormatter | None = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> str: ... @@ -49,10 +49,10 @@ def MessageToBytes( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: Optional[str] = ..., - double_format: Optional[str] = ..., + float_format: str | None = ..., + double_format: str | None = ..., use_field_number: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., + descriptor_pool: DescriptorPool | None = ..., indent: int = ..., message_formatter: _MessageFormatter = ..., print_unknown_fields: bool = ..., @@ -67,11 +67,11 @@ def PrintMessage( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: Optional[str] = ..., - double_format: Optional[str] = ..., + float_format: str | None = ..., + double_format: str | None = ..., use_field_number: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., - message_formatter: Optional[_MessageFormatter] = ..., + descriptor_pool: DescriptorPool | None = ..., + message_formatter: _MessageFormatter | None = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> None: ... @@ -85,9 +85,9 @@ def PrintField( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: Optional[str] = ..., - double_format: Optional[str] = ..., - message_formatter: Optional[_MessageFormatter] = ..., + float_format: str | None = ..., + double_format: str | None = ..., + message_formatter: _MessageFormatter | None = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> None: ... @@ -101,9 +101,9 @@ def PrintFieldValue( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: Optional[str] = ..., - double_format: Optional[str] = ..., - message_formatter: Optional[_MessageFormatter] = ..., + float_format: str | None = ..., + double_format: str | None = ..., + message_formatter: _MessageFormatter | None = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> None: ... @@ -116,11 +116,11 @@ class _Printer: use_short_repeated_primitives: bool = ... pointy_brackets: bool = ... use_index_order: bool = ... - float_format: Optional[str] = ... - double_format: Optional[str] = ... + float_format: str | None = ... + double_format: str | None = ... use_field_number: bool = ... - descriptor_pool: Optional[DescriptorPool] = ... - message_formatter: Optional[_MessageFormatter] = ... + descriptor_pool: DescriptorPool | None = ... + message_formatter: _MessageFormatter | None = ... print_unknown_fields: bool = ... force_colon: bool = ... def __init__( @@ -132,11 +132,11 @@ class _Printer: use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: Optional[str] = ..., - double_format: Optional[str] = ..., + float_format: str | None = ..., + double_format: str | None = ..., use_field_number: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., - message_formatter: Optional[_MessageFormatter] = ..., + descriptor_pool: DescriptorPool | None = ..., + message_formatter: _MessageFormatter | None = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> None: ... @@ -145,44 +145,44 @@ class _Printer: def PrintFieldValue(self, field: FieldDescriptor, value: Any) -> None: ... def Parse( - text: Union[Text, bytes], + text: Text | bytes, message: _M, allow_unknown_extension: bool = ..., allow_field_number: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., + descriptor_pool: DescriptorPool | None = ..., allow_unknown_field: bool = ..., ) -> _M: ... def Merge( - text: Union[Text, bytes], + text: Text | bytes, message: _M, allow_unknown_extension: bool = ..., allow_field_number: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., + descriptor_pool: DescriptorPool | None = ..., allow_unknown_field: bool = ..., ) -> _M: ... def MergeLines( - lines: Iterable[Union[Text, bytes]], + lines: Iterable[Text | bytes], message: _M, allow_unknown_extension: bool = ..., allow_field_number: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., + descriptor_pool: DescriptorPool | None = ..., allow_unknown_field: bool = ..., ) -> _M: ... class _Parser: allow_unknown_extension: bool = ... allow_field_number: bool = ... - descriptor_pool: Optional[DescriptorPool] = ... + descriptor_pool: DescriptorPool | None = ... allow_unknown_field: bool = ... def __init__( self, allow_unknown_extension: bool = ..., allow_field_number: bool = ..., - descriptor_pool: Optional[DescriptorPool] = ..., + descriptor_pool: DescriptorPool | None = ..., allow_unknown_field: bool = ..., ) -> None: ... - def ParseLines(self, lines: Iterable[Union[Text, bytes]], message: _M) -> _M: ... - def MergeLines(self, lines: Iterable[Union[Text, bytes]], message: _M) -> _M: ... + def ParseLines(self, lines: Iterable[Text | bytes], message: _M) -> _M: ... + def MergeLines(self, lines: Iterable[Text | bytes], message: _M) -> _M: ... _ParseError = ParseError diff --git a/stubs/protobuf/google/protobuf/type_pb2.pyi b/stubs/protobuf/google/protobuf/type_pb2.pyi index 399cb4b0ab1a..d7db74b0a1ef 100644 --- a/stubs/protobuf/google/protobuf/type_pb2.pyi +++ b/stubs/protobuf/google/protobuf/type_pb2.pyi @@ -61,10 +61,10 @@ class Type(google.protobuf.message.Message): def __init__(self, *, name : typing.Text = ..., - fields : typing.Optional[typing.Iterable[global___Field]] = ..., - oneofs : typing.Optional[typing.Iterable[typing.Text]] = ..., - options : typing.Optional[typing.Iterable[global___Option]] = ..., - source_context : typing.Optional[google.protobuf.source_context_pb2.SourceContext] = ..., + fields : typing.typing.Iterable[global___Field] | None = ..., + oneofs : typing.typing.Iterable[typing.Text] | None = ..., + options : typing.typing.Iterable[global___Option] | None = ..., + source_context : typing.google.protobuf.source_context_pb2.SourceContext | None = ..., syntax : global___Syntax.V = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"source_context",b"source_context"]) -> builtins.bool: ... @@ -226,7 +226,7 @@ class Field(google.protobuf.message.Message): type_url : typing.Text = ..., oneof_index : builtins.int = ..., packed : builtins.bool = ..., - options : typing.Optional[typing.Iterable[global___Option]] = ..., + options : typing.typing.Iterable[global___Option] | None = ..., json_name : typing.Text = ..., default_value : typing.Text = ..., ) -> None: ... @@ -257,9 +257,9 @@ class Enum(google.protobuf.message.Message): def __init__(self, *, name : typing.Text = ..., - enumvalue : typing.Optional[typing.Iterable[global___EnumValue]] = ..., - options : typing.Optional[typing.Iterable[global___Option]] = ..., - source_context : typing.Optional[google.protobuf.source_context_pb2.SourceContext] = ..., + enumvalue : typing.typing.Iterable[global___EnumValue] | None = ..., + options : typing.typing.Iterable[global___Option] | None = ..., + source_context : typing.google.protobuf.source_context_pb2.SourceContext | None = ..., syntax : global___Syntax.V = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"source_context",b"source_context"]) -> builtins.bool: ... @@ -283,7 +283,7 @@ class EnumValue(google.protobuf.message.Message): *, name : typing.Text = ..., number : builtins.int = ..., - options : typing.Optional[typing.Iterable[global___Option]] = ..., + options : typing.typing.Iterable[global___Option] | None = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"number",b"number",u"options",b"options"]) -> None: ... global___EnumValue = EnumValue @@ -308,7 +308,7 @@ class Option(google.protobuf.message.Message): def __init__(self, *, name : typing.Text = ..., - value : typing.Optional[google.protobuf.any_pb2.Any] = ..., + value : typing.google.protobuf.any_pb2.Any | None = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"value",b"value"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"value",b"value"]) -> None: ... diff --git a/stubs/pyRFC3339/pyrfc3339/utils.pyi b/stubs/pyRFC3339/pyrfc3339/utils.pyi index f49a8c068502..7b3441424666 100644 --- a/stubs/pyRFC3339/pyrfc3339/utils.pyi +++ b/stubs/pyRFC3339/pyrfc3339/utils.pyi @@ -3,9 +3,9 @@ from typing import Optional class FixedOffset(tzinfo): def __init__(self, hours: float, minutes: float) -> None: ... - def dst(self, dt: Optional[datetime]) -> timedelta: ... - def utcoffset(self, dt: Optional[datetime]) -> timedelta: ... - def tzname(self, dt: Optional[datetime]) -> str: ... + def dst(self, dt: datetime | None) -> timedelta: ... + def utcoffset(self, dt: datetime | None) -> timedelta: ... + def tzname(self, dt: datetime | None) -> str: ... def timedelta_seconds(td: timedelta) -> int: ... def timezone(utcoffset: float) -> str: ... diff --git a/stubs/pyaudio/pyaudio.pyi b/stubs/pyaudio/pyaudio.pyi index 8dd7b25b0134..6849056b1d47 100644 --- a/stubs/pyaudio/pyaudio.pyi +++ b/stubs/pyaudio/pyaudio.pyi @@ -86,13 +86,13 @@ class Stream: format: int, input: bool = ..., output: bool = ..., - input_device_index: Optional[int] = ..., - output_device_index: Optional[int] = ..., + input_device_index: int | None = ..., + output_device_index: int | None = ..., frames_per_buffer: int = ..., start: bool = ..., - input_host_api_specific_stream_info: Optional[PaMacCoreStreamInfo] = ..., - output_host_api_specific_stream_info: Optional[PaMacCoreStreamInfo] = ..., - stream_callback: Optional[_StreamCallback] = ..., + input_host_api_specific_stream_info: PaMacCoreStreamInfo | None = ..., + output_host_api_specific_stream_info: PaMacCoreStreamInfo | None = ..., + stream_callback: _StreamCallback | None = ..., ) -> None: ... def close(self) -> None: ... def get_cpu_load(self) -> float: ... @@ -106,7 +106,7 @@ class Stream: def read(self, num_frames: int, exception_on_overflow: bool = ...) -> bytes: ... def start_stream(self) -> None: ... def stop_stream(self) -> None: ... - def write(self, frames: bytes, num_frames: Optional[int] = ..., exception_on_underflow: bool = ...) -> None: ... + def write(self, frames: bytes, num_frames: int | None = ..., exception_on_underflow: bool = ...) -> None: ... class PyAudio: def __init__(self) -> None: ... @@ -125,12 +125,12 @@ class PyAudio: def is_format_supported( self, rate: int, - input_device: Optional[int] = ..., - input_channels: Optional[int] = ..., - input_format: Optional[int] = ..., - output_device: Optional[int] = ..., - output_channels: Optional[int] = ..., - output_format: Optional[int] = ..., + input_device: int | None = ..., + input_channels: int | None = ..., + input_format: int | None = ..., + output_device: int | None = ..., + output_channels: int | None = ..., + output_format: int | None = ..., ) -> bool: ... def open( self, @@ -139,13 +139,13 @@ class PyAudio: format: int, input: bool = ..., output: bool = ..., - input_device_index: Optional[int] = ..., - output_device_index: Optional[int] = ..., + input_device_index: int | None = ..., + output_device_index: int | None = ..., frames_per_buffer: int = ..., start: bool = ..., - input_host_api_specific_stream_info: Optional[PaMacCoreStreamInfo] = ..., - output_host_api_specific_stream_info: Optional[PaMacCoreStreamInfo] = ..., - stream_callback: Optional[_StreamCallback] = ..., + input_host_api_specific_stream_info: PaMacCoreStreamInfo | None = ..., + output_host_api_specific_stream_info: PaMacCoreStreamInfo | None = ..., + stream_callback: _StreamCallback | None = ..., ) -> Stream: ... def terminate(self) -> None: ... @@ -161,6 +161,6 @@ class PaMacCoreStreamInfo: paMacCorePro: Final[int] = ... paMacCoreMinimizeCPUButPlayNice: Final[int] = ... paMacCoreMinimizeCPU: Final[int] = ... - def __init__(self, flags: Optional[int] = ..., channel_map: Optional[_ChannelMap] = ...) -> None: ... + def __init__(self, flags: int | None = ..., channel_map: _ChannelMap | None = ...) -> None: ... def get_flags(self) -> int: ... - def get_channel_map(self) -> Optional[_ChannelMap]: ... + def get_channel_map(self) -> _ChannelMap | None: ... diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 2bbbb68d4717..90986bb0d600 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -25,9 +25,9 @@ from pysftp.helpers import ( class CnOpts: log: bool = ... compression: bool = ... - ciphers: Optional[Sequence[str]] = ... + ciphers: Sequence[str] | None = ... hostkeys: paramiko.HostKeys = ... - def __init__(self, knownhosts: Optional[str] = ...) -> None: ... + def __init__(self, knownhosts: str | None = ...) -> None: ... def get_hostkey(self, host: str) -> paramiko.PKey: ... _Callback = Callable[[int, int], Any] @@ -37,29 +37,29 @@ class Connection: def __init__( self, host: str, - username: Optional[str] = ..., - private_key: Optional[Union[str, paramiko.RSAKey, paramiko.AgentKey]] = ..., - password: Optional[str] = ..., + username: str | None = ..., + private_key: str | paramiko.RSAKey | paramiko.AgentKey | None = ..., + password: str | None = ..., port: int = ..., - private_key_pass: Optional[str] = ..., - ciphers: Optional[Sequence[str]] = ..., + private_key_pass: str | None = ..., + ciphers: Sequence[str] | None = ..., log: bool = ..., - cnopts: Optional[CnOpts] = ..., - default_path: Optional[_Path] = ..., + cnopts: CnOpts | None = ..., + default_path: _Path | None = ..., ) -> None: ... @property def pwd(self) -> str: ... def get( - self, remotepath: _Path, localpath: Optional[_Path] = ..., callback: Optional[_Callback] = ..., preserve_mtime: bool = ... + self, remotepath: _Path, localpath: _Path | None = ..., callback: _Callback | None = ..., preserve_mtime: bool = ... ) -> None: ... def get_d(self, remotedir: _Path, localdir: _Path, preserve_mtime: bool = ...) -> None: ... def get_r(self, remotedir: _Path, localdir: _Path, preserve_mtime: bool = ...) -> None: ... - def getfo(self, remotepath: _Path, flo: IO[bytes], callback: Optional[_Callback] = ...) -> int: ... + def getfo(self, remotepath: _Path, flo: IO[bytes], callback: _Callback | None = ...) -> int: ... def put( self, localpath: _Path, - remotepath: Optional[_Path] = ..., - callback: Optional[_Callback] = ..., + remotepath: _Path | None = ..., + callback: _Callback | None = ..., confirm: bool = ..., preserve_mtime: bool = ..., ) -> paramiko.SFTPAttributes: ... @@ -68,17 +68,17 @@ class Connection: def putfo( self, flo: IO[bytes], - remotepath: Optional[_Path] = ..., + remotepath: _Path | None = ..., file_size: int = ..., - callback: Optional[_Callback] = ..., + callback: _Callback | None = ..., confirm: bool = ..., ) -> paramiko.SFTPAttributes: ... def execute(self, command: str) -> List[str]: ... - def cd(self, remotepath: Optional[_Path] = ...) -> ContextManager[None]: ... # noqa: F811 + def cd(self, remotepath: _Path | None = ...) -> ContextManager[None]: ... # noqa: F811 def chdir(self, remotepath: _Path) -> None: ... def cwd(self, remotepath: _Path) -> None: ... def chmod(self, remotepath: _Path, mode: int = ...) -> None: ... - def chown(self, remotepath: _Path, uid: Optional[int] = ..., gid: Optional[int] = ...) -> None: ... + def chown(self, remotepath: _Path, uid: int | None = ..., gid: int | None = ...) -> None: ... def getcwd(self) -> str: ... def listdir(self, remotepath: _Path = ...) -> List[str]: ... def listdir_attr(self, remotepath: _Path = ...) -> List[paramiko.SFTPAttributes]: ... @@ -112,15 +112,15 @@ class Connection: @property def security_options(self) -> paramiko.SecurityOptions: ... @property - def logfile(self) -> Union[str, Literal[False]]: ... + def logfile(self) -> str | Literal[False]: ... @property - def timeout(self) -> Optional[float]: ... + def timeout(self) -> float | None: ... @timeout.setter - def timeout(self, val: Optional[float]) -> None: ... + def timeout(self, val: float | None) -> None: ... @property def remote_server_key(self) -> paramiko.PKey: ... def __del__(self) -> None: ... def __enter__(self) -> "Connection": ... def __exit__( - self, etype: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] + self, etype: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... diff --git a/stubs/pysftp/pysftp/helpers.pyi b/stubs/pysftp/pysftp/helpers.pyi index f96bec800827..9d2b3a4f1c75 100644 --- a/stubs/pysftp/pysftp/helpers.pyi +++ b/stubs/pysftp/pysftp/helpers.pyi @@ -30,4 +30,4 @@ _PathCallback = Callable[[str], None] def walktree( localpath: str, fcallback: _PathCallback, dcallback: _PathCallback, ucallback: _PathCallback, recurse: bool = ... ) -> None: ... -def cd(localpath: Optional[str] = ...) -> ContextManager[None]: ... +def cd(localpath: str | None = ...) -> ContextManager[None]: ... diff --git a/stubs/python-dateutil/dateutil/_common.pyi b/stubs/python-dateutil/dateutil/_common.pyi index c8326dbb989a..2aefaff5b19e 100644 --- a/stubs/python-dateutil/dateutil/_common.pyi +++ b/stubs/python-dateutil/dateutil/_common.pyi @@ -3,7 +3,7 @@ from typing import Optional, TypeVar _T = TypeVar("_T") class weekday(object): - def __init__(self, weekday: int, n: Optional[int] = ...) -> None: ... + def __init__(self, weekday: int, n: int | None = ...) -> None: ... def __call__(self: _T, n: int) -> _T: ... def __eq__(self, other: object) -> bool: ... def __repr__(self) -> str: ... diff --git a/stubs/python-dateutil/dateutil/parser.pyi b/stubs/python-dateutil/dateutil/parser.pyi index 78c6965afde0..ca4db017137b 100644 --- a/stubs/python-dateutil/dateutil/parser.pyi +++ b/stubs/python-dateutil/dateutil/parser.pyi @@ -14,32 +14,32 @@ class parserinfo(object): TZOFFSET: Dict[str, int] def __init__(self, dayfirst: bool = ..., yearfirst: bool = ...) -> None: ... def jump(self, name: Text) -> bool: ... - def weekday(self, name: Text) -> Optional[int]: ... - def month(self, name: Text) -> Optional[int]: ... - def hms(self, name: Text) -> Optional[int]: ... - def ampm(self, name: Text) -> Optional[int]: ... + def weekday(self, name: Text) -> int | None: ... + def month(self, name: Text) -> int | None: ... + def hms(self, name: Text) -> int | None: ... + def ampm(self, name: Text) -> int | None: ... def pertain(self, name: Text) -> bool: ... def utczone(self, name: Text) -> bool: ... - def tzoffset(self, name: Text) -> Optional[int]: ... + def tzoffset(self, name: Text) -> int | None: ... def convertyear(self, year: int) -> int: ... def validate(self, res: datetime) -> bool: ... class parser(object): - def __init__(self, info: Optional[parserinfo] = ...) -> None: ... + def __init__(self, info: parserinfo | None = ...) -> None: ... def parse( self, timestr: _FileOrStr, - default: Optional[datetime] = ..., + default: datetime | None = ..., ignoretz: bool = ..., - tzinfos: Optional[Mapping[Text, tzinfo]] = ..., + tzinfos: Mapping[Text, tzinfo] | None = ..., **kwargs: Any, ) -> datetime: ... -def isoparse(dt_str: Union[str, bytes, IO[str], IO[bytes]]) -> datetime: ... +def isoparse(dt_str: str | bytes | IO[str] | IO[bytes]) -> datetime: ... DEFAULTPARSER: parser -def parse(timestr: _FileOrStr, parserinfo: Optional[parserinfo] = ..., **kwargs: Any) -> datetime: ... +def parse(timestr: _FileOrStr, parserinfo: parserinfo | None = ..., **kwargs: Any) -> datetime: ... class _tzparser: ... diff --git a/stubs/python-dateutil/dateutil/relativedelta.pyi b/stubs/python-dateutil/dateutil/relativedelta.pyi index d8cfe61c300c..6dd39caee21c 100644 --- a/stubs/python-dateutil/dateutil/relativedelta.pyi +++ b/stubs/python-dateutil/dateutil/relativedelta.pyi @@ -25,37 +25,37 @@ class relativedelta(object): minutes: int seconds: int microseconds: int - year: Optional[int] - month: Optional[int] - weekday: Optional[_weekday] - day: Optional[int] - hour: Optional[int] - minute: Optional[int] - second: Optional[int] - microsecond: Optional[int] + year: int | None + month: int | None + weekday: _weekday | None + day: int | None + hour: int | None + minute: int | None + second: int | None + microsecond: int | None def __init__( self, - dt1: Optional[date] = ..., - dt2: Optional[date] = ..., - years: Optional[int] = ..., - months: Optional[int] = ..., - days: Optional[int] = ..., - leapdays: Optional[int] = ..., - weeks: Optional[int] = ..., - hours: Optional[int] = ..., - minutes: Optional[int] = ..., - seconds: Optional[int] = ..., - microseconds: Optional[int] = ..., - year: Optional[int] = ..., - month: Optional[int] = ..., - day: Optional[int] = ..., - weekday: Optional[Union[int, _weekday]] = ..., - yearday: Optional[int] = ..., - nlyearday: Optional[int] = ..., - hour: Optional[int] = ..., - minute: Optional[int] = ..., - second: Optional[int] = ..., - microsecond: Optional[int] = ..., + dt1: date | None = ..., + dt2: date | None = ..., + years: int | None = ..., + months: int | None = ..., + days: int | None = ..., + leapdays: int | None = ..., + weeks: int | None = ..., + hours: int | None = ..., + minutes: int | None = ..., + seconds: int | None = ..., + microseconds: int | None = ..., + year: int | None = ..., + month: int | None = ..., + day: int | None = ..., + weekday: int | _weekday | None = ..., + yearday: int | None = ..., + nlyearday: int | None = ..., + hour: int | None = ..., + minute: int | None = ..., + second: int | None = ..., + microsecond: int | None = ..., ) -> None: ... @property def weeks(self) -> int: ... diff --git a/stubs/python-dateutil/dateutil/rrule.pyi b/stubs/python-dateutil/dateutil/rrule.pyi index a0b9af35e28a..a3fbe78f94e3 100644 --- a/stubs/python-dateutil/dateutil/rrule.pyi +++ b/stubs/python-dateutil/dateutil/rrule.pyi @@ -29,28 +29,28 @@ class rrulebase: def count(self): ... def before(self, dt, inc: bool = ...): ... def after(self, dt, inc: bool = ...): ... - def xafter(self, dt, count: Optional[Any] = ..., inc: bool = ...): ... + def xafter(self, dt, count: Any | None = ..., inc: bool = ...): ... def between(self, after, before, inc: bool = ..., count: int = ...): ... class rrule(rrulebase): def __init__( self, freq, - dtstart: Optional[datetime.date] = ..., + dtstart: datetime.date | None = ..., interval: int = ..., - wkst: Optional[Union[weekday, int]] = ..., - count: Optional[int] = ..., - until: Optional[Union[datetime.date, int]] = ..., - bysetpos: Optional[Union[int, Iterable[int]]] = ..., - bymonth: Optional[Union[int, Iterable[int]]] = ..., - bymonthday: Optional[Union[int, Iterable[int]]] = ..., - byyearday: Optional[Union[int, Iterable[int]]] = ..., - byeaster: Optional[Union[int, Iterable[int]]] = ..., - byweekno: Optional[Union[int, Iterable[int]]] = ..., - byweekday: Optional[Union[int, weekday, Iterable[int], Iterable[weekday]]] = ..., - byhour: Optional[Union[int, Iterable[int]]] = ..., - byminute: Optional[Union[int, Iterable[int]]] = ..., - bysecond: Optional[Union[int, Iterable[int]]] = ..., + wkst: weekday | int | None = ..., + count: int | None = ..., + until: datetime.date | int | None = ..., + bysetpos: int | Iterable[int] | None = ..., + bymonth: int | Iterable[int] | None = ..., + bymonthday: int | Iterable[int] | None = ..., + byyearday: int | Iterable[int] | None = ..., + byeaster: int | Iterable[int] | None = ..., + byweekno: int | Iterable[int] | None = ..., + byweekday: int | weekday | Iterable[int] | Iterable[weekday] | None = ..., + byhour: int | Iterable[int] | None = ..., + byminute: int | Iterable[int] | None = ..., + bysecond: int | Iterable[int] | None = ..., cache: bool = ..., ) -> None: ... def replace(self, **kwargs): ... diff --git a/stubs/python-dateutil/dateutil/tz/_common.pyi b/stubs/python-dateutil/dateutil/tz/_common.pyi index b185f0dcafec..354b8fa3dcfa 100644 --- a/stubs/python-dateutil/dateutil/tz/_common.pyi +++ b/stubs/python-dateutil/dateutil/tz/_common.pyi @@ -14,9 +14,9 @@ class _tzinfo(tzinfo): class tzrangebase(_tzinfo): def __init__(self) -> None: ... - def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ... - def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... - def tzname(self, dt: Optional[datetime]) -> str: ... + def utcoffset(self, dt: datetime | None) -> timedelta | None: ... + def dst(self, dt: datetime | None) -> timedelta | None: ... + def tzname(self, dt: datetime | None) -> str: ... def fromutc(self, dt: datetime) -> datetime: ... def is_ambiguous(self, dt: datetime) -> bool: ... __hash__: Any diff --git a/stubs/python-dateutil/dateutil/tz/tz.pyi b/stubs/python-dateutil/dateutil/tz/tz.pyi index ee7e6a539ffb..df68918a1627 100644 --- a/stubs/python-dateutil/dateutil/tz/tz.pyi +++ b/stubs/python-dateutil/dateutil/tz/tz.pyi @@ -11,10 +11,10 @@ EPOCH: datetime.datetime EPOCHORDINAL: int class tzutc(datetime.tzinfo): - def utcoffset(self, dt: Optional[datetime.datetime]) -> Optional[datetime.timedelta]: ... - def dst(self, dt: Optional[datetime.datetime]) -> Optional[datetime.timedelta]: ... - def tzname(self, dt: Optional[datetime.datetime]) -> str: ... - def is_ambiguous(self, dt: Optional[datetime.datetime]) -> bool: ... + def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ... + def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ... + def tzname(self, dt: datetime.datetime | None) -> str: ... + def is_ambiguous(self, dt: datetime.datetime | None) -> bool: ... def __eq__(self, other): ... __hash__: Any def __ne__(self, other): ... @@ -22,10 +22,10 @@ class tzutc(datetime.tzinfo): class tzoffset(datetime.tzinfo): def __init__(self, name, offset) -> None: ... - def utcoffset(self, dt: Optional[datetime.datetime]) -> Optional[datetime.timedelta]: ... - def dst(self, dt: Optional[datetime.datetime]) -> Optional[datetime.timedelta]: ... - def is_ambiguous(self, dt: Optional[datetime.datetime]) -> bool: ... - def tzname(self, dt: Optional[datetime.datetime]) -> str: ... + def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ... + def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ... + def is_ambiguous(self, dt: datetime.datetime | None) -> bool: ... + def tzname(self, dt: datetime.datetime | None) -> str: ... def __eq__(self, other): ... __hash__: Any def __ne__(self, other): ... @@ -35,10 +35,10 @@ class tzoffset(datetime.tzinfo): class tzlocal(_tzinfo): def __init__(self) -> None: ... - def utcoffset(self, dt: Optional[datetime.datetime]) -> Optional[datetime.timedelta]: ... - def dst(self, dt: Optional[datetime.datetime]) -> Optional[datetime.timedelta]: ... - def tzname(self, dt: Optional[datetime.datetime]) -> str: ... - def is_ambiguous(self, dt: Optional[datetime.datetime]) -> bool: ... + def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ... + def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ... + def tzname(self, dt: datetime.datetime | None) -> str: ... + def is_ambiguous(self, dt: datetime.datetime | None) -> bool: ... def __eq__(self, other): ... __hash__: Any def __ne__(self, other): ... @@ -51,11 +51,11 @@ class _ttinfo: def __ne__(self, other): ... class tzfile(_tzinfo): - def __init__(self, fileobj: _FileObj, filename: Optional[Text] = ...) -> None: ... - def is_ambiguous(self, dt: Optional[datetime.datetime], idx: Optional[int] = ...) -> bool: ... - def utcoffset(self, dt: Optional[datetime.datetime]) -> Optional[datetime.timedelta]: ... - def dst(self, dt: Optional[datetime.datetime]) -> Optional[datetime.timedelta]: ... - def tzname(self, dt: Optional[datetime.datetime]) -> str: ... + def __init__(self, fileobj: _FileObj, filename: Text | None = ...) -> None: ... + def is_ambiguous(self, dt: datetime.datetime | None, idx: int | None = ...) -> bool: ... + def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ... + def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ... + def tzname(self, dt: datetime.datetime | None) -> str: ... def __eq__(self, other): ... __hash__: Any def __ne__(self, other): ... @@ -67,35 +67,35 @@ class tzrange(tzrangebase): def __init__( self, stdabbr: Text, - stdoffset: Union[int, datetime.timedelta, None] = ..., - dstabbr: Optional[Text] = ..., - dstoffset: Union[int, datetime.timedelta, None] = ..., - start: Optional[relativedelta] = ..., - end: Optional[relativedelta] = ..., + stdoffset: int | datetime.timedelta | None = ..., + dstabbr: Text | None = ..., + dstoffset: int | datetime.timedelta | None = ..., + start: relativedelta | None = ..., + end: relativedelta | None = ..., ) -> None: ... def transitions(self, year: int) -> Tuple[datetime.datetime, datetime.datetime]: ... def __eq__(self, other): ... class tzstr(tzrange): hasdst: bool - def __init__(self, s: Union[bytes, _FileObj], posix_offset: bool = ...) -> None: ... + def __init__(self, s: bytes | _FileObj, posix_offset: bool = ...) -> None: ... @classmethod def instance(cls, name, offset) -> tzoffset: ... class tzical: def __init__(self, fileobj: _FileObj) -> None: ... def keys(self): ... - def get(self, tzid: Optional[Any] = ...): ... + def get(self, tzid: Any | None = ...): ... TZFILES: List[str] TZPATHS: List[str] -def datetime_exists(dt: datetime.datetime, tz: Optional[datetime.tzinfo] = ...) -> bool: ... -def datetime_ambiguous(dt: datetime.datetime, tz: Optional[datetime.tzinfo] = ...) -> bool: ... +def datetime_exists(dt: datetime.datetime, tz: datetime.tzinfo | None = ...) -> bool: ... +def datetime_ambiguous(dt: datetime.datetime, tz: datetime.tzinfo | None = ...) -> bool: ... def resolve_imaginary(dt: datetime.datetime) -> datetime.datetime: ... class _GetTZ: - def __call__(self, name: Optional[Text] = ...) -> Optional[datetime.tzinfo]: ... - def nocache(self, name: Optional[Text]) -> Optional[datetime.tzinfo]: ... + def __call__(self, name: Text | None = ...) -> datetime.tzinfo | None: ... + def nocache(self, name: Text | None) -> datetime.tzinfo | None: ... gettz: _GetTZ diff --git a/stubs/python-dateutil/dateutil/utils.pyi b/stubs/python-dateutil/dateutil/utils.pyi index 1eaa66683440..62044433391e 100644 --- a/stubs/python-dateutil/dateutil/utils.pyi +++ b/stubs/python-dateutil/dateutil/utils.pyi @@ -2,5 +2,5 @@ from datetime import datetime, timedelta, tzinfo from typing import Optional def default_tzinfo(dt: datetime, tzinfo: tzinfo) -> datetime: ... -def today(tzinfo: Optional[tzinfo] = ...) -> datetime: ... +def today(tzinfo: tzinfo | None = ...) -> datetime: ... def within_delta(dt1: datetime, dt2: datetime, delta: timedelta) -> bool: ... diff --git a/stubs/python-gflags/gflags.pyi b/stubs/python-gflags/gflags.pyi index a4c487d310d4..e2904dc6233c 100644 --- a/stubs/python-gflags/gflags.pyi +++ b/stubs/python-gflags/gflags.pyi @@ -72,7 +72,7 @@ class FlagValues: FlagValuesDict = flag_values_dict def __str__(self) -> str: ... def GetHelp(self, prefix: str = ...) -> str: ... - def module_help(self, module: Union[ModuleType, str]) -> str: ... + def module_help(self, module: ModuleType | str) -> str: ... ModuleHelp = module_help def main_module_help(self) -> str: ... MainModuleHelp = main_module_help @@ -111,7 +111,7 @@ class Flag: parser: ArgumentParser, serializer: ArgumentSerializer, name: str, - default: Optional[str], + default: str | None, help_string: str, short_name: str = ..., boolean: bool = ..., @@ -176,16 +176,16 @@ def adopt_module_key_flags(module: ModuleType, flag_values: FlagValues = ...) -> ADOPT_module_key_flags = adopt_module_key_flags -def DEFINE_string(name: str, default: Optional[str], help: str, flag_values: FlagValues = ..., **args: Any) -> None: ... +def DEFINE_string(name: str, default: str | None, help: str, flag_values: FlagValues = ..., **args: Any) -> None: ... class BooleanParser(ArgumentParser): def Convert(self, argument: Any) -> bool: ... def Parse(self, argument: Any) -> bool: ... class BooleanFlag(Flag): - def __init__(self, name: str, default: Optional[bool], help: str, short_name: str = ..., **args: Any) -> None: ... + def __init__(self, name: str, default: bool | None, help: str, short_name: str = ..., **args: Any) -> None: ... -def DEFINE_boolean(name: str, default: Optional[bool], help: str, flag_values: FlagValues = ..., **args: Any) -> None: ... +def DEFINE_boolean(name: str, default: bool | None, help: str, flag_values: FlagValues = ..., **args: Any) -> None: ... DEFINE_bool = DEFINE_boolean @@ -216,7 +216,7 @@ class FloatParser(NumericParser): def DEFINE_float( name: str, - default: Optional[float], + default: float | None, help: str, lower_bound: float = ..., upper_bound: float = ..., @@ -233,7 +233,7 @@ class IntegerParser(NumericParser): def DEFINE_integer( name: str, - default: Optional[int], + default: int | None, help: str, lower_bound: int = ..., upper_bound: int = ..., @@ -247,11 +247,11 @@ class EnumParser(ArgumentParser): class EnumFlag(Flag): def __init__( - self, name: str, default: Optional[str], help: str, enum_values: List[str], short_name: str, **args: Any + self, name: str, default: str | None, help: str, enum_values: List[str], short_name: str, **args: Any ) -> None: ... def DEFINE_enum( - name: str, default: Optional[str], enum_values: Iterable[str], help: str, flag_values: FlagValues = ..., **args: Any + name: str, default: str | None, enum_values: Iterable[str], help: str, flag_values: FlagValues = ..., **args: Any ) -> None: ... class BaseListParser(ArgumentParser): @@ -264,9 +264,9 @@ class ListParser(BaseListParser): class WhitespaceSeparatedListParser(BaseListParser): def __init__(self) -> None: ... -def DEFINE_list(name: str, default: Optional[List[str]], help: str, flag_values: FlagValues = ..., **args: Any) -> None: ... +def DEFINE_list(name: str, default: List[str] | None, help: str, flag_values: FlagValues = ..., **args: Any) -> None: ... def DEFINE_spaceseplist( - name: str, default: Optional[List[str]], help: str, flag_values: FlagValues = ..., **args: Any + name: str, default: List[str] | None, help: str, flag_values: FlagValues = ..., **args: Any ) -> None: ... class MultiFlag(Flag): @@ -275,14 +275,14 @@ class MultiFlag(Flag): def Serialize(self) -> str: ... def DEFINE_multi_string( - name: str, default: Optional[Union[str, List[str]]], help: str, flag_values: FlagValues = ..., **args: Any + name: str, default: str | List[str] | None, help: str, flag_values: FlagValues = ..., **args: Any ) -> None: ... DEFINE_multistring = DEFINE_multi_string def DEFINE_multi_integer( name: str, - default: Optional[Union[int, List[int]]], + default: int | List[int] | None, help: str, lower_bound: int = ..., upper_bound: int = ..., @@ -294,7 +294,7 @@ DEFINE_multi_int = DEFINE_multi_integer def DEFINE_multi_float( name: str, - default: Optional[Union[float, List[float]]], + default: float | List[float] | None, help: str, lower_bound: float = ..., upper_bound: float = ..., @@ -303,7 +303,7 @@ def DEFINE_multi_float( ) -> None: ... def DEFINE_multi_enum( name: str, - default: Optional[Union[Sequence[str], str]], + default: Sequence[str] | str | None, enum_values: Sequence[str], help: str, flag_values: FlagValues = ..., diff --git a/stubs/python-slugify/slugify/slugify.pyi b/stubs/python-slugify/slugify/slugify.pyi index a51c78732ac4..d53dc07e4644 100644 --- a/stubs/python-slugify/slugify/slugify.pyi +++ b/stubs/python-slugify/slugify/slugify.pyi @@ -13,7 +13,7 @@ def slugify( separator: str = ..., save_order: bool = ..., stopwords: Iterable[str] = ..., - regex_pattern: Optional[str] = ..., + regex_pattern: str | None = ..., lowercase: bool = ..., replacements: Iterable[str] = ..., ) -> str: ... diff --git a/stubs/pytz/pytz/__init__.pyi b/stubs/pytz/pytz/__init__.pyi index 10423da452f0..6a01fa9b298a 100644 --- a/stubs/pytz/pytz/__init__.pyi +++ b/stubs/pytz/pytz/__init__.pyi @@ -3,23 +3,23 @@ from typing import List, Mapping, Optional, Set, Union class BaseTzInfo(datetime.tzinfo): zone: str = ... - def localize(self, dt: datetime.datetime, is_dst: Optional[bool] = ...) -> datetime.datetime: ... + def localize(self, dt: datetime.datetime, is_dst: bool | None = ...) -> datetime.datetime: ... def normalize(self, dt: datetime.datetime) -> datetime.datetime: ... class _UTCclass(BaseTzInfo): - def tzname(self, dt: Optional[datetime.datetime]) -> str: ... - def utcoffset(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... - def dst(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... + def tzname(self, dt: datetime.datetime | None) -> str: ... + def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta: ... + def dst(self, dt: datetime.datetime | None) -> datetime.timedelta: ... class _StaticTzInfo(BaseTzInfo): - def tzname(self, dt: Optional[datetime.datetime], is_dst: Optional[bool] = ...) -> str: ... - def utcoffset(self, dt: Optional[datetime.datetime], is_dst: Optional[bool] = ...) -> datetime.timedelta: ... - def dst(self, dt: Optional[datetime.datetime], is_dst: Optional[bool] = ...) -> datetime.timedelta: ... + def tzname(self, dt: datetime.datetime | None, is_dst: bool | None = ...) -> str: ... + def utcoffset(self, dt: datetime.datetime | None, is_dst: bool | None = ...) -> datetime.timedelta: ... + def dst(self, dt: datetime.datetime | None, is_dst: bool | None = ...) -> datetime.timedelta: ... class _DstTzInfo(BaseTzInfo): - def tzname(self, dt: Optional[datetime.datetime], is_dst: Optional[bool] = ...) -> str: ... - def utcoffset(self, dt: Optional[datetime.datetime], is_dst: Optional[bool] = ...) -> Optional[datetime.timedelta]: ... - def dst(self, dt: Optional[datetime.datetime], is_dst: Optional[bool] = ...) -> Optional[datetime.timedelta]: ... + def tzname(self, dt: datetime.datetime | None, is_dst: bool | None = ...) -> str: ... + def utcoffset(self, dt: datetime.datetime | None, is_dst: bool | None = ...) -> datetime.timedelta | None: ... + def dst(self, dt: datetime.datetime | None, is_dst: bool | None = ...) -> datetime.timedelta | None: ... class UnknownTimeZoneError(KeyError): ... class InvalidTimeError(Exception): ... @@ -29,8 +29,8 @@ class NonExistentTimeError(InvalidTimeError): ... utc: _UTCclass UTC: _UTCclass -def timezone(zone: str) -> Union[_UTCclass, _StaticTzInfo, _DstTzInfo]: ... -def FixedOffset(offset: int) -> Union[_UTCclass, datetime.tzinfo]: ... +def timezone(zone: str) -> _UTCclass | _StaticTzInfo | _DstTzInfo: ... +def FixedOffset(offset: int) -> _UTCclass | datetime.tzinfo: ... all_timezones: List[str] all_timezones_set: Set[str] diff --git a/stubs/pyvmomi/pyVmomi/vmodl/query.pyi b/stubs/pyvmomi/pyVmomi/vmodl/query.pyi index 7f089b875b08..9bd372a9b2e8 100644 --- a/stubs/pyvmomi/pyVmomi/vmodl/query.pyi +++ b/stubs/pyvmomi/pyVmomi/vmodl/query.pyi @@ -47,9 +47,9 @@ class PropertyCollector: propSet: List[DynamicProperty] def __getattr__(self, name: str) -> Any: ... # incomplete class RetrieveResult: - def __init__(self, *, objects: List[PropertyCollector.ObjectContent] = ..., token: Optional[str] = ...) -> None: ... + def __init__(self, *, objects: List[PropertyCollector.ObjectContent] = ..., token: str | None = ...) -> None: ... objects: List[PropertyCollector.ObjectContent] - token: Optional[str] + token: str | None def RetrievePropertiesEx( self, specSet: List[PropertyCollector.FilterSpec], options: PropertyCollector.RetrieveOptions ) -> PropertyCollector.RetrieveResult: ... diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 0b70a94daf65..0be14f1679b8 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -71,100 +71,100 @@ class Redis(Generic[_StrType]): def from_url( cls, url: Text, - host: Optional[Text], - port: Optional[int], - db: Optional[int], - password: Optional[Text], - socket_timeout: Optional[float], - socket_connect_timeout: Optional[float], - socket_keepalive: Optional[bool], - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]], - connection_pool: Optional[ConnectionPool], - unix_socket_path: Optional[Text], + host: Text | None, + port: int | None, + db: int | None, + password: Text | None, + socket_timeout: float | None, + socket_connect_timeout: float | None, + socket_keepalive: bool | None, + socket_keepalive_options: Mapping[str, int | str] | None, + connection_pool: ConnectionPool | None, + unix_socket_path: Text | None, encoding: Text, encoding_errors: Text, - charset: Optional[Text], - errors: Optional[Text], + charset: Text | None, + errors: Text | None, decode_responses: Literal[True], retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> Redis[str]: ... @overload @classmethod def from_url( cls, url: Text, - host: Optional[Text] = ..., - port: Optional[int] = ..., - db: Optional[int] = ..., - password: Optional[Text] = ..., - socket_timeout: Optional[float] = ..., - socket_connect_timeout: Optional[float] = ..., - socket_keepalive: Optional[bool] = ..., - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]] = ..., - connection_pool: Optional[ConnectionPool] = ..., - unix_socket_path: Optional[Text] = ..., + host: Text | None = ..., + port: int | None = ..., + db: int | None = ..., + password: Text | None = ..., + socket_timeout: float | None = ..., + socket_connect_timeout: float | None = ..., + socket_keepalive: bool | None = ..., + socket_keepalive_options: Mapping[str, int | str] | None = ..., + connection_pool: ConnectionPool | None = ..., + unix_socket_path: Text | None = ..., encoding: Text = ..., encoding_errors: Text = ..., - charset: Optional[Text] = ..., - errors: Optional[Text] = ..., + charset: Text | None = ..., + errors: Text | None = ..., *, decode_responses: Literal[True], retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> Redis[str]: ... @overload @classmethod def from_url( cls, url: Text, - host: Optional[Text] = ..., - port: Optional[int] = ..., - db: Optional[int] = ..., - password: Optional[Text] = ..., - socket_timeout: Optional[float] = ..., - socket_connect_timeout: Optional[float] = ..., - socket_keepalive: Optional[bool] = ..., - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]] = ..., - connection_pool: Optional[ConnectionPool] = ..., - unix_socket_path: Optional[Text] = ..., + host: Text | None = ..., + port: int | None = ..., + db: int | None = ..., + password: Text | None = ..., + socket_timeout: float | None = ..., + socket_connect_timeout: float | None = ..., + socket_keepalive: bool | None = ..., + socket_keepalive_options: Mapping[str, int | str] | None = ..., + connection_pool: ConnectionPool | None = ..., + unix_socket_path: Text | None = ..., encoding: Text = ..., encoding_errors: Text = ..., - charset: Optional[Text] = ..., + charset: Text | None = ..., decode_responses: Literal[False] = ..., - errors: Optional[Text] = ..., + errors: Text | None = ..., retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> Redis[bytes]: ... connection_pool: Any response_callbacks: Any @@ -174,30 +174,30 @@ class Redis(Generic[_StrType]): host: Text, port: int, db: int, - password: Optional[Text], - socket_timeout: Optional[float], - socket_connect_timeout: Optional[float], - socket_keepalive: Optional[bool], - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]], - connection_pool: Optional[ConnectionPool], - unix_socket_path: Optional[Text], + password: Text | None, + socket_timeout: float | None, + socket_connect_timeout: float | None, + socket_keepalive: bool | None, + socket_keepalive_options: Mapping[str, int | str] | None, + connection_pool: ConnectionPool | None, + unix_socket_path: Text | None, encoding: Text, encoding_errors: Text, - charset: Optional[Text], + charset: Text | None, decode_responses: Literal[True], - errors: Optional[Text] = ..., + errors: Text | None = ..., retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> Redis[str]: ... @overload def __new__( @@ -205,31 +205,31 @@ class Redis(Generic[_StrType]): host: Text = ..., port: int = ..., db: int = ..., - password: Optional[Text] = ..., - socket_timeout: Optional[float] = ..., - socket_connect_timeout: Optional[float] = ..., - socket_keepalive: Optional[bool] = ..., - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]] = ..., - connection_pool: Optional[ConnectionPool] = ..., - unix_socket_path: Optional[Text] = ..., + password: Text | None = ..., + socket_timeout: float | None = ..., + socket_connect_timeout: float | None = ..., + socket_keepalive: bool | None = ..., + socket_keepalive_options: Mapping[str, int | str] | None = ..., + connection_pool: ConnectionPool | None = ..., + unix_socket_path: Text | None = ..., encoding: Text = ..., encoding_errors: Text = ..., - charset: Optional[Text] = ..., + charset: Text | None = ..., *, decode_responses: Literal[True], - errors: Optional[Text] = ..., + errors: Text | None = ..., retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> Redis[str]: ... @overload def __new__( @@ -237,30 +237,30 @@ class Redis(Generic[_StrType]): host: Text = ..., port: int = ..., db: int = ..., - password: Optional[Text] = ..., - socket_timeout: Optional[float] = ..., - socket_connect_timeout: Optional[float] = ..., - socket_keepalive: Optional[bool] = ..., - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]] = ..., - connection_pool: Optional[ConnectionPool] = ..., - unix_socket_path: Optional[Text] = ..., + password: Text | None = ..., + socket_timeout: float | None = ..., + socket_connect_timeout: float | None = ..., + socket_keepalive: bool | None = ..., + socket_keepalive_options: Mapping[str, int | str] | None = ..., + connection_pool: ConnectionPool | None = ..., + unix_socket_path: Text | None = ..., encoding: Text = ..., encoding_errors: Text = ..., - charset: Optional[Text] = ..., - errors: Optional[Text] = ..., + charset: Text | None = ..., + errors: Text | None = ..., decode_responses: Literal[False] = ..., retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> Redis[bytes]: ... @overload def __init__( @@ -268,30 +268,30 @@ class Redis(Generic[_StrType]): host: Text, port: int, db: int, - password: Optional[Text], - socket_timeout: Optional[float], - socket_connect_timeout: Optional[float], - socket_keepalive: Optional[bool], - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]], - connection_pool: Optional[ConnectionPool], - unix_socket_path: Optional[Text], + password: Text | None, + socket_timeout: float | None, + socket_connect_timeout: float | None, + socket_keepalive: bool | None, + socket_keepalive_options: Mapping[str, int | str] | None, + connection_pool: ConnectionPool | None, + unix_socket_path: Text | None, encoding: Text, encoding_errors: Text, - charset: Optional[Text], - errors: Optional[Text], + charset: Text | None, + errors: Text | None, decode_responses: Literal[True], retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> None: ... @overload def __init__( @@ -299,31 +299,31 @@ class Redis(Generic[_StrType]): host: Text = ..., port: int = ..., db: int = ..., - password: Optional[Text] = ..., - socket_timeout: Optional[float] = ..., - socket_connect_timeout: Optional[float] = ..., - socket_keepalive: Optional[bool] = ..., - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]] = ..., - connection_pool: Optional[ConnectionPool] = ..., - unix_socket_path: Optional[Text] = ..., + password: Text | None = ..., + socket_timeout: float | None = ..., + socket_connect_timeout: float | None = ..., + socket_keepalive: bool | None = ..., + socket_keepalive_options: Mapping[str, int | str] | None = ..., + connection_pool: ConnectionPool | None = ..., + unix_socket_path: Text | None = ..., encoding: Text = ..., encoding_errors: Text = ..., - charset: Optional[Text] = ..., - errors: Optional[Text] = ..., + charset: Text | None = ..., + errors: Text | None = ..., *, decode_responses: Literal[True], retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> None: ... @overload def __init__( @@ -331,30 +331,30 @@ class Redis(Generic[_StrType]): host: Text = ..., port: int = ..., db: int = ..., - password: Optional[Text] = ..., - socket_timeout: Optional[float] = ..., - socket_connect_timeout: Optional[float] = ..., - socket_keepalive: Optional[bool] = ..., - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]] = ..., - connection_pool: Optional[ConnectionPool] = ..., - unix_socket_path: Optional[Text] = ..., + password: Text | None = ..., + socket_timeout: float | None = ..., + socket_connect_timeout: float | None = ..., + socket_keepalive: bool | None = ..., + socket_keepalive_options: Mapping[str, int | str] | None = ..., + connection_pool: ConnectionPool | None = ..., + unix_socket_path: Text | None = ..., encoding: Text = ..., encoding_errors: Text = ..., - charset: Optional[Text] = ..., - errors: Optional[Text] = ..., + charset: Text | None = ..., + errors: Text | None = ..., decode_responses: Literal[False] = ..., retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Optional[Text] = ..., - ssl_certfile: Optional[Text] = ..., - ssl_cert_reqs: Optional[Union[str, int]] = ..., - ssl_ca_certs: Optional[Text] = ..., + ssl_keyfile: Text | None = ..., + ssl_certfile: Text | None = ..., + ssl_cert_reqs: str | int | None = ..., + ssl_ca_certs: Text | None = ..., ssl_check_hostname: bool = ..., - max_connections: Optional[int] = ..., + max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> None: ... def set_response_callback(self, command, callback): ... def pipeline(self, transaction: bool = ..., shard_hint: Any = ...) -> Pipeline[_StrType]: ... @@ -363,9 +363,9 @@ class Redis(Generic[_StrType]): def lock( self, name: _Key, - timeout: Optional[float] = ..., + timeout: float | None = ..., sleep: float = ..., - blocking_timeout: Optional[float] = ..., + blocking_timeout: float | None = ..., lock_class: None = ..., thread_local: bool = ..., ) -> Lock: ... @@ -373,9 +373,9 @@ class Redis(Generic[_StrType]): def lock( self, name: _Key, - timeout: Optional[float], + timeout: float | None, sleep: float, - blocking_timeout: Optional[float], + blocking_timeout: float | None, lock_class: Type[_LockType], thread_local: bool = ..., ) -> _LockType: ... @@ -383,9 +383,9 @@ class Redis(Generic[_StrType]): def lock( self, name: _Key, - timeout: Optional[float] = ..., + timeout: float | None = ..., sleep: float = ..., - blocking_timeout: Optional[float] = ..., + blocking_timeout: float | None = ..., *, lock_class: Type[_LockType], thread_local: bool = ..., @@ -393,10 +393,10 @@ class Redis(Generic[_StrType]): def pubsub(self, shard_hint: Any = ..., ignore_subscribe_messages: bool = ...) -> PubSub: ... def execute_command(self, *args, **options): ... def parse_response(self, connection, command_name, **options): ... - def acl_cat(self, category: Optional[Text] = ...) -> List[str]: ... + def acl_cat(self, category: Text | None = ...) -> List[str]: ... def acl_deluser(self, username: Text) -> int: ... def acl_genpass(self) -> Text: ... - def acl_getuser(self, username: Text) -> Optional[Any]: ... + def acl_getuser(self, username: Text) -> Any | None: ... def acl_list(self) -> List[Text]: ... def acl_load(self) -> bool: ... def acl_setuser( @@ -404,11 +404,11 @@ class Redis(Generic[_StrType]): username: Text = ..., enabled: bool = ..., nopass: bool = ..., - passwords: Optional[Sequence[Text]] = ..., - hashed_passwords: Optional[Sequence[Text]] = ..., - categories: Optional[Sequence[Text]] = ..., - commands: Optional[Sequence[Text]] = ..., - keys: Optional[Sequence[Text]] = ..., + passwords: Sequence[Text] | None = ..., + hashed_passwords: Sequence[Text] | None = ..., + categories: Sequence[Text] | None = ..., + commands: Sequence[Text] | None = ..., + keys: Sequence[Text] | None = ..., reset: bool = ..., reset_keys: bool = ..., reset_passwords: bool = ..., @@ -420,7 +420,7 @@ class Redis(Generic[_StrType]): def client_id(self) -> int: ... def client_kill(self, address: Text) -> bool: ... def client_list(self) -> List[Dict[str, str]]: ... - def client_getname(self) -> Optional[str]: ... + def client_getname(self) -> str | None: ... def client_setname(self, name: Text) -> bool: ... def readwrite(self) -> bool: ... def readonly(self) -> bool: ... @@ -433,7 +433,7 @@ class Redis(Generic[_StrType]): def echo(self, value: _Value) -> bytes: ... def flushall(self) -> bool: ... def flushdb(self) -> bool: ... - def info(self, section: Optional[_Key] = ...) -> Mapping[str, Any]: ... + def info(self, section: _Key | None = ...) -> Mapping[str, Any]: ... def lastsave(self): ... def object(self, infotype, key): ... def ping(self) -> bool: ... @@ -454,7 +454,7 @@ class Redis(Generic[_StrType]): def slowlog_reset(self): ... def time(self): ... def append(self, key, value): ... - def bitcount(self, key: _Key, start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... + def bitcount(self, key: _Key, start: int | None = ..., end: int | None = ...) -> int: ... def bitop(self, operation, dest, *keys): ... def bitpos(self, key, bit, start=..., end=...): ... def decr(self, name, amount=...): ... @@ -463,24 +463,24 @@ class Redis(Generic[_StrType]): def dump(self, name): ... def exists(self, *names: _Key) -> int: ... __contains__: Any - def expire(self, name: _Key, time: Union[int, timedelta]) -> bool: ... + def expire(self, name: _Key, time: int | timedelta) -> bool: ... def expireat(self, name, when): ... - def get(self, name: _Key) -> Optional[_StrType]: ... + def get(self, name: _Key) -> _StrType | None: ... def __getitem__(self, name): ... def getbit(self, name: _Key, offset: int) -> int: ... def getrange(self, key, start, end): ... - def getset(self, name, value) -> Optional[_StrType]: ... + def getset(self, name, value) -> _StrType | None: ... def incr(self, name: _Key, amount: int = ...) -> int: ... def incrby(self, name: _Key, amount: int = ...) -> int: ... def incrbyfloat(self, name: _Key, amount: float = ...) -> float: ... def keys(self, pattern: _Key = ...) -> List[_StrType]: ... - def mget(self, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> List[Optional[_StrType]]: ... + def mget(self, keys: _Key | Iterable[_Key], *args: _Key) -> List[_StrType | None]: ... def mset(self, mapping: Mapping[_Key, _Value]) -> Literal[True]: ... def msetnx(self, mapping: Mapping[_Key, _Value]) -> bool: ... def move(self, name: _Key, db: int) -> bool: ... def persist(self, name: _Key) -> bool: ... - def pexpire(self, name: _Key, time: Union[int, timedelta]) -> Literal[1, 0]: ... - def pexpireat(self, name: _Key, when: Union[int, datetime]) -> Literal[1, 0]: ... + def pexpire(self, name: _Key, time: int | timedelta) -> Literal[1, 0]: ... + def pexpireat(self, name: _Key, when: int | datetime) -> Literal[1, 0]: ... def psetex(self, name, time_ms, value): ... def pttl(self, name): ... def randomkey(self): ... @@ -491,15 +491,15 @@ class Redis(Generic[_StrType]): self, name: _Key, value: _Value, - ex: Union[None, int, timedelta] = ..., - px: Union[None, int, timedelta] = ..., + ex: None | int | timedelta = ..., + px: None | int | timedelta = ..., nx: bool = ..., xx: bool = ..., keepttl: bool = ..., - ) -> Optional[bool]: ... + ) -> bool | None: ... def __setitem__(self, name, value): ... def setbit(self, name: _Key, offset: int, value: int) -> int: ... - def setex(self, name: _Key, time: Union[int, timedelta], value: _Value) -> bool: ... + def setex(self, name: _Key, time: int | timedelta, value: _Value) -> bool: ... def setnx(self, name: _Key, value: _Value) -> bool: ... def setrange(self, name, offset, value): ... def strlen(self, name): ... @@ -510,15 +510,15 @@ class Redis(Generic[_StrType]): def unlink(self, *names: _Key) -> int: ... def unwatch(self): ... @overload - def blpop(self, keys: Union[_Value, Iterable[_Value]], timeout: Literal[0] = ...) -> Tuple[_StrType, _StrType]: ... + def blpop(self, keys: _Value | Iterable[_Value], timeout: Literal[0] = ...) -> Tuple[_StrType, _StrType]: ... @overload - def blpop(self, keys: Union[_Value, Iterable[_Value]], timeout: float) -> Optional[Tuple[_StrType, _StrType]]: ... + def blpop(self, keys: _Value | Iterable[_Value], timeout: float) -> Tuple[_StrType, _StrType] | None: ... @overload - def brpop(self, keys: Union[_Value, Iterable[_Value]], timeout: Literal[0] = ...) -> Tuple[_StrType, _StrType]: ... + def brpop(self, keys: _Value | Iterable[_Value], timeout: Literal[0] = ...) -> Tuple[_StrType, _StrType]: ... @overload - def brpop(self, keys: Union[_Value, Iterable[_Value]], timeout: float) -> Optional[Tuple[_StrType, _StrType]]: ... + def brpop(self, keys: _Value | Iterable[_Value], timeout: float) -> Tuple[_StrType, _StrType] | None: ... def brpoplpush(self, src, dst, timeout=...): ... - def lindex(self, name: _Key, index: int) -> Optional[_StrType]: ... + def lindex(self, name: _Key, index: int) -> _StrType | None: ... def linsert( self, name: _Key, where: Literal["BEFORE", "AFTER", "before", "after"], refvalue: _Value, value: _Value ) -> int: ... @@ -538,10 +538,10 @@ class Redis(Generic[_StrType]): def sort( self, name: _Key, - start: Optional[int] = ..., - num: Optional[int] = ..., - by: Optional[_Key] = ..., - get: Optional[Union[_Key, Sequence[_Key]]] = ..., + start: int | None = ..., + num: int | None = ..., + by: _Key | None = ..., + get: _Key | Sequence[_Key] | None = ..., desc: bool = ..., alpha: bool = ..., store: None = ..., @@ -551,10 +551,10 @@ class Redis(Generic[_StrType]): def sort( self, name: _Key, - start: Optional[int] = ..., - num: Optional[int] = ..., - by: Optional[_Key] = ..., - get: Optional[Union[_Key, Sequence[_Key]]] = ..., + start: int | None = ..., + num: int | None = ..., + by: _Key | None = ..., + get: _Key | Sequence[_Key] | None = ..., desc: bool = ..., alpha: bool = ..., *, @@ -565,17 +565,17 @@ class Redis(Generic[_StrType]): def sort( self, name: _Key, - start: Optional[int], - num: Optional[int], - by: Optional[_Key], - get: Optional[Union[_Key, Sequence[_Key]]], + start: int | None, + num: int | None, + by: _Key | None, + get: _Key | Sequence[_Key] | None, desc: bool, alpha: bool, store: _Key, groups: bool = ..., ) -> int: ... - def scan(self, cursor: int = ..., match: Optional[_Key] = ..., count: Optional[int] = ...) -> Tuple[int, List[_StrType]]: ... - def scan_iter(self, match: Optional[Text] = ..., count: Optional[int] = ...) -> Iterator[_StrType]: ... + def scan(self, cursor: int = ..., match: _Key | None = ..., count: int | None = ...) -> Tuple[int, List[_StrType]]: ... + def scan_iter(self, match: Text | None = ..., count: int | None = ...) -> Iterator[_StrType]: ... def sscan(self, name: _Key, cursor: int = ..., match: Text = ..., count: int = ...) -> Tuple[int, List[_StrType]]: ... def sscan_iter(self, name, match=..., count=...): ... def hscan( @@ -586,24 +586,24 @@ class Redis(Generic[_StrType]): def zscan_iter(self, name, match=..., count=..., score_cast_func=...): ... def sadd(self, name: _Key, *values: _Value) -> int: ... def scard(self, name: _Key) -> int: ... - def sdiff(self, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Set[_Value]: ... - def sdiffstore(self, dest: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> int: ... - def sinter(self, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Set[_Value]: ... - def sinterstore(self, dest: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> int: ... + def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ... + def sdiffstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... + def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ... + def sinterstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... def sismember(self, name: _Key, value: _Value) -> bool: ... def smembers(self, name: _Key) -> Set[_StrType]: ... def smove(self, src: _Key, dst: _Key, value: _Value) -> bool: ... @overload - def spop(self, name: _Key, count: None = ...) -> Optional[_Value]: ... + def spop(self, name: _Key, count: None = ...) -> _Value | None: ... @overload def spop(self, name: _Key, count: int) -> List[_Value]: ... @overload - def srandmember(self, name: _Key, number: None = ...) -> Optional[_Value]: ... + def srandmember(self, name: _Key, number: None = ...) -> _Value | None: ... @overload def srandmember(self, name: _Key, number: int) -> List[_Value]: ... def srem(self, name: _Key, *values: _Value) -> int: ... - def sunion(self, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Set[_Value]: ... - def sunionstore(self, dest: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> int: ... + def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> Set[_Value]: ... + def sunionstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... def xack(self, name, groupname, *ids): ... def xadd(self, name, fields, id=..., maxlen=..., approximate=...): ... def xclaim( @@ -633,16 +633,16 @@ class Redis(Generic[_StrType]): def zincrby(self, name: _Key, amount: float, value: _Value) -> float: ... def zinterstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] = ...) -> int: ... def zlexcount(self, name: _Key, min: _Value, max: _Value) -> int: ... - def zpopmax(self, name: _Key, count: Optional[int] = ...) -> List[_StrType]: ... - def zpopmin(self, name: _Key, count: Optional[int] = ...) -> List[_StrType]: ... + def zpopmax(self, name: _Key, count: int | None = ...) -> List[_StrType]: ... + def zpopmin(self, name: _Key, count: int | None = ...) -> List[_StrType]: ... @overload - def bzpopmax(self, keys: Union[_Key, Iterable[_Key]], timeout: Literal[0] = ...) -> Tuple[_StrType, _StrType, float]: ... + def bzpopmax(self, keys: _Key | Iterable[_Key], timeout: Literal[0] = ...) -> Tuple[_StrType, _StrType, float]: ... @overload - def bzpopmax(self, keys: Union[_Key, Iterable[_Key]], timeout: float) -> Optional[Tuple[_StrType, _StrType, float]]: ... + def bzpopmax(self, keys: _Key | Iterable[_Key], timeout: float) -> Tuple[_StrType, _StrType, float] | None: ... @overload - def bzpopmin(self, keys: Union[_Key, Iterable[_Key]], timeout: Literal[0] = ...) -> Tuple[_StrType, _StrType, float]: ... + def bzpopmin(self, keys: _Key | Iterable[_Key], timeout: Literal[0] = ...) -> Tuple[_StrType, _StrType, float]: ... @overload - def bzpopmin(self, keys: Union[_Key, Iterable[_Key]], timeout: float) -> Optional[Tuple[_StrType, _StrType, float]]: ... + def bzpopmin(self, keys: _Key | Iterable[_Key], timeout: float) -> Tuple[_StrType, _StrType, float] | None: ... @overload def zrange( self, @@ -665,7 +665,7 @@ class Redis(Generic[_StrType]): score_cast_func: Callable[[Any], Any] = ..., ) -> List[_StrType]: ... def zrangebylex( - self, name: _Key, min: _Value, max: _Value, start: Optional[int] = ..., num: Optional[int] = ... + self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ... ) -> List[_StrType]: ... @overload def zrangebyscore( @@ -673,8 +673,8 @@ class Redis(Generic[_StrType]): name: _Key, min: _Value, max: _Value, - start: Optional[int] = ..., - num: Optional[int] = ..., + start: int | None = ..., + num: int | None = ..., *, withscores: Literal[True], score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., @@ -685,12 +685,12 @@ class Redis(Generic[_StrType]): name: _Key, min: _Value, max: _Value, - start: Optional[int] = ..., - num: Optional[int] = ..., + start: int | None = ..., + num: int | None = ..., withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ..., ) -> List[_StrType]: ... - def zrank(self, name: _Key, value: _Value) -> Optional[int]: ... + def zrank(self, name: _Key, value: _Value) -> int | None: ... def zrem(self, name: _Key, *values: _Value) -> int: ... def zremrangebylex(self, name: _Key, min: _Value, max: _Value) -> int: ... def zremrangebyrank(self, name: _Key, min: int, max: int) -> int: ... @@ -722,8 +722,8 @@ class Redis(Generic[_StrType]): name: _Key, min: _Value, max: _Value, - start: Optional[int] = ..., - num: Optional[int] = ..., + start: int | None = ..., + num: int | None = ..., *, withscores: Literal[True], score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., @@ -734,37 +734,37 @@ class Redis(Generic[_StrType]): name: _Key, min: _Value, max: _Value, - start: Optional[int] = ..., - num: Optional[int] = ..., + start: int | None = ..., + num: int | None = ..., withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ..., ) -> List[_StrType]: ... def zrevrangebylex( - self, name: _Key, min: _Value, max: _Value, start: Optional[int] = ..., num: Optional[int] = ... + self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ... ) -> List[_StrType]: ... - def zrevrank(self, name: _Key, value: _Value) -> Optional[int]: ... - def zscore(self, name: _Key, value: _Value) -> Optional[float]: ... + def zrevrank(self, name: _Key, value: _Value) -> int | None: ... + def zscore(self, name: _Key, value: _Value) -> float | None: ... def zunionstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] = ...) -> int: ... def pfadd(self, name: _Key, *values: _Value) -> int: ... def pfcount(self, name: _Key) -> int: ... def pfmerge(self, dest: _Key, *sources: _Key) -> bool: ... def hdel(self, name: _Key, *keys: _Key) -> int: ... def hexists(self, name: _Key, key: _Key) -> bool: ... - def hget(self, name: _Key, key: _Key) -> Optional[_StrType]: ... + def hget(self, name: _Key, key: _Key) -> _StrType | None: ... def hgetall(self, name: _Key) -> Dict[_StrType, _StrType]: ... def hincrby(self, name: _Key, key: _Key, amount: int = ...) -> int: ... def hincrbyfloat(self, name: _Key, key: _Key, amount: float = ...) -> float: ... def hkeys(self, name: _Key) -> List[_StrType]: ... def hlen(self, name: _Key) -> int: ... @overload - def hset(self, name: _Key, key: _Key, value: _Value, mapping: Optional[Mapping[_Key, _Value]] = ...) -> int: ... + def hset(self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ...) -> int: ... @overload def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> int: ... @overload def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> int: ... def hsetnx(self, name: _Key, key: _Key, value: _Value) -> int: ... def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> bool: ... - def hmget(self, name: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> List[Optional[_StrType]]: ... + def hmget(self, name: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> List[_StrType | None]: ... def hvals(self, name: _Key) -> List[_StrType]: ... def publish(self, channel: _Key, message: _Key) -> int: ... def eval(self, script, numkeys, *keys_and_args): ... @@ -773,7 +773,7 @@ class Redis(Generic[_StrType]): def script_flush(self): ... def script_kill(self): ... def script_load(self, script): ... - def register_script(self, script: Union[Text, _StrType]) -> Script: ... + def register_script(self, script: Text | _StrType) -> Script: ... def pubsub_channels(self, pattern: _Key = ...) -> List[Text]: ... def pubsub_numsub(self, *args: _Key) -> List[Tuple[Text, int]]: ... def pubsub_numpat(self) -> int: ... @@ -814,10 +814,10 @@ class PubSub: def subscribe(self, *args: _Key, **kwargs: Callable[[Any], None]) -> None: ... def unsubscribe(self, *args: _Key) -> None: ... def listen(self): ... - def get_message(self, ignore_subscribe_messages: bool = ..., timeout: float = ...) -> Optional[Dict[str, Any]]: ... - def handle_message(self, response, ignore_subscribe_messages: bool = ...) -> Optional[Dict[str, Any]]: ... + def get_message(self, ignore_subscribe_messages: bool = ..., timeout: float = ...) -> Dict[str, Any] | None: ... + def handle_message(self, response, ignore_subscribe_messages: bool = ...) -> Dict[str, Any] | None: ... def run_in_thread(self, sleep_time=...): ... - def ping(self, message: Optional[_Value] = ...) -> None: ... + def ping(self, message: _Value | None = ...) -> None: ... class Pipeline(Redis[_StrType], Generic[_StrType]): UNWATCH_COMMANDS: Any @@ -854,7 +854,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def pipeline(self, transaction: bool = ..., shard_hint: Any = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def lock(self, name, timeout=..., sleep=..., blocking_timeout=..., lock_class=..., thread_local=...): ... def pubsub(self, shard_hint: Any = ..., ignore_subscribe_messages: bool = ...) -> PubSub: ... - def acl_cat(self, category: Optional[Text] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def acl_cat(self, category: Text | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def acl_deluser(self, username: Text) -> Pipeline[_StrType]: ... # type: ignore [override] def acl_genpass(self) -> Pipeline[_StrType]: ... # type: ignore [override] def acl_getuser(self, username: Text) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -865,11 +865,11 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): username: Text = ..., enabled: bool = ..., nopass: bool = ..., - passwords: Optional[Sequence[Text]] = ..., - hashed_passwords: Optional[Sequence[Text]] = ..., - categories: Optional[Sequence[Text]] = ..., - commands: Optional[Sequence[Text]] = ..., - keys: Optional[Sequence[Text]] = ..., + passwords: Sequence[Text] | None = ..., + hashed_passwords: Sequence[Text] | None = ..., + categories: Sequence[Text] | None = ..., + commands: Sequence[Text] | None = ..., + keys: Sequence[Text] | None = ..., reset: bool = ..., reset_keys: bool = ..., reset_passwords: bool = ..., @@ -894,7 +894,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def echo(self, value) -> Pipeline[_StrType]: ... # type: ignore [override] def flushall(self) -> Pipeline[_StrType]: ... # type: ignore [override] def flushdb(self) -> Pipeline[_StrType]: ... # type: ignore [override] - def info(self, section: Optional[_Key] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def info(self, section: _Key | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def lastsave(self) -> Pipeline[_StrType]: ... # type: ignore [override] def object(self, infotype, key) -> Pipeline[_StrType]: ... # type: ignore [override] def ping(self) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -915,7 +915,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def slowlog_reset(self) -> Pipeline[_StrType]: ... # type: ignore [override] def time(self) -> Pipeline[_StrType]: ... # type: ignore [override] def append(self, key, value) -> Pipeline[_StrType]: ... # type: ignore [override] - def bitcount(self, key: _Key, start: Optional[int] = ..., end: Optional[int] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def bitcount(self, key: _Key, start: int | None = ..., end: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def bitop(self, operation, dest, *keys) -> Pipeline[_StrType]: ... # type: ignore [override] def bitpos(self, key, bit, start=..., end=...) -> Pipeline[_StrType]: ... # type: ignore [override] def decr(self, name, amount=...) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -924,7 +924,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def dump(self, name) -> Pipeline[_StrType]: ... # type: ignore [override] def exists(self, *names: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def __contains__(self, *names: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] - def expire(self, name: _Key, time: Union[int, timedelta]) -> Pipeline[_StrType]: ... # type: ignore [override] + def expire(self, name: _Key, time: int | timedelta) -> Pipeline[_StrType]: ... # type: ignore [override] def expireat(self, name, when) -> Pipeline[_StrType]: ... # type: ignore [override] def get(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def __getitem__(self, name) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -935,13 +935,13 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def incrby(self, name, amount=...) -> Pipeline[_StrType]: ... # type: ignore [override] def incrbyfloat(self, name, amount=...) -> Pipeline[_StrType]: ... # type: ignore [override] def keys(self, pattern: _Key = ...) -> Pipeline[_StrType]: ... # type: ignore [override] - def mget(self, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] + def mget(self, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def mset(self, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... # type: ignore [override] def msetnx(self, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... # type: ignore [override] def move(self, name: _Key, db: int) -> Pipeline[_StrType]: ... # type: ignore [override] def persist(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] - def pexpire(self, name: _Key, time: Union[int, timedelta]) -> Pipeline[_StrType]: ... # type: ignore [override] - def pexpireat(self, name: _Key, when: Union[int, datetime]) -> Pipeline[_StrType]: ... # type: ignore [override] + def pexpire(self, name: _Key, time: int | timedelta) -> Pipeline[_StrType]: ... # type: ignore [override] + def pexpireat(self, name: _Key, when: int | datetime) -> Pipeline[_StrType]: ... # type: ignore [override] def psetex(self, name, time_ms, value) -> Pipeline[_StrType]: ... # type: ignore [override] def pttl(self, name) -> Pipeline[_StrType]: ... # type: ignore [override] def randomkey(self) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -952,15 +952,15 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): self, name: _Key, value: _Value, - ex: Union[None, int, timedelta] = ..., - px: Union[None, int, timedelta] = ..., + ex: None | int | timedelta = ..., + px: None | int | timedelta = ..., nx: bool = ..., xx: bool = ..., keepttl: bool = ..., ) -> Pipeline[_StrType]: ... def __setitem__(self, name, value) -> None: ... def setbit(self, name: _Key, offset: int, value: int) -> Pipeline[_StrType]: ... # type: ignore [override] - def setex(self, name: _Key, time: Union[int, timedelta], value: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] + def setex(self, name: _Key, time: int | timedelta, value: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] def setnx(self, name, value) -> Pipeline[_StrType]: ... # type: ignore [override] def setrange(self, name, offset, value) -> Pipeline[_StrType]: ... # type: ignore [override] def strlen(self, name) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -968,8 +968,8 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def ttl(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def type(self, name) -> Pipeline[_StrType]: ... # type: ignore [override] def unlink(self, *names: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] - def blpop(self, keys: Union[_Value, Iterable[_Value]], timeout: float = ...) -> Pipeline[_StrType]: ... # type: ignore [override] - def brpop(self, keys: Union[_Value, Iterable[_Value]], timeout: float = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def blpop(self, keys: _Value | Iterable[_Value], timeout: float = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def brpop(self, keys: _Value | Iterable[_Value], timeout: float = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def brpoplpush(self, src, dst, timeout=...) -> Pipeline[_StrType]: ... # type: ignore [override] def lindex(self, name: _Key, index: int) -> Pipeline[_StrType]: ... # type: ignore [override] def linsert( # type: ignore [override] @@ -990,17 +990,17 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def sort( # type: ignore [override] self, name: _Key, - start: Optional[int] = ..., - num: Optional[int] = ..., - by: Optional[_Key] = ..., - get: Optional[Union[_Key, Sequence[_Key]]] = ..., + start: int | None = ..., + num: int | None = ..., + by: _Key | None = ..., + get: _Key | Sequence[_Key] | None = ..., desc: bool = ..., alpha: bool = ..., - store: Optional[_Key] = ..., + store: _Key | None = ..., groups: bool = ..., ) -> Pipeline[_StrType]: ... - def scan(self, cursor: int = ..., match: Optional[_Key] = ..., count: Optional[int] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] - def scan_iter(self, match: Optional[Text] = ..., count: Optional[int] = ...) -> Iterator[Any]: ... + def scan(self, cursor: int = ..., match: _Key | None = ..., count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def scan_iter(self, match: Text | None = ..., count: int | None = ...) -> Iterator[Any]: ... def sscan(self, name: _Key, cursor: int = ..., match: Text = ..., count: int = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def sscan_iter(self, name, match=..., count=...) -> Iterator[Any]: ... def hscan(self, name: _Key, cursor: int = ..., match: Text = ..., count: int = ...) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -1009,18 +1009,18 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def zscan_iter(self, name, match=..., count=..., score_cast_func=...) -> Iterator[Any]: ... def sadd(self, name: _Key, *values: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] def scard(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] - def sdiff(self, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] - def sdiffstore(self, dest: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] - def sinter(self, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] - def sinterstore(self, dest: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] + def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] + def sdiffstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] + def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] + def sinterstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def sismember(self, name: _Key, value: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] def smembers(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def smove(self, src: _Key, dst: _Key, value: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] - def spop(self, name: _Key, count: Optional[int] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] - def srandmember(self, name: _Key, number: Optional[int] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def spop(self, name: _Key, count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def srandmember(self, name: _Key, number: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def srem(self, name: _Key, *values: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] - def sunion(self, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] - def sunionstore(self, dest: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] + def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] + def sunionstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def xack(self, name, groupname, *ids) -> Pipeline[_StrType]: ... # type: ignore [override] def xadd(self, name, fields, id=..., maxlen=..., approximate=...) -> Pipeline[_StrType]: ... # type: ignore [override] def xclaim( @@ -1050,10 +1050,10 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def zincrby(self, name: _Key, amount: float, value: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] def zinterstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def zlexcount(self, name: _Key, min: _Value, max: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] - def zpopmax(self, name: _Key, count: Optional[int] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] - def zpopmin(self, name: _Key, count: Optional[int] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] - def bzpopmax(self, keys: Union[_Key, Iterable[_Key]], timeout: float = ...) -> Pipeline[_StrType]: ... # type: ignore [override] - def bzpopmin(self, keys: Union[_Key, Iterable[_Key]], timeout: float = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def zpopmax(self, name: _Key, count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def zpopmin(self, name: _Key, count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def bzpopmax(self, keys: _Key | Iterable[_Key], timeout: float = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def bzpopmin(self, keys: _Key | Iterable[_Key], timeout: float = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def zrange( # type: ignore [override] self, name: _Key, @@ -1063,14 +1063,14 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ..., ) -> Pipeline[_StrType]: ... - def zrangebylex(self, name: _Key, min: _Value, max: _Value, start: Optional[int] = ..., num: Optional[int] = ...) -> Pipeline[_StrType]: ... # type: ignore [override] + def zrangebylex(self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def zrangebyscore( # type: ignore [override] self, name: _Key, min: _Value, max: _Value, - start: Optional[int] = ..., - num: Optional[int] = ..., + start: int | None = ..., + num: int | None = ..., withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ..., ) -> Pipeline[_StrType]: ... @@ -1093,13 +1093,13 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): name: _Key, min: _Value, max: _Value, - start: Optional[int] = ..., - num: Optional[int] = ..., + start: int | None = ..., + num: int | None = ..., withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ..., ) -> Pipeline[_StrType]: ... def zrevrangebylex( # type: ignore [override] - self, name: _Key, min: _Value, max: _Value, start: Optional[int] = ..., num: Optional[int] = ... + self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ... ) -> Pipeline[_StrType]: ... def zrevrank(self, name: _Key, value: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] def zscore(self, name: _Key, value: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -1117,7 +1117,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def hlen(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] @overload # type: ignore [override] def hset( - self, name: _Key, key: _Key, value: _Value, mapping: Optional[Mapping[_Key, _Value]] = ... + self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ... ) -> Pipeline[_StrType]: ... @overload # type: ignore [override] def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... @@ -1125,7 +1125,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... def hsetnx(self, name: _Key, key: _Key, value: _Value) -> Pipeline[_StrType]: ... # type: ignore [override] def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... # type: ignore [override] - def hmget(self, name: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] + def hmget(self, name: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def hvals(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def publish(self, channel: _Key, message: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def eval(self, script, numkeys, *keys_and_args) -> Pipeline[_StrType]: ... # type: ignore [override] @@ -1134,7 +1134,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def script_flush(self) -> Pipeline[_StrType]: ... # type: ignore [override] def script_kill(self) -> Pipeline[_StrType]: ... # type: ignore [override] def script_load(self, script) -> Pipeline[_StrType]: ... # type: ignore [override] - def register_script(self, script: Union[Text, _StrType]) -> Script: ... + def register_script(self, script: Text | _StrType) -> Script: ... def pubsub_channels(self, pattern: _Key = ...) -> Pipeline[_StrType]: ... # type: ignore [override] def pubsub_numsub(self, *args: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def pubsub_numpat(self) -> Pipeline[_StrType]: ... # type: ignore [override] diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index db30d2895e4d..22025a599a41 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -53,8 +53,8 @@ DefaultParser: Any class Encoder: def __init__(self, encoding, encoding_errors, decode_responses: bool) -> None: ... - def encode(self, value: Union[Text, bytes, memoryview, bool, float]) -> bytes: ... - def decode(self, value: Union[Text, bytes, memoryview], force: bool = ...) -> Text: ... + def encode(self, value: Text | bytes | memoryview | bool | float) -> bytes: ... + def decode(self, value: Text | bytes | memoryview, force: bool = ...) -> Text: ... class Connection: description_format: Any @@ -76,11 +76,11 @@ class Connection: host: Text = ..., port: int = ..., db: int = ..., - password: Optional[Text] = ..., - socket_timeout: Optional[float] = ..., - socket_connect_timeout: Optional[float] = ..., + password: Text | None = ..., + socket_timeout: float | None = ..., + socket_connect_timeout: float | None = ..., socket_keepalive: bool = ..., - socket_keepalive_options: Optional[Mapping[str, Union[int, str]]] = ..., + socket_keepalive_options: Mapping[str, int | str] | None = ..., socket_type: int = ..., retry_on_timeout: bool = ..., encoding: Text = ..., @@ -89,8 +89,8 @@ class Connection: parser_class: Type[BaseParser] = ..., socket_read_size: int = ..., health_check_interval: int = ..., - client_name: Optional[Text] = ..., - username: Optional[Text] = ..., + client_name: Text | None = ..., + username: Text | None = ..., ) -> None: ... def __del__(self): ... def register_connect_callback(self, callback): ... @@ -150,7 +150,7 @@ def to_bool(value: object) -> bool: ... class ConnectionPool: @classmethod - def from_url(cls, url: Text, db: Optional[int] = ..., decode_components: bool = ..., **kwargs) -> ConnectionPool: ... + def from_url(cls, url: Text, db: int | None = ..., decode_components: bool = ..., **kwargs) -> ConnectionPool: ... connection_class: Any connection_kwargs: Any max_connections: Any diff --git a/stubs/redis/redis/lock.pyi b/stubs/redis/redis/lock.pyi index 281144d68275..37b8e9073065 100644 --- a/stubs/redis/redis/lock.pyi +++ b/stubs/redis/redis/lock.pyi @@ -10,26 +10,26 @@ class Lock: self, redis: Redis[Any], name: str, - timeout: Union[None, int, float] = ..., + timeout: None | int | float = ..., sleep: float = ..., blocking: bool = ..., - blocking_timeout: Optional[bool] = ..., + blocking_timeout: bool | None = ..., thread_local: bool = ..., ) -> None: ... def register_scripts(self) -> None: ... def __enter__(self) -> Lock: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... def acquire( - self, blocking: Optional[bool] = ..., blocking_timeout: Union[None, int, float] = ..., token: Optional[_TokenValue] = ... + self, blocking: bool | None = ..., blocking_timeout: None | int | float = ..., token: _TokenValue | None = ... ) -> bool: ... def do_acquire(self, token: _TokenValue) -> bool: ... def locked(self) -> bool: ... def owned(self) -> bool: ... def release(self) -> None: ... def do_release(self, expected_token: _TokenValue) -> None: ... - def extend(self, additional_time: Union[int, float], replace_ttl: bool = ...) -> bool: ... - def do_extend(self, additional_time: Union[int, float], replace_ttl: bool) -> bool: ... + def extend(self, additional_time: int | float, replace_ttl: bool = ...) -> bool: ... + def do_extend(self, additional_time: int | float, replace_ttl: bool) -> bool: ... def reacquire(self) -> bool: ... def do_reacquire(self) -> bool: ... diff --git a/stubs/redis/redis/utils.pyi b/stubs/redis/redis/utils.pyi index 33814eb40d3a..ba3f06e766c4 100644 --- a/stubs/redis/redis/utils.pyi +++ b/stubs/redis/redis/utils.pyi @@ -8,9 +8,9 @@ _T = TypeVar("_T") HIREDIS_AVAILABLE: bool @overload -def from_url(url: Text, db: Optional[int] = ..., *, decode_responses: Literal[True], **kwargs: Any) -> Redis[str]: ... +def from_url(url: Text, db: int | None = ..., *, decode_responses: Literal[True], **kwargs: Any) -> Redis[str]: ... @overload -def from_url(url: Text, db: Optional[int] = ..., *, decode_responses: Literal[False] = ..., **kwargs: Any) -> Redis[bytes]: ... +def from_url(url: Text, db: int | None = ..., *, decode_responses: Literal[False] = ..., **kwargs: Any) -> Redis[bytes]: ... @overload def str_if_bytes(value: bytes) -> str: ... # type: ignore @overload diff --git a/stubs/requests/requests/adapters.pyi b/stubs/requests/requests/adapters.pyi index 1cb59c60e139..484efde75c30 100644 --- a/stubs/requests/requests/adapters.pyi +++ b/stubs/requests/requests/adapters.pyi @@ -32,7 +32,7 @@ RetryError = exceptions.RetryError DEFAULT_POOLBLOCK: bool DEFAULT_POOLSIZE: int DEFAULT_RETRIES: int -DEFAULT_POOL_TIMEOUT: Optional[float] +DEFAULT_POOL_TIMEOUT: float | None class BaseAdapter: def __init__(self) -> None: ... @@ -40,10 +40,10 @@ class BaseAdapter: self, request: PreparedRequest, stream: bool = ..., - timeout: Union[None, float, Tuple[float, float], Tuple[float, None]] = ..., - verify: Union[bool, str] = ..., - cert: Union[None, Union[bytes, Text], Container[Union[bytes, Text]]] = ..., - proxies: Optional[Mapping[str, str]] = ..., + timeout: None | float | Tuple[float, float] | Tuple[float, None] = ..., + verify: bool | str = ..., + cert: None | bytes | Text | Container[bytes | Text] = ..., + proxies: Mapping[str, str] | None = ..., ) -> Response: ... def close(self) -> None: ... @@ -56,7 +56,7 @@ class HTTPAdapter(BaseAdapter): self, pool_connections: int = ..., pool_maxsize: int = ..., - max_retries: Union[Retry, int, None] = ..., + max_retries: Retry | int | None = ..., pool_block: bool = ..., ) -> None: ... poolmanager: Any @@ -73,8 +73,8 @@ class HTTPAdapter(BaseAdapter): self, request: PreparedRequest, stream: bool = ..., - timeout: Union[None, float, Tuple[float, float], Tuple[float, None]] = ..., - verify: Union[bool, str] = ..., - cert: Union[None, Union[bytes, Text], Container[Union[bytes, Text]]] = ..., - proxies: Optional[Mapping[str, str]] = ..., + timeout: None | float | Tuple[float, float] | Tuple[float, None] = ..., + verify: bool | str = ..., + cert: None | bytes | Text | Container[bytes | Text] = ..., + proxies: Mapping[str, str] | None = ..., ) -> Response: ... diff --git a/stubs/requests/requests/api.pyi b/stubs/requests/requests/api.pyi index 26c120fe52d5..eb31e32a90d8 100644 --- a/stubs/requests/requests/api.pyi +++ b/stubs/requests/requests/api.pyi @@ -4,139 +4,139 @@ from .models import Response from .sessions import _Data, _Params def request( - method: Union[Text, bytes], - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + method: Text | bytes, + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def get( - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def options( - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def head( - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def post( - url: Union[Text, bytes], + url: Text | bytes, data: _Data = ..., - json: Optional[Any] = ..., - params: Optional[_Params] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + json: Any | None = ..., + params: _Params | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., ) -> Response: ... def put( - url: Union[Text, bytes], + url: Text | bytes, data: _Data = ..., - params: Optional[_Params] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + params: _Params | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def patch( - url: Union[Text, bytes], + url: Text | bytes, data: _Data = ..., - params: Optional[_Params] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + params: _Params | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def delete( - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... diff --git a/stubs/requests/requests/auth.pyi b/stubs/requests/requests/auth.pyi index 6362a6d68263..f9d2214801b2 100644 --- a/stubs/requests/requests/auth.pyi +++ b/stubs/requests/requests/auth.pyi @@ -9,7 +9,7 @@ to_native_string = utils.to_native_string CONTENT_TYPE_FORM_URLENCODED: Any CONTENT_TYPE_MULTI_PART: Any -def _basic_auth_str(username: Union[bytes, Text], password: Union[bytes, Text]) -> str: ... +def _basic_auth_str(username: bytes | Text, password: bytes | Text) -> str: ... class AuthBase: def __call__(self, r: models.PreparedRequest) -> models.PreparedRequest: ... diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index ac2ceeed003c..95753a07ea55 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -67,10 +67,10 @@ class Request(RequestHooksMixin): def prepare(self) -> PreparedRequest: ... class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): - method: Optional[Union[str, Text]] - url: Optional[Union[str, Text]] + method: str | Text | None + url: str | Text | None headers: CaseInsensitiveDict[str] - body: Optional[Union[bytes, Text]] + body: bytes | Text | None hooks: Any def __init__(self) -> None: ... def prepare( @@ -88,7 +88,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): class Response: __attrs__: Any - _content: Optional[bytes] # undocumented + _content: bytes | None # undocumented status_code: int headers: CaseInsensitiveDict[str] raw: Any @@ -106,7 +106,7 @@ class Response: def __enter__(self) -> Response: ... def __exit__(self, *args: Any) -> None: ... @property - def next(self) -> Optional[PreparedRequest]: ... + def next(self) -> PreparedRequest | None: ... @property def ok(self) -> bool: ... @property @@ -115,9 +115,9 @@ class Response: def is_permanent_redirect(self) -> bool: ... @property def apparent_encoding(self) -> str: ... - def iter_content(self, chunk_size: Optional[int] = ..., decode_unicode: bool = ...) -> Iterator[Any]: ... + def iter_content(self, chunk_size: int | None = ..., decode_unicode: bool = ...) -> Iterator[Any]: ... def iter_lines( - self, chunk_size: Optional[int] = ..., decode_unicode: bool = ..., delimiter: Optional[Union[Text, bytes]] = ... + self, chunk_size: int | None = ..., decode_unicode: bool = ..., delimiter: Text | bytes | None = ... ) -> Iterator[Any]: ... @property def content(self) -> bytes: ... diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index e3d3c3a349be..e63409439299 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -55,20 +55,20 @@ _Params = Union[ SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType], Tuple[_ParamsMappingKeyType, _ParamsMappingValueType], Iterable[Tuple[_ParamsMappingKeyType, _ParamsMappingValueType]], - Union[Text, bytes], + Text | bytes, ] _SessionT = TypeVar("_SessionT", bound=Session) class Session(SessionRedirectMixin): __attrs__: Any headers: CaseInsensitiveDict[Text] - auth: Union[None, Tuple[Text, Text], _auth.AuthBase, Callable[[PreparedRequest], PreparedRequest]] + auth: None | Tuple[Text, Text] | _auth.AuthBase | Callable[[PreparedRequest], PreparedRequest] proxies: MutableMapping[Text, Text] hooks: _Hooks params: _Params stream: bool - verify: Union[None, bool, Text] - cert: Union[None, Text, Tuple[Text, Text]] + verify: None | bool | Text + cert: None | Text | Tuple[Text, Text] max_redirects: int trust_env: bool cookies: RequestsCookieJar @@ -81,152 +81,152 @@ class Session(SessionRedirectMixin): def request( self, method: str, - url: Union[str, bytes, Text], - params: Optional[_Params] = ..., + url: str | bytes | Text, + params: _Params | None = ..., data: _Data = ..., - headers: Optional[MutableMapping[Text, Text]] = ..., - cookies: Union[None, RequestsCookieJar, MutableMapping[Text, Text]] = ..., - files: Optional[MutableMapping[Text, IO[Any]]] = ..., - auth: Union[None, Tuple[Text, Text], _auth.AuthBase, Callable[[PreparedRequest], PreparedRequest]] = ..., - timeout: Union[None, float, Tuple[float, float], Tuple[float, None]] = ..., - allow_redirects: Optional[bool] = ..., - proxies: Optional[MutableMapping[Text, Text]] = ..., - hooks: Optional[_HooksInput] = ..., - stream: Optional[bool] = ..., - verify: Union[None, bool, Text] = ..., - cert: Union[Text, Tuple[Text, Text], None] = ..., - json: Optional[Any] = ..., + headers: MutableMapping[Text, Text] | None = ..., + cookies: None | RequestsCookieJar | MutableMapping[Text, Text] = ..., + files: MutableMapping[Text, IO[Any]] | None = ..., + auth: None | Tuple[Text, Text] | _auth.AuthBase | Callable[[PreparedRequest], PreparedRequest] = ..., + timeout: None | float | Tuple[float, float] | Tuple[float, None] = ..., + allow_redirects: bool | None = ..., + proxies: MutableMapping[Text, Text] | None = ..., + hooks: _HooksInput | None = ..., + stream: bool | None = ..., + verify: None | bool | Text = ..., + cert: Text | Tuple[Text, Text] | None = ..., + json: Any | None = ..., ) -> Response: ... def get( self, - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def options( self, - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def head( self, - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def post( self, - url: Union[Text, bytes], + url: Text | bytes, data: _Data = ..., - json: Optional[Any] = ..., - params: Optional[_Params] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + json: Any | None = ..., + params: _Params | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., ) -> Response: ... def put( self, - url: Union[Text, bytes], + url: Text | bytes, data: _Data = ..., - params: Optional[_Params] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + params: _Params | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def patch( self, - url: Union[Text, bytes], + url: Text | bytes, data: _Data = ..., - params: Optional[_Params] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + params: _Params | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def delete( self, - url: Union[Text, bytes], - params: Optional[_Params] = ..., - data: Optional[Any] = ..., - headers: Optional[Any] = ..., - cookies: Optional[Any] = ..., - files: Optional[Any] = ..., - auth: Optional[Any] = ..., - timeout: Optional[Any] = ..., + url: Text | bytes, + params: _Params | None = ..., + data: Any | None = ..., + headers: Any | None = ..., + cookies: Any | None = ..., + files: Any | None = ..., + auth: Any | None = ..., + timeout: Any | None = ..., allow_redirects: bool = ..., - proxies: Optional[Any] = ..., - hooks: Optional[Any] = ..., - stream: Optional[Any] = ..., - verify: Optional[Any] = ..., - cert: Optional[Any] = ..., - json: Optional[Any] = ..., + proxies: Any | None = ..., + hooks: Any | None = ..., + stream: Any | None = ..., + verify: Any | None = ..., + cert: Any | None = ..., + json: Any | None = ..., ) -> Response: ... def send(self, request: PreparedRequest, **kwargs) -> Response: ... def merge_environment_settings(self, url, proxies, stream, verify, cert): ... def get_adapter(self, url): ... def close(self) -> None: ... - def mount(self, prefix: Union[Text, bytes], adapter: BaseAdapter) -> None: ... + def mount(self, prefix: Text | bytes, adapter: BaseAdapter) -> None: ... def session() -> Session: ... diff --git a/stubs/requests/requests/structures.pyi b/stubs/requests/requests/structures.pyi index ffc459796cb4..e29b70cc8d37 100644 --- a/stubs/requests/requests/structures.pyi +++ b/stubs/requests/requests/structures.pyi @@ -3,7 +3,7 @@ from typing import Any, Dict, Generic, Iterable, Iterator, Mapping, MutableMappi _VT = TypeVar("_VT") class CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]): - def __init__(self, data: Optional[Union[Mapping[str, _VT], Iterable[Tuple[str, _VT]]]] = ..., **kwargs: _VT) -> None: ... + def __init__(self, data: Mapping[str, _VT] | Iterable[Tuple[str, _VT]] | None = ..., **kwargs: _VT) -> None: ... def lower_items(self) -> Iterator[Tuple[str, _VT]]: ... def __setitem__(self, key: str, value: _VT) -> None: ... def __getitem__(self, key: str) -> _VT: ... @@ -15,6 +15,6 @@ class CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]): class LookupDict(Dict[str, _VT]): name: Any def __init__(self, name: Any = ...) -> None: ... - def __getitem__(self, key: str) -> Optional[_VT]: ... # type: ignore + def __getitem__(self, key: str) -> _VT | None: ... # type: ignore def __getattr__(self, attr: str) -> _VT: ... def __setattr__(self, attr: str, value: _VT) -> None: ... diff --git a/stubs/requests/requests/utils.pyi b/stubs/requests/requests/utils.pyi index 3a84c6254547..ef3137230a48 100644 --- a/stubs/requests/requests/utils.pyi +++ b/stubs/requests/requests/utils.pyi @@ -39,9 +39,9 @@ def dotted_netmask(mask): ... def is_ipv4_address(string_ip): ... def is_valid_cidr(string_network): ... def set_environ(env_name, value): ... -def should_bypass_proxies(url, no_proxy: Optional[Iterable[AnyStr]]) -> bool: ... -def get_environ_proxies(url, no_proxy: Optional[Iterable[AnyStr]] = ...) -> Dict[Any, Any]: ... -def select_proxy(url: Text, proxies: Optional[Mapping[Any, Any]]): ... +def should_bypass_proxies(url, no_proxy: Iterable[AnyStr] | None) -> bool: ... +def get_environ_proxies(url, no_proxy: Iterable[AnyStr] | None = ...) -> Dict[Any, Any]: ... +def select_proxy(url: Text, proxies: Mapping[Any, Any] | None): ... def default_user_agent(name=...): ... def default_headers(): ... def parse_header_links(value): ... diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index cf52a9ef908d..b69307f00a10 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -6,22 +6,22 @@ _R = TypeVar("_R") def retry_call( f: Callable[..., _R], - fargs: Optional[Sequence[Any]] = ..., - fkwargs: Optional[Dict[str, Any]] = ..., - exceptions: Union[Type[Exception], Tuple[Type[Exception], ...]] = ..., + fargs: Sequence[Any] | None = ..., + fkwargs: Dict[str, Any] | None = ..., + exceptions: Type[Exception] | Tuple[Type[Exception], ...] = ..., tries: int = ..., delay: float = ..., - max_delay: Optional[float] = ..., + max_delay: float | None = ..., backoff: float = ..., - jitter: Union[Tuple[float, float], float] = ..., - logger: Optional[Logger] = ..., + jitter: Tuple[float, float] | float = ..., + logger: Logger | None = ..., ) -> _R: ... def retry( - exceptions: Union[Type[Exception], Tuple[Type[Exception], ...]] = ..., + exceptions: Type[Exception] | Tuple[Type[Exception], ...] = ..., tries: int = ..., delay: float = ..., - max_delay: Optional[float] = ..., + max_delay: float | None = ..., backoff: float = ..., - jitter: Union[Tuple[float, float], float] = ..., - logger: Optional[Logger] = ..., + jitter: Tuple[float, float] | float = ..., + logger: Logger | None = ..., ) -> IdentityFunction: ... diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index c1adcbb9d572..247caffa320c 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -21,21 +21,21 @@ def fixup_namespace_packages(path_item: str) -> None: ... class WorkingSet: entries: List[str] - def __init__(self, entries: Optional[Iterable[str]] = ...) -> None: ... + def __init__(self, entries: Iterable[str] | None = ...) -> None: ... def require(self, *requirements: _NestedStr) -> Sequence[Distribution]: ... def run_script(self, requires: str, script_name: str) -> None: ... - def iter_entry_points(self, group: str, name: Optional[str] = ...) -> Generator[EntryPoint, None, None]: ... + def iter_entry_points(self, group: str, name: str | None = ...) -> Generator[EntryPoint, None, None]: ... def add_entry(self, entry: str) -> None: ... def __contains__(self, dist: Distribution) -> bool: ... def __iter__(self) -> Generator[Distribution, None, None]: ... - def find(self, req: Requirement) -> Optional[Distribution]: ... + def find(self, req: Requirement) -> Distribution | None: ... def resolve( - self, requirements: Iterable[Requirement], env: Optional[Environment] = ..., installer: Optional[_InstallerType] = ... + self, requirements: Iterable[Requirement], env: Environment | None = ..., installer: _InstallerType | None = ... ) -> List[Distribution]: ... - def add(self, dist: Distribution, entry: Optional[str] = ..., insert: bool = ..., replace: bool = ...) -> None: ... + def add(self, dist: Distribution, entry: str | None = ..., insert: bool = ..., replace: bool = ...) -> None: ... def subscribe(self, callback: Callable[[Distribution], None]) -> None: ... def find_plugins( - self, plugin_env: Environment, full_env: Optional[Environment] = ..., fallback: bool = ... + self, plugin_env: Environment, full_env: Environment | None = ..., fallback: bool = ... ) -> Tuple[List[Distribution], Dict[Distribution, Exception]]: ... working_set: WorkingSet = ... @@ -47,15 +47,15 @@ add_activation_listener = working_set.subscribe class Environment: def __init__( - self, search_path: Optional[Sequence[str]] = ..., platform: Optional[str] = ..., python: Optional[str] = ... + self, search_path: Sequence[str] | None = ..., platform: str | None = ..., python: str | None = ... ) -> None: ... def __getitem__(self, project_name: str) -> List[Distribution]: ... def __iter__(self) -> Generator[str, None, None]: ... def add(self, dist: Distribution) -> None: ... def remove(self, dist: Distribution) -> None: ... def can_add(self, dist: Distribution) -> bool: ... - def __add__(self, other: Union[Distribution, Environment]) -> Environment: ... - def __iadd__(self, other: Union[Distribution, Environment]) -> Environment: ... + def __add__(self, other: Distribution | Environment) -> Environment: ... + def __iadd__(self, other: Distribution | Environment) -> Environment: ... @overload def best_match(self, req: Requirement, working_set: WorkingSet) -> Distribution: ... @overload @@ -64,9 +64,9 @@ class Environment: def obtain(self, requirement: Requirement) -> None: ... @overload def obtain(self, requirement: Requirement, installer: Callable[[Requirement], _T] = ...) -> _T: ... - def scan(self, search_path: Optional[Sequence[str]] = ...) -> None: ... + def scan(self, search_path: Sequence[str] | None = ...) -> None: ... -def parse_requirements(strs: Union[str, Iterable[str]]) -> Generator[Requirement, None, None]: ... +def parse_requirements(strs: str | Iterable[str]) -> Generator[Requirement, None, None]: ... class Requirement: unsafe_name: str @@ -74,16 +74,16 @@ class Requirement: key: str extras: Tuple[str, ...] specs: List[Tuple[str, str]] - # TODO: change this to Optional[packaging.markers.Marker] once we can import + # TODO: change this to packaging.markers.Marker | None once we can import # packaging.markers - marker: Optional[Any] + marker: Any | None @staticmethod - def parse(s: Union[str, Iterable[str]]) -> Requirement: ... - def __contains__(self, item: Union[Distribution, str, Tuple[str, ...]]) -> bool: ... + def parse(s: str | Iterable[str]) -> Requirement: ... + def __contains__(self, item: Distribution | str | Tuple[str, ...]) -> bool: ... def __eq__(self, other_requirement: Any) -> bool: ... def load_entry_point(dist: _EPDistType, group: str, name: str) -> Any: ... -def get_entry_info(dist: _EPDistType, group: str, name: str) -> Optional[EntryPoint]: ... +def get_entry_info(dist: _EPDistType, group: str, name: str) -> EntryPoint | None: ... @overload def get_entry_map(dist: _EPDistType) -> Dict[str, Dict[str, EntryPoint]]: ... @overload @@ -94,31 +94,31 @@ class EntryPoint: module_name: str attrs: Tuple[str, ...] extras: Tuple[str, ...] - dist: Optional[Distribution] + dist: Distribution | None def __init__( self, name: str, module_name: str, attrs: Tuple[str, ...] = ..., extras: Tuple[str, ...] = ..., - dist: Optional[Distribution] = ..., + dist: Distribution | None = ..., ) -> None: ... @classmethod - def parse(cls, src: str, dist: Optional[Distribution] = ...) -> EntryPoint: ... + def parse(cls, src: str, dist: Distribution | None = ...) -> EntryPoint: ... @classmethod def parse_group( - cls, group: str, lines: Union[str, Sequence[str]], dist: Optional[Distribution] = ... + cls, group: str, lines: str | Sequence[str], dist: Distribution | None = ... ) -> Dict[str, EntryPoint]: ... @classmethod def parse_map( - cls, data: Union[Dict[str, Union[str, Sequence[str]]], str, Sequence[str]], dist: Optional[Distribution] = ... + cls, data: Dict[str, str | Sequence[str]] | str | Sequence[str], dist: Distribution | None = ... ) -> Dict[str, EntryPoint]: ... - def load(self, require: bool = ..., env: Optional[Environment] = ..., installer: Optional[_InstallerType] = ...) -> Any: ... - def require(self, env: Optional[Environment] = ..., installer: Optional[_InstallerType] = ...) -> None: ... + def load(self, require: bool = ..., env: Environment | None = ..., installer: _InstallerType | None = ...) -> Any: ... + def require(self, env: Environment | None = ..., installer: _InstallerType | None = ...) -> None: ... def resolve(self) -> Any: ... def find_distributions(path_item: str, only: bool = ...) -> Generator[Distribution, None, None]: ... -def get_distribution(dist: Union[Requirement, str, Distribution]) -> Distribution: ... +def get_distribution(dist: Requirement | str | Distribution) -> Distribution: ... class Distribution(IResourceProvider, IMetadataProvider): PKG_INFO: str @@ -129,31 +129,31 @@ class Distribution(IResourceProvider, IMetadataProvider): version: str parsed_version: Tuple[str, ...] py_version: str - platform: Optional[str] + platform: str | None precedence: int def __init__( self, - location: Optional[str] = ..., + location: str | None = ..., metadata: _MetadataType = ..., - project_name: Optional[str] = ..., - version: Optional[str] = ..., + project_name: str | None = ..., + version: str | None = ..., py_version: str = ..., - platform: Optional[str] = ..., + platform: str | None = ..., precedence: int = ..., ) -> None: ... @classmethod def from_location( - cls, location: str, basename: str, metadata: _MetadataType = ..., **kw: Union[str, None, int] + cls, location: str, basename: str, metadata: _MetadataType = ..., **kw: str | None | int ) -> Distribution: ... @classmethod - def from_filename(cls, filename: str, metadata: _MetadataType = ..., **kw: Union[str, None, int]) -> Distribution: ... - def activate(self, path: Optional[List[str]] = ...) -> None: ... + def from_filename(cls, filename: str, metadata: _MetadataType = ..., **kw: str | None | int) -> Distribution: ... + def activate(self, path: List[str] | None = ...) -> None: ... def as_requirement(self) -> Requirement: ... def requires(self, extras: Tuple[str, ...] = ...) -> List[Requirement]: ... - def clone(self, **kw: Union[str, int, None]) -> Requirement: ... + def clone(self, **kw: str | int | None) -> Requirement: ... def egg_name(self) -> str: ... def __cmp__(self, other: Any) -> bool: ... - def get_entry_info(self, group: str, name: str) -> Optional[EntryPoint]: ... + def get_entry_info(self, group: str, name: str) -> EntryPoint | None: ... @overload def get_entry_map(self) -> Dict[str, Dict[str, EntryPoint]]: ... @overload @@ -218,11 +218,11 @@ class VersionConflict(ResolutionError): @property def req(self) -> Any: ... def report(self) -> str: ... - def with_context(self, required_by: Set[Union[Distribution, str]]) -> VersionConflict: ... + def with_context(self, required_by: Set[Distribution | str]) -> VersionConflict: ... class ContextualVersionConflict(VersionConflict): @property - def required_by(self) -> Set[Union[Distribution, str]]: ... + def required_by(self) -> Set[Distribution | str]: ... class UnknownExtra(ResolutionError): ... @@ -257,9 +257,9 @@ empty_provider: EmptyProvider class FileMetadata(EmptyProvider, IResourceProvider): def __init__(self, path_to_pkg_info: str) -> None: ... -def parse_version(v: str) -> Union[Version, LegacyVersion]: ... +def parse_version(v: str) -> Version | LegacyVersion: ... def yield_lines(strs: _NestedStr) -> Generator[str, None, None]: ... -def split_sections(strs: _NestedStr) -> Generator[Tuple[Optional[str], str], None, None]: ... +def split_sections(strs: _NestedStr) -> Generator[Tuple[str | None, str], None, None]: ... def safe_name(name: str) -> str: ... def safe_version(version: str) -> str: ... def safe_extra(extra: str) -> str: ... @@ -267,7 +267,7 @@ def to_filename(name_or_version: str) -> str: ... def get_build_platform() -> str: ... def get_platform() -> str: ... def get_supported_platform() -> str: ... -def compatible_platforms(provided: Optional[str], required: Optional[str]) -> bool: ... +def compatible_platforms(provided: str | None, required: str | None) -> bool: ... def get_default_cache() -> str: ... def get_importer(path_item: str) -> _Importer: ... def ensure_directory(path: str) -> None: ... diff --git a/stubs/simplejson/simplejson/scanner.pyi b/stubs/simplejson/simplejson/scanner.pyi index 5de484a072d1..4dae33b323d9 100644 --- a/stubs/simplejson/simplejson/scanner.pyi +++ b/stubs/simplejson/simplejson/scanner.pyi @@ -4,8 +4,8 @@ class JSONDecodeError(ValueError): msg: str = ... doc: str = ... pos: int = ... - end: Optional[int] = ... + end: int | None = ... lineno: int = ... colno: int = ... - endlineno: Optional[int] = ... - endcolno: Optional[int] = ... + endlineno: int | None = ... + endcolno: int | None = ... diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 80b21672db27..357951966a1b 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -56,10 +56,10 @@ def create_unbound_method(func: types.FunctionType, cls: type) -> types.Function Iterator = object def get_method_function(meth: types.MethodType) -> types.FunctionType: ... -def get_method_self(meth: types.MethodType) -> Optional[object]: ... -def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ... +def get_method_self(meth: types.MethodType) -> object | None: ... +def get_function_closure(fun: types.FunctionType) -> Tuple[types._Cell, ...] | None: ... def get_function_code(fun: types.FunctionType) -> types.CodeType: ... -def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ... +def get_function_defaults(fun: types.FunctionType) -> Tuple[Any, ...] | None: ... def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ... def iterkeys(d: Mapping[_K, Any]) -> typing.Iterator[_K]: ... def itervalues(d: Mapping[Any, _V]) -> typing.Iterator[_V]: ... @@ -79,47 +79,47 @@ def int2byte(i: int) -> bytes: ... def byte2int(bs: binary_type) -> int: ... def indexbytes(buf: binary_type, i: int) -> int: ... def iterbytes(buf: binary_type) -> typing.Iterator[int]: ... -def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: Optional[str] = ...) -> None: ... +def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: str | None = ...) -> None: ... @overload -def assertRaisesRegex(self: unittest.TestCase, msg: Optional[str] = ...) -> Any: ... +def assertRaisesRegex(self: unittest.TestCase, msg: str | None = ...) -> Any: ... @overload def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... def assertRegex( - self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: Optional[str] = ... + self: unittest.TestCase, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: str | None = ... ) -> None: ... exec_ = exec def reraise( - tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ... + tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ... ) -> NoReturn: ... -def raise_from(value: Union[BaseException, Type[BaseException]], from_value: Optional[BaseException]) -> NoReturn: ... +def raise_from(value: BaseException | Type[BaseException], from_value: BaseException | None) -> NoReturn: ... print_ = print def with_metaclass(meta: type, *bases: type) -> type: ... def add_metaclass(metaclass: type) -> Callable[[_T], _T]: ... -def ensure_binary(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> bytes: ... -def ensure_str(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> str: ... -def ensure_text(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> str: ... +def ensure_binary(s: bytes | str, encoding: str = ..., errors: str = ...) -> bytes: ... +def ensure_str(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ... +def ensure_text(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ... def python_2_unicode_compatible(klass: _T) -> _T: ... class _LazyDescriptor: name: str def __init__(self, name: str) -> None: ... - def __get__(self, obj: Optional[object], type: Optional[type] = ...) -> Any: ... + def __get__(self, obj: object | None, type: type | None = ...) -> Any: ... class MovedModule(_LazyDescriptor): mod: str - def __init__(self, name: str, old: str, new: Optional[str] = ...) -> None: ... + def __init__(self, name: str, old: str, new: str | None = ...) -> None: ... def __getattr__(self, attr: str) -> Any: ... class MovedAttribute(_LazyDescriptor): mod: str attr: str def __init__( - self, name: str, old_mod: str, new_mod: str, old_attr: Optional[str] = ..., new_attr: Optional[str] = ... + self, name: str, old_mod: str, new_mod: str, old_attr: str | None = ..., new_attr: str | None = ... ) -> None: ... -def add_move(move: Union[MovedModule, MovedAttribute]) -> None: ... +def add_move(move: MovedModule | MovedAttribute) -> None: ... def remove_move(name: str) -> None: ... diff --git a/stubs/tabulate/tabulate.pyi b/stubs/tabulate/tabulate.pyi index acfe1ae610a3..d5f48f48d03b 100644 --- a/stubs/tabulate/tabulate.pyi +++ b/stubs/tabulate/tabulate.pyi @@ -29,18 +29,18 @@ class TableFormat(NamedTuple): headerrow: _TableFormatRow datarow: _TableFormatRow padding: int - with_header_hide: Optional[Container[str]] + with_header_hide: Container[str] | None def simple_separated_format(separator: str) -> TableFormat: ... def tabulate( - tabular_data: Union[Mapping[str, Iterable[Any]], Iterable[Iterable[Any]]], - headers: Union[str, Dict[str, str], Sequence[str]] = ..., - tablefmt: Union[str, TableFormat] = ..., - floatfmt: Union[str, Iterable[str]] = ..., - numalign: Optional[str] = ..., - stralign: Optional[str] = ..., - missingval: Union[str, Iterable[str]] = ..., - showindex: Union[str, bool, Iterable[Any]] = ..., - disable_numparse: Union[bool, Iterable[int]] = ..., - colalign: Optional[Iterable[Optional[str]]] = ..., + tabular_data: Mapping[str, Iterable[Any]] | Iterable[Iterable[Any]], + headers: str | Dict[str, str] | Sequence[str] = ..., + tablefmt: str | TableFormat = ..., + floatfmt: str | Iterable[str] = ..., + numalign: str | None = ..., + stralign: str | None = ..., + missingval: str | Iterable[str] = ..., + showindex: str | bool | Iterable[Any] = ..., + disable_numparse: bool | Iterable[int] = ..., + colalign: Iterable[str | None] | None = ..., ) -> str: ... diff --git a/stubs/termcolor/termcolor.pyi b/stubs/termcolor/termcolor.pyi index 8baaeffa9507..a5a358c5686c 100644 --- a/stubs/termcolor/termcolor.pyi +++ b/stubs/termcolor/termcolor.pyi @@ -6,8 +6,8 @@ HIGHLIGHTS: dict[str, int] RESET: str def colored( - text: Text, color: Optional[Text] = ..., on_color: Optional[Text] = ..., attrs: Optional[Iterable[Text]] = ... + text: Text, color: Text | None = ..., on_color: Text | None = ..., attrs: Iterable[Text] | None = ... ) -> Text: ... def cprint( - text: Text, color: Optional[Text] = ..., on_color: Optional[Text] = ..., attrs: Optional[Iterable[Text]] = ..., **kwargs: Any + text: Text, color: Text | None = ..., on_color: Text | None = ..., attrs: Iterable[Text] | None = ..., **kwargs: Any ) -> None: ... diff --git a/stubs/toml/toml.pyi b/stubs/toml/toml.pyi index e19bc775f423..ec12441da4a3 100644 --- a/stubs/toml/toml.pyi +++ b/stubs/toml/toml.pyi @@ -13,7 +13,7 @@ else: class TomlDecodeError(Exception): ... -def load(f: Union[_PathLike, List[Text], IO[str]], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... +def load(f: _PathLike | List[Text] | IO[str], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... def loads(s: Text, _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... def dump(o: Mapping[str, Any], f: SupportsWrite[str]) -> str: ... def dumps(o: Mapping[str, Any]) -> str: ... diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index 139e58aac246..ebfa3b6ed4dd 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -8,15 +8,15 @@ class NodeVisitor: class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> None: ... -def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ... +def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: AST) -> AST: ... -def get_docstring(node: AST, clean: bool = ...) -> Optional[bytes]: ... +def get_docstring(node: AST, clean: bool = ...) -> bytes | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: Union[str, AST]) -> Any: ... +def literal_eval(node_or_string: str | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... PyCF_ONLY_AST: int @@ -58,7 +58,7 @@ class FunctionDef(stmt): args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - type_comment: Optional[str] + type_comment: str | None class ClassDef(stmt): name: identifier @@ -67,7 +67,7 @@ class ClassDef(stmt): decorator_list: typing.List[expr] class Return(stmt): - value: Optional[expr] + value: expr | None class Delete(stmt): targets: typing.List[expr] @@ -75,7 +75,7 @@ class Delete(stmt): class Assign(stmt): targets: typing.List[expr] value: expr - type_comment: Optional[str] + type_comment: str | None class AugAssign(stmt): target: expr @@ -83,7 +83,7 @@ class AugAssign(stmt): value: expr class Print(stmt): - dest: Optional[expr] + dest: expr | None values: typing.List[expr] nl: bool @@ -92,7 +92,7 @@ class For(stmt): iter: expr body: typing.List[stmt] orelse: typing.List[stmt] - type_comment: Optional[str] + type_comment: str | None class While(stmt): test: expr @@ -106,14 +106,14 @@ class If(stmt): class With(stmt): context_expr: expr - optional_vars: Optional[expr] + optional_vars: expr | None body: typing.List[stmt] - type_comment: Optional[str] + type_comment: str | None class Raise(stmt): - type: Optional[expr] - inst: Optional[expr] - tback: Optional[expr] + type: expr | None + inst: expr | None + tback: expr | None class TryExcept(stmt): body: typing.List[stmt] @@ -126,20 +126,20 @@ class TryFinally(stmt): class Assert(stmt): test: expr - msg: Optional[expr] + msg: expr | None class Import(stmt): names: typing.List[alias] class ImportFrom(stmt): - module: Optional[identifier] + module: identifier | None names: typing.List[alias] - level: Optional[int] + level: int | None class Exec(stmt): body: expr - globals: Optional[expr] - locals: Optional[expr] + globals: expr | None + locals: expr | None class Global(stmt): names: typing.List[identifier] @@ -155,9 +155,9 @@ class slice(AST): ... _slice = slice # this lets us type the variable named 'slice' below class Slice(slice): - lower: Optional[expr] - upper: Optional[expr] - step: Optional[expr] + lower: expr | None + upper: expr | None + step: expr | None class ExtSlice(slice): dims: typing.List[slice] @@ -218,7 +218,7 @@ class GeneratorExp(expr): generators: typing.List[comprehension] class Yield(expr): - value: Optional[expr] + value: expr | None class Compare(expr): left: expr @@ -229,17 +229,17 @@ class Call(expr): func: expr args: typing.List[expr] keywords: typing.List[keyword] - starargs: Optional[expr] - kwargs: Optional[expr] + starargs: expr | None + kwargs: expr | None class Repr(expr): value: expr class Num(expr): - n: Union[int, float, complex] + n: int | float | complex class Str(expr): - s: Union[str, bytes] + s: str | bytes kind: str class Attribute(expr): @@ -310,18 +310,18 @@ class comprehension(AST): ifs: typing.List[expr] class ExceptHandler(AST): - type: Optional[expr] - name: Optional[expr] + type: expr | None + name: expr | None body: typing.List[stmt] lineno: int col_offset: int class arguments(AST): args: typing.List[expr] - vararg: Optional[identifier] - kwarg: Optional[identifier] + vararg: identifier | None + kwarg: identifier | None defaults: typing.List[expr] - type_comments: typing.List[Optional[str]] + type_comments: typing.List[str | None] class keyword(AST): arg: identifier @@ -329,7 +329,7 @@ class keyword(AST): class alias(AST): name: identifier - asname: Optional[identifier] + asname: identifier | None class TypeIgnore(AST): lineno: int diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 3dac9b2e1fd4..7431a79e613f 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -8,15 +8,15 @@ class NodeVisitor: class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> None: ... -def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ..., feature_version: int = ...) -> AST: ... +def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ..., feature_version: int = ...) -> AST: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: AST) -> AST: ... -def get_docstring(node: AST, clean: bool = ...) -> Optional[str]: ... +def get_docstring(node: AST, clean: bool = ...) -> str | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: Union[str, AST]) -> Any: ... +def literal_eval(node_or_string: str | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... PyCF_ONLY_AST: int @@ -58,16 +58,16 @@ class FunctionDef(stmt): args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - returns: Optional[expr] - type_comment: Optional[str] + returns: expr | None + type_comment: str | None class AsyncFunctionDef(stmt): name: identifier args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - returns: Optional[expr] - type_comment: Optional[str] + returns: expr | None + type_comment: str | None class ClassDef(stmt): name: identifier @@ -77,7 +77,7 @@ class ClassDef(stmt): decorator_list: typing.List[expr] class Return(stmt): - value: Optional[expr] + value: expr | None class Delete(stmt): targets: typing.List[expr] @@ -85,7 +85,7 @@ class Delete(stmt): class Assign(stmt): targets: typing.List[expr] value: expr - type_comment: Optional[str] + type_comment: str | None class AugAssign(stmt): target: expr @@ -95,7 +95,7 @@ class AugAssign(stmt): class AnnAssign(stmt): target: expr annotation: expr - value: Optional[expr] + value: expr | None simple: int class For(stmt): @@ -103,14 +103,14 @@ class For(stmt): iter: expr body: typing.List[stmt] orelse: typing.List[stmt] - type_comment: Optional[str] + type_comment: str | None class AsyncFor(stmt): target: expr iter: expr body: typing.List[stmt] orelse: typing.List[stmt] - type_comment: Optional[str] + type_comment: str | None class While(stmt): test: expr @@ -125,16 +125,16 @@ class If(stmt): class With(stmt): items: typing.List[withitem] body: typing.List[stmt] - type_comment: Optional[str] + type_comment: str | None class AsyncWith(stmt): items: typing.List[withitem] body: typing.List[stmt] - type_comment: Optional[str] + type_comment: str | None class Raise(stmt): - exc: Optional[expr] - cause: Optional[expr] + exc: expr | None + cause: expr | None class Try(stmt): body: typing.List[stmt] @@ -144,15 +144,15 @@ class Try(stmt): class Assert(stmt): test: expr - msg: Optional[expr] + msg: expr | None class Import(stmt): names: typing.List[alias] class ImportFrom(stmt): - module: Optional[identifier] + module: identifier | None names: typing.List[alias] - level: Optional[int] + level: int | None class Global(stmt): names: typing.List[identifier] @@ -171,9 +171,9 @@ class slice(AST): ... _slice = slice # this lets us type the variable named 'slice' below class Slice(slice): - lower: Optional[expr] - upper: Optional[expr] - step: Optional[expr] + lower: expr | None + upper: expr | None + step: expr | None class ExtSlice(slice): dims: typing.List[slice] @@ -235,7 +235,7 @@ class Await(expr): value: expr class Yield(expr): - value: Optional[expr] + value: expr | None class YieldFrom(expr): value: expr @@ -251,7 +251,7 @@ class Call(expr): keywords: typing.List[keyword] class Num(expr): - n: Union[float, int, complex] + n: float | int | complex class Str(expr): s: str @@ -259,8 +259,8 @@ class Str(expr): class FormattedValue(expr): value: expr - conversion: typing.Optional[int] - format_spec: typing.Optional[expr] + conversion: typing.int | None + format_spec: typing.expr | None class JoinedStr(expr): values: typing.List[expr] @@ -347,38 +347,38 @@ class comprehension(AST): is_async: int class ExceptHandler(AST): - type: Optional[expr] - name: Optional[identifier] + type: expr | None + name: identifier | None body: typing.List[stmt] lineno: int col_offset: int class arguments(AST): args: typing.List[arg] - vararg: Optional[arg] + vararg: arg | None kwonlyargs: typing.List[arg] kw_defaults: typing.List[expr] - kwarg: Optional[arg] + kwarg: arg | None defaults: typing.List[expr] class arg(AST): arg: identifier - annotation: Optional[expr] + annotation: expr | None lineno: int col_offset: int - type_comment: typing.Optional[str] + type_comment: typing.str | None class keyword(AST): - arg: Optional[identifier] + arg: identifier | None value: expr class alias(AST): name: identifier - asname: Optional[identifier] + asname: identifier | None class withitem(AST): context_expr: expr - optional_vars: Optional[expr] + optional_vars: expr | None class TypeIgnore(AST): lineno: int diff --git a/stubs/waitress/waitress/adjustments.pyi b/stubs/waitress/waitress/adjustments.pyi index e1c370039293..7f03a7e0ebeb 100644 --- a/stubs/waitress/waitress/adjustments.pyi +++ b/stubs/waitress/waitress/adjustments.pyi @@ -7,13 +7,13 @@ from .proxy_headers import PROXY_HEADERS as PROXY_HEADERS truthy: FrozenSet[Any] KNOWN_PROXY_HEADERS: FrozenSet[Any] -def asbool(s: Optional[Union[bool, str, int]]) -> bool: ... +def asbool(s: bool | str | int | None) -> bool: ... def asoctal(s: str) -> int: ... def aslist_cronly(value: str) -> List[str]: ... def aslist(value: str) -> List[str]: ... -def asset(value: Optional[str]) -> Set[str]: ... -def slash_fixed_str(s: Optional[str]) -> str: ... -def str_iftruthy(s: Optional[str]) -> Optional[str]: ... +def asset(value: str | None) -> Set[str]: ... +def slash_fixed_str(s: str | None) -> str: ... +def str_iftruthy(s: str | None) -> str | None: ... def as_socket_list(sockets: Sequence[object]) -> List[socket]: ... class _str_marker(str): ... @@ -25,11 +25,11 @@ class Adjustments: port: _int_marker = ... listen: List[str] = ... threads: int = ... - trusted_proxy: Optional[str] = ... - trusted_proxy_count: Optional[int] = ... + trusted_proxy: str | None = ... + trusted_proxy_count: int | None = ... trusted_proxy_headers: Set[str] = ... log_untrusted_proxy_headers: bool = ... - clear_untrusted_proxy_headers: Union[_bool_marker, bool] = ... + clear_untrusted_proxy_headers: _bool_marker | bool = ... url_scheme: str = ... url_prefix: str = ... ident: str = ... @@ -46,7 +46,7 @@ class Adjustments: max_request_header_size: int = ... max_request_body_size: int = ... expose_tracebacks: bool = ... - unix_socket: Optional[str] = ... + unix_socket: str | None = ... unix_socket_perms: int = ... socket_options: List[Tuple[int, int, int]] = ... asyncore_loop_timeout: int = ... diff --git a/stubs/waitress/waitress/buffers.pyi b/stubs/waitress/waitress/buffers.pyi index fc5147e00d35..248c8b413cab 100644 --- a/stubs/waitress/waitress/buffers.pyi +++ b/stubs/waitress/waitress/buffers.pyi @@ -7,7 +7,7 @@ STRBUF_LIMIT: int class FileBasedBuffer: remain: int = ... file: BytesIO = ... - def __init__(self, file: BytesIO, from_buffer: Optional[BytesIO] = ...) -> None: ... + def __init__(self, file: BytesIO, from_buffer: BytesIO | None = ...) -> None: ... def __len__(self) -> int: ... def __nonzero__(self) -> bool: ... __bool__: Callable[[], bool] = ... @@ -20,12 +20,12 @@ class FileBasedBuffer: def close(self) -> None: ... class TempfileBasedBuffer(FileBasedBuffer): - def __init__(self, from_buffer: Optional[BytesIO] = ...) -> None: ... + def __init__(self, from_buffer: BytesIO | None = ...) -> None: ... def newfile(self) -> BufferedRandom: ... class BytesIOBasedBuffer(FileBasedBuffer): file: BytesIO = ... - def __init__(self, from_buffer: Optional[BytesIO] = ...) -> None: ... + def __init__(self, from_buffer: BytesIO | None = ...) -> None: ... def newfile(self) -> BytesIO: ... class ReadOnlyFileBasedBuffer(FileBasedBuffer): @@ -33,16 +33,16 @@ class ReadOnlyFileBasedBuffer(FileBasedBuffer): block_size: int = ... def __init__(self, file: BytesIO, block_size: int = ...) -> None: ... remain: int = ... - def prepare(self, size: Optional[int] = ...) -> int: ... + def prepare(self, size: int | None = ...) -> int: ... def get(self, numbytes: int = ..., skip: bool = ...) -> bytes: ... def __iter__(self) -> ReadOnlyFileBasedBuffer: ... - def next(self) -> Optional[bytes]: ... - __next__: Callable[[], Optional[bytes]] = ... + def next(self) -> bytes | None: ... + __next__: Callable[[], bytes | None] = ... def append(self, s: Any) -> None: ... class OverflowableBuffer: overflowed: bool = ... - buf: Optional[BufferedIOBase] = ... + buf: BufferedIOBase | None = ... strbuf: bytes = ... overflow: int = ... def __init__(self, overflow: int) -> None: ... diff --git a/stubs/waitress/waitress/channel.pyi b/stubs/waitress/waitress/channel.pyi index fcf07606895c..86f527fdf360 100644 --- a/stubs/waitress/waitress/channel.pyi +++ b/stubs/waitress/waitress/channel.pyi @@ -33,7 +33,7 @@ class HTTPChannel(wasyncore.dispatcher): outbuf_lock: Condition = ... addr: Tuple[str, int] = ... def __init__( - self, server: BaseWSGIServer, sock: socket, addr: str, adj: Adjustments, map: Optional[Mapping[int, socket]] = ... + self, server: BaseWSGIServer, sock: socket, addr: str, adj: Adjustments, map: Mapping[int, socket] | None = ... ) -> None: ... def writable(self) -> bool: ... def handle_write(self) -> None: ... @@ -42,8 +42,8 @@ class HTTPChannel(wasyncore.dispatcher): def received(self, data: bytes) -> bool: ... connected: bool = ... def handle_close(self) -> None: ... - def add_channel(self, map: Optional[Mapping[int, socket]] = ...) -> None: ... - def del_channel(self, map: Optional[Mapping[int, socket]] = ...) -> None: ... + def add_channel(self, map: Mapping[int, socket] | None = ...) -> None: ... + def del_channel(self, map: Mapping[int, socket] | None = ...) -> None: ... def write_soon(self, data: bytes) -> int: ... def service(self) -> None: ... def cancel(self) -> None: ... diff --git a/stubs/waitress/waitress/compat.pyi b/stubs/waitress/waitress/compat.pyi index 35d92409300a..49e32e239ea6 100644 --- a/stubs/waitress/waitress/compat.pyi +++ b/stubs/waitress/waitress/compat.pyi @@ -18,7 +18,7 @@ def tobytes(s: str) -> bytes: ... exec_: Any -def reraise(tp: Any, value: BaseException, tb: Optional[str] = ...) -> None: ... +def reraise(tp: Any, value: BaseException, tb: str | None = ...) -> None: ... MAXINT: int HAS_IPV6: bool diff --git a/stubs/waitress/waitress/parser.pyi b/stubs/waitress/waitress/parser.pyi index 48a3d210f74e..80d123ffcd7b 100644 --- a/stubs/waitress/waitress/parser.pyi +++ b/stubs/waitress/waitress/parser.pyi @@ -20,9 +20,9 @@ class HTTPRequestParser: content_length: int = ... header_bytes_received: int = ... body_bytes_received: int = ... - body_rcv: Optional[Union[ChunkedReceiver, FixedStreamReceiver]] = ... + body_rcv: ChunkedReceiver | FixedStreamReceiver | None = ... version: str = ... - error: Optional[Error] = ... + error: Error | None = ... connection_close: bool = ... headers: Mapping[str, str] = ... adj: Adjustments = ... diff --git a/stubs/waitress/waitress/proxy_headers.pyi b/stubs/waitress/waitress/proxy_headers.pyi index 42486a4caf4f..1a8f554c4d70 100644 --- a/stubs/waitress/waitress/proxy_headers.pyi +++ b/stubs/waitress/waitress/proxy_headers.pyi @@ -19,9 +19,9 @@ class MalformedProxyHeader(Exception): def proxy_headers_middleware( app: Any, - trusted_proxy: Optional[str] = ..., + trusted_proxy: str | None = ..., trusted_proxy_count: int = ..., - trusted_proxy_headers: Optional[Set[str]] = ..., + trusted_proxy_headers: Set[str] | None = ..., clear_untrusted: bool = ..., log_untrusted: bool = ..., logger: Logger = ..., diff --git a/stubs/waitress/waitress/receiver.pyi b/stubs/waitress/waitress/receiver.pyi index 2be77dc6157a..e4255d6c6451 100644 --- a/stubs/waitress/waitress/receiver.pyi +++ b/stubs/waitress/waitress/receiver.pyi @@ -23,7 +23,7 @@ class ChunkedReceiver: all_chunks_received: bool = ... trailer: bytes = ... completed: bool = ... - error: Optional[BadRequest] = ... + error: BadRequest | None = ... buf: OverflowableBuffer = ... def __init__(self, buf: OverflowableBuffer) -> None: ... def __len__(self) -> int: ... diff --git a/stubs/waitress/waitress/runner.pyi b/stubs/waitress/waitress/runner.pyi index 1fb240a202c5..0b39c957fc6f 100644 --- a/stubs/waitress/waitress/runner.pyi +++ b/stubs/waitress/waitress/runner.pyi @@ -6,6 +6,6 @@ RUNNER_PATTERN: Pattern[Any] def match(obj_name: str) -> Tuple[str, str]: ... def resolve(module_name: str, object_name: str) -> Any: ... -def show_help(stream: TextIOWrapper, name: str, error: Optional[str] = ...) -> None: ... +def show_help(stream: TextIOWrapper, name: str, error: str | None = ...) -> None: ... def show_exception(stream: TextIOWrapper) -> None: ... def run(argv: Sequence[str] = ..., _serve: Callable[..., Any] = ...) -> None: ... diff --git a/stubs/waitress/waitress/server.pyi b/stubs/waitress/waitress/server.pyi index ab2022939916..075a3fa44cc0 100644 --- a/stubs/waitress/waitress/server.pyi +++ b/stubs/waitress/waitress/server.pyi @@ -9,12 +9,12 @@ from . import wasyncore def create_server( application: Any, - map: Optional[Any] = ..., + map: Any | None = ..., _start: bool = ..., - _sock: Optional[socket] = ..., - _dispatcher: Optional[ThreadedTaskDispatcher] = ..., + _sock: socket | None = ..., + _dispatcher: ThreadedTaskDispatcher | None = ..., **kw: Any, -) -> Union[MultiSocketServer, BaseWSGIServer]: ... +) -> MultiSocketServer | BaseWSGIServer: ... class MultiSocketServer: asyncore: Any = ... @@ -24,10 +24,10 @@ class MultiSocketServer: task_dispatcher: ThreadedTaskDispatcher = ... def __init__( self, - map: Optional[Any] = ..., - adj: Optional[Adjustments] = ..., - effective_listen: Optional[Sequence[Tuple[str, int]]] = ..., - dispatcher: Optional[ThreadedTaskDispatcher] = ..., + map: Any | None = ..., + adj: Adjustments | None = ..., + effective_listen: Sequence[Tuple[str, int]] | None = ..., + dispatcher: ThreadedTaskDispatcher | None = ..., ) -> None: ... def print_listen(self, format_str: str) -> None: ... def run(self) -> None: ... @@ -50,12 +50,12 @@ class BaseWSGIServer(wasyncore.dispatcher): def __init__( self, application: Any, - map: Optional[Any] = ..., + map: Any | None = ..., _start: bool = ..., - _sock: Optional[Any] = ..., - dispatcher: Optional[ThreadedTaskDispatcher] = ..., - adj: Optional[Adjustments] = ..., - sockinfo: Optional[Any] = ..., + _sock: Any | None = ..., + dispatcher: ThreadedTaskDispatcher | None = ..., + adj: Adjustments | None = ..., + sockinfo: Any | None = ..., bind_socket: bool = ..., **kw: Any, ) -> None: ... @@ -87,12 +87,12 @@ class UnixWSGIServer(BaseWSGIServer): def __init__( self, application: Any, - map: Optional[Any] = ..., + map: Any | None = ..., _start: bool = ..., - _sock: Optional[Any] = ..., - dispatcher: Optional[Any] = ..., - adj: Optional[Adjustments] = ..., - sockinfo: Optional[Any] = ..., + _sock: Any | None = ..., + dispatcher: Any | None = ..., + adj: Adjustments | None = ..., + sockinfo: Any | None = ..., **kw: Any, ) -> None: ... def bind_server_socket(self) -> None: ... diff --git a/stubs/waitress/waitress/task.pyi b/stubs/waitress/waitress/task.pyi index 9dffbf7bceeb..25c7c00b8d9c 100644 --- a/stubs/waitress/waitress/task.pyi +++ b/stubs/waitress/waitress/task.pyi @@ -30,7 +30,7 @@ class Task: status: str = ... wrote_header: bool = ... start_time: int = ... - content_length: Optional[int] = ... + content_length: int | None = ... content_bytes_written: int = ... logged_write_excess: bool = ... logged_write_no_body: bool = ... @@ -59,7 +59,7 @@ class ErrorTask(Task): def execute(self) -> None: ... class WSGITask(Task): - environ: Optional[Any] = ... + environ: Any | None = ... response_headers: Sequence[Tuple[str, str]] = ... complete: bool = ... status: str = ... diff --git a/stubs/waitress/waitress/trigger.pyi b/stubs/waitress/waitress/trigger.pyi index 8062cfcf5d44..d49a346d3733 100644 --- a/stubs/waitress/waitress/trigger.pyi +++ b/stubs/waitress/waitress/trigger.pyi @@ -7,7 +7,7 @@ from typing_extensions import Literal from . import wasyncore as wasyncore class _triggerbase: - kind: Optional[str] = ... + kind: str | None = ... lock: Lock = ... thunks: Callable[[None], None] = ... def __init__(self) -> None: ... @@ -16,7 +16,7 @@ class _triggerbase: def handle_connect(self) -> None: ... def handle_close(self) -> None: ... def close(self) -> None: ... - def pull_trigger(self, thunk: Optional[Callable[[None], None]] = ...) -> None: ... + def pull_trigger(self, thunk: Callable[[None], None] | None = ...) -> None: ... def handle_read(self) -> None: ... if sys.platform == "linux" or sys.platform == "darwin": diff --git a/stubs/waitress/waitress/wasyncore.pyi b/stubs/waitress/waitress/wasyncore.pyi index ca21a9fc8998..1194a4718166 100644 --- a/stubs/waitress/waitress/wasyncore.pyi +++ b/stubs/waitress/waitress/wasyncore.pyi @@ -15,13 +15,13 @@ class ExitNow(Exception): ... def read(obj: dispatcher) -> None: ... def write(obj: dispatcher) -> None: ... def readwrite(obj: dispatcher, flags: int) -> None: ... -def poll(timeout: float = ..., map: Optional[Mapping[int, socket]] = ...) -> None: ... -def poll2(timeout: float = ..., map: Optional[Mapping[int, socket]] = ...) -> None: ... +def poll(timeout: float = ..., map: Mapping[int, socket] | None = ...) -> None: ... +def poll2(timeout: float = ..., map: Mapping[int, socket] | None = ...) -> None: ... poll3 = poll2 def loop( - timeout: float = ..., use_poll: bool = ..., map: Optional[Mapping[int, socket]] = ..., count: Optional[int] = ... + timeout: float = ..., use_poll: bool = ..., map: Mapping[int, socket] | None = ..., count: int | None = ... ) -> None: ... def compact_traceback() -> Tuple[Tuple[str, str, str], BaseException, BaseException, str]: ... @@ -31,24 +31,24 @@ class dispatcher: accepting: bool = ... connecting: bool = ... closing: bool = ... - addr: Optional[Tuple[str, int]] = ... + addr: Tuple[str, int] | None = ... ignore_log_types: frozenset[Any] logger: Logger = ... compact_traceback: Callable[[], Tuple[Tuple[str, str, str], BaseException, BaseException, str]] = ... - socket: Optional[_socket] = ... - def __init__(self, sock: Optional[_socket] = ..., map: Optional[Mapping[int, _socket]] = ...) -> None: ... - def add_channel(self, map: Optional[Mapping[int, _socket]] = ...) -> None: ... - def del_channel(self, map: Optional[Mapping[int, _socket]] = ...) -> None: ... + socket: _socket | None = ... + def __init__(self, sock: _socket | None = ..., map: Mapping[int, _socket] | None = ...) -> None: ... + def add_channel(self, map: Mapping[int, _socket] | None = ...) -> None: ... + def del_channel(self, map: Mapping[int, _socket] | None = ...) -> None: ... family_and_type: Tuple[int, int] = ... def create_socket(self, family: int = ..., type: int = ...) -> None: ... - def set_socket(self, sock: _socket, map: Optional[Mapping[int, _socket]] = ...) -> None: ... + def set_socket(self, sock: _socket, map: Mapping[int, _socket] | None = ...) -> None: ... def set_reuse_addr(self) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... def listen(self, num: int) -> None: ... def bind(self, addr: Tuple[str, int]) -> None: ... def connect(self, address: Tuple[str, int]) -> None: ... - def accept(self) -> Optional[Tuple[_socket, Tuple[str, int]]]: ... + def accept(self) -> Tuple[_socket, Tuple[str, int]] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... def close(self) -> None: ... @@ -69,13 +69,13 @@ class dispatcher: class dispatcher_with_send(dispatcher): out_buffer: bytes = ... - def __init__(self, sock: Optional[socket] = ..., map: Optional[Mapping[int, socket]] = ...) -> None: ... + def __init__(self, sock: socket | None = ..., map: Mapping[int, socket] | None = ...) -> None: ... def initiate_send(self) -> None: ... handle_write: Callable[[], None] = ... def writable(self) -> bool: ... def send(self, data: bytes) -> None: ... # type: ignore -def close_all(map: Optional[Mapping[int, socket]] = ..., ignore_all: bool = ...) -> None: ... +def close_all(map: Mapping[int, socket] | None = ..., ignore_all: bool = ...) -> None: ... class file_wrapper: fd: BytesIO = ... @@ -83,7 +83,7 @@ class file_wrapper: def __del__(self) -> None: ... def recv(self, *args: Any) -> bytes: ... def send(self, *args: Any) -> bytes: ... - def getsockopt(self, level: int, optname: int, buflen: Optional[bool] = ...) -> int: ... + def getsockopt(self, level: int, optname: int, buflen: bool | None = ...) -> int: ... read: Callable[..., bytes] = ... write: Callable[..., bytes] = ... def close(self) -> None: ... @@ -91,6 +91,6 @@ class file_wrapper: class file_dispatcher(dispatcher): connected: bool = ... - def __init__(self, fd: BytesIO, map: Optional[Mapping[int, _socket]] = ...) -> None: ... + def __init__(self, fd: BytesIO, map: Mapping[int, _socket] | None = ...) -> None: ... socket: _socket = ... def set_file(self, fd: BytesIO) -> None: ... From a5a30b06bb3bd470c4ad6e6b5204167cd0b2b88a Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 17:51:25 +0300 Subject: [PATCH 02/13] run black --- stdlib/_bisect.pyi | 14 +---- stdlib/_codecs.pyi | 4 +- stdlib/argparse.pyi | 18 ++---- stdlib/asyncio/base_events.pyi | 25 ++------- stdlib/asyncio/events.pyi | 25 ++------- stdlib/asyncio/staggered.pyi | 5 +- stdlib/asyncio/tasks.pyi | 34 ++--------- stdlib/asyncio/unix_events.pyi | 4 +- stdlib/base64.pyi | 4 +- stdlib/bdb.pyi | 8 +-- stdlib/builtins.pyi | 26 ++------- stdlib/bz2.pyi | 6 +- stdlib/cgitb.pyi | 4 +- stdlib/codecs.pyi | 16 ++---- stdlib/collections/__init__.pyi | 15 +---- stdlib/configparser.pyi | 12 +--- stdlib/contextlib.pyi | 10 +--- stdlib/ctypes/__init__.pyi | 7 +-- stdlib/difflib.pyi | 4 +- stdlib/dis.pyi | 4 +- stdlib/distutils/filelist.pyi | 17 +----- stdlib/doctest.pyi | 11 +--- stdlib/email/generator.pyi | 14 +---- stdlib/email/mime/text.pyi | 4 +- stdlib/filecmp.pyi | 5 +- stdlib/fractions.pyi | 6 +- stdlib/http/client.pyi | 14 +---- stdlib/http/cookiejar.pyi | 8 +-- stdlib/importlib/machinery.pyi | 12 +--- stdlib/itertools.pyi | 4 +- stdlib/lib2to3/pytree.pyi | 7 +-- stdlib/logging/__init__.pyi | 56 +++---------------- stdlib/logging/config.pyi | 4 +- stdlib/logging/handlers.pyi | 15 +---- stdlib/lzma.pyi | 4 +- stdlib/mailbox.pyi | 8 +-- stdlib/mmap.pyi | 4 +- stdlib/msilib/__init__.pyi | 26 +-------- stdlib/msilib/schema.pyi | 4 +- stdlib/multiprocessing/context.pyi | 16 +----- stdlib/multiprocessing/dummy/__init__.pyi | 4 +- stdlib/multiprocessing/managers.pyi | 18 ++---- stdlib/multiprocessing/sharedctypes.pyi | 6 +- stdlib/nntplib.pyi | 4 +- stdlib/optparse.pyi | 4 +- stdlib/os/__init__.pyi | 12 +--- stdlib/pathlib.pyi | 7 +-- stdlib/pickle.pyi | 21 +------ stdlib/platform.pyi | 4 +- stdlib/pprint.pyi | 4 +- stdlib/pyclbr.pyi | 8 +-- stdlib/pydoc.pyi | 10 +--- stdlib/pyexpat/__init__.pyi | 4 +- stdlib/random.pyi | 10 +--- stdlib/shutil.pyi | 4 +- stdlib/smtplib.pyi | 10 +--- stdlib/socket.pyi | 6 +- stdlib/ssl.pyi | 12 +--- stdlib/sys.pyi | 4 +- stdlib/tarfile.pyi | 4 +- stdlib/tempfile.pyi | 8 +-- stdlib/time.pyi | 8 ++- stdlib/tkinter/__init__.pyi | 36 +++--------- stdlib/tkinter/colorchooser.pyi | 4 +- stdlib/tkinter/tix.pyi | 8 +-- stdlib/trace.pyi | 5 +- stdlib/tracemalloc.pyi | 7 +-- stdlib/turtle.pyi | 13 +---- stdlib/typing.pyi | 5 +- stdlib/unittest/case.pyi | 18 ++---- stdlib/unittest/result.pyi | 8 +-- stdlib/urllib/parse.pyi | 4 +- stdlib/urllib/request.pyi | 8 +-- stdlib/warnings.pyi | 11 +--- stdlib/xml/dom/domreg.pyi | 4 +- stdlib/xml/dom/minidom.pyi | 4 +- stdlib/xml/dom/pulldom.pyi | 4 +- stdlib/xml/etree/ElementInclude.pyi | 5 +- stdlib/xml/etree/ElementPath.pyi | 4 +- stdlib/xml/etree/ElementTree.pyi | 4 +- stdlib/xmlrpc/client.pyi | 4 +- stdlib/xmlrpc/server.pyi | 4 +- stdlib/zipfile.pyi | 15 +---- stdlib/zipimport.pyi | 4 +- .../DateTimeRange/datetimerange/__init__.pyi | 4 +- stubs/Flask/flask/app.pyi | 4 +- stubs/Flask/flask/blueprints.pyi | 4 +- stubs/Jinja2/jinja2/environment.pyi | 16 +----- stubs/Jinja2/jinja2/loaders.pyi | 4 +- stubs/Jinja2/jinja2/utils.pyi | 5 +- stubs/Markdown/markdown/core.pyi | 4 +- stubs/MarkupSafe/markupsafe/__init__.pyi | 4 +- stubs/Werkzeug/werkzeug/datastructures.pyi | 4 +- stubs/Werkzeug/werkzeug/exceptions.pyi | 5 +- stubs/Werkzeug/werkzeug/http.pyi | 4 +- stubs/Werkzeug/werkzeug/routing.pyi | 17 +----- stubs/Werkzeug/werkzeug/test.pyi | 10 +--- stubs/aiofiles/aiofiles/base.pyi | 4 +- stubs/boto/boto/__init__.pyi | 8 +-- stubs/boto/boto/kms/layer1.pyi | 9 +-- stubs/boto/boto/regioninfo.pyi | 6 +- stubs/boto/boto/s3/bucket.pyi | 15 +---- stubs/boto/boto/s3/bucketlistresultset.pyi | 7 +-- stubs/boto/boto/s3/key.pyi | 4 +- stubs/boto/boto/utils.pyi | 10 +--- stubs/cachetools/cachetools/decorators.pyi | 4 +- stubs/cachetools/cachetools/func.pyi | 4 +- stubs/cachetools/cachetools/rr.pyi | 5 +- stubs/click/click/core.pyi | 4 +- stubs/click/click/exceptions.pyi | 6 +- stubs/click/click/testing.pyi | 6 +- stubs/colorama/colorama/ansitowin32.pyi | 4 +- .../hazmat/primitives/asymmetric/dsa.pyi | 4 +- .../hazmat/primitives/asymmetric/rsa.pyi | 4 +- .../hazmat/primitives/kdf/concatkdf.pyi | 4 +- .../hazmat/primitives/kdf/hkdf.pyi | 7 +-- .../hazmat/primitives/kdf/x963kdf.pyi | 4 +- .../hazmat/primitives/twofactor/hotp.pyi | 7 +-- .../cryptography/x509/__init__.pyi | 5 +- stubs/dataclasses/dataclasses.pyi | 7 +-- stubs/docutils/docutils/frontend.pyi | 4 +- stubs/geoip2/geoip2/database.pyi | 5 +- stubs/itsdangerous/itsdangerous.pyi | 18 ++---- stubs/maxminddb/maxminddb/reader.pyi | 5 +- stubs/paramiko/paramiko/sftp_client.pyi | 13 +---- .../protobuf/google/protobuf/json_format.pyi | 5 +- stubs/python-gflags/gflags.pyi | 4 +- stubs/redis/redis/client.pyi | 4 +- stubs/requests/requests/adapters.pyi | 6 +- stubs/setuptools/pkg_resources/__init__.pyi | 8 +-- stubs/six/six/__init__.pyi | 8 +-- stubs/termcolor/termcolor.pyi | 4 +- stubs/waitress/waitress/wasyncore.pyi | 4 +- 133 files changed, 236 insertions(+), 910 deletions(-) diff --git a/stdlib/_bisect.pyi b/stdlib/_bisect.pyi index 2e9b82203d39..2ef92b205257 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -12,20 +12,10 @@ if sys.version_info >= (3, 10): a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ... ) -> int: ... def insort_left( - a: MutableSequence[_T], - x: _T, - lo: int = ..., - hi: int | None = ..., - *, - key: Callable[[_T], SupportsLessThan] | None = ..., + a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ... ) -> None: ... def insort_right( - a: MutableSequence[_T], - x: _T, - lo: int = ..., - hi: int | None = ..., - *, - key: Callable[[_T], SupportsLessThan] | None = ..., + a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsLessThan] | None = ... ) -> None: ... else: diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 469aa99dacf5..c5026bacd75b 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -60,9 +60,7 @@ def utf_8_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: . if sys.platform == "win32": def mbcs_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... def mbcs_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... - def code_page_decode( - __codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ... - ) -> Tuple[str, int]: ... + def code_page_decode(__codepage: int, __data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... def oem_decode(__data: bytes, __errors: str | None = ..., __final: int = ...) -> Tuple[str, int]: ... def oem_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 2570cf87dbd7..a674cd70f28c 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -192,9 +192,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def exit(self, status: int = ..., message: str | None = ...) -> NoReturn: ... def error(self, message: str) -> NoReturn: ... if sys.version_info >= (3, 7): - def parse_intermixed_args( - self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... - ) -> Namespace: ... + def parse_intermixed_args(self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...) -> Namespace: ... def parse_known_intermixed_args( self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... ) -> Tuple[Namespace, List[str]]: ... @@ -228,9 +226,7 @@ class HelpFormatter: _whitespace_matcher: Pattern[str] _long_break_matcher: Pattern[str] _Section: Type[Any] # Nested class - def __init__( - self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ... - ) -> None: ... + def __init__(self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ...) -> None: ... def _indent(self) -> None: ... def _dedent(self) -> None: ... def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ... @@ -291,11 +287,7 @@ class Action(_AttributeHolder): metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... def __call__( - self, - parser: ArgumentParser, - namespace: Namespace, - values: str | Sequence[Any] | None, - option_string: str | None = ..., + self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = ... ) -> None: ... if sys.version_info >= (3, 9): def format_usage(self) -> str: ... @@ -326,9 +318,7 @@ class FileType: _bufsize: int _encoding: str | None _errors: str | None - def __init__( - self, mode: str = ..., bufsize: int = ..., encoding: str | None = ..., errors: str | None = ... - ) -> None: ... + def __init__(self, mode: str = ..., bufsize: int = ..., encoding: str | None = ..., errors: str | None = ...) -> None: ... def __call__(self, string: str) -> IO[Any]: ... # undocumented diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 8f1bd00860b4..2599f050fd77 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -77,9 +77,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T], *, name: object = ...) -> Task[_T]: ... else: def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T]) -> Task[_T]: ... - def set_task_factory( - self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None - ) -> None: ... + def set_task_factory(self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None) -> None: ... def get_task_factory(self) -> Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None: ... # Methods for interacting with threads if sys.version_info >= (3, 7): @@ -90,18 +88,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def set_default_executor(self, executor: Any) -> None: ... # Network I/O methods returning Futures. async def getaddrinfo( - self, - host: str | None, - port: str | int | None, - *, - family: int = ..., - type: int = ..., - proto: int = ..., - flags: int = ..., + self, host: str | None, port: str | int | None, *, family: int = ..., type: int = ..., proto: int = ..., flags: int = ... ) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[str, int] | Tuple[str, int, int, int]]]: ... - async def getnameinfo( - self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ... - ) -> Tuple[str, str]: ... + async def getnameinfo(self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ...) -> Tuple[str, str]: ... if sys.version_info >= (3, 8): @overload async def create_connection( @@ -250,13 +239,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... async def sendfile( - self, - transport: BaseTransport, - file: IO[bytes], - offset: int = ..., - count: int | None = ..., - *, - fallback: bool = ..., + self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ... ) -> int: ... async def start_tls( self, diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index ec7d4b4ef312..fcfaebd8ed18 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -106,9 +106,7 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod def create_task(self, coro: Awaitable[_T] | Generator[Any, None, _T]) -> Task[_T]: ... @abstractmethod - def set_task_factory( - self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None - ) -> None: ... + def set_task_factory(self, factory: Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None) -> None: ... @abstractmethod def get_task_factory(self) -> Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]] | None: ... # Methods for interacting with threads @@ -121,19 +119,10 @@ class AbstractEventLoop(metaclass=ABCMeta): # Network I/O methods returning Futures. @abstractmethod async def getaddrinfo( - self, - host: str | None, - port: str | int | None, - *, - family: int = ..., - type: int = ..., - proto: int = ..., - flags: int = ..., + self, host: str | None, port: str | int | None, *, family: int = ..., type: int = ..., proto: int = ..., flags: int = ... ) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[str, int] | Tuple[str, int, int, int]]]: ... @abstractmethod - async def getnameinfo( - self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ... - ) -> Tuple[str, str]: ... + async def getnameinfo(self, sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int = ...) -> Tuple[str, str]: ... if sys.version_info >= (3, 8): @overload @abstractmethod @@ -305,13 +294,7 @@ class AbstractEventLoop(metaclass=ABCMeta): ) -> Server: ... @abstractmethod async def sendfile( - self, - transport: BaseTransport, - file: IO[bytes], - offset: int = ..., - count: int | None = ..., - *, - fallback: bool = ..., + self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ... ) -> int: ... @abstractmethod async def start_tls( diff --git a/stdlib/asyncio/staggered.pyi b/stdlib/asyncio/staggered.pyi index 3a70fbf88b46..ded4611de8dc 100644 --- a/stdlib/asyncio/staggered.pyi +++ b/stdlib/asyncio/staggered.pyi @@ -5,8 +5,5 @@ from . import events if sys.version_info >= (3, 8): async def staggered_race( - coro_fns: Iterable[Callable[[], Awaitable[Any]]], - delay: float | None, - *, - loop: events.AbstractEventLoop | None = ..., + coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = ... ) -> Tuple[Any, int | None, List[Exception | None]]: ... diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index fe533fac2bb4..cc96126c064b 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -112,9 +112,7 @@ if sys.version_info >= (3, 10): coro_or_future4: _FutureT[_T4], *, return_exceptions: bool = ..., - ) -> Future[ - Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException] - ]: ... + ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -125,13 +123,7 @@ if sys.version_info >= (3, 10): *, return_exceptions: bool = ..., ) -> Future[ - Tuple[ - _T1 | BaseException, - _T2 | BaseException, - _T3 | BaseException, - _T4 | BaseException, - _T5 | BaseException, - ] + Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException,] ]: ... else: @@ -219,9 +211,7 @@ else: *, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., - ) -> Future[ - Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException] - ]: ... + ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -233,13 +223,7 @@ else: loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., ) -> Future[ - Tuple[ - _T1 | BaseException, - _T2 | BaseException, - _T3 | BaseException, - _T4 | BaseException, - _T5 | BaseException, - ] + Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException,] ]: ... def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... @@ -262,11 +246,7 @@ else: def wait(fs: Iterable[_FT], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore @overload def wait( - fs: Iterable[Awaitable[_T]], - *, - loop: AbstractEventLoop | None = ..., - timeout: float | None = ..., - return_when: str = ..., + fs: Iterable[Awaitable[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ... ) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ... def wait_for(fut: _FutureT[_T], timeout: float | None, *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... @@ -307,9 +287,7 @@ class Task(Future[_T], Generic[_T]): if sys.version_info >= (3, 7): def all_tasks(loop: AbstractEventLoop | None = ...) -> Set[Task[Any]]: ... if sys.version_info >= (3, 8): - def create_task( - coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, name: str | None = ... - ) -> Task[_T]: ... + def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, name: str | None = ...) -> Task[_T]: ... else: def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T]) -> Task[_T]: ... def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index edb8f3a289b1..cb35a3db4695 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -14,9 +14,7 @@ class AbstractChildWatcher: def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None - ) -> None: ... + def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... if sys.version_info >= (3, 8): def is_active(self) -> bool: ... diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 0e2dda19756e..0b17173350e3 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -17,9 +17,7 @@ if sys.version_info >= (3, 10): def b32hexdecode(s: str | bytes, casefold: bool = ...) -> bytes: ... def a85encode(b: bytes, *, foldspaces: bool = ..., wrapcol: int = ..., pad: bool = ..., adobe: bool = ...) -> bytes: ... -def a85decode( - b: str | bytes, *, foldspaces: bool = ..., adobe: bool = ..., ignorechars: str | bytes = ... -) -> bytes: ... +def a85decode(b: str | bytes, *, foldspaces: bool = ..., adobe: bool = ..., ignorechars: str | bytes = ...) -> bytes: ... def b85encode(b: bytes, pad: bool = ...) -> bytes: ... def b85decode(b: str | bytes) -> bytes: ... def decode(input: IO[bytes], output: IO[bytes]) -> None: ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index bf8f3c583260..1b68d3bfc2d8 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -58,13 +58,9 @@ class Bdb: def get_all_breaks(self) -> List[Breakpoint]: ... def get_stack(self, f: FrameType | None, t: TracebackType | None) -> Tuple[List[Tuple[FrameType, int]], int]: ... def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ... - def run( - self, cmd: str | CodeType, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ... - ) -> None: ... + def run(self, cmd: str | CodeType, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... def runeval(self, expr: str, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... - def runctx( - self, cmd: str | CodeType, globals: Dict[str, Any] | None, locals: Mapping[str, Any] | None - ) -> None: ... + def runctx(self, cmd: str | CodeType, globals: Dict[str, Any] | None, locals: Mapping[str, Any] | None) -> None: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> _T | None: ... class Breakpoint: diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 46ace545416d..654a08f4614f 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -436,10 +436,7 @@ class bytes(ByteString): ) -> int: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( - self, - __suffix: bytes | Tuple[bytes, ...], - __start: SupportsIndex | None = ..., - __end: SupportsIndex | None = ..., + self, __suffix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ... @@ -486,10 +483,7 @@ class bytes(ByteString): def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> List[bytes]: ... def splitlines(self, keepends: bool = ...) -> List[bytes]: ... def startswith( - self, - __prefix: bytes | Tuple[bytes, ...], - __start: SupportsIndex | None = ..., - __end: SupportsIndex | None = ..., + self, __prefix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... def strip(self, __bytes: bytes | None = ...) -> bytes: ... def swapcase(self) -> bytes: ... @@ -542,10 +536,7 @@ class bytearray(MutableSequence[int], ByteString): def copy(self) -> bytearray: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( - self, - __suffix: bytes | Tuple[bytes, ...], - __start: SupportsIndex | None = ..., - __end: SupportsIndex | None = ..., + self, __suffix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ... @@ -594,10 +585,7 @@ class bytearray(MutableSequence[int], ByteString): def split(self, sep: bytes | None = ..., maxsplit: SupportsIndex = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( - self, - __prefix: bytes | Tuple[bytes, ...], - __start: SupportsIndex | None = ..., - __end: SupportsIndex | None = ..., + self, __prefix: bytes | Tuple[bytes, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... def strip(self, __bytes: bytes | None = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... @@ -1242,11 +1230,7 @@ def open( ) -> IO[Any]: ... def ord(__c: str | bytes) -> int: ... def print( - *values: object, - sep: str | None = ..., - end: str | None = ..., - file: SupportsWrite[str] | None = ..., - flush: bool = ..., + *values: object, sep: str | None = ..., end: str | None = ..., file: SupportsWrite[str] | None = ..., flush: bool = ... ) -> None: ... _E = TypeVar("_E", contravariant=True) diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index 971c1fb5307e..1f6848c5134b 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -99,11 +99,7 @@ class BZ2File(BaseStream, IO[bytes]): ) -> None: ... @overload def __init__( - self, - filename: _ReadableFileobj, - mode: _ReadBinaryMode = ..., - buffering: Any | None = ..., - compresslevel: int = ..., + self, filename: _ReadableFileobj, mode: _ReadBinaryMode = ..., buffering: Any | None = ..., compresslevel: int = ... ) -> None: ... @overload def __init__( diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index b2f1c23fa1a5..b9ef8e312aec 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -24,9 +24,7 @@ class Hook: # undocumented file: IO[str] | None = ..., format: str = ..., ) -> None: ... - def __call__( - self, etype: Type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None - ) -> None: ... + def __call__(self, etype: Type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None) -> None: ... def handle(self, info: _ExcInfo | None = ...) -> None: ... def handler(info: _ExcInfo | None = ...) -> None: ... diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 1e9b0454965f..889b4f04fb2a 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -198,9 +198,7 @@ class StreamWriter(Codec): def writelines(self, list: Iterable[str]) -> None: ... def reset(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None - ) -> None: ... + def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... class StreamReader(Codec): @@ -211,9 +209,7 @@ class StreamReader(Codec): def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[str]: ... def reset(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None - ) -> None: ... + def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __iter__(self) -> Iterator[str]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -235,9 +231,7 @@ class StreamReaderWriter(TextIO): # Same as write() def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None - ) -> None: ... + def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str) -> Any: ... # These methods don't actually exist directly, but they are needed to satisfy the TextIO # interface. At runtime, they are delegated through __getattr__. @@ -273,9 +267,7 @@ class StreamRecoder(BinaryIO): def reset(self) -> None: ... def __getattr__(self, name: str) -> Any: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, type: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None - ) -> None: ... + def __exit__(self, type: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ... # These methods don't actually exist directly, but they are needed to satisfy the BinaryIO # interface. At runtime, they are delegated through __getattr__. def seek(self, offset: int, whence: int = ...) -> int: ... diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index f24972423d9a..67eb5b4cefdd 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -37,12 +37,7 @@ if sys.version_info >= (3, 7): else: def namedtuple( - typename: str, - field_names: str | Iterable[str], - *, - verbose: bool = ..., - rename: bool = ..., - module: str | None = ..., + typename: str, field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., module: str | None = ... ) -> Type[Tuple[Any, ...]]: ... class UserDict(MutableMapping[_KT, _VT]): @@ -151,9 +146,7 @@ class UserString(Sequence[str]): if sys.version_info >= (3, 9): def removeprefix(self: _UserStringT, __prefix: str | UserString) -> _UserStringT: ... def removesuffix(self: _UserStringT, __suffix: str | UserString) -> _UserStringT: ... - def replace( - self: _UserStringT, old: str | UserString, new: str | UserString, maxsplit: int = ... - ) -> _UserStringT: ... + def replace(self: _UserStringT, old: str | UserString, new: str | UserString, maxsplit: int = ...) -> _UserStringT: ... def rfind(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def rindex(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def rjust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... @@ -285,9 +278,7 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): @overload def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... @overload - def __init__( - self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT - ) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... def __missing__(self, key: _KT) -> _VT: ... # TODO __reversed__ def copy(self: _S) -> _S: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index c8ae90f6573f..db19582e772d 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -143,9 +143,7 @@ class RawConfigParser(_parser): @overload # type: ignore def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> str: ... @overload - def get( - self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T - ) -> str | _T: ... + def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T) -> str | _T: ... @overload def items(self, *, raw: bool = ..., vars: _section | None = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... @overload @@ -181,15 +179,11 @@ class SectionProxy(MutableMapping[str, str]): @overload def getfloat(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ... @overload - def getfloat( - self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ... - ) -> float | _T: ... + def getfloat(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> float | _T: ... @overload def getboolean(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ... @overload - def getboolean( - self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ... - ) -> bool | _T: ... + def getboolean(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> bool | _T: ... # SectionProxy can have arbitrary attributes when custom converters are used def __getattr__(self, key: str) -> Callable[..., Any]: ... diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index de56117f2d13..69f62575633c 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -81,10 +81,7 @@ class ExitStack(ContextManager[ExitStack]): def close(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, - __exc_type: Type[BaseException] | None, - __exc_value: BaseException | None, - __traceback: TracebackType | None, + self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> bool: ... if sys.version_info >= (3, 7): @@ -103,10 +100,7 @@ if sys.version_info >= (3, 7): def aclose(self) -> Awaitable[None]: ... def __aenter__(self: Self) -> Awaitable[Self]: ... def __aexit__( - self, - __exc_type: Type[BaseException] | None, - __exc_value: BaseException | None, - __traceback: TracebackType | None, + self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> Awaitable[bool]: ... if sys.version_info >= (3, 10): diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index adb4743140df..d7ea65f09189 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -47,12 +47,7 @@ class CDLL(object): ) -> None: ... else: def __init__( - self, - name: str | None, - mode: int = ..., - handle: int | None = ..., - use_errno: bool = ..., - use_last_error: bool = ..., + self, name: str | None, mode: int = ..., handle: int | None = ..., use_errno: bool = ..., use_last_error: bool = ... ) -> None: ... def __getattr__(self, name: str) -> _NamedFuncPointer: ... def __getitem__(self, name: str) -> _NamedFuncPointer: ... diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index 4793709fe7ce..f8bf6844638a 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -35,9 +35,7 @@ class SequenceMatcher(Generic[_T]): def set_seq1(self, a: Sequence[_T]) -> None: ... def set_seq2(self, b: Sequence[_T]) -> None: ... if sys.version_info >= (3, 9): - def find_longest_match( - self, alo: int = ..., ahi: int | None = ..., blo: int = ..., bhi: int | None = ... - ) -> Match: ... + def find_longest_match(self, alo: int = ..., ahi: int | None = ..., blo: int = ..., bhi: int | None = ...) -> Match: ... else: def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ... def get_matching_blocks(self) -> List[Match]: ... diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index 3676ba0bb849..e4a4d2cf477c 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -36,9 +36,7 @@ class Instruction(NamedTuple): class Bytecode: codeobj: types.CodeType first_line: int - def __init__( - self, x: _have_code_or_string, *, first_line: int | None = ..., current_offset: int | None = ... - ) -> None: ... + def __init__(self, x: _have_code_or_string, *, first_line: int | None = ..., current_offset: int | None = ...) -> None: ... def __iter__(self) -> Iterator[Instruction]: ... def __repr__(self) -> str: ... def info(self) -> str: ... diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 24f990691896..7206724bcd6d 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -22,11 +22,7 @@ class FileList: def include_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> bool: ... @overload def include_pattern( - self, - pattern: str | Pattern[str], - anchor: int | bool = ..., - prefix: str | None = ..., - is_regex: int | bool = ..., + self, pattern: str | Pattern[str], anchor: int | bool = ..., prefix: str | None = ..., is_regex: int | bool = ... ) -> bool: ... @overload def exclude_pattern( @@ -36,11 +32,7 @@ class FileList: def exclude_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> bool: ... @overload def exclude_pattern( - self, - pattern: str | Pattern[str], - anchor: int | bool = ..., - prefix: str | None = ..., - is_regex: int | bool = ..., + self, pattern: str | Pattern[str], anchor: int | bool = ..., prefix: str | None = ..., is_regex: int | bool = ... ) -> bool: ... def findall(dir: str = ...) -> List[str]: ... @@ -53,8 +45,5 @@ def translate_pattern( def translate_pattern(pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> Pattern[str]: ... @overload def translate_pattern( - pattern: str | Pattern[str], - anchor: int | bool = ..., - prefix: str | None = ..., - is_regex: int | bool = ..., + pattern: str | Pattern[str], anchor: int | bool = ..., prefix: str | None = ..., is_regex: int | bool = ... ) -> Pattern[str]: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 91f2640cd79a..ba13eaa6db3c 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -69,9 +69,7 @@ class DocTest: class DocTestParser: def parse(self, string: str, name: str = ...) -> List[str | Example]: ... - def get_doctest( - self, string: str, globs: Dict[str, Any], name: str, filename: str | None, lineno: int | None - ) -> DocTest: ... + def get_doctest(self, string: str, globs: Dict[str, Any], name: str, filename: str | None, lineno: int | None) -> DocTest: ... def get_examples(self, string: str, name: str = ...) -> List[Example]: ... class DocTestFinder: @@ -154,12 +152,7 @@ def testfile( encoding: str | None = ..., ) -> TestResults: ... def run_docstring_examples( - f: object, - globs: Dict[str, Any], - verbose: bool = ..., - name: str = ..., - compileflags: int | None = ..., - optionflags: int = ..., + f: object, globs: Dict[str, Any], verbose: bool = ..., name: str = ..., compileflags: int | None = ..., optionflags: int = ... ) -> None: ... def set_unittest_reportflags(flags: int) -> int: ... diff --git a/stdlib/email/generator.pyi b/stdlib/email/generator.pyi index cd0b2285a954..b4dec2a2ff15 100644 --- a/stdlib/email/generator.pyi +++ b/stdlib/email/generator.pyi @@ -6,12 +6,7 @@ class Generator: def clone(self, fp: TextIO) -> Generator: ... def write(self, s: str) -> None: ... def __init__( - self, - outfp: TextIO, - mangle_from_: bool | None = ..., - maxheaderlen: int | None = ..., - *, - policy: Policy | None = ..., + self, outfp: TextIO, mangle_from_: bool | None = ..., maxheaderlen: int | None = ..., *, policy: Policy | None = ... ) -> None: ... def flatten(self, msg: Message, unixfrom: bool = ..., linesep: str | None = ...) -> None: ... @@ -19,12 +14,7 @@ class BytesGenerator: def clone(self, fp: BinaryIO) -> BytesGenerator: ... def write(self, s: str) -> None: ... def __init__( - self, - outfp: BinaryIO, - mangle_from_: bool | None = ..., - maxheaderlen: int | None = ..., - *, - policy: Policy | None = ..., + self, outfp: BinaryIO, mangle_from_: bool | None = ..., maxheaderlen: int | None = ..., *, policy: Policy | None = ... ) -> None: ... def flatten(self, msg: Message, unixfrom: bool = ..., linesep: str | None = ...) -> None: ... diff --git a/stdlib/email/mime/text.pyi b/stdlib/email/mime/text.pyi index 716010b9a6fa..2a800fd01194 100644 --- a/stdlib/email/mime/text.pyi +++ b/stdlib/email/mime/text.pyi @@ -3,6 +3,4 @@ from email.policy import Policy from typing import Optional class MIMEText(MIMENonMultipart): - def __init__( - self, _text: str, _subtype: str = ..., _charset: str | None = ..., *, policy: Policy | None = ... - ) -> None: ... + def __init__(self, _text: str, _subtype: str = ..., _charset: str | None = ..., *, policy: Policy | None = ...) -> None: ... diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 5438d0d5e47d..bc4a2962b823 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -10,10 +10,7 @@ DEFAULT_IGNORES: List[str] def cmp(f1: StrOrBytesPath, f2: StrOrBytesPath, shallow: int | bool = ...) -> bool: ... def cmpfiles( - a: AnyStr | PathLike[AnyStr], - b: AnyStr | PathLike[AnyStr], - common: Iterable[AnyStr], - shallow: int | bool = ..., + a: AnyStr | PathLike[AnyStr], b: AnyStr | PathLike[AnyStr], common: Iterable[AnyStr], shallow: int | bool = ... ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... class dircmp(Generic[AnyStr]): diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index ff5671e6f944..4ecb5d06329c 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -20,11 +20,7 @@ if sys.version_info < (3, 9): class Fraction(Rational): @overload def __new__( - cls: Type[_T], - numerator: int | Rational = ..., - denominator: int | Rational | None = ..., - *, - _normalize: bool = ..., + cls: Type[_T], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ... ) -> _T: ... @overload def __new__(cls: Type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 34f517b1ce4a..60fc79ccc8cb 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -163,20 +163,10 @@ class HTTPConnection: ) -> None: ... else: def __init__( - self, - host: str, - port: int | None = ..., - timeout: float | None = ..., - source_address: Tuple[str, int] | None = ..., + self, host: str, port: int | None = ..., timeout: float | None = ..., source_address: Tuple[str, int] | None = ... ) -> None: ... def request( - self, - method: str, - url: str, - body: _DataType | None = ..., - headers: Mapping[str, str] = ..., - *, - encode_chunked: bool = ..., + self, method: str, url: str, body: _DataType | None = ..., headers: Mapping[str, str] = ..., *, encode_chunked: bool = ... ) -> None: ... def getresponse(self) -> HTTPResponse: ... def set_debuglevel(self, level: int) -> None: ... diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 09434eafcad9..65819695a615 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -34,13 +34,9 @@ class FileCookieJar(CookieJar): filename: str delayload: bool if sys.version_info >= (3, 8): - def __init__( - self, filename: StrPath | None = ..., delayload: bool = ..., policy: CookiePolicy | None = ... - ) -> None: ... + def __init__(self, filename: StrPath | None = ..., delayload: bool = ..., policy: CookiePolicy | None = ...) -> None: ... else: - def __init__( - self, filename: str | None = ..., delayload: bool = ..., policy: CookiePolicy | None = ... - ) -> None: ... + def __init__(self, filename: str | None = ..., delayload: bool = ..., policy: CookiePolicy | None = ...) -> None: ... def save(self, filename: str | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... def load(self, filename: str | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... def revert(self, filename: str | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...) -> None: ... diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index af54a7bb2bc5..7c7660db6e62 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -25,9 +25,7 @@ class ModuleSpec: class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder @classmethod - def find_module( - cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ... - ) -> importlib.abc.Loader | None: ... + def find_module(cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ...) -> importlib.abc.Loader | None: ... @classmethod def find_spec( cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... @@ -52,9 +50,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder @classmethod - def find_module( - cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ... - ) -> importlib.abc.Loader | None: ... + def find_module(cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ...) -> importlib.abc.Loader | None: ... @classmethod def find_spec( cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... @@ -78,9 +74,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): class WindowsRegistryFinder(importlib.abc.MetaPathFinder): @classmethod - def find_module( - cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ... - ) -> importlib.abc.Loader | None: ... + def find_module(cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ...) -> importlib.abc.Loader | None: ... @classmethod def find_spec( cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 348c5d6c2918..f179cdb108aa 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -99,9 +99,7 @@ class islice(Iterator[_T], Generic[_T]): @overload def __init__(self, __iterable: Iterable[_T], __stop: int | None) -> None: ... @overload - def __init__( - self, __iterable: Iterable[_T], __start: int | None, __stop: int | None, __step: int | None = ... - ) -> None: ... + def __init__(self, __iterable: Iterable[_T], __start: int | None, __stop: int | None, __step: int | None = ...) -> None: ... def __iter__(self) -> Iterator[_T]: ... def __next__(self) -> _T: ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index ff0ba49bab93..f78f2864c59d 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -56,12 +56,7 @@ class Leaf(Base): value: str fixers_applied: List[Any] def __init__( - self, - type: int, - value: str, - context: _Context | None = ..., - prefix: str | None = ..., - fixers_applied: List[Any] = ..., + self, type: int, value: str, context: _Context | None = ..., prefix: str | None = ..., fixers_applied: List[Any] = ... ) -> None: ... def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 922d6105e9a5..f01f2455d9e9 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -146,52 +146,22 @@ class Logger(Filterer): ) -> None: ... # undocumented else: def debug( - self, - msg: Any, - *args: Any, - exc_info: _ExcInfoType = ..., - stack_info: bool = ..., - extra: dict[str, Any] | None = ..., + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def info( - self, - msg: Any, - *args: Any, - exc_info: _ExcInfoType = ..., - stack_info: bool = ..., - extra: dict[str, Any] | None = ..., + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def warning( - self, - msg: Any, - *args: Any, - exc_info: _ExcInfoType = ..., - stack_info: bool = ..., - extra: dict[str, Any] | None = ..., + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def warn( - self, - msg: Any, - *args: Any, - exc_info: _ExcInfoType = ..., - stack_info: bool = ..., - extra: dict[str, Any] | None = ..., + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def error( - self, - msg: Any, - *args: Any, - exc_info: _ExcInfoType = ..., - stack_info: bool = ..., - extra: dict[str, Any] | None = ..., + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def critical( - self, - msg: Any, - *args: Any, - exc_info: _ExcInfoType = ..., - stack_info: bool = ..., - extra: dict[str, Any] | None = ..., + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def log( self, @@ -203,12 +173,7 @@ class Logger(Filterer): extra: dict[str, Any] | None = ..., ) -> None: ... def exception( - self, - msg: Any, - *args: Any, - exc_info: _ExcInfoType = ..., - stack_info: bool = ..., - extra: dict[str, Any] | None = ..., + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def _log( self, @@ -626,12 +591,7 @@ else: msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... def log( - level: int, - msg: Any, - *args: Any, - exc_info: _ExcInfoType = ..., - stack_info: bool = ..., - extra: dict[str, Any] | None = ..., + level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: dict[str, Any] | None = ... ) -> None: ... fatal = critical diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index 5adee0b084d7..2558973f63e8 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -31,9 +31,7 @@ if sys.version_info >= (3, 10): else: def fileConfig( - fname: _Path | IO[str] | RawConfigParser, - defaults: dict[str, str] | None = ..., - disable_existing_loggers: bool = ..., + fname: _Path | IO[str] | RawConfigParser, defaults: dict[str, str] | None = ..., disable_existing_loggers: bool = ... ) -> None: ... def valid_ident(s: str) -> Literal[True]: ... # undocumented diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index 3bb7e4ec6fcd..caddc3197a47 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -25,12 +25,7 @@ class WatchedFileHandler(FileHandler): ino: int # undocumented if sys.version_info >= (3, 9): def __init__( - self, - filename: StrPath, - mode: str = ..., - encoding: str | None = ..., - delay: bool = ..., - errors: str | None = ..., + self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ..., errors: str | None = ... ) -> None: ... else: def __init__(self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ...) -> None: ... @@ -180,9 +175,7 @@ class SysLogHandler(Handler): priority_names: ClassVar[dict[str, int]] # undocumented facility_names: ClassVar[dict[str, int]] # undocumented priority_map: ClassVar[dict[str, str]] # undocumented - def __init__( - self, address: tuple[str, int] | str = ..., facility: int = ..., socktype: SocketKind | None = ... - ) -> None: ... + def __init__(self, address: tuple[str, int] | str = ..., facility: int = ..., socktype: SocketKind | None = ...) -> None: ... def encodePriority(self, facility: int | str, priority: int | str) -> int: ... def mapPriority(self, levelName: str) -> str: ... @@ -226,9 +219,7 @@ class MemoryHandler(BufferingHandler): flushLevel: int # undocumented target: Handler | None # undocumented flushOnClose: bool # undocumented - def __init__( - self, capacity: int, flushLevel: int = ..., target: Handler | None = ..., flushOnClose: bool = ... - ) -> None: ... + def __init__(self, capacity: int, flushLevel: int = ..., target: Handler | None = ..., flushOnClose: bool = ...) -> None: ... def setTarget(self, target: Handler | None) -> None: ... class HTTPHandler(Handler): diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index 763f2f7bf544..5321dc27de56 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -41,9 +41,7 @@ PRESET_EXTREME: int # from _lzma.c class LZMADecompressor(object): - def __init__( - self, format: int | None = ..., memlimit: int | None = ..., filters: _FilterChain | None = ... - ) -> None: ... + def __init__(self, format: int | None = ..., memlimit: int | None = ..., filters: _FilterChain | None = ...) -> None: ... def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... @property def check(self) -> int: ... diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index b8a28d42bc77..71acfba1936c 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -152,9 +152,7 @@ class MaildirMessage(Message): class _mboxMMDFMessage(Message): def get_from(self) -> str: ... - def set_from( - self, from_: str, time_: bool | Tuple[int, int, int, int, int, int, int, int, int] | None = ... - ) -> None: ... + def set_from(self, from_: str, time_: bool | Tuple[int, int, int, int, int, int, int, int, int] | None = ...) -> None: ... def get_flags(self) -> str: ... def set_flags(self, flags: Iterable[str]) -> None: ... def add_flag(self, flag: str) -> None: ... @@ -190,9 +188,7 @@ class _ProxyFile(Generic[AnyStr]): def seek(self, offset: int, whence: int = ...) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None - ) -> None: ... + def __exit__(self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... def seekable(self) -> bool: ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index acecb1f51683..e760cc701a38 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -26,9 +26,7 @@ if sys.platform != "win32": class mmap(ContextManager[mmap], Iterable[int], Sized): if sys.platform == "win32": - def __init__( - self, fileno: int, length: int, tagname: str | None = ..., access: int = ..., offset: int = ... - ) -> None: ... + def __init__(self, fileno: int, length: int, tagname: str | None = ..., access: int = ..., offset: int = ...) -> None: ... else: def __init__( self, fileno: int, length: int, flags: int = ..., prot: int = ..., access: int = ..., offset: int = ... diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 1b25db5b5ca9..26b1bd31f9dd 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -88,9 +88,7 @@ if sys.platform == "win32": uuid: str | None = ..., ) -> None: ... def make_short(self, file: str) -> str: ... - def add_file( - self, file: str, src: str | None = ..., version: str | None = ..., language: str | None = ... - ) -> str: ... + def add_file(self, file: str, src: str | None = ..., version: str | None = ..., language: str | None = ...) -> str: ... def glob(self, pattern: str, exclude: Container[str] | None = ...) -> List[str]: ... def remove_pyc(self) -> None: ... class Binary: @@ -171,26 +169,8 @@ if sys.platform == "win32": self, name: str, x: int, y: int, w: int, h: int, attr: int, text: str | None, next: str | None ) -> Control: ... def radiogroup( - self, - name: str, - x: int, - y: int, - w: int, - h: int, - attr: int, - prop: str | None, - text: str | None, - next: str | None, + self, name: str, x: int, y: int, w: int, h: int, attr: int, prop: str | None, text: str | None, next: str | None ) -> RadioButtonGroup: ... def checkbox( - self, - name: str, - x: int, - y: int, - w: int, - h: int, - attr: int, - prop: str | None, - text: str | None, - next: str | None, + self, name: str, x: int, y: int, w: int, h: int, attr: int, prop: str | None, text: str | None, next: str | None ) -> Control: ... diff --git a/stdlib/msilib/schema.pyi b/stdlib/msilib/schema.pyi index f7f71edff390..1b3b1dc86c46 100644 --- a/stdlib/msilib/schema.pyi +++ b/stdlib/msilib/schema.pyi @@ -92,6 +92,4 @@ if sys.platform == "win32": tables: List[Table] - _Validation_records: List[ - Tuple[str, str, str, int | None, int | None, str | None, int | None, str | None, str | None, str] - ] + _Validation_records: List[Tuple[str, str, str, int | None, int | None, str | None, int | None, str | None, str | None, str]] diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index 18b3b2910ca5..fc648ca5f63f 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -75,16 +75,10 @@ class BaseContext(object): @overload def Value(self, typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ... @overload - def Array( - self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False] - ) -> _CT: ... + def Array(self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]) -> _CT: ... @overload def Array( - self, - typecode_or_type: Type[_CT], - size_or_initializer: int | Sequence[Any], - *, - lock: Literal[True] | _LockLike, + self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike ) -> SynchronizedArray[_CT]: ... @overload def Array( @@ -92,11 +86,7 @@ class BaseContext(object): ) -> SynchronizedArray[Any]: ... @overload def Array( - self, - typecode_or_type: str | Type[_CData], - size_or_initializer: int | Sequence[Any], - *, - lock: bool | _LockLike = ..., + self, typecode_or_type: str | Type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ... ) -> Any: ... def freeze_support(self) -> None: ... def get_logger(self) -> Logger: ... diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index 55fda28bf776..f2feeeb83af4 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -43,9 +43,7 @@ class Value: def Array(typecode: Any, sequence: Sequence[Any], lock: Any = ...) -> array.array[Any]: ... def Manager() -> Any: ... -def Pool( - processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ... -) -> Any: ... +def Pool(processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ...) -> Any: ... def active_children() -> List[Any]: ... def current_process() -> threading.Thread: ... def freeze_support() -> None: ... diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 43cd91d7dccb..175127785a77 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -47,16 +47,10 @@ class Token(object): typeid: str | bytes | None address: Tuple[str | bytes, int] id: str | bytes | int | None - def __init__( - self, typeid: bytes | str | None, address: Tuple[str | bytes, int], id: str | bytes | int | None - ) -> None: ... + def __init__(self, typeid: bytes | str | None, address: Tuple[str | bytes, int], id: str | bytes | int | None) -> None: ... def __repr__(self) -> str: ... - def __getstate__( - self, - ) -> Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]: ... - def __setstate__( - self, state: Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None] - ) -> None: ... + def __getstate__(self) -> Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]: ... + def __setstate__(self, state: Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]) -> None: ... class BaseProxy(object): _address_to_local: Dict[Any, Any] @@ -94,11 +88,7 @@ class Server: class BaseManager(ContextManager[BaseManager]): def __init__( - self, - address: Any | None = ..., - authkey: bytes | None = ..., - serializer: str = ..., - ctx: BaseContext | None = ..., + self, address: Any | None = ..., authkey: bytes | None = ..., serializer: str = ..., ctx: BaseContext | None = ... ) -> None: ... def get_server(self) -> Server: ... def connect(self) -> None: ... diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index 4b02927be3f7..379b97ca8c4c 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -33,11 +33,7 @@ def Value( ) -> Any: ... @overload def Array( - typecode_or_type: Type[_CT], - size_or_initializer: int | Sequence[Any], - *, - lock: Literal[False], - ctx: BaseContext | None = ..., + typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = ... ) -> _CT: ... @overload def Array( diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 8263029158cc..a77514dd4bd3 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -54,9 +54,7 @@ class _NNTPBase: def debug(self, level: int) -> None: ... def capabilities(self) -> Tuple[str, Dict[str, List[str]]]: ... def newgroups(self, date: datetime.date | datetime.datetime, *, file: _File = ...) -> Tuple[str, List[str]]: ... - def newnews( - self, group: str, date: datetime.date | datetime.datetime, *, file: _File = ... - ) -> Tuple[str, List[str]]: ... + def newnews(self, group: str, date: datetime.date | datetime.datetime, *, file: _File = ...) -> Tuple[str, List[str]]: ... def list(self, group_pattern: str | None = ..., *, file: _File = ...) -> Tuple[str, List[str]]: ... def description(self, group: str) -> str: ... def descriptions(self, group_pattern: str) -> Tuple[str, Dict[str, str]]: ... diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index 047dbffa8feb..791636be7122 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -215,9 +215,7 @@ class OptionParser(OptionContainer): def get_prog_name(self) -> str: ... def get_usage(self) -> str: ... def get_version(self) -> str: ... - def parse_args( - self, args: Sequence[AnyStr] | None = ..., values: Values | None = ... - ) -> Tuple[Values, List[AnyStr]]: ... + def parse_args(self, args: Sequence[AnyStr] | None = ..., values: Values | None = ...) -> Tuple[Values, List[AnyStr]]: ... def print_usage(self, file: IO[str] | None = ...) -> None: ... def print_help(self, file: IO[str] | None = ...) -> None: ... def print_version(self, file: IO[str] | None = ...) -> None: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 363973d18503..eb318b5fa1a3 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -636,13 +636,9 @@ if sys.platform != "win32": def readlink(path: AnyStr | PathLike[AnyStr], *, dir_fd: int | None = ...) -> AnyStr: ... def remove(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... def removedirs(name: StrOrBytesPath) -> None: ... -def rename( - src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ... -) -> None: ... +def rename(src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ...) -> None: ... def renames(old: StrOrBytesPath, new: StrOrBytesPath) -> None: ... -def replace( - src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ... -) -> None: ... +def replace(src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ...) -> None: ... def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): @@ -674,9 +670,7 @@ if sys.version_info < (3, 7): if sys.platform != "win32": def statvfs(path: _FdOrAnyPath) -> statvfs_result: ... # Unix only -def symlink( - src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: int | None = ... -) -> None: ... +def symlink(src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: int | None = ...) -> None: ... if sys.platform != "win32": def sync() -> None: ... # Unix only diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 11f0618e2da8..948a3a96b654 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -138,12 +138,7 @@ class Path(PurePath): # Fallback if mode is not specified @overload def open( - self, - mode: str, - buffering: int = ..., - encoding: str | None = ..., - errors: str | None = ..., - newline: str | None = ..., + self, mode: str, buffering: int = ..., encoding: str | None = ..., errors: str | None = ..., newline: str | None = ... ) -> IO[Any]: ... def owner(self) -> str: ... if sys.version_info >= (3, 9): diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index 2cfadf05ec73..b4a21bae7493 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -15,23 +15,13 @@ if sys.version_info >= (3, 8): def release(self) -> None: ... _BufferCallback = Optional[Callable[[PickleBuffer], Any]] def dump( - obj: Any, - file: IO[bytes], - protocol: int | None = ..., - *, - fix_imports: bool = ..., - buffer_callback: _BufferCallback = ..., + obj: Any, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... ) -> None: ... def dumps( obj: Any, protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... ) -> bytes: ... def load( - file: IO[bytes], - *, - fix_imports: bool = ..., - encoding: str = ..., - errors: str = ..., - buffers: Iterable[Any] | None = ..., + file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ... ) -> Any: ... def loads( __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ... @@ -63,12 +53,7 @@ class Pickler: if sys.version_info >= (3, 8): def __init__( - self, - file: IO[bytes], - protocol: int | None = ..., - *, - fix_imports: bool = ..., - buffer_callback: _BufferCallback = ..., + self, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... ) -> None: ... def reducer_override(self, obj: Any) -> Any: ... else: diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index 0f75cf82c8a0..eb37c6a50987 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -7,9 +7,7 @@ if sys.version_info < (3, 8): from typing import NamedTuple, Optional, Tuple if sys.version_info >= (3, 8): - def libc_ver( - executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ... - ) -> Tuple[str, str]: ... + def libc_ver(executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ... else: def libc_ver(executable: str = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ... diff --git a/stdlib/pprint.pyi b/stdlib/pprint.pyi index f32b58427e37..f59ff86f1be0 100644 --- a/stdlib/pprint.pyi +++ b/stdlib/pprint.pyi @@ -25,9 +25,7 @@ elif sys.version_info >= (3, 8): ) -> str: ... else: - def pformat( - object: object, indent: int = ..., width: int = ..., depth: int | None = ..., *, compact: bool = ... - ) -> str: ... + def pformat(object: object, indent: int = ..., width: int = ..., depth: int | None = ..., *, compact: bool = ...) -> str: ... if sys.version_info >= (3, 10): def pp( diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index 77a342edb861..8f4f35979531 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -11,13 +11,7 @@ class Class: if sys.version_info >= (3, 7): def __init__( - self, - module: str, - name: str, - super: List[Class | str] | None, - file: str, - lineno: int, - parent: Class | None = ..., + self, module: str, name: str, super: List[Class | str] | None, file: str, lineno: int, parent: Class | None = ... ) -> None: ... else: def __init__(self, module: str, name: str, super: List[Class | str] | None, file: str, lineno: int) -> None: ... diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 4b0e9b5f7819..30e869253fb6 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -163,11 +163,7 @@ class TextDoc(Doc): def indent(self, text: str, prefix: str = ...) -> str: ... def section(self, title: str, contents: str) -> str: ... def formattree( - self, - tree: List[Tuple[type, Tuple[type, ...]] | List[Any]], - modname: str, - parent: type | None = ..., - prefix: str = ..., + self, tree: List[Tuple[type, Tuple[type, ...]] | List[Any]], modname: str, parent: type | None = ..., prefix: str = ... ) -> str: ... def docmodule(self, object: object, name: str | None = ..., mod: Any | None = ..., *ignored: Any) -> str: ... def docclass(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... @@ -209,9 +205,7 @@ class _OldStyleClass: ... def resolve(thing: str | object, forceload: bool = ...) -> Tuple[object, str] | None: ... def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Doc | None = ...) -> str: ... -def doc( - thing: str | object, title: str = ..., forceload: bool = ..., output: SupportsWrite[str] | None = ... -) -> None: ... +def doc(thing: str | object, title: str = ..., forceload: bool = ..., output: SupportsWrite[str] | None = ...) -> None: ... def writedoc(thing: str | object, forceload: bool = ...) -> None: ... def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index cdb9bec1e63e..3cdb2520ec33 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -48,7 +48,9 @@ class XMLParserType(object): EndDoctypeDeclHandler: Callable[[], Any] | None ElementDeclHandler: Callable[[str, _Model], Any] | None AttlistDeclHandler: Callable[[str, str, str, str | None, bool], Any] | None - StartElementHandler: Callable[[str, Dict[str, str]], Any] | Callable[[str, List[str]], Any] | Callable[[str, Dict[str, str], List[str]], Any] | None + StartElementHandler: Callable[[str, Dict[str, str]], Any] | Callable[[str, List[str]], Any] | Callable[ + [str, Dict[str, str], List[str]], Any + ] | None EndElementHandler: Callable[[str], Any] | None ProcessingInstructionHandler: Callable[[str, str], Any] | None CharacterDataHandler: Callable[[str], Any] | None diff --git a/stdlib/random.pyi b/stdlib/random.pyi index b7b5b2577591..db4683355af9 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -27,9 +27,7 @@ class Random(_random.Random): ) -> list[_T]: ... def shuffle(self, x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ... if sys.version_info >= (3, 9): - def sample( - self, population: Sequence[_T] | Set[_T], k: int, *, counts: Iterable[_T] | None = ... - ) -> list[_T]: ... + def sample(self, population: Sequence[_T] | Set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ... else: def sample(self, population: Sequence[_T] | Set[_T], k: int) -> list[_T]: ... def random(self) -> float: ... @@ -63,11 +61,7 @@ if sys.version_info >= (3, 9): def choice(seq: Sequence[_T]) -> _T: ... def choices( - population: Sequence[_T], - weights: Sequence[float] | None = ..., - *, - cum_weights: Sequence[float] | None = ..., - k: int = ..., + population: Sequence[_T], weights: Sequence[float] | None = ..., *, cum_weights: Sequence[float] | None = ..., k: int = ... ) -> list[_T]: ... def shuffle(x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ... diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index e8d8324793b7..a648358382be 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -44,9 +44,7 @@ else: ignore_dangling_symlinks: bool = ..., ) -> _PathReturn: ... -def rmtree( - path: bytes | StrPath, ignore_errors: bool = ..., onerror: Callable[[Any, Any, Any], Any] | None = ... -) -> None: ... +def rmtree(path: bytes | StrPath, ignore_errors: bool = ..., onerror: Callable[[Any, Any, Any], Any] | None = ...) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index d72e98af1e89..91cde355444f 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -109,9 +109,7 @@ class SMTP: def auth_plain(self, challenge: bytes | None = ...) -> str: ... def auth_login(self, challenge: bytes | None = ...) -> str: ... def login(self, user: str, password: str, *, initial_response_ok: bool = ...) -> _Reply: ... - def starttls( - self, keyfile: str | None = ..., certfile: str | None = ..., context: SSLContext | None = ... - ) -> _Reply: ... + def starttls(self, keyfile: str | None = ..., certfile: str | None = ..., context: SSLContext | None = ...) -> _Reply: ... def sendmail( self, from_addr: str, @@ -152,9 +150,5 @@ LMTP_PORT: int class LMTP(SMTP): def __init__( - self, - host: str = ..., - port: int = ..., - local_hostname: str | None = ..., - source_address: _SourceAddress | None = ..., + self, host: str = ..., port: int = ..., local_hostname: str | None = ..., source_address: _SourceAddress | None = ... ) -> None: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index c6261df9686a..7def99e735d0 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -539,11 +539,7 @@ if sys.platform == "win32": class socket(_socket.socket): def __init__( - self, - family: AddressFamily | int = ..., - type: SocketKind | int = ..., - proto: int = ..., - fileno: int | None = ..., + self, family: AddressFamily | int = ..., type: SocketKind | int = ..., proto: int = ..., fileno: int | None = ... ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: object) -> None: ... diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index dfa978715fc6..6bbfd69b89f8 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -326,9 +326,7 @@ class SSLSocket(socket.socket): @overload def sendto(self, data: ReadableBuffer, flags_or_addr: socket._Address) -> int: ... @overload - def sendto( - self, data: ReadableBuffer, flags_or_addr: int | socket._Address, addr: socket._Address | None = ... - ) -> int: ... + def sendto(self, data: ReadableBuffer, flags_or_addr: int | socket._Address, addr: socket._Address | None = ...) -> int: ... def shutdown(self, how: int) -> None: ... def read(self, len: int = ..., buffer: bytearray | None = ...) -> bytes: ... def write(self, data: bytes) -> int: ... @@ -382,9 +380,7 @@ class SSLContext: def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> SSLContext: ... def __init__(self, protocol: int = ...) -> None: ... def cert_store_stats(self) -> Dict[str, int]: ... - def load_cert_chain( - self, certfile: StrPath, keyfile: StrPath | None = ..., password: _PasswordType | None = ... - ) -> None: ... + def load_cert_chain(self, certfile: StrPath, keyfile: StrPath | None = ..., password: _PasswordType | None = ...) -> None: ... def load_default_certs(self, purpose: Purpose = ...) -> None: ... def load_verify_locations( self, cafile: StrPath | None = ..., capath: StrPath | None = ..., cadata: str | bytes | None = ... @@ -429,9 +425,7 @@ class SSLObject: if sys.version_info >= (3, 7): def __init__(self, *args: Any, **kwargs: Any) -> None: ... else: - def __init__( - self, sslobj: Any, owner: SSLSocket | SSLObject | None = ..., session: Any | None = ... - ) -> None: ... + def __init__(self, sslobj: Any, owner: SSLSocket | SSLObject | None = ..., session: Any | None = ...) -> None: ... def read(self, len: int = ..., buffer: bytearray | None = ...) -> bytes: ... def write(self, data: bytes) -> int: ... @overload diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index 9ec01c71cfea..3078b5a000d3 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -34,9 +34,7 @@ _PathSequence = Sequence[Union[bytes, str]] # Unlike importlib.abc.MetaPathFinder, invalidate_caches() might not exist (see python docs) class _MetaPathFinder(Protocol): def find_module(self, fullname: str, path: _PathSequence | None) -> Loader | None: ... - def find_spec( - self, fullname: str, path: _PathSequence | None, target: ModuleType | None = ... - ) -> ModuleSpec | None: ... + def find_spec(self, fullname: str, path: _PathSequence | None, target: ModuleType | None = ...) -> ModuleSpec | None: ... # ----- sys variables ----- if sys.platform != "win32": diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index b0c3bce26fe9..1e2e354a61a4 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -297,9 +297,7 @@ class TarFile: filter: Callable[[TarInfo], TarInfo | None] | None = ..., ) -> None: ... def addfile(self, tarinfo: TarInfo, fileobj: IO[bytes] | None = ...) -> None: ... - def gettarinfo( - self, name: str | None = ..., arcname: str | None = ..., fileobj: IO[bytes] | None = ... - ) -> TarInfo: ... + def gettarinfo(self, name: str | None = ..., arcname: str | None = ..., fileobj: IO[bytes] | None = ...) -> TarInfo: ... def close(self) -> None: ... if sys.version_info >= (3, 9): diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index b552875b2e96..eec652464f20 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -169,9 +169,7 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): delete: bool def __init__(self, file: IO[AnyStr], name: str, delete: bool = ...) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None - ) -> bool | None: ... + def __exit__(self, exc: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> bool | None: ... def __getattr__(self, name: str) -> Any: ... def close(self) -> None: ... # These methods don't exist directly on this object, but @@ -326,9 +324,7 @@ class TemporaryDirectory(Generic[AnyStr]): @overload def __init__(self: TemporaryDirectory[str], suffix: None = ..., prefix: None = ..., dir: None = ...) -> None: ... @overload - def __init__( - self, suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ... - ) -> None: ... + def __init__(self, suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ...) -> None: ... def cleanup(self) -> None: ... def __enter__(self) -> AnyStr: ... def __exit__( diff --git a/stdlib/time.pyi b/stdlib/time.pyi index e50cf4549b55..34867104db1c 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -51,12 +51,16 @@ class _struct_time(NamedTuple): class struct_time(_struct_time): def __init__( self, - o: Tuple[int, int, int, int, int, int, int, int, int] | Tuple[int, int, int, int, int, int, int, int, int, str] | Tuple[int, int, int, int, int, int, int, int, int, str, int], + o: Tuple[int, int, int, int, int, int, int, int, int] + | Tuple[int, int, int, int, int, int, int, int, int, str] + | Tuple[int, int, int, int, int, int, int, int, int, str, int], _arg: Any = ..., ) -> None: ... def __new__( cls, - o: Tuple[int, int, int, int, int, int, int, int, int] | Tuple[int, int, int, int, int, int, int, int, int, str] | Tuple[int, int, int, int, int, int, int, int, int, str, int], + o: Tuple[int, int, int, int, int, int, int, int, int] + | Tuple[int, int, int, int, int, int, int, int, int, str] + | Tuple[int, int, int, int, int, int, int, int, int, str, int], _arg: Any = ..., ) -> struct_time: ... @property diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 71931e7525ac..0b26d99f3371 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -367,11 +367,7 @@ class Misc: def bind_all(self, *, func: str, add: bool | None = ...) -> None: ... @overload def bind_class( - self, - className: str, - sequence: str | None = ..., - func: Callable[[Event[Misc]], Any] | None = ..., - add: bool | None = ..., + self, className: str, sequence: str | None = ..., func: Callable[[Event[Misc]], Any] | None = ..., add: bool | None = ... ) -> str: ... @overload def bind_class(self, className: str, sequence: str | None, func: str, add: bool | None = ...) -> None: ... @@ -521,11 +517,7 @@ class Wm: def wm_geometry(self, newGeometry: str) -> None: ... geometry = wm_geometry def wm_grid( - self, - baseWidth: Any | None = ..., - baseHeight: Any | None = ..., - widthInc: Any | None = ..., - heightInc: Any | None = ..., + self, baseWidth: Any | None = ..., baseHeight: Any | None = ..., widthInc: Any | None = ..., heightInc: Any | None = ... ): ... grid = wm_grid def wm_group(self, pathName: Any | None = ...): ... @@ -1298,9 +1290,7 @@ class Canvas(Widget, XView, YView): itemconfig = itemconfigure def move(self, *args): ... if sys.version_info >= (3, 8): - def moveto( - self, tagOrId: str | _CanvasItemId, x: Literal[""] | float = ..., y: Literal[""] | float = ... - ) -> None: ... + def moveto(self, tagOrId: str | _CanvasItemId, x: Literal[""] | float = ..., y: Literal[""] | float = ...) -> None: ... def postscript(self, cnf=..., **kw): ... # tkinter does: # lower = tag_lower @@ -2745,12 +2735,8 @@ class Text(Widget, XView, YView): def tag_delete(self, __first_tag_name: str, *tagNames: str) -> None: ... # error if no tag names given def tag_lower(self, tagName: str, belowThis: str | None = ...) -> None: ... def tag_names(self, index: _TextIndex | None = ...) -> Tuple[str, ...]: ... - def tag_nextrange( - self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ... - ) -> Tuple[str, str] | Tuple[()]: ... - def tag_prevrange( - self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ... - ) -> Tuple[str, str] | Tuple[()]: ... + def tag_nextrange(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> Tuple[str, str] | Tuple[()]: ... + def tag_prevrange(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> Tuple[str, str] | Tuple[()]: ... def tag_raise(self, tagName: str, aboveThis: str | None = ...) -> None: ... def tag_ranges(self, tagName: str) -> Tuple[_tkinter.Tcl_Obj, ...]: ... # tag_remove and tag_delete are different @@ -2792,9 +2778,7 @@ class _Image(Protocol): class Image: name: Any tk: _tkinter.TkappType - def __init__( - self, imgtype, name: Any | None = ..., cnf=..., master: Misc | _tkinter.TkappType | None = ..., **kw - ): ... + def __init__(self, imgtype, name: Any | None = ..., cnf=..., master: Misc | _tkinter.TkappType | None = ..., **kw): ... def __del__(self): ... def __setitem__(self, key, value): ... def __getitem__(self, key): ... @@ -2838,12 +2822,8 @@ class PhotoImage(Image): def zoom(self, x: int, y: int | Literal[""] = ...) -> PhotoImage: ... def subsample(self, x: int, y: int | Literal[""] = ...) -> PhotoImage: ... def get(self, x: int, y: int) -> Tuple[int, int, int]: ... - def put( - self, data: str | _TkinterSequence[str] | _TkinterSequence2D[_Color], to: Tuple[int, int] | None = ... - ) -> None: ... - def write( - self, filename: StrOrBytesPath, format: str | None = ..., from_coords: Tuple[int, int] | None = ... - ) -> None: ... + def put(self, data: str | _TkinterSequence[str] | _TkinterSequence2D[_Color], to: Tuple[int, int] | None = ...) -> None: ... + def write(self, filename: StrOrBytesPath, format: str | None = ..., from_coords: Tuple[int, int] | None = ...) -> None: ... if sys.version_info >= (3, 8): def transparency_get(self, x: int, y: int) -> bool: ... def transparency_set(self, x: int, y: int, boolean: bool) -> None: ... diff --git a/stdlib/tkinter/colorchooser.pyi b/stdlib/tkinter/colorchooser.pyi index 23b31f34b17d..a0f7e79a9f6f 100644 --- a/stdlib/tkinter/colorchooser.pyi +++ b/stdlib/tkinter/colorchooser.pyi @@ -4,6 +4,4 @@ from typing import Any, ClassVar, Optional, Tuple, Union class Chooser(Dialog): command: ClassVar[str] -def askcolor( - color: str | bytes | None = ..., **options: Any -) -> Tuple[None, None] | Tuple[Tuple[float, float, float], str]: ... +def askcolor(color: str | bytes | None = ..., **options: Any) -> Tuple[None, None] | Tuple[Tuple[float, float, float], str]: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index d5d8e987a07f..33a12208f14c 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -61,9 +61,7 @@ class TixWidget(tkinter.Widget): def subwidget(self, name: str) -> tkinter.Widget: ... def subwidgets_all(self) -> List[tkinter.Widget]: ... def config_all(self, option: Any, value: Any) -> None: ... - def image_create( - self, imgtype: str, cnf: Dict[str, Any] = ..., master: tkinter.Widget | None = ..., **kw: Any - ) -> None: ... + def image_create(self, imgtype: str, cnf: Dict[str, Any] = ..., master: tkinter.Widget | None = ..., **kw: Any) -> None: ... def image_delete(self, imgname: str) -> None: ... class TixSubWidget(TixWidget): @@ -72,9 +70,7 @@ class TixSubWidget(TixWidget): ) -> None: ... class DisplayStyle: - def __init__( - self, itemtype: str, cnf: Dict[str, Any] = ..., *, master: tkinter.Widget | None = ..., **kw: Any - ) -> None: ... + def __init__(self, itemtype: str, cnf: Dict[str, Any] = ..., *, master: tkinter.Widget | None = ..., **kw: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... def __setitem__(self, key: str, value: Any) -> None: ... def delete(self) -> None: ... diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index 6de05c0fd3d2..ab4015f2ffc7 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -38,10 +38,7 @@ class Trace: ) -> None: ... def run(self, cmd: str | types.CodeType) -> None: ... def runctx( - self, - cmd: str | types.CodeType, - globals: Mapping[str, Any] | None = ..., - locals: Mapping[str, Any] | None = ..., + self, cmd: str | types.CodeType, globals: Mapping[str, Any] | None = ..., locals: Mapping[str, Any] | None = ... ) -> None: ... if sys.version_info >= (3, 9): def runfunc(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 08a694da5eb8..04843950ab79 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -18,12 +18,7 @@ class Filter: filename_pattern: str all_frames: bool def __init__( - self, - inclusive: bool, - filename_pattern: str, - lineno: int | None = ..., - all_frames: bool = ..., - domain: int | None = ..., + self, inclusive: bool, filename_pattern: str, lineno: int | None = ..., all_frames: bool = ..., domain: int | None = ... ) -> None: ... class Statistic: diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 460118b34cfb..b1fa497a59d3 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -28,12 +28,7 @@ class TurtleScreenBase(object): def mainloop(self) -> None: ... def textinput(self, title: str, prompt: str) -> str | None: ... def numinput( - self, - title: str, - prompt: str, - default: float | None = ..., - minval: float | None = ..., - maxval: float | None = ..., + self, title: str, prompt: str, default: float | None = ..., minval: float | None = ..., maxval: float | None = ... ) -> float | None: ... class Terminator(Exception): ... @@ -275,11 +270,7 @@ class _Screen(TurtleScreen): def __init__(self) -> None: ... # Note int and float are interpreted differently, hence the Union instead of just float def setup( - self, - width: int | float = ..., - height: int | float = ..., - startx: int | None = ..., - starty: int | None = ..., + self, width: int | float = ..., height: int | float = ..., startx: int | None = ..., starty: int | None = ... ) -> None: ... def title(self, titlestring: str) -> None: ... def bye(self) -> None: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index c54d582a5dc7..ff1958e439f8 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -422,10 +422,7 @@ class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): class ContextManager(Protocol[_T_co]): def __enter__(self) -> _T_co: ... def __exit__( - self, - __exc_type: Type[BaseException] | None, - __exc_value: BaseException | None, - __traceback: TracebackType | None, + self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> bool | None: ... @runtime_checkable diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 767da2c6af72..6ba076574a78 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -92,9 +92,7 @@ class TestCase: **kwargs: Any, ) -> None: ... @overload - def assertRaises( - self, expected_exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ... - ) -> _AssertRaisesContext[_E]: ... + def assertRaises(self, expected_exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... @overload def assertRaisesRegex( # type: ignore self, @@ -113,16 +111,10 @@ class TestCase: ) -> _AssertRaisesContext[_E]: ... @overload def assertWarns( # type: ignore - self, - expected_warning: Type[Warning] | Tuple[Type[Warning], ...], - callable: Callable[..., Any], - *args: Any, - **kwargs: Any, + self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any ) -> None: ... @overload - def assertWarns( - self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], msg: Any = ... - ) -> _AssertWarnsContext: ... + def assertWarns(self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ... @overload def assertWarnsRegex( # type: ignore self, @@ -139,9 +131,7 @@ class TestCase: expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertWarnsContext: ... - def assertLogs( - self, logger: str | logging.Logger | None = ..., level: int | str | None = ... - ) -> _AssertLogsContext: ... + def assertLogs(self, logger: str | logging.Logger | None = ..., level: int | str | None = ...) -> _AssertLogsContext: ... @overload def assertAlmostEqual( self, first: float, second: float, places: int | None = ..., msg: Any = ..., delta: float | None = ... diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index c55fc6fd969d..936f312cb196 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -20,9 +20,7 @@ class TestResult: buffer: bool failfast: bool tb_locals: bool - def __init__( - self, stream: TextIO | None = ..., descriptions: bool | None = ..., verbosity: int | None = ... - ) -> None: ... + def __init__(self, stream: TextIO | None = ..., descriptions: bool | None = ..., verbosity: int | None = ...) -> None: ... def printErrors(self) -> None: ... def wasSuccessful(self) -> bool: ... def stop(self) -> None: ... @@ -36,6 +34,4 @@ class TestResult: def addSkip(self, test: unittest.case.TestCase, reason: str) -> None: ... def addExpectedFailure(self, test: unittest.case.TestCase, err: _SysExcInfoType) -> None: ... def addUnexpectedSuccess(self, test: unittest.case.TestCase) -> None: ... - def addSubTest( - self, test: unittest.case.TestCase, subtest: unittest.case.TestCase, err: _SysExcInfoType | None - ) -> None: ... + def addSubTest(self, test: unittest.case.TestCase, subtest: unittest.case.TestCase, err: _SysExcInfoType | None) -> None: ... diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 087536556006..8977cd64a4f6 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -137,8 +137,6 @@ def urlunparse( @overload def urlunparse(components: Sequence[AnyStr | None]) -> AnyStr: ... @overload -def urlunsplit( - components: Tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None] -) -> AnyStr: ... +def urlunsplit(components: Tuple[AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None, AnyStr | None]) -> AnyStr: ... @overload def urlunsplit(components: Sequence[AnyStr | None]) -> AnyStr: ... diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 16059b1dd5dd..3a642fbdfa8a 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -331,12 +331,8 @@ class FancyURLopener(URLopener): def redirect_internal( self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: HTTPMessage, data: bytes | None ) -> _UrlopenRet | None: ... # undocumented - def retry_http_basic_auth( - self, url: str, realm: str, data: bytes | None = ... - ) -> _UrlopenRet | None: ... # undocumented - def retry_https_basic_auth( - self, url: str, realm: str, data: bytes | None = ... - ) -> _UrlopenRet | None: ... # undocumented + def retry_http_basic_auth(self, url: str, realm: str, data: bytes | None = ...) -> _UrlopenRet | None: ... # undocumented + def retry_https_basic_auth(self, url: str, realm: str, data: bytes | None = ...) -> _UrlopenRet | None: ... # undocumented def retry_proxy_http_basic_auth( self, url: str, realm: str, data: bytes | None = ... ) -> _UrlopenRet | None: ... # undocumented diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index e40a17746b45..cc848865f8ae 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -5,16 +5,9 @@ from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit def showwarning( - message: Warning | str, - category: Type[Warning], - filename: str, - lineno: int, - file: TextIO | None = ..., - line: str | None = ..., + message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... ) -> None: ... -def formatwarning( - message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ... -) -> str: ... +def formatwarning(message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ... def filterwarnings( action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ... ) -> None: ... diff --git a/stdlib/xml/dom/domreg.pyi b/stdlib/xml/dom/domreg.pyi index cbd861f3709f..aba2fcd59ca7 100644 --- a/stdlib/xml/dom/domreg.pyi +++ b/stdlib/xml/dom/domreg.pyi @@ -5,6 +5,4 @@ well_known_implementations: Dict[str, str] registered: Dict[str, Callable[[], DOMImplementation]] def registerDOMImplementation(name: str, factory: Callable[[], DOMImplementation]) -> None: ... -def getDOMImplementation( - name: str | None = ..., features: str | Iterable[Tuple[str, str | None]] = ... -) -> DOMImplementation: ... +def getDOMImplementation(name: str | None = ..., features: str | Iterable[Tuple[str, str | None]] = ...) -> DOMImplementation: ... diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index 547e88ee490d..c2c581b9ffbb 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -18,9 +18,7 @@ class Node(xml.dom.Node): prefix: Any if sys.version_info >= (3, 9): def toxml(self, encoding: Any | None = ..., standalone: Any | None = ...): ... - def toprettyxml( - self, indent: str = ..., newl: str = ..., encoding: Any | None = ..., standalone: Any | None = ... - ): ... + def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Any | None = ..., standalone: Any | None = ...): ... else: def toxml(self, encoding: Any | None = ...): ... def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Any | None = ...): ... diff --git a/stdlib/xml/dom/pulldom.pyi b/stdlib/xml/dom/pulldom.pyi index 65dd761bcbaa..15422684c71d 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -65,7 +65,5 @@ class SAX2DOM(PullDOM): default_bufsize: int -def parse( - stream_or_string: str | IO[bytes], parser: XMLReader | None = ..., bufsize: int | None = ... -) -> DOMEventStream: ... +def parse(stream_or_string: str | IO[bytes], parser: XMLReader | None = ..., bufsize: int | None = ...) -> DOMEventStream: ... def parseString(string: str, parser: XMLReader | None = ...) -> DOMEventStream: ... diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 02bb217ecead..5d90a110c8d2 100644 --- a/stdlib/xml/etree/ElementInclude.pyi +++ b/stdlib/xml/etree/ElementInclude.pyi @@ -15,10 +15,7 @@ def default_loader(href: str | bytes | int, parse: str, encoding: str | None = . # Which can't be represented using Callable... if sys.version_info >= (3, 9): def include( - elem: Element, - loader: Callable[..., str | Element] | None = ..., - base_url: str | None = ..., - max_depth: int | None = ..., + elem: Element, loader: Callable[..., str | Element] | None = ..., base_url: str | None = ..., max_depth: int | None = ... ) -> None: ... else: diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index 076cb867be70..ccc609a39538 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -28,6 +28,4 @@ _T = TypeVar("_T") def iterfind(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> Generator[Element, None, None]: ... def find(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> Element | None: ... def findall(elem: Element, path: str, namespaces: Dict[str, str] | None = ...) -> List[Element]: ... -def findtext( - elem: Element, path: str, default: _T | None = ..., namespaces: Dict[str, str] | None = ... -) -> _T | str: ... +def findtext(elem: Element, path: str, default: _T | None = ..., namespaces: Dict[str, str] | None = ...) -> _T | str: ... diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index f834186c9e1d..41ce89d93455 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -234,9 +234,7 @@ if sys.version_info >= (3, 9): def indent(tree: Element | ElementTree, space: str = ..., level: int = ...) -> None: ... def parse(source: _File, parser: XMLParser | None = ...) -> ElementTree: ... -def iterparse( - source: _File, events: Sequence[str] | None = ..., parser: XMLParser | None = ... -) -> Iterator[Tuple[str, Any]]: ... +def iterparse(source: _File, events: Sequence[str] | None = ..., parser: XMLParser | None = ...) -> Iterator[Tuple[str, Any]]: ... class XMLPullParser: def __init__(self, events: Sequence[str] | None = ..., *, _parser: XMLParser | None = ...) -> None: ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index d67434b66df8..6d333bd53d6e 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -192,9 +192,7 @@ def dumps( encoding: str | None = ..., allow_none: bool = ..., ) -> str: ... -def loads( - data: str, use_datetime: bool = ..., use_builtin_types: bool = ... -) -> Tuple[Tuple[_Marshallable, ...], str | None]: ... +def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[Tuple[_Marshallable, ...], str | None]: ... def gzip_encode(data: bytes) -> bytes: ... # undocumented def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ... # undocumented diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index 5faaff5e9565..61f4a921762e 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -46,9 +46,7 @@ class SimpleXMLRPCDispatcher: # undocumented def __init__(self, allow_none: bool = ..., encoding: str | None = ..., use_builtin_types: bool = ...) -> None: ... def register_instance(self, instance: Any, allow_dotted_names: bool = ...) -> None: ... if sys.version_info >= (3, 7): - def register_function( - self, function: _DispatchProtocol | None = ..., name: str | None = ... - ) -> Callable[..., Any]: ... + def register_function(self, function: _DispatchProtocol | None = ..., name: str | None = ...) -> Callable[..., Any]: ... else: def register_function(self, function: _DispatchProtocol, name: str | None = ...) -> Callable[..., Any]: ... def register_introspection_functions(self) -> None: ... diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index c839ce367614..b06c18c94539 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -52,12 +52,7 @@ class ZipExtFile(io.BufferedIOBase): ) -> None: ... @overload def __init__( - self, - fileobj: _ZipStream, - mode: str, - zipinfo: ZipInfo, - pwd: bytes | None = ..., - close_fileobj: Literal[False] = ..., + self, fileobj: _ZipStream, mode: str, zipinfo: ZipInfo, pwd: bytes | None = ..., close_fileobj: Literal[False] = ... ) -> None: ... else: @overload @@ -145,9 +140,7 @@ class ZipFile: self, name: str | ZipInfo, mode: Literal["r", "w"] = ..., pwd: bytes | None = ..., *, force_zip64: bool = ... ) -> IO[bytes]: ... def extract(self, member: str | ZipInfo, path: StrPath | None = ..., pwd: bytes | None = ...) -> str: ... - def extractall( - self, path: StrPath | None = ..., members: Iterable[str] | None = ..., pwd: bytes | None = ... - ) -> None: ... + def extractall(self, path: StrPath | None = ..., members: Iterable[str] | None = ..., pwd: bytes | None = ...) -> None: ... def printdir(self, file: _Writer | None = ...) -> None: ... def setpassword(self, pwd: bytes) -> None: ... def read(self, name: str | ZipInfo, pwd: bytes | None = ...) -> bytes: ... @@ -171,9 +164,7 @@ class ZipFile: compresslevel: int | None = ..., ) -> None: ... else: - def writestr( - self, zinfo_or_arcname: str | ZipInfo, data: bytes | str, compress_type: int | None = ... - ) -> None: ... + def writestr(self, zinfo_or_arcname: str | ZipInfo, data: bytes | str, compress_type: int | None = ...) -> None: ... class PyZipFile(ZipFile): def __init__( diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index 323f23476dc1..3096e326e816 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -12,9 +12,7 @@ class zipimporter(object): archive: str prefix: str def __init__(self, path: str | bytes | os.PathLike[Any]) -> None: ... - def find_loader( - self, fullname: str, path: str | None = ... - ) -> Tuple[zipimporter | None, List[str]]: ... # undocumented + def find_loader(self, fullname: str, path: str | None = ...) -> Tuple[zipimporter | None, List[str]]: ... # undocumented def find_module(self, fullname: str, path: str | None = ...) -> zipimporter | None: ... def get_code(self, fullname: str) -> CodeType: ... def get_data(self, pathname: str) -> str: ... diff --git a/stubs/DateTimeRange/datetimerange/__init__.pyi b/stubs/DateTimeRange/datetimerange/__init__.pyi index 8535795f0d5b..2aec2b3e97e6 100644 --- a/stubs/DateTimeRange/datetimerange/__init__.pyi +++ b/stubs/DateTimeRange/datetimerange/__init__.pyi @@ -38,9 +38,7 @@ class DateTimeRange(object): def get_timedelta_second(self) -> float: ... def set_start_datetime(self, value: datetime.datetime | str | None, timezone: str | None = ...) -> None: ... def set_end_datetime(self, value: datetime.datetime | str | None, timezone: str | None = ...) -> None: ... - def set_time_range( - self, start: datetime.datetime | str | None, end: datetime.datetime | str | None - ) -> None: ... + def set_time_range(self, start: datetime.datetime | str | None, end: datetime.datetime | str | None) -> None: ... def range(self, step: datetime.timedelta | relativedelta) -> Iterable[datetime.datetime]: ... def intersection(self, x: DateTimeRange) -> DateTimeRange: ... def encompass(self, x: DateTimeRange) -> DateTimeRange: ... diff --git a/stubs/Flask/flask/app.pyi b/stubs/Flask/flask/app.pyi index 80196b4dbbc6..e6ffec0cec83 100644 --- a/stubs/Flask/flask/app.pyi +++ b/stubs/Flask/flask/app.pyi @@ -146,9 +146,7 @@ class Flask(_PackageBoundObject): ) -> None: ... def route(self, rule: str, **options: Any) -> Callable[[_VT], _VT]: ... def endpoint(self, endpoint: str) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... - def errorhandler( - self, code_or_exception: int | Type[Exception] - ) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... + def errorhandler(self, code_or_exception: int | Type[Exception]) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... def register_error_handler(self, code_or_exception: int | Type[Exception], f: Callable[..., Any]) -> None: ... def template_filter(self, name: Any | None = ...): ... def add_template_filter(self, f: Any, name: Any | None = ...) -> None: ... diff --git a/stubs/Flask/flask/blueprints.pyi b/stubs/Flask/flask/blueprints.pyi index 65b282e9f80c..edf57320e9a4 100644 --- a/stubs/Flask/flask/blueprints.pyi +++ b/stubs/Flask/flask/blueprints.pyi @@ -74,7 +74,5 @@ class Blueprint(_PackageBoundObject): def url_defaults(self, f: Any): ... def app_url_value_preprocessor(self, f: Any): ... def app_url_defaults(self, f: Any): ... - def errorhandler( - self, code_or_exception: int | Type[Exception] - ) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... + def errorhandler(self, code_or_exception: int | Type[Exception]) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... def register_error_handler(self, code_or_exception: int | Type[Exception], f: Callable[..., Any]) -> None: ... diff --git a/stubs/Jinja2/jinja2/environment.pyi b/stubs/Jinja2/jinja2/environment.pyi index 31827431259d..6ebece7fbbe0 100644 --- a/stubs/Jinja2/jinja2/environment.pyi +++ b/stubs/Jinja2/jinja2/environment.pyi @@ -100,21 +100,13 @@ class Environment: def getitem(self, obj, argument): ... def getattr(self, obj, attribute): ... def call_filter( - self, - name, - value, - args: Any | None = ..., - kwargs: Any | None = ..., - context: Any | None = ..., - eval_ctx: Any | None = ..., + self, name, value, args: Any | None = ..., kwargs: Any | None = ..., context: Any | None = ..., eval_ctx: Any | None = ... ): ... def call_test(self, name, value, args: Any | None = ..., kwargs: Any | None = ...): ... def parse(self, source, name: Any | None = ..., filename: Any | None = ...): ... def lex(self, source, name: Any | None = ..., filename: Any | None = ...): ... def preprocess(self, source: Text, name: Any | None = ..., filename: Any | None = ...): ... - def compile( - self, source, name: Any | None = ..., filename: Any | None = ..., raw: bool = ..., defer_init: bool = ... - ): ... + def compile(self, source, name: Any | None = ..., filename: Any | None = ..., raw: bool = ..., defer_init: bool = ...): ... def compile_expression(self, source: Text, undefined_to_none: bool = ...): ... def compile_templates( self, @@ -129,9 +121,7 @@ class Environment: def list_templates(self, extensions: Any | None = ..., filter_func: Any | None = ...): ... def handle_exception(self, exc_info: Any | None = ..., rendered: bool = ..., source_hint: Any | None = ...): ... def join_path(self, template: Template | Text, parent: Text) -> Text: ... - def get_template( - self, name: Template | Text, parent: Text | None = ..., globals: Any | None = ... - ) -> Template: ... + def get_template(self, name: Template | Text, parent: Text | None = ..., globals: Any | None = ...) -> Template: ... def select_template( self, names: Sequence[Template | Text], parent: Text | None = ..., globals: Dict[str, Any] | None = ... ) -> Template: ... diff --git a/stubs/Jinja2/jinja2/loaders.pyi b/stubs/Jinja2/jinja2/loaders.pyi index d607eef66d4f..5a41f52a8d3b 100644 --- a/stubs/Jinja2/jinja2/loaders.pyi +++ b/stubs/Jinja2/jinja2/loaders.pyi @@ -46,9 +46,7 @@ class DictLoader(BaseLoader): class FunctionLoader(BaseLoader): load_func: Any def __init__(self, load_func) -> None: ... - def get_source( - self, environment: Environment, template: Text - ) -> Tuple[Text, Text | None, Callable[..., Any] | None]: ... + def get_source(self, environment: Environment, template: Text) -> Tuple[Text, Text | None, Callable[..., Any] | None]: ... class PrefixLoader(BaseLoader): mapping: Any diff --git a/stubs/Jinja2/jinja2/utils.pyi b/stubs/Jinja2/jinja2/utils.pyi index 591c6592e665..17ca2a4cdd64 100644 --- a/stubs/Jinja2/jinja2/utils.pyi +++ b/stubs/Jinja2/jinja2/utils.pyi @@ -40,10 +40,7 @@ def open_if_exists(filename: StrOrBytesPath, mode: str = ...) -> IO[Any] | None: def object_type_repr(obj: object) -> str: ... def pformat(obj: object, verbose: bool = ...) -> str: ... def urlize( - text: Markup | Text, - trim_url_limit: int | None = ..., - rel: Markup | Text | None = ..., - target: Markup | Text | None = ..., + text: Markup | Text, trim_url_limit: int | None = ..., rel: Markup | Text | None = ..., target: Markup | Text | None = ... ) -> str: ... def generate_lorem_ipsum(n: int = ..., html: bool = ..., min: int = ..., max: int = ...) -> Markup | str: ... def unicode_urlencode(obj: object, charset: str = ..., for_qs: bool = ...) -> str: ... diff --git a/stubs/Markdown/markdown/core.pyi b/stubs/Markdown/markdown/core.pyi index 7db6eaf8cfb3..340182fd535b 100644 --- a/stubs/Markdown/markdown/core.pyi +++ b/stubs/Markdown/markdown/core.pyi @@ -27,9 +27,7 @@ class Markdown: tab_length: int | None = ..., ) -> None: ... def build_parser(self) -> Markdown: ... - def registerExtensions( - self, extensions: Sequence[Extension | str], configs: Mapping[str, Mapping[str, Any]] - ) -> Markdown: ... + def registerExtensions(self, extensions: Sequence[Extension | str], configs: Mapping[str, Mapping[str, Any]]) -> Markdown: ... def build_extension(self, ext_name: Text, configs: Mapping[str, str]) -> Extension: ... def registerExtension(self, extension: Extension) -> Markdown: ... def reset(self: Markdown) -> Markdown: ... diff --git a/stubs/MarkupSafe/markupsafe/__init__.pyi b/stubs/MarkupSafe/markupsafe/__init__.pyi index 4aa0e0356de1..117586e67f70 100644 --- a/stubs/MarkupSafe/markupsafe/__init__.pyi +++ b/stubs/MarkupSafe/markupsafe/__init__.pyi @@ -41,9 +41,7 @@ class Markup(text_type): def strip(self, chars: text_type | None = ...) -> Markup: ... def center(self, width: SupportsIndex, fillchar: text_type = ...) -> Markup: ... def zfill(self, width: SupportsIndex) -> Markup: ... - def translate( - self, table: Mapping[int, int | text_type | None] | Sequence[int | text_type | None] - ) -> Markup: ... + def translate(self, table: Mapping[int, int | text_type | None] | Sequence[int | text_type | None]) -> Markup: ... if sys.version_info >= (3, 8): def expandtabs(self, tabsize: SupportsIndex = ...) -> Markup: ... else: diff --git a/stubs/Werkzeug/werkzeug/datastructures.pyi b/stubs/Werkzeug/werkzeug/datastructures.pyi index 049179d8ee3f..0c60602553b3 100644 --- a/stubs/Werkzeug/werkzeug/datastructures.pyi +++ b/stubs/Werkzeug/werkzeug/datastructures.pyi @@ -433,9 +433,7 @@ class WWWAuthenticate(UpdateDictMixin, Dict[str, Any]): on_update: Any def __init__(self, auth_type: Any | None = ..., values: Any | None = ..., on_update: Any | None = ...): ... def set_basic(self, realm: str = ...): ... - def set_digest( - self, realm, nonce, qop=..., opaque: Any | None = ..., algorithm: Any | None = ..., stale: bool = ... - ): ... + def set_digest(self, realm, nonce, qop=..., opaque: Any | None = ..., algorithm: Any | None = ..., stale: bool = ...): ... def to_header(self): ... @staticmethod def auth_property(name, doc: Any | None = ...): ... diff --git a/stubs/Werkzeug/werkzeug/exceptions.pyi b/stubs/Werkzeug/werkzeug/exceptions.pyi index bb438d72b73c..51d5c58d21a0 100644 --- a/stubs/Werkzeug/werkzeug/exceptions.pyi +++ b/stubs/Werkzeug/werkzeug/exceptions.pyi @@ -128,10 +128,7 @@ class PreconditionRequired(HTTPException): class _RetryAfter(HTTPException): retry_after: None | int | datetime.datetime def __init__( - self, - description: Text | None = ..., - response: Response | None = ..., - retry_after: None | int | datetime.datetime = ..., + self, description: Text | None = ..., response: Response | None = ..., retry_after: None | int | datetime.datetime = ... ) -> None: ... class TooManyRequests(_RetryAfter): diff --git a/stubs/Werkzeug/werkzeug/http.pyi b/stubs/Werkzeug/werkzeug/http.pyi index cf1219ad1d88..be3cbc2e91c9 100644 --- a/stubs/Werkzeug/werkzeug/http.pyi +++ b/stubs/Werkzeug/werkzeug/http.pyi @@ -78,9 +78,7 @@ def parse_cache_control_header( value: None | bytes | Text, on_update: _T, cls: Callable[[Dict[Text, Text | None], _T], _U] ) -> _U: ... @overload -def parse_cache_control_header( - value: None | bytes | Text, *, cls: Callable[[Dict[Text, Text | None], None], _U] -) -> _U: ... +def parse_cache_control_header(value: None | bytes | Text, *, cls: Callable[[Dict[Text, Text | None], None], _U]) -> _U: ... def parse_set_header(value: Text, on_update: Callable[[HeaderSet], Any] | None = ...) -> HeaderSet: ... def parse_authorization_header(value: None | bytes | Text) -> Authorization | None: ... def parse_www_authenticate_header( diff --git a/stubs/Werkzeug/werkzeug/routing.pyi b/stubs/Werkzeug/werkzeug/routing.pyi index 983c6d5040bc..6acdbd905b2f 100644 --- a/stubs/Werkzeug/werkzeug/routing.pyi +++ b/stubs/Werkzeug/werkzeug/routing.pyi @@ -203,15 +203,9 @@ class MapAdapter: def __init__( self, map, server_name, script_name, subdomain, url_scheme, path_info, default_method, query_args: Any | None = ... ): ... - def dispatch( - self, view_func, path_info: Any | None = ..., method: Any | None = ..., catch_http_exceptions: bool = ... - ): ... + def dispatch(self, view_func, path_info: Any | None = ..., method: Any | None = ..., catch_http_exceptions: bool = ...): ... def match( - self, - path_info: Any | None = ..., - method: Any | None = ..., - return_rule: bool = ..., - query_args: Any | None = ..., + self, path_info: Any | None = ..., method: Any | None = ..., return_rule: bool = ..., query_args: Any | None = ... ): ... def test(self, path_info: Any | None = ..., method: Any | None = ...): ... def allowed_methods(self, path_info: Any | None = ...): ... @@ -221,10 +215,5 @@ class MapAdapter: def make_redirect_url(self, path_info, query_args: Any | None = ..., domain_part: Any | None = ...): ... def make_alias_redirect_url(self, path, endpoint, values, method, query_args): ... def build( - self, - endpoint, - values: Any | None = ..., - method: Any | None = ..., - force_external: bool = ..., - append_unknown: bool = ..., + self, endpoint, values: Any | None = ..., method: Any | None = ..., force_external: bool = ..., append_unknown: bool = ... ): ... diff --git a/stubs/Werkzeug/werkzeug/test.pyi b/stubs/Werkzeug/werkzeug/test.pyi index 3ac0f49424aa..e6d0d5b35465 100644 --- a/stubs/Werkzeug/werkzeug/test.pyi +++ b/stubs/Werkzeug/werkzeug/test.pyi @@ -10,9 +10,7 @@ else: from cookielib import CookieJar from urllib2 import Request as U2Request -def stream_encode_multipart( - values, use_tempfile: int = ..., threshold=..., boundary: Any | None = ..., charset: Text = ... -): ... +def stream_encode_multipart(values, use_tempfile: int = ..., threshold=..., boundary: Any | None = ..., charset: Text = ...): ... def encode_multipart(values, boundary: Any | None = ..., charset: Text = ...): ... def File(fd, filename: Any | None = ..., mimetype: Any | None = ...): ... @@ -94,11 +92,7 @@ class Client(Generic[_R]): cookie_jar: Any allow_subdomain_redirects: Any def __init__( - self, - application, - response_wrapper: Type[_R] | None = ..., - use_cookies: bool = ..., - allow_subdomain_redirects: bool = ..., + self, application, response_wrapper: Type[_R] | None = ..., use_cookies: bool = ..., allow_subdomain_redirects: bool = ... ): ... def set_cookie( self, diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index 94152daad1f4..23da66371768 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -15,9 +15,7 @@ class AsyncBase(Generic[_T]): class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]): def __init__(self, coro: Coroutine[_T_co, _T_contra, _V_co]) -> None: ... def send(self, value: _T_contra) -> _T_co: ... - def throw( - self, typ: Type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ... - ) -> _T_co: ... + def throw(self, typ: Type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ...) -> _T_co: ... def close(self) -> None: ... @property def gi_frame(self) -> FrameType: ... diff --git a/stubs/boto/boto/__init__.pyi b/stubs/boto/boto/__init__.pyi index fe6573fcfa54..507c40d12ca7 100644 --- a/stubs/boto/boto/__init__.pyi +++ b/stubs/boto/boto/__init__.pyi @@ -23,9 +23,7 @@ perflog: Any def set_file_logger(name, filepath, level: Any = ..., format_string: Any | None = ...): ... def set_stream_logger(name, level: Any = ..., format_string: Any | None = ...): ... def connect_sqs(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... -def connect_s3( - aws_access_key_id: Text | None = ..., aws_secret_access_key: Text | None = ..., **kwargs -) -> S3Connection: ... +def connect_s3(aws_access_key_id: Text | None = ..., aws_secret_access_key: Text | None = ..., **kwargs) -> S3Connection: ... def connect_gs(gs_access_key_id: Any | None = ..., gs_secret_access_key: Any | None = ..., **kwargs): ... def connect_ec2(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_elb(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... @@ -65,9 +63,7 @@ def connect_walrus( ): ... def connect_ses(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_sts(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... -def connect_ia( - ia_access_key_id: Any | None = ..., ia_secret_access_key: Any | None = ..., is_secure: bool = ..., **kwargs -): ... +def connect_ia(ia_access_key_id: Any | None = ..., ia_secret_access_key: Any | None = ..., is_secure: bool = ..., **kwargs): ... def connect_dynamodb(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_swf(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... def connect_cloudsearch(aws_access_key_id: Any | None = ..., aws_secret_access_key: Any | None = ..., **kwargs): ... diff --git a/stubs/boto/boto/kms/layer1.pyi b/stubs/boto/boto/kms/layer1.pyi index dd3b0df6830c..9e41ea39760f 100644 --- a/stubs/boto/boto/kms/layer1.pyi +++ b/stubs/boto/boto/kms/layer1.pyi @@ -25,10 +25,7 @@ class KMSConnection(AWSQueryConnection): self, policy: str | None = ..., description: str | None = ..., key_usage: str | None = ... ) -> Dict[str, Any] | None: ... def decrypt( - self, - ciphertext_blob: bytes, - encryption_context: Mapping[str, Any] | None = ..., - grant_tokens: List[str] | None = ..., + self, ciphertext_blob: bytes, encryption_context: Mapping[str, Any] | None = ..., grant_tokens: List[str] | None = ... ) -> Dict[str, Any] | None: ... def delete_alias(self, alias_name: str) -> Dict[str, Any] | None: ... def describe_key(self, key_id: str) -> Dict[str, Any] | None: ... @@ -64,9 +61,7 @@ class KMSConnection(AWSQueryConnection): def get_key_rotation_status(self, key_id: str) -> Dict[str, Any] | None: ... def list_aliases(self, limit: int | None = ..., marker: str | None = ...) -> Dict[str, Any] | None: ... def list_grants(self, key_id: str, limit: int | None = ..., marker: str | None = ...) -> Dict[str, Any] | None: ... - def list_key_policies( - self, key_id: str, limit: int | None = ..., marker: str | None = ... - ) -> Dict[str, Any] | None: ... + def list_key_policies(self, key_id: str, limit: int | None = ..., marker: str | None = ...) -> Dict[str, Any] | None: ... def list_keys(self, limit: int | None = ..., marker: str | None = ...) -> Dict[str, Any] | None: ... def put_key_policy(self, key_id: str, policy_name: str, policy: str) -> Dict[str, Any] | None: ... def re_encrypt( diff --git a/stubs/boto/boto/regioninfo.pyi b/stubs/boto/boto/regioninfo.pyi index 2270fd3c804f..fd7069994843 100644 --- a/stubs/boto/boto/regioninfo.pyi +++ b/stubs/boto/boto/regioninfo.pyi @@ -11,11 +11,7 @@ class RegionInfo: endpoint: Any connection_cls: Any def __init__( - self, - connection: Any | None = ..., - name: Any | None = ..., - endpoint: Any | None = ..., - connection_cls: Any | None = ..., + self, connection: Any | None = ..., name: Any | None = ..., endpoint: Any | None = ..., connection_cls: Any | None = ... ) -> None: ... def startElement(self, name, attrs, connection): ... def endElement(self, name, value, connection): ... diff --git a/stubs/boto/boto/s3/bucket.pyi b/stubs/boto/boto/s3/bucket.pyi index 413b73aa2dea..4c25b4cbd97b 100644 --- a/stubs/boto/boto/s3/bucket.pyi +++ b/stubs/boto/boto/s3/bucket.pyi @@ -20,9 +20,7 @@ class Bucket: name: Text connection: S3Connection key_class: Type[Key] - def __init__( - self, connection: S3Connection | None = ..., name: Text | None = ..., key_class: Type[Key] = ... - ) -> None: ... + def __init__(self, connection: S3Connection | None = ..., name: Text | None = ..., key_class: Type[Key] = ...) -> None: ... def __iter__(self): ... def __contains__(self, key_name) -> bool: ... def startElement(self, name, attrs, connection): ... @@ -106,9 +104,7 @@ class Bucket: version_id: Any | None = ..., query_args: str = ..., ): ... - def set_acl( - self, acl_or_str, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ... - ): ... + def set_acl(self, acl_or_str, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ...): ... def get_acl(self, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ...): ... def set_subresource( self, subresource, value, key_name: str = ..., headers: Dict[Text, Text] | None = ..., version_id: Any | None = ... @@ -119,12 +115,7 @@ class Bucket: def make_public(self, recursive: bool = ..., headers: Dict[Text, Text] | None = ...): ... def add_email_grant(self, permission, email_address, recursive: bool = ..., headers: Dict[Text, Text] | None = ...): ... def add_user_grant( - self, - permission, - user_id, - recursive: bool = ..., - headers: Dict[Text, Text] | None = ..., - display_name: Any | None = ..., + self, permission, user_id, recursive: bool = ..., headers: Dict[Text, Text] | None = ..., display_name: Any | None = ... ): ... def list_grants(self, headers: Dict[Text, Text] | None = ...): ... def get_location(self): ... diff --git a/stubs/boto/boto/s3/bucketlistresultset.pyi b/stubs/boto/boto/s3/bucketlistresultset.pyi index 801bf2615f57..f34d9f2b4b37 100644 --- a/stubs/boto/boto/s3/bucketlistresultset.pyi +++ b/stubs/boto/boto/s3/bucketlistresultset.pyi @@ -3,12 +3,7 @@ from typing import Any, Iterable, Iterator, Optional from .key import Key def bucket_lister( - bucket, - prefix: str = ..., - delimiter: str = ..., - marker: str = ..., - headers: Any | None = ..., - encoding_type: Any | None = ..., + bucket, prefix: str = ..., delimiter: str = ..., marker: str = ..., headers: Any | None = ..., encoding_type: Any | None = ... ): ... class BucketListResultSet(Iterable[Key]): diff --git a/stubs/boto/boto/s3/key.pyi b/stubs/boto/boto/s3/key.pyi index 7537f48f6842..e0686b466b3c 100644 --- a/stubs/boto/boto/s3/key.pyi +++ b/stubs/boto/boto/s3/key.pyi @@ -226,8 +226,6 @@ class Key: encoding: Text, ) -> Text: ... def add_email_grant(self, permission, email_address, headers: Dict[Text, Text] | None = ...): ... - def add_user_grant( - self, permission, user_id, headers: Dict[Text, Text] | None = ..., display_name: Any | None = ... - ): ... + def add_user_grant(self, permission, user_id, headers: Dict[Text, Text] | None = ..., display_name: Any | None = ...): ... def set_remote_metadata(self, metadata_plus, metadata_minus, preserve_acl, headers: Dict[Text, Text] | None = ...): ... def restore(self, days, headers: Dict[Text, Text] | None = ...): ... diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 58256034a8ee..2ec9363ff35b 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -57,11 +57,7 @@ qsa_of_interest: List[str] def unquote_v(nv: str) -> str | Tuple[str, str]: ... def canonical_string( - method: str, - path: str, - headers: Mapping[str, str | None], - expires: int | None = ..., - provider: _Provider | None = ..., + method: str, path: str, headers: Mapping[str, str | None], expires: int | None = ..., provider: _Provider | None = ... ) -> str: ... def merge_meta( headers: Mapping[str, str], metadata: Mapping[str, str], provider: _Provider | None = ... @@ -160,9 +156,7 @@ def write_mime_multipart( ) -> str: ... def guess_mime_type(content: str, deftype: str) -> str: ... def compute_md5(fp: IO[Any], buf_size: int = ..., size: int | None = ...) -> Tuple[str, str, int]: ... -def compute_hash( - fp: IO[Any], buf_size: int = ..., size: int | None = ..., hash_algorithm: Any = ... -) -> Tuple[str, str, int]: ... +def compute_hash(fp: IO[Any], buf_size: int = ..., size: int | None = ..., hash_algorithm: Any = ...) -> Tuple[str, str, int]: ... def find_matching_headers(name: str, headers: Mapping[str, str | None]) -> List[str]: ... def merge_headers_by_name(name: str, headers: Mapping[str, str | None]) -> str: ... diff --git a/stubs/cachetools/cachetools/decorators.pyi b/stubs/cachetools/cachetools/decorators.pyi index a7ecc9f5b9a0..0d6e8141cb6f 100644 --- a/stubs/cachetools/cachetools/decorators.pyi +++ b/stubs/cachetools/cachetools/decorators.pyi @@ -7,7 +7,5 @@ def cached( cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ... ) -> IdentityFunction: ... def cachedmethod( - cache: Callable[[Any], MutableMapping[_KT, Any] | None], - key: Callable[..., _KT] = ..., - lock: ContextManager[Any] | None = ..., + cache: Callable[[Any], MutableMapping[_KT, Any] | None], key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ... ) -> IdentityFunction: ... diff --git a/stubs/cachetools/cachetools/func.pyi b/stubs/cachetools/cachetools/func.pyi index b0e568f3b9dd..1f5a520792aa 100644 --- a/stubs/cachetools/cachetools/func.pyi +++ b/stubs/cachetools/cachetools/func.pyi @@ -5,7 +5,5 @@ _T = TypeVar("_T") def lfu_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ... def lru_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ... -def rr_cache( - maxsize: float = ..., choice: Callable[[Sequence[_T]], _T] | None = ..., typed: bool = ... -) -> IdentityFunction: ... +def rr_cache(maxsize: float = ..., choice: Callable[[Sequence[_T]], _T] | None = ..., typed: bool = ...) -> IdentityFunction: ... def ttl_cache(maxsize: float = ..., ttl: float = ..., timer: float = ..., typed: bool = ...) -> IdentityFunction: ... diff --git a/stubs/cachetools/cachetools/rr.pyi b/stubs/cachetools/cachetools/rr.pyi index c6daabf12441..ab6af13d118d 100644 --- a/stubs/cachetools/cachetools/rr.pyi +++ b/stubs/cachetools/cachetools/rr.pyi @@ -7,10 +7,7 @@ _VT = TypeVar("_VT") class RRCache(Cache[_KT, _VT]): def __init__( - self, - maxsize: float, - choice: Callable[[Sequence[_KT]], _KT] | None = ..., - getsizeof: Callable[[_VT], float] | None = ..., + self, maxsize: float, choice: Callable[[Sequence[_KT]], _KT] | None = ..., getsizeof: Callable[[_VT], float] | None = ... ) -> None: ... def __getitem__(self, key: _KT) -> _VT: ... def __setitem__(self, key: _KT, value: _VT) -> None: ... diff --git a/stubs/click/click/core.pyi b/stubs/click/click/core.pyi index b7ff86f743fa..bcb6dae71879 100644 --- a/stubs/click/click/core.pyi +++ b/stubs/click/click/core.pyi @@ -198,9 +198,7 @@ class _ParamType: def fail(self, message: str, param: Parameter | None = ..., ctx: Context | None = ...) -> NoReturn: ... # This type is here to resolve https://github.com/python/mypy/issues/5275 -_ConvertibleType = Union[ - type, _ParamType, Tuple[type | _ParamType, ...], Callable[[str], Any], Callable[[str | None], Any] -] +_ConvertibleType = Union[type, _ParamType, Tuple[type | _ParamType, ...], Callable[[str], Any], Callable[[str | None], Any]] class Parameter: param_type_name: str diff --git a/stubs/click/click/exceptions.pyi b/stubs/click/click/exceptions.pyi index acf6534171f5..06deb0169863 100644 --- a/stubs/click/click/exceptions.pyi +++ b/stubs/click/click/exceptions.pyi @@ -37,11 +37,7 @@ class NoSuchOption(UsageError): option_name: str possibilities: List[str] | None def __init__( - self, - option_name: str, - message: str | None = ..., - possibilities: List[str] | None = ..., - ctx: Context | None = ..., + self, option_name: str, message: str | None = ..., possibilities: List[str] | None = ..., ctx: Context | None = ... ) -> None: ... class BadOptionUsage(UsageError): diff --git a/stubs/click/click/testing.pyi b/stubs/click/click/testing.pyi index cd399cffd603..0cc4061b2f09 100644 --- a/stubs/click/click/testing.pyi +++ b/stubs/click/click/testing.pyi @@ -45,11 +45,7 @@ class CliRunner: echo_stdin: bool mix_stderr: bool def __init__( - self, - charset: Text | None = ..., - env: Mapping[str, str] | None = ..., - echo_stdin: bool = ..., - mix_stderr: bool = ..., + self, charset: Text | None = ..., env: Mapping[str, str] | None = ..., echo_stdin: bool = ..., mix_stderr: bool = ... ) -> None: ... def get_default_prog_name(self, cli: BaseCommand) -> str: ... def make_env(self, overrides: Mapping[str, str] | None = ...) -> Dict[str, str]: ... diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index df8dc1759db2..117fe8f6265c 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -32,9 +32,7 @@ class AnsiToWin32: convert: bool = ... win32_calls: _WinTermCallDict = ... on_stderr: bool = ... - def __init__( - self, wrapped: TextIO, convert: bool | None = ..., strip: bool | None = ..., autoreset: bool = ... - ) -> None: ... + def __init__(self, wrapped: TextIO, convert: bool | None = ..., strip: bool | None = ..., autoreset: bool = ...) -> None: ... def should_wrap(self) -> bool: ... def get_win32_calls(self) -> _WinTermCallDict: ... def write(self, text: str) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi index 3580c910e3d7..ef95e63eff93 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi @@ -60,9 +60,7 @@ class DSAPublicKey(metaclass=ABCMeta): @abstractmethod def public_numbers(self) -> DSAPublicNumbers: ... @abstractmethod - def verifier( - self, signature: bytes, signature_algorithm: HashAlgorithm | Prehashed - ) -> AsymmetricVerificationContext: ... + def verifier(self, signature: bytes, signature_algorithm: HashAlgorithm | Prehashed) -> AsymmetricVerificationContext: ... @abstractmethod def verify(self, signature: bytes, data: bytes, algorithm: HashAlgorithm | Prehashed) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi index 8af772c44f66..d9ed1d7ab285 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi @@ -42,9 +42,7 @@ class RSAPublicKey(metaclass=ABCMeta): self, signature: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed ) -> AsymmetricVerificationContext: ... @abstractmethod - def verify( - self, signature: bytes, data: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed - ) -> None: ... + def verify(self, signature: bytes, data: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed) -> None: ... RSAPublicKeyWithSerialization = RSAPublicKey diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi index d1964dd22e9a..25ed2317de24 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi @@ -5,9 +5,7 @@ from cryptography.hazmat.primitives.hashes import HashAlgorithm from cryptography.hazmat.primitives.kdf import KeyDerivationFunction class ConcatKDFHash(KeyDerivationFunction): - def __init__( - self, algorithm: HashAlgorithm, length: int, otherinfo: bytes | None, backend: HashBackend | None = ... - ): ... + def __init__(self, algorithm: HashAlgorithm, length: int, otherinfo: bytes | None, backend: HashBackend | None = ...): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi index 5c497400c1c2..d9703957e876 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi @@ -6,12 +6,7 @@ from cryptography.hazmat.primitives.kdf import KeyDerivationFunction class HKDF(KeyDerivationFunction): def __init__( - self, - algorithm: HashAlgorithm, - length: int, - salt: bytes | None, - info: bytes | None, - backend: HMACBackend | None = ..., + self, algorithm: HashAlgorithm, length: int, salt: bytes | None, info: bytes | None, backend: HMACBackend | None = ... ): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi index 7e655a6fd639..43f741d95f27 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi @@ -5,8 +5,6 @@ from cryptography.hazmat.primitives.hashes import HashAlgorithm from cryptography.hazmat.primitives.kdf import KeyDerivationFunction class X963KDF(KeyDerivationFunction): - def __init__( - self, algorithm: HashAlgorithm, length: int, sharedinfo: bytes | None, backend: HashBackend | None = ... - ): ... + def __init__(self, algorithm: HashAlgorithm, length: int, sharedinfo: bytes | None, backend: HashBackend | None = ...): ... def derive(self, key_material: bytes) -> bytes: ... def verify(self, key_material: bytes, expected_key: bytes) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi index a5eb582f8614..5ca76bd08a49 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi @@ -5,12 +5,7 @@ from cryptography.hazmat.primitives.hashes import HashAlgorithm class HOTP(object): def __init__( - self, - key: bytes, - length: int, - algorithm: HashAlgorithm, - backend: HMACBackend | None = ..., - enforce_key_length: bool = ..., + self, key: bytes, length: int, algorithm: HashAlgorithm, backend: HMACBackend | None = ..., enforce_key_length: bool = ... ): ... def generate(self, counter: int) -> bytes: ... def get_provisioning_uri(self, account_name: str, counter: int, issuer: str | None) -> str: ... diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index 7f12e6b040ed..cb9352381158 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -321,10 +321,7 @@ class AuthorityKeyIdentifier(ExtensionType): @property def authority_cert_serial_number(self) -> int | None: ... def __init__( - self, - key_identifier: bytes, - authority_cert_issuer: Iterable[GeneralName] | None, - authority_cert_serial_number: int | None, + self, key_identifier: bytes, authority_cert_issuer: Iterable[GeneralName] | None, authority_cert_serial_number: int | None ) -> None: ... @classmethod def from_issuer_public_key( diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index 587c26391ec0..fe86dcaa1b3a 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -64,12 +64,7 @@ def field( ) -> _T: ... @overload def field( - *, - init: bool = ..., - repr: bool = ..., - hash: bool | None = ..., - compare: bool = ..., - metadata: Mapping[str, Any] | None = ..., + *, init: bool = ..., repr: bool = ..., hash: bool | None = ..., compare: bool = ..., metadata: Mapping[str, Any] | None = ... ) -> Any: ... def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ... def is_dataclass(obj: Any) -> bool: ... diff --git a/stubs/docutils/docutils/frontend.pyi b/stubs/docutils/docutils/frontend.pyi index 554b2afa676e..2a08ddac1a9f 100644 --- a/stubs/docutils/docutils/frontend.pyi +++ b/stubs/docutils/docutils/frontend.pyi @@ -37,9 +37,7 @@ def validate_url_trailing_slash( def validate_dependency_file( setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> DependencyList: ... -def validate_strip_class( - setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... -): ... +def validate_strip_class(setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ...): ... def validate_smartquotes_locales( setting, value, option_parser, config_parser: Any | None = ..., config_section: Any | None = ... ) -> list[tuple[str, str]]: ... diff --git a/stubs/geoip2/geoip2/database.pyi b/stubs/geoip2/geoip2/database.pyi index f589128ce631..cda6509959a3 100644 --- a/stubs/geoip2/geoip2/database.pyi +++ b/stubs/geoip2/geoip2/database.pyi @@ -10,10 +10,7 @@ class Reader: def __init__(self, filename: Text, locales: _Locales = ..., mode: int = ...) -> None: ... def __enter__(self) -> Reader: ... def __exit__( - self, - exc_type: Type[BaseException] | None = ..., - exc_val: BaseException | None = ..., - exc_tb: TracebackType | None = ..., + self, exc_type: Type[BaseException] | None = ..., exc_val: BaseException | None = ..., exc_tb: TracebackType | None = ... ) -> None: ... def country(self, ip_address: Text) -> Country: ... def city(self, ip_address: Text) -> City: ... diff --git a/stubs/itsdangerous/itsdangerous.pyi b/stubs/itsdangerous/itsdangerous.pyi index 793a90c7bb46..f1645e4ef62b 100644 --- a/stubs/itsdangerous/itsdangerous.pyi +++ b/stubs/itsdangerous/itsdangerous.pyi @@ -112,15 +112,9 @@ class Serializer(object): class TimedSerializer(Serializer): def loads( - self, - s: Text | bytes, - salt: Text | bytes | None = ..., - max_age: int | None = ..., - return_timestamp: bool = ..., + self, s: Text | bytes, salt: Text | bytes | None = ..., max_age: int | None = ..., return_timestamp: bool = ... ) -> Any: ... # morally -> Any | Tuple[Any, datetime] - def loads_unsafe( - self, s: Text | bytes, salt: Text | bytes | None = ..., max_age: int | None = ... - ) -> Tuple[bool, Any]: ... + def loads_unsafe(self, s: Text | bytes, salt: Text | bytes | None = ..., max_age: int | None = ...) -> Tuple[bool, Any]: ... class JSONWebSignatureSerializer(Serializer): jws_algorithms: MutableMapping[Text, SigningAlgorithm] = ... @@ -145,15 +139,11 @@ class JSONWebSignatureSerializer(Serializer): def make_algorithm(self, algorithm_name: Text) -> SigningAlgorithm: ... def make_signer(self, salt: Text | bytes | None = ..., algorithm: SigningAlgorithm = ...) -> Signer: ... def make_header(self, header_fields: Mapping[str, Any] | None) -> MutableMapping[str, Any]: ... - def dumps( - self, obj: Any, salt: Text | bytes | None = ..., header_fields: Mapping[str, Any] | None = ... - ) -> bytes: ... + def dumps(self, obj: Any, salt: Text | bytes | None = ..., header_fields: Mapping[str, Any] | None = ...) -> bytes: ... def loads( self, s: Text | bytes, salt: Text | bytes | None = ..., return_header: bool = ... ) -> Any: ... # morally -> Any | Tuple[Any, MutableMapping[str, Any]] - def loads_unsafe( - self, s: Text | bytes, salt: Text | bytes | None = ..., return_header: bool = ... - ) -> Tuple[bool, Any]: ... + def loads_unsafe(self, s: Text | bytes, salt: Text | bytes | None = ..., return_header: bool = ...) -> Tuple[bool, Any]: ... class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer): DEFAULT_EXPIRES_IN: int = ... diff --git a/stubs/maxminddb/maxminddb/reader.pyi b/stubs/maxminddb/maxminddb/reader.pyi index 0d4aa5dffdda..affe1b7d82b6 100644 --- a/stubs/maxminddb/maxminddb/reader.pyi +++ b/stubs/maxminddb/maxminddb/reader.pyi @@ -11,10 +11,7 @@ class Reader: def close(self) -> None: ... def __enter__(self) -> Reader: ... def __exit__( - self, - exc_type: Type[BaseException] | None = ..., - exc_val: BaseException | None = ..., - exc_tb: TracebackType | None = ..., + self, exc_type: Type[BaseException] | None = ..., exc_val: BaseException | None = ..., exc_tb: TracebackType | None = ... ) -> None: ... class Metadata: diff --git a/stubs/paramiko/paramiko/sftp_client.pyi b/stubs/paramiko/paramiko/sftp_client.pyi index d39eb7392705..2a4be022b211 100644 --- a/stubs/paramiko/paramiko/sftp_client.pyi +++ b/stubs/paramiko/paramiko/sftp_client.pyi @@ -47,19 +47,10 @@ class SFTPClient(BaseSFTP, ClosingContextManager): def chdir(self, path: None | bytes | Text = ...) -> None: ... def getcwd(self) -> Text | None: ... def putfo( - self, - fl: IO[bytes], - remotepath: bytes | Text, - file_size: int = ..., - callback: _Callback | None = ..., - confirm: bool = ..., + self, fl: IO[bytes], remotepath: bytes | Text, file_size: int = ..., callback: _Callback | None = ..., confirm: bool = ... ) -> SFTPAttributes: ... def put( - self, - localpath: bytes | Text, - remotepath: bytes | Text, - callback: _Callback | None = ..., - confirm: bool = ..., + self, localpath: bytes | Text, remotepath: bytes | Text, callback: _Callback | None = ..., confirm: bool = ... ) -> SFTPAttributes: ... def getfo(self, remotepath: bytes | Text, fl: IO[bytes], callback: _Callback | None = ...) -> int: ... def get(self, remotepath: bytes | Text, localpath: bytes | Text, callback: _Callback | None = ...) -> None: ... diff --git a/stubs/protobuf/google/protobuf/json_format.pyi b/stubs/protobuf/google/protobuf/json_format.pyi index 7ab8a721414b..241eb6018b43 100644 --- a/stubs/protobuf/google/protobuf/json_format.pyi +++ b/stubs/protobuf/google/protobuf/json_format.pyi @@ -28,10 +28,7 @@ def MessageToDict( float_precision: int | None = ..., ) -> Dict[Text, Any]: ... def Parse( - text: bytes | Text, - message: _MessageT, - ignore_unknown_fields: bool = ..., - descriptor_pool: DescriptorPool | None = ..., + text: bytes | Text, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: DescriptorPool | None = ... ) -> _MessageT: ... def ParseDict( js_dict: Any, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: DescriptorPool | None = ... diff --git a/stubs/python-gflags/gflags.pyi b/stubs/python-gflags/gflags.pyi index e2904dc6233c..db8a196d802e 100644 --- a/stubs/python-gflags/gflags.pyi +++ b/stubs/python-gflags/gflags.pyi @@ -265,9 +265,7 @@ class WhitespaceSeparatedListParser(BaseListParser): def __init__(self) -> None: ... def DEFINE_list(name: str, default: List[str] | None, help: str, flag_values: FlagValues = ..., **args: Any) -> None: ... -def DEFINE_spaceseplist( - name: str, default: List[str] | None, help: str, flag_values: FlagValues = ..., **args: Any -) -> None: ... +def DEFINE_spaceseplist(name: str, default: List[str] | None, help: str, flag_values: FlagValues = ..., **args: Any) -> None: ... class MultiFlag(Flag): def __init__(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 0be14f1679b8..fe993d5716bb 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -1116,9 +1116,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def hkeys(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] def hlen(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore [override] @overload # type: ignore [override] - def hset( - self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ... - ) -> Pipeline[_StrType]: ... + def hset(self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ...) -> Pipeline[_StrType]: ... @overload # type: ignore [override] def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... @overload # type: ignore [override] diff --git a/stubs/requests/requests/adapters.pyi b/stubs/requests/requests/adapters.pyi index 484efde75c30..e2121c36f9e0 100644 --- a/stubs/requests/requests/adapters.pyi +++ b/stubs/requests/requests/adapters.pyi @@ -53,11 +53,7 @@ class HTTPAdapter(BaseAdapter): config: Any proxy_manager: Any def __init__( - self, - pool_connections: int = ..., - pool_maxsize: int = ..., - max_retries: Retry | int | None = ..., - pool_block: bool = ..., + self, pool_connections: int = ..., pool_maxsize: int = ..., max_retries: Retry | int | None = ..., pool_block: bool = ... ) -> None: ... poolmanager: Any def init_poolmanager(self, connections, maxsize, block=..., **pool_kwargs): ... diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index 247caffa320c..240907e4bcf9 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -46,9 +46,7 @@ iter_entry_points = working_set.iter_entry_points add_activation_listener = working_set.subscribe class Environment: - def __init__( - self, search_path: Sequence[str] | None = ..., platform: str | None = ..., python: str | None = ... - ) -> None: ... + def __init__(self, search_path: Sequence[str] | None = ..., platform: str | None = ..., python: str | None = ...) -> None: ... def __getitem__(self, project_name: str) -> List[Distribution]: ... def __iter__(self) -> Generator[str, None, None]: ... def add(self, dist: Distribution) -> None: ... @@ -106,9 +104,7 @@ class EntryPoint: @classmethod def parse(cls, src: str, dist: Distribution | None = ...) -> EntryPoint: ... @classmethod - def parse_group( - cls, group: str, lines: str | Sequence[str], dist: Distribution | None = ... - ) -> Dict[str, EntryPoint]: ... + def parse_group(cls, group: str, lines: str | Sequence[str], dist: Distribution | None = ...) -> Dict[str, EntryPoint]: ... @classmethod def parse_map( cls, data: Dict[str, str | Sequence[str]] | str | Sequence[str], dist: Distribution | None = ... diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 357951966a1b..24aedeafabd9 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -90,9 +90,7 @@ def assertRegex( exec_ = exec -def reraise( - tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ... -) -> NoReturn: ... +def reraise(tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ... def raise_from(value: BaseException | Type[BaseException], from_value: BaseException | None) -> NoReturn: ... print_ = print @@ -117,9 +115,7 @@ class MovedModule(_LazyDescriptor): class MovedAttribute(_LazyDescriptor): mod: str attr: str - def __init__( - self, name: str, old_mod: str, new_mod: str, old_attr: str | None = ..., new_attr: str | None = ... - ) -> None: ... + def __init__(self, name: str, old_mod: str, new_mod: str, old_attr: str | None = ..., new_attr: str | None = ...) -> None: ... def add_move(move: MovedModule | MovedAttribute) -> None: ... def remove_move(name: str) -> None: ... diff --git a/stubs/termcolor/termcolor.pyi b/stubs/termcolor/termcolor.pyi index a5a358c5686c..ca93ece19785 100644 --- a/stubs/termcolor/termcolor.pyi +++ b/stubs/termcolor/termcolor.pyi @@ -5,9 +5,7 @@ COLORS: dict[str, int] HIGHLIGHTS: dict[str, int] RESET: str -def colored( - text: Text, color: Text | None = ..., on_color: Text | None = ..., attrs: Iterable[Text] | None = ... -) -> Text: ... +def colored(text: Text, color: Text | None = ..., on_color: Text | None = ..., attrs: Iterable[Text] | None = ...) -> Text: ... def cprint( text: Text, color: Text | None = ..., on_color: Text | None = ..., attrs: Iterable[Text] | None = ..., **kwargs: Any ) -> None: ... diff --git a/stubs/waitress/waitress/wasyncore.pyi b/stubs/waitress/waitress/wasyncore.pyi index 1194a4718166..1282a4ce7c89 100644 --- a/stubs/waitress/waitress/wasyncore.pyi +++ b/stubs/waitress/waitress/wasyncore.pyi @@ -20,9 +20,7 @@ def poll2(timeout: float = ..., map: Mapping[int, socket] | None = ...) -> None: poll3 = poll2 -def loop( - timeout: float = ..., use_poll: bool = ..., map: Mapping[int, socket] | None = ..., count: int | None = ... -) -> None: ... +def loop(timeout: float = ..., use_poll: bool = ..., map: Mapping[int, socket] | None = ..., count: int | None = ...) -> None: ... def compact_traceback() -> Tuple[Tuple[str, str, str], BaseException, BaseException, str]: ... class dispatcher: From 77b7cf7067fdec4b615246e909ecb0251e8b18be Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:03:42 +0300 Subject: [PATCH 03/13] clean imports with script --- stdlib/_ast.pyi | 2 +- stdlib/_bisect.pyi | 2 +- stdlib/_codecs.pyi | 2 +- stdlib/_compression.pyi | 2 +- stdlib/_csv.pyi | 2 +- stdlib/_curses.pyi | 2 +- stdlib/_dummy_thread.pyi | 2 +- stdlib/_dummy_threading.pyi | 2 +- stdlib/_json.pyi | 2 +- stdlib/_msi.pyi | 2 +- stdlib/_osx_support.pyi | 2 +- stdlib/_sitebuiltins.pyi | 2 +- stdlib/_socket.pyi | 2 +- stdlib/_thread.pyi | 2 +- stdlib/_tracemalloc.pyi | 2 +- stdlib/_typeshed/wsgi.pyi | 2 +- stdlib/_typeshed/xml.pyi | 2 +- stdlib/_warnings.pyi | 2 +- stdlib/_weakref.pyi | 2 +- stdlib/_weakrefset.pyi | 2 +- stdlib/_winapi.pyi | 2 +- stdlib/aifc.pyi | 2 +- stdlib/argparse.pyi | 4 ++-- stdlib/ast.pyi | 2 +- stdlib/asynchat.pyi | 1 - stdlib/asyncio/base_events.pyi | 2 +- stdlib/asyncio/base_tasks.pyi | 2 +- stdlib/asyncio/events.pyi | 2 +- stdlib/asyncio/exceptions.pyi | 1 - stdlib/asyncio/format_helpers.pyi | 2 +- stdlib/asyncio/futures.pyi | 2 +- stdlib/asyncio/locks.pyi | 2 +- stdlib/asyncio/proactor_events.pyi | 2 +- stdlib/asyncio/protocols.pyi | 2 +- stdlib/asyncio/queues.pyi | 2 +- stdlib/asyncio/runners.pyi | 2 +- stdlib/asyncio/selector_events.pyi | 1 - stdlib/asyncio/sslproto.pyi | 2 +- stdlib/asyncio/staggered.pyi | 2 +- stdlib/asyncio/streams.pyi | 2 +- stdlib/asyncio/subprocess.pyi | 2 +- stdlib/asyncio/transports.pyi | 2 +- stdlib/asyncio/trsock.pyi | 2 +- stdlib/asyncio/unix_events.pyi | 2 +- stdlib/asyncio/windows_events.pyi | 2 +- stdlib/asyncio/windows_utils.pyi | 2 +- stdlib/asyncore.pyi | 2 +- stdlib/audioop.pyi | 2 +- stdlib/base64.pyi | 2 +- stdlib/bdb.pyi | 2 +- stdlib/binascii.pyi | 1 - stdlib/builtins.pyi | 2 +- stdlib/bz2.pyi | 2 +- stdlib/cProfile.pyi | 2 +- stdlib/calendar.pyi | 2 +- stdlib/cgi.pyi | 2 +- stdlib/cmd.pyi | 2 +- stdlib/codecs.pyi | 4 ++-- stdlib/codeop.pyi | 1 - stdlib/collections/__init__.pyi | 2 +- stdlib/compileall.pyi | 2 +- stdlib/concurrent/futures/_base.pyi | 2 +- stdlib/concurrent/futures/process.pyi | 2 +- stdlib/concurrent/futures/thread.pyi | 2 +- stdlib/configparser.pyi | 4 ++-- stdlib/contextvars.pyi | 2 +- stdlib/copy.pyi | 2 +- stdlib/crypt.pyi | 2 +- stdlib/csv.pyi | 2 +- stdlib/ctypes/util.pyi | 1 - stdlib/curses/ascii.pyi | 2 +- stdlib/curses/textpad.pyi | 2 +- stdlib/dataclasses.pyi | 2 +- stdlib/datetime.pyi | 2 +- stdlib/dbm/__init__.pyi | 2 +- stdlib/dbm/dumb.pyi | 2 +- stdlib/dbm/gnu.pyi | 2 +- stdlib/dbm/ndbm.pyi | 2 +- stdlib/decimal.pyi | 2 +- stdlib/difflib.pyi | 2 +- stdlib/dis.pyi | 2 +- stdlib/distutils/archive_util.pyi | 1 - stdlib/distutils/cmd.pyi | 2 +- stdlib/distutils/core.pyi | 2 +- stdlib/distutils/debug.pyi | 1 - stdlib/distutils/dist.pyi | 2 +- stdlib/distutils/extension.pyi | 2 +- stdlib/distutils/fancy_getopt.pyi | 2 +- stdlib/distutils/file_util.pyi | 2 +- stdlib/distutils/filelist.pyi | 2 +- stdlib/distutils/spawn.pyi | 2 +- stdlib/distutils/sysconfig.pyi | 2 +- stdlib/distutils/text_file.pyi | 2 +- stdlib/distutils/version.pyi | 2 +- stdlib/doctest.pyi | 2 +- stdlib/email/_header_value_parser.pyi | 2 +- stdlib/email/charset.pyi | 2 +- stdlib/email/errors.pyi | 1 - stdlib/email/generator.pyi | 2 +- stdlib/email/header.pyi | 2 +- stdlib/email/headerregistry.pyi | 2 +- stdlib/email/iterators.pyi | 2 +- stdlib/email/mime/message.pyi | 1 - stdlib/email/mime/text.pyi | 1 - stdlib/email/parser.pyi | 2 +- stdlib/email/policy.pyi | 2 +- stdlib/encodings/__init__.pyi | 2 +- stdlib/encodings/utf_8.pyi | 2 +- stdlib/ensurepip/__init__.pyi | 1 - stdlib/enum.pyi | 2 +- stdlib/filecmp.pyi | 2 +- stdlib/fileinput.pyi | 2 +- stdlib/formatter.pyi | 2 +- stdlib/fractions.pyi | 2 +- stdlib/ftplib.pyi | 2 +- stdlib/functools.pyi | 4 ++-- stdlib/gc.pyi | 2 +- stdlib/genericpath.pyi | 2 +- stdlib/getpass.pyi | 2 +- stdlib/gettext.pyi | 2 +- stdlib/glob.pyi | 2 +- stdlib/graphlib.pyi | 2 +- stdlib/grp.pyi | 2 +- stdlib/gzip.pyi | 2 +- stdlib/hashlib.pyi | 2 +- stdlib/heapq.pyi | 2 +- stdlib/hmac.pyi | 2 +- stdlib/html/parser.pyi | 2 +- stdlib/http/client.pyi | 2 +- stdlib/http/cookiejar.pyi | 2 +- stdlib/http/cookies.pyi | 2 +- stdlib/http/server.pyi | 2 +- stdlib/imaplib.pyi | 2 +- stdlib/imghdr.pyi | 2 +- stdlib/imp.pyi | 2 +- stdlib/importlib/__init__.pyi | 2 +- stdlib/importlib/abc.pyi | 2 +- stdlib/importlib/machinery.pyi | 2 +- stdlib/importlib/metadata.pyi | 2 +- stdlib/importlib/util.pyi | 2 +- stdlib/inspect.pyi | 2 +- stdlib/io.pyi | 2 +- stdlib/ipaddress.pyi | 2 +- stdlib/itertools.pyi | 2 +- stdlib/json/__init__.pyi | 2 +- stdlib/json/decoder.pyi | 2 +- stdlib/json/encoder.pyi | 2 +- stdlib/lib2to3/pgen2/driver.pyi | 2 +- stdlib/lib2to3/pgen2/parse.pyi | 2 +- stdlib/lib2to3/pgen2/pgen.pyi | 2 +- stdlib/locale.pyi | 2 +- stdlib/logging/config.pyi | 2 +- stdlib/logging/handlers.pyi | 2 +- stdlib/lzma.pyi | 2 +- stdlib/macpath.pyi | 2 +- stdlib/macurl2path.pyi | 1 - stdlib/mailbox.pyi | 2 +- stdlib/mailcap.pyi | 2 +- stdlib/math.pyi | 2 +- stdlib/mimetypes.pyi | 2 +- stdlib/mmap.pyi | 2 +- stdlib/modulefinder.pyi | 2 +- stdlib/msilib/__init__.pyi | 2 +- stdlib/msilib/schema.pyi | 2 +- stdlib/msilib/text.pyi | 2 +- stdlib/multiprocessing/__init__.pyi | 2 +- stdlib/multiprocessing/connection.pyi | 2 +- stdlib/multiprocessing/context.pyi | 2 +- stdlib/multiprocessing/dummy/__init__.pyi | 2 +- stdlib/multiprocessing/dummy/connection.pyi | 2 +- stdlib/multiprocessing/managers.pyi | 4 ++-- stdlib/multiprocessing/pool.pyi | 2 +- stdlib/multiprocessing/process.pyi | 2 +- stdlib/multiprocessing/queues.pyi | 2 +- stdlib/multiprocessing/shared_memory.pyi | 2 +- stdlib/multiprocessing/sharedctypes.pyi | 2 +- stdlib/multiprocessing/spawn.pyi | 2 +- stdlib/multiprocessing/synchronize.pyi | 2 +- stdlib/nntplib.pyi | 2 +- stdlib/numbers.pyi | 2 +- stdlib/opcode.pyi | 2 +- stdlib/optparse.pyi | 2 +- stdlib/os/__init__.pyi | 2 +- stdlib/pathlib.pyi | 2 +- stdlib/pdb.pyi | 2 +- stdlib/pickletools.pyi | 2 +- stdlib/pkgutil.pyi | 2 +- stdlib/platform.pyi | 2 +- stdlib/plistlib.pyi | 2 +- stdlib/poplib.pyi | 2 +- stdlib/posix.pyi | 2 +- stdlib/posixpath.pyi | 2 +- stdlib/pprint.pyi | 2 +- stdlib/profile.pyi | 2 +- stdlib/pstats.pyi | 2 +- stdlib/pty.pyi | 2 +- stdlib/py_compile.pyi | 2 +- stdlib/pyclbr.pyi | 2 +- stdlib/pydoc.pyi | 2 +- stdlib/pyexpat/__init__.pyi | 2 +- stdlib/queue.pyi | 2 +- stdlib/random.pyi | 2 +- stdlib/re.pyi | 2 +- stdlib/rlcompleter.pyi | 2 +- stdlib/runpy.pyi | 2 +- stdlib/sched.pyi | 2 +- stdlib/secrets.pyi | 2 +- stdlib/select.pyi | 2 +- stdlib/selectors.pyi | 2 +- stdlib/shelve.pyi | 2 +- stdlib/shlex.pyi | 2 +- stdlib/shutil.pyi | 2 +- stdlib/site.pyi | 2 +- stdlib/smtpd.pyi | 2 +- stdlib/smtplib.pyi | 2 +- stdlib/sndhdr.pyi | 2 +- stdlib/socket.pyi | 2 +- stdlib/socketserver.pyi | 2 +- stdlib/sqlite3/dbapi2.pyi | 2 +- stdlib/sre_compile.pyi | 2 +- stdlib/sre_constants.pyi | 2 +- stdlib/statistics.pyi | 2 +- stdlib/string.pyi | 2 +- stdlib/struct.pyi | 2 +- stdlib/subprocess.pyi | 4 ++-- stdlib/sunau.pyi | 2 +- stdlib/symtable.pyi | 2 +- stdlib/sysconfig.pyi | 2 +- stdlib/tarfile.pyi | 2 +- stdlib/telnetlib.pyi | 2 +- stdlib/tempfile.pyi | 2 +- stdlib/textwrap.pyi | 2 +- stdlib/threading.pyi | 2 +- stdlib/time.pyi | 2 +- stdlib/timeit.pyi | 2 +- stdlib/tkinter/colorchooser.pyi | 2 +- stdlib/tkinter/commondialog.pyi | 2 +- stdlib/tkinter/dialog.pyi | 2 +- stdlib/tkinter/dnd.pyi | 2 +- stdlib/tkinter/filedialog.pyi | 2 +- stdlib/tkinter/font.pyi | 2 +- stdlib/tkinter/messagebox.pyi | 2 +- stdlib/tkinter/scrolledtext.pyi | 2 +- stdlib/tkinter/simpledialog.pyi | 2 +- stdlib/tkinter/tix.pyi | 2 +- stdlib/tkinter/ttk.pyi | 2 +- stdlib/tokenize.pyi | 2 +- stdlib/trace.pyi | 2 +- stdlib/turtle.pyi | 2 +- stdlib/types.pyi | 2 +- stdlib/typing_extensions.pyi | 4 ++-- stdlib/unicodedata.pyi | 2 +- stdlib/unittest/__init__.pyi | 1 - stdlib/unittest/case.pyi | 4 ++-- stdlib/unittest/loader.pyi | 2 +- stdlib/unittest/main.pyi | 2 +- stdlib/unittest/mock.pyi | 2 +- stdlib/unittest/result.pyi | 2 +- stdlib/unittest/runner.pyi | 2 +- stdlib/urllib/error.pyi | 2 +- stdlib/urllib/parse.pyi | 2 +- stdlib/urllib/request.pyi | 4 ++-- stdlib/urllib/response.pyi | 2 +- stdlib/urllib/robotparser.pyi | 2 +- stdlib/uu.pyi | 2 +- stdlib/uuid.pyi | 2 +- stdlib/venv/__init__.pyi | 2 +- stdlib/warnings.pyi | 2 +- stdlib/wave.pyi | 2 +- stdlib/weakref.pyi | 4 ++-- stdlib/webbrowser.pyi | 2 +- stdlib/winreg.pyi | 2 +- stdlib/winsound.pyi | 2 +- stdlib/wsgiref/headers.pyi | 2 +- stdlib/wsgiref/simple_server.pyi | 2 +- stdlib/wsgiref/util.pyi | 2 +- stdlib/wsgiref/validate.pyi | 2 +- stdlib/xml/dom/domreg.pyi | 2 +- stdlib/xml/dom/minicompat.pyi | 2 +- stdlib/xml/dom/minidom.pyi | 2 +- stdlib/xml/dom/pulldom.pyi | 2 +- stdlib/xml/etree/ElementInclude.pyi | 2 +- stdlib/xml/etree/ElementPath.pyi | 2 +- stdlib/xml/etree/ElementTree.pyi | 2 +- stdlib/xml/sax/__init__.pyi | 2 +- stdlib/xml/sax/saxutils.pyi | 2 +- stdlib/xml/sax/xmlreader.pyi | 2 +- stdlib/xmlrpc/client.pyi | 2 +- stdlib/xmlrpc/server.pyi | 2 +- stdlib/zipapp.pyi | 2 +- stdlib/zipfile.pyi | 2 +- stdlib/zipimport.pyi | 2 +- stdlib/zlib.pyi | 2 +- stdlib/zoneinfo/__init__.pyi | 2 +- stubs/DateTimeRange/datetimerange/__init__.pyi | 2 +- stubs/Deprecated/deprecated/classic.pyi | 2 +- stubs/Deprecated/deprecated/sphinx.pyi | 2 +- stubs/Flask/flask/blueprints.pyi | 2 +- stubs/Flask/flask/cli.pyi | 2 +- stubs/Flask/flask/config.pyi | 2 +- stubs/Flask/flask/ctx.pyi | 2 +- stubs/Flask/flask/helpers.pyi | 2 +- stubs/Flask/flask/json/tag.pyi | 2 +- stubs/Flask/flask/sessions.pyi | 2 +- stubs/Flask/flask/signals.pyi | 2 +- stubs/Flask/flask/templating.pyi | 2 +- stubs/Flask/flask/testing.pyi | 2 +- stubs/Flask/flask/wrappers.pyi | 2 +- stubs/JACK-Client/jack/__init__.pyi | 2 +- stubs/Jinja2/jinja2/_compat.pyi | 2 +- stubs/Jinja2/jinja2/bccache.pyi | 2 +- stubs/Jinja2/jinja2/compiler.pyi | 2 +- stubs/Jinja2/jinja2/debug.pyi | 2 +- stubs/Jinja2/jinja2/defaults.pyi | 2 +- stubs/Jinja2/jinja2/environment.pyi | 2 +- stubs/Jinja2/jinja2/exceptions.pyi | 2 +- stubs/Jinja2/jinja2/ext.pyi | 2 +- stubs/Jinja2/jinja2/filters.pyi | 2 +- stubs/Jinja2/jinja2/lexer.pyi | 2 +- stubs/Jinja2/jinja2/loaders.pyi | 2 +- stubs/Jinja2/jinja2/nodes.pyi | 2 +- stubs/Jinja2/jinja2/parser.pyi | 2 +- stubs/Jinja2/jinja2/runtime.pyi | 2 +- stubs/Jinja2/jinja2/utils.pyi | 2 +- stubs/Markdown/markdown/core.pyi | 2 +- stubs/Markdown/markdown/extensions/codehilite.pyi | 2 +- stubs/Markdown/markdown/inlinepatterns.pyi | 2 +- stubs/Markdown/markdown/treeprocessors.pyi | 2 +- stubs/Markdown/markdown/util.pyi | 2 +- stubs/MarkupSafe/markupsafe/__init__.pyi | 2 +- stubs/MarkupSafe/markupsafe/_native.pyi | 2 +- stubs/MarkupSafe/markupsafe/_speedups.pyi | 2 +- stubs/PyMySQL/pymysql/cursors.pyi | 2 +- stubs/PyYAML/yaml/__init__.pyi | 2 +- stubs/PyYAML/yaml/composer.pyi | 2 +- stubs/PyYAML/yaml/cyaml.pyi | 2 +- stubs/Pygments/pygments/__init__.pyi | 2 +- stubs/Pygments/pygments/cmdline.pyi | 2 +- stubs/Pygments/pygments/filter.pyi | 2 +- stubs/Pygments/pygments/formatters/html.pyi | 2 +- stubs/Pygments/pygments/formatters/terminal256.pyi | 2 +- stubs/Pygments/pygments/lexer.pyi | 2 +- stubs/Pygments/pygments/util.pyi | 2 +- stubs/Werkzeug/werkzeug/_compat.pyi | 2 +- stubs/Werkzeug/werkzeug/_internal.pyi | 2 +- stubs/Werkzeug/werkzeug/_reloader.pyi | 2 +- stubs/Werkzeug/werkzeug/contrib/atom.pyi | 2 +- stubs/Werkzeug/werkzeug/contrib/cache.pyi | 2 +- stubs/Werkzeug/werkzeug/contrib/fixers.pyi | 2 +- stubs/Werkzeug/werkzeug/contrib/iterio.pyi | 2 +- stubs/Werkzeug/werkzeug/contrib/securecookie.pyi | 2 +- stubs/Werkzeug/werkzeug/contrib/sessions.pyi | 2 +- stubs/Werkzeug/werkzeug/datastructures.pyi | 4 ++-- stubs/Werkzeug/werkzeug/debug/__init__.pyi | 2 +- stubs/Werkzeug/werkzeug/debug/console.pyi | 2 +- stubs/Werkzeug/werkzeug/debug/repr.pyi | 2 +- stubs/Werkzeug/werkzeug/debug/tbtools.pyi | 2 +- stubs/Werkzeug/werkzeug/exceptions.pyi | 2 +- stubs/Werkzeug/werkzeug/formparser.pyi | 2 +- stubs/Werkzeug/werkzeug/http.pyi | 2 +- stubs/Werkzeug/werkzeug/local.pyi | 2 +- stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi | 2 +- stubs/Werkzeug/werkzeug/middleware/lint.pyi | 2 +- stubs/Werkzeug/werkzeug/middleware/profiler.pyi | 2 +- stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi | 2 +- stubs/Werkzeug/werkzeug/routing.pyi | 2 +- stubs/Werkzeug/werkzeug/script.pyi | 2 +- stubs/Werkzeug/werkzeug/security.pyi | 2 +- stubs/Werkzeug/werkzeug/serving.pyi | 2 +- stubs/Werkzeug/werkzeug/test.pyi | 2 +- stubs/Werkzeug/werkzeug/urls.pyi | 2 +- stubs/Werkzeug/werkzeug/useragents.pyi | 2 +- stubs/Werkzeug/werkzeug/utils.pyi | 2 +- stubs/Werkzeug/werkzeug/wrappers.pyi | 4 ++-- stubs/Werkzeug/werkzeug/wsgi.pyi | 2 +- stubs/aiofiles/aiofiles/base.pyi | 2 +- stubs/aiofiles/aiofiles/os.pyi | 2 +- stubs/aiofiles/aiofiles/threadpool/__init__.pyi | 2 +- stubs/aiofiles/aiofiles/threadpool/binary.pyi | 2 +- stubs/aiofiles/aiofiles/threadpool/text.pyi | 2 +- stubs/atomicwrites/atomicwrites/__init__.pyi | 2 +- stubs/bleach/bleach/__init__.pyi | 2 +- stubs/bleach/bleach/html5lib_shim.pyi | 2 +- stubs/bleach/bleach/linkifier.pyi | 2 +- stubs/bleach/bleach/sanitizer.pyi | 2 +- stubs/boto/boto/__init__.pyi | 2 +- stubs/boto/boto/auth.pyi | 2 +- stubs/boto/boto/connection.pyi | 2 +- stubs/boto/boto/exception.pyi | 2 +- stubs/boto/boto/kms/layer1.pyi | 2 +- stubs/boto/boto/plugin.pyi | 2 +- stubs/boto/boto/regioninfo.pyi | 2 +- stubs/boto/boto/s3/__init__.pyi | 2 +- stubs/boto/boto/s3/acl.pyi | 2 +- stubs/boto/boto/s3/bucket.pyi | 2 +- stubs/boto/boto/s3/bucketlistresultset.pyi | 2 +- stubs/boto/boto/s3/bucketlogging.pyi | 2 +- stubs/boto/boto/s3/connection.pyi | 2 +- stubs/boto/boto/s3/cors.pyi | 2 +- stubs/boto/boto/s3/deletemarker.pyi | 2 +- stubs/boto/boto/s3/key.pyi | 2 +- stubs/boto/boto/s3/lifecycle.pyi | 2 +- stubs/boto/boto/s3/multidelete.pyi | 2 +- stubs/boto/boto/s3/multipart.pyi | 2 +- stubs/boto/boto/s3/prefix.pyi | 2 +- stubs/boto/boto/s3/tagging.pyi | 2 +- stubs/boto/boto/s3/user.pyi | 2 +- stubs/boto/boto/s3/website.pyi | 2 +- stubs/boto/boto/utils.pyi | 4 ++-- stubs/cachetools/cachetools/cache.pyi | 2 +- stubs/cachetools/cachetools/decorators.pyi | 2 +- stubs/cachetools/cachetools/func.pyi | 2 +- stubs/cachetools/cachetools/lfu.pyi | 2 +- stubs/cachetools/cachetools/lru.pyi | 2 +- stubs/cachetools/cachetools/rr.pyi | 2 +- stubs/cachetools/cachetools/ttl.pyi | 2 +- stubs/characteristic/characteristic/__init__.pyi | 2 +- stubs/chardet/chardet/universaldetector.pyi | 2 +- stubs/click-spinner/click_spinner/__init__.pyi | 2 +- stubs/click/click/_termui_impl.pyi | 2 +- stubs/click/click/core.pyi | 2 +- stubs/click/click/decorators.pyi | 2 +- stubs/click/click/exceptions.pyi | 2 +- stubs/click/click/formatting.pyi | 2 +- stubs/click/click/globals.pyi | 1 - stubs/click/click/parser.pyi | 2 +- stubs/click/click/termui.pyi | 2 +- stubs/click/click/testing.pyi | 2 +- stubs/click/click/utils.pyi | 2 +- stubs/colorama/colorama/initialise.pyi | 2 +- stubs/colorama/colorama/winterm.pyi | 3 +-- stubs/croniter/croniter.pyi | 2 +- stubs/cryptography/cryptography/fernet.pyi | 2 +- .../cryptography/cryptography/hazmat/backends/interfaces.pyi | 2 +- .../cryptography/hazmat/bindings/openssl/binding.pyi | 2 +- .../cryptography/hazmat/primitives/asymmetric/dh.pyi | 1 - .../cryptography/hazmat/primitives/asymmetric/dsa.pyi | 1 - .../cryptography/hazmat/primitives/asymmetric/ec.pyi | 2 +- .../cryptography/hazmat/primitives/asymmetric/padding.pyi | 2 +- .../cryptography/hazmat/primitives/asymmetric/rsa.pyi | 2 +- .../cryptography/hazmat/primitives/ciphers/__init__.pyi | 1 - .../cryptography/hazmat/primitives/ciphers/aead.pyi | 1 - .../cryptography/hazmat/primitives/ciphers/modes.pyi | 1 - stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi | 1 - stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi | 1 - stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi | 1 - .../cryptography/hazmat/primitives/kdf/concatkdf.pyi | 1 - .../cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi | 1 - .../cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi | 1 - .../cryptography/hazmat/primitives/kdf/pbkdf2.pyi | 1 - .../cryptography/hazmat/primitives/kdf/scrypt.pyi | 1 - .../cryptography/hazmat/primitives/kdf/x963kdf.pyi | 1 - stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi | 1 - .../cryptography/hazmat/primitives/serialization/__init__.pyi | 2 +- .../cryptography/hazmat/primitives/serialization/pkcs12.pyi | 2 +- .../cryptography/hazmat/primitives/serialization/pkcs7.pyi | 2 +- .../cryptography/hazmat/primitives/twofactor/hotp.pyi | 1 - .../cryptography/hazmat/primitives/twofactor/totp.pyi | 1 - stubs/cryptography/cryptography/x509/__init__.pyi | 2 +- stubs/cryptography/cryptography/x509/oid.pyi | 2 +- stubs/dataclasses/dataclasses.pyi | 2 +- stubs/dateparser/dateparser.pyi | 2 +- stubs/decorator/decorator.pyi | 2 +- stubs/docopt/docopt.pyi | 2 +- stubs/docutils/docutils/__init__.pyi | 2 +- stubs/docutils/docutils/frontend.pyi | 2 +- stubs/docutils/docutils/io.pyi | 2 +- stubs/docutils/docutils/parsers/rst/__init__.pyi | 2 +- stubs/docutils/docutils/utils/__init__.pyi | 2 +- stubs/emoji/emoji/core.pyi | 2 +- stubs/filelock/filelock/__init__.pyi | 2 +- stubs/first/first.pyi | 2 +- stubs/geoip2/geoip2/errors.pyi | 2 +- stubs/itsdangerous/itsdangerous.pyi | 2 +- stubs/maxminddb/maxminddb/reader.pyi | 2 +- stubs/mock/mock.pyi | 2 +- stubs/mypy-extensions/mypy_extensions.pyi | 2 +- stubs/nmap/nmap/nmap.pyi | 2 +- stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi | 2 +- stubs/orjson/orjson.pyi | 2 +- stubs/paramiko/paramiko/_winapi.pyi | 2 +- stubs/paramiko/paramiko/auth_handler.pyi | 2 +- stubs/paramiko/paramiko/ber.pyi | 2 +- stubs/paramiko/paramiko/buffered_pipe.pyi | 2 +- stubs/paramiko/paramiko/channel.pyi | 2 +- stubs/paramiko/paramiko/client.pyi | 2 +- stubs/paramiko/paramiko/config.pyi | 2 +- stubs/paramiko/paramiko/dsskey.pyi | 2 +- stubs/paramiko/paramiko/ecdsakey.pyi | 2 +- stubs/paramiko/paramiko/ed25519key.pyi | 2 +- stubs/paramiko/paramiko/file.pyi | 2 +- stubs/paramiko/paramiko/hostkeys.pyi | 2 +- stubs/paramiko/paramiko/kex_curve25519.pyi | 2 +- stubs/paramiko/paramiko/kex_ecdh_nist.pyi | 2 +- stubs/paramiko/paramiko/kex_gex.pyi | 2 +- stubs/paramiko/paramiko/kex_gss.pyi | 1 - stubs/paramiko/paramiko/message.pyi | 2 +- stubs/paramiko/paramiko/pkey.pyi | 2 +- stubs/paramiko/paramiko/proxy.pyi | 2 +- stubs/paramiko/paramiko/py3compat.pyi | 2 +- stubs/paramiko/paramiko/rsakey.pyi | 2 +- stubs/paramiko/paramiko/server.pyi | 2 +- stubs/paramiko/paramiko/sftp.pyi | 2 +- stubs/paramiko/paramiko/sftp_attr.pyi | 2 +- stubs/paramiko/paramiko/sftp_client.pyi | 2 +- stubs/paramiko/paramiko/sftp_file.pyi | 2 +- stubs/paramiko/paramiko/sftp_handle.pyi | 1 - stubs/paramiko/paramiko/sftp_server.pyi | 2 +- stubs/paramiko/paramiko/sftp_si.pyi | 2 +- stubs/paramiko/paramiko/ssh_exception.pyi | 2 +- stubs/paramiko/paramiko/ssh_gss.pyi | 2 +- stubs/paramiko/paramiko/transport.pyi | 2 +- stubs/paramiko/paramiko/util.pyi | 2 +- stubs/polib/polib.pyi | 2 +- stubs/protobuf/google/protobuf/descriptor_pool.pyi | 2 +- stubs/protobuf/google/protobuf/internal/containers.pyi | 2 +- stubs/protobuf/google/protobuf/internal/extension_dict.pyi | 2 +- stubs/protobuf/google/protobuf/internal/well_known_types.pyi | 2 +- stubs/protobuf/google/protobuf/json_format.pyi | 2 +- stubs/protobuf/google/protobuf/message_factory.pyi | 2 +- stubs/protobuf/google/protobuf/service.pyi | 2 +- stubs/protobuf/google/protobuf/symbol_database.pyi | 2 +- stubs/protobuf/google/protobuf/text_format.pyi | 2 +- stubs/pyRFC3339/pyrfc3339/utils.pyi | 1 - stubs/pysftp/pysftp/__init__.pyi | 2 +- stubs/pysftp/pysftp/helpers.pyi | 2 +- stubs/python-dateutil/dateutil/_common.pyi | 2 +- stubs/python-dateutil/dateutil/parser.pyi | 2 +- stubs/python-dateutil/dateutil/relativedelta.pyi | 2 +- stubs/python-dateutil/dateutil/rrule.pyi | 2 +- stubs/python-dateutil/dateutil/tz/_common.pyi | 2 +- stubs/python-dateutil/dateutil/tz/tz.pyi | 2 +- stubs/python-dateutil/dateutil/utils.pyi | 1 - stubs/python-gflags/gflags.pyi | 2 +- stubs/python-slugify/slugify/slugify.pyi | 2 +- stubs/pytz/pytz/__init__.pyi | 2 +- stubs/pyvmomi/pyVmomi/vmodl/query.pyi | 2 +- stubs/redis/redis/client.pyi | 2 +- stubs/redis/redis/connection.pyi | 2 +- stubs/redis/redis/lock.pyi | 2 +- stubs/redis/redis/utils.pyi | 2 +- stubs/requests/requests/adapters.pyi | 2 +- stubs/requests/requests/api.pyi | 2 +- stubs/requests/requests/auth.pyi | 2 +- stubs/requests/requests/models.pyi | 2 +- stubs/requests/requests/structures.pyi | 2 +- stubs/requests/requests/utils.pyi | 2 +- stubs/retry/retry/api.pyi | 2 +- stubs/simplejson/simplejson/scanner.pyi | 1 - stubs/six/six/__init__.pyi | 4 ++-- stubs/tabulate/tabulate.pyi | 2 +- stubs/termcolor/termcolor.pyi | 2 +- stubs/typed-ast/typed_ast/ast27.pyi | 2 +- stubs/typed-ast/typed_ast/ast3.pyi | 2 +- stubs/waitress/waitress/adjustments.pyi | 2 +- stubs/waitress/waitress/buffers.pyi | 2 +- stubs/waitress/waitress/channel.pyi | 2 +- stubs/waitress/waitress/compat.pyi | 2 +- stubs/waitress/waitress/parser.pyi | 2 +- stubs/waitress/waitress/proxy_headers.pyi | 2 +- stubs/waitress/waitress/receiver.pyi | 1 - stubs/waitress/waitress/runner.pyi | 2 +- stubs/waitress/waitress/server.pyi | 2 +- stubs/waitress/waitress/task.pyi | 2 +- stubs/waitress/waitress/trigger.pyi | 2 +- stubs/waitress/waitress/wasyncore.pyi | 2 +- 566 files changed, 542 insertions(+), 581 deletions(-) diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index 97f140d61513..66e3be054f5e 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -1,6 +1,6 @@ import sys import typing -from typing import Any, ClassVar, Optional +from typing import Any, ClassVar from typing_extensions import Literal PyCF_ONLY_AST: int diff --git a/stdlib/_bisect.pyi b/stdlib/_bisect.pyi index 2ef92b205257..6da6e7f58823 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import SupportsLessThan -from typing import Callable, MutableSequence, Optional, Sequence, TypeVar +from typing import Callable, MutableSequence, Sequence, TypeVar _T = TypeVar("_T") diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index c5026bacd75b..aa30309cb53c 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -1,6 +1,6 @@ import codecs import sys -from typing import Any, Callable, Dict, Optional, Tuple, Union +from typing import Any, Callable, Dict, Tuple, Union # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap: diff --git a/stdlib/_compression.pyi b/stdlib/_compression.pyi index 12a160566958..8f81847ff492 100644 --- a/stdlib/_compression.pyi +++ b/stdlib/_compression.pyi @@ -1,6 +1,6 @@ from _typeshed import WriteableBuffer from io import BufferedIOBase, RawIOBase -from typing import Any, Callable, Protocol, Tuple, Type, Union +from typing import Any, Callable, Protocol, Tuple, Type BUFFER_SIZE: Any diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index ef85aca8d6f0..94f304f3e3d1 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, List, Optional, Protocol, Type, Union +from typing import Any, Iterable, Iterator, List, Protocol, Type, Union QUOTE_ALL: int QUOTE_MINIMAL: int diff --git a/stdlib/_curses.pyi b/stdlib/_curses.pyi index bb2d4fdbd4bb..96a391b75606 100644 --- a/stdlib/_curses.pyi +++ b/stdlib/_curses.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, BinaryIO, NamedTuple, Optional, Tuple, Union, overload +from typing import IO, Any, BinaryIO, NamedTuple, Tuple, Union, overload _chtype = Union[str, bytes, int] diff --git a/stdlib/_dummy_thread.pyi b/stdlib/_dummy_thread.pyi index a9ccdd56c8d1..ef0576799251 100644 --- a/stdlib/_dummy_thread.pyi +++ b/stdlib/_dummy_thread.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, NoReturn, Optional, Tuple +from typing import Any, Callable, Dict, NoReturn, Tuple TIMEOUT_MAX: int error = RuntimeError diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index 47246fe05f0e..00394d500209 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -1,6 +1,6 @@ import sys from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, List, Mapping, Optional, Type, TypeVar, Union +from typing import Any, Callable, Iterable, List, Mapping, Optional, Type, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] diff --git a/stdlib/_json.pyi b/stdlib/_json.pyi index ddfde30a312b..14b5c93e6e8d 100644 --- a/stdlib/_json.pyi +++ b/stdlib/_json.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Optional, Tuple +from typing import Any, Callable, Dict, Tuple class make_encoder: sort_keys: Any diff --git a/stdlib/_msi.pyi b/stdlib/_msi.pyi index f70a6df31a74..a1030a66160f 100644 --- a/stdlib/_msi.pyi +++ b/stdlib/_msi.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Optional, Union +from typing import List if sys.platform == "win32": diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index 0362ebef3a2f..1b890d8d8a0a 100644 --- a/stdlib/_osx_support.pyi +++ b/stdlib/_osx_support.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Iterable, List, Optional, Sequence, Tuple, TypeVar, Union +from typing import Dict, Iterable, List, Sequence, Tuple, TypeVar _T = TypeVar("_T") _K = TypeVar("_K") diff --git a/stdlib/_sitebuiltins.pyi b/stdlib/_sitebuiltins.pyi index f00084b9e25d..a71364b8db65 100644 --- a/stdlib/_sitebuiltins.pyi +++ b/stdlib/_sitebuiltins.pyi @@ -1,4 +1,4 @@ -from typing import ClassVar, Iterable, NoReturn, Optional +from typing import ClassVar, Iterable, NoReturn from typing_extensions import Literal class Quitter: diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index cb76e35d3868..7945c662e820 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Iterable -from typing import Any, Optional, SupportsInt, Tuple, Union, overload +from typing import Any, SupportsInt, Tuple, Union, overload if sys.version_info >= (3, 8): from typing import SupportsIndex diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 234331fcaa4c..049c7e1e3ef4 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -1,7 +1,7 @@ import sys from threading import Thread from types import TracebackType -from typing import Any, Callable, Dict, NoReturn, Optional, Tuple, Type +from typing import Any, Callable, Dict, NoReturn, Tuple, Type error = RuntimeError diff --git a/stdlib/_tracemalloc.pyi b/stdlib/_tracemalloc.pyi index 0b7550c7ef51..4a538c5e111a 100644 --- a/stdlib/_tracemalloc.pyi +++ b/stdlib/_tracemalloc.pyi @@ -1,6 +1,6 @@ import sys from tracemalloc import _FrameTupleT, _TraceTupleT -from typing import Optional, Sequence, Tuple +from typing import Sequence, Tuple def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ... def _get_traces() -> Sequence[_TraceTupleT]: ... diff --git a/stdlib/_typeshed/wsgi.pyi b/stdlib/_typeshed/wsgi.pyi index 7ec00c341666..2f201444916b 100644 --- a/stdlib/_typeshed/wsgi.pyi +++ b/stdlib/_typeshed/wsgi.pyi @@ -3,7 +3,7 @@ # See the README.md file in this directory for more information. from sys import _OptExcInfo -from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Tuple +from typing import Any, Callable, Dict, Iterable, List, Protocol, Tuple # stable class StartResponse(Protocol): diff --git a/stdlib/_typeshed/xml.pyi b/stdlib/_typeshed/xml.pyi index 9017589a4e0d..d53b743af2d3 100644 --- a/stdlib/_typeshed/xml.pyi +++ b/stdlib/_typeshed/xml.pyi @@ -1,6 +1,6 @@ # See the README.md file in this directory for more information. -from typing import Any, Optional +from typing import Any from typing_extensions import Protocol # As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects diff --git a/stdlib/_warnings.pyi b/stdlib/_warnings.pyi index 2cfb48f3b4cc..e0a1ccf5c201 100644 --- a/stdlib/_warnings.pyi +++ b/stdlib/_warnings.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload +from typing import Any, Dict, List, Tuple, Type, overload _defaultaction: str _onceregistry: Dict[Any, Any] diff --git a/stdlib/_weakref.pyi b/stdlib/_weakref.pyi index f366213e2bd4..51d8205e7eff 100644 --- a/stdlib/_weakref.pyi +++ b/stdlib/_weakref.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Generic, List, Optional, TypeVar, overload +from typing import Any, Callable, Generic, List, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/_weakrefset.pyi b/stdlib/_weakrefset.pyi index 82cae5660de5..1f0132f4c240 100644 --- a/stdlib/_weakrefset.pyi +++ b/stdlib/_weakrefset.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Generic, Iterable, Iterator, MutableSet, Optional, TypeVar, Union +from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index d6351ca2ebb2..5e3db51435cd 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, NoReturn, Optional, Sequence, Tuple, Union, overload +from typing import Any, Dict, NoReturn, Sequence, Tuple, overload from typing_extensions import Literal CREATE_NEW_CONSOLE: int diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index fdf5a1b82834..c54ada6a1ebc 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self from types import TracebackType -from typing import IO, Any, List, NamedTuple, Optional, Tuple, Type, Union, overload +from typing import IO, Any, List, NamedTuple, Tuple, Type, Union, overload from typing_extensions import Literal class Error(Exception): ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index a674cd70f28c..3af265e1e287 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -8,14 +8,14 @@ from typing import ( Iterable, List, NoReturn, - Optional, + Pattern, Protocol, Sequence, Tuple, Type, TypeVar, - Union, + overload, ) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 0f4e79db7ca7..1649e4ab41be 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -8,7 +8,7 @@ # sys. import sys import typing as _typing -from typing import Any, Iterator, Optional, TypeVar, Union, overload +from typing import Any, Iterator, TypeVar, overload from typing_extensions import Literal from _ast import * # type: ignore diff --git a/stdlib/asynchat.pyi b/stdlib/asynchat.pyi index 4fabf46f4ed6..e1787ca98b4f 100644 --- a/stdlib/asynchat.pyi +++ b/stdlib/asynchat.pyi @@ -1,7 +1,6 @@ import asyncore import socket from abc import abstractmethod -from typing import Optional, Union class simple_producer: def __init__(self, data: bytes, buffer_size: int = ...) -> None: ... diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 2599f050fd77..d3cdc9b31d26 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -9,7 +9,7 @@ from asyncio.tasks import Task from asyncio.transports import BaseTransport from collections.abc import Iterable from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Sequence, Tuple, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 7): diff --git a/stdlib/asyncio/base_tasks.pyi b/stdlib/asyncio/base_tasks.pyi index 94c39a1e7592..0bb394f1beb8 100644 --- a/stdlib/asyncio/base_tasks.pyi +++ b/stdlib/asyncio/base_tasks.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath from types import FrameType -from typing import Any, List, Optional +from typing import Any, List from . import tasks diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index fcfaebd8ed18..c66163b45ff7 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -3,7 +3,7 @@ import sys from _typeshed import FileDescriptorLike, Self from abc import ABCMeta, abstractmethod from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket -from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload +from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Sequence, Tuple, TypeVar, Union, overload from typing_extensions import Literal from .base_events import Server diff --git a/stdlib/asyncio/exceptions.pyi b/stdlib/asyncio/exceptions.pyi index 5ee8a3ea3c08..5b99966329ac 100644 --- a/stdlib/asyncio/exceptions.pyi +++ b/stdlib/asyncio/exceptions.pyi @@ -1,5 +1,4 @@ import sys -from typing import Optional if sys.version_info >= (3, 8): class CancelledError(BaseException): ... diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index 8dd07a7a90b2..5e09a6798892 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -2,7 +2,7 @@ import functools import sys import traceback from types import FrameType, FunctionType -from typing import Any, Dict, Iterable, Optional, Tuple, Union, overload +from typing import Any, Dict, Iterable, Tuple, Union, overload class _HasWrapper: __wrapper__: _HasWrapper | FunctionType diff --git a/stdlib/asyncio/futures.pyi b/stdlib/asyncio/futures.pyi index a5b19cacccd9..a8954e75a03b 100644 --- a/stdlib/asyncio/futures.pyi +++ b/stdlib/asyncio/futures.pyi @@ -1,6 +1,6 @@ import sys from concurrent.futures._base import Error, Future as _ConcurrentFuture -from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple, TypeVar, Union +from typing import Any, Awaitable, Callable, Generator, Iterable, List, Tuple, TypeVar from .events import AbstractEventLoop diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index af605f9a93e6..901232740773 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,6 +1,6 @@ import sys from types import TracebackType -from typing import Any, Awaitable, Callable, Deque, Generator, Optional, Type, TypeVar, Union +from typing import Any, Awaitable, Callable, Deque, Generator, Type, TypeVar from .events import AbstractEventLoop from .futures import Future diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index b2a1b104b89b..26a19dde5d35 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -1,6 +1,6 @@ import sys from socket import socket -from typing import Any, Mapping, Optional, Type +from typing import Any, Mapping, Type from typing_extensions import Literal, Protocol from . import base_events, constants, events, futures, streams, transports diff --git a/stdlib/asyncio/protocols.pyi b/stdlib/asyncio/protocols.pyi index a6b356550edb..675994906778 100644 --- a/stdlib/asyncio/protocols.pyi +++ b/stdlib/asyncio/protocols.pyi @@ -1,6 +1,6 @@ import sys from asyncio import transports -from typing import Optional, Tuple +from typing import Tuple class BaseProtocol: def connection_made(self, transport: transports.BaseTransport) -> None: ... diff --git a/stdlib/asyncio/queues.pyi b/stdlib/asyncio/queues.pyi index 25d815aed455..aff4af727b08 100644 --- a/stdlib/asyncio/queues.pyi +++ b/stdlib/asyncio/queues.pyi @@ -1,6 +1,6 @@ import sys from asyncio.events import AbstractEventLoop -from typing import Any, Generic, Optional, TypeVar +from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/asyncio/runners.pyi b/stdlib/asyncio/runners.pyi index aa914fac0767..3f0f42eef48b 100644 --- a/stdlib/asyncio/runners.pyi +++ b/stdlib/asyncio/runners.pyi @@ -1,7 +1,7 @@ import sys if sys.version_info >= (3, 7): - from typing import Awaitable, Optional, TypeVar + from typing import Awaitable, TypeVar _T = TypeVar("_T") if sys.version_info >= (3, 8): diff --git a/stdlib/asyncio/selector_events.pyi b/stdlib/asyncio/selector_events.pyi index 7ed70cda0ad7..bcbcd2fbe4b8 100644 --- a/stdlib/asyncio/selector_events.pyi +++ b/stdlib/asyncio/selector_events.pyi @@ -1,5 +1,4 @@ import selectors -from typing import Optional from . import base_events diff --git a/stdlib/asyncio/sslproto.pyi b/stdlib/asyncio/sslproto.pyi index ad4c537fbbab..7bbb6215e1d6 100644 --- a/stdlib/asyncio/sslproto.pyi +++ b/stdlib/asyncio/sslproto.pyi @@ -1,6 +1,6 @@ import ssl import sys -from typing import Any, Callable, ClassVar, Deque, Dict, List, Optional, Tuple +from typing import Any, Callable, ClassVar, Deque, Dict, List, Tuple from typing_extensions import Literal from . import constants, events, futures, protocols, transports diff --git a/stdlib/asyncio/staggered.pyi b/stdlib/asyncio/staggered.pyi index ded4611de8dc..93227bf2c6b9 100644 --- a/stdlib/asyncio/staggered.pyi +++ b/stdlib/asyncio/staggered.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Awaitable, Callable, Iterable, List, Optional, Tuple +from typing import Any, Awaitable, Callable, Iterable, List, Tuple from . import events diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index 75e7e96bfc0d..6598110f87f9 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple, Union +from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple from . import events, protocols, transports from .base_events import Server diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index 544d31e5e35b..428260af5465 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -2,7 +2,7 @@ import subprocess import sys from _typeshed import StrOrBytesPath from asyncio import events, protocols, streams, transports -from typing import IO, Any, Callable, Optional, Tuple, Union +from typing import IO, Any, Callable, Tuple, Union from typing_extensions import Literal if sys.version_info >= (3, 8): diff --git a/stdlib/asyncio/transports.pyi b/stdlib/asyncio/transports.pyi index 7508cb789ea4..0dc5f63cef53 100644 --- a/stdlib/asyncio/transports.pyi +++ b/stdlib/asyncio/transports.pyi @@ -2,7 +2,7 @@ import sys from asyncio.events import AbstractEventLoop from asyncio.protocols import BaseProtocol from socket import _Address -from typing import Any, List, Mapping, Optional, Tuple +from typing import Any, List, Mapping, Tuple class BaseTransport: def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ... diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index bc7a680cb25f..ffb2095d4291 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -1,7 +1,7 @@ import socket import sys from types import TracebackType -from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Tuple, Type, Union, overload +from typing import Any, BinaryIO, Iterable, List, NoReturn, Tuple, Type, Union, overload if sys.version_info >= (3, 8): # These are based in socket, maybe move them out into _typeshed.pyi or such diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index cb35a3db4695..e8e57a20a765 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -2,7 +2,7 @@ import sys import types from _typeshed import Self from socket import socket -from typing import Any, Callable, Optional, Type +from typing import Any, Callable, Type from .base_events import Server from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index 266a5760839d..8a8bfd8ecca8 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -1,7 +1,7 @@ import socket import sys from _typeshed import WriteableBuffer -from typing import IO, Any, Callable, ClassVar, List, NoReturn, Optional, Tuple, Type +from typing import IO, Any, Callable, ClassVar, List, NoReturn, Tuple, Type from . import events, futures, proactor_events, selector_events, streams, windows_utils diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index 66c06661acb2..f32ed3c80389 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self from types import TracebackType -from typing import Callable, Optional, Protocol, Tuple, Type +from typing import Callable, Protocol, Tuple, Type class _WarnFunction(Protocol): def __call__(self, message: str, category: Type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ...) -> None: ... diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index 80b7747c5d0e..a43fb55ed9df 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike from socket import socket -from typing import Any, Dict, Optional, Tuple, Union, overload +from typing import Any, Dict, Tuple, overload # cyclic dependence with asynchat _maptype = Dict[int, Any] diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index 53ba6a46ec44..e969f60e579d 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Tuple +from typing import Tuple AdpcmState = Tuple[int, int] RatecvState = Tuple[int, Tuple[Tuple[int, int], ...]] diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 0b17173350e3..8610eea17b52 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Optional, Union +from typing import IO def b64encode(s: bytes, altchars: bytes | None = ...) -> bytes: ... def b64decode(s: str | bytes, altchars: bytes | None = ..., validate: bool = ...) -> bytes: ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index 1b68d3bfc2d8..5bee9dadb928 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -1,5 +1,5 @@ from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, Dict, Iterable, List, Mapping, Optional, Set, SupportsInt, Tuple, Type, TypeVar, Union +from typing import IO, Any, Callable, Dict, Iterable, List, Mapping, Set, SupportsInt, Tuple, Type, TypeVar _T = TypeVar("_T") _TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type diff --git a/stdlib/binascii.pyi b/stdlib/binascii.pyi index f28c7590ae4b..962f5666b284 100644 --- a/stdlib/binascii.pyi +++ b/stdlib/binascii.pyi @@ -1,5 +1,4 @@ import sys -from typing import Union def a2b_uu(__data: str | bytes) -> bytes: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 654a08f4614f..8a8f343987ec 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -42,7 +42,7 @@ from typing import ( MutableSequence, MutableSet, NoReturn, - Optional, + Protocol, Reversible, Sequence, diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index 1f6848c5134b..66e7b62fe590 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -2,7 +2,7 @@ import _compression import sys from _compression import BaseStream from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer -from typing import IO, Any, Iterable, List, Optional, Protocol, TextIO, TypeVar, Union, overload +from typing import IO, Any, Iterable, List, Protocol, TextIO, TypeVar, overload from typing_extensions import Literal, SupportsIndex # The following attributes and methods are optional: diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index d07a8c1c28a6..969f13adca37 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from types import CodeType -from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Tuple, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index c348cb8b4c27..2b59c502fa9e 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -1,7 +1,7 @@ import datetime import sys from time import struct_time -from typing import Any, Iterable, List, Optional, Sequence, Tuple, Union +from typing import Any, Iterable, List, Optional, Sequence, Tuple _LocaleType = Tuple[Optional[str], Optional[str]] diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index 778cf632e1f0..3821de46ed75 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import SupportsGetItem, SupportsItemAccess from builtins import type as _type from collections.abc import Iterable, Iterator, Mapping -from typing import IO, Any, Optional, Protocol, TypeVar, Union +from typing import IO, Any, Protocol, TypeVar _T = TypeVar("_T", bound=FieldStorage) diff --git a/stdlib/cmd.pyi b/stdlib/cmd.pyi index 0ae61d8d0013..ffccba84ec16 100644 --- a/stdlib/cmd.pyi +++ b/stdlib/cmd.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, List, Optional, Tuple +from typing import IO, Any, Callable, List, Tuple class Cmd: prompt: str diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 889b4f04fb2a..e96f7f6814b4 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -11,13 +11,13 @@ from typing import ( Iterable, Iterator, List, - Optional, + Protocol, TextIO, Tuple, Type, TypeVar, - Union, + overload, ) from typing_extensions import Literal diff --git a/stdlib/codeop.pyi b/stdlib/codeop.pyi index 35cb4c5e3e60..8ed5710c9891 100644 --- a/stdlib/codeop.pyi +++ b/stdlib/codeop.pyi @@ -1,5 +1,4 @@ from types import CodeType -from typing import Optional def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 67eb5b4cefdd..b6bd10ec265f 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self -from typing import Any, Dict, Generic, List, NoReturn, Optional, Tuple, Type, TypeVar, Union, overload +from typing import Any, Dict, Generic, List, NoReturn, Tuple, Type, TypeVar, overload if sys.version_info >= (3, 10): from typing import ( diff --git a/stdlib/compileall.pyi b/stdlib/compileall.pyi index 4a8b734be634..64b4dc2bc5f7 100644 --- a/stdlib/compileall.pyi +++ b/stdlib/compileall.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import Any, Optional, Protocol +from typing import Any, Protocol if sys.version_info >= (3, 7): from py_compile import PycInvalidationMode diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index cbbe031ebc70..cd3dd05421e9 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -11,7 +11,7 @@ from typing import ( Iterable, Iterator, List, - Optional, + Protocol, Sequence, Set, diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index e0003fe74761..7f9ca51ef7a5 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Optional, Tuple +from typing import Any, Callable, Tuple from ._base import Executor diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 788c81158454..56686b52202c 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -1,6 +1,6 @@ import queue import sys -from typing import Any, Callable, Generic, Iterable, Mapping, Optional, Tuple, TypeVar +from typing import Any, Callable, Generic, Iterable, Mapping, Tuple, TypeVar from ._base import Executor, Future diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index db19582e772d..ba81f34a1ce9 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -11,13 +11,13 @@ from typing import ( List, Mapping, MutableMapping, - Optional, + Pattern, Sequence, Tuple, Type, TypeVar, - Union, + overload, ) from typing_extensions import Literal diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index 41c8bdbbe82c..e97f62188dcb 100644 --- a/stdlib/contextvars.pyi +++ b/stdlib/contextvars.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, Optional, TypeVar, Union, overload +from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/copy.pyi b/stdlib/copy.pyi index 180e58756ead..c88f92846ddf 100644 --- a/stdlib/copy.pyi +++ b/stdlib/copy.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, TypeVar +from typing import Any, Dict, TypeVar _T = TypeVar("_T") diff --git a/stdlib/crypt.pyi b/stdlib/crypt.pyi index 3dfaa9bb0bc1..d453450308fc 100644 --- a/stdlib/crypt.pyi +++ b/stdlib/crypt.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Optional, Union +from typing import List class _Method: ... diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 13539c6bd6e3..5d82a639cd56 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -17,7 +17,7 @@ from _csv import ( unregister_dialect as unregister_dialect, writer as writer, ) -from typing import Any, Generic, Iterable, Iterator, List, Mapping, Optional, Sequence, Type, TypeVar, overload +from typing import Any, Generic, Iterable, Iterator, List, Mapping, Sequence, Type, TypeVar, overload if sys.version_info >= (3, 8): from typing import Dict as _DictReadMapping diff --git a/stdlib/ctypes/util.pyi b/stdlib/ctypes/util.pyi index 5d0a732de9f8..c0274f5e539b 100644 --- a/stdlib/ctypes/util.pyi +++ b/stdlib/ctypes/util.pyi @@ -1,5 +1,4 @@ import sys -from typing import Optional def find_library(name: str) -> str | None: ... diff --git a/stdlib/curses/ascii.pyi b/stdlib/curses/ascii.pyi index 1baff6e81a11..05efb326687a 100644 --- a/stdlib/curses/ascii.pyi +++ b/stdlib/curses/ascii.pyi @@ -1,4 +1,4 @@ -from typing import List, TypeVar, Union +from typing import List, TypeVar _CharT = TypeVar("_CharT", str, int) diff --git a/stdlib/curses/textpad.pyi b/stdlib/curses/textpad.pyi index 41b32bc9b5e1..578a579fda38 100644 --- a/stdlib/curses/textpad.pyi +++ b/stdlib/curses/textpad.pyi @@ -1,5 +1,5 @@ from _curses import _CursesWindow -from typing import Callable, Optional, Union +from typing import Callable def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 9dc893fb853a..30a8194a7784 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Tuple, Type, TypeVar, overload from typing_extensions import Protocol if sys.version_info >= (3, 9): diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 35cf7646631e..22782d9d46e4 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -1,6 +1,6 @@ import sys from time import struct_time -from typing import ClassVar, NamedTuple, Optional, SupportsAbs, Tuple, Type, TypeVar, overload +from typing import ClassVar, NamedTuple, SupportsAbs, Tuple, Type, TypeVar, overload _S = TypeVar("_S") diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 50001f5ca7c6..9b9f92ccaa86 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Iterator, MutableMapping, Optional, Tuple, Type, Union +from typing import Iterator, MutableMapping, Tuple, Type, Union from typing_extensions import Literal _KeyType = Union[str, bytes] diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index 3c2ba6f791a6..0a941b070754 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Iterator, MutableMapping, Optional, Type, Union +from typing import Iterator, MutableMapping, Type, Union _KeyType = Union[str, bytes] _ValueType = Union[str, bytes] diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index 21f2d7b8eac2..6cb2cac24485 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import List, Optional, Type, TypeVar, Union, overload +from typing import List, Type, TypeVar, Union, overload _T = TypeVar("_T") _KeyType = Union[str, bytes] diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index b7366e1ea1b8..4da04feed9cb 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import List, Optional, Type, TypeVar, Union, overload +from typing import List, Type, TypeVar, Union, overload _T = TypeVar("_T") _KeyType = Union[str, bytes] diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 11326541699a..15cb686c07ed 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -1,6 +1,6 @@ import numbers from types import TracebackType -from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Container, Dict, List, NamedTuple, Sequence, Tuple, Type, TypeVar, Union, overload _Decimal = Union[Decimal, int] _DecimalNew = Union[Decimal, float, str, Tuple[int, Sequence[int], int]] diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index f8bf6844638a..c0cb7b907bb4 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -8,7 +8,7 @@ from typing import ( Iterator, List, NamedTuple, - Optional, + Sequence, Tuple, TypeVar, diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index e4a4d2cf477c..5790c7340b9f 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -16,7 +16,7 @@ from opcode import ( opname as opname, stack_effect as stack_effect, ) -from typing import IO, Any, Callable, Dict, Iterator, List, NamedTuple, Optional, Tuple, Union +from typing import IO, Any, Callable, Dict, Iterator, List, NamedTuple, Tuple, Union # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) diff --git a/stdlib/distutils/archive_util.pyi b/stdlib/distutils/archive_util.pyi index 0cc06b3332de..3960a488dd46 100644 --- a/stdlib/distutils/archive_util.pyi +++ b/stdlib/distutils/archive_util.pyi @@ -1,4 +1,3 @@ -from typing import Optional def make_archive( base_name: str, diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 63c910cd1c5f..56383e8a0d65 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -1,6 +1,6 @@ from abc import abstractmethod from distutils.dist import Distribution -from typing import Any, Callable, Iterable, List, Optional, Tuple, Union +from typing import Any, Callable, Iterable, List, Tuple class Command: sub_commands: List[Tuple[str, Callable[[Command], bool] | None]] diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index 997134596087..48bd7b5018bc 100644 --- a/stdlib/distutils/core.pyi +++ b/stdlib/distutils/core.pyi @@ -1,7 +1,7 @@ from distutils.cmd import Command as Command from distutils.dist import Distribution as Distribution from distutils.extension import Extension as Extension -from typing import Any, List, Mapping, Optional, Tuple, Type, Union +from typing import Any, List, Mapping, Tuple, Type def setup( *, diff --git a/stdlib/distutils/debug.pyi b/stdlib/distutils/debug.pyi index 9aacb8d4879c..f84bd9d75952 100644 --- a/stdlib/distutils/debug.pyi +++ b/stdlib/distutils/debug.pyi @@ -1,3 +1,2 @@ -from typing import Optional DEBUG: bool | None diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index c8811ed7e4c1..b6d47fcae4dd 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath, SupportsWrite from distutils.cmd import Command -from typing import IO, Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, Union +from typing import IO, Any, Dict, Iterable, List, Mapping, Tuple, Type class DistributionMetadata: def __init__(self, path: int | StrOrBytesPath | None = ...) -> None: ... diff --git a/stdlib/distutils/extension.pyi b/stdlib/distutils/extension.pyi index 613a9b33fa24..041a6a449b18 100644 --- a/stdlib/distutils/extension.pyi +++ b/stdlib/distutils/extension.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Tuple +from typing import List, Tuple class Extension: def __init__( diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index ab7ac0e6a152..cc81997fe1a3 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, Mapping, Optional, Tuple, Union, overload +from typing import Any, Iterable, List, Mapping, Optional, Tuple, overload _Option = Tuple[str, Optional[str], str] _GR = Tuple[List[str], OptionDummy] diff --git a/stdlib/distutils/file_util.pyi b/stdlib/distutils/file_util.pyi index 8c2b302efa6a..9bc2923a6480 100644 --- a/stdlib/distutils/file_util.pyi +++ b/stdlib/distutils/file_util.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Sequence, Tuple +from typing import Sequence, Tuple def copy_file( src: str, diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 7206724bcd6d..a0b02c87dc85 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -1,4 +1,4 @@ -from typing import Iterable, List, Optional, Pattern, Union, overload +from typing import Iterable, List, Pattern, overload from typing_extensions import Literal # class is entirely undocumented diff --git a/stdlib/distutils/spawn.pyi b/stdlib/distutils/spawn.pyi index 6e51effd858d..0fffc5402c62 100644 --- a/stdlib/distutils/spawn.pyi +++ b/stdlib/distutils/spawn.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional +from typing import List def spawn(cmd: List[str], search_path: bool = ..., verbose: bool = ..., dry_run: bool = ...) -> None: ... def find_executable(executable: str, path: str | None = ...) -> str | None: ... diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index a5617cd76424..3f579be40882 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -1,5 +1,5 @@ from distutils.ccompiler import CCompiler -from typing import Mapping, Optional, Union +from typing import Mapping PREFIX: str EXEC_PREFIX: str diff --git a/stdlib/distutils/text_file.pyi b/stdlib/distutils/text_file.pyi index 71983de31e68..1dd7a206f8bf 100644 --- a/stdlib/distutils/text_file.pyi +++ b/stdlib/distutils/text_file.pyi @@ -1,4 +1,4 @@ -from typing import IO, List, Optional, Tuple, Union +from typing import IO, List, Tuple class TextFile: def __init__( diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 1b48b84b292b..0a6d015847ac 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Optional, Pattern, Tuple, TypeVar, Union +from typing import Pattern, Tuple, TypeVar _T = TypeVar("_T", bound=Version) diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index ba13eaa6db3c..9babdf2372dc 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -1,6 +1,6 @@ import types import unittest -from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple, Type, Union +from typing import Any, Callable, Dict, List, NamedTuple, Tuple, Type class TestResults(NamedTuple): failed: int diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index 28427c25d1eb..d59f3dbeaec8 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -1,7 +1,7 @@ import sys from email.errors import HeaderParseError, MessageDefect from email.policy import Policy -from typing import Any, Iterable, Iterator, List, Optional, Pattern, Set, Tuple, Type, TypeVar, Union +from typing import Any, Iterable, Iterator, List, Pattern, Set, Tuple, Type, TypeVar from typing_extensions import Final _T = TypeVar("_T") diff --git a/stdlib/email/charset.pyi b/stdlib/email/charset.pyi index 505318f36111..485764378f5a 100644 --- a/stdlib/email/charset.pyi +++ b/stdlib/email/charset.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, List, Optional +from typing import Any, Iterator, List QP: int # undocumented BASE64: int # undocumented diff --git a/stdlib/email/errors.pyi b/stdlib/email/errors.pyi index c137cbf02135..656cbd374ac4 100644 --- a/stdlib/email/errors.pyi +++ b/stdlib/email/errors.pyi @@ -1,5 +1,4 @@ import sys -from typing import Optional class MessageError(Exception): ... class MessageParseError(MessageError): ... diff --git a/stdlib/email/generator.pyi b/stdlib/email/generator.pyi index b4dec2a2ff15..1a810558a0da 100644 --- a/stdlib/email/generator.pyi +++ b/stdlib/email/generator.pyi @@ -1,6 +1,6 @@ from email.message import Message from email.policy import Policy -from typing import BinaryIO, Optional, TextIO +from typing import BinaryIO, TextIO class Generator: def clone(self, fp: TextIO) -> Generator: ... diff --git a/stdlib/email/header.pyi b/stdlib/email/header.pyi index 5591b370894e..6d9e8d43d4c1 100644 --- a/stdlib/email/header.pyi +++ b/stdlib/email/header.pyi @@ -1,5 +1,5 @@ from email.charset import Charset -from typing import Any, List, Optional, Tuple, Union +from typing import Any, List, Tuple class Header: def __init__( diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index 3f4804a61d5f..5d718805c6ae 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -11,7 +11,7 @@ from email._header_value_parser import ( ) from email.errors import MessageDefect from email.policy import Policy -from typing import Any, Dict, Iterable, Mapping, Optional, Tuple, Type, Union +from typing import Any, Dict, Iterable, Mapping, Tuple, Type class BaseHeader(str): @property diff --git a/stdlib/email/iterators.pyi b/stdlib/email/iterators.pyi index 817a3aea7c58..9081a3e3ba73 100644 --- a/stdlib/email/iterators.pyi +++ b/stdlib/email/iterators.pyi @@ -1,5 +1,5 @@ from email.message import Message -from typing import Iterator, Optional +from typing import Iterator def body_line_iterator(msg: Message, decode: bool = ...) -> Iterator[str]: ... def typed_subpart_iterator(msg: Message, maintype: str = ..., subtype: str | None = ...) -> Iterator[str]: ... diff --git a/stdlib/email/mime/message.pyi b/stdlib/email/mime/message.pyi index 17b9ee8a3ab6..8878741e8db3 100644 --- a/stdlib/email/mime/message.pyi +++ b/stdlib/email/mime/message.pyi @@ -1,7 +1,6 @@ from email.message import Message from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Optional class MIMEMessage(MIMENonMultipart): def __init__(self, _msg: Message, _subtype: str = ..., *, policy: Policy | None = ...) -> None: ... diff --git a/stdlib/email/mime/text.pyi b/stdlib/email/mime/text.pyi index 2a800fd01194..afcafa66ee60 100644 --- a/stdlib/email/mime/text.pyi +++ b/stdlib/email/mime/text.pyi @@ -1,6 +1,5 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Optional class MIMEText(MIMENonMultipart): def __init__(self, _text: str, _subtype: str = ..., _charset: str | None = ..., *, policy: Policy | None = ...) -> None: ... diff --git a/stdlib/email/parser.pyi b/stdlib/email/parser.pyi index 1978b7944394..574c927eeaf5 100644 --- a/stdlib/email/parser.pyi +++ b/stdlib/email/parser.pyi @@ -1,7 +1,7 @@ import email.feedparser from email.message import Message from email.policy import Policy -from typing import BinaryIO, Callable, Optional, TextIO +from typing import BinaryIO, Callable, TextIO FeedParser = email.feedparser.FeedParser BytesFeedParser = email.feedparser.BytesFeedParser diff --git a/stdlib/email/policy.pyi b/stdlib/email/policy.pyi index d6284e919fd6..56d1f989239f 100644 --- a/stdlib/email/policy.pyi +++ b/stdlib/email/policy.pyi @@ -3,7 +3,7 @@ from email.contentmanager import ContentManager from email.errors import MessageDefect from email.header import Header from email.message import Message -from typing import Any, Callable, List, Optional, Tuple, Union +from typing import Any, Callable, List, Tuple class Policy: max_line_length: int | None diff --git a/stdlib/encodings/__init__.pyi b/stdlib/encodings/__init__.pyi index dd3cf28e2772..d86466762268 100644 --- a/stdlib/encodings/__init__.pyi +++ b/stdlib/encodings/__init__.pyi @@ -1,5 +1,5 @@ from codecs import CodecInfo -from typing import Any, Optional, Union +from typing import Any class CodecRegistryError(LookupError, SystemError): ... diff --git a/stdlib/encodings/utf_8.pyi b/stdlib/encodings/utf_8.pyi index 416e90caa239..04979dfdd689 100644 --- a/stdlib/encodings/utf_8.pyi +++ b/stdlib/encodings/utf_8.pyi @@ -1,5 +1,5 @@ import codecs -from typing import Optional, Tuple +from typing import Tuple class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input: str, final: bool = ...) -> bytes: ... diff --git a/stdlib/ensurepip/__init__.pyi b/stdlib/ensurepip/__init__.pyi index bed46578fbb3..70b27edc6dd8 100644 --- a/stdlib/ensurepip/__init__.pyi +++ b/stdlib/ensurepip/__init__.pyi @@ -1,4 +1,3 @@ -from typing import Optional def version() -> str: ... def bootstrap( diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index da1c23bc286e..77a3fe6ef582 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -1,7 +1,7 @@ import sys from abc import ABCMeta from builtins import property as _builtins_property -from typing import Any, Dict, Iterator, List, Mapping, Type, TypeVar, Union +from typing import Any, Dict, Iterator, List, Mapping, Type, TypeVar _T = TypeVar("_T") _S = TypeVar("_S", bound=Type[Enum]) diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index bc4a2962b823..2ddfd18c2d99 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from os import PathLike -from typing import Any, AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Tuple, Union +from typing import Any, AnyStr, Callable, Dict, Generic, Iterable, List, Sequence, Tuple if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index bf88c7861bef..3c14b736ca50 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self, StrOrBytesPath -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Union +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/formatter.pyi b/stdlib/formatter.pyi index f57d86c1022b..da165f2d55e3 100644 --- a/stdlib/formatter.pyi +++ b/stdlib/formatter.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Iterable, List, Optional, Tuple +from typing import IO, Any, Iterable, List, Tuple AS_IS: None _FontType = Tuple[str, bool, bool, bool] diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index 4ecb5d06329c..f184fb801516 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -1,7 +1,7 @@ import sys from decimal import Decimal from numbers import Integral, Rational, Real -from typing import Optional, Tuple, Type, TypeVar, Union, overload +from typing import Tuple, Type, TypeVar, Union, overload from typing_extensions import Literal _ComparableNum = Union[int, float, Decimal, Real] diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index cbc3c5a663cd..692f63c73457 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -2,7 +2,7 @@ from _typeshed import Self, SupportsRead, SupportsReadline from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, Union +from typing import Any, Callable, Dict, Iterable, Iterator, List, TextIO, Tuple, Type from typing_extensions import Literal MSG_OOB: int diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index e4bae49a0dec..ac9ae629e89a 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -9,14 +9,14 @@ from typing import ( Iterable, Mapping, NamedTuple, - Optional, + Sequence, Set, Sized, Tuple, Type, TypeVar, - Union, + overload, ) diff --git a/stdlib/gc.pyi b/stdlib/gc.pyi index 5998b8e0c01a..44bb2fd20bb9 100644 --- a/stdlib/gc.pyi +++ b/stdlib/gc.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Dict, List, Tuple DEBUG_COLLECTABLE: int DEBUG_LEAK: int diff --git a/stdlib/genericpath.pyi b/stdlib/genericpath.pyi index b1f702efaa57..999715c8e5f1 100644 --- a/stdlib/genericpath.pyi +++ b/stdlib/genericpath.pyi @@ -1,6 +1,6 @@ import os from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsLessThanT -from typing import List, Sequence, Tuple, Union, overload +from typing import List, Sequence, Tuple, overload from typing_extensions import Literal # All overloads can return empty string. Ideally, Literal[""] would be a valid diff --git a/stdlib/getpass.pyi b/stdlib/getpass.pyi index fe4be95d285a..600ebfa7883a 100644 --- a/stdlib/getpass.pyi +++ b/stdlib/getpass.pyi @@ -1,4 +1,4 @@ -from typing import Optional, TextIO +from typing import TextIO def getpass(prompt: str = ..., stream: TextIO | None = ...) -> str: ... def getuser() -> str: ... diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index 658aa9d805c6..b408d3f7485c 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import IO, Any, Container, Iterable, Optional, Sequence, Type, TypeVar, overload +from typing import IO, Any, Container, Iterable, Sequence, Type, TypeVar, overload from typing_extensions import Literal class NullTranslations: diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index f0462c96c41e..d8e5b494857c 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrOrBytesPath -from typing import AnyStr, Iterator, List, Optional, Union +from typing import AnyStr, Iterator, List def glob0(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... def glob1(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... diff --git a/stdlib/graphlib.pyi b/stdlib/graphlib.pyi index bb4e373314dd..0872af4a54a4 100644 --- a/stdlib/graphlib.pyi +++ b/stdlib/graphlib.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsItems -from typing import Generic, Iterable, Optional, Tuple, TypeVar +from typing import Generic, Iterable, Tuple, TypeVar _T = TypeVar("_T") diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 63b7145d0350..63898b26bf17 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -1,4 +1,4 @@ -from typing import List, NamedTuple, Optional +from typing import List, NamedTuple class struct_group(NamedTuple): gr_name: str diff --git a/stdlib/gzip.pyi b/stdlib/gzip.pyi index 3b21448c23f5..070ceac48282 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -3,7 +3,7 @@ import sys import zlib from _typeshed import ReadableBuffer, StrOrBytesPath from io import FileIO -from typing import Any, Optional, Protocol, TextIO, Union, overload +from typing import Any, Protocol, TextIO, overload from typing_extensions import Literal _ReadBinaryMode = Literal["r", "rb"] diff --git a/stdlib/hashlib.pyi b/stdlib/hashlib.pyi index f5ab456feb0f..3f86ed73a103 100644 --- a/stdlib/hashlib.pyi +++ b/stdlib/hashlib.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer -from typing import AbstractSet, Optional +from typing import AbstractSet class _Hash(object): digest_size: int diff --git a/stdlib/heapq.pyi b/stdlib/heapq.pyi index 86a0af89ff82..72153930ce95 100644 --- a/stdlib/heapq.pyi +++ b/stdlib/heapq.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsLessThan -from typing import Any, Callable, Iterable, List, Optional, TypeVar +from typing import Any, Callable, Iterable, List, TypeVar _T = TypeVar("_T") diff --git a/stdlib/hmac.pyi b/stdlib/hmac.pyi index d7963a3b23c5..440bddd7919c 100644 --- a/stdlib/hmac.pyi +++ b/stdlib/hmac.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import ReadableBuffer from types import ModuleType -from typing import Any, AnyStr, Callable, Optional, Union, overload +from typing import Any, AnyStr, Callable, Union, overload # TODO more precise type for object of hashlib _Hash = Any diff --git a/stdlib/html/parser.pyi b/stdlib/html/parser.pyi index 8eed327f156d..dd94f0383e39 100644 --- a/stdlib/html/parser.pyi +++ b/stdlib/html/parser.pyi @@ -1,5 +1,5 @@ from _markupbase import ParserBase -from typing import List, Optional, Tuple +from typing import List, Tuple class HTMLParser(ParserBase): def __init__(self, *, convert_charrefs: bool = ...) -> None: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 60fc79ccc8cb..c883fbc21c81 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -15,7 +15,7 @@ from typing import ( Iterator, List, Mapping, - Optional, + Protocol, Tuple, Type, diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 65819695a615..568b14dca427 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrPath from http.client import HTTPResponse -from typing import ClassVar, Dict, Iterable, Iterator, Optional, Pattern, Sequence, Tuple, TypeVar, Union, overload +from typing import ClassVar, Dict, Iterable, Iterator, Pattern, Sequence, Tuple, TypeVar, overload from urllib.request import Request _T = TypeVar("_T") diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 6248bec95603..4d4420ec1cd8 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, TypeVar, Union, overload +from typing import Any, Dict, Generic, Iterable, List, Mapping, Tuple, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index 7c5c9818fe1f..7ea662f72520 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -3,7 +3,7 @@ import io import socketserver import sys from _typeshed import StrPath, SupportsRead, SupportsWrite -from typing import Any, AnyStr, BinaryIO, ClassVar, Dict, List, Mapping, Optional, Sequence, Tuple, Union +from typing import Any, AnyStr, BinaryIO, ClassVar, Dict, List, Mapping, Sequence, Tuple class HTTPServer(socketserver.TCPServer): server_name: str diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 3d287eb4b5ab..a5c4a31780d6 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -5,7 +5,7 @@ from _typeshed import Self from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Callable, Dict, List, Optional, Pattern, Tuple, Type, Union +from typing import IO, Any, Callable, Dict, List, Pattern, Tuple, Type, Union from typing_extensions import Literal # TODO: Commands should use their actual return types, not this type alias. diff --git a/stdlib/imghdr.pyi b/stdlib/imghdr.pyi index f972c6d70275..850a317ad9b1 100644 --- a/stdlib/imghdr.pyi +++ b/stdlib/imghdr.pyi @@ -1,5 +1,5 @@ from _typeshed import StrPath -from typing import Any, BinaryIO, Callable, List, Optional, Protocol, Union, overload +from typing import Any, BinaryIO, Callable, List, Protocol, overload class _ReadableBinary(Protocol): def tell(self) -> int: ... diff --git a/stdlib/imp.pyi b/stdlib/imp.pyi index 0f32f379c279..154259807651 100644 --- a/stdlib/imp.pyi +++ b/stdlib/imp.pyi @@ -1,7 +1,7 @@ import types from _typeshed import StrPath from os import PathLike -from typing import IO, Any, List, Optional, Protocol, Tuple, TypeVar, Union +from typing import IO, Any, List, Protocol, Tuple, TypeVar from _imp import ( acquire_lock as acquire_lock, diff --git a/stdlib/importlib/__init__.pyi b/stdlib/importlib/__init__.pyi index 600aec1281e4..b7986de57a45 100644 --- a/stdlib/importlib/__init__.pyi +++ b/stdlib/importlib/__init__.pyi @@ -1,6 +1,6 @@ import types from importlib.abc import Loader -from typing import Any, Mapping, Optional, Sequence +from typing import Any, Mapping, Sequence def __import__( name: str, diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index db850734070a..69608c57cc4d 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -3,7 +3,7 @@ import types from _typeshed import StrOrBytesPath from abc import ABCMeta, abstractmethod from importlib.machinery import ModuleSpec -from typing import IO, Any, Iterator, Mapping, Optional, Protocol, Sequence, Tuple, Union +from typing import IO, Any, Iterator, Mapping, Protocol, Sequence, Tuple, Union from typing_extensions import Literal, runtime_checkable _Path = Union[bytes, str] diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index 7c7660db6e62..3f879dfcbf15 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -1,6 +1,6 @@ import importlib.abc import types -from typing import Any, Callable, List, Optional, Sequence, Tuple, Union +from typing import Any, Callable, List, Sequence, Tuple # TODO: the loaders seem a bit backwards, attribute is protocol but __init__ arg isn't? class ModuleSpec: diff --git a/stdlib/importlib/metadata.pyi b/stdlib/importlib/metadata.pyi index 6b3474fbf118..8aea3e9227a0 100644 --- a/stdlib/importlib/metadata.pyi +++ b/stdlib/importlib/metadata.pyi @@ -7,7 +7,7 @@ from email.message import Message from importlib.abc import MetaPathFinder from os import PathLike from pathlib import Path -from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Tuple, overload +from typing import Any, Dict, Iterable, List, NamedTuple, Tuple, overload if sys.version_info >= (3, 10): def packages_distributions() -> Mapping[str, List[str]]: ... diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index a32054176e1a..006a00ce2095 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -2,7 +2,7 @@ import importlib.abc import importlib.machinery import types from _typeshed import StrOrBytesPath -from typing import Any, Callable, List, Optional +from typing import Any, Callable, List def module_for_loader(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ... def set_loader(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index e13b90a710d0..0c903d28d808 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -15,7 +15,7 @@ from types import ( ModuleType, TracebackType, ) -from typing import Any, ClassVar, NamedTuple, Optional, Tuple, Type, Union +from typing import Any, ClassVar, NamedTuple, Tuple, Type, Union from typing_extensions import Literal, TypeGuard # diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 0e8a5289f149..becfd7e6ad9d 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -4,7 +4,7 @@ import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer from os import _Opener from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, Union +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, TextIO, Tuple, Type DEFAULT_BUFFER_SIZE: int diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index cfad77f03f96..710ad27dd466 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Container, Generic, Iterable, Iterator, Optional, SupportsInt, Tuple, TypeVar, overload +from typing import Any, Container, Generic, Iterable, Iterator, SupportsInt, Tuple, TypeVar, overload # Undocumented length constants IPV4LENGTH: int diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index f179cdb108aa..4bff4c51144d 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -6,7 +6,7 @@ from typing import ( Generic, Iterable, Iterator, - Optional, + SupportsComplex, SupportsFloat, SupportsInt, diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index 1615c2fb8593..1194bd2eaf4d 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsRead -from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type, Union +from typing import IO, Any, Callable, Dict, List, Tuple, Type from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder from .encoder import JSONEncoder as JSONEncoder diff --git a/stdlib/json/decoder.pyi b/stdlib/json/decoder.pyi index f8b15086c2eb..3ffd3da65e57 100644 --- a/stdlib/json/decoder.pyi +++ b/stdlib/json/decoder.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import Any, Callable, Dict, List, Tuple class JSONDecodeError(ValueError): msg: str diff --git a/stdlib/json/encoder.pyi b/stdlib/json/encoder.pyi index 2eaa6dfa8d8c..36113ed229ca 100644 --- a/stdlib/json/encoder.pyi +++ b/stdlib/json/encoder.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Iterator, Optional, Tuple +from typing import Any, Callable, Iterator, Tuple def py_encode_basestring(s: str) -> str: ... # undocumented def py_encode_basestring_ascii(s: str) -> str: ... # undocumented diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index 414b6e95c8ad..a8159dccf037 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -2,7 +2,7 @@ from _typeshed import StrPath from lib2to3.pgen2.grammar import Grammar from lib2to3.pytree import _NL, _Convert from logging import Logger -from typing import IO, Any, Iterable, Optional +from typing import IO, Any, Iterable class Driver: grammar: Grammar diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index b93867f9d9d4..fa8eed3b4f9e 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -1,6 +1,6 @@ from lib2to3.pgen2.grammar import _DFAS, Grammar from lib2to3.pytree import _NL, _Convert, _RawNode -from typing import Any, List, Optional, Sequence, Set, Tuple +from typing import Any, List, Sequence, Set, Tuple _Context = Sequence[Any] diff --git a/stdlib/lib2to3/pgen2/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index c2dede8b7267..6050573deb5d 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -1,7 +1,7 @@ from _typeshed import StrPath from lib2to3.pgen2 import grammar from lib2to3.pgen2.tokenize import _TokenInfo -from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Optional, Tuple +from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Tuple class PgenGrammar(grammar.Grammar): ... diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index b21ccf17c9c6..11bb65347054 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -4,7 +4,7 @@ import sys # as a type annotation or type alias. from builtins import str as _str from decimal import Decimal -from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union +from typing import Any, Callable, Dict, Iterable, List, Mapping, Sequence, Tuple CODESET: int D_T_FMT: int diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index 2558973f63e8..f84865e35f92 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -3,7 +3,7 @@ from _typeshed import StrOrBytesPath, StrPath from collections.abc import Callable from configparser import RawConfigParser from threading import Thread -from typing import IO, Any, Optional, Pattern, Union +from typing import IO, Any, Pattern if sys.version_info >= (3, 8): from typing import Literal diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index caddc3197a47..ff4e71820da5 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -6,7 +6,7 @@ from _typeshed import StrPath from collections.abc import Callable from logging import FileHandler, Handler, LogRecord from socket import SocketKind, socket -from typing import Any, ClassVar, Optional, Pattern, Union +from typing import Any, ClassVar, Pattern if sys.version_info >= (3, 7): from queue import Queue, SimpleQueue diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index 5321dc27de56..7a26d15292d4 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -1,6 +1,6 @@ import io from _typeshed import ReadableBuffer, Self, StrOrBytesPath -from typing import IO, Any, Mapping, Optional, Sequence, TextIO, Union, overload +from typing import IO, Any, Mapping, Sequence, TextIO, Union, overload from typing_extensions import Literal _OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"] diff --git a/stdlib/macpath.pyi b/stdlib/macpath.pyi index 5e88670a0012..5657adde9a84 100644 --- a/stdlib/macpath.pyi +++ b/stdlib/macpath.pyi @@ -32,7 +32,7 @@ from posixpath import ( splitext as splitext, supports_unicode_filenames as supports_unicode_filenames, ) -from typing import AnyStr, Optional, Tuple, overload +from typing import AnyStr, Tuple, overload altsep: str | None diff --git a/stdlib/macurl2path.pyi b/stdlib/macurl2path.pyi index 532d464d81ab..a6c7a5135985 100644 --- a/stdlib/macurl2path.pyi +++ b/stdlib/macurl2path.pyi @@ -1,4 +1,3 @@ -from typing import Union def url2pathname(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ... diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 71acfba1936c..88c14e468008 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -13,7 +13,7 @@ from typing import ( Iterator, List, Mapping, - Optional, + Protocol, Sequence, Tuple, diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index 1f4b8c65d1b2..b29854f3c744 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -1,4 +1,4 @@ -from typing import Dict, List, Mapping, Optional, Sequence, Tuple, Union +from typing import Dict, List, Mapping, Sequence, Tuple, Union _Cap = Dict[str, Union[str, int]] diff --git a/stdlib/math.pyi b/stdlib/math.pyi index a1023f71bfd2..5a1e71a1c560 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -1,5 +1,5 @@ import sys -from typing import Iterable, Optional, SupportsFloat, SupportsInt, Tuple, overload +from typing import Iterable, SupportsFloat, SupportsInt, Tuple, overload e: float pi: float diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index 4156fe161be0..f952d42a2015 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import IO, Dict, List, Optional, Sequence, Tuple +from typing import IO, Dict, List, Sequence, Tuple if sys.version_info >= (3, 8): def guess_type(url: StrPath, strict: bool = ...) -> Tuple[str | None, str | None]: ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index e760cc701a38..4dd8f8cd2cdd 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer -from typing import ContextManager, Iterable, Iterator, NoReturn, Optional, Sized, Union, overload +from typing import ContextManager, Iterable, Iterator, NoReturn, Sized, overload ACCESS_DEFAULT: int ACCESS_READ: int diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index 335e7917b13b..1a5a4996d409 100644 --- a/stdlib/modulefinder.pyi +++ b/stdlib/modulefinder.pyi @@ -1,6 +1,6 @@ import sys from types import CodeType -from typing import IO, Any, Container, Dict, Iterable, Iterator, List, Optional, Sequence, Tuple +from typing import IO, Any, Container, Dict, Iterable, Iterator, List, Sequence, Tuple LOAD_CONST: int # undocumented IMPORT_NAME: int # undocumented diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 26b1bd31f9dd..b0d77b141d4a 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -1,6 +1,6 @@ import sys from types import ModuleType -from typing import Any, Container, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, Container, Dict, Iterable, List, Sequence, Set, Tuple, Type from typing_extensions import Literal if sys.platform == "win32": diff --git a/stdlib/msilib/schema.pyi b/stdlib/msilib/schema.pyi index 1b3b1dc86c46..d59e9767c3de 100644 --- a/stdlib/msilib/schema.pyi +++ b/stdlib/msilib/schema.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Optional, Tuple +from typing import List, Tuple if sys.platform == "win32": from . import Table diff --git a/stdlib/msilib/text.pyi b/stdlib/msilib/text.pyi index 79e166eed550..4ae8ee68184b 100644 --- a/stdlib/msilib/text.pyi +++ b/stdlib/msilib/text.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Optional, Tuple +from typing import List, Tuple if sys.platform == "win32": diff --git a/stdlib/multiprocessing/__init__.pyi b/stdlib/multiprocessing/__init__.pyi index 1be9e2efafd0..53b0c983fbcf 100644 --- a/stdlib/multiprocessing/__init__.pyi +++ b/stdlib/multiprocessing/__init__.pyi @@ -20,7 +20,7 @@ from multiprocessing.process import active_children as active_children, current_ # multiprocessing.queues or the aliases defined below. See #4266 for discussion. from multiprocessing.queues import JoinableQueue as JoinableQueue, Queue as Queue, SimpleQueue as SimpleQueue from multiprocessing.spawn import freeze_support as freeze_support -from typing import Any, Optional, Union, overload +from typing import Any, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 8): diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index 52c6636cd370..95d5b5c7c1e7 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -2,7 +2,7 @@ import socket import sys import types from _typeshed import Self -from typing import Any, Iterable, List, Optional, Tuple, Type, Union +from typing import Any, Iterable, List, Tuple, Type, Union if sys.version_info >= (3, 8): from typing import SupportsIndex diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index fc648ca5f63f..59ff0afadbc4 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -7,7 +7,7 @@ from logging import Logger from multiprocessing import queues, synchronize from multiprocessing.process import BaseProcess from multiprocessing.sharedctypes import SynchronizedArray, SynchronizedBase -from typing import Any, Optional, Type, TypeVar, Union, overload +from typing import Any, Type, TypeVar, Union, overload from typing_extensions import Literal _LockLike = Union[synchronize.Lock, synchronize.RLock] diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index f2feeeb83af4..64e0bb61e158 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -2,7 +2,7 @@ import array import threading import weakref from queue import Queue as Queue -from typing import Any, Callable, Iterable, List, Mapping, Optional, Sequence +from typing import Any, Callable, Iterable, List, Mapping, Sequence JoinableQueue = Queue Barrier = threading.Barrier diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index b9257eb0322f..0d788fd42df8 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -1,7 +1,7 @@ from _typeshed import Self from queue import Queue from types import TracebackType -from typing import Any, List, Optional, Tuple, Type, Union +from typing import Any, List, Tuple, Type, Union families: List[None] diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 175127785a77..cedff2e85911 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -13,11 +13,11 @@ from typing import ( Iterable, List, Mapping, - Optional, + Sequence, Tuple, TypeVar, - Union, + ) from .connection import Connection diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index 9f5cad97f31e..f602a8ccb241 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self -from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, Optional, TypeVar +from typing import Any, Callable, ContextManager, Generic, Iterable, Iterator, List, Mapping, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index 1c29e7f79a5b..d5300e79367b 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, List, Mapping, Optional, Tuple +from typing import Any, Callable, List, Mapping, Tuple class BaseProcess: name: str diff --git a/stdlib/multiprocessing/queues.pyi b/stdlib/multiprocessing/queues.pyi index b3c71690e926..1c9d76917292 100644 --- a/stdlib/multiprocessing/queues.pyi +++ b/stdlib/multiprocessing/queues.pyi @@ -1,6 +1,6 @@ import queue import sys -from typing import Any, Generic, Optional, TypeVar +from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index ec86882d1d21..47669aa4bcb5 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Generic, Iterable, Optional, Tuple, TypeVar +from typing import Any, Generic, Iterable, Tuple, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index 379b97ca8c4c..259a460dbf92 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -3,7 +3,7 @@ from collections.abc import Callable, Iterable, Sequence from ctypes import _CData, _SimpleCData, c_char from multiprocessing.context import BaseContext from multiprocessing.synchronize import _LockLike -from typing import Any, Generic, Optional, Protocol, Type, TypeVar, Union, overload +from typing import Any, Generic, Protocol, Type, TypeVar, overload from typing_extensions import Literal _T = TypeVar("_T") diff --git a/stdlib/multiprocessing/spawn.pyi b/stdlib/multiprocessing/spawn.pyi index 27b9daf45677..4d42f4252b12 100644 --- a/stdlib/multiprocessing/spawn.pyi +++ b/stdlib/multiprocessing/spawn.pyi @@ -1,5 +1,5 @@ from types import ModuleType -from typing import Any, Dict, List, Mapping, Optional, Sequence +from typing import Any, Dict, List, Mapping, Sequence WINEXE: bool WINSERVICE: bool diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 5f9e085fb867..1741885f13bf 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -1,7 +1,7 @@ import sys import threading from multiprocessing.context import BaseContext -from typing import Any, Callable, ContextManager, Optional, Union +from typing import Any, Callable, ContextManager, Union _LockLike = Union[Lock, RLock] diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index a77514dd4bd3..f06b278134b2 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -3,7 +3,7 @@ import socket import ssl import sys from _typeshed import Self -from typing import IO, Any, Dict, Iterable, List, NamedTuple, Optional, Tuple, Union +from typing import IO, Any, Dict, Iterable, List, NamedTuple, Tuple, Union _File = Union[IO[bytes], bytes, str, None] diff --git a/stdlib/numbers.pyi b/stdlib/numbers.pyi index 7d56aa15f44d..eaf53d25347a 100644 --- a/stdlib/numbers.pyi +++ b/stdlib/numbers.pyi @@ -2,7 +2,7 @@ # signatures are currently omitted. from abc import ABCMeta, abstractmethod -from typing import Any, Optional, SupportsFloat, overload +from typing import Any, SupportsFloat, overload class Number(metaclass=ABCMeta): @abstractmethod diff --git a/stdlib/opcode.pyi b/stdlib/opcode.pyi index 7d734b1c11be..820b867670be 100644 --- a/stdlib/opcode.pyi +++ b/stdlib/opcode.pyi @@ -1,5 +1,5 @@ import sys -from typing import Dict, List, Optional, Sequence +from typing import Dict, List, Sequence cmp_op: Sequence[str] hasconst: List[int] diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index 791636be7122..18cee61c08ed 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, overload +from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Sequence, Tuple, Type, overload NO_DEFAULT: Tuple[str, ...] SUPPRESS_HELP: str diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index eb318b5fa1a3..85b22d4e3616 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -29,7 +29,7 @@ from typing import ( Mapping, MutableMapping, NoReturn, - Optional, + Protocol, Sequence, Set, diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 948a3a96b654..5d454250c9ac 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -11,7 +11,7 @@ from _typeshed import ( from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from os import PathLike, stat_result from types import TracebackType -from typing import IO, Any, BinaryIO, Generator, List, Optional, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import IO, Any, BinaryIO, Generator, List, Sequence, Tuple, Type, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index ae4383f361d5..265fe2830dd9 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -4,7 +4,7 @@ from bdb import Bdb from cmd import Cmd from inspect import _SourceObjectType from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, ClassVar, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, TypeVar, Union +from typing import IO, Any, Callable, ClassVar, Dict, Iterable, List, Mapping, Sequence, Tuple, TypeVar _T = TypeVar("_T") diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 99eac8bde92d..391ed7b4cac0 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Iterator, List, MutableMapping, Optional, Tuple, Type, Union +from typing import IO, Any, Callable, Iterator, List, MutableMapping, Tuple, Type _Reader = Callable[[IO[bytes]], Any] bytes_types: Tuple[Type[Any], ...] diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index 51aa1d6dfa28..c0a8e8e49782 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import SupportsRead from importlib.abc import Loader, MetaPathFinder, PathEntryFinder -from typing import IO, Any, Callable, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Union +from typing import IO, Any, Callable, Iterable, Iterator, List, NamedTuple, Tuple class ModuleInfo(NamedTuple): module_finder: MetaPathFinder | PathEntryFinder diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index eb37c6a50987..d0f08a20fcd6 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -4,7 +4,7 @@ if sys.version_info < (3, 8): import os DEV_NULL = os.devnull -from typing import NamedTuple, Optional, Tuple +from typing import NamedTuple, Tuple if sys.version_info >= (3, 8): def libc_ver(executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ... diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index 6551577b6d92..26de8f77eb39 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -1,6 +1,6 @@ import sys from enum import Enum -from typing import IO, Any, Dict as DictT, Mapping, MutableMapping, Optional, Type, Union +from typing import IO, Any, Dict as DictT, Mapping, MutableMapping, Type class PlistFormat(Enum): FMT_XML: int diff --git a/stdlib/poplib.pyi b/stdlib/poplib.pyi index f63319ea0914..79447c597f20 100644 --- a/stdlib/poplib.pyi +++ b/stdlib/poplib.pyi @@ -1,6 +1,6 @@ import socket import ssl -from typing import Any, BinaryIO, Dict, List, Optional, Pattern, Tuple, overload +from typing import Any, BinaryIO, Dict, List, Pattern, Tuple, overload _LongResp = Tuple[bytes, List[bytes], int] diff --git a/stdlib/posix.pyi b/stdlib/posix.pyi index 353b858022c5..aad94fd5d196 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from os import PathLike, _ExecEnv, _ExecVArgs, stat_result as stat_result -from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Sequence, Tuple, overload +from typing import Any, Dict, Iterable, List, NamedTuple, Sequence, Tuple, overload class uname_result(NamedTuple): sysname: str diff --git a/stdlib/posixpath.pyi b/stdlib/posixpath.pyi index d357f2323e5a..cc5e5cb8ed50 100644 --- a/stdlib/posixpath.pyi +++ b/stdlib/posixpath.pyi @@ -14,7 +14,7 @@ from genericpath import ( samestat as samestat, ) from os import PathLike -from typing import AnyStr, Optional, Sequence, Tuple, overload +from typing import AnyStr, Sequence, Tuple, overload supports_unicode_filenames: bool # aliases (also in os) diff --git a/stdlib/pprint.pyi b/stdlib/pprint.pyi index f59ff86f1be0..688561b43115 100644 --- a/stdlib/pprint.pyi +++ b/stdlib/pprint.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, Dict, Optional, Tuple +from typing import IO, Any, Dict, Tuple if sys.version_info >= (3, 10): def pformat( diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index 2b822d7d5e52..b159c0cc5876 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Tuple, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index a9b1095cadf1..686c4ef2f958 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import StrOrBytesPath from cProfile import Profile as _cProfile from profile import Profile -from typing import IO, Any, Dict, Iterable, List, Optional, Tuple, TypeVar, Union, overload +from typing import IO, Any, Dict, Iterable, List, Tuple, TypeVar, Union, overload _Selector = Union[str, float, int] _T = TypeVar("_T", bound=Stats) diff --git a/stdlib/pty.pyi b/stdlib/pty.pyi index 25959cd9fb35..ba6b9b40edc0 100644 --- a/stdlib/pty.pyi +++ b/stdlib/pty.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Iterable, Tuple, Union +from typing import Callable, Iterable, Tuple _Reader = Callable[[int], bytes] diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 7816ee2bf9a5..e1c0b91f5a9f 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -1,5 +1,5 @@ import sys -from typing import AnyStr, List, Optional, Type +from typing import AnyStr, List, Type class PyCompileError(Exception): exc_type_name: str diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index 8f4f35979531..64adc2800d91 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -1,5 +1,5 @@ import sys -from typing import Dict, List, Optional, Sequence, Union +from typing import Dict, List, Sequence class Class: module: str diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 30e869253fb6..6d5b3bd565c2 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -15,7 +15,7 @@ from typing import ( Optional, Tuple, Type, - Union, + ) # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 3cdb2520ec33..cc9bbe13a7c0 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,7 +1,7 @@ import pyexpat.errors as errors import pyexpat.model as model from _typeshed import SupportsRead -from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from typing import Any, Callable, Dict, List, Optional, Tuple EXPAT_VERSION: str # undocumented version_info: Tuple[int, int, int] # undocumented diff --git a/stdlib/queue.pyi b/stdlib/queue.pyi index 5884d4e18f46..9671155b7eb6 100644 --- a/stdlib/queue.pyi +++ b/stdlib/queue.pyi @@ -1,6 +1,6 @@ import sys from threading import Condition, Lock -from typing import Any, Generic, Optional, TypeVar +from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/random.pyi b/stdlib/random.pyi index db4683355af9..f284fe831b42 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -2,7 +2,7 @@ import _random import sys from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set from fractions import Fraction -from typing import Any, NoReturn, Optional, Tuple, TypeVar, Union +from typing import Any, NoReturn, Tuple, TypeVar _T = TypeVar("_T") diff --git a/stdlib/re.pyi b/stdlib/re.pyi index b1bae4aac875..df6bba234764 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -1,7 +1,7 @@ import enum import sys from sre_constants import error as error -from typing import Any, AnyStr, Callable, Iterator, List, Optional, Tuple, Union, overload +from typing import Any, AnyStr, Callable, Iterator, List, Tuple, Union, overload # ----- re variables and constants ----- if sys.version_info >= (3, 7): diff --git a/stdlib/rlcompleter.pyi b/stdlib/rlcompleter.pyi index f7e3cf1b8c4a..c217111471a6 100644 --- a/stdlib/rlcompleter.pyi +++ b/stdlib/rlcompleter.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict class Completer: def __init__(self, namespace: Dict[str, Any] | None = ...) -> None: ... diff --git a/stdlib/runpy.pyi b/stdlib/runpy.pyi index 5915ee7815ac..25e30f9fd487 100644 --- a/stdlib/runpy.pyi +++ b/stdlib/runpy.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import ModuleType -from typing import Any, Dict, Optional +from typing import Any, Dict class _TempModule: mod_name: str = ... diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index 05d81aa69ee2..937b68913879 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple +from typing import Any, Callable, Dict, List, NamedTuple, Tuple class Event(NamedTuple): time: float diff --git a/stdlib/secrets.pyi b/stdlib/secrets.pyi index bcf9bf1526d1..9a3910ddaddd 100644 --- a/stdlib/secrets.pyi +++ b/stdlib/secrets.pyi @@ -1,6 +1,6 @@ from hmac import compare_digest as compare_digest from random import SystemRandom as SystemRandom -from typing import Optional, Sequence, TypeVar +from typing import Sequence, TypeVar _T = TypeVar("_T") diff --git a/stdlib/select.pyi b/stdlib/select.pyi index f9887bd8281d..7fa89c78d55d 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike, Self from types import TracebackType -from typing import Any, Iterable, List, Optional, Tuple, Type +from typing import Any, Iterable, List, Tuple, Type if sys.platform != "win32": PIPE_BUF: int diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index 74f3b60513bd..99c961dc59f0 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptor, FileDescriptorLike, Self from abc import ABCMeta, abstractmethod -from typing import Any, List, Mapping, NamedTuple, Optional, Tuple +from typing import Any, List, Mapping, NamedTuple, Tuple _EventMask = int diff --git a/stdlib/shelve.pyi b/stdlib/shelve.pyi index 45ec2120f5f0..06d0b044c423 100644 --- a/stdlib/shelve.pyi +++ b/stdlib/shelve.pyi @@ -1,7 +1,7 @@ from _typeshed import Self from collections.abc import Iterator, MutableMapping from types import TracebackType -from typing import Optional, Type, TypeVar, Union, overload +from typing import Type, TypeVar, overload _T = TypeVar("_T") _VT = TypeVar("_VT") diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index f74e8de78276..ac04f9ae863f 100644 --- a/stdlib/shlex.pyi +++ b/stdlib/shlex.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Iterable, List, Optional, TextIO, Tuple, TypeVar, Union +from typing import Any, Iterable, List, TextIO, Tuple, TypeVar def split(s: str, comments: bool = ..., posix: bool = ...) -> List[str]: ... diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index a648358382be..cf5a2c323f8d 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -1,7 +1,7 @@ import os import sys from _typeshed import StrPath, SupportsRead, SupportsWrite -from typing import Any, AnyStr, Callable, Iterable, List, NamedTuple, Optional, Sequence, Set, Tuple, TypeVar, Union, overload +from typing import Any, AnyStr, Callable, Iterable, List, NamedTuple, Sequence, Set, Tuple, TypeVar, Union, overload _PathT = TypeVar("_PathT", str, os.PathLike[str]) # Return value of some functions that may either return a path-like object that was passed in or diff --git a/stdlib/site.pyi b/stdlib/site.pyi index d9f8da8a7e2d..c77c9397f612 100644 --- a/stdlib/site.pyi +++ b/stdlib/site.pyi @@ -1,4 +1,4 @@ -from typing import Iterable, List, Optional +from typing import Iterable, List PREFIXES: List[str] ENABLE_USER_SITE: bool | None diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index 75c7755b5b66..d34ed7e539be 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -1,7 +1,7 @@ import asynchat import asyncore import socket -from typing import Any, DefaultDict, List, Optional, Tuple, Type, Union +from typing import Any, DefaultDict, List, Tuple, Type _Address = Tuple[str, int] # (host, port) diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 91cde355444f..c0fdafbcb684 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -3,7 +3,7 @@ from email.message import Message as _Message from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Dict, Optional, Pattern, Protocol, Sequence, Tuple, Type, Union, overload +from typing import Any, Dict, Pattern, Protocol, Sequence, Tuple, Type, Union, overload _Reply = Tuple[int, bytes] _SendErrs = Dict[str, _Reply] diff --git a/stdlib/sndhdr.pyi b/stdlib/sndhdr.pyi index adeb283ffc95..84d6441a83b1 100644 --- a/stdlib/sndhdr.pyi +++ b/stdlib/sndhdr.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import NamedTuple, Optional, Union +from typing import NamedTuple class SndHeaders(NamedTuple): filetype: str diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 7def99e735d0..f72115301ace 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, Self, WriteableBuffer from collections.abc import Iterable from enum import IntEnum, IntFlag from io import RawIOBase -from typing import Any, BinaryIO, Optional, TextIO, TypeVar, Union, overload +from typing import Any, BinaryIO, TextIO, TypeVar, overload from typing_extensions import Literal # Ideally, we'd just do "from _socket import *". Unfortunately, socket diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index 97fd2fb7a632..ec57b02f06c5 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -2,7 +2,7 @@ import sys import types from _typeshed import Self from socket import socket as _socket -from typing import Any, BinaryIO, Callable, ClassVar, Optional, Set, Tuple, Type, TypeVar, Union +from typing import Any, BinaryIO, Callable, ClassVar, Set, Tuple, Type, TypeVar, Union _T = TypeVar("_T") _RequestType = Union[_socket, Tuple[bytes, _socket]] diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index cc86500acf84..d6931751801b 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, List, Optional, Protocol, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Generator, Iterable, Iterator, List, Protocol, Tuple, Type, TypeVar _T = TypeVar("_T") diff --git a/stdlib/sre_compile.pyi b/stdlib/sre_compile.pyi index 3fc27f798299..2a7a62234b8a 100644 --- a/stdlib/sre_compile.pyi +++ b/stdlib/sre_compile.pyi @@ -14,7 +14,7 @@ from sre_constants import ( _NamedIntConstant, ) from sre_parse import SubPattern -from typing import Any, List, Pattern, Union +from typing import Any, List, Pattern MAXCODE: int diff --git a/stdlib/sre_constants.pyi b/stdlib/sre_constants.pyi index 0de1dca8c16e..22e0a6942219 100644 --- a/stdlib/sre_constants.pyi +++ b/stdlib/sre_constants.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List MAGIC: int diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index ad22bba4b3f0..7c0dd02ab61e 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import SupportsLessThanT from decimal import Decimal from fractions import Fraction -from typing import Any, Hashable, Iterable, List, NamedTuple, Optional, Sequence, SupportsFloat, Type, TypeVar, Union +from typing import Any, Hashable, Iterable, List, NamedTuple, Sequence, SupportsFloat, Type, TypeVar, Union _T = TypeVar("_T") # Most functions in this module accept homogeneous collections of one of these types diff --git a/stdlib/string.pyi b/stdlib/string.pyi index e7156105f94e..ceed38f00931 100644 --- a/stdlib/string.pyi +++ b/stdlib/string.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Mapping, Optional, Sequence, Tuple, Union +from typing import Any, Iterable, Mapping, Sequence, Tuple ascii_letters: str ascii_lowercase: str diff --git a/stdlib/struct.pyi b/stdlib/struct.pyi index 7799e7dec62e..d7c9cbef7dce 100644 --- a/stdlib/struct.pyi +++ b/stdlib/struct.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer -from typing import Any, Iterator, Tuple, Union +from typing import Any, Iterator, Tuple class error(Exception): ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 80517ff9e0c7..8cb1e7e83eb8 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -9,7 +9,7 @@ from typing import ( Generic, Iterable, Mapping, - Optional, + Sequence, Tuple, Type, @@ -55,7 +55,7 @@ class CompletedProcess(Generic[_T]): # morally: _CMD args: Any returncode: int - # These are really both Optional, but requiring checks would be tedious + # These are really both but requiring checks would be tedious # and writing all the overloads would be horrific. stdout: _T stderr: _T diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index 228d5e19e2d3..8393136aa795 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self -from typing import IO, Any, NamedTuple, NoReturn, Optional, Union +from typing import IO, Any, NamedTuple, NoReturn, Union _File = Union[str, IO[bytes]] diff --git a/stdlib/symtable.pyi b/stdlib/symtable.pyi index 7e5fe3975165..79753ed6acbc 100644 --- a/stdlib/symtable.pyi +++ b/stdlib/symtable.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, List, Optional, Sequence, Tuple +from typing import Any, List, Sequence, Tuple def symtable(code: str, filename: str, compile_type: str) -> SymbolTable: ... diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index 8f4df8b47c8c..2bef9e467bc9 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Dict, List, Optional, Tuple, overload +from typing import IO, Any, Dict, List, Tuple, overload def get_config_var(name: str) -> str | None: ... @overload diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 1e2e354a61a4..0b33cc85ec60 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -5,7 +5,7 @@ from _typeshed import Self, StrOrBytesPath, StrPath from collections.abc import Callable, Iterable, Iterator, Mapping from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj from types import TracebackType -from typing import IO, Dict, List, Optional, Protocol, Set, Tuple, Type, TypeVar, Union, overload +from typing import IO, Dict, List, Protocol, Set, Tuple, Type, TypeVar, overload from typing_extensions import Literal _TF = TypeVar("_TF", bound=TarFile) diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index dd852a051f02..b9c984550c2c 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -1,6 +1,6 @@ import socket from _typeshed import Self -from typing import Any, Callable, Match, Optional, Pattern, Sequence, Tuple, Union +from typing import Any, Callable, Match, Pattern, Sequence, Tuple DEBUGLEVEL: int TELNET_PORT: int diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index eec652464f20..8f4b1495ea07 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -2,7 +2,7 @@ import os import sys from _typeshed import Self from types import TracebackType -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Optional, Tuple, Type, Union, overload +from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Tuple, Type, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/textwrap.pyi b/stdlib/textwrap.pyi index 70308adc49d2..1cd32c314c01 100644 --- a/stdlib/textwrap.pyi +++ b/stdlib/textwrap.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Dict, List, Optional, Pattern +from typing import Callable, Dict, List, Pattern class TextWrapper: width: int = ... diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index 47246fe05f0e..00394d500209 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -1,6 +1,6 @@ import sys from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, List, Mapping, Optional, Type, TypeVar, Union +from typing import Any, Callable, Iterable, List, Mapping, Optional, Type, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] diff --git a/stdlib/time.pyi b/stdlib/time.pyi index 34867104db1c..039350c5b7ad 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -1,6 +1,6 @@ import sys from types import SimpleNamespace -from typing import Any, NamedTuple, Optional, Tuple, Union +from typing import Any, NamedTuple, Tuple _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] diff --git a/stdlib/timeit.pyi b/stdlib/timeit.pyi index 7375b61091d1..9d36ce6cb696 100644 --- a/stdlib/timeit.pyi +++ b/stdlib/timeit.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Dict, List, Optional, Sequence, Tuple, Union +from typing import IO, Any, Callable, Dict, List, Sequence, Tuple, Union _Timer = Callable[[], float] _Stmt = Union[str, Callable[[], Any]] diff --git a/stdlib/tkinter/colorchooser.pyi b/stdlib/tkinter/colorchooser.pyi index a0f7e79a9f6f..184f9a2c9914 100644 --- a/stdlib/tkinter/colorchooser.pyi +++ b/stdlib/tkinter/colorchooser.pyi @@ -1,5 +1,5 @@ from tkinter.commondialog import Dialog -from typing import Any, ClassVar, Optional, Tuple, Union +from typing import Any, ClassVar, Tuple class Chooser(Dialog): command: ClassVar[str] diff --git a/stdlib/tkinter/commondialog.pyi b/stdlib/tkinter/commondialog.pyi index 91c4b2d5d739..6a02a57c6a3d 100644 --- a/stdlib/tkinter/commondialog.pyi +++ b/stdlib/tkinter/commondialog.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Mapping, Optional +from typing import Any, ClassVar, Mapping class Dialog: command: ClassVar[str | None] = ... diff --git a/stdlib/tkinter/dialog.pyi b/stdlib/tkinter/dialog.pyi index cf0c0cd3b013..91b0570d97be 100644 --- a/stdlib/tkinter/dialog.pyi +++ b/stdlib/tkinter/dialog.pyi @@ -1,5 +1,5 @@ from tkinter import Widget -from typing import Any, Mapping, Optional +from typing import Any, Mapping DIALOG_ICON: str diff --git a/stdlib/tkinter/dnd.pyi b/stdlib/tkinter/dnd.pyi index a27a43871c2b..339291a20d0f 100644 --- a/stdlib/tkinter/dnd.pyi +++ b/stdlib/tkinter/dnd.pyi @@ -1,5 +1,5 @@ from tkinter import Event, Misc, Tk, Widget -from typing import ClassVar, Optional, Protocol +from typing import ClassVar, Protocol class _DndSource(Protocol): def dnd_end(self, target: Widget | None, event: Event[Misc] | None) -> None: ... diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index 84084591be5b..b442a3c09fd9 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, _TkinterSequence, commondialog -from typing import IO, Any, ClassVar, Dict, Iterable, Optional, Tuple +from typing import IO, Any, ClassVar, Dict, Iterable, Tuple from typing_extensions import Literal dialogstates: Dict[Any, Tuple[Any, Any]] diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index 9f1f526d6947..7e875a96859d 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,6 +1,6 @@ import sys import tkinter -from typing import Any, Optional, Tuple, Union, overload +from typing import Any, Tuple, Union, overload from typing_extensions import Literal, TypedDict NORMAL: Literal["normal"] diff --git a/stdlib/tkinter/messagebox.pyi b/stdlib/tkinter/messagebox.pyi index bcc3e9dae69f..486c96821cc0 100644 --- a/stdlib/tkinter/messagebox.pyi +++ b/stdlib/tkinter/messagebox.pyi @@ -1,5 +1,5 @@ from tkinter.commondialog import Dialog -from typing import Any, ClassVar, Optional +from typing import Any, ClassVar ERROR: str INFO: str diff --git a/stdlib/tkinter/scrolledtext.pyi b/stdlib/tkinter/scrolledtext.pyi index 83632fd12fe6..246979d5afd7 100644 --- a/stdlib/tkinter/scrolledtext.pyi +++ b/stdlib/tkinter/scrolledtext.pyi @@ -1,5 +1,5 @@ from tkinter import Frame, Misc, Scrollbar, Text -from typing import Any, Optional +from typing import Any # The methods from Pack, Place, and Grid are dynamically added over the parent's impls class ScrolledText(Text): diff --git a/stdlib/tkinter/simpledialog.pyi b/stdlib/tkinter/simpledialog.pyi index a4cd2ba42ebb..bdbf600bd498 100644 --- a/stdlib/tkinter/simpledialog.pyi +++ b/stdlib/tkinter/simpledialog.pyi @@ -1,5 +1,5 @@ from tkinter import Event, Misc, Toplevel -from typing import Any, List, Optional +from typing import Any, List class Dialog(Toplevel): def __init__(self, parent: Misc | None, title: str | None = ...) -> None: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 33a12208f14c..a5242bd9fe16 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -1,5 +1,5 @@ import tkinter -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Dict, List, Tuple from typing_extensions import Literal WINDOW: Literal["window"] diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index c4aca1e145cd..6cda54f6d5b2 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -2,7 +2,7 @@ import _tkinter import sys import tkinter from tkinter.font import _FontDescription -from typing import Any, Callable, Dict, Optional, Tuple, Union, overload +from typing import Any, Callable, Dict, Tuple, Union, overload from typing_extensions import Literal, TypedDict def tclobjs_to_py(adict): ... diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index f944cd240d1b..72d23b5cc228 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -10,7 +10,7 @@ from typing import ( Iterable, List, NamedTuple, - Optional, + Pattern, Sequence, Set, diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index ab4015f2ffc7..4fef84566e1d 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -1,7 +1,7 @@ import sys import types from _typeshed import StrPath -from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, TypeVar _T = TypeVar("_T") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index b1fa497a59d3..ced5607271d7 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -1,5 +1,5 @@ from tkinter import Canvas, PhotoImage -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, TypeVar, Union, overload +from typing import Any, Callable, Dict, List, Sequence, Tuple, TypeVar, Union, overload # Note: '_Color' is the alias we use for arguments and _AnyColor is the # alias we use for return types. Really, these two aliases should be the diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 878e57983327..9bdb65c85c10 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -15,7 +15,7 @@ from typing import ( Iterator, KeysView, Mapping, - Optional, + Tuple, Type, TypeVar, diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 15e283fca92d..c73e6f8870f5 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -22,12 +22,12 @@ from typing import ( Mapping, NewType as NewType, NoReturn as NoReturn, - Optional, + Text as Text, Tuple, Type as Type, TypeVar, - Union, + ValuesView, _Alias, overload as overload, diff --git a/stdlib/unicodedata.pyi b/stdlib/unicodedata.pyi index 3412e670b4ed..66c93f7439f7 100644 --- a/stdlib/unicodedata.pyi +++ b/stdlib/unicodedata.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, TypeVar, Union +from typing import Any, TypeVar ucd_3_2_0: UCD ucnhash_CAPI: Any diff --git a/stdlib/unittest/__init__.pyi b/stdlib/unittest/__init__.pyi index 6f322099b0fc..8f0ef896fa0c 100644 --- a/stdlib/unittest/__init__.pyi +++ b/stdlib/unittest/__init__.pyi @@ -1,5 +1,4 @@ import sys -from typing import Optional from unittest.async_case import * from .case import ( diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 6ba076574a78..6b07808fc2aa 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -17,13 +17,13 @@ from typing import ( Mapping, NamedTuple, NoReturn, - Optional, + Pattern, Sequence, Tuple, Type, TypeVar, - Union, + overload, ) from warnings import WarningMessage diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 1102015fa117..a71f0d8d91ea 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -3,7 +3,7 @@ import unittest.case import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Callable, List, Optional, Sequence, Type +from typing import Any, Callable, List, Sequence, Type _SortComparisonMethod = Callable[[str, str], int] _SuiteClass = Callable[[List[unittest.case.TestCase]], unittest.suite.TestSuite] diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 18dbd553f577..8588ae03431d 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -4,7 +4,7 @@ import unittest.loader import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Iterable, List, Optional, Protocol, Type, Union +from typing import Any, Iterable, List, Protocol, Type class _TestRunner(Protocol): def run(self, test: unittest.suite.TestSuite | unittest.case.TestCase) -> unittest.result.TestResult: ... diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 2407be5168f4..1d1185af6939 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Generic, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, Iterable, List, Mapping, Sequence, Tuple, Type, TypeVar, overload _F = TypeVar("_F", bound=Callable[..., Any]) _T = TypeVar("_T") diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 936f312cb196..f31d8ca4922c 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -1,6 +1,6 @@ import unittest.case from types import TracebackType -from typing import Any, Callable, List, Optional, TextIO, Tuple, Type, TypeVar, Union +from typing import Any, Callable, List, TextIO, Tuple, Type, TypeVar, Union _SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, TracebackType], Tuple[None, None, None]] diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index a84c58849e21..128909b2090b 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -1,7 +1,7 @@ import unittest.case import unittest.result import unittest.suite -from typing import Callable, Optional, TextIO, Tuple, Type, Union +from typing import Callable, TextIO, Tuple, Type _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index 103350820ec1..557f84a40159 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -1,5 +1,5 @@ from email.message import Message -from typing import IO, Optional, Tuple, Union +from typing import IO, Tuple from urllib.response import addinfourl # Stubs for urllib.error diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 8977cd64a4f6..2ac8a3175db9 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, AnyStr, Callable, Dict, Generic, List, Mapping, NamedTuple, Optional, Sequence, Tuple, Union, overload +from typing import Any, AnyStr, Callable, Dict, Generic, List, Mapping, NamedTuple, Sequence, Tuple, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 3a642fbdfa8a..178244dfcfaa 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -13,12 +13,12 @@ from typing import ( List, Mapping, NoReturn, - Optional, + Pattern, Sequence, Tuple, TypeVar, - Union, + overload, ) from urllib.error import HTTPError diff --git a/stdlib/urllib/response.pyi b/stdlib/urllib/response.pyi index c9d39ff38209..fef25068ed33 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -1,7 +1,7 @@ from _typeshed import Self from email.message import Message from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, List, Optional, Tuple, Type, TypeVar +from typing import IO, Any, BinaryIO, Callable, Iterable, List, Tuple, Type, TypeVar _AIUT = TypeVar("_AIUT", bound=addbase) diff --git a/stdlib/urllib/robotparser.pyi b/stdlib/urllib/robotparser.pyi index 1bafbae74d8b..1dcf5f6fc933 100644 --- a/stdlib/urllib/robotparser.pyi +++ b/stdlib/urllib/robotparser.pyi @@ -1,5 +1,5 @@ import sys -from typing import Iterable, List, NamedTuple, Optional +from typing import Iterable, List, NamedTuple class _RequestRate(NamedTuple): requests: int diff --git a/stdlib/uu.pyi b/stdlib/uu.pyi index b613c6e791b6..aacd458c02c7 100644 --- a/stdlib/uu.pyi +++ b/stdlib/uu.pyi @@ -1,5 +1,5 @@ import sys -from typing import BinaryIO, Optional, Union +from typing import BinaryIO, Union _File = Union[str, BinaryIO] diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index ce7a0d2e877c..da13d819fbdf 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Optional, Tuple +from typing import Any, Tuple # Because UUID has properties called int and bytes we need to rename these temporarily. _Int = int diff --git a/stdlib/venv/__init__.pyi b/stdlib/venv/__init__.pyi index 870bca5a3789..a3b9a79bfc52 100644 --- a/stdlib/venv/__init__.pyi +++ b/stdlib/venv/__init__.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from types import SimpleNamespace -from typing import Optional, Sequence +from typing import Sequence class EnvBuilder: system_site_packages: bool diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index cc848865f8ae..a612146b1399 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,5 +1,5 @@ from types import ModuleType, TracebackType -from typing import Any, List, Optional, TextIO, Type, Union, overload +from typing import Any, List, TextIO, Type, overload from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index b12b235518ad..3ce1b88a6835 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self -from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Optional, Union +from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Union _File = Union[str, IO[bytes]] diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index d4ecf1318182..0d2fd8779fcc 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -10,11 +10,11 @@ from typing import ( List, Mapping, MutableMapping, - Optional, + Tuple, Type, TypeVar, - Union, + overload, ) diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index 65e87c00e369..8ef1c042b2a0 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -1,5 +1,5 @@ import sys -from typing import Callable, List, Optional, Sequence, Union +from typing import Callable, List, Sequence class Error(Exception): ... diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index 91f5edb353d7..3c7ab0113e04 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Any, Optional, Tuple, Type, Union +from typing import Any, Tuple, Type, Union _KeyType = Union[HKEYType, int] diff --git a/stdlib/winsound.pyi b/stdlib/winsound.pyi index 91ec0b717157..3ffd47d64c19 100644 --- a/stdlib/winsound.pyi +++ b/stdlib/winsound.pyi @@ -1,5 +1,5 @@ import sys -from typing import Optional, Union, overload +from typing import overload from typing_extensions import Literal if sys.platform == "win32": diff --git a/stdlib/wsgiref/headers.pyi b/stdlib/wsgiref/headers.pyi index 2c7b9526dfee..43404488b8dc 100644 --- a/stdlib/wsgiref/headers.pyi +++ b/stdlib/wsgiref/headers.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Pattern, Tuple, overload +from typing import List, Pattern, Tuple, overload _HeaderList = List[Tuple[str, str]] diff --git a/stdlib/wsgiref/simple_server.pyi b/stdlib/wsgiref/simple_server.pyi index 9df34cb951dc..3849f6d4987b 100644 --- a/stdlib/wsgiref/simple_server.pyi +++ b/stdlib/wsgiref/simple_server.pyi @@ -1,5 +1,5 @@ from http.server import BaseHTTPRequestHandler, HTTPServer -from typing import List, Optional, Type, TypeVar, overload +from typing import List, Type, TypeVar, overload from .handlers import SimpleHandler from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment diff --git a/stdlib/wsgiref/util.pyi b/stdlib/wsgiref/util.pyi index 65560c349484..a7f710e8012c 100644 --- a/stdlib/wsgiref/util.pyi +++ b/stdlib/wsgiref/util.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Optional +from typing import IO, Any, Callable from .types import WSGIEnvironment diff --git a/stdlib/wsgiref/validate.pyi b/stdlib/wsgiref/validate.pyi index 3372f73d7991..68e22727bc73 100644 --- a/stdlib/wsgiref/validate.pyi +++ b/stdlib/wsgiref/validate.pyi @@ -1,5 +1,5 @@ from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication -from typing import Any, Callable, Iterable, Iterator, NoReturn, Optional +from typing import Any, Callable, Iterable, Iterator, NoReturn class WSGIWarning(Warning): ... diff --git a/stdlib/xml/dom/domreg.pyi b/stdlib/xml/dom/domreg.pyi index aba2fcd59ca7..2496b3884ea1 100644 --- a/stdlib/xml/dom/domreg.pyi +++ b/stdlib/xml/dom/domreg.pyi @@ -1,5 +1,5 @@ from _typeshed.xml import DOMImplementation -from typing import Callable, Dict, Iterable, Optional, Tuple, Union +from typing import Callable, Dict, Iterable, Tuple well_known_implementations: Dict[str, str] registered: Dict[str, Callable[[], DOMImplementation]] diff --git a/stdlib/xml/dom/minicompat.pyi b/stdlib/xml/dom/minicompat.pyi index 3dcfe095ea93..e9b0395ab50d 100644 --- a/stdlib/xml/dom/minicompat.pyi +++ b/stdlib/xml/dom/minicompat.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, Optional, Tuple, Type, TypeVar +from typing import Any, Iterable, List, Tuple, Type, TypeVar _T = TypeVar("_T") diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index c2c581b9ffbb..8d5642656669 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -1,7 +1,7 @@ import sys import xml.dom from _typeshed import Self -from typing import IO, Any, Optional, Union +from typing import IO, Any 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 15422684c71d..cdbe35540771 100644 --- a/stdlib/xml/dom/pulldom.pyi +++ b/stdlib/xml/dom/pulldom.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Optional +from typing import IO, Any from xml.sax.handler import ContentHandler from xml.sax.xmlreader import XMLReader diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 5d90a110c8d2..0ccccce4f3d0 100644 --- a/stdlib/xml/etree/ElementInclude.pyi +++ b/stdlib/xml/etree/ElementInclude.pyi @@ -1,5 +1,5 @@ import sys -from typing import Callable, Optional, Union +from typing import Callable from xml.etree.ElementTree import Element XINCLUDE: str diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index ccc609a39538..02fe84567543 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Dict, Generator, List, Optional, Pattern, Tuple, TypeVar, Union +from typing import Callable, Dict, Generator, List, Pattern, Tuple, TypeVar from xml.etree.ElementTree import Element xpath_tokenizer_re: Pattern[str] diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 41ce89d93455..aec9a604bcd4 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -12,7 +12,7 @@ from typing import ( KeysView, List, MutableSequence, - Optional, + Sequence, Tuple, TypeVar, diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index e778f309bb37..8d3a17d64842 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, Iterable, List, NoReturn, Optional, Union +from typing import IO, Any, Iterable, List, NoReturn from xml.sax.handler import ContentHandler, ErrorHandler from xml.sax.xmlreader import Locator, XMLReader diff --git a/stdlib/xml/sax/saxutils.pyi b/stdlib/xml/sax/saxutils.pyi index 0c08198b2c87..c7304f4b5261 100644 --- a/stdlib/xml/sax/saxutils.pyi +++ b/stdlib/xml/sax/saxutils.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsWrite from codecs import StreamReaderWriter, StreamWriter from io import RawIOBase, TextIOBase -from typing import Mapping, Optional, Union +from typing import Mapping from xml.sax import handler, xmlreader def escape(data: str, entities: Mapping[str, str] = ...) -> str: ... diff --git a/stdlib/xml/sax/xmlreader.pyi b/stdlib/xml/sax/xmlreader.pyi index 1cba860017a5..8afc566b16a1 100644 --- a/stdlib/xml/sax/xmlreader.pyi +++ b/stdlib/xml/sax/xmlreader.pyi @@ -1,4 +1,4 @@ -from typing import Mapping, Optional, Tuple +from typing import Mapping, Tuple class XMLReader: def __init__(self) -> None: ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 6d333bd53d6e..7d0f2f9782ee 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -6,7 +6,7 @@ from _typeshed import Self, SupportsRead, SupportsWrite from datetime import datetime from io import BytesIO from types import TracebackType -from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Protocol, Tuple, Type, Union, overload +from typing import Any, Callable, Dict, Iterable, List, Mapping, Protocol, Tuple, Type, Union, overload from typing_extensions import Literal class _SupportsTimeTuple(Protocol): diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index 61f4a921762e..9d86fe2b6c75 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -3,7 +3,7 @@ import pydoc import socketserver import sys from datetime import datetime -from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Pattern, Protocol, Tuple, Type, Union +from typing import Any, Callable, Dict, Iterable, List, Mapping, Pattern, Protocol, Tuple, Type, Union from xmlrpc.client import Fault _Marshallable = Union[ diff --git a/stdlib/zipapp.pyi b/stdlib/zipapp.pyi index 986dbe145f9a..581d2b72a664 100644 --- a/stdlib/zipapp.pyi +++ b/stdlib/zipapp.pyi @@ -1,6 +1,6 @@ import sys from pathlib import Path -from typing import BinaryIO, Callable, Optional, Union +from typing import BinaryIO, Callable, Union _Path = Union[str, Path, BinaryIO] diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index b06c18c94539..42bd4ed45f0a 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -2,7 +2,7 @@ import io import sys from _typeshed import Self, StrPath from types import TracebackType -from typing import IO, Callable, Dict, Iterable, Iterator, List, Optional, Protocol, Sequence, Tuple, Type, Union, overload +from typing import IO, Callable, Dict, Iterable, Iterator, List, Protocol, Sequence, Tuple, Type, overload from typing_extensions import Literal _DateTuple = Tuple[int, int, int, int, int, int] diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index 3096e326e816..a83a8793ccac 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -1,7 +1,7 @@ import os import sys from types import CodeType, ModuleType -from typing import Any, List, Optional, Tuple, Union +from typing import Any, List, Tuple if sys.version_info >= (3, 7): from importlib.abc import ResourceReader diff --git a/stdlib/zlib.pyi b/stdlib/zlib.pyi index 57f8f06412f6..5acc4190f1fe 100644 --- a/stdlib/zlib.pyi +++ b/stdlib/zlib.pyi @@ -1,5 +1,5 @@ from array import array -from typing import Any, Optional, Union +from typing import Any DEFLATED: int DEF_MEM_LEVEL: int diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index a6b2bb831bb1..2a188c7d0477 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -1,7 +1,7 @@ import typing from _typeshed import StrPath from datetime import tzinfo -from typing import Any, Iterable, Optional, Protocol, Sequence, Set, Type +from typing import Any, Iterable, Protocol, Sequence, Set, Type _T = typing.TypeVar("_T", bound="ZoneInfo") diff --git a/stubs/DateTimeRange/datetimerange/__init__.pyi b/stubs/DateTimeRange/datetimerange/__init__.pyi index 2aec2b3e97e6..b38cad3bf897 100644 --- a/stubs/DateTimeRange/datetimerange/__init__.pyi +++ b/stubs/DateTimeRange/datetimerange/__init__.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Iterable, Optional, Union +from typing import Iterable from dateutil.relativedelta import relativedelta diff --git a/stubs/Deprecated/deprecated/classic.pyi b/stubs/Deprecated/deprecated/classic.pyi index b80ceca86fe6..ecf21efbc015 100644 --- a/stubs/Deprecated/deprecated/classic.pyi +++ b/stubs/Deprecated/deprecated/classic.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Type, TypeVar, overload +from typing import Any, Callable, Type, TypeVar, overload _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/stubs/Deprecated/deprecated/sphinx.pyi b/stubs/Deprecated/deprecated/sphinx.pyi index df1b2f0398fa..9d3f1ba15994 100644 --- a/stubs/Deprecated/deprecated/sphinx.pyi +++ b/stubs/Deprecated/deprecated/sphinx.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Type, TypeVar, overload +from typing import Any, Callable, Type, TypeVar, overload from typing_extensions import Literal from .classic import ClassicAdapter diff --git a/stubs/Flask/flask/blueprints.pyi b/stubs/Flask/flask/blueprints.pyi index edf57320e9a4..df795f1a3e75 100644 --- a/stubs/Flask/flask/blueprints.pyi +++ b/stubs/Flask/flask/blueprints.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Type, TypeVar, Union +from typing import Any, Callable, Type, TypeVar from .app import _ViewFunc from .helpers import _PackageBoundObject diff --git a/stubs/Flask/flask/cli.pyi b/stubs/Flask/flask/cli.pyi index cfec1e08767a..9f79483a75d6 100644 --- a/stubs/Flask/flask/cli.pyi +++ b/stubs/Flask/flask/cli.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any import click diff --git a/stubs/Flask/flask/config.pyi b/stubs/Flask/flask/config.pyi index a0a9be05fb6d..b33ddd0c00cd 100644 --- a/stubs/Flask/flask/config.pyi +++ b/stubs/Flask/flask/config.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict class ConfigAttribute: __name__: Any = ... diff --git a/stubs/Flask/flask/ctx.pyi b/stubs/Flask/flask/ctx.pyi index 5717e0ac8c89..2246ca79b4a5 100644 --- a/stubs/Flask/flask/ctx.pyi +++ b/stubs/Flask/flask/ctx.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class _AppCtxGlobals: def get(self, name: Any, default: Any | None = ...): ... diff --git a/stubs/Flask/flask/helpers.pyi b/stubs/Flask/flask/helpers.pyi index c07bd8134bfa..bf9a6982f8ab 100644 --- a/stubs/Flask/flask/helpers.pyi +++ b/stubs/Flask/flask/helpers.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from .cli import AppGroup from .wrappers import Response diff --git a/stubs/Flask/flask/json/tag.pyi b/stubs/Flask/flask/json/tag.pyi index a4fd09acd3be..4b9d15a65244 100644 --- a/stubs/Flask/flask/json/tag.pyi +++ b/stubs/Flask/flask/json/tag.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class JSONTag: key: Any = ... diff --git a/stubs/Flask/flask/sessions.pyi b/stubs/Flask/flask/sessions.pyi index 5ba26473db56..84c3fcc90edb 100644 --- a/stubs/Flask/flask/sessions.pyi +++ b/stubs/Flask/flask/sessions.pyi @@ -1,5 +1,5 @@ from abc import ABCMeta -from typing import Any, MutableMapping, Optional +from typing import Any, MutableMapping from werkzeug.datastructures import CallbackDict diff --git a/stubs/Flask/flask/signals.pyi b/stubs/Flask/flask/signals.pyi index 628c340b1cb8..de7c1951faf3 100644 --- a/stubs/Flask/flask/signals.pyi +++ b/stubs/Flask/flask/signals.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any signals_available: bool diff --git a/stubs/Flask/flask/templating.pyi b/stubs/Flask/flask/templating.pyi index 7650851941ae..d9bf997cb6b8 100644 --- a/stubs/Flask/flask/templating.pyi +++ b/stubs/Flask/flask/templating.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Text, Union +from typing import Any, Iterable, Text from jinja2 import BaseLoader, Environment as BaseEnvironment diff --git a/stubs/Flask/flask/testing.pyi b/stubs/Flask/flask/testing.pyi index 5bd42b623824..08f5a0d080b3 100644 --- a/stubs/Flask/flask/testing.pyi +++ b/stubs/Flask/flask/testing.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Iterable, Mapping, Optional, Text, TypeVar, Union +from typing import IO, Any, Iterable, Mapping, Text, TypeVar from click import BaseCommand from click.testing import CliRunner, Result diff --git a/stubs/Flask/flask/wrappers.pyi b/stubs/Flask/flask/wrappers.pyi index 1c22f6071b15..67a64910f03d 100644 --- a/stubs/Flask/flask/wrappers.pyi +++ b/stubs/Flask/flask/wrappers.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict from werkzeug.exceptions import HTTPException from werkzeug.routing import Rule diff --git a/stubs/JACK-Client/jack/__init__.pyi b/stubs/JACK-Client/jack/__init__.pyi index 8cdaed8637cb..020d48dfef7f 100644 --- a/stubs/JACK-Client/jack/__init__.pyi +++ b/stubs/JACK-Client/jack/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Generator, Iterable, Iterator, List, Optional, Sequence, Tuple, Union, overload +from typing import Any, Callable, Dict, Generator, Iterable, Iterator, List, Sequence, Tuple, overload _NDArray = Any # FIXME: no typings for numpy arrays diff --git a/stubs/Jinja2/jinja2/_compat.pyi b/stubs/Jinja2/jinja2/_compat.pyi index 740802bffb13..f85bd0f2fb3f 100644 --- a/stubs/Jinja2/jinja2/_compat.pyi +++ b/stubs/Jinja2/jinja2/_compat.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Optional +from typing import Any if sys.version_info >= (3,): from urllib.parse import quote_from_bytes diff --git a/stubs/Jinja2/jinja2/bccache.pyi b/stubs/Jinja2/jinja2/bccache.pyi index ec82a2d487aa..2f39dce24ea5 100644 --- a/stubs/Jinja2/jinja2/bccache.pyi +++ b/stubs/Jinja2/jinja2/bccache.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any marshal_dump: Any marshal_load: Any diff --git a/stubs/Jinja2/jinja2/compiler.pyi b/stubs/Jinja2/jinja2/compiler.pyi index e7ad55c47b70..43eb332b25ff 100644 --- a/stubs/Jinja2/jinja2/compiler.pyi +++ b/stubs/Jinja2/jinja2/compiler.pyi @@ -1,5 +1,5 @@ from keyword import iskeyword as is_python_keyword -from typing import Any, Optional +from typing import Any from jinja2.visitor import NodeVisitor diff --git a/stubs/Jinja2/jinja2/debug.pyi b/stubs/Jinja2/jinja2/debug.pyi index df745204e2f3..5bffa43f5969 100644 --- a/stubs/Jinja2/jinja2/debug.pyi +++ b/stubs/Jinja2/jinja2/debug.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any tproxy: Any raise_helper: str diff --git a/stubs/Jinja2/jinja2/defaults.pyi b/stubs/Jinja2/jinja2/defaults.pyi index 574b8528bb53..052744024729 100644 --- a/stubs/Jinja2/jinja2/defaults.pyi +++ b/stubs/Jinja2/jinja2/defaults.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict from jinja2.filters import FILTERS from jinja2.tests import TESTS diff --git a/stubs/Jinja2/jinja2/environment.pyi b/stubs/Jinja2/jinja2/environment.pyi index 6ebece7fbbe0..3276a028d948 100644 --- a/stubs/Jinja2/jinja2/environment.pyi +++ b/stubs/Jinja2/jinja2/environment.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Text, Type, Union +from typing import Any, Callable, Dict, Iterator, List, Sequence, Text, Type from .bccache import BytecodeCache from .loaders import BaseLoader diff --git a/stubs/Jinja2/jinja2/exceptions.pyi b/stubs/Jinja2/jinja2/exceptions.pyi index b9a750137511..c227a9b0d539 100644 --- a/stubs/Jinja2/jinja2/exceptions.pyi +++ b/stubs/Jinja2/jinja2/exceptions.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Text +from typing import Any, Text class TemplateError(Exception): def __init__(self, message: Text | None = ...) -> None: ... diff --git a/stubs/Jinja2/jinja2/ext.pyi b/stubs/Jinja2/jinja2/ext.pyi index 4cd92f48f975..61ffa50d624b 100644 --- a/stubs/Jinja2/jinja2/ext.pyi +++ b/stubs/Jinja2/jinja2/ext.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any GETTEXT_FUNCTIONS: Any diff --git a/stubs/Jinja2/jinja2/filters.pyi b/stubs/Jinja2/jinja2/filters.pyi index ea3f17c086cc..ac5614e26970 100644 --- a/stubs/Jinja2/jinja2/filters.pyi +++ b/stubs/Jinja2/jinja2/filters.pyi @@ -1,4 +1,4 @@ -from typing import Any, NamedTuple, Optional +from typing import Any, NamedTuple def contextfilter(f): ... def evalcontextfilter(f): ... diff --git a/stubs/Jinja2/jinja2/lexer.pyi b/stubs/Jinja2/jinja2/lexer.pyi index 915cddc930e5..714f76f92232 100644 --- a/stubs/Jinja2/jinja2/lexer.pyi +++ b/stubs/Jinja2/jinja2/lexer.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Tuple +from typing import Any, Tuple whitespace_re: Any string_re: Any diff --git a/stubs/Jinja2/jinja2/loaders.pyi b/stubs/Jinja2/jinja2/loaders.pyi index 5a41f52a8d3b..6c7cec4cb0d2 100644 --- a/stubs/Jinja2/jinja2/loaders.pyi +++ b/stubs/Jinja2/jinja2/loaders.pyi @@ -1,6 +1,6 @@ import sys from types import ModuleType -from typing import Any, Callable, Iterable, List, Optional, Text, Tuple, Union +from typing import Any, Callable, Iterable, List, Text, Tuple, Union from .environment import Environment diff --git a/stubs/Jinja2/jinja2/nodes.pyi b/stubs/Jinja2/jinja2/nodes.pyi index 6b5bf6966cfb..2f680dbc72be 100644 --- a/stubs/Jinja2/jinja2/nodes.pyi +++ b/stubs/Jinja2/jinja2/nodes.pyi @@ -1,5 +1,5 @@ import typing -from typing import Any, Optional +from typing import Any class Impossible(Exception): ... diff --git a/stubs/Jinja2/jinja2/parser.pyi b/stubs/Jinja2/jinja2/parser.pyi index ba53f6cfbcd3..ac9942592dde 100644 --- a/stubs/Jinja2/jinja2/parser.pyi +++ b/stubs/Jinja2/jinja2/parser.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class Parser: environment: Any diff --git a/stubs/Jinja2/jinja2/runtime.pyi b/stubs/Jinja2/jinja2/runtime.pyi index 62ff25154c67..782fd8c970f8 100644 --- a/stubs/Jinja2/jinja2/runtime.pyi +++ b/stubs/Jinja2/jinja2/runtime.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Text, Union +from typing import Any, Dict, Text from jinja2.environment import Environment from jinja2.exceptions import TemplateNotFound as TemplateNotFound, TemplateRuntimeError as TemplateRuntimeError diff --git a/stubs/Jinja2/jinja2/utils.pyi b/stubs/Jinja2/jinja2/utils.pyi index 17ca2a4cdd64..41488c04139b 100644 --- a/stubs/Jinja2/jinja2/utils.pyi +++ b/stubs/Jinja2/jinja2/utils.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import IO, Any, Callable, Iterable, Optional, Protocol, Text, TypeVar, Union +from typing import IO, Any, Callable, Iterable, Protocol, Text, TypeVar from typing_extensions import Literal from markupsafe import Markup as Markup, escape as escape, soft_unicode as soft_unicode diff --git a/stubs/Markdown/markdown/core.pyi b/stubs/Markdown/markdown/core.pyi index 340182fd535b..76e45116a6a3 100644 --- a/stubs/Markdown/markdown/core.pyi +++ b/stubs/Markdown/markdown/core.pyi @@ -1,4 +1,4 @@ -from typing import Any, BinaryIO, Callable, ClassVar, Dict, List, Mapping, Optional, Sequence, Text, TextIO, Union +from typing import Any, BinaryIO, Callable, ClassVar, Dict, List, Mapping, Sequence, Text, TextIO from typing_extensions import Literal from xml.etree.ElementTree import Element diff --git a/stubs/Markdown/markdown/extensions/codehilite.pyi b/stubs/Markdown/markdown/extensions/codehilite.pyi index 2cc87ce42aa6..1f99ea3dc53d 100644 --- a/stubs/Markdown/markdown/extensions/codehilite.pyi +++ b/stubs/Markdown/markdown/extensions/codehilite.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict from markdown.extensions import Extension from markdown.treeprocessors import Treeprocessor diff --git a/stubs/Markdown/markdown/inlinepatterns.pyi b/stubs/Markdown/markdown/inlinepatterns.pyi index 32503352b45e..01068e034120 100644 --- a/stubs/Markdown/markdown/inlinepatterns.pyi +++ b/stubs/Markdown/markdown/inlinepatterns.pyi @@ -1,4 +1,4 @@ -from typing import Any, Match, Optional, Tuple, Union +from typing import Any, Match, Tuple from xml.etree.ElementTree import Element def build_inlinepatterns(md, **kwargs): ... diff --git a/stubs/Markdown/markdown/treeprocessors.pyi b/stubs/Markdown/markdown/treeprocessors.pyi index e30689cf0d04..26cd06b43628 100644 --- a/stubs/Markdown/markdown/treeprocessors.pyi +++ b/stubs/Markdown/markdown/treeprocessors.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from . import util diff --git a/stubs/Markdown/markdown/util.pyi b/stubs/Markdown/markdown/util.pyi index 98c144aa564d..c252334d3984 100644 --- a/stubs/Markdown/markdown/util.pyi +++ b/stubs/Markdown/markdown/util.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Pattern +from typing import Any, Pattern PY37: Any __deprecated__: Any diff --git a/stubs/MarkupSafe/markupsafe/__init__.pyi b/stubs/MarkupSafe/markupsafe/__init__.pyi index 117586e67f70..1b05a386f825 100644 --- a/stubs/MarkupSafe/markupsafe/__init__.pyi +++ b/stubs/MarkupSafe/markupsafe/__init__.pyi @@ -1,6 +1,6 @@ import string import sys -from typing import Any, Callable, Iterable, Mapping, Optional, Sequence, Text, Tuple, Union +from typing import Any, Callable, Iterable, Mapping, Sequence, Text, Tuple from typing_extensions import SupportsIndex from markupsafe._compat import text_type diff --git a/stubs/MarkupSafe/markupsafe/_native.pyi b/stubs/MarkupSafe/markupsafe/_native.pyi index b2af1190f111..c9f993e01bfc 100644 --- a/stubs/MarkupSafe/markupsafe/_native.pyi +++ b/stubs/MarkupSafe/markupsafe/_native.pyi @@ -1,4 +1,4 @@ -from typing import Text, Union +from typing import Text from . import Markup from ._compat import text_type diff --git a/stubs/MarkupSafe/markupsafe/_speedups.pyi b/stubs/MarkupSafe/markupsafe/_speedups.pyi index b2af1190f111..c9f993e01bfc 100644 --- a/stubs/MarkupSafe/markupsafe/_speedups.pyi +++ b/stubs/MarkupSafe/markupsafe/_speedups.pyi @@ -1,4 +1,4 @@ -from typing import Text, Union +from typing import Text from . import Markup from ._compat import text_type diff --git a/stubs/PyMySQL/pymysql/cursors.pyi b/stubs/PyMySQL/pymysql/cursors.pyi index d06115bed272..b2d1ffb74241 100644 --- a/stubs/PyMySQL/pymysql/cursors.pyi +++ b/stubs/PyMySQL/pymysql/cursors.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, Optional, Text, Tuple, TypeVar +from typing import Any, Iterable, Iterator, Text, Tuple, TypeVar from .connections import Connection diff --git a/stubs/PyYAML/yaml/__init__.pyi b/stubs/PyYAML/yaml/__init__.pyi index 4e8ea69bde63..ab01e00fac35 100644 --- a/stubs/PyYAML/yaml/__init__.pyi +++ b/stubs/PyYAML/yaml/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, Callable, Iterator, Optional, Sequence, Text, Type, TypeVar, Union, overload +from typing import IO, Any, Callable, Iterator, Sequence, Text, Type, TypeVar, Union, overload from yaml.dumper import * # noqa: F403 from yaml.error import * # noqa: F403 diff --git a/stubs/PyYAML/yaml/composer.pyi b/stubs/PyYAML/yaml/composer.pyi index 44bc4ad60ccf..1d30f2417419 100644 --- a/stubs/PyYAML/yaml/composer.pyi +++ b/stubs/PyYAML/yaml/composer.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict from yaml.error import MarkedYAMLError from yaml.nodes import MappingNode, Node, ScalarNode, SequenceNode diff --git a/stubs/PyYAML/yaml/cyaml.pyi b/stubs/PyYAML/yaml/cyaml.pyi index 4f0184e281f6..9e79f4023711 100644 --- a/stubs/PyYAML/yaml/cyaml.pyi +++ b/stubs/PyYAML/yaml/cyaml.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsRead -from typing import IO, Any, Mapping, Optional, Sequence, Text, Union +from typing import IO, Any, Mapping, Sequence, Text, Union from yaml.constructor import BaseConstructor, Constructor, SafeConstructor from yaml.representer import BaseRepresenter, Representer, SafeRepresenter diff --git a/stubs/Pygments/pygments/__init__.pyi b/stubs/Pygments/pygments/__init__.pyi index d6407af1babe..1b05e273a1d3 100644 --- a/stubs/Pygments/pygments/__init__.pyi +++ b/stubs/Pygments/pygments/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any def lex(code, lexer): ... def format(tokens, formatter, outfile: Any | None = ...): ... diff --git a/stubs/Pygments/pygments/cmdline.pyi b/stubs/Pygments/pygments/cmdline.pyi index 4846ec18c24e..2226b9834a53 100644 --- a/stubs/Pygments/pygments/cmdline.pyi +++ b/stubs/Pygments/pygments/cmdline.pyi @@ -1,5 +1,5 @@ import argparse -from typing import Any, Optional +from typing import Any def main_inner(parser, argns): ... diff --git a/stubs/Pygments/pygments/filter.pyi b/stubs/Pygments/pygments/filter.pyi index 796ff59aff2f..b1437328bca1 100644 --- a/stubs/Pygments/pygments/filter.pyi +++ b/stubs/Pygments/pygments/filter.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Iterator -from typing import Any, Optional +from typing import Any from pygments.lexer import Lexer from pygments.token import _TokenType diff --git a/stubs/Pygments/pygments/formatters/html.pyi b/stubs/Pygments/pygments/formatters/html.pyi index b7507c499d53..ba3d0696d853 100644 --- a/stubs/Pygments/pygments/formatters/html.pyi +++ b/stubs/Pygments/pygments/formatters/html.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from pygments.formatter import Formatter diff --git a/stubs/Pygments/pygments/formatters/terminal256.pyi b/stubs/Pygments/pygments/formatters/terminal256.pyi index 048946e45bea..55786c45dc9b 100644 --- a/stubs/Pygments/pygments/formatters/terminal256.pyi +++ b/stubs/Pygments/pygments/formatters/terminal256.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from pygments.formatter import Formatter diff --git a/stubs/Pygments/pygments/lexer.pyi b/stubs/Pygments/pygments/lexer.pyi index 4b2d40cb8096..979d822b9962 100644 --- a/stubs/Pygments/pygments/lexer.pyi +++ b/stubs/Pygments/pygments/lexer.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Iterator, Sequence -from typing import Any, Optional, Tuple +from typing import Any, Tuple from pygments.token import _TokenType from pygments.util import Future diff --git a/stubs/Pygments/pygments/util.pyi b/stubs/Pygments/pygments/util.pyi index 1dd131dbf6e0..23addc163de9 100644 --- a/stubs/Pygments/pygments/util.pyi +++ b/stubs/Pygments/pygments/util.pyi @@ -1,5 +1,5 @@ from io import TextIOWrapper -from typing import Any, Optional +from typing import Any split_path_re: Any doctype_lookup_re: Any diff --git a/stubs/Werkzeug/werkzeug/_compat.pyi b/stubs/Werkzeug/werkzeug/_compat.pyi index 217c66cba311..788f16f7737c 100644 --- a/stubs/Werkzeug/werkzeug/_compat.pyi +++ b/stubs/Werkzeug/werkzeug/_compat.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Optional, Text +from typing import Any, Text if sys.version_info >= (3,): from io import BytesIO as BytesIO, StringIO as StringIO diff --git a/stubs/Werkzeug/werkzeug/_internal.pyi b/stubs/Werkzeug/werkzeug/_internal.pyi index 588fb6e0f93b..2deec4fd3db5 100644 --- a/stubs/Werkzeug/werkzeug/_internal.pyi +++ b/stubs/Werkzeug/werkzeug/_internal.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class _Missing: def __reduce__(self): ... diff --git a/stubs/Werkzeug/werkzeug/_reloader.pyi b/stubs/Werkzeug/werkzeug/_reloader.pyi index 749940de9db9..5e9f95866ae3 100644 --- a/stubs/Werkzeug/werkzeug/_reloader.pyi +++ b/stubs/Werkzeug/werkzeug/_reloader.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class ReloaderLoop: name: Any diff --git a/stubs/Werkzeug/werkzeug/contrib/atom.pyi b/stubs/Werkzeug/werkzeug/contrib/atom.pyi index 950eebfb8d13..8c73bb94bc9c 100644 --- a/stubs/Werkzeug/werkzeug/contrib/atom.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/atom.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any XHTML_NAMESPACE: Any diff --git a/stubs/Werkzeug/werkzeug/contrib/cache.pyi b/stubs/Werkzeug/werkzeug/contrib/cache.pyi index 2b24d2ec1e22..95841456b77f 100644 --- a/stubs/Werkzeug/werkzeug/contrib/cache.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/cache.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class BaseCache: default_timeout: float diff --git a/stubs/Werkzeug/werkzeug/contrib/fixers.pyi b/stubs/Werkzeug/werkzeug/contrib/fixers.pyi index 2b232c4a688c..9656028a6244 100644 --- a/stubs/Werkzeug/werkzeug/contrib/fixers.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/fixers.pyi @@ -1,5 +1,5 @@ from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment -from typing import Any, Iterable, List, Mapping, Optional, Set, Text +from typing import Any, Iterable, List, Mapping, Set, Text from ..middleware.proxy_fix import ProxyFix as ProxyFix diff --git a/stubs/Werkzeug/werkzeug/contrib/iterio.pyi b/stubs/Werkzeug/werkzeug/contrib/iterio.pyi index baf2b6813a19..08162fdcede7 100644 --- a/stubs/Werkzeug/werkzeug/contrib/iterio.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/iterio.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Text, Union +from typing import Any, Text greenlet: Any diff --git a/stubs/Werkzeug/werkzeug/contrib/securecookie.pyi b/stubs/Werkzeug/werkzeug/contrib/securecookie.pyi index 8ebf6b0407ee..30f27b316410 100644 --- a/stubs/Werkzeug/werkzeug/contrib/securecookie.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/securecookie.pyi @@ -1,6 +1,6 @@ from hashlib import sha1 as _default_hash from hmac import new as hmac -from typing import Any, Optional +from typing import Any from werkzeug.contrib.sessions import ModificationTrackingDict diff --git a/stubs/Werkzeug/werkzeug/contrib/sessions.pyi b/stubs/Werkzeug/werkzeug/contrib/sessions.pyi index ddc8b5126974..2d0bba57406c 100644 --- a/stubs/Werkzeug/werkzeug/contrib/sessions.pyi +++ b/stubs/Werkzeug/werkzeug/contrib/sessions.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Text, TypeVar +from typing import Any, Text, TypeVar from werkzeug.datastructures import CallbackDict diff --git a/stubs/Werkzeug/werkzeug/datastructures.pyi b/stubs/Werkzeug/werkzeug/datastructures.pyi index 0c60602553b3..761befb69b33 100644 --- a/stubs/Werkzeug/werkzeug/datastructures.pyi +++ b/stubs/Werkzeug/werkzeug/datastructures.pyi @@ -13,12 +13,12 @@ from typing import ( Mapping, MutableSet, NoReturn, - Optional, + Text, Tuple, Type, TypeVar, - Union, + overload, ) diff --git a/stubs/Werkzeug/werkzeug/debug/__init__.pyi b/stubs/Werkzeug/werkzeug/debug/__init__.pyi index ece4726df295..87a62c339f54 100644 --- a/stubs/Werkzeug/werkzeug/debug/__init__.pyi +++ b/stubs/Werkzeug/werkzeug/debug/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from werkzeug.wrappers import BaseRequest as Request, BaseResponse as Response diff --git a/stubs/Werkzeug/werkzeug/debug/console.pyi b/stubs/Werkzeug/werkzeug/debug/console.pyi index 1f1298f2687a..e1a121973670 100644 --- a/stubs/Werkzeug/werkzeug/debug/console.pyi +++ b/stubs/Werkzeug/werkzeug/debug/console.pyi @@ -1,5 +1,5 @@ import code -from typing import Any, Optional +from typing import Any class HTMLStringO: def __init__(self): ... diff --git a/stubs/Werkzeug/werkzeug/debug/repr.pyi b/stubs/Werkzeug/werkzeug/debug/repr.pyi index 988dcc371dd6..073fd26128cb 100644 --- a/stubs/Werkzeug/werkzeug/debug/repr.pyi +++ b/stubs/Werkzeug/werkzeug/debug/repr.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any deque: Any missing: Any diff --git a/stubs/Werkzeug/werkzeug/debug/tbtools.pyi b/stubs/Werkzeug/werkzeug/debug/tbtools.pyi index f3a7c8705993..45bcf7048a7b 100644 --- a/stubs/Werkzeug/werkzeug/debug/tbtools.pyi +++ b/stubs/Werkzeug/werkzeug/debug/tbtools.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any UTF8_COOKIE: Any system_exceptions: Any diff --git a/stubs/Werkzeug/werkzeug/exceptions.pyi b/stubs/Werkzeug/werkzeug/exceptions.pyi index 51d5c58d21a0..2ff1739538a2 100644 --- a/stubs/Werkzeug/werkzeug/exceptions.pyi +++ b/stubs/Werkzeug/werkzeug/exceptions.pyi @@ -1,6 +1,6 @@ import datetime from _typeshed.wsgi import StartResponse, WSGIEnvironment -from typing import Any, Dict, Iterable, List, NoReturn, Optional, Protocol, Text, Tuple, Type, Union +from typing import Any, Dict, Iterable, List, NoReturn, Protocol, Text, Tuple, Type from werkzeug.wrappers import Response diff --git a/stubs/Werkzeug/werkzeug/formparser.pyi b/stubs/Werkzeug/werkzeug/formparser.pyi index 8042b90bc7e5..3b0cfc3a2a03 100644 --- a/stubs/Werkzeug/werkzeug/formparser.pyi +++ b/stubs/Werkzeug/werkzeug/formparser.pyi @@ -13,7 +13,7 @@ from typing import ( Text, Tuple, TypeVar, - Union, + ) from .datastructures import Headers diff --git a/stubs/Werkzeug/werkzeug/http.pyi b/stubs/Werkzeug/werkzeug/http.pyi index be3cbc2e91c9..e3d8ac45a431 100644 --- a/stubs/Werkzeug/werkzeug/http.pyi +++ b/stubs/Werkzeug/werkzeug/http.pyi @@ -8,7 +8,7 @@ from typing import ( Iterable, List, Mapping, - Optional, + SupportsInt, Text, Tuple, diff --git a/stubs/Werkzeug/werkzeug/local.pyi b/stubs/Werkzeug/werkzeug/local.pyi index 20a9120285aa..11d133b725bf 100644 --- a/stubs/Werkzeug/werkzeug/local.pyi +++ b/stubs/Werkzeug/werkzeug/local.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any def release_local(local): ... diff --git a/stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi b/stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi index 7c1ac0283375..1b8a28a45fa7 100644 --- a/stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/dispatcher.pyi @@ -1,5 +1,5 @@ from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment -from typing import Iterable, Mapping, Optional, Text +from typing import Iterable, Mapping, Text class DispatcherMiddleware(object): app: WSGIApplication diff --git a/stubs/Werkzeug/werkzeug/middleware/lint.pyi b/stubs/Werkzeug/werkzeug/middleware/lint.pyi index d3035c6daabe..7eb90ca3cc00 100644 --- a/stubs/Werkzeug/werkzeug/middleware/lint.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/lint.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import SupportsWrite from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment -from typing import Any, Iterable, Iterator, List, Mapping, Optional, Protocol, Tuple +from typing import Any, Iterable, Iterator, List, Mapping, Protocol, Tuple from ..datastructures import Headers diff --git a/stubs/Werkzeug/werkzeug/middleware/profiler.pyi b/stubs/Werkzeug/werkzeug/middleware/profiler.pyi index aed6e3233e3b..61c30b4366e8 100644 --- a/stubs/Werkzeug/werkzeug/middleware/profiler.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/profiler.pyi @@ -1,5 +1,5 @@ from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment -from typing import IO, Iterable, List, Optional, Text, Tuple, Union +from typing import IO, Iterable, List, Text, Tuple class ProfilerMiddleware(object): def __init__( diff --git a/stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi b/stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi index 955b713b915f..3d166e6960d0 100644 --- a/stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi +++ b/stubs/Werkzeug/werkzeug/middleware/proxy_fix.pyi @@ -1,5 +1,5 @@ from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment -from typing import Iterable, Optional +from typing import Iterable class ProxyFix(object): app: WSGIApplication diff --git a/stubs/Werkzeug/werkzeug/routing.pyi b/stubs/Werkzeug/werkzeug/routing.pyi index 6acdbd905b2f..51bd18363bc0 100644 --- a/stubs/Werkzeug/werkzeug/routing.pyi +++ b/stubs/Werkzeug/werkzeug/routing.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Text +from typing import Any, Text from werkzeug.exceptions import HTTPException diff --git a/stubs/Werkzeug/werkzeug/script.pyi b/stubs/Werkzeug/werkzeug/script.pyi index 6f9c4f280232..697be6727f3b 100644 --- a/stubs/Werkzeug/werkzeug/script.pyi +++ b/stubs/Werkzeug/werkzeug/script.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any argument_types: Any converters: Any diff --git a/stubs/Werkzeug/werkzeug/security.pyi b/stubs/Werkzeug/werkzeug/security.pyi index 8ba8ac531517..7e9e90763cea 100644 --- a/stubs/Werkzeug/werkzeug/security.pyi +++ b/stubs/Werkzeug/werkzeug/security.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any SALT_CHARS: Any DEFAULT_PBKDF2_ITERATIONS: Any diff --git a/stubs/Werkzeug/werkzeug/serving.pyi b/stubs/Werkzeug/werkzeug/serving.pyi index 5ad65258c491..b27ae56d3eba 100644 --- a/stubs/Werkzeug/werkzeug/serving.pyi +++ b/stubs/Werkzeug/werkzeug/serving.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Optional +from typing import Any if sys.version_info >= (3, 0): from http.server import BaseHTTPRequestHandler, HTTPServer diff --git a/stubs/Werkzeug/werkzeug/test.pyi b/stubs/Werkzeug/werkzeug/test.pyi index e6d0d5b35465..79b93fb51cbb 100644 --- a/stubs/Werkzeug/werkzeug/test.pyi +++ b/stubs/Werkzeug/werkzeug/test.pyi @@ -1,6 +1,6 @@ import sys from _typeshed.wsgi import WSGIEnvironment -from typing import Any, Generic, Optional, Text, Tuple, Type, TypeVar, overload +from typing import Any, Generic, Text, Tuple, Type, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 0): diff --git a/stubs/Werkzeug/werkzeug/urls.pyi b/stubs/Werkzeug/werkzeug/urls.pyi index 84a7fb74e227..62f4d374b313 100644 --- a/stubs/Werkzeug/werkzeug/urls.pyi +++ b/stubs/Werkzeug/werkzeug/urls.pyi @@ -1,4 +1,4 @@ -from typing import Any, NamedTuple, Optional, Text +from typing import Any, NamedTuple, Text class _URLTuple(NamedTuple): scheme: Any diff --git a/stubs/Werkzeug/werkzeug/useragents.pyi b/stubs/Werkzeug/werkzeug/useragents.pyi index 47dee0a008c3..702067046911 100644 --- a/stubs/Werkzeug/werkzeug/useragents.pyi +++ b/stubs/Werkzeug/werkzeug/useragents.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class UserAgentParser: platforms: Any diff --git a/stubs/Werkzeug/werkzeug/utils.pyi b/stubs/Werkzeug/werkzeug/utils.pyi index cbbb37dba20d..5b4f507dea98 100644 --- a/stubs/Werkzeug/werkzeug/utils.pyi +++ b/stubs/Werkzeug/werkzeug/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Text, Type, TypeVar, overload +from typing import Any, Text, Type, TypeVar, overload from werkzeug._internal import _DictAccessorProperty from werkzeug.wrappers import Response diff --git a/stubs/Werkzeug/werkzeug/wrappers.pyi b/stubs/Werkzeug/werkzeug/wrappers.pyi index e4bb49146883..d154fd22d992 100644 --- a/stubs/Werkzeug/werkzeug/wrappers.pyi +++ b/stubs/Werkzeug/werkzeug/wrappers.pyi @@ -7,13 +7,13 @@ from typing import ( Iterator, Mapping, MutableMapping, - Optional, + Sequence, Text, Tuple, Type, TypeVar, - Union, + overload, ) from typing_extensions import Literal diff --git a/stubs/Werkzeug/werkzeug/wsgi.pyi b/stubs/Werkzeug/werkzeug/wsgi.pyi index 1804242cbc09..a0bf5ab9b0ca 100644 --- a/stubs/Werkzeug/werkzeug/wsgi.pyi +++ b/stubs/Werkzeug/werkzeug/wsgi.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsRead from _typeshed.wsgi import InputStream, WSGIEnvironment -from typing import Any, Iterable, Optional, Text +from typing import Any, Iterable, Text from .middleware.dispatcher import DispatcherMiddleware as DispatcherMiddleware from .middleware.http_proxy import ProxyMiddleware as ProxyMiddleware diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index 23da66371768..3859bc5ce660 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import CodeType, FrameType, TracebackType, coroutine -from typing import Any, Coroutine, Generator, Generic, Iterator, Optional, Type, TypeVar, Union +from typing import Any, Coroutine, Generator, Generic, Iterator, Type, TypeVar _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index 9e8bd975f0c3..f2456b144e3e 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from os import stat_result -from typing import Optional, Sequence, Union, overload +from typing import Sequence, Union, overload _FdOrAnyPath = Union[int, StrOrBytesPath] diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index 8035c5a43200..a43b5ab0defb 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -7,7 +7,7 @@ from _typeshed import ( StrOrBytesPath, ) from asyncio import AbstractEventLoop -from typing import Any, Callable, Optional, Union, overload +from typing import Any, Callable, Union, overload from typing_extensions import Literal from ..base import AiofilesContextManager diff --git a/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/stubs/aiofiles/aiofiles/threadpool/binary.pyi index 88261b989a0b..b1a1e65b9e2a 100644 --- a/stubs/aiofiles/aiofiles/threadpool/binary.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/binary.pyi @@ -1,6 +1,6 @@ from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from io import FileIO -from typing import Iterable, List, Optional, Union +from typing import Iterable, List from ..base import AsyncBase diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index 57eeb8667b3c..0cd89a4699eb 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import BinaryIO, Iterable, List, Optional, Tuple, Union +from typing import BinaryIO, Iterable, List, Tuple from ..base import AsyncBase diff --git a/stubs/atomicwrites/atomicwrites/__init__.pyi b/stubs/atomicwrites/atomicwrites/__init__.pyi index 69636df39481..388ac27182fe 100644 --- a/stubs/atomicwrites/atomicwrites/__init__.pyi +++ b/stubs/atomicwrites/atomicwrites/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import IO, Any, AnyStr, Callable, ContextManager, Optional, Text, Type +from typing import IO, Any, AnyStr, Callable, ContextManager, Text, Type def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... def move_atomic(src: AnyStr, dst: AnyStr) -> None: ... diff --git a/stubs/bleach/bleach/__init__.pyi b/stubs/bleach/bleach/__init__.pyi index a61b389ad2e6..7561549817f3 100644 --- a/stubs/bleach/bleach/__init__.pyi +++ b/stubs/bleach/bleach/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Container, Iterable, Optional, Text +from typing import Any, Container, Iterable, Text from bleach.linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker, _Callback from bleach.sanitizer import ( diff --git a/stubs/bleach/bleach/html5lib_shim.pyi b/stubs/bleach/bleach/html5lib_shim.pyi index 01adb4a4cdd0..0f17263ec4c8 100644 --- a/stubs/bleach/bleach/html5lib_shim.pyi +++ b/stubs/bleach/bleach/html5lib_shim.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generator, Iterable, List, Optional, Text +from typing import Any, Generator, Iterable, List, Text class HTMLParser(object): # actually html5lib.HTMLParser def __getattr__(self, __name: Text) -> Any: ... # incomplete diff --git a/stubs/bleach/bleach/linkifier.pyi b/stubs/bleach/bleach/linkifier.pyi index 4f5f32851f0d..2586978f16e5 100644 --- a/stubs/bleach/bleach/linkifier.pyi +++ b/stubs/bleach/bleach/linkifier.pyi @@ -1,4 +1,4 @@ -from typing import Any, Container, Iterable, List, MutableMapping, Optional, Pattern, Protocol, Text +from typing import Any, Container, Iterable, List, MutableMapping, Pattern, Protocol, Text from .html5lib_shim import Filter diff --git a/stubs/bleach/bleach/sanitizer.pyi b/stubs/bleach/bleach/sanitizer.pyi index 88c094af38dd..ac9a127d7d45 100644 --- a/stubs/bleach/bleach/sanitizer.pyi +++ b/stubs/bleach/bleach/sanitizer.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Container, Dict, Iterable, List, Optional, Pattern, Text, Union +from typing import Any, Callable, Container, Dict, Iterable, List, Pattern, Text, Union from .html5lib_shim import BleachHTMLParser, BleachHTMLSerializer, SanitizerFilter diff --git a/stubs/boto/boto/__init__.pyi b/stubs/boto/boto/__init__.pyi index 507c40d12ca7..775be7c5372d 100644 --- a/stubs/boto/boto/__init__.pyi +++ b/stubs/boto/boto/__init__.pyi @@ -1,5 +1,5 @@ import logging -from typing import Any, Optional, Text +from typing import Any, Text from .s3.connection import S3Connection diff --git a/stubs/boto/boto/auth.pyi b/stubs/boto/boto/auth.pyi index a58b22104ece..2dc77949c110 100644 --- a/stubs/boto/boto/auth.pyi +++ b/stubs/boto/boto/auth.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from boto.auth_handler import AuthHandler diff --git a/stubs/boto/boto/connection.pyi b/stubs/boto/boto/connection.pyi index 8e79c4a216ac..c47f7414fba3 100644 --- a/stubs/boto/boto/connection.pyi +++ b/stubs/boto/boto/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from six.moves import http_client diff --git a/stubs/boto/boto/exception.pyi b/stubs/boto/boto/exception.pyi index a6a6b0a9e363..95ebed39378b 100644 --- a/stubs/boto/boto/exception.pyi +++ b/stubs/boto/boto/exception.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from boto.compat import StandardError diff --git a/stubs/boto/boto/kms/layer1.pyi b/stubs/boto/boto/kms/layer1.pyi index 9e41ea39760f..b639b94199b4 100644 --- a/stubs/boto/boto/kms/layer1.pyi +++ b/stubs/boto/boto/kms/layer1.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Mapping, Optional, Type +from typing import Any, Dict, List, Mapping, Type from boto.connection import AWSQueryConnection diff --git a/stubs/boto/boto/plugin.pyi b/stubs/boto/boto/plugin.pyi index 013827641344..7e9ec2dc6852 100644 --- a/stubs/boto/boto/plugin.pyi +++ b/stubs/boto/boto/plugin.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class Plugin: capability: Any diff --git a/stubs/boto/boto/regioninfo.pyi b/stubs/boto/boto/regioninfo.pyi index fd7069994843..b8cb71e2c252 100644 --- a/stubs/boto/boto/regioninfo.pyi +++ b/stubs/boto/boto/regioninfo.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any def load_endpoint_json(path): ... def merge_endpoints(defaults, additions): ... diff --git a/stubs/boto/boto/s3/__init__.pyi b/stubs/boto/boto/s3/__init__.pyi index 247cc68d5da1..0d30c85c401e 100644 --- a/stubs/boto/boto/s3/__init__.pyi +++ b/stubs/boto/boto/s3/__init__.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Text, Type +from typing import List, Text, Type from boto.connection import AWSAuthConnection from boto.regioninfo import RegionInfo diff --git a/stubs/boto/boto/s3/acl.pyi b/stubs/boto/boto/s3/acl.pyi index cccaba4daeb4..2a4d315c8814 100644 --- a/stubs/boto/boto/s3/acl.pyi +++ b/stubs/boto/boto/s3/acl.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Text, Union +from typing import Any, Dict, List, Text from .connection import S3Connection from .user import User diff --git a/stubs/boto/boto/s3/bucket.pyi b/stubs/boto/boto/s3/bucket.pyi index 4c25b4cbd97b..cc51b8cf0e12 100644 --- a/stubs/boto/boto/s3/bucket.pyi +++ b/stubs/boto/boto/s3/bucket.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Text, Type +from typing import Any, Dict, List, Text, Type from .bucketlistresultset import BucketListResultSet from .connection import S3Connection diff --git a/stubs/boto/boto/s3/bucketlistresultset.pyi b/stubs/boto/boto/s3/bucketlistresultset.pyi index f34d9f2b4b37..e327ac42404c 100644 --- a/stubs/boto/boto/s3/bucketlistresultset.pyi +++ b/stubs/boto/boto/s3/bucketlistresultset.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, Optional +from typing import Any, Iterable, Iterator from .key import Key diff --git a/stubs/boto/boto/s3/bucketlogging.pyi b/stubs/boto/boto/s3/bucketlogging.pyi index 8c5c6d368c30..f804d172cafa 100644 --- a/stubs/boto/boto/s3/bucketlogging.pyi +++ b/stubs/boto/boto/s3/bucketlogging.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class BucketLogging: target: Any diff --git a/stubs/boto/boto/s3/connection.pyi b/stubs/boto/boto/s3/connection.pyi index 3db4349ceb94..8a42dc35d5ef 100644 --- a/stubs/boto/boto/s3/connection.pyi +++ b/stubs/boto/boto/s3/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Text, Type +from typing import Any, Dict, Text, Type from boto.connection import AWSAuthConnection from boto.exception import BotoClientError diff --git a/stubs/boto/boto/s3/cors.pyi b/stubs/boto/boto/s3/cors.pyi index 9fd8d8cafc4c..f31e612f748d 100644 --- a/stubs/boto/boto/s3/cors.pyi +++ b/stubs/boto/boto/s3/cors.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List class CORSRule: allowed_method: Any diff --git a/stubs/boto/boto/s3/deletemarker.pyi b/stubs/boto/boto/s3/deletemarker.pyi index 59d6748f743d..83f9b53c03bb 100644 --- a/stubs/boto/boto/s3/deletemarker.pyi +++ b/stubs/boto/boto/s3/deletemarker.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class DeleteMarker: bucket: Any diff --git a/stubs/boto/boto/s3/key.pyi b/stubs/boto/boto/s3/key.pyi index e0686b466b3c..f32016226eb0 100644 --- a/stubs/boto/boto/s3/key.pyi +++ b/stubs/boto/boto/s3/key.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Optional, Text, Union, overload +from typing import Any, Callable, Dict, Text, overload class Key: DefaultContentType: str diff --git a/stubs/boto/boto/s3/lifecycle.pyi b/stubs/boto/boto/s3/lifecycle.pyi index 4ccc9fd41c20..bf750bb2e50f 100644 --- a/stubs/boto/boto/s3/lifecycle.pyi +++ b/stubs/boto/boto/s3/lifecycle.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List class Rule: id: Any diff --git a/stubs/boto/boto/s3/multidelete.pyi b/stubs/boto/boto/s3/multidelete.pyi index a72f2d359575..8d5ab28a5a59 100644 --- a/stubs/boto/boto/s3/multidelete.pyi +++ b/stubs/boto/boto/s3/multidelete.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class Deleted: key: Any diff --git a/stubs/boto/boto/s3/multipart.pyi b/stubs/boto/boto/s3/multipart.pyi index 4fcb84b937ca..7a231caa4224 100644 --- a/stubs/boto/boto/s3/multipart.pyi +++ b/stubs/boto/boto/s3/multipart.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class CompleteMultiPartUpload: bucket: Any diff --git a/stubs/boto/boto/s3/prefix.pyi b/stubs/boto/boto/s3/prefix.pyi index f3596b9832e3..db66a76d701b 100644 --- a/stubs/boto/boto/s3/prefix.pyi +++ b/stubs/boto/boto/s3/prefix.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class Prefix: bucket: Any diff --git a/stubs/boto/boto/s3/tagging.pyi b/stubs/boto/boto/s3/tagging.pyi index c751e4b6a1e6..ad1bcf8039f4 100644 --- a/stubs/boto/boto/s3/tagging.pyi +++ b/stubs/boto/boto/s3/tagging.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List class Tag: key: Any diff --git a/stubs/boto/boto/s3/user.pyi b/stubs/boto/boto/s3/user.pyi index ef4ca26287e0..18d8a0a31d69 100644 --- a/stubs/boto/boto/s3/user.pyi +++ b/stubs/boto/boto/s3/user.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class User: type: Any diff --git a/stubs/boto/boto/s3/website.pyi b/stubs/boto/boto/s3/website.pyi index 5c67f0b6690e..186afdf1fdd1 100644 --- a/stubs/boto/boto/s3/website.pyi +++ b/stubs/boto/boto/s3/website.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List def tag(key, value): ... diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 2ec9363ff35b..1a5ca0dc234c 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -12,12 +12,12 @@ from typing import ( Iterable, List, Mapping, - Optional, + Sequence, Tuple, Type, TypeVar, - Union, + ) import boto.connection diff --git a/stubs/cachetools/cachetools/cache.pyi b/stubs/cachetools/cachetools/cache.pyi index 1bb565aaab80..ad5ff1473ff7 100644 --- a/stubs/cachetools/cachetools/cache.pyi +++ b/stubs/cachetools/cachetools/cache.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Generic, Iterator, Optional, TypeVar +from typing import Callable, Generic, Iterator, TypeVar from .abc import DefaultMapping as DefaultMapping diff --git a/stubs/cachetools/cachetools/decorators.pyi b/stubs/cachetools/cachetools/decorators.pyi index 0d6e8141cb6f..426fc871d665 100644 --- a/stubs/cachetools/cachetools/decorators.pyi +++ b/stubs/cachetools/cachetools/decorators.pyi @@ -1,5 +1,5 @@ from _typeshed import IdentityFunction -from typing import Any, Callable, ContextManager, MutableMapping, Optional, TypeVar +from typing import Any, Callable, ContextManager, MutableMapping, TypeVar _KT = TypeVar("_KT") diff --git a/stubs/cachetools/cachetools/func.pyi b/stubs/cachetools/cachetools/func.pyi index 1f5a520792aa..75a532a00ba8 100644 --- a/stubs/cachetools/cachetools/func.pyi +++ b/stubs/cachetools/cachetools/func.pyi @@ -1,5 +1,5 @@ from _typeshed import IdentityFunction -from typing import Callable, Optional, Sequence, TypeVar +from typing import Callable, Sequence, TypeVar _T = TypeVar("_T") diff --git a/stubs/cachetools/cachetools/lfu.pyi b/stubs/cachetools/cachetools/lfu.pyi index 1016e395f013..e63aeb313628 100644 --- a/stubs/cachetools/cachetools/lfu.pyi +++ b/stubs/cachetools/cachetools/lfu.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Iterator, Optional, TypeVar +from typing import Callable, Iterator, TypeVar from .cache import Cache diff --git a/stubs/cachetools/cachetools/lru.pyi b/stubs/cachetools/cachetools/lru.pyi index c476c02237db..128a91480aff 100644 --- a/stubs/cachetools/cachetools/lru.pyi +++ b/stubs/cachetools/cachetools/lru.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Iterator, Optional, TypeVar +from typing import Callable, Iterator, TypeVar from .cache import Cache as Cache diff --git a/stubs/cachetools/cachetools/rr.pyi b/stubs/cachetools/cachetools/rr.pyi index ab6af13d118d..aa4190d047c2 100644 --- a/stubs/cachetools/cachetools/rr.pyi +++ b/stubs/cachetools/cachetools/rr.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Iterator, Optional, Sequence, TypeVar +from typing import Callable, Iterator, Sequence, TypeVar from .cache import Cache as Cache diff --git a/stubs/cachetools/cachetools/ttl.pyi b/stubs/cachetools/cachetools/ttl.pyi index 9e8373618593..12cd6072cdfb 100644 --- a/stubs/cachetools/cachetools/ttl.pyi +++ b/stubs/cachetools/cachetools/ttl.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Iterator, Optional, TypeVar +from typing import Callable, Iterator, TypeVar from .cache import Cache as Cache diff --git a/stubs/characteristic/characteristic/__init__.pyi b/stubs/characteristic/characteristic/__init__.pyi index 213f6f0b6f46..dd4322e93a8f 100644 --- a/stubs/characteristic/characteristic/__init__.pyi +++ b/stubs/characteristic/characteristic/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Callable, Dict, Optional, Sequence, Type, TypeVar, Union +from typing import Any, AnyStr, Callable, Dict, Sequence, Type, TypeVar def with_repr(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... def with_cmp(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... diff --git a/stubs/chardet/chardet/universaldetector.pyi b/stubs/chardet/chardet/universaldetector.pyi index c186f4d18413..5a2f68a0de8f 100644 --- a/stubs/chardet/chardet/universaldetector.pyi +++ b/stubs/chardet/chardet/universaldetector.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import Dict, Optional, Pattern +from typing import Dict, Pattern from typing_extensions import TypedDict class _FinalResultType(TypedDict): diff --git a/stubs/click-spinner/click_spinner/__init__.pyi b/stubs/click-spinner/click_spinner/__init__.pyi index c2e840a6f8c7..5ec098ed3421 100644 --- a/stubs/click-spinner/click_spinner/__init__.pyi +++ b/stubs/click-spinner/click_spinner/__init__.pyi @@ -1,6 +1,6 @@ import threading from types import TracebackType -from typing import Iterator, Optional, Type +from typing import Iterator, Type from typing_extensions import Literal, Protocol __version__: str diff --git a/stubs/click/click/_termui_impl.pyi b/stubs/click/click/_termui_impl.pyi index 19003f807c4d..9e373295d8fd 100644 --- a/stubs/click/click/_termui_impl.pyi +++ b/stubs/click/click/_termui_impl.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Generic, Optional, Type, TypeVar +from typing import Generic, Type, TypeVar _T = TypeVar("_T") diff --git a/stubs/click/click/core.pyi b/stubs/click/click/core.pyi index bcb6dae71879..d15dadbee17b 100644 --- a/stubs/click/click/core.pyi +++ b/stubs/click/click/core.pyi @@ -7,7 +7,7 @@ from typing import ( List, Mapping, NoReturn, - Optional, + Sequence, Set, Tuple, diff --git a/stubs/click/click/decorators.pyi b/stubs/click/click/decorators.pyi index 84447ad77691..b0cd8133308c 100644 --- a/stubs/click/click/decorators.pyi +++ b/stubs/click/click/decorators.pyi @@ -1,6 +1,6 @@ from _typeshed import IdentityFunction from distutils.version import Version -from typing import Any, Callable, Dict, Iterable, List, Optional, Text, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, Iterable, List, Text, Tuple, Type, TypeVar, Union, overload from click.core import Argument, Command, Context, Group, Option, Parameter, _ConvertibleType diff --git a/stubs/click/click/exceptions.pyi b/stubs/click/click/exceptions.pyi index 06deb0169863..8a89649b99f0 100644 --- a/stubs/click/click/exceptions.pyi +++ b/stubs/click/click/exceptions.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, List, Optional +from typing import IO, Any, List from click.core import Command, Context, Parameter diff --git a/stubs/click/click/formatting.pyi b/stubs/click/click/formatting.pyi index 9378469acece..60b5c605e5e0 100644 --- a/stubs/click/click/formatting.pyi +++ b/stubs/click/click/formatting.pyi @@ -1,4 +1,4 @@ -from typing import ContextManager, Generator, Iterable, List, Optional, Tuple +from typing import ContextManager, Generator, Iterable, List, Tuple FORCED_WIDTH: int | None diff --git a/stubs/click/click/globals.pyi b/stubs/click/click/globals.pyi index 5b6ba9543aef..75fb9017c48f 100644 --- a/stubs/click/click/globals.pyi +++ b/stubs/click/click/globals.pyi @@ -1,4 +1,3 @@ -from typing import Optional from click.core import Context diff --git a/stubs/click/click/parser.pyi b/stubs/click/click/parser.pyi index 5e15d9e71c88..51182494034e 100644 --- a/stubs/click/click/parser.pyi +++ b/stubs/click/click/parser.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Optional, Set, Tuple +from typing import Any, Dict, Iterable, List, Set, Tuple from click.core import Context diff --git a/stubs/click/click/termui.pyi b/stubs/click/click/termui.pyi index da32f93c1d98..8345c47fe3ad 100644 --- a/stubs/click/click/termui.pyi +++ b/stubs/click/click/termui.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Generator, Iterable, Optional, Text, Tuple, TypeVar, Union, overload +from typing import IO, Any, Callable, Generator, Iterable, Text, Tuple, TypeVar, overload from click._termui_impl import ProgressBar as _ProgressBar from click.core import _ConvertibleType diff --git a/stubs/click/click/testing.pyi b/stubs/click/click/testing.pyi index 0cc4061b2f09..82dcc29e787f 100644 --- a/stubs/click/click/testing.pyi +++ b/stubs/click/click/testing.pyi @@ -1,5 +1,5 @@ import io -from typing import IO, Any, BinaryIO, ContextManager, Dict, Iterable, List, Mapping, Optional, Text, Tuple, Union +from typing import IO, Any, BinaryIO, ContextManager, Dict, Iterable, List, Mapping, Text, Tuple from typing_extensions import Literal from .core import BaseCommand diff --git a/stubs/click/click/utils.pyi b/stubs/click/click/utils.pyi index 240e8ebf0b6e..fc753c4af798 100644 --- a/stubs/click/click/utils.pyi +++ b/stubs/click/click/utils.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import IO, Any, AnyStr, Generic, Iterator, List, Optional, Text, Type, TypeVar +from typing import IO, Any, AnyStr, Generic, Iterator, List, Text, Type, TypeVar _T = TypeVar("_T") diff --git a/stubs/colorama/colorama/initialise.pyi b/stubs/colorama/colorama/initialise.pyi index fd21d53eae65..f76f826e0925 100644 --- a/stubs/colorama/colorama/initialise.pyi +++ b/stubs/colorama/colorama/initialise.pyi @@ -1,4 +1,4 @@ -from typing import Any, ContextManager, Optional, TextIO, Union +from typing import Any, ContextManager, TextIO from .ansitowin32 import StreamWrapper diff --git a/stubs/colorama/colorama/winterm.pyi b/stubs/colorama/colorama/winterm.pyi index f97c91a38c5d..26e5434a5abb 100644 --- a/stubs/colorama/colorama/winterm.pyi +++ b/stubs/colorama/colorama/winterm.pyi @@ -1,8 +1,7 @@ import sys if sys.platform == "win32": - from typing import Optional - + from . import win32 class WinColor: BLACK: int = ... diff --git a/stubs/croniter/croniter.pyi b/stubs/croniter/croniter.pyi index 0d4c9f9a7bf6..fc9f2710dcf1 100644 --- a/stubs/croniter/croniter.pyi +++ b/stubs/croniter/croniter.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Any, Dict, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union +from typing import Any, Dict, Iterator, List, Text, Tuple, Type, TypeVar, Union _RetType = Union[Type[float], Type[datetime.datetime]] _SelfT = TypeVar("_SelfT", bound=croniter) diff --git a/stubs/cryptography/cryptography/fernet.pyi b/stubs/cryptography/cryptography/fernet.pyi index ec91ed0f4d15..62a39efc0a91 100644 --- a/stubs/cryptography/cryptography/fernet.pyi +++ b/stubs/cryptography/cryptography/fernet.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Text, Union +from typing import List, Text class InvalidToken(Exception): ... diff --git a/stubs/cryptography/cryptography/hazmat/backends/interfaces.pyi b/stubs/cryptography/cryptography/hazmat/backends/interfaces.pyi index f225f12baa90..9dbbecfbe3f7 100644 --- a/stubs/cryptography/cryptography/hazmat/backends/interfaces.pyi +++ b/stubs/cryptography/cryptography/hazmat/backends/interfaces.pyi @@ -1,5 +1,5 @@ from abc import ABCMeta, abstractmethod -from typing import Any, Optional, Union +from typing import Any from cryptography.hazmat.primitives.asymmetric.dh import ( DHParameterNumbers, diff --git a/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi b/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi index f0d9955bd52b..51c967bee642 100644 --- a/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi +++ b/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class Binding(object): ffi: Any | None diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi index 22d1b6c54607..7846f75b055c 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi @@ -1,5 +1,4 @@ from abc import ABCMeta, abstractmethod -from typing import Optional from cryptography.hazmat.backends.interfaces import DHBackend from cryptography.hazmat.primitives.serialization import ( diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi index ef95e63eff93..db9f191536de 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi @@ -1,5 +1,4 @@ from abc import ABCMeta, abstractmethod -from typing import Optional, Union from cryptography.hazmat.backends.interfaces import DSABackend from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi index 7cee69646258..33fb4cb9a931 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi @@ -1,5 +1,5 @@ from abc import ABCMeta, abstractmethod -from typing import ClassVar, Optional, Union +from typing import ClassVar from cryptography.hazmat.backends.interfaces import EllipticCurveBackend from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi index c12c34ac49ce..bb1781c132ef 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi @@ -1,5 +1,5 @@ from abc import ABCMeta, abstractmethod -from typing import ClassVar, Optional, Union +from typing import ClassVar from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi index d9ed1d7ab285..100cf6e22ebe 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi @@ -1,5 +1,5 @@ from abc import ABCMeta, abstractmethod -from typing import Optional, Tuple, Union +from typing import Tuple from cryptography.hazmat.backends.interfaces import RSABackend from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi index 0cf569aca838..f75a32cc50d9 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi @@ -1,5 +1,4 @@ from abc import ABCMeta, abstractmethod -from typing import Optional from cryptography.hazmat.backends.interfaces import CipherBackend from cryptography.hazmat.primitives.ciphers.modes import Mode diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi index fe74280e5993..856c316b8a12 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi @@ -1,4 +1,3 @@ -from typing import Optional class AESCCM(object): def __init__(self, key: bytes, tag_length: int | None) -> None: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyi index 98e6e693ba28..e01d2009438c 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyi @@ -1,5 +1,4 @@ from abc import ABCMeta, abstractmethod -from typing import Optional from cryptography.hazmat.primitives.ciphers import CipherAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi b/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi index 11cd34711e3e..c59dda9cee54 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import CMACBackend from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi b/stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi index f0a426a7957f..6e4828a48b21 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/hashes.pyi @@ -1,5 +1,4 @@ from abc import ABCMeta, abstractmethod -from typing import Optional from cryptography.hazmat.backends.interfaces import HashBackend diff --git a/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi b/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi index 2e63a96c459e..c06e190999ff 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi index 25ed2317de24..1eeb5f73d0ef 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import HashBackend, HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi index d9703957e876..34b0e1b5ee4d 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi index 3bff4fb0830b..375ef66a885d 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/kbkdf.pyi @@ -1,5 +1,4 @@ from enum import Enum -from typing import Optional from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi index 58411b85ea29..843b5a383807 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import PBKDF2HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi index 0d5169658a1f..dd331356a84d 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import ScryptBackend from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi index 43f741d95f27..cc9cc9e14434 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import HashBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi b/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi index bf08ecc0ccef..f81fce3ac612 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import CipherBackend diff --git a/stubs/cryptography/cryptography/hazmat/primitives/serialization/__init__.pyi b/stubs/cryptography/cryptography/hazmat/primitives/serialization/__init__.pyi index 61960c881cbf..e899766b7d0a 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/serialization/__init__.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/serialization/__init__.pyi @@ -1,6 +1,6 @@ from abc import ABCMeta from enum import Enum -from typing import Any, Optional, Union +from typing import Any from cryptography.hazmat.backends.interfaces import ( DERSerializationBackend, diff --git a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs12.pyi b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs12.pyi index cde76ee63238..c075872540d1 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs12.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs12.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple, Union +from typing import Any, List, Tuple from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKeyWithSerialization from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKeyWithSerialization diff --git a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi index 1973fc03153f..27a5ddf25fe4 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/serialization/pkcs7.pyi @@ -1,5 +1,5 @@ from enum import Enum -from typing import Any, Iterable, List, Optional, Union +from typing import Any, Iterable, List from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi index 5ca76bd08a49..73ce4aa2e855 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi index 9730043b05f3..a3e81981ba5f 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi @@ -1,4 +1,3 @@ -from typing import Optional from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index cb9352381158..9e95f3ed0beb 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -2,7 +2,7 @@ import datetime from abc import ABCMeta, abstractmethod from enum import Enum from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network -from typing import Any, ClassVar, Generator, Generic, Iterable, List, Optional, Sequence, Text, Type, TypeVar, Union +from typing import Any, ClassVar, Generator, Generic, Iterable, List, Sequence, Text, Type, TypeVar from cryptography.hazmat.backends.interfaces import X509Backend from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey diff --git a/stubs/cryptography/cryptography/x509/oid.pyi b/stubs/cryptography/cryptography/x509/oid.pyi index 5687c1c9690d..7daf8aee55e2 100644 --- a/stubs/cryptography/cryptography/x509/oid.pyi +++ b/stubs/cryptography/cryptography/x509/oid.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Optional +from typing import Dict from cryptography.hazmat.primitives.hashes import HashAlgorithm from cryptography.x509 import ObjectIdentifier diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index fe86dcaa1b3a..9117eb79db9f 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Tuple, Type, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stubs/dateparser/dateparser.pyi b/stubs/dateparser/dateparser.pyi index 1603fcbd24e5..3401001e0eef 100644 --- a/stubs/dateparser/dateparser.pyi +++ b/stubs/dateparser/dateparser.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Any, List, Mapping, Optional, Set, Tuple, Union +from typing import Any, List, Mapping, Set, Tuple __version__: str diff --git a/stubs/decorator/decorator.pyi b/stubs/decorator/decorator.pyi index f660544ea331..cbd690b21a3f 100644 --- a/stubs/decorator/decorator.pyi +++ b/stubs/decorator/decorator.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Dict, Iterator, List, NamedTuple, Optional, Pattern, Text, Tuple, TypeVar +from typing import Any, Callable, Dict, Iterator, List, NamedTuple, Pattern, Text, Tuple, TypeVar _C = TypeVar("_C", bound=Callable[..., Any]) _Func = TypeVar("_Func", bound=Callable[..., Any]) diff --git a/stubs/docopt/docopt.pyi b/stubs/docopt/docopt.pyi index 06eccd44448f..7f7bba6a7e69 100644 --- a/stubs/docopt/docopt.pyi +++ b/stubs/docopt/docopt.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Optional, Union +from typing import Any, Iterable, Union __version__: str diff --git a/stubs/docutils/docutils/__init__.pyi b/stubs/docutils/docutils/__init__.pyi index 4d7cdc5c9ae1..d4477b9624b0 100644 --- a/stubs/docutils/docutils/__init__.pyi +++ b/stubs/docutils/docutils/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, NamedTuple, Optional, Tuple +from typing import Any, ClassVar, NamedTuple, Tuple __docformat__: str __version__: str diff --git a/stubs/docutils/docutils/frontend.pyi b/stubs/docutils/docutils/frontend.pyi index 2a08ddac1a9f..f482a037adc4 100644 --- a/stubs/docutils/docutils/frontend.pyi +++ b/stubs/docutils/docutils/frontend.pyi @@ -1,6 +1,6 @@ import optparse from configparser import RawConfigParser -from typing import Any, ClassVar, Optional, Tuple +from typing import Any, ClassVar, Tuple from docutils import SettingsSpec from docutils.utils import DependencyList diff --git a/stubs/docutils/docutils/io.pyi b/stubs/docutils/docutils/io.pyi index 635b1686bcc1..b8d4751e8fc5 100644 --- a/stubs/docutils/docutils/io.pyi +++ b/stubs/docutils/docutils/io.pyi @@ -1,5 +1,5 @@ from _typeshed import OpenBinaryModeReading, OpenBinaryModeWriting, OpenTextModeReading, OpenTextModeWriting -from typing import Any, ClassVar, Optional, Union +from typing import Any, ClassVar from docutils import TransformSpec diff --git a/stubs/docutils/docutils/parsers/rst/__init__.pyi b/stubs/docutils/docutils/parsers/rst/__init__.pyi index 76de43d97a99..d58522203c2e 100644 --- a/stubs/docutils/docutils/parsers/rst/__init__.pyi +++ b/stubs/docutils/docutils/parsers/rst/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Optional, Tuple +from typing import Any, ClassVar, Tuple from typing_extensions import Literal from docutils import parsers diff --git a/stubs/docutils/docutils/utils/__init__.pyi b/stubs/docutils/docutils/utils/__init__.pyi index 5cd3e66222fc..189352a6770c 100644 --- a/stubs/docutils/docutils/utils/__init__.pyi +++ b/stubs/docutils/docutils/utils/__init__.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable -from typing import Any, Optional +from typing import Any from docutils.io import FileOutput diff --git a/stubs/emoji/emoji/core.pyi b/stubs/emoji/emoji/core.pyi index 54c19e1b10ad..f0d765663430 100644 --- a/stubs/emoji/emoji/core.pyi +++ b/stubs/emoji/emoji/core.pyi @@ -1,4 +1,4 @@ -from typing import Dict, List, Pattern, Text, Tuple, Union +from typing import Dict, List, Pattern, Text, Tuple from typing_extensions import Literal _DEFAULT_DELIMITER: str diff --git a/stubs/filelock/filelock/__init__.pyi b/stubs/filelock/filelock/__init__.pyi index a5b2eb9d285b..90e6c1c5df1d 100644 --- a/stubs/filelock/filelock/__init__.pyi +++ b/stubs/filelock/filelock/__init__.pyi @@ -1,7 +1,7 @@ import sys from logging import Logger from types import TracebackType -from typing import Optional, Type, Union +from typing import Type def logger() -> Logger: ... diff --git a/stubs/first/first.pyi b/stubs/first/first.pyi index 7e5591b4f83a..2306d521be3c 100644 --- a/stubs/first/first.pyi +++ b/stubs/first/first.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Iterable, TypeVar, overload _T = TypeVar("_T") _S = TypeVar("_S") diff --git a/stubs/geoip2/geoip2/errors.pyi b/stubs/geoip2/geoip2/errors.pyi index 912858685382..1bba2d31beea 100644 --- a/stubs/geoip2/geoip2/errors.pyi +++ b/stubs/geoip2/geoip2/errors.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Text +from typing import Text class GeoIP2Error(RuntimeError): ... class AddressNotFoundError(GeoIP2Error): ... diff --git a/stubs/itsdangerous/itsdangerous.pyi b/stubs/itsdangerous/itsdangerous.pyi index f1645e4ef62b..17e1ba1ead3c 100644 --- a/stubs/itsdangerous/itsdangerous.pyi +++ b/stubs/itsdangerous/itsdangerous.pyi @@ -1,5 +1,5 @@ from datetime import datetime -from typing import IO, Any, Callable, Generator, Mapping, MutableMapping, Optional, Text, Tuple, Union +from typing import IO, Any, Callable, Generator, Mapping, MutableMapping, Text, Tuple _serializer = Any # must be an object that has "dumps" and "loads" attributes (e.g. the json module) diff --git a/stubs/maxminddb/maxminddb/reader.pyi b/stubs/maxminddb/maxminddb/reader.pyi index affe1b7d82b6..ec81db5988a9 100644 --- a/stubs/maxminddb/maxminddb/reader.pyi +++ b/stubs/maxminddb/maxminddb/reader.pyi @@ -1,6 +1,6 @@ from ipaddress import IPv4Address, IPv6Address from types import TracebackType -from typing import Any, Mapping, Optional, Sequence, Text, Tuple, Type, Union +from typing import Any, Mapping, Sequence, Text, Tuple, Type class Reader: closed: bool = ... diff --git a/stubs/mock/mock.pyi b/stubs/mock/mock.pyi index 83cd0e0defcc..a691fbd34342 100644 --- a/stubs/mock/mock.pyi +++ b/stubs/mock/mock.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Generic, List, Mapping, Optional, Sequence, Text, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, List, Mapping, Sequence, Text, Tuple, Type, TypeVar, overload _F = TypeVar("_F", bound=Callable[..., Any]) _T = TypeVar("_T") diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index 52d00ad67c17..b59eb17e33f3 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -1,6 +1,6 @@ import abc import sys -from typing import Any, Callable, Dict, Generic, ItemsView, KeysView, Mapping, Optional, Type, TypeVar, Union, ValuesView +from typing import Any, Callable, Dict, Generic, ItemsView, KeysView, Mapping, Type, TypeVar, Union, ValuesView _T = TypeVar("_T") _U = TypeVar("_U") diff --git a/stubs/nmap/nmap/nmap.pyi b/stubs/nmap/nmap/nmap.pyi index 80b6e0ad6646..82550de2c9eb 100644 --- a/stubs/nmap/nmap/nmap.pyi +++ b/stubs/nmap/nmap/nmap.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Text, Tuple, TypeVar +from typing import Any, Callable, Dict, Iterable, Iterator, List, Text, Tuple, TypeVar from typing_extensions import TypedDict _T = TypeVar("_T") diff --git a/stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi b/stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi index 2feebdd63683..bda6f7b0f457 100644 --- a/stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi +++ b/stubs/oauthlib/oauthlib/oauth1/rfc5849/signature.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any log: Any diff --git a/stubs/orjson/orjson.pyi b/stubs/orjson/orjson.pyi index 35387cecef56..9dcb4c45e494 100644 --- a/stubs/orjson/orjson.pyi +++ b/stubs/orjson/orjson.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Union +from typing import Any, Callable __version__: str diff --git a/stubs/paramiko/paramiko/_winapi.pyi b/stubs/paramiko/paramiko/_winapi.pyi index f3a31bd006cd..92517ba6cc45 100644 --- a/stubs/paramiko/paramiko/_winapi.pyi +++ b/stubs/paramiko/paramiko/_winapi.pyi @@ -2,7 +2,7 @@ import builtins import ctypes import sys from types import TracebackType -from typing import Any, Optional, Type, TypeVar +from typing import Any, Type, TypeVar if sys.platform == "win32": diff --git a/stubs/paramiko/paramiko/auth_handler.pyi b/stubs/paramiko/paramiko/auth_handler.pyi index e8e20726f329..ffd9c75fb8bb 100644 --- a/stubs/paramiko/paramiko/auth_handler.pyi +++ b/stubs/paramiko/paramiko/auth_handler.pyi @@ -1,5 +1,5 @@ from threading import Event -from typing import Callable, List, Optional, Tuple +from typing import Callable, List, Tuple from paramiko.pkey import PKey from paramiko.ssh_gss import _SSH_GSSAuth diff --git a/stubs/paramiko/paramiko/ber.pyi b/stubs/paramiko/paramiko/ber.pyi index dd14ce7bdfce..200f5ea58d2b 100644 --- a/stubs/paramiko/paramiko/ber.pyi +++ b/stubs/paramiko/paramiko/ber.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, Union +from typing import Any, Iterable, List class BERException(Exception): ... diff --git a/stubs/paramiko/paramiko/buffered_pipe.pyi b/stubs/paramiko/paramiko/buffered_pipe.pyi index 4e1ad59afac3..795c49cd9c01 100644 --- a/stubs/paramiko/paramiko/buffered_pipe.pyi +++ b/stubs/paramiko/paramiko/buffered_pipe.pyi @@ -1,5 +1,5 @@ from threading import Event -from typing import Generic, Optional, Text, TypeVar +from typing import Generic, Text, TypeVar _T = TypeVar("_T", Text, bytes) diff --git a/stubs/paramiko/paramiko/channel.pyi b/stubs/paramiko/paramiko/channel.pyi index ed4f8f44c537..47aacdea5f87 100644 --- a/stubs/paramiko/paramiko/channel.pyi +++ b/stubs/paramiko/paramiko/channel.pyi @@ -1,6 +1,6 @@ from logging import Logger from threading import Condition, Event, Lock -from typing import Any, Callable, Mapping, Optional, Tuple, TypeVar +from typing import Any, Callable, Mapping, Tuple, TypeVar from paramiko.buffered_pipe import BufferedPipe from paramiko.file import BufferedFile diff --git a/stubs/paramiko/paramiko/client.pyi b/stubs/paramiko/paramiko/client.pyi index 3798a355f9c2..d6b9545ba9d7 100644 --- a/stubs/paramiko/paramiko/client.pyi +++ b/stubs/paramiko/paramiko/client.pyi @@ -1,5 +1,5 @@ from socket import socket -from typing import Dict, Iterable, Mapping, NoReturn, Optional, Tuple, Type, Union +from typing import Dict, Iterable, Mapping, NoReturn, Tuple, Type from paramiko.channel import Channel, ChannelFile, ChannelStderrFile, ChannelStdinFile from paramiko.hostkeys import HostKeys diff --git a/stubs/paramiko/paramiko/config.pyi b/stubs/paramiko/paramiko/config.pyi index a738f6cb6450..99d3c0383192 100644 --- a/stubs/paramiko/paramiko/config.pyi +++ b/stubs/paramiko/paramiko/config.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Dict, Iterable, List, Optional, Pattern, Set +from typing import IO, Any, Dict, Iterable, List, Pattern, Set from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize diff --git a/stubs/paramiko/paramiko/dsskey.pyi b/stubs/paramiko/paramiko/dsskey.pyi index 8baf6aaa590b..b687655dc22d 100644 --- a/stubs/paramiko/paramiko/dsskey.pyi +++ b/stubs/paramiko/paramiko/dsskey.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Optional, Tuple +from typing import IO, Any, Callable, Tuple from paramiko.message import Message from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/ecdsakey.pyi b/stubs/paramiko/paramiko/ecdsakey.pyi index b1ca8ae74f40..804ae7d468a7 100644 --- a/stubs/paramiko/paramiko/ecdsakey.pyi +++ b/stubs/paramiko/paramiko/ecdsakey.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, List, Optional, Sequence, Tuple, Type +from typing import IO, Any, Callable, List, Sequence, Tuple, Type from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/paramiko/paramiko/ed25519key.pyi b/stubs/paramiko/paramiko/ed25519key.pyi index 73bb2b69cdca..1f57ba269701 100644 --- a/stubs/paramiko/paramiko/ed25519key.pyi +++ b/stubs/paramiko/paramiko/ed25519key.pyi @@ -1,4 +1,4 @@ -from typing import IO, Optional +from typing import IO from paramiko.message import Message from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/file.pyi b/stubs/paramiko/paramiko/file.pyi index 2e2732ea2f6b..df8eae9b32f7 100644 --- a/stubs/paramiko/paramiko/file.pyi +++ b/stubs/paramiko/paramiko/file.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Generic, Iterable, List, Optional, Tuple, Union +from typing import Any, AnyStr, Generic, Iterable, List, Tuple from paramiko.util import ClosingContextManager diff --git a/stubs/paramiko/paramiko/hostkeys.pyi b/stubs/paramiko/paramiko/hostkeys.pyi index f307cc5dcba7..d7b6d5d8083a 100644 --- a/stubs/paramiko/paramiko/hostkeys.pyi +++ b/stubs/paramiko/paramiko/hostkeys.pyi @@ -1,4 +1,4 @@ -from typing import Iterator, List, Mapping, MutableMapping, Optional +from typing import Iterator, List, Mapping, MutableMapping from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/kex_curve25519.pyi b/stubs/paramiko/paramiko/kex_curve25519.pyi index 6d03704b39f3..c2811dd70c96 100644 --- a/stubs/paramiko/paramiko/kex_curve25519.pyi +++ b/stubs/paramiko/paramiko/kex_curve25519.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer as ReadableBuffer -from typing import Callable, Optional +from typing import Callable from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi index 70be59d25ae5..aec8d912aff0 100644 --- a/stubs/paramiko/paramiko/kex_ecdh_nist.pyi +++ b/stubs/paramiko/paramiko/kex_ecdh_nist.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer -from typing import Callable, Optional, Union +from typing import Callable from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/kex_gex.pyi b/stubs/paramiko/paramiko/kex_gex.pyi index 36f2b27432d0..a47717ec9c4f 100644 --- a/stubs/paramiko/paramiko/kex_gex.pyi +++ b/stubs/paramiko/paramiko/kex_gex.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer -from typing import Callable, Optional +from typing import Callable from paramiko.message import Message from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/kex_gss.pyi b/stubs/paramiko/paramiko/kex_gss.pyi index c38b2be3afcb..8c7ec249f479 100644 --- a/stubs/paramiko/paramiko/kex_gss.pyi +++ b/stubs/paramiko/paramiko/kex_gss.pyi @@ -1,4 +1,3 @@ -from typing import Optional from paramiko.message import Message from paramiko.ssh_gss import _SSH_GSSAuth diff --git a/stubs/paramiko/paramiko/message.pyi b/stubs/paramiko/paramiko/message.pyi index 05c3111fe3b8..604993604deb 100644 --- a/stubs/paramiko/paramiko/message.pyi +++ b/stubs/paramiko/paramiko/message.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Iterable, List, Optional, Text +from typing import Any, Iterable, List, Text from .common import _LikeBytes diff --git a/stubs/paramiko/paramiko/pkey.pyi b/stubs/paramiko/paramiko/pkey.pyi index 50bc1ea3a1aa..4990501b7384 100644 --- a/stubs/paramiko/paramiko/pkey.pyi +++ b/stubs/paramiko/paramiko/pkey.pyi @@ -1,4 +1,4 @@ -from typing import IO, Optional, Pattern, Type, TypeVar, Union +from typing import IO, Pattern, Type, TypeVar from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/proxy.pyi b/stubs/paramiko/paramiko/proxy.pyi index fb50e6288c6a..0810605cc334 100644 --- a/stubs/paramiko/paramiko/proxy.pyi +++ b/stubs/paramiko/paramiko/proxy.pyi @@ -1,5 +1,5 @@ from subprocess import Popen -from typing import Any, List, Optional +from typing import Any, List from paramiko.util import ClosingContextManager diff --git a/stubs/paramiko/paramiko/py3compat.pyi b/stubs/paramiko/paramiko/py3compat.pyi index 06b60eac0c71..c260b9b42a6c 100644 --- a/stubs/paramiko/paramiko/py3compat.pyi +++ b/stubs/paramiko/paramiko/py3compat.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Iterable, Sequence, Text, Type, TypeVar, Union +from typing import Any, Iterable, Sequence, Text, Type, TypeVar _T = TypeVar("_T") diff --git a/stubs/paramiko/paramiko/rsakey.pyi b/stubs/paramiko/paramiko/rsakey.pyi index 85b949c202c8..7c76e60e23d9 100644 --- a/stubs/paramiko/paramiko/rsakey.pyi +++ b/stubs/paramiko/paramiko/rsakey.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Optional, Union +from typing import IO, Any, Callable from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey, RSAPublicNumbers from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/server.pyi b/stubs/paramiko/paramiko/server.pyi index fcf3a6d4f067..c4ee38221245 100644 --- a/stubs/paramiko/paramiko/server.pyi +++ b/stubs/paramiko/paramiko/server.pyi @@ -1,5 +1,5 @@ import threading -from typing import Any, List, Optional, Tuple, Union +from typing import Any, List, Tuple from paramiko.channel import Channel from paramiko.message import Message diff --git a/stubs/paramiko/paramiko/sftp.pyi b/stubs/paramiko/paramiko/sftp.pyi index e1423fbb85c2..c941d6bfe10f 100644 --- a/stubs/paramiko/paramiko/sftp.pyi +++ b/stubs/paramiko/paramiko/sftp.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import Dict, List, Optional +from typing import Dict, List from paramiko.channel import Channel diff --git a/stubs/paramiko/paramiko/sftp_attr.pyi b/stubs/paramiko/paramiko/sftp_attr.pyi index a876e7d89bd6..532996598a03 100644 --- a/stubs/paramiko/paramiko/sftp_attr.pyi +++ b/stubs/paramiko/paramiko/sftp_attr.pyi @@ -1,5 +1,5 @@ from os import stat_result -from typing import Dict, Optional +from typing import Dict class SFTPAttributes: FLAG_SIZE: int diff --git a/stubs/paramiko/paramiko/sftp_client.pyi b/stubs/paramiko/paramiko/sftp_client.pyi index 2a4be022b211..203bf380a534 100644 --- a/stubs/paramiko/paramiko/sftp_client.pyi +++ b/stubs/paramiko/paramiko/sftp_client.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import IO, Any, Callable, Iterator, List, Optional, Text, Tuple, Union +from typing import IO, Any, Callable, Iterator, List, Text, Tuple from paramiko.channel import Channel from paramiko.sftp import BaseSFTP diff --git a/stubs/paramiko/paramiko/sftp_file.pyi b/stubs/paramiko/paramiko/sftp_file.pyi index 3b216d27586b..d335c14f3fae 100644 --- a/stubs/paramiko/paramiko/sftp_file.pyi +++ b/stubs/paramiko/paramiko/sftp_file.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, Optional, Sequence, Tuple +from typing import Any, Iterator, Sequence, Tuple from paramiko.file import BufferedFile from paramiko.sftp_attr import SFTPAttributes diff --git a/stubs/paramiko/paramiko/sftp_handle.pyi b/stubs/paramiko/paramiko/sftp_handle.pyi index 03d0daba59da..3c7cacca19b7 100644 --- a/stubs/paramiko/paramiko/sftp_handle.pyi +++ b/stubs/paramiko/paramiko/sftp_handle.pyi @@ -1,4 +1,3 @@ -from typing import Union from paramiko.sftp_attr import SFTPAttributes from paramiko.util import ClosingContextManager diff --git a/stubs/paramiko/paramiko/sftp_server.pyi b/stubs/paramiko/paramiko/sftp_server.pyi index 553ec1de368d..a0f8cf0b56c4 100644 --- a/stubs/paramiko/paramiko/sftp_server.pyi +++ b/stubs/paramiko/paramiko/sftp_server.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import Any, Dict, Optional, Type +from typing import Any, Dict, Type from paramiko.channel import Channel from paramiko.server import ServerInterface, SubsystemHandler diff --git a/stubs/paramiko/paramiko/sftp_si.pyi b/stubs/paramiko/paramiko/sftp_si.pyi index eaaddccbc491..70b7d6b080c0 100644 --- a/stubs/paramiko/paramiko/sftp_si.pyi +++ b/stubs/paramiko/paramiko/sftp_si.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Union +from typing import Any, List from paramiko.server import ServerInterface from paramiko.sftp_attr import SFTPAttributes diff --git a/stubs/paramiko/paramiko/ssh_exception.pyi b/stubs/paramiko/paramiko/ssh_exception.pyi index 844ba6e5625e..2911b5a70266 100644 --- a/stubs/paramiko/paramiko/ssh_exception.pyi +++ b/stubs/paramiko/paramiko/ssh_exception.pyi @@ -1,5 +1,5 @@ import socket -from typing import List, Mapping, Tuple, Union +from typing import List, Mapping, Tuple from paramiko.pkey import PKey diff --git a/stubs/paramiko/paramiko/ssh_gss.pyi b/stubs/paramiko/paramiko/ssh_gss.pyi index df52bae88cc2..aed5ae7672fe 100644 --- a/stubs/paramiko/paramiko/ssh_gss.pyi +++ b/stubs/paramiko/paramiko/ssh_gss.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Tuple, Type +from typing import Any, Tuple, Type GSS_AUTH_AVAILABLE: bool GSS_EXCEPTIONS: Tuple[Type[Exception], ...] diff --git a/stubs/paramiko/paramiko/transport.pyi b/stubs/paramiko/paramiko/transport.pyi index 9d9378ca4687..46fdf356f0b5 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -2,7 +2,7 @@ from logging import Logger from socket import socket from threading import Condition, Event, Lock, Thread from types import ModuleType -from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Sequence, Tuple, Type, Union +from typing import Any, Callable, Dict, Iterable, List, Protocol, Sequence, Tuple, Type from paramiko.auth_handler import AuthHandler, _InteractiveCallback from paramiko.channel import Channel diff --git a/stubs/paramiko/paramiko/util.pyi b/stubs/paramiko/paramiko/util.pyi index 4f57876b003e..4ca921eb47a0 100644 --- a/stubs/paramiko/paramiko/util.pyi +++ b/stubs/paramiko/paramiko/util.pyi @@ -1,7 +1,7 @@ import sys from logging import Logger, LogRecord from types import TracebackType -from typing import IO, AnyStr, Callable, List, Optional, Protocol, Type, TypeVar, Union +from typing import IO, AnyStr, Callable, List, Protocol, Type, TypeVar from paramiko.config import SSHConfig, SSHConfigDict from paramiko.hostkeys import HostKeys diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index 661f72901b47..f1df97f72b13 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -1,5 +1,5 @@ import textwrap -from typing import IO, Any, Callable, Dict, Generic, List, Optional, Text, Tuple, Type, TypeVar, Union, overload +from typing import IO, Any, Callable, Dict, Generic, List, Text, Tuple, Type, TypeVar, overload from typing_extensions import SupportsIndex _TB = TypeVar("_TB", bound="_BaseEntry") diff --git a/stubs/protobuf/google/protobuf/descriptor_pool.pyi b/stubs/protobuf/google/protobuf/descriptor_pool.pyi index 124be8f24e96..f1ecee77622a 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pool.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pool.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class DescriptorPool: def __new__(cls, descriptor_db: Any | None = ...): ... diff --git a/stubs/protobuf/google/protobuf/internal/containers.pyi b/stubs/protobuf/google/protobuf/internal/containers.pyi index dabb6dd69a6c..8da0df3a1c6f 100644 --- a/stubs/protobuf/google/protobuf/internal/containers.pyi +++ b/stubs/protobuf/google/protobuf/internal/containers.pyi @@ -6,7 +6,7 @@ from typing import ( List, Mapping as Mapping, MutableMapping as MutableMapping, - Optional, + Sequence, Text, TypeVar, diff --git a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi index 0495df6347dc..a8aead6fd3ad 100644 --- a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi +++ b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Iterator, Text, TypeVar, Union +from typing import Any, Generic, Iterator, Text, TypeVar from google.protobuf.descriptor import FieldDescriptor from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer diff --git a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi index fad401e227ea..239a44397f95 100644 --- a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +++ b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi @@ -1,5 +1,5 @@ from datetime import datetime, timedelta -from typing import Any as tAny, Dict, Optional, Type +from typing import Any as tAny, Dict, Type class Error(Exception): ... class ParseError(Error): ... diff --git a/stubs/protobuf/google/protobuf/json_format.pyi b/stubs/protobuf/google/protobuf/json_format.pyi index 241eb6018b43..dc3ace7caf15 100644 --- a/stubs/protobuf/google/protobuf/json_format.pyi +++ b/stubs/protobuf/google/protobuf/json_format.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Text, TypeVar, Union +from typing import Any, Dict, Text, TypeVar from google.protobuf.descriptor_pool import DescriptorPool from google.protobuf.message import Message diff --git a/stubs/protobuf/google/protobuf/message_factory.pyi b/stubs/protobuf/google/protobuf/message_factory.pyi index d619740ced07..3c092f45627c 100644 --- a/stubs/protobuf/google/protobuf/message_factory.pyi +++ b/stubs/protobuf/google/protobuf/message_factory.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, Optional, Type +from typing import Any, Dict, Iterable, Type from google.protobuf.descriptor import Descriptor from google.protobuf.descriptor_pb2 import FileDescriptorProto diff --git a/stubs/protobuf/google/protobuf/service.pyi b/stubs/protobuf/google/protobuf/service.pyi index afe0cc9a1bc5..ca686a9b2c61 100644 --- a/stubs/protobuf/google/protobuf/service.pyi +++ b/stubs/protobuf/google/protobuf/service.pyi @@ -1,5 +1,5 @@ from concurrent.futures import Future -from typing import Callable, Optional, Text, Type +from typing import Callable, Text, Type from google.protobuf.descriptor import MethodDescriptor, ServiceDescriptor from google.protobuf.message import Message diff --git a/stubs/protobuf/google/protobuf/symbol_database.pyi b/stubs/protobuf/google/protobuf/symbol_database.pyi index e1a4a4b3b76b..eda439e7e4b9 100644 --- a/stubs/protobuf/google/protobuf/symbol_database.pyi +++ b/stubs/protobuf/google/protobuf/symbol_database.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Iterable, Type, Union +from typing import Dict, Iterable, Type from google.protobuf.descriptor import Descriptor, EnumDescriptor, FileDescriptor, ServiceDescriptor from google.protobuf.message import Message diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index 8e36b7a9a562..1185808ab72b 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import SupportsWrite -from typing import Any, Callable, Iterable, Optional, Text, Tuple, TypeVar, Union +from typing import Any, Callable, Iterable, Optional, Text, Tuple, TypeVar from .descriptor import FieldDescriptor from .descriptor_pool import DescriptorPool diff --git a/stubs/pyRFC3339/pyrfc3339/utils.pyi b/stubs/pyRFC3339/pyrfc3339/utils.pyi index 7b3441424666..54588acf74a5 100644 --- a/stubs/pyRFC3339/pyrfc3339/utils.pyi +++ b/stubs/pyRFC3339/pyrfc3339/utils.pyi @@ -1,5 +1,4 @@ from datetime import datetime, timedelta, tzinfo -from typing import Optional class FixedOffset(tzinfo): def __init__(self, hours: float, minutes: float) -> None: ... diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 90986bb0d600..133c78e9a7d9 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -1,6 +1,6 @@ from stat import S_IMODE as S_IMODE from types import TracebackType -from typing import IO, Any, Callable, ContextManager, List, Optional, Sequence, Text, Tuple, Type, Union +from typing import IO, Any, Callable, ContextManager, List, Sequence, Text, Tuple, Type, Union from typing_extensions import Literal import paramiko diff --git a/stubs/pysftp/pysftp/helpers.pyi b/stubs/pysftp/pysftp/helpers.pyi index 9d2b3a4f1c75..4849fe213768 100644 --- a/stubs/pysftp/pysftp/helpers.pyi +++ b/stubs/pysftp/pysftp/helpers.pyi @@ -1,4 +1,4 @@ -from typing import Callable, ContextManager, Iterator, List, Optional +from typing import Callable, ContextManager, Iterator, List def known_hosts() -> str: ... def st_mode_to_int(val: int) -> int: ... diff --git a/stubs/python-dateutil/dateutil/_common.pyi b/stubs/python-dateutil/dateutil/_common.pyi index 2aefaff5b19e..dd3d52d40fc2 100644 --- a/stubs/python-dateutil/dateutil/_common.pyi +++ b/stubs/python-dateutil/dateutil/_common.pyi @@ -1,4 +1,4 @@ -from typing import Optional, TypeVar +from typing import TypeVar _T = TypeVar("_T") diff --git a/stubs/python-dateutil/dateutil/parser.pyi b/stubs/python-dateutil/dateutil/parser.pyi index ca4db017137b..2fd41c4c1a9f 100644 --- a/stubs/python-dateutil/dateutil/parser.pyi +++ b/stubs/python-dateutil/dateutil/parser.pyi @@ -1,5 +1,5 @@ from datetime import datetime, tzinfo -from typing import IO, Any, Dict, List, Mapping, Optional, Text, Tuple, Union +from typing import IO, Any, Dict, List, Mapping, Text, Tuple, Union _FileOrStr = Union[bytes, Text, IO[str], IO[Any]] diff --git a/stubs/python-dateutil/dateutil/relativedelta.pyi b/stubs/python-dateutil/dateutil/relativedelta.pyi index 6dd39caee21c..61f743fb8db4 100644 --- a/stubs/python-dateutil/dateutil/relativedelta.pyi +++ b/stubs/python-dateutil/dateutil/relativedelta.pyi @@ -1,5 +1,5 @@ from datetime import date, datetime, timedelta -from typing import Optional, SupportsFloat, TypeVar, Union, overload +from typing import SupportsFloat, TypeVar, overload from ._common import weekday diff --git a/stubs/python-dateutil/dateutil/rrule.pyi b/stubs/python-dateutil/dateutil/rrule.pyi index a3fbe78f94e3..d928c8d779bd 100644 --- a/stubs/python-dateutil/dateutil/rrule.pyi +++ b/stubs/python-dateutil/dateutil/rrule.pyi @@ -1,5 +1,5 @@ import datetime -from typing import Any, Iterable, Optional, Union +from typing import Any, Iterable from ._common import weekday as weekdaybase diff --git a/stubs/python-dateutil/dateutil/tz/_common.pyi b/stubs/python-dateutil/dateutil/tz/_common.pyi index 354b8fa3dcfa..807789fef776 100644 --- a/stubs/python-dateutil/dateutil/tz/_common.pyi +++ b/stubs/python-dateutil/dateutil/tz/_common.pyi @@ -1,5 +1,5 @@ from datetime import datetime, timedelta, tzinfo -from typing import Any, Optional +from typing import Any def tzname_in_python2(namefunc): ... def enfold(dt: datetime, fold: int = ...): ... diff --git a/stubs/python-dateutil/dateutil/tz/tz.pyi b/stubs/python-dateutil/dateutil/tz/tz.pyi index df68918a1627..70dd605a8011 100644 --- a/stubs/python-dateutil/dateutil/tz/tz.pyi +++ b/stubs/python-dateutil/dateutil/tz/tz.pyi @@ -1,5 +1,5 @@ import datetime -from typing import IO, Any, List, Optional, Text, Tuple, Union +from typing import IO, Any, List, Text, Tuple, Union from ..relativedelta import relativedelta from ._common import _tzinfo as _tzinfo, enfold as enfold, tzname_in_python2 as tzname_in_python2, tzrangebase as tzrangebase diff --git a/stubs/python-dateutil/dateutil/utils.pyi b/stubs/python-dateutil/dateutil/utils.pyi index 62044433391e..6ebd4031fdb7 100644 --- a/stubs/python-dateutil/dateutil/utils.pyi +++ b/stubs/python-dateutil/dateutil/utils.pyi @@ -1,5 +1,4 @@ from datetime import datetime, timedelta, tzinfo -from typing import Optional def default_tzinfo(dt: datetime, tzinfo: tzinfo) -> datetime: ... def today(tzinfo: tzinfo | None = ...) -> datetime: ... diff --git a/stubs/python-gflags/gflags.pyi b/stubs/python-gflags/gflags.pyi index db8a196d802e..7cf85dfa321f 100644 --- a/stubs/python-gflags/gflags.pyi +++ b/stubs/python-gflags/gflags.pyi @@ -1,5 +1,5 @@ from types import ModuleType -from typing import IO, Any, Callable, Dict, Iterable, List, Optional, Sequence, Text, Union +from typing import IO, Any, Callable, Dict, Iterable, List, Sequence, Text class Error(Exception): ... diff --git a/stubs/python-slugify/slugify/slugify.pyi b/stubs/python-slugify/slugify/slugify.pyi index d53dc07e4644..65b3ec6f1c3e 100644 --- a/stubs/python-slugify/slugify/slugify.pyi +++ b/stubs/python-slugify/slugify/slugify.pyi @@ -1,4 +1,4 @@ -from typing import Iterable, Optional +from typing import Iterable def smart_truncate( string: str, max_length: int = ..., word_boundary: bool = ..., separator: str = ..., save_order: bool = ... diff --git a/stubs/pytz/pytz/__init__.pyi b/stubs/pytz/pytz/__init__.pyi index 6a01fa9b298a..1bf5a6cd1acb 100644 --- a/stubs/pytz/pytz/__init__.pyi +++ b/stubs/pytz/pytz/__init__.pyi @@ -1,5 +1,5 @@ import datetime -from typing import List, Mapping, Optional, Set, Union +from typing import List, Mapping, Set class BaseTzInfo(datetime.tzinfo): zone: str = ... diff --git a/stubs/pyvmomi/pyVmomi/vmodl/query.pyi b/stubs/pyvmomi/pyVmomi/vmodl/query.pyi index 9bd372a9b2e8..059e282b7607 100644 --- a/stubs/pyvmomi/pyVmomi/vmodl/query.pyi +++ b/stubs/pyvmomi/pyVmomi/vmodl/query.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Type +from typing import Any, List, Type from pyVmomi.vim import ManagedEntity from pyVmomi.vim.view import ContainerView diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index fe993d5716bb..f792efc5c650 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -8,7 +8,7 @@ from typing import ( Iterator, List, Mapping, - Optional, + Sequence, Set, Text, diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index 22025a599a41..8863d4b79a9e 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Mapping, Optional, Text, Tuple, Type, Union +from typing import Any, List, Mapping, Text, Tuple, Type ssl_available: Any hiredis_version: Any diff --git a/stubs/redis/redis/lock.pyi b/stubs/redis/redis/lock.pyi index 37b8e9073065..6dd6e07d1ca4 100644 --- a/stubs/redis/redis/lock.pyi +++ b/stubs/redis/redis/lock.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Optional, Text, Type, Union +from typing import Any, Text, Type, Union from redis.client import Redis diff --git a/stubs/redis/redis/utils.pyi b/stubs/redis/redis/utils.pyi index ba3f06e766c4..aa0e827f2e1e 100644 --- a/stubs/redis/redis/utils.pyi +++ b/stubs/redis/redis/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, ContextManager, Optional, Text, TypeVar, overload +from typing import Any, ContextManager, Text, TypeVar, overload from typing_extensions import Literal from .client import Pipeline, Redis, _StrType diff --git a/stubs/requests/requests/adapters.pyi b/stubs/requests/requests/adapters.pyi index e2121c36f9e0..bbcdd2adcccc 100644 --- a/stubs/requests/requests/adapters.pyi +++ b/stubs/requests/requests/adapters.pyi @@ -1,4 +1,4 @@ -from typing import Any, Container, Mapping, Optional, Text, Tuple, Union +from typing import Any, Container, Mapping, Text, Tuple from . import cookies, exceptions, models, structures, utils from .packages.urllib3 import exceptions as urllib3_exceptions, poolmanager, response diff --git a/stubs/requests/requests/api.pyi b/stubs/requests/requests/api.pyi index eb31e32a90d8..1a241d308940 100644 --- a/stubs/requests/requests/api.pyi +++ b/stubs/requests/requests/api.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Text, Union +from typing import Any, Text from .models import Response from .sessions import _Data, _Params diff --git a/stubs/requests/requests/auth.pyi b/stubs/requests/requests/auth.pyi index f9d2214801b2..97e81122237a 100644 --- a/stubs/requests/requests/auth.pyi +++ b/stubs/requests/requests/auth.pyi @@ -1,4 +1,4 @@ -from typing import Any, Text, Union +from typing import Any, Text from . import cookies, models, utils diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 95753a07ea55..b5d71e7e07e6 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -1,6 +1,6 @@ import datetime from json import JSONDecoder -from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Type, Union +from typing import Any, Callable, Dict, Iterator, List, Text, Type from . import auth, cookies, exceptions, hooks, status_codes, structures, utils from .cookies import RequestsCookieJar diff --git a/stubs/requests/requests/structures.pyi b/stubs/requests/requests/structures.pyi index e29b70cc8d37..c8fcfe538ca3 100644 --- a/stubs/requests/requests/structures.pyi +++ b/stubs/requests/requests/structures.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Generic, Iterable, Iterator, Mapping, MutableMapping, Optional, Tuple, TypeVar, Union +from typing import Any, Dict, Generic, Iterable, Iterator, Mapping, MutableMapping, Tuple, TypeVar _VT = TypeVar("_VT") diff --git a/stubs/requests/requests/utils.pyi b/stubs/requests/requests/utils.pyi index ef3137230a48..4deba4d858dd 100644 --- a/stubs/requests/requests/utils.pyi +++ b/stubs/requests/requests/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Dict, Iterable, Mapping, Optional, Text, Tuple +from typing import Any, AnyStr, Dict, Iterable, Mapping, Text, Tuple from . import compat, cookies, exceptions, structures diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index b69307f00a10..637599514f7e 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -1,6 +1,6 @@ from _typeshed import IdentityFunction from logging import Logger -from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Dict, Sequence, Tuple, Type, TypeVar _R = TypeVar("_R") diff --git a/stubs/simplejson/simplejson/scanner.pyi b/stubs/simplejson/simplejson/scanner.pyi index 4dae33b323d9..fb280813e65b 100644 --- a/stubs/simplejson/simplejson/scanner.pyi +++ b/stubs/simplejson/simplejson/scanner.pyi @@ -1,4 +1,3 @@ -from typing import Optional class JSONDecodeError(ValueError): msg: str = ... diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 24aedeafabd9..b065d9e911c9 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -16,12 +16,12 @@ from typing import ( KeysView, Mapping, NoReturn, - Optional, + Pattern, Tuple, Type, TypeVar, - Union, + ValuesView, overload, ) diff --git a/stubs/tabulate/tabulate.pyi b/stubs/tabulate/tabulate.pyi index d5f48f48d03b..f91b8313b324 100644 --- a/stubs/tabulate/tabulate.pyi +++ b/stubs/tabulate/tabulate.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Container, Dict, Iterable, List, Mapping, NamedTuple, Optional, Sequence, Union +from typing import Any, Callable, Container, Dict, Iterable, List, Mapping, NamedTuple, Sequence, Union LATEX_ESCAPE_RULES: Dict[str, str] MIN_PADDING: int diff --git a/stubs/termcolor/termcolor.pyi b/stubs/termcolor/termcolor.pyi index ca93ece19785..534ae2747d60 100644 --- a/stubs/termcolor/termcolor.pyi +++ b/stubs/termcolor/termcolor.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Optional, Text +from typing import Any, Iterable, Text ATTRIBUTES: dict[str, int] COLORS: dict[str, int] diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index ebfa3b6ed4dd..1991733f4c08 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -1,5 +1,5 @@ import typing -from typing import Any, Iterator, Optional, Union +from typing import Any, Iterator class NodeVisitor: def visit(self, node: AST) -> Any: ... diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 7431a79e613f..0901e5e7b18f 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -1,5 +1,5 @@ import typing -from typing import Any, Iterator, Optional, Union +from typing import Any, Iterator class NodeVisitor: def visit(self, node: AST) -> Any: ... diff --git a/stubs/waitress/waitress/adjustments.pyi b/stubs/waitress/waitress/adjustments.pyi index 7f03a7e0ebeb..d88ad1d8d7f5 100644 --- a/stubs/waitress/waitress/adjustments.pyi +++ b/stubs/waitress/waitress/adjustments.pyi @@ -1,5 +1,5 @@ from socket import socket -from typing import Any, Dict, FrozenSet, Iterable, List, Optional, Sequence, Set, Tuple, Union +from typing import Any, Dict, FrozenSet, Iterable, List, Sequence, Set, Tuple from .compat import HAS_IPV6 as HAS_IPV6, PY2 as PY2, WIN as WIN, string_types as string_types from .proxy_headers import PROXY_HEADERS as PROXY_HEADERS diff --git a/stubs/waitress/waitress/buffers.pyi b/stubs/waitress/waitress/buffers.pyi index 248c8b413cab..128b1cef4b23 100644 --- a/stubs/waitress/waitress/buffers.pyi +++ b/stubs/waitress/waitress/buffers.pyi @@ -1,5 +1,5 @@ from io import BufferedIOBase, BufferedRandom, BytesIO -from typing import Any, Callable, Optional +from typing import Any, Callable COPY_BYTES: int STRBUF_LIMIT: int diff --git a/stubs/waitress/waitress/channel.pyi b/stubs/waitress/waitress/channel.pyi index 86f527fdf360..1e3b84cec185 100644 --- a/stubs/waitress/waitress/channel.pyi +++ b/stubs/waitress/waitress/channel.pyi @@ -1,6 +1,6 @@ from socket import socket from threading import Condition, Lock -from typing import Mapping, Optional, Sequence, Tuple +from typing import Mapping, Sequence, Tuple from waitress.adjustments import Adjustments from waitress.buffers import OverflowableBuffer diff --git a/stubs/waitress/waitress/compat.pyi b/stubs/waitress/waitress/compat.pyi index 49e32e239ea6..94bbb9eb18ea 100644 --- a/stubs/waitress/waitress/compat.pyi +++ b/stubs/waitress/waitress/compat.pyi @@ -1,5 +1,5 @@ from io import TextIOWrapper -from typing import Any, Optional, Tuple +from typing import Any, Tuple PY2: bool PY3: bool diff --git a/stubs/waitress/waitress/parser.pyi b/stubs/waitress/waitress/parser.pyi index 80d123ffcd7b..8b7a09121f66 100644 --- a/stubs/waitress/waitress/parser.pyi +++ b/stubs/waitress/waitress/parser.pyi @@ -1,5 +1,5 @@ from io import BytesIO -from typing import Any, Mapping, Optional, Pattern, Sequence, Tuple, Union +from typing import Any, Mapping, Pattern, Sequence, Tuple from waitress.adjustments import Adjustments from waitress.receiver import ChunkedReceiver, FixedStreamReceiver diff --git a/stubs/waitress/waitress/proxy_headers.pyi b/stubs/waitress/waitress/proxy_headers.pyi index 1a8f554c4d70..b13a2e98b129 100644 --- a/stubs/waitress/waitress/proxy_headers.pyi +++ b/stubs/waitress/waitress/proxy_headers.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import Any, Callable, Mapping, NamedTuple, Optional, Sequence, Set +from typing import Any, Callable, Mapping, NamedTuple, Sequence, Set from .utilities import BadRequest as BadRequest diff --git a/stubs/waitress/waitress/receiver.pyi b/stubs/waitress/waitress/receiver.pyi index e4255d6c6451..d05ea56b7d60 100644 --- a/stubs/waitress/waitress/receiver.pyi +++ b/stubs/waitress/waitress/receiver.pyi @@ -1,5 +1,4 @@ from io import BytesIO -from typing import Optional from waitress.buffers import OverflowableBuffer from waitress.utilities import BadRequest diff --git a/stubs/waitress/waitress/runner.pyi b/stubs/waitress/waitress/runner.pyi index 0b39c957fc6f..ad7e9fd53a2a 100644 --- a/stubs/waitress/waitress/runner.pyi +++ b/stubs/waitress/waitress/runner.pyi @@ -1,5 +1,5 @@ from io import TextIOWrapper -from typing import Any, Callable, Optional, Pattern, Sequence, Tuple +from typing import Any, Callable, Pattern, Sequence, Tuple HELP: str RUNNER_PATTERN: Pattern[Any] diff --git a/stubs/waitress/waitress/server.pyi b/stubs/waitress/waitress/server.pyi index 075a3fa44cc0..269a390757d2 100644 --- a/stubs/waitress/waitress/server.pyi +++ b/stubs/waitress/waitress/server.pyi @@ -1,5 +1,5 @@ from socket import socket -from typing import Any, Optional, Sequence, Tuple, Union +from typing import Any, Sequence, Tuple from waitress.adjustments import Adjustments from waitress.channel import HTTPChannel diff --git a/stubs/waitress/waitress/task.pyi b/stubs/waitress/waitress/task.pyi index 25c7c00b8d9c..c0dea9f5889a 100644 --- a/stubs/waitress/waitress/task.pyi +++ b/stubs/waitress/waitress/task.pyi @@ -1,6 +1,6 @@ from logging import Logger from threading import Condition, Lock -from typing import Any, Deque, Mapping, Optional, Sequence, Tuple +from typing import Any, Deque, Mapping, Sequence, Tuple from .channel import HTTPChannel from .utilities import Error diff --git a/stubs/waitress/waitress/trigger.pyi b/stubs/waitress/waitress/trigger.pyi index d49a346d3733..8196dbbfafbe 100644 --- a/stubs/waitress/waitress/trigger.pyi +++ b/stubs/waitress/waitress/trigger.pyi @@ -1,7 +1,7 @@ import sys from socket import socket from threading import Lock -from typing import Callable, Mapping, Optional +from typing import Callable, Mapping from typing_extensions import Literal from . import wasyncore as wasyncore diff --git a/stubs/waitress/waitress/wasyncore.pyi b/stubs/waitress/waitress/wasyncore.pyi index 1282a4ce7c89..003c17e67a44 100644 --- a/stubs/waitress/waitress/wasyncore.pyi +++ b/stubs/waitress/waitress/wasyncore.pyi @@ -1,7 +1,7 @@ from io import BytesIO from logging import Logger from socket import socket -from typing import Any, Callable, Mapping, Optional, Tuple +from typing import Any, Callable, Mapping, Tuple from . import compat as compat, utilities as utilities From e381bb18570f5b24fa3e9e1084aa683a23ee2b59 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:05:16 +0300 Subject: [PATCH 04/13] run isort --- stdlib/_tracemalloc.pyi | 2 +- stdlib/argparse.pyi | 2 -- stdlib/asyncio/protocols.pyi | 2 +- stdlib/audioop.pyi | 2 +- stdlib/builtins.pyi | 1 - stdlib/codecs.pyi | 2 -- stdlib/concurrent/futures/_base.pyi | 16 +--------------- stdlib/configparser.pyi | 2 -- stdlib/difflib.pyi | 17 +---------------- stdlib/distutils/file_util.pyi | 2 +- stdlib/distutils/version.pyi | 2 +- stdlib/encodings/utf_8.pyi | 2 +- stdlib/fractions.pyi | 2 +- stdlib/functools.pyi | 2 -- stdlib/getpass.pyi | 2 +- stdlib/http/client.pyi | 1 - stdlib/itertools.pyi | 1 - stdlib/mailbox.pyi | 1 - stdlib/multiprocessing/managers.pyi | 17 +---------------- stdlib/os/__init__.pyi | 1 - stdlib/pydoc.pyi | 17 +---------------- stdlib/secrets.pyi | 2 +- stdlib/shelve.pyi | 2 +- stdlib/subprocess.pyi | 17 +---------------- stdlib/tokenize.pyi | 17 +---------------- stdlib/types.pyi | 1 - stdlib/typing_extensions.pyi | 2 -- stdlib/unittest/case.pyi | 2 -- stdlib/urllib/request.pyi | 18 +----------------- stdlib/weakref.pyi | 18 +----------------- stdlib/winsound.pyi | 2 +- stdlib/xml/etree/ElementTree.pyi | 1 - stubs/Werkzeug/werkzeug/datastructures.pyi | 2 -- stubs/Werkzeug/werkzeug/formparser.pyi | 17 +---------------- stubs/Werkzeug/werkzeug/http.pyi | 17 +---------------- stubs/Werkzeug/werkzeug/wrappers.pyi | 17 +---------------- stubs/aiofiles/aiofiles/os.pyi | 2 +- stubs/boto/boto/utils.pyi | 17 +---------------- stubs/click/click/core.pyi | 17 +---------------- .../hazmat/primitives/asymmetric/rsa.pyi | 2 +- stubs/filelock/filelock/__init__.pyi | 2 +- stubs/geoip2/geoip2/errors.pyi | 2 +- .../google/protobuf/internal/containers.pyi | 1 - stubs/python-dateutil/dateutil/_common.pyi | 2 +- .../python-dateutil/dateutil/relativedelta.pyi | 2 +- stubs/redis/redis/client.pyi | 1 - stubs/six/six/__init__.pyi | 2 -- 47 files changed, 30 insertions(+), 251 deletions(-) diff --git a/stdlib/_tracemalloc.pyi b/stdlib/_tracemalloc.pyi index 4a538c5e111a..27637637f6c5 100644 --- a/stdlib/_tracemalloc.pyi +++ b/stdlib/_tracemalloc.pyi @@ -1,6 +1,6 @@ import sys from tracemalloc import _FrameTupleT, _TraceTupleT -from typing import Sequence, Tuple +from typing import Sequence, Tuple def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ... def _get_traces() -> Sequence[_TraceTupleT]: ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 3af265e1e287..ec66de722826 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -8,14 +8,12 @@ from typing import ( Iterable, List, NoReturn, - Pattern, Protocol, Sequence, Tuple, Type, TypeVar, - overload, ) diff --git a/stdlib/asyncio/protocols.pyi b/stdlib/asyncio/protocols.pyi index 675994906778..a7eb940b05da 100644 --- a/stdlib/asyncio/protocols.pyi +++ b/stdlib/asyncio/protocols.pyi @@ -1,6 +1,6 @@ import sys from asyncio import transports -from typing import Tuple +from typing import Tuple class BaseProtocol: def connection_made(self, transport: transports.BaseTransport) -> None: ... diff --git a/stdlib/audioop.pyi b/stdlib/audioop.pyi index e969f60e579d..71671afe487e 100644 --- a/stdlib/audioop.pyi +++ b/stdlib/audioop.pyi @@ -1,4 +1,4 @@ -from typing import Tuple +from typing import Tuple AdpcmState = Tuple[int, int] RatecvState = Tuple[int, Tuple[Tuple[int, int], ...]] diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 8a8f343987ec..46a5144ba9f5 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -42,7 +42,6 @@ from typing import ( MutableSequence, MutableSet, NoReturn, - Protocol, Reversible, Sequence, diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index e96f7f6814b4..dffd6c104f64 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -11,13 +11,11 @@ from typing import ( Iterable, Iterator, List, - Protocol, TextIO, Tuple, Type, TypeVar, - overload, ) from typing_extensions import Literal diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index cd3dd05421e9..e804b82d87cd 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -3,21 +3,7 @@ import threading from _typeshed import Self from abc import abstractmethod from logging import Logger -from typing import ( - Any, - Callable, - Container, - Generic, - Iterable, - Iterator, - List, - - Protocol, - Sequence, - Set, - TypeVar, - overload, -) +from typing import Any, Callable, Container, Generic, Iterable, Iterator, List, Protocol, Sequence, Set, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index ba81f34a1ce9..dfe7ffd1b14f 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -11,13 +11,11 @@ from typing import ( List, Mapping, MutableMapping, - Pattern, Sequence, Tuple, Type, TypeVar, - overload, ) from typing_extensions import Literal diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index c0cb7b907bb4..7a1310160f63 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -1,20 +1,5 @@ import sys -from typing import ( - Any, - AnyStr, - Callable, - Generic, - Iterable, - Iterator, - List, - NamedTuple, - - Sequence, - Tuple, - TypeVar, - Union, - overload, -) +from typing import Any, AnyStr, Callable, Generic, Iterable, Iterator, List, NamedTuple, Sequence, Tuple, TypeVar, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/distutils/file_util.pyi b/stdlib/distutils/file_util.pyi index 9bc2923a6480..cfe840e71040 100644 --- a/stdlib/distutils/file_util.pyi +++ b/stdlib/distutils/file_util.pyi @@ -1,4 +1,4 @@ -from typing import Sequence, Tuple +from typing import Sequence, Tuple def copy_file( src: str, diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 0a6d015847ac..29d72174d8db 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Pattern, Tuple, TypeVar +from typing import Pattern, Tuple, TypeVar _T = TypeVar("_T", bound=Version) diff --git a/stdlib/encodings/utf_8.pyi b/stdlib/encodings/utf_8.pyi index 04979dfdd689..892f2f082af0 100644 --- a/stdlib/encodings/utf_8.pyi +++ b/stdlib/encodings/utf_8.pyi @@ -1,5 +1,5 @@ import codecs -from typing import Tuple +from typing import Tuple class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input: str, final: bool = ...) -> bytes: ... diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index f184fb801516..a5d2e21e9a29 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -1,7 +1,7 @@ import sys from decimal import Decimal from numbers import Integral, Rational, Real -from typing import Tuple, Type, TypeVar, Union, overload +from typing import Tuple, Type, TypeVar, Union, overload from typing_extensions import Literal _ComparableNum = Union[int, float, Decimal, Real] diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index ac9ae629e89a..1ebf4f13c7cf 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -9,14 +9,12 @@ from typing import ( Iterable, Mapping, NamedTuple, - Sequence, Set, Sized, Tuple, Type, TypeVar, - overload, ) diff --git a/stdlib/getpass.pyi b/stdlib/getpass.pyi index 600ebfa7883a..27f4c6a9b635 100644 --- a/stdlib/getpass.pyi +++ b/stdlib/getpass.pyi @@ -1,4 +1,4 @@ -from typing import TextIO +from typing import TextIO def getpass(prompt: str = ..., stream: TextIO | None = ...) -> str: ... def getuser() -> str: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index c883fbc21c81..b6d11bbdef0f 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -15,7 +15,6 @@ from typing import ( Iterator, List, Mapping, - Protocol, Tuple, Type, diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 4bff4c51144d..4ffa181bfd7d 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -6,7 +6,6 @@ from typing import ( Generic, Iterable, Iterator, - SupportsComplex, SupportsFloat, SupportsInt, diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 88c14e468008..543af690c967 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -13,7 +13,6 @@ from typing import ( Iterator, List, Mapping, - Protocol, Sequence, Tuple, diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index cedff2e85911..422a7fd6266d 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -3,22 +3,7 @@ import queue import sys import threading -from typing import ( - Any, - AnyStr, - Callable, - ContextManager, - Dict, - Generic, - Iterable, - List, - Mapping, - - Sequence, - Tuple, - TypeVar, - -) +from typing import Any, AnyStr, Callable, ContextManager, Dict, Generic, Iterable, List, Mapping, Sequence, Tuple, TypeVar from .connection import Connection from .context import BaseContext diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 85b22d4e3616..3d01568ff770 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -29,7 +29,6 @@ from typing import ( Mapping, MutableMapping, NoReturn, - Protocol, Sequence, Set, diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 6d5b3bd565c2..daa8c27e0b1e 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -1,22 +1,7 @@ from _typeshed import SupportsWrite from reprlib import Repr from types import MethodType, ModuleType, TracebackType -from typing import ( - IO, - Any, - AnyStr, - Callable, - Container, - Dict, - List, - Mapping, - MutableMapping, - NoReturn, - Optional, - Tuple, - Type, - -) +from typing import IO, Any, AnyStr, Callable, Container, Dict, List, Mapping, MutableMapping, NoReturn, Optional, Tuple, Type # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ _Exc_Info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] diff --git a/stdlib/secrets.pyi b/stdlib/secrets.pyi index 9a3910ddaddd..6752a30f431e 100644 --- a/stdlib/secrets.pyi +++ b/stdlib/secrets.pyi @@ -1,6 +1,6 @@ from hmac import compare_digest as compare_digest from random import SystemRandom as SystemRandom -from typing import Sequence, TypeVar +from typing import Sequence, TypeVar _T = TypeVar("_T") diff --git a/stdlib/shelve.pyi b/stdlib/shelve.pyi index 06d0b044c423..90b2aafa4f03 100644 --- a/stdlib/shelve.pyi +++ b/stdlib/shelve.pyi @@ -1,7 +1,7 @@ from _typeshed import Self from collections.abc import Iterator, MutableMapping from types import TracebackType -from typing import Type, TypeVar, overload +from typing import Type, TypeVar, overload _T = TypeVar("_T") _VT = TypeVar("_VT") diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 8cb1e7e83eb8..c518ac2e0f89 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -1,22 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from types import TracebackType -from typing import ( - IO, - Any, - AnyStr, - Callable, - Generic, - Iterable, - Mapping, - - Sequence, - Tuple, - Type, - TypeVar, - Union, - overload, -) +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Tuple, Type, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index 72d23b5cc228..e64e64842a17 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -2,22 +2,7 @@ import sys from _typeshed import StrOrBytesPath from builtins import open as _builtin_open from token import * # noqa: F403 -from typing import ( - Any, - Callable, - Dict, - Generator, - Iterable, - List, - NamedTuple, - - Pattern, - Sequence, - Set, - TextIO, - Tuple, - Union, -) +from typing import Any, Callable, Dict, Generator, Iterable, List, NamedTuple, Pattern, Sequence, Set, TextIO, Tuple, Union if sys.version_info < (3, 7): COMMENT: int diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 9bdb65c85c10..e9dbf2e686d1 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -15,7 +15,6 @@ from typing import ( Iterator, KeysView, Mapping, - Tuple, Type, TypeVar, diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index c73e6f8870f5..1ea3545b165d 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -22,12 +22,10 @@ from typing import ( Mapping, NewType as NewType, NoReturn as NoReturn, - Text as Text, Tuple, Type as Type, TypeVar, - ValuesView, _Alias, overload as overload, diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 6b07808fc2aa..37dc44bd4338 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -17,13 +17,11 @@ from typing import ( Mapping, NamedTuple, NoReturn, - Pattern, Sequence, Tuple, Type, TypeVar, - overload, ) from warnings import WarningMessage diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 178244dfcfaa..b40105f67da9 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -4,23 +4,7 @@ from _typeshed import StrOrBytesPath from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar -from typing import ( - IO, - Any, - Callable, - ClassVar, - Dict, - List, - Mapping, - NoReturn, - - Pattern, - Sequence, - Tuple, - TypeVar, - - overload, -) +from typing import IO, Any, Callable, ClassVar, Dict, List, Mapping, NoReturn, Pattern, Sequence, Tuple, TypeVar, overload from urllib.error import HTTPError from urllib.response import addclosehook, addinfourl diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 0d2fd8779fcc..f2458c484dc2 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -1,22 +1,6 @@ import types from _weakrefset import WeakSet as WeakSet -from typing import ( - Any, - Callable, - Dict, - Generic, - Iterable, - Iterator, - List, - Mapping, - MutableMapping, - - Tuple, - Type, - TypeVar, - - overload, -) +from typing import Any, Callable, Dict, Generic, Iterable, Iterator, List, Mapping, MutableMapping, Tuple, Type, TypeVar, overload from _weakref import ( CallableProxyType as CallableProxyType, diff --git a/stdlib/winsound.pyi b/stdlib/winsound.pyi index 3ffd47d64c19..3d79f3b043f2 100644 --- a/stdlib/winsound.pyi +++ b/stdlib/winsound.pyi @@ -1,5 +1,5 @@ import sys -from typing import overload +from typing import overload from typing_extensions import Literal if sys.platform == "win32": diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index aec9a604bcd4..d863e38d3aca 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -12,7 +12,6 @@ from typing import ( KeysView, List, MutableSequence, - Sequence, Tuple, TypeVar, diff --git a/stubs/Werkzeug/werkzeug/datastructures.pyi b/stubs/Werkzeug/werkzeug/datastructures.pyi index 761befb69b33..39231ce89c88 100644 --- a/stubs/Werkzeug/werkzeug/datastructures.pyi +++ b/stubs/Werkzeug/werkzeug/datastructures.pyi @@ -13,12 +13,10 @@ from typing import ( Mapping, MutableSet, NoReturn, - Text, Tuple, Type, TypeVar, - overload, ) diff --git a/stubs/Werkzeug/werkzeug/formparser.pyi b/stubs/Werkzeug/werkzeug/formparser.pyi index 3b0cfc3a2a03..42460805f2ea 100644 --- a/stubs/Werkzeug/werkzeug/formparser.pyi +++ b/stubs/Werkzeug/werkzeug/formparser.pyi @@ -1,20 +1,5 @@ from _typeshed.wsgi import WSGIEnvironment -from typing import ( - IO, - Any, - Callable, - Dict, - Generator, - Iterable, - Mapping, - NoReturn, - Optional, - Protocol, - Text, - Tuple, - TypeVar, - -) +from typing import IO, Any, Callable, Dict, Generator, Iterable, Mapping, NoReturn, Optional, Protocol, Text, Tuple, TypeVar from .datastructures import Headers diff --git a/stubs/Werkzeug/werkzeug/http.pyi b/stubs/Werkzeug/werkzeug/http.pyi index e3d8ac45a431..13b4244a5ebb 100644 --- a/stubs/Werkzeug/werkzeug/http.pyi +++ b/stubs/Werkzeug/werkzeug/http.pyi @@ -1,22 +1,7 @@ import sys from _typeshed.wsgi import WSGIEnvironment from datetime import datetime, timedelta -from typing import ( - Any, - Callable, - Dict, - Iterable, - List, - Mapping, - - SupportsInt, - Text, - Tuple, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, Dict, Iterable, List, Mapping, SupportsInt, Text, Tuple, Type, TypeVar, Union, overload from .datastructures import ( Accept, diff --git a/stubs/Werkzeug/werkzeug/wrappers.pyi b/stubs/Werkzeug/werkzeug/wrappers.pyi index d154fd22d992..ef11750febb2 100644 --- a/stubs/Werkzeug/werkzeug/wrappers.pyi +++ b/stubs/Werkzeug/werkzeug/wrappers.pyi @@ -1,21 +1,6 @@ from _typeshed.wsgi import InputStream, WSGIEnvironment from datetime import datetime, timedelta -from typing import ( - Any, - Callable, - Iterable, - Iterator, - Mapping, - MutableMapping, - - Sequence, - Text, - Tuple, - Type, - TypeVar, - - overload, -) +from typing import Any, Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence, Text, Tuple, Type, TypeVar, overload from typing_extensions import Literal from .datastructures import ( diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index f2456b144e3e..b48884c4430e 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from os import stat_result -from typing import Sequence, Union, overload +from typing import Sequence, Union, overload _FdOrAnyPath = Union[int, StrOrBytesPath] diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 1a5ca0dc234c..338b409fffad 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -3,22 +3,7 @@ import logging.handlers import subprocess import sys import time -from typing import ( - IO, - Any, - Callable, - ContextManager, - Dict, - Iterable, - List, - Mapping, - - Sequence, - Tuple, - Type, - TypeVar, - -) +from typing import IO, Any, Callable, ContextManager, Dict, Iterable, List, Mapping, Sequence, Tuple, Type, TypeVar import boto.connection diff --git a/stubs/click/click/core.pyi b/stubs/click/click/core.pyi index d15dadbee17b..8a3723332b64 100644 --- a/stubs/click/click/core.pyi +++ b/stubs/click/click/core.pyi @@ -1,19 +1,4 @@ -from typing import ( - Any, - Callable, - ContextManager, - Dict, - Iterable, - List, - Mapping, - NoReturn, - - Sequence, - Set, - Tuple, - TypeVar, - Union, -) +from typing import Any, Callable, ContextManager, Dict, Iterable, List, Mapping, NoReturn, Sequence, Set, Tuple, TypeVar, Union from click.formatting import HelpFormatter from click.parser import OptionParser diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi index 100cf6e22ebe..3b5f0ca0caad 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi @@ -1,5 +1,5 @@ from abc import ABCMeta, abstractmethod -from typing import Tuple +from typing import Tuple from cryptography.hazmat.backends.interfaces import RSABackend from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext diff --git a/stubs/filelock/filelock/__init__.pyi b/stubs/filelock/filelock/__init__.pyi index 90e6c1c5df1d..6b65fa78e039 100644 --- a/stubs/filelock/filelock/__init__.pyi +++ b/stubs/filelock/filelock/__init__.pyi @@ -1,7 +1,7 @@ import sys from logging import Logger from types import TracebackType -from typing import Type +from typing import Type def logger() -> Logger: ... diff --git a/stubs/geoip2/geoip2/errors.pyi b/stubs/geoip2/geoip2/errors.pyi index 1bba2d31beea..aa6a929c30c8 100644 --- a/stubs/geoip2/geoip2/errors.pyi +++ b/stubs/geoip2/geoip2/errors.pyi @@ -1,4 +1,4 @@ -from typing import Text +from typing import Text class GeoIP2Error(RuntimeError): ... class AddressNotFoundError(GeoIP2Error): ... diff --git a/stubs/protobuf/google/protobuf/internal/containers.pyi b/stubs/protobuf/google/protobuf/internal/containers.pyi index 8da0df3a1c6f..6e3034258237 100644 --- a/stubs/protobuf/google/protobuf/internal/containers.pyi +++ b/stubs/protobuf/google/protobuf/internal/containers.pyi @@ -6,7 +6,6 @@ from typing import ( List, Mapping as Mapping, MutableMapping as MutableMapping, - Sequence, Text, TypeVar, diff --git a/stubs/python-dateutil/dateutil/_common.pyi b/stubs/python-dateutil/dateutil/_common.pyi index dd3d52d40fc2..a437f85035a3 100644 --- a/stubs/python-dateutil/dateutil/_common.pyi +++ b/stubs/python-dateutil/dateutil/_common.pyi @@ -1,4 +1,4 @@ -from typing import TypeVar +from typing import TypeVar _T = TypeVar("_T") diff --git a/stubs/python-dateutil/dateutil/relativedelta.pyi b/stubs/python-dateutil/dateutil/relativedelta.pyi index 61f743fb8db4..ec2adea537fa 100644 --- a/stubs/python-dateutil/dateutil/relativedelta.pyi +++ b/stubs/python-dateutil/dateutil/relativedelta.pyi @@ -1,5 +1,5 @@ from datetime import date, datetime, timedelta -from typing import SupportsFloat, TypeVar, overload +from typing import SupportsFloat, TypeVar, overload from ._common import weekday diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index f792efc5c650..5303c93c5598 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -8,7 +8,6 @@ from typing import ( Iterator, List, Mapping, - Sequence, Set, Text, diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index b065d9e911c9..bf22203db5d6 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -16,12 +16,10 @@ from typing import ( KeysView, Mapping, NoReturn, - Pattern, Tuple, Type, TypeVar, - ValuesView, overload, ) From 223939b9140b3c58cafb9cac72a970db137628c1 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:09:27 +0300 Subject: [PATCH 05/13] manual fix, import cleaner was a bit too lol --- stdlib/subprocess.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index c518ac2e0f89..ed8dce29363d 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -40,7 +40,7 @@ class CompletedProcess(Generic[_T]): # morally: _CMD args: Any returncode: int - # These are really both but requiring checks would be tedious + # These can both be None, but requiring checks for None would be tedious # and writing all the overloads would be horrific. stdout: _T stderr: _T From 75e2cdcc8fb392891c162db8eeb133128138fbb6 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:17:38 +0300 Subject: [PATCH 06/13] black --- stdlib/distutils/archive_util.pyi | 1 - stdlib/distutils/debug.pyi | 1 - stdlib/ensurepip/__init__.pyi | 1 - stdlib/macurl2path.pyi | 1 - stdlib/venv/__init__.pyi | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/stdlib/distutils/archive_util.pyi b/stdlib/distutils/archive_util.pyi index 3960a488dd46..38458fc0e003 100644 --- a/stdlib/distutils/archive_util.pyi +++ b/stdlib/distutils/archive_util.pyi @@ -1,4 +1,3 @@ - def make_archive( base_name: str, format: str, diff --git a/stdlib/distutils/debug.pyi b/stdlib/distutils/debug.pyi index f84bd9d75952..11f28a8bc8ae 100644 --- a/stdlib/distutils/debug.pyi +++ b/stdlib/distutils/debug.pyi @@ -1,2 +1 @@ - DEBUG: bool | None diff --git a/stdlib/ensurepip/__init__.pyi b/stdlib/ensurepip/__init__.pyi index 70b27edc6dd8..749fedc04424 100644 --- a/stdlib/ensurepip/__init__.pyi +++ b/stdlib/ensurepip/__init__.pyi @@ -1,4 +1,3 @@ - def version() -> str: ... def bootstrap( *, diff --git a/stdlib/macurl2path.pyi b/stdlib/macurl2path.pyi index a6c7a5135985..6aac6dfeace5 100644 --- a/stdlib/macurl2path.pyi +++ b/stdlib/macurl2path.pyi @@ -1,4 +1,3 @@ - def url2pathname(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ... def _pncomp2url(component: str | bytes) -> str: ... diff --git a/stdlib/venv/__init__.pyi b/stdlib/venv/__init__.pyi index a3b9a79bfc52..25cf615a3243 100644 --- a/stdlib/venv/__init__.pyi +++ b/stdlib/venv/__init__.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from types import SimpleNamespace -from typing import Sequence +from typing import Sequence class EnvBuilder: system_site_packages: bool From 8eec61cce9f64cfc81e56e4565990138836dde32 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:19:55 +0300 Subject: [PATCH 07/13] revert files that need manual fixing --- stdlib/types.pyi | 55 ++++++++++++----------- stubs/typed-ast/typed_ast/ast3.pyi | 72 +++++++++++++++--------------- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/stdlib/types.pyi b/stdlib/types.pyi index e9dbf2e686d1..f55abd2209e9 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -15,6 +15,7 @@ from typing import ( Iterator, KeysView, Mapping, + Optional, Tuple, Type, TypeVar, @@ -173,31 +174,31 @@ class ModuleType: __name__: str __file__: str __dict__: Dict[str, Any] - __loader__: _LoaderProtocol | None - __package__: str | None - __spec__: ModuleSpec | None - def __init__(self, name: str, doc: str | None = ...) -> None: ... + __loader__: Optional[_LoaderProtocol] + __package__: Optional[str] + __spec__: Optional[ModuleSpec] + def __init__(self, name: str, doc: Optional[str] = ...) -> None: ... @final class GeneratorType(Generator[_T_co, _T_contra, _V_co]): gi_code: CodeType gi_frame: FrameType gi_running: bool - gi_yieldfrom: GeneratorType[_T_co, _T_contra, Any] | None + gi_yieldfrom: Optional[GeneratorType[_T_co, _T_contra, Any]] def __iter__(self) -> GeneratorType[_T_co, _T_contra, _V_co]: ... def __next__(self) -> _T_co: ... def close(self) -> None: ... def send(self, __arg: _T_contra) -> _T_co: ... @overload def throw( - self, __typ: Type[BaseException], __val: typing.BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: Type[BaseException], __val: typing.Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... ) -> _T_co: ... @overload - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... + def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ... @final class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): - ag_await: Awaitable[Any] | None + ag_await: Optional[Awaitable[Any]] ag_frame: FrameType ag_running: bool ag_code: CodeType @@ -206,15 +207,15 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): def asend(self, __val: _T_contra) -> Awaitable[_T_co]: ... @overload def athrow( - self, __typ: Type[BaseException], __val: typing.BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: Type[BaseException], __val: typing.Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... ) -> Awaitable[_T_co]: ... @overload - def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ... + def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ... def aclose(self) -> Awaitable[None]: ... @final class CoroutineType: - cr_await: Any | None + cr_await: Optional[Any] cr_code: CodeType cr_frame: FrameType cr_running: bool @@ -222,10 +223,10 @@ class CoroutineType: def send(self, __arg: Any) -> Any: ... @overload def throw( - self, __typ: Type[BaseException], __val: typing.BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: Type[BaseException], __val: typing.Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... ) -> Any: ... @overload - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Any: ... + def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Any: ... class _StaticFunctionType: """Fictional type to correct the type of MethodType.__func__. @@ -241,12 +242,12 @@ class _StaticFunctionType: being bound as a method. """ - def __get__(self, obj: object | None, type: type | None) -> FunctionType: ... + def __get__(self, obj: Optional[object], type: Optional[type]) -> FunctionType: ... @final class MethodType: - __closure__: Tuple[_Cell, ...] | None # inherited from the added function - __defaults__: Tuple[Any, ...] | None # inherited from the added function + __closure__: Optional[Tuple[_Cell, ...]] # inherited from the added function + __defaults__: Optional[Tuple[Any, ...]] # inherited from the added function __func__: _StaticFunctionType __self__: object __name__: str # inherited from the added function @@ -256,7 +257,7 @@ class MethodType: @final class BuiltinFunctionType: - __self__: typing.object | ModuleType + __self__: typing.Union[object, ModuleType] __name__: str __qualname__: str def __call__(self, *args: Any, **kwargs: Any) -> Any: ... @@ -298,11 +299,11 @@ if sys.version_info >= (3, 7): @final class TracebackType: if sys.version_info >= (3, 7): - def __init__(self, tb_next: TracebackType | None, tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ... - tb_next: TracebackType | None + def __init__(self, tb_next: Optional[TracebackType], tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ... + tb_next: Optional[TracebackType] else: @property - def tb_next(self) -> TracebackType | None: ... + def tb_next(self) -> Optional[TracebackType]: ... # the rest are read-only even in 3.7 @property def tb_frame(self) -> FrameType: ... @@ -313,14 +314,14 @@ class TracebackType: @final class FrameType: - f_back: FrameType | None + f_back: Optional[FrameType] f_builtins: Dict[str, Any] f_code: CodeType f_globals: Dict[str, Any] f_lasti: int f_lineno: int f_locals: Dict[str, Any] - f_trace: Callable[[FrameType, str, Any], Any] | None + f_trace: Optional[Callable[[FrameType, str, Any], Any]] if sys.version_info >= (3, 7): f_trace_lines: bool f_trace_opcodes: bool @@ -346,8 +347,8 @@ if sys.version_info >= (3, 7): def new_class( name: str, bases: Iterable[object] = ..., - kwds: Dict[str, Any] | None = ..., - exec_body: Callable[[Dict[str, Any]], None] | None = ..., + kwds: Optional[Dict[str, Any]] = ..., + exec_body: Optional[Callable[[Dict[str, Any]], None]] = ..., ) -> type: ... def resolve_bases(bases: Iterable[object]) -> Tuple[Any, ...]: ... @@ -355,12 +356,12 @@ else: def new_class( name: str, bases: Tuple[type, ...] = ..., - kwds: Dict[str, Any] | None = ..., - exec_body: Callable[[Dict[str, Any]], None] | None = ..., + kwds: Optional[Dict[str, Any]] = ..., + exec_body: Optional[Callable[[Dict[str, Any]], None]] = ..., ) -> type: ... def prepare_class( - name: str, bases: Tuple[type, ...] = ..., kwds: Dict[str, Any] | None = ... + name: str, bases: Tuple[type, ...] = ..., kwds: Optional[Dict[str, Any]] = ... ) -> Tuple[type, Dict[str, Any], Dict[str, Any]]: ... # Actually a different type, but `property` is special and we want that too. diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 0901e5e7b18f..3dac9b2e1fd4 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -1,5 +1,5 @@ import typing -from typing import Any, Iterator +from typing import Any, Iterator, Optional, Union class NodeVisitor: def visit(self, node: AST) -> Any: ... @@ -8,15 +8,15 @@ class NodeVisitor: class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> None: ... -def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ..., feature_version: int = ...) -> AST: ... +def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ..., feature_version: int = ...) -> AST: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: AST) -> AST: ... -def get_docstring(node: AST, clean: bool = ...) -> str | None: ... +def get_docstring(node: AST, clean: bool = ...) -> Optional[str]: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: str | AST) -> Any: ... +def literal_eval(node_or_string: Union[str, AST]) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... PyCF_ONLY_AST: int @@ -58,16 +58,16 @@ class FunctionDef(stmt): args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - returns: expr | None - type_comment: str | None + returns: Optional[expr] + type_comment: Optional[str] class AsyncFunctionDef(stmt): name: identifier args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - returns: expr | None - type_comment: str | None + returns: Optional[expr] + type_comment: Optional[str] class ClassDef(stmt): name: identifier @@ -77,7 +77,7 @@ class ClassDef(stmt): decorator_list: typing.List[expr] class Return(stmt): - value: expr | None + value: Optional[expr] class Delete(stmt): targets: typing.List[expr] @@ -85,7 +85,7 @@ class Delete(stmt): class Assign(stmt): targets: typing.List[expr] value: expr - type_comment: str | None + type_comment: Optional[str] class AugAssign(stmt): target: expr @@ -95,7 +95,7 @@ class AugAssign(stmt): class AnnAssign(stmt): target: expr annotation: expr - value: expr | None + value: Optional[expr] simple: int class For(stmt): @@ -103,14 +103,14 @@ class For(stmt): iter: expr body: typing.List[stmt] orelse: typing.List[stmt] - type_comment: str | None + type_comment: Optional[str] class AsyncFor(stmt): target: expr iter: expr body: typing.List[stmt] orelse: typing.List[stmt] - type_comment: str | None + type_comment: Optional[str] class While(stmt): test: expr @@ -125,16 +125,16 @@ class If(stmt): class With(stmt): items: typing.List[withitem] body: typing.List[stmt] - type_comment: str | None + type_comment: Optional[str] class AsyncWith(stmt): items: typing.List[withitem] body: typing.List[stmt] - type_comment: str | None + type_comment: Optional[str] class Raise(stmt): - exc: expr | None - cause: expr | None + exc: Optional[expr] + cause: Optional[expr] class Try(stmt): body: typing.List[stmt] @@ -144,15 +144,15 @@ class Try(stmt): class Assert(stmt): test: expr - msg: expr | None + msg: Optional[expr] class Import(stmt): names: typing.List[alias] class ImportFrom(stmt): - module: identifier | None + module: Optional[identifier] names: typing.List[alias] - level: int | None + level: Optional[int] class Global(stmt): names: typing.List[identifier] @@ -171,9 +171,9 @@ class slice(AST): ... _slice = slice # this lets us type the variable named 'slice' below class Slice(slice): - lower: expr | None - upper: expr | None - step: expr | None + lower: Optional[expr] + upper: Optional[expr] + step: Optional[expr] class ExtSlice(slice): dims: typing.List[slice] @@ -235,7 +235,7 @@ class Await(expr): value: expr class Yield(expr): - value: expr | None + value: Optional[expr] class YieldFrom(expr): value: expr @@ -251,7 +251,7 @@ class Call(expr): keywords: typing.List[keyword] class Num(expr): - n: float | int | complex + n: Union[float, int, complex] class Str(expr): s: str @@ -259,8 +259,8 @@ class Str(expr): class FormattedValue(expr): value: expr - conversion: typing.int | None - format_spec: typing.expr | None + conversion: typing.Optional[int] + format_spec: typing.Optional[expr] class JoinedStr(expr): values: typing.List[expr] @@ -347,38 +347,38 @@ class comprehension(AST): is_async: int class ExceptHandler(AST): - type: expr | None - name: identifier | None + type: Optional[expr] + name: Optional[identifier] body: typing.List[stmt] lineno: int col_offset: int class arguments(AST): args: typing.List[arg] - vararg: arg | None + vararg: Optional[arg] kwonlyargs: typing.List[arg] kw_defaults: typing.List[expr] - kwarg: arg | None + kwarg: Optional[arg] defaults: typing.List[expr] class arg(AST): arg: identifier - annotation: expr | None + annotation: Optional[expr] lineno: int col_offset: int - type_comment: typing.str | None + type_comment: typing.Optional[str] class keyword(AST): - arg: identifier | None + arg: Optional[identifier] value: expr class alias(AST): name: identifier - asname: identifier | None + asname: Optional[identifier] class withitem(AST): context_expr: expr - optional_vars: expr | None + optional_vars: Optional[expr] class TypeIgnore(AST): lineno: int From 81ba00388ded998d4df27ef4f552b44cc965a60c Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:24:08 +0300 Subject: [PATCH 08/13] revert more files --- stdlib/configparser.pyi | 88 ++++++++------- stdlib/ctypes/__init__.pyi | 37 ++++--- stdlib/email/_header_value_parser.pyi | 22 ++-- stdlib/os/__init__.pyi | 147 ++++++++++++++------------ stdlib/pickle.pyi | 37 +++++-- 5 files changed, 183 insertions(+), 148 deletions(-) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index fe2eae712792..165b173e55dd 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -11,11 +11,13 @@ from typing import ( List, Mapping, MutableMapping, + Optional, Pattern, Sequence, Tuple, Type, TypeVar, + Union, overload, ) from typing_extensions import Literal @@ -62,33 +64,33 @@ class RawConfigParser(_parser): @overload def __init__( self, - defaults: Mapping[str, str | None] | None = ..., + defaults: Optional[Mapping[str, Optional[str]]] = ..., dict_type: Type[Mapping[str, str]] = ..., allow_no_value: Literal[True] = ..., *, delimiters: Sequence[str] = ..., comment_prefixes: Sequence[str] = ..., - inline_comment_prefixes: Sequence[str] | None = ..., + inline_comment_prefixes: Optional[Sequence[str]] = ..., strict: bool = ..., empty_lines_in_values: bool = ..., default_section: str = ..., - interpolation: Interpolation | None = ..., + interpolation: Optional[Interpolation] = ..., converters: _converters = ..., ) -> None: ... @overload def __init__( self, - defaults: _section | None = ..., + defaults: Optional[_section] = ..., dict_type: Type[Mapping[str, str]] = ..., allow_no_value: bool = ..., *, delimiters: Sequence[str] = ..., comment_prefixes: Sequence[str] = ..., - inline_comment_prefixes: Sequence[str] | None = ..., + inline_comment_prefixes: Optional[Sequence[str]] = ..., strict: bool = ..., empty_lines_in_values: bool = ..., default_section: str = ..., - interpolation: Interpolation | None = ..., + interpolation: Optional[Interpolation] = ..., converters: _converters = ..., ) -> None: ... def __len__(self) -> int: ... @@ -102,31 +104,31 @@ class RawConfigParser(_parser): def has_section(self, section: str) -> bool: ... def options(self, section: str) -> List[str]: ... def has_option(self, section: str, option: str) -> bool: ... - def read(self, filenames: _Path | Iterable[_Path], encoding: str | None = ...) -> List[str]: ... - def read_file(self, f: Iterable[str], source: str | None = ...) -> None: ... + def read(self, filenames: Union[_Path, Iterable[_Path]], encoding: Optional[str] = ...) -> List[str]: ... + def read_file(self, f: Iterable[str], source: Optional[str] = ...) -> None: ... def read_string(self, string: str, source: str = ...) -> None: ... def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = ...) -> None: ... - def readfp(self, fp: Iterable[str], filename: str | None = ...) -> None: ... + def readfp(self, fp: Iterable[str], filename: Optional[str] = ...) -> None: ... # These get* methods are partially applied (with the same names) in # SectionProxy; the stubs should be kept updated together @overload - def getint(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> int: ... + def getint(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> int: ... @overload def getint( - self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ... - ) -> int | _T: ... + self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... + ) -> Union[int, _T]: ... @overload - def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ... + def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> float: ... @overload def getfloat( - self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ... - ) -> float | _T: ... + self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... + ) -> Union[float, _T]: ... @overload - def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ... + def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> bool: ... @overload def getboolean( - self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ... - ) -> bool | _T: ... + self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... + ) -> Union[bool, _T]: ... def _get_conv( self, section: str, @@ -134,19 +136,21 @@ class RawConfigParser(_parser): conv: Callable[[str], _T], *, raw: bool = ..., - vars: _section | None = ..., + vars: Optional[_section] = ..., fallback: _T = ..., ) -> _T: ... # This is incompatible with MutableMapping so we ignore the type @overload # type: ignore - def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> str: ... + def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> str: ... @overload - def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T) -> str | _T: ... + def get( + self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T + ) -> Union[str, _T]: ... @overload - def items(self, *, raw: bool = ..., vars: _section | None = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... + def items(self, *, raw: bool = ..., vars: Optional[_section] = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... @overload - def items(self, section: str, raw: bool = ..., vars: _section | None = ...) -> List[Tuple[str, str]]: ... - def set(self, section: str, option: str, value: str | None = ...) -> None: ... + def items(self, section: str, raw: bool = ..., vars: Optional[_section] = ...) -> List[Tuple[str, str]]: ... + def set(self, section: str, option: str, value: Optional[str] = ...) -> None: ... def write(self, fp: SupportsWrite[str], space_around_delimiters: bool = ...) -> None: ... def remove_option(self, section: str, option: str) -> bool: ... def remove_section(self, section: str) -> bool: ... @@ -167,29 +171,33 @@ class SectionProxy(MutableMapping[str, str]): def parser(self) -> RawConfigParser: ... @property def name(self) -> str: ... - def get(self, option: str, fallback: str | None = ..., *, raw: bool = ..., vars: _section | None = ..., _impl: Any | None = ..., **kwargs: Any) -> str: ... # type: ignore + def get(self, option: str, fallback: Optional[str] = ..., *, raw: bool = ..., vars: Optional[_section] = ..., _impl: Optional[Any] = ..., **kwargs: Any) -> str: ... # type: ignore # These are partially-applied version of the methods with the same names in # RawConfigParser; the stubs should be kept updated together @overload - def getint(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> int: ... + def getint(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> int: ... @overload - def getint(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> int | _T: ... + def getint(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ...) -> Union[int, _T]: ... @overload - def getfloat(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ... + def getfloat(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> float: ... @overload - def getfloat(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> float | _T: ... + def getfloat( + self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ... + ) -> Union[float, _T]: ... @overload - def getboolean(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ... + def getboolean(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> bool: ... @overload - def getboolean(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> bool | _T: ... + def getboolean( + self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ... + ) -> Union[bool, _T]: ... # SectionProxy can have arbitrary attributes when custom converters are used def __getattr__(self, key: str) -> Callable[..., Any]: ... -class ConverterMapping(MutableMapping[str, _converter | None]): +class ConverterMapping(MutableMapping[str, Optional[_converter]]): GETTERCRE: Pattern[Any] def __init__(self, parser: RawConfigParser) -> None: ... def __getitem__(self, key: str) -> _converter: ... - def __setitem__(self, key: str, value: _converter | None) -> None: ... + def __setitem__(self, key: str, value: Optional[_converter]) -> None: ... def __delitem__(self, key: str) -> None: ... def __iter__(self) -> Iterator[str]: ... def __len__(self) -> int: ... @@ -204,16 +212,16 @@ class NoSectionError(Error): class DuplicateSectionError(Error): section: str - source: str | None - lineno: int | None - def __init__(self, section: str, source: str | None = ..., lineno: int | None = ...) -> None: ... + source: Optional[str] + lineno: Optional[int] + def __init__(self, section: str, source: Optional[str] = ..., lineno: Optional[int] = ...) -> None: ... class DuplicateOptionError(Error): section: str option: str - source: str | None - lineno: int | None - def __init__(self, section: str, option: str, source: str | None = ..., lineno: int | None = ...) -> None: ... + source: Optional[str] + lineno: Optional[int] + def __init__(self, section: str, option: str, source: Optional[str] = ..., lineno: Optional[int] = ...) -> None: ... class NoOptionError(Error): section: str @@ -237,7 +245,7 @@ class InterpolationSyntaxError(InterpolationError): ... class ParsingError(Error): source: str errors: List[Tuple[int, str]] - def __init__(self, source: str | None = ..., filename: str | None = ...) -> None: ... + def __init__(self, source: Optional[str] = ..., filename: Optional[str] = ...) -> None: ... def append(self, lineno: int, line: str) -> None: ... class MissingSectionHeaderError(ParsingError): diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index d7ea65f09189..131bb4d7e1c0 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -38,16 +38,21 @@ class CDLL(object): if sys.version_info >= (3, 8): def __init__( self, - name: str | None, + name: Optional[str], mode: int = ..., - handle: int | None = ..., + handle: Optional[int] = ..., use_errno: bool = ..., use_last_error: bool = ..., - winmode: int | None = ..., + winmode: Optional[int] = ..., ) -> None: ... else: def __init__( - self, name: str | None, mode: int = ..., handle: int | None = ..., use_errno: bool = ..., use_last_error: bool = ... + self, + name: Optional[str], + mode: int = ..., + handle: Optional[int] = ..., + use_errno: bool = ..., + use_last_error: bool = ..., ) -> None: ... def __getattr__(self, name: str) -> _NamedFuncPointer: ... def __getitem__(self, name: str) -> _NamedFuncPointer: ... @@ -90,7 +95,7 @@ class _CDataMeta(type): class _CData(metaclass=_CDataMeta): _b_base: int = ... _b_needsfree_: bool = ... - _objects: Mapping[Any, int] | None = ... + _objects: Optional[Mapping[Any, int]] = ... @classmethod def from_buffer(cls: Type[_CT], source: _WritableBuffer, offset: int = ...) -> _CT: ... @classmethod @@ -128,15 +133,15 @@ class _NamedFuncPointer(_FuncPointer): class ArgumentError(Exception): ... def CFUNCTYPE( - restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... + restype: Optional[Type[_CData]], *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... ) -> Type[_FuncPointer]: ... if sys.platform == "win32": def WINFUNCTYPE( - restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... + restype: Optional[Type[_CData]], *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... ) -> Type[_FuncPointer]: ... -def PYFUNCTYPE(restype: Type[_CData] | None, *argtypes: Type[_CData]) -> Type[_FuncPointer]: ... +def PYFUNCTYPE(restype: Optional[Type[_CData]], *argtypes: Type[_CData]) -> Type[_FuncPointer]: ... class _CArgObject: ... @@ -156,11 +161,11 @@ def byref(obj: _CData, offset: int = ...) -> _CArgObject: ... _CastT = TypeVar("_CastT", bound=_CanCastTo) def cast(obj: _UnionT[_CData, _CArgObject, int], typ: Type[_CastT]) -> _CastT: ... -def create_string_buffer(init: _UnionT[int, bytes], size: int | None = ...) -> Array[c_char]: ... +def create_string_buffer(init: _UnionT[int, bytes], size: Optional[int] = ...) -> Array[c_char]: ... c_buffer = create_string_buffer -def create_unicode_buffer(init: _UnionT[int, str], size: int | None = ...) -> Array[c_wchar]: ... +def create_unicode_buffer(init: _UnionT[int, str], size: Optional[int] = ...) -> Array[c_wchar]: ... if sys.platform == "win32": def DllCanUnloadNow() -> int: ... @@ -203,7 +208,7 @@ def sizeof(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ... def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ... if sys.platform == "win32": - def WinError(code: int | None = ..., descr: str | None = ...) -> OSError: ... + def WinError(code: Optional[int] = ..., descr: Optional[str] = ...) -> OSError: ... def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ... @@ -216,8 +221,8 @@ class c_byte(_SimpleCData[int]): ... class c_char(_SimpleCData[bytes]): def __init__(self, value: _UnionT[int, bytes] = ...) -> None: ... -class c_char_p(_PointerLike, _SimpleCData[bytes | None]): - def __init__(self, value: _UnionT[int, bytes] | None = ...) -> None: ... +class c_char_p(_PointerLike, _SimpleCData[Optional[bytes]]): + def __init__(self, value: Optional[_UnionT[int, bytes]] = ...) -> None: ... class c_double(_SimpleCData[float]): ... class c_longdouble(_SimpleCData[float]): ... @@ -241,11 +246,11 @@ class c_uint64(_SimpleCData[int]): ... class c_ulong(_SimpleCData[int]): ... class c_ulonglong(_SimpleCData[int]): ... class c_ushort(_SimpleCData[int]): ... -class c_void_p(_PointerLike, _SimpleCData[int | None]): ... +class c_void_p(_PointerLike, _SimpleCData[Optional[int]]): ... class c_wchar(_SimpleCData[str]): ... -class c_wchar_p(_PointerLike, _SimpleCData[str | None]): - def __init__(self, value: _UnionT[int, str] | None = ...) -> None: ... +class c_wchar_p(_PointerLike, _SimpleCData[Optional[str]]): + def __init__(self, value: Optional[_UnionT[int, str]] = ...) -> None: ... class c_bool(_SimpleCData[bool]): def __init__(self, value: bool = ...) -> None: ... diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index d59f3dbeaec8..22a2a643ed1b 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -1,7 +1,7 @@ import sys from email.errors import HeaderParseError, MessageDefect from email.policy import Policy -from typing import Any, Iterable, Iterator, List, Pattern, Set, Tuple, Type, TypeVar +from typing import Any, Iterable, Iterator, List, Optional, Pattern, Set, Tuple, Type, TypeVar, Union from typing_extensions import Final _T = TypeVar("_T") @@ -23,8 +23,8 @@ def quote_string(value: Any) -> str: ... if sys.version_info >= (3, 7): rfc2047_matcher: Pattern[str] -class TokenList(List[TokenList | Terminal]): - token_type: str | None = ... +class TokenList(List[Union[TokenList, Terminal]]): + token_type: Optional[str] = ... syntactic_break: bool = ... ew_combine_allowed: bool = ... defects: List[MessageDefect] = ... @@ -69,9 +69,9 @@ class Token(TokenList): class EncodedWord(TokenList): token_type: str = ... - cte: str | None = ... - charset: str | None = ... - lang: str | None = ... + cte: Optional[str] = ... + charset: Optional[str] = ... + lang: Optional[str] = ... class QuotedString(TokenList): token_type: str = ... @@ -145,7 +145,7 @@ class NameAddr(TokenList): @property def domain(self) -> str: ... @property - def route(self) -> List[Domain] | None: ... + def route(self) -> Optional[List[Domain]]: ... @property def addr_spec(self) -> str: ... @@ -156,7 +156,7 @@ class AngleAddr(TokenList): @property def domain(self) -> str: ... @property - def route(self) -> List[Domain] | None: ... + def route(self) -> Optional[List[Domain]]: ... @property def addr_spec(self) -> str: ... @@ -247,8 +247,8 @@ class DomainLiteral(TokenList): class MIMEVersion(TokenList): token_type: str = ... - major: int | None = ... - minor: int | None = ... + major: Optional[int] = ... + minor: Optional[int] = ... class Parameter(TokenList): token_type: str = ... @@ -270,7 +270,7 @@ class Attribute(TokenList): class Section(TokenList): token_type: str = ... - number: int | None = ... + number: Optional[int] = ... class Value(TokenList): token_type: str = ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 3d01568ff770..71700daff545 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -29,6 +29,7 @@ from typing import ( Mapping, MutableMapping, NoReturn, + Optional, Protocol, Sequence, Set, @@ -170,7 +171,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: str | None + altsep: Optional[str] extsep: str pathsep: str defpath: str @@ -336,7 +337,7 @@ if sys.platform != "win32": if sys.version_info >= (3, 7): # f_fsid was added in https://github.com/python/cpython/pull/4571 class statvfs_result(_Tuple10Int): # Unix only - def __new__(cls, seq: _Tuple10Int | _Tuple11Int, dict: Dict[str, int] = ...) -> statvfs_result: ... + def __new__(cls, seq: Union[_Tuple10Int, _Tuple11Int], dict: Dict[str, int] = ...) -> statvfs_result: ... n_fields: int n_sequence_fields: int n_unnamed_fields: int @@ -378,7 +379,7 @@ def fspath(path: str) -> str: ... def fspath(path: bytes) -> bytes: ... @overload def fspath(path: PathLike[AnyStr]) -> AnyStr: ... -def get_exec_path(env: Mapping[str, str] | None = ...) -> List[str]: ... +def get_exec_path(env: Optional[Mapping[str, str]] = ...) -> List[str]: ... # NOTE: get_exec_path(): returns List[bytes] when env not None def getlogin() -> str: ... @@ -422,20 +423,20 @@ if sys.platform != "win32": def uname() -> uname_result: ... @overload -def getenv(key: str) -> str | None: ... +def getenv(key: str) -> Optional[str]: ... @overload -def getenv(key: str, default: _T) -> str | _T: ... +def getenv(key: str, default: _T) -> Union[str, _T]: ... if sys.platform != "win32": @overload - def getenvb(key: bytes) -> bytes | None: ... + def getenvb(key: bytes) -> Optional[bytes]: ... @overload - def getenvb(key: bytes, default: _T) -> bytes | _T: ... + def getenvb(key: bytes, default: _T) -> Union[bytes, _T]: ... -def putenv(__name: bytes | str, __value: bytes | str) -> None: ... +def putenv(__name: Union[bytes, str], __value: Union[bytes, str]) -> None: ... if sys.platform != "win32": - def unsetenv(__name: bytes | str) -> None: ... + def unsetenv(__name: Union[bytes, str]) -> None: ... _Opener = Callable[[str, int], int] @@ -444,11 +445,11 @@ def fdopen( fd: int, mode: OpenTextMode = ..., buffering: int = ..., - encoding: str | None = ..., - errors: str | None = ..., - newline: str | None = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., closefd: bool = ..., - opener: _Opener | None = ..., + opener: Optional[_Opener] = ..., ) -> _TextIOWrapper: ... @overload def fdopen( @@ -459,7 +460,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: _Opener | None = ..., + opener: Optional[_Opener] = ..., ) -> FileIO: ... @overload def fdopen( @@ -470,7 +471,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: _Opener | None = ..., + opener: Optional[_Opener] = ..., ) -> BufferedRandom: ... @overload def fdopen( @@ -481,7 +482,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: _Opener | None = ..., + opener: Optional[_Opener] = ..., ) -> BufferedWriter: ... @overload def fdopen( @@ -492,7 +493,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: _Opener | None = ..., + opener: Optional[_Opener] = ..., ) -> BufferedReader: ... @overload def fdopen( @@ -503,22 +504,22 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: _Opener | None = ..., + opener: Optional[_Opener] = ..., ) -> BinaryIO: ... @overload def fdopen( fd: int, mode: str, buffering: int = ..., - encoding: str | None = ..., - errors: str | None = ..., - newline: str | None = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., closefd: bool = ..., - opener: _Opener | None = ..., + opener: Optional[_Opener] = ..., ) -> IO[Any]: ... def close(fd: int) -> None: ... def closerange(__fd_low: int, __fd_high: int) -> None: ... -def device_encoding(fd: int) -> str | None: ... +def device_encoding(fd: int) -> Optional[str]: ... def dup(__fd: int) -> int: ... if sys.version_info >= (3, 7): @@ -530,7 +531,7 @@ else: def fstat(fd: int) -> stat_result: ... def fsync(fd: FileDescriptorLike) -> None: ... def lseek(__fd: int, __position: int, __how: int) -> int: ... -def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: int | None = ...) -> int: ... +def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ... def pipe() -> Tuple[int, int]: ... def read(__fd: int, __length: int) -> bytes: ... @@ -540,7 +541,7 @@ if sys.platform != "win32": def fchown(fd: int, uid: int, gid: int) -> None: ... if sys.platform != "darwin": def fdatasync(fd: FileDescriptorLike) -> None: ... # Unix only, not Mac - def fpathconf(__fd: int, __name: str | int) -> int: ... + def fpathconf(__fd: int, __name: Union[str, int]) -> int: ... def fstatvfs(__fd: int) -> statvfs_result: ... def ftruncate(__fd: int, __length: int) -> None: ... def get_blocking(__fd: int) -> bool: ... @@ -555,7 +556,7 @@ if sys.platform != "win32": def pread(__fd: int, __length: int, __offset: int) -> bytes: ... def pwrite(__fd: int, __buffer: bytes, __offset: int) -> int: ... @overload - def sendfile(out_fd: int, in_fd: int, offset: int | None, count: int) -> int: ... + def sendfile(out_fd: int, in_fd: int, offset: Optional[int], count: int) -> int: ... @overload def sendfile( out_fd: int, @@ -585,7 +586,7 @@ if sys.platform != "win32": def write(__fd: int, __data: bytes) -> int: ... def access( - path: _FdOrAnyPath, mode: int, *, dir_fd: int | None = ..., effective_ids: bool = ..., follow_symlinks: bool = ... + path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., effective_ids: bool = ..., follow_symlinks: bool = ... ) -> bool: ... def chdir(path: _FdOrAnyPath) -> None: ... @@ -594,12 +595,12 @@ if sys.platform != "win32": def getcwd() -> str: ... def getcwdb() -> bytes: ... -def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> None: ... +def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... if sys.platform != "win32": def chflags(path: StrOrBytesPath, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix def chown( - path: _FdOrAnyPath, uid: int, gid: int, *, dir_fd: int | None = ..., follow_symlinks: bool = ... + path: _FdOrAnyPath, uid: int, gid: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ... ) -> None: ... # Unix only if sys.platform != "win32": @@ -613,32 +614,36 @@ def link( src: StrOrBytesPath, dst: StrOrBytesPath, *, - src_dir_fd: int | None = ..., - dst_dir_fd: int | None = ..., + src_dir_fd: Optional[int] = ..., + dst_dir_fd: Optional[int] = ..., follow_symlinks: bool = ..., ) -> None: ... -def lstat(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> stat_result: ... -def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ... +def lstat(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> stat_result: ... +def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... if sys.platform != "win32": - def mkfifo(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ... # Unix only + def mkfifo(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only def makedirs(name: StrOrBytesPath, mode: int = ..., exist_ok: bool = ...) -> None: ... if sys.platform != "win32": - def mknod(path: StrOrBytesPath, mode: int = ..., device: int = ..., *, dir_fd: int | None = ...) -> None: ... + def mknod(path: StrOrBytesPath, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... def major(__device: int) -> int: ... def minor(__device: int) -> int: ... def makedev(__major: int, __minor: int) -> int: ... - def pathconf(path: _FdOrAnyPath, name: str | int) -> int: ... # Unix only + def pathconf(path: _FdOrAnyPath, name: Union[str, int]) -> int: ... # Unix only -def readlink(path: AnyStr | PathLike[AnyStr], *, dir_fd: int | None = ...) -> AnyStr: ... -def remove(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... +def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ... +def remove(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... def removedirs(name: StrOrBytesPath) -> None: ... -def rename(src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ...) -> None: ... +def rename( + src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ... +) -> None: ... def renames(old: StrOrBytesPath, new: StrOrBytesPath) -> None: ... -def replace(src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ...) -> None: ... -def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... +def replace( + src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ... +) -> None: ... +def rmdir(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... @@ -650,15 +655,15 @@ if sys.version_info >= (3, 7): @overload def scandir(path: int) -> _ScandirIterator[str]: ... @overload - def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ... + def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ... else: @overload def scandir(path: None = ...) -> _ScandirIterator[str]: ... @overload - def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ... + def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ... -def stat(path: _FdOrAnyPath, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> stat_result: ... +def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ... if sys.version_info < (3, 7): @overload @@ -669,26 +674,28 @@ if sys.version_info < (3, 7): if sys.platform != "win32": def statvfs(path: _FdOrAnyPath) -> statvfs_result: ... # Unix only -def symlink(src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: int | None = ...) -> None: ... +def symlink( + src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: Optional[int] = ... +) -> None: ... if sys.platform != "win32": def sync() -> None: ... # Unix only def truncate(path: _FdOrAnyPath, length: int) -> None: ... # Unix only up to version 3.4 -def unlink(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... +def unlink(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... def utime( path: _FdOrAnyPath, - times: Tuple[int, int] | Tuple[float, float] | None = ..., + times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ..., *, ns: Tuple[int, int] = ..., - dir_fd: int | None = ..., + dir_fd: Optional[int] = ..., follow_symlinks: bool = ..., ) -> None: ... _OnError = Callable[[OSError], Any] def walk( - top: AnyStr | PathLike[AnyStr], topdown: bool = ..., onerror: _OnError | None = ..., followlinks: bool = ... + top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., onerror: Optional[_OnError] = ..., followlinks: bool = ... ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... if sys.platform != "win32": @@ -697,32 +704,32 @@ if sys.platform != "win32": def fwalk( top: StrPath = ..., topdown: bool = ..., - onerror: _OnError | None = ..., + onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ..., - dir_fd: int | None = ..., + dir_fd: Optional[int] = ..., ) -> Iterator[Tuple[str, List[str], List[str], int]]: ... @overload def fwalk( top: bytes, topdown: bool = ..., - onerror: _OnError | None = ..., + onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ..., - dir_fd: int | None = ..., + dir_fd: Optional[int] = ..., ) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ... else: def fwalk( top: StrPath = ..., topdown: bool = ..., - onerror: _OnError | None = ..., + onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ..., - dir_fd: int | None = ..., + dir_fd: Optional[int] = ..., ) -> Iterator[Tuple[str, List[str], List[str], int]]: ... if sys.platform == "linux": def getxattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> bytes: ... - def listxattr(path: _FdOrAnyPath | None = ..., *, follow_symlinks: bool = ...) -> List[str]: ... + def listxattr(path: Optional[_FdOrAnyPath] = ..., *, follow_symlinks: bool = ...) -> List[str]: ... def removexattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> None: ... def setxattr( path: _FdOrAnyPath, attribute: StrOrBytesPath, value: bytes, flags: int = ..., *, follow_symlinks: bool = ... @@ -748,10 +755,10 @@ _ExecVArgs = Union[ List[bytes], List[str], List[PathLike[Any]], - List[bytes | str], - List[bytes | PathLike[Any]], - List[str | PathLike[Any]], - List[bytes | str | PathLike[Any]], + List[Union[bytes, str]], + List[Union[bytes, PathLike[Any]]], + List[Union[str, PathLike[Any]]], + List[Union[bytes, str, PathLike[Any]]], ] _ExecEnv = Union[Mapping[bytes, Union[bytes, str]], Mapping[str, Union[bytes, str]]] @@ -773,7 +780,7 @@ if sys.platform != "win32": class _wrap_close(_TextIOWrapper): def __init__(self, stream: _TextIOWrapper, proc: Popen[str]) -> None: ... - def close(self) -> int | None: ... # type: ignore + def close(self) -> Optional[int]: ... # type: ignore def popen(cmd: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ... def spawnl(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: ... @@ -792,7 +799,7 @@ def times() -> times_result: ... def waitpid(__pid: int, __options: int) -> Tuple[int, int]: ... if sys.platform == "win32": - def startfile(path: StrOrBytesPath, operation: str | None = ...) -> None: ... + def startfile(path: StrOrBytesPath, operation: Optional[str] = ...) -> None: ... else: # Unix only @@ -831,13 +838,13 @@ if sys.platform != "win32": def sched_setaffinity(pid: int, mask: Iterable[int]) -> None: ... # some flavors of Unix def sched_getaffinity(pid: int) -> Set[int]: ... # some flavors of Unix -def cpu_count() -> int | None: ... +def cpu_count() -> Optional[int]: ... if sys.platform != "win32": # Unix only - def confstr(__name: str | int) -> str | None: ... + def confstr(__name: Union[str, int]) -> Optional[str]: ... def getloadavg() -> Tuple[float, float, float]: ... - def sysconf(__name: str | int) -> int: ... + def sysconf(__name: Union[str, int]) -> int: ... if sys.platform == "linux": def getrandom(size: int, flags: int = ...) -> bytes: ... @@ -847,16 +854,16 @@ def urandom(__size: int) -> bytes: ... if sys.version_info >= (3, 7) and sys.platform != "win32": def register_at_fork( *, - before: Callable[..., Any] | None = ..., - after_in_parent: Callable[..., Any] | None = ..., - after_in_child: Callable[..., Any] | None = ..., + before: Optional[Callable[..., Any]] = ..., + after_in_parent: Optional[Callable[..., Any]] = ..., + after_in_child: Optional[Callable[..., Any]] = ..., ) -> None: ... if sys.version_info >= (3, 8): if sys.platform == "win32": class _AddedDllDirectory: - path: str | None - def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], Any]) -> None: ... + path: Optional[str] + def __init__(self, path: Optional[str], cookie: _T, remove_dll_directory: Callable[[_T], Any]) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index b4a21bae7493..4183a019402a 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -15,21 +15,31 @@ if sys.version_info >= (3, 8): def release(self) -> None: ... _BufferCallback = Optional[Callable[[PickleBuffer], Any]] def dump( - obj: Any, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... + obj: Any, + file: IO[bytes], + protocol: Optional[int] = ..., + *, + fix_imports: bool = ..., + buffer_callback: _BufferCallback = ..., ) -> None: ... def dumps( - obj: Any, protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... + obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... ) -> bytes: ... def load( - file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ... + file: IO[bytes], + *, + fix_imports: bool = ..., + encoding: str = ..., + errors: str = ..., + buffers: Optional[Iterable[Any]] = ..., ) -> Any: ... def loads( - __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ... + __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Optional[Iterable[Any]] = ... ) -> Any: ... else: - def dump(obj: Any, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ... - def dumps(obj: Any, protocol: int | None = ..., *, fix_imports: bool = ...) -> bytes: ... + def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... + def dumps(obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> bytes: ... def load(file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ... def loads(data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ... @@ -41,8 +51,8 @@ _reducedtype = Union[ str, Tuple[Callable[..., Any], Tuple[Any, ...]], Tuple[Callable[..., Any], Tuple[Any, ...], Any], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Iterator[Any] | None], - Tuple[Callable[..., Any], Tuple[Any, ...], Any, Iterator[Any] | None, Iterator[Any] | None], + Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]]], + Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]], ] class Pickler: @@ -53,11 +63,16 @@ class Pickler: if sys.version_info >= (3, 8): def __init__( - self, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... + self, + file: IO[bytes], + protocol: Optional[int] = ..., + *, + fix_imports: bool = ..., + buffer_callback: _BufferCallback = ..., ) -> None: ... def reducer_override(self, obj: Any) -> Any: ... else: - def __init__(self, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ... + def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... def dump(self, __obj: Any) -> None: ... def clear_memo(self) -> None: ... def persistent_id(self, obj: Any) -> Any: ... @@ -73,7 +88,7 @@ class Unpickler: fix_imports: bool = ..., encoding: str = ..., errors: str = ..., - buffers: Iterable[Any] | None = ..., + buffers: Optional[Iterable[Any]] = ..., ) -> None: ... else: def __init__(self, file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> None: ... From e582886cd74c1f8ed2d506e03853a784972c327b Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:26:37 +0300 Subject: [PATCH 09/13] revert stubs/protobuf/google/ changes --- stubs/protobuf/google/protobuf/api_pb2.pyi | 10 +- .../google/protobuf/compiler/plugin_pb2.pyi | 30 +-- .../google/protobuf/descriptor_pb2.pyi | 250 +++++++++--------- .../google/protobuf/descriptor_pool.pyi | 6 +- .../google/protobuf/field_mask_pb2.pyi | 2 +- .../google/protobuf/internal/containers.pyi | 9 +- .../protobuf/internal/extension_dict.pyi | 4 +- .../protobuf/internal/well_known_types.pyi | 6 +- .../protobuf/google/protobuf/json_format.pyi | 17 +- .../google/protobuf/message_factory.pyi | 4 +- stubs/protobuf/google/protobuf/service.pyi | 12 +- stubs/protobuf/google/protobuf/struct_pb2.pyi | 12 +- .../google/protobuf/symbol_database.pyi | 4 +- .../protobuf/google/protobuf/text_format.pyi | 78 +++--- stubs/protobuf/google/protobuf/type_pb2.pyi | 20 +- 15 files changed, 234 insertions(+), 230 deletions(-) diff --git a/stubs/protobuf/google/protobuf/api_pb2.pyi b/stubs/protobuf/google/protobuf/api_pb2.pyi index 8f61763c54ab..10d183c44b2a 100644 --- a/stubs/protobuf/google/protobuf/api_pb2.pyi +++ b/stubs/protobuf/google/protobuf/api_pb2.pyi @@ -72,11 +72,11 @@ class Api(google.protobuf.message.Message): def __init__(self, *, name : typing.Text = ..., - methods : typing.typing.Iterable[global___Method] | None = ..., - options : typing.typing.Iterable[google.protobuf.type_pb2.Option] | None = ..., + methods : typing.Optional[typing.Iterable[global___Method]] = ..., + options : typing.Optional[typing.Iterable[google.protobuf.type_pb2.Option]] = ..., version : typing.Text = ..., - source_context : typing.google.protobuf.source_context_pb2.SourceContext | None = ..., - mixins : typing.typing.Iterable[global___Mixin] | None = ..., + source_context : typing.Optional[google.protobuf.source_context_pb2.SourceContext] = ..., + mixins : typing.Optional[typing.Iterable[global___Mixin]] = ..., syntax : google.protobuf.type_pb2.Syntax.V = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"source_context",b"source_context"]) -> builtins.bool: ... @@ -115,7 +115,7 @@ class Method(google.protobuf.message.Message): request_streaming : builtins.bool = ..., response_type_url : typing.Text = ..., response_streaming : builtins.bool = ..., - options : typing.typing.Iterable[google.protobuf.type_pb2.Option] | None = ..., + options : typing.Optional[typing.Iterable[google.protobuf.type_pb2.Option]] = ..., syntax : google.protobuf.type_pb2.Syntax.V = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options",u"request_streaming",b"request_streaming",u"request_type_url",b"request_type_url",u"response_streaming",b"response_streaming",u"response_type_url",b"response_type_url",u"syntax",b"syntax"]) -> None: ... diff --git a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi index cfb0a90ab5d2..012d8956ba77 100644 --- a/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi +++ b/stubs/protobuf/google/protobuf/compiler/plugin_pb2.pyi @@ -28,10 +28,10 @@ class Version(google.protobuf.message.Message): suffix: typing.Text = ... def __init__(self, *, - major : typing.builtins.int | None = ..., - minor : typing.builtins.int | None = ..., - patch : typing.builtins.int | None = ..., - suffix : typing.typing.Text | None = ..., + major : typing.Optional[builtins.int] = ..., + minor : typing.Optional[builtins.int] = ..., + patch : typing.Optional[builtins.int] = ..., + suffix : typing.Optional[typing.Text] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"major",b"major",u"minor",b"minor",u"patch",b"patch",u"suffix",b"suffix"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"major",b"major",u"minor",b"minor",u"patch",b"patch",u"suffix",b"suffix"]) -> None: ... @@ -72,10 +72,10 @@ class CodeGeneratorRequest(google.protobuf.message.Message): def compiler_version(self) -> global___Version: ... def __init__(self, *, - file_to_generate : typing.typing.Iterable[typing.Text] | None = ..., - parameter : typing.typing.Text | None = ..., - proto_file : typing.typing.Iterable[google.protobuf.descriptor_pb2.FileDescriptorProto] | None = ..., - compiler_version : typing.global___Version | None = ..., + file_to_generate : typing.Optional[typing.Iterable[typing.Text]] = ..., + parameter : typing.Optional[typing.Text] = ..., + proto_file : typing.Optional[typing.Iterable[google.protobuf.descriptor_pb2.FileDescriptorProto]] = ..., + compiler_version : typing.Optional[global___Version] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"compiler_version",b"compiler_version",u"parameter",b"parameter"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"compiler_version",b"compiler_version",u"file_to_generate",b"file_to_generate",u"parameter",b"parameter",u"proto_file",b"proto_file"]) -> None: ... @@ -163,10 +163,10 @@ class CodeGeneratorResponse(google.protobuf.message.Message): def generated_code_info(self) -> google.protobuf.descriptor_pb2.GeneratedCodeInfo: ... def __init__(self, *, - name : typing.typing.Text | None = ..., - insertion_point : typing.typing.Text | None = ..., - content : typing.typing.Text | None = ..., - generated_code_info : typing.google.protobuf.descriptor_pb2.GeneratedCodeInfo | None = ..., + name : typing.Optional[typing.Text] = ..., + insertion_point : typing.Optional[typing.Text] = ..., + content : typing.Optional[typing.Text] = ..., + generated_code_info : typing.Optional[google.protobuf.descriptor_pb2.GeneratedCodeInfo] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"content",b"content",u"generated_code_info",b"generated_code_info",u"insertion_point",b"insertion_point",u"name",b"name"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"content",b"content",u"generated_code_info",b"generated_code_info",u"insertion_point",b"insertion_point",u"name",b"name"]) -> None: ... @@ -190,9 +190,9 @@ class CodeGeneratorResponse(google.protobuf.message.Message): def file(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___CodeGeneratorResponse.File]: ... def __init__(self, *, - error : typing.typing.Text | None = ..., - supported_features : typing.builtins.int | None = ..., - file : typing.typing.Iterable[global___CodeGeneratorResponse.File] | None = ..., + error : typing.Optional[typing.Text] = ..., + supported_features : typing.Optional[builtins.int] = ..., + file : typing.Optional[typing.Iterable[global___CodeGeneratorResponse.File]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"error",b"error",u"supported_features",b"supported_features"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"error",b"error",u"file",b"file",u"supported_features",b"supported_features"]) -> None: ... diff --git a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi index 300aab9e3640..2a8a5b11f2b0 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pb2.pyi @@ -21,7 +21,7 @@ class FileDescriptorSet(google.protobuf.message.Message): def file(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___FileDescriptorProto]: ... def __init__(self, *, - file : typing.typing.Iterable[global___FileDescriptorProto] | None = ..., + file : typing.Optional[typing.Iterable[global___FileDescriptorProto]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"file",b"file"]) -> None: ... global___FileDescriptorSet = FileDescriptorSet @@ -77,18 +77,18 @@ class FileDescriptorProto(google.protobuf.message.Message): syntax: typing.Text = ... def __init__(self, *, - name : typing.typing.Text | None = ..., - package : typing.typing.Text | None = ..., - dependency : typing.typing.Iterable[typing.Text] | None = ..., - public_dependency : typing.typing.Iterable[builtins.int] | None = ..., - weak_dependency : typing.typing.Iterable[builtins.int] | None = ..., - message_type : typing.typing.Iterable[global___DescriptorProto] | None = ..., - enum_type : typing.typing.Iterable[global___EnumDescriptorProto] | None = ..., - service : typing.typing.Iterable[global___ServiceDescriptorProto] | None = ..., - extension : typing.typing.Iterable[global___FieldDescriptorProto] | None = ..., - options : typing.global___FileOptions | None = ..., - source_code_info : typing.global___SourceCodeInfo | None = ..., - syntax : typing.typing.Text | None = ..., + name : typing.Optional[typing.Text] = ..., + package : typing.Optional[typing.Text] = ..., + dependency : typing.Optional[typing.Iterable[typing.Text]] = ..., + public_dependency : typing.Optional[typing.Iterable[builtins.int]] = ..., + weak_dependency : typing.Optional[typing.Iterable[builtins.int]] = ..., + message_type : typing.Optional[typing.Iterable[global___DescriptorProto]] = ..., + enum_type : typing.Optional[typing.Iterable[global___EnumDescriptorProto]] = ..., + service : typing.Optional[typing.Iterable[global___ServiceDescriptorProto]] = ..., + extension : typing.Optional[typing.Iterable[global___FieldDescriptorProto]] = ..., + options : typing.Optional[global___FileOptions] = ..., + source_code_info : typing.Optional[global___SourceCodeInfo] = ..., + syntax : typing.Optional[typing.Text] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options",u"package",b"package",u"source_code_info",b"source_code_info",u"syntax",b"syntax"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"dependency",b"dependency",u"enum_type",b"enum_type",u"extension",b"extension",u"message_type",b"message_type",u"name",b"name",u"options",b"options",u"package",b"package",u"public_dependency",b"public_dependency",u"service",b"service",u"source_code_info",b"source_code_info",u"syntax",b"syntax",u"weak_dependency",b"weak_dependency"]) -> None: ... @@ -110,9 +110,9 @@ class DescriptorProto(google.protobuf.message.Message): def options(self) -> global___ExtensionRangeOptions: ... def __init__(self, *, - start : typing.builtins.int | None = ..., - end : typing.builtins.int | None = ..., - options : typing.global___ExtensionRangeOptions | None = ..., + start : typing.Optional[builtins.int] = ..., + end : typing.Optional[builtins.int] = ..., + options : typing.Optional[global___ExtensionRangeOptions] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"end",b"end",u"options",b"options",u"start",b"start"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"end",b"end",u"options",b"options",u"start",b"start"]) -> None: ... @@ -130,8 +130,8 @@ class DescriptorProto(google.protobuf.message.Message): end: builtins.int = ... def __init__(self, *, - start : typing.builtins.int | None = ..., - end : typing.builtins.int | None = ..., + start : typing.Optional[builtins.int] = ..., + end : typing.Optional[builtins.int] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"end",b"end",u"start",b"start"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"end",b"end",u"start",b"start"]) -> None: ... @@ -169,16 +169,16 @@ class DescriptorProto(google.protobuf.message.Message): def reserved_name(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ... def __init__(self, *, - name : typing.typing.Text | None = ..., - field : typing.typing.Iterable[global___FieldDescriptorProto] | None = ..., - extension : typing.typing.Iterable[global___FieldDescriptorProto] | None = ..., - nested_type : typing.typing.Iterable[global___DescriptorProto] | None = ..., - enum_type : typing.typing.Iterable[global___EnumDescriptorProto] | None = ..., - extension_range : typing.typing.Iterable[global___DescriptorProto.ExtensionRange] | None = ..., - oneof_decl : typing.typing.Iterable[global___OneofDescriptorProto] | None = ..., - options : typing.global___MessageOptions | None = ..., - reserved_range : typing.typing.Iterable[global___DescriptorProto.ReservedRange] | None = ..., - reserved_name : typing.typing.Iterable[typing.Text] | None = ..., + name : typing.Optional[typing.Text] = ..., + field : typing.Optional[typing.Iterable[global___FieldDescriptorProto]] = ..., + extension : typing.Optional[typing.Iterable[global___FieldDescriptorProto]] = ..., + nested_type : typing.Optional[typing.Iterable[global___DescriptorProto]] = ..., + enum_type : typing.Optional[typing.Iterable[global___EnumDescriptorProto]] = ..., + extension_range : typing.Optional[typing.Iterable[global___DescriptorProto.ExtensionRange]] = ..., + oneof_decl : typing.Optional[typing.Iterable[global___OneofDescriptorProto]] = ..., + options : typing.Optional[global___MessageOptions] = ..., + reserved_range : typing.Optional[typing.Iterable[global___DescriptorProto.ReservedRange]] = ..., + reserved_name : typing.Optional[typing.Iterable[typing.Text]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"enum_type",b"enum_type",u"extension",b"extension",u"extension_range",b"extension_range",u"field",b"field",u"name",b"name",u"nested_type",b"nested_type",u"oneof_decl",b"oneof_decl",u"options",b"options",u"reserved_name",b"reserved_name",u"reserved_range",b"reserved_range"]) -> None: ... @@ -192,7 +192,7 @@ class ExtensionRangeOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... global___ExtensionRangeOptions = ExtensionRangeOptions @@ -354,17 +354,17 @@ class FieldDescriptorProto(google.protobuf.message.Message): proto3_optional: builtins.bool = ... def __init__(self, *, - name : typing.typing.Text | None = ..., - number : typing.builtins.int | None = ..., - label : typing.global___FieldDescriptorProto.Label.V | None = ..., - type : typing.global___FieldDescriptorProto.Type.V | None = ..., - type_name : typing.typing.Text | None = ..., - extendee : typing.typing.Text | None = ..., - default_value : typing.typing.Text | None = ..., - oneof_index : typing.builtins.int | None = ..., - json_name : typing.typing.Text | None = ..., - options : typing.global___FieldOptions | None = ..., - proto3_optional : typing.builtins.bool | None = ..., + name : typing.Optional[typing.Text] = ..., + number : typing.Optional[builtins.int] = ..., + label : typing.Optional[global___FieldDescriptorProto.Label.V] = ..., + type : typing.Optional[global___FieldDescriptorProto.Type.V] = ..., + type_name : typing.Optional[typing.Text] = ..., + extendee : typing.Optional[typing.Text] = ..., + default_value : typing.Optional[typing.Text] = ..., + oneof_index : typing.Optional[builtins.int] = ..., + json_name : typing.Optional[typing.Text] = ..., + options : typing.Optional[global___FieldOptions] = ..., + proto3_optional : typing.Optional[builtins.bool] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"default_value",b"default_value",u"extendee",b"extendee",u"json_name",b"json_name",u"label",b"label",u"name",b"name",u"number",b"number",u"oneof_index",b"oneof_index",u"options",b"options",u"proto3_optional",b"proto3_optional",u"type",b"type",u"type_name",b"type_name"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"default_value",b"default_value",u"extendee",b"extendee",u"json_name",b"json_name",u"label",b"label",u"name",b"name",u"number",b"number",u"oneof_index",b"oneof_index",u"options",b"options",u"proto3_optional",b"proto3_optional",u"type",b"type",u"type_name",b"type_name"]) -> None: ... @@ -380,8 +380,8 @@ class OneofDescriptorProto(google.protobuf.message.Message): def options(self) -> global___OneofOptions: ... def __init__(self, *, - name : typing.typing.Text | None = ..., - options : typing.global___OneofOptions | None = ..., + name : typing.Optional[typing.Text] = ..., + options : typing.Optional[global___OneofOptions] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> None: ... @@ -406,8 +406,8 @@ class EnumDescriptorProto(google.protobuf.message.Message): end: builtins.int = ... def __init__(self, *, - start : typing.builtins.int | None = ..., - end : typing.builtins.int | None = ..., + start : typing.Optional[builtins.int] = ..., + end : typing.Optional[builtins.int] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"end",b"end",u"start",b"start"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"end",b"end",u"start",b"start"]) -> None: ... @@ -433,11 +433,11 @@ class EnumDescriptorProto(google.protobuf.message.Message): def reserved_name(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ... def __init__(self, *, - name : typing.typing.Text | None = ..., - value : typing.typing.Iterable[global___EnumValueDescriptorProto] | None = ..., - options : typing.global___EnumOptions | None = ..., - reserved_range : typing.typing.Iterable[global___EnumDescriptorProto.EnumReservedRange] | None = ..., - reserved_name : typing.typing.Iterable[typing.Text] | None = ..., + name : typing.Optional[typing.Text] = ..., + value : typing.Optional[typing.Iterable[global___EnumValueDescriptorProto]] = ..., + options : typing.Optional[global___EnumOptions] = ..., + reserved_range : typing.Optional[typing.Iterable[global___EnumDescriptorProto.EnumReservedRange]] = ..., + reserved_name : typing.Optional[typing.Iterable[typing.Text]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options",u"reserved_name",b"reserved_name",u"reserved_range",b"reserved_range",u"value",b"value"]) -> None: ... @@ -455,9 +455,9 @@ class EnumValueDescriptorProto(google.protobuf.message.Message): def options(self) -> global___EnumValueOptions: ... def __init__(self, *, - name : typing.typing.Text | None = ..., - number : typing.builtins.int | None = ..., - options : typing.global___EnumValueOptions | None = ..., + name : typing.Optional[typing.Text] = ..., + number : typing.Optional[builtins.int] = ..., + options : typing.Optional[global___EnumValueOptions] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"number",b"number",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"number",b"number",u"options",b"options"]) -> None: ... @@ -476,9 +476,9 @@ class ServiceDescriptorProto(google.protobuf.message.Message): def options(self) -> global___ServiceOptions: ... def __init__(self, *, - name : typing.typing.Text | None = ..., - method : typing.typing.Iterable[global___MethodDescriptorProto] | None = ..., - options : typing.global___ServiceOptions | None = ..., + name : typing.Optional[typing.Text] = ..., + method : typing.Optional[typing.Iterable[global___MethodDescriptorProto]] = ..., + options : typing.Optional[global___ServiceOptions] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"name",b"name",u"options",b"options"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"method",b"method",u"name",b"name",u"options",b"options"]) -> None: ... @@ -506,12 +506,12 @@ class MethodDescriptorProto(google.protobuf.message.Message): server_streaming: builtins.bool = ... def __init__(self, *, - name : typing.typing.Text | None = ..., - input_type : typing.typing.Text | None = ..., - output_type : typing.typing.Text | None = ..., - options : typing.global___MethodOptions | None = ..., - client_streaming : typing.builtins.bool | None = ..., - server_streaming : typing.builtins.bool | None = ..., + name : typing.Optional[typing.Text] = ..., + input_type : typing.Optional[typing.Text] = ..., + output_type : typing.Optional[typing.Text] = ..., + options : typing.Optional[global___MethodOptions] = ..., + client_streaming : typing.Optional[builtins.bool] = ..., + server_streaming : typing.Optional[builtins.bool] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"client_streaming",b"client_streaming",u"input_type",b"input_type",u"name",b"name",u"options",b"options",u"output_type",b"output_type",u"server_streaming",b"server_streaming"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"client_streaming",b"client_streaming",u"input_type",b"input_type",u"name",b"name",u"options",b"options",u"output_type",b"output_type",u"server_streaming",b"server_streaming"]) -> None: ... @@ -682,27 +682,27 @@ class FileOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - java_package : typing.typing.Text | None = ..., - java_outer_classname : typing.typing.Text | None = ..., - java_multiple_files : typing.builtins.bool | None = ..., - java_generate_equals_and_hash : typing.builtins.bool | None = ..., - java_string_check_utf8 : typing.builtins.bool | None = ..., - optimize_for : typing.global___FileOptions.OptimizeMode.V | None = ..., - go_package : typing.typing.Text | None = ..., - cc_generic_services : typing.builtins.bool | None = ..., - java_generic_services : typing.builtins.bool | None = ..., - py_generic_services : typing.builtins.bool | None = ..., - php_generic_services : typing.builtins.bool | None = ..., - deprecated : typing.builtins.bool | None = ..., - cc_enable_arenas : typing.builtins.bool | None = ..., - objc_class_prefix : typing.typing.Text | None = ..., - csharp_namespace : typing.typing.Text | None = ..., - swift_prefix : typing.typing.Text | None = ..., - php_class_prefix : typing.typing.Text | None = ..., - php_namespace : typing.typing.Text | None = ..., - php_metadata_namespace : typing.typing.Text | None = ..., - ruby_package : typing.typing.Text | None = ..., - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + java_package : typing.Optional[typing.Text] = ..., + java_outer_classname : typing.Optional[typing.Text] = ..., + java_multiple_files : typing.Optional[builtins.bool] = ..., + java_generate_equals_and_hash : typing.Optional[builtins.bool] = ..., + java_string_check_utf8 : typing.Optional[builtins.bool] = ..., + optimize_for : typing.Optional[global___FileOptions.OptimizeMode.V] = ..., + go_package : typing.Optional[typing.Text] = ..., + cc_generic_services : typing.Optional[builtins.bool] = ..., + java_generic_services : typing.Optional[builtins.bool] = ..., + py_generic_services : typing.Optional[builtins.bool] = ..., + php_generic_services : typing.Optional[builtins.bool] = ..., + deprecated : typing.Optional[builtins.bool] = ..., + cc_enable_arenas : typing.Optional[builtins.bool] = ..., + objc_class_prefix : typing.Optional[typing.Text] = ..., + csharp_namespace : typing.Optional[typing.Text] = ..., + swift_prefix : typing.Optional[typing.Text] = ..., + php_class_prefix : typing.Optional[typing.Text] = ..., + php_namespace : typing.Optional[typing.Text] = ..., + php_metadata_namespace : typing.Optional[typing.Text] = ..., + ruby_package : typing.Optional[typing.Text] = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"cc_enable_arenas",b"cc_enable_arenas",u"cc_generic_services",b"cc_generic_services",u"csharp_namespace",b"csharp_namespace",u"deprecated",b"deprecated",u"go_package",b"go_package",u"java_generate_equals_and_hash",b"java_generate_equals_and_hash",u"java_generic_services",b"java_generic_services",u"java_multiple_files",b"java_multiple_files",u"java_outer_classname",b"java_outer_classname",u"java_package",b"java_package",u"java_string_check_utf8",b"java_string_check_utf8",u"objc_class_prefix",b"objc_class_prefix",u"optimize_for",b"optimize_for",u"php_class_prefix",b"php_class_prefix",u"php_generic_services",b"php_generic_services",u"php_metadata_namespace",b"php_metadata_namespace",u"php_namespace",b"php_namespace",u"py_generic_services",b"py_generic_services",u"ruby_package",b"ruby_package",u"swift_prefix",b"swift_prefix"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"cc_enable_arenas",b"cc_enable_arenas",u"cc_generic_services",b"cc_generic_services",u"csharp_namespace",b"csharp_namespace",u"deprecated",b"deprecated",u"go_package",b"go_package",u"java_generate_equals_and_hash",b"java_generate_equals_and_hash",u"java_generic_services",b"java_generic_services",u"java_multiple_files",b"java_multiple_files",u"java_outer_classname",b"java_outer_classname",u"java_package",b"java_package",u"java_string_check_utf8",b"java_string_check_utf8",u"objc_class_prefix",b"objc_class_prefix",u"optimize_for",b"optimize_for",u"php_class_prefix",b"php_class_prefix",u"php_generic_services",b"php_generic_services",u"php_metadata_namespace",b"php_metadata_namespace",u"php_namespace",b"php_namespace",u"py_generic_services",b"py_generic_services",u"ruby_package",b"ruby_package",u"swift_prefix",b"swift_prefix",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -770,11 +770,11 @@ class MessageOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - message_set_wire_format : typing.builtins.bool | None = ..., - no_standard_descriptor_accessor : typing.builtins.bool | None = ..., - deprecated : typing.builtins.bool | None = ..., - map_entry : typing.builtins.bool | None = ..., - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + message_set_wire_format : typing.Optional[builtins.bool] = ..., + no_standard_descriptor_accessor : typing.Optional[builtins.bool] = ..., + deprecated : typing.Optional[builtins.bool] = ..., + map_entry : typing.Optional[builtins.bool] = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"map_entry",b"map_entry",u"message_set_wire_format",b"message_set_wire_format",u"no_standard_descriptor_accessor",b"no_standard_descriptor_accessor"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"map_entry",b"map_entry",u"message_set_wire_format",b"message_set_wire_format",u"no_standard_descriptor_accessor",b"no_standard_descriptor_accessor",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -889,13 +889,13 @@ class FieldOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - ctype : typing.global___FieldOptions.CType.V | None = ..., - packed : typing.builtins.bool | None = ..., - jstype : typing.global___FieldOptions.JSType.V | None = ..., - lazy : typing.builtins.bool | None = ..., - deprecated : typing.builtins.bool | None = ..., - weak : typing.builtins.bool | None = ..., - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + ctype : typing.Optional[global___FieldOptions.CType.V] = ..., + packed : typing.Optional[builtins.bool] = ..., + jstype : typing.Optional[global___FieldOptions.JSType.V] = ..., + lazy : typing.Optional[builtins.bool] = ..., + deprecated : typing.Optional[builtins.bool] = ..., + weak : typing.Optional[builtins.bool] = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"ctype",b"ctype",u"deprecated",b"deprecated",u"jstype",b"jstype",u"lazy",b"lazy",u"packed",b"packed",u"weak",b"weak"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"ctype",b"ctype",u"deprecated",b"deprecated",u"jstype",b"jstype",u"lazy",b"lazy",u"packed",b"packed",u"uninterpreted_option",b"uninterpreted_option",u"weak",b"weak"]) -> None: ... @@ -909,7 +909,7 @@ class OneofOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... global___OneofOptions = OneofOptions @@ -932,9 +932,9 @@ class EnumOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - allow_alias : typing.builtins.bool | None = ..., - deprecated : typing.builtins.bool | None = ..., - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + allow_alias : typing.Optional[builtins.bool] = ..., + deprecated : typing.Optional[builtins.bool] = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"allow_alias",b"allow_alias",u"deprecated",b"deprecated"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"allow_alias",b"allow_alias",u"deprecated",b"deprecated",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -954,8 +954,8 @@ class EnumValueOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - deprecated : typing.builtins.bool | None = ..., - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + deprecated : typing.Optional[builtins.bool] = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -980,8 +980,8 @@ class ServiceOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - deprecated : typing.builtins.bool | None = ..., - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + deprecated : typing.Optional[builtins.bool] = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -1029,9 +1029,9 @@ class MethodOptions(google.protobuf.message.Message): def uninterpreted_option(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___UninterpretedOption]: ... def __init__(self, *, - deprecated : typing.builtins.bool | None = ..., - idempotency_level : typing.global___MethodOptions.IdempotencyLevel.V | None = ..., - uninterpreted_option : typing.typing.Iterable[global___UninterpretedOption] | None = ..., + deprecated : typing.Optional[builtins.bool] = ..., + idempotency_level : typing.Optional[global___MethodOptions.IdempotencyLevel.V] = ..., + uninterpreted_option : typing.Optional[typing.Iterable[global___UninterpretedOption]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"idempotency_level",b"idempotency_level"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"deprecated",b"deprecated",u"idempotency_level",b"idempotency_level",u"uninterpreted_option",b"uninterpreted_option"]) -> None: ... @@ -1058,8 +1058,8 @@ class UninterpretedOption(google.protobuf.message.Message): is_extension: builtins.bool = ... def __init__(self, *, - name_part : typing.typing.Text | None = ..., - is_extension : typing.builtins.bool | None = ..., + name_part : typing.Optional[typing.Text] = ..., + is_extension : typing.Optional[builtins.bool] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"is_extension",b"is_extension",u"name_part",b"name_part"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"is_extension",b"is_extension",u"name_part",b"name_part"]) -> None: ... @@ -1083,13 +1083,13 @@ class UninterpretedOption(google.protobuf.message.Message): aggregate_value: typing.Text = ... def __init__(self, *, - name : typing.typing.Iterable[global___UninterpretedOption.NamePart] | None = ..., - identifier_value : typing.typing.Text | None = ..., - positive_int_value : typing.builtins.int | None = ..., - negative_int_value : typing.builtins.int | None = ..., - double_value : typing.builtins.float | None = ..., - string_value : typing.builtins.bytes | None = ..., - aggregate_value : typing.typing.Text | None = ..., + name : typing.Optional[typing.Iterable[global___UninterpretedOption.NamePart]] = ..., + identifier_value : typing.Optional[typing.Text] = ..., + positive_int_value : typing.Optional[builtins.int] = ..., + negative_int_value : typing.Optional[builtins.int] = ..., + double_value : typing.Optional[builtins.float] = ..., + string_value : typing.Optional[builtins.bytes] = ..., + aggregate_value : typing.Optional[typing.Text] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"aggregate_value",b"aggregate_value",u"double_value",b"double_value",u"identifier_value",b"identifier_value",u"negative_int_value",b"negative_int_value",u"positive_int_value",b"positive_int_value",u"string_value",b"string_value"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"aggregate_value",b"aggregate_value",u"double_value",b"double_value",u"identifier_value",b"identifier_value",u"name",b"name",u"negative_int_value",b"negative_int_value",u"positive_int_value",b"positive_int_value",u"string_value",b"string_value"]) -> None: ... @@ -1194,11 +1194,11 @@ class SourceCodeInfo(google.protobuf.message.Message): def leading_detached_comments(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ... def __init__(self, *, - path : typing.typing.Iterable[builtins.int] | None = ..., - span : typing.typing.Iterable[builtins.int] | None = ..., - leading_comments : typing.typing.Text | None = ..., - trailing_comments : typing.typing.Text | None = ..., - leading_detached_comments : typing.typing.Iterable[typing.Text] | None = ..., + path : typing.Optional[typing.Iterable[builtins.int]] = ..., + span : typing.Optional[typing.Iterable[builtins.int]] = ..., + leading_comments : typing.Optional[typing.Text] = ..., + trailing_comments : typing.Optional[typing.Text] = ..., + leading_detached_comments : typing.Optional[typing.Iterable[typing.Text]] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"leading_comments",b"leading_comments",u"trailing_comments",b"trailing_comments"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"leading_comments",b"leading_comments",u"leading_detached_comments",b"leading_detached_comments",u"path",b"path",u"span",b"span",u"trailing_comments",b"trailing_comments"]) -> None: ... @@ -1251,7 +1251,7 @@ class SourceCodeInfo(google.protobuf.message.Message): def location(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___SourceCodeInfo.Location]: ... def __init__(self, *, - location : typing.typing.Iterable[global___SourceCodeInfo.Location] | None = ..., + location : typing.Optional[typing.Iterable[global___SourceCodeInfo.Location]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"location",b"location"]) -> None: ... global___SourceCodeInfo = SourceCodeInfo @@ -1282,10 +1282,10 @@ class GeneratedCodeInfo(google.protobuf.message.Message): end: builtins.int = ... def __init__(self, *, - path : typing.typing.Iterable[builtins.int] | None = ..., - source_file : typing.typing.Text | None = ..., - begin : typing.builtins.int | None = ..., - end : typing.builtins.int | None = ..., + path : typing.Optional[typing.Iterable[builtins.int]] = ..., + source_file : typing.Optional[typing.Text] = ..., + begin : typing.Optional[builtins.int] = ..., + end : typing.Optional[builtins.int] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"begin",b"begin",u"end",b"end",u"source_file",b"source_file"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"begin",b"begin",u"end",b"end",u"path",b"path",u"source_file",b"source_file"]) -> None: ... @@ -1297,7 +1297,7 @@ class GeneratedCodeInfo(google.protobuf.message.Message): def annotation(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___GeneratedCodeInfo.Annotation]: ... def __init__(self, *, - annotation : typing.typing.Iterable[global___GeneratedCodeInfo.Annotation] | None = ..., + annotation : typing.Optional[typing.Iterable[global___GeneratedCodeInfo.Annotation]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"annotation",b"annotation"]) -> None: ... global___GeneratedCodeInfo = GeneratedCodeInfo diff --git a/stubs/protobuf/google/protobuf/descriptor_pool.pyi b/stubs/protobuf/google/protobuf/descriptor_pool.pyi index f1ecee77622a..aabe9d9dca0a 100644 --- a/stubs/protobuf/google/protobuf/descriptor_pool.pyi +++ b/stubs/protobuf/google/protobuf/descriptor_pool.pyi @@ -1,8 +1,8 @@ -from typing import Any +from typing import Any, Optional class DescriptorPool: - def __new__(cls, descriptor_db: Any | None = ...): ... - def __init__(self, descriptor_db: Any | None = ...) -> None: ... + def __new__(cls, descriptor_db: Optional[Any] = ...): ... + def __init__(self, descriptor_db: Optional[Any] = ...) -> None: ... def Add(self, file_desc_proto): ... def AddSerializedFile(self, serialized_file_desc_proto): ... def AddDescriptor(self, desc): ... diff --git a/stubs/protobuf/google/protobuf/field_mask_pb2.pyi b/stubs/protobuf/google/protobuf/field_mask_pb2.pyi index 78c801a101fc..efa622a680f8 100644 --- a/stubs/protobuf/google/protobuf/field_mask_pb2.pyi +++ b/stubs/protobuf/google/protobuf/field_mask_pb2.pyi @@ -219,7 +219,7 @@ class FieldMask(google.protobuf.message.Message, google.protobuf.internal.well_k def paths(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ... def __init__(self, *, - paths : typing.typing.Iterable[typing.Text] | None = ..., + paths : typing.Optional[typing.Iterable[typing.Text]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"paths",b"paths"]) -> None: ... global___FieldMask = FieldMask diff --git a/stubs/protobuf/google/protobuf/internal/containers.pyi b/stubs/protobuf/google/protobuf/internal/containers.pyi index 6e3034258237..5e54051b6afa 100644 --- a/stubs/protobuf/google/protobuf/internal/containers.pyi +++ b/stubs/protobuf/google/protobuf/internal/containers.pyi @@ -6,6 +6,7 @@ from typing import ( List, Mapping as Mapping, MutableMapping as MutableMapping, + Optional, Sequence, Text, TypeVar, @@ -30,7 +31,7 @@ class BaseContainer(Sequence[_T]): def __ne__(self, other: object) -> bool: ... def __hash__(self) -> int: ... def __repr__(self) -> str: ... - def sort(self, *, key: Callable[[_T], Any] | None = ..., reverse: bool = ...) -> None: ... + def sort(self, *, key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...) -> None: ... @overload def __getitem__(self, key: int) -> _T: ... @overload @@ -40,7 +41,7 @@ class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]): def __init__(self, message_listener: MessageListener, message_descriptor: Descriptor) -> None: ... def append(self, value: _ScalarV) -> None: ... def insert(self, key: int, value: _ScalarV) -> None: ... - def extend(self, elem_seq: Iterable[_ScalarV] | None) -> None: ... + def extend(self, elem_seq: Optional[Iterable[_ScalarV]]) -> None: ... def MergeFrom(self: _M, other: _M) -> None: ... def remove(self, elem: _ScalarV) -> None: ... def pop(self, key: int = ...) -> _ScalarV: ... @@ -50,7 +51,7 @@ class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]): def __setitem__(self, key: slice, value: Iterable[_ScalarV]) -> None: ... def __getslice__(self, start: int, stop: int) -> List[_ScalarV]: ... def __setslice__(self, start: int, stop: int, values: Iterable[_ScalarV]) -> None: ... - def __delitem__(self, key: int | slice) -> None: ... + def __delitem__(self, key: Union[int, slice]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __eq__(self, other: object) -> bool: ... @@ -64,7 +65,7 @@ class RepeatedCompositeFieldContainer(BaseContainer[_MessageV]): def remove(self, elem: _MessageV) -> None: ... def pop(self, key: int = ...) -> _MessageV: ... def __getslice__(self, start: int, stop: int) -> List[_MessageV]: ... - def __delitem__(self, key: int | slice) -> None: ... + def __delitem__(self, key: Union[int, slice]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __eq__(self, other: object) -> bool: ... diff --git a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi index a8aead6fd3ad..486e367eaa15 100644 --- a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi +++ b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Iterator, Text, TypeVar +from typing import Any, Generic, Iterator, Text, TypeVar, Union from google.protobuf.descriptor import FieldDescriptor from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer @@ -7,7 +7,7 @@ from google.protobuf.message import Message _ContainerMessageT = TypeVar("_ContainerMessageT", bound=Message) _ExtenderMessageT = TypeVar( "_ExtenderMessageT", - bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | int | float | Text | bytes, + bound=Union[Message, RepeatedScalarFieldContainer[Any], RepeatedCompositeFieldContainer[Any], bool, int, float, Text, bytes], ) class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ... diff --git a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi index 239a44397f95..6b6b95a197cf 100644 --- a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +++ b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi @@ -1,5 +1,5 @@ from datetime import datetime, timedelta -from typing import Any as tAny, Dict, Type +from typing import Any as tAny, Dict, Optional, Type class Error(Exception): ... class ParseError(Error): ... @@ -7,7 +7,7 @@ class ParseError(Error): ... class Any: type_url: tAny = ... value: tAny = ... - def Pack(self, msg: tAny, type_url_prefix: bytes = ..., deterministic: tAny | None = ...) -> None: ... + def Pack(self, msg: tAny, type_url_prefix: bytes = ..., deterministic: Optional[tAny] = ...) -> None: ... def Unpack(self, msg: tAny): ... def TypeName(self): ... def Is(self, descriptor: tAny): ... @@ -58,7 +58,7 @@ class FieldMask: ) -> None: ... class _FieldMaskTree: - def __init__(self, field_mask: tAny | None = ...) -> None: ... + def __init__(self, field_mask: Optional[tAny] = ...) -> None: ... def MergeFromFieldMask(self, field_mask: tAny) -> None: ... def AddPath(self, path: tAny): ... def ToFieldMask(self, field_mask: tAny) -> None: ... diff --git a/stubs/protobuf/google/protobuf/json_format.pyi b/stubs/protobuf/google/protobuf/json_format.pyi index dc3ace7caf15..75fda13431a6 100644 --- a/stubs/protobuf/google/protobuf/json_format.pyi +++ b/stubs/protobuf/google/protobuf/json_format.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Text, TypeVar +from typing import Any, Dict, Optional, Text, TypeVar, Union from google.protobuf.descriptor_pool import DescriptorPool from google.protobuf.message import Message @@ -16,20 +16,23 @@ def MessageToJson( indent: int = ..., sort_keys: bool = ..., use_integers_for_enums: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - float_precision: int | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., + float_precision: Optional[int] = ..., ) -> str: ... def MessageToDict( message: Message, including_default_value_fields: bool = ..., preserving_proto_field_name: bool = ..., use_integers_for_enums: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - float_precision: int | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., + float_precision: Optional[int] = ..., ) -> Dict[Text, Any]: ... def Parse( - text: bytes | Text, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: DescriptorPool | None = ... + text: Union[bytes, Text], + message: _MessageT, + ignore_unknown_fields: bool = ..., + descriptor_pool: Optional[DescriptorPool] = ..., ) -> _MessageT: ... def ParseDict( - js_dict: Any, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: DescriptorPool | None = ... + js_dict: Any, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: Optional[DescriptorPool] = ... ) -> _MessageT: ... diff --git a/stubs/protobuf/google/protobuf/message_factory.pyi b/stubs/protobuf/google/protobuf/message_factory.pyi index 3c092f45627c..d8a42d30bc65 100644 --- a/stubs/protobuf/google/protobuf/message_factory.pyi +++ b/stubs/protobuf/google/protobuf/message_factory.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, Type +from typing import Any, Dict, Iterable, Optional, Type from google.protobuf.descriptor import Descriptor from google.protobuf.descriptor_pb2 import FileDescriptorProto @@ -7,7 +7,7 @@ from google.protobuf.message import Message class MessageFactory: pool: Any - def __init__(self, pool: DescriptorPool | None = ...) -> None: ... + def __init__(self, pool: Optional[DescriptorPool] = ...) -> None: ... def GetPrototype(self, descriptor: Descriptor) -> Type[Message]: ... def GetMessages(self, files: Iterable[str]) -> Dict[str, Type[Message]]: ... diff --git a/stubs/protobuf/google/protobuf/service.pyi b/stubs/protobuf/google/protobuf/service.pyi index ca686a9b2c61..4874d5356ded 100644 --- a/stubs/protobuf/google/protobuf/service.pyi +++ b/stubs/protobuf/google/protobuf/service.pyi @@ -1,5 +1,5 @@ from concurrent.futures import Future -from typing import Callable, Text, Type +from typing import Callable, Optional, Text, Type from google.protobuf.descriptor import MethodDescriptor, ServiceDescriptor from google.protobuf.message import Message @@ -14,15 +14,15 @@ class Service: method_descriptor: MethodDescriptor, rpc_controller: RpcController, request: Message, - done: Callable[[Message], None] | None, - ) -> Future[Message] | None: ... + done: Optional[Callable[[Message], None]], + ) -> Optional[Future[Message]]: ... def GetRequestClass(self, method_descriptor: MethodDescriptor) -> Type[Message]: ... def GetResponseClass(self, method_descriptor: MethodDescriptor) -> Type[Message]: ... class RpcController: def Reset(self) -> None: ... def Failed(self) -> bool: ... - def ErrorText(self) -> Text | None: ... + def ErrorText(self) -> Optional[Text]: ... def StartCancel(self) -> None: ... def SetFailed(self, reason: Text) -> None: ... def IsCanceled(self) -> bool: ... @@ -35,5 +35,5 @@ class RpcChannel: rpc_controller: RpcController, request: Message, response_class: Type[Message], - done: Callable[[Message], None] | None, - ) -> Future[Message] | None: ... + done: Optional[Callable[[Message], None]], + ) -> Optional[Future[Message]]: ... diff --git a/stubs/protobuf/google/protobuf/struct_pb2.pyi b/stubs/protobuf/google/protobuf/struct_pb2.pyi index 9956cf6f4fe9..d6f93a3d179b 100644 --- a/stubs/protobuf/google/protobuf/struct_pb2.pyi +++ b/stubs/protobuf/google/protobuf/struct_pb2.pyi @@ -51,7 +51,7 @@ class Struct(google.protobuf.message.Message, google.protobuf.internal.well_know def __init__(self, *, key : typing.Text = ..., - value : typing.global___Value | None = ..., + value : typing.Optional[global___Value] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"value",b"value"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"key",b"key",u"value",b"value"]) -> None: ... @@ -62,7 +62,7 @@ class Struct(google.protobuf.message.Message, google.protobuf.internal.well_know def fields(self) -> google.protobuf.internal.containers.MessageMap[typing.Text, global___Value]: ... def __init__(self, *, - fields : typing.typing.Mapping[typing.Text, global___Value] | None = ..., + fields : typing.Optional[typing.Mapping[typing.Text, global___Value]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"fields",b"fields"]) -> None: ... global___Struct = Struct @@ -101,12 +101,12 @@ class Value(google.protobuf.message.Message): number_value : builtins.float = ..., string_value : typing.Text = ..., bool_value : builtins.bool = ..., - struct_value : typing.global___Struct | None = ..., - list_value : typing.global___ListValue | None = ..., + struct_value : typing.Optional[global___Struct] = ..., + list_value : typing.Optional[global___ListValue] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"bool_value",b"bool_value",u"kind",b"kind",u"list_value",b"list_value",u"null_value",b"null_value",u"number_value",b"number_value",u"string_value",b"string_value",u"struct_value",b"struct_value"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"bool_value",b"bool_value",u"kind",b"kind",u"list_value",b"list_value",u"null_value",b"null_value",u"number_value",b"number_value",u"string_value",b"string_value",u"struct_value",b"struct_value"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions.Literal[u"kind",b"kind"]) -> typing.typing_extensions.Literal["null_value","number_value","string_value","bool_value","struct_value","list_value"] | None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal[u"kind",b"kind"]) -> typing.Optional[typing_extensions.Literal["null_value","number_value","string_value","bool_value","struct_value","list_value"]]: ... global___Value = Value # `ListValue` is a wrapper around a repeated field of values. @@ -120,7 +120,7 @@ class ListValue(google.protobuf.message.Message, google.protobuf.internal.well_k def values(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Value]: ... def __init__(self, *, - values : typing.typing.Iterable[global___Value] | None = ..., + values : typing.Optional[typing.Iterable[global___Value]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"values",b"values"]) -> None: ... global___ListValue = ListValue diff --git a/stubs/protobuf/google/protobuf/symbol_database.pyi b/stubs/protobuf/google/protobuf/symbol_database.pyi index eda439e7e4b9..09e32e9de2f7 100644 --- a/stubs/protobuf/google/protobuf/symbol_database.pyi +++ b/stubs/protobuf/google/protobuf/symbol_database.pyi @@ -1,11 +1,11 @@ -from typing import Dict, Iterable, Type +from typing import Dict, Iterable, Type, Union from google.protobuf.descriptor import Descriptor, EnumDescriptor, FileDescriptor, ServiceDescriptor from google.protobuf.message import Message from google.protobuf.message_factory import MessageFactory class SymbolDatabase(MessageFactory): - def RegisterMessage(self, message: Type[Message] | Message) -> Type[Message] | Message: ... + def RegisterMessage(self, message: Union[Type[Message], Message]) -> Union[Type[Message], Message]: ... def RegisterMessageDescriptor(self, message_descriptor: Descriptor) -> None: ... def RegisterEnumDescriptor(self, enum_descriptor: EnumDescriptor) -> EnumDescriptor: ... def RegisterServiceDescriptor(self, service_descriptor: ServiceDescriptor) -> None: ... diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index 1185808ab72b..7fe57b6429f3 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import SupportsWrite -from typing import Any, Callable, Iterable, Optional, Text, Tuple, TypeVar +from typing import Any, Callable, Iterable, Optional, Text, Tuple, TypeVar, Union from .descriptor import FieldDescriptor from .descriptor_pool import DescriptorPool @@ -14,9 +14,9 @@ _M = TypeVar("_M", bound=Message) # message type (of self) class Error(Exception): ... class ParseError(Error): - def __init__(self, message: str | None = ..., line: int | None = ..., column: int | None = ...) -> None: ... - def GetLine(self) -> int | None: ... - def GetColumn(self) -> int | None: ... + def __init__(self, message: Optional[str] = ..., line: Optional[int] = ..., column: Optional[int] = ...) -> None: ... + def GetLine(self) -> Optional[int]: ... + def GetColumn(self) -> Optional[int]: ... class TextWriter: def __init__(self, as_utf8: bool) -> None: ... @@ -33,12 +33,12 @@ def MessageToString( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., + float_format: Optional[str] = ..., + double_format: Optional[str] = ..., use_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., indent: int = ..., - message_formatter: _MessageFormatter | None = ..., + message_formatter: Optional[_MessageFormatter] = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> str: ... @@ -49,10 +49,10 @@ def MessageToBytes( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., + float_format: Optional[str] = ..., + double_format: Optional[str] = ..., use_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., indent: int = ..., message_formatter: _MessageFormatter = ..., print_unknown_fields: bool = ..., @@ -67,11 +67,11 @@ def PrintMessage( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., + float_format: Optional[str] = ..., + double_format: Optional[str] = ..., use_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - message_formatter: _MessageFormatter | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., + message_formatter: Optional[_MessageFormatter] = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> None: ... @@ -85,9 +85,9 @@ def PrintField( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., - message_formatter: _MessageFormatter | None = ..., + float_format: Optional[str] = ..., + double_format: Optional[str] = ..., + message_formatter: Optional[_MessageFormatter] = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> None: ... @@ -101,9 +101,9 @@ def PrintFieldValue( use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., - message_formatter: _MessageFormatter | None = ..., + float_format: Optional[str] = ..., + double_format: Optional[str] = ..., + message_formatter: Optional[_MessageFormatter] = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> None: ... @@ -116,11 +116,11 @@ class _Printer: use_short_repeated_primitives: bool = ... pointy_brackets: bool = ... use_index_order: bool = ... - float_format: str | None = ... - double_format: str | None = ... + float_format: Optional[str] = ... + double_format: Optional[str] = ... use_field_number: bool = ... - descriptor_pool: DescriptorPool | None = ... - message_formatter: _MessageFormatter | None = ... + descriptor_pool: Optional[DescriptorPool] = ... + message_formatter: Optional[_MessageFormatter] = ... print_unknown_fields: bool = ... force_colon: bool = ... def __init__( @@ -132,11 +132,11 @@ class _Printer: use_short_repeated_primitives: bool = ..., pointy_brackets: bool = ..., use_index_order: bool = ..., - float_format: str | None = ..., - double_format: str | None = ..., + float_format: Optional[str] = ..., + double_format: Optional[str] = ..., use_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., - message_formatter: _MessageFormatter | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., + message_formatter: Optional[_MessageFormatter] = ..., print_unknown_fields: bool = ..., force_colon: bool = ..., ) -> None: ... @@ -145,44 +145,44 @@ class _Printer: def PrintFieldValue(self, field: FieldDescriptor, value: Any) -> None: ... def Parse( - text: Text | bytes, + text: Union[Text, bytes], message: _M, allow_unknown_extension: bool = ..., allow_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., allow_unknown_field: bool = ..., ) -> _M: ... def Merge( - text: Text | bytes, + text: Union[Text, bytes], message: _M, allow_unknown_extension: bool = ..., allow_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., allow_unknown_field: bool = ..., ) -> _M: ... def MergeLines( - lines: Iterable[Text | bytes], + lines: Iterable[Union[Text, bytes]], message: _M, allow_unknown_extension: bool = ..., allow_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., allow_unknown_field: bool = ..., ) -> _M: ... class _Parser: allow_unknown_extension: bool = ... allow_field_number: bool = ... - descriptor_pool: DescriptorPool | None = ... + descriptor_pool: Optional[DescriptorPool] = ... allow_unknown_field: bool = ... def __init__( self, allow_unknown_extension: bool = ..., allow_field_number: bool = ..., - descriptor_pool: DescriptorPool | None = ..., + descriptor_pool: Optional[DescriptorPool] = ..., allow_unknown_field: bool = ..., ) -> None: ... - def ParseLines(self, lines: Iterable[Text | bytes], message: _M) -> _M: ... - def MergeLines(self, lines: Iterable[Text | bytes], message: _M) -> _M: ... + def ParseLines(self, lines: Iterable[Union[Text, bytes]], message: _M) -> _M: ... + def MergeLines(self, lines: Iterable[Union[Text, bytes]], message: _M) -> _M: ... _ParseError = ParseError diff --git a/stubs/protobuf/google/protobuf/type_pb2.pyi b/stubs/protobuf/google/protobuf/type_pb2.pyi index d7db74b0a1ef..399cb4b0ab1a 100644 --- a/stubs/protobuf/google/protobuf/type_pb2.pyi +++ b/stubs/protobuf/google/protobuf/type_pb2.pyi @@ -61,10 +61,10 @@ class Type(google.protobuf.message.Message): def __init__(self, *, name : typing.Text = ..., - fields : typing.typing.Iterable[global___Field] | None = ..., - oneofs : typing.typing.Iterable[typing.Text] | None = ..., - options : typing.typing.Iterable[global___Option] | None = ..., - source_context : typing.google.protobuf.source_context_pb2.SourceContext | None = ..., + fields : typing.Optional[typing.Iterable[global___Field]] = ..., + oneofs : typing.Optional[typing.Iterable[typing.Text]] = ..., + options : typing.Optional[typing.Iterable[global___Option]] = ..., + source_context : typing.Optional[google.protobuf.source_context_pb2.SourceContext] = ..., syntax : global___Syntax.V = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"source_context",b"source_context"]) -> builtins.bool: ... @@ -226,7 +226,7 @@ class Field(google.protobuf.message.Message): type_url : typing.Text = ..., oneof_index : builtins.int = ..., packed : builtins.bool = ..., - options : typing.typing.Iterable[global___Option] | None = ..., + options : typing.Optional[typing.Iterable[global___Option]] = ..., json_name : typing.Text = ..., default_value : typing.Text = ..., ) -> None: ... @@ -257,9 +257,9 @@ class Enum(google.protobuf.message.Message): def __init__(self, *, name : typing.Text = ..., - enumvalue : typing.typing.Iterable[global___EnumValue] | None = ..., - options : typing.typing.Iterable[global___Option] | None = ..., - source_context : typing.google.protobuf.source_context_pb2.SourceContext | None = ..., + enumvalue : typing.Optional[typing.Iterable[global___EnumValue]] = ..., + options : typing.Optional[typing.Iterable[global___Option]] = ..., + source_context : typing.Optional[google.protobuf.source_context_pb2.SourceContext] = ..., syntax : global___Syntax.V = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"source_context",b"source_context"]) -> builtins.bool: ... @@ -283,7 +283,7 @@ class EnumValue(google.protobuf.message.Message): *, name : typing.Text = ..., number : builtins.int = ..., - options : typing.typing.Iterable[global___Option] | None = ..., + options : typing.Optional[typing.Iterable[global___Option]] = ..., ) -> None: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"number",b"number",u"options",b"options"]) -> None: ... global___EnumValue = EnumValue @@ -308,7 +308,7 @@ class Option(google.protobuf.message.Message): def __init__(self, *, name : typing.Text = ..., - value : typing.google.protobuf.any_pb2.Any | None = ..., + value : typing.Optional[google.protobuf.any_pb2.Any] = ..., ) -> None: ... def HasField(self, field_name: typing_extensions.Literal[u"value",b"value"]) -> builtins.bool: ... def ClearField(self, field_name: typing_extensions.Literal[u"name",b"name",u"value",b"value"]) -> None: ... From 8993ebc80d1cbe723c95bee8010e6cc1cbd42bba Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:29:44 +0300 Subject: [PATCH 10/13] revert everything that contains 'import typing' --- stdlib/_ast.pyi | 68 ++++++++++++++--------------- stdlib/ast.pyi | 28 ++++++------ stdlib/zoneinfo/__init__.pyi | 6 +-- stubs/Jinja2/jinja2/nodes.pyi | 54 +++++++++++------------ stubs/six/six/__init__.pyi | 36 ++++++++------- stubs/typed-ast/typed_ast/ast27.pyi | 66 ++++++++++++++-------------- 6 files changed, 132 insertions(+), 126 deletions(-) diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index 66e3be054f5e..eee5b55f01b0 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -1,6 +1,6 @@ import sys import typing -from typing import Any, ClassVar +from typing import Any, ClassVar, Optional from typing_extensions import Literal PyCF_ONLY_AST: int @@ -18,9 +18,9 @@ class AST: lineno: int col_offset: int if sys.version_info >= (3, 8): - end_lineno: int | None - end_col_offset: int | None - type_comment: str | None + end_lineno: Optional[int] + end_col_offset: Optional[int] + type_comment: Optional[str] class mod(AST): ... @@ -50,14 +50,14 @@ class FunctionDef(stmt): args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - returns: expr | None + returns: Optional[expr] class AsyncFunctionDef(stmt): name: _identifier args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - returns: expr | None + returns: Optional[expr] class ClassDef(stmt): name: _identifier @@ -67,7 +67,7 @@ class ClassDef(stmt): decorator_list: typing.List[expr] class Return(stmt): - value: expr | None + value: Optional[expr] class Delete(stmt): targets: typing.List[expr] @@ -84,7 +84,7 @@ class AugAssign(stmt): class AnnAssign(stmt): target: expr annotation: expr - value: expr | None + value: Optional[expr] simple: int class For(stmt): @@ -118,8 +118,8 @@ class AsyncWith(stmt): body: typing.List[stmt] class Raise(stmt): - exc: expr | None - cause: expr | None + exc: Optional[expr] + cause: Optional[expr] class Try(stmt): body: typing.List[stmt] @@ -129,13 +129,13 @@ class Try(stmt): class Assert(stmt): test: expr - msg: expr | None + msg: Optional[expr] class Import(stmt): names: typing.List[alias] class ImportFrom(stmt): - module: _identifier | None + module: Optional[_identifier] names: typing.List[alias] level: int @@ -176,7 +176,7 @@ class IfExp(expr): orelse: expr class Dict(expr): - keys: typing.List[expr | None] + keys: typing.List[Optional[expr]] values: typing.List[expr] class Set(expr): @@ -203,7 +203,7 @@ class Await(expr): value: expr class Yield(expr): - value: expr | None + value: Optional[expr] class YieldFrom(expr): value: expr @@ -220,8 +220,8 @@ class Call(expr): class FormattedValue(expr): value: expr - conversion: int | None - format_spec: expr | None + conversion: Optional[int] + format_spec: Optional[expr] class JoinedStr(expr): values: typing.List[expr] @@ -239,7 +239,7 @@ if sys.version_info < (3, 8): class Constant(expr): value: Any # None, str, bytes, bool, int, float, complex, Ellipsis - kind: str | None + kind: Optional[str] # Aliases for value, for backwards compatibility s: Any n: complex @@ -261,9 +261,9 @@ else: _SliceT = slice class Slice(_SliceT): - lower: expr | None - upper: expr | None - step: expr | None + lower: Optional[expr] + upper: Optional[expr] + step: Optional[expr] if sys.version_info < (3, 9): class ExtSlice(slice): @@ -347,35 +347,35 @@ class comprehension(AST): class excepthandler(AST): ... class ExceptHandler(excepthandler): - type: expr | None - name: _identifier | None + type: Optional[expr] + name: Optional[_identifier] body: typing.List[stmt] class arguments(AST): if sys.version_info >= (3, 8): posonlyargs: typing.List[arg] args: typing.List[arg] - vararg: arg | None + vararg: Optional[arg] kwonlyargs: typing.List[arg] - kw_defaults: typing.List[expr | None] - kwarg: arg | None + kw_defaults: typing.List[Optional[expr]] + kwarg: Optional[arg] defaults: typing.List[expr] class arg(AST): arg: _identifier - annotation: expr | None + annotation: Optional[expr] class keyword(AST): - arg: _identifier | None + arg: Optional[_identifier] value: expr class alias(AST): name: _identifier - asname: _identifier | None + asname: Optional[_identifier] class withitem(AST): context_expr: expr - optional_vars: expr | None + optional_vars: Optional[expr] if sys.version_info >= (3, 10): class Match(stmt): @@ -386,7 +386,7 @@ if sys.version_info >= (3, 10): _pattern = pattern class match_case(AST): pattern: _pattern - guard: expr | None + guard: Optional[expr] body: typing.List[stmt] class MatchValue(pattern): value: expr @@ -395,18 +395,18 @@ if sys.version_info >= (3, 10): class MatchSequence(pattern): patterns: typing.List[pattern] class MatchStar(pattern): - name: _identifier | None + name: Optional[_identifier] class MatchMapping(pattern): keys: typing.List[expr] patterns: typing.List[pattern] - rest: _identifier | None + rest: Optional[_identifier] class MatchClass(pattern): cls: expr patterns: typing.List[pattern] kwd_attrs: typing.List[_identifier] kwd_patterns: typing.List[pattern] class MatchAs(pattern): - pattern: _pattern | None - name: _identifier | None + pattern: Optional[_pattern] + name: Optional[_identifier] class MatchOr(pattern): patterns: typing.List[pattern] diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 1649e4ab41be..ff1cd00c7757 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -8,7 +8,7 @@ # sys. import sys import typing as _typing -from typing import Any, Iterator, TypeVar, overload +from typing import Any, Iterator, Optional, TypeVar, Union, overload from typing_extensions import Literal from _ast import * # type: ignore @@ -150,7 +150,7 @@ class NodeVisitor: class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> AST: ... # TODO: Override the visit_* methods with better return types. - # The usual return type is AST | None, but Iterable[AST] + # The usual return type is Optional[AST], but Iterable[AST] # is also allowed in some cases -- this needs to be mapped. _T = TypeVar("_T", bound=AST) @@ -158,28 +158,28 @@ _T = TypeVar("_T", bound=AST) if sys.version_info >= (3, 8): @overload def parse( - source: str | bytes, - filename: str | bytes = ..., + source: Union[str, bytes], + filename: Union[str, bytes] = ..., mode: Literal["exec"] = ..., *, type_comments: bool = ..., - feature_version: None | int | _typing.Tuple[int, int] = ..., + feature_version: Union[None, int, _typing.Tuple[int, int]] = ..., ) -> Module: ... @overload def parse( - source: str | bytes, - filename: str | bytes = ..., + source: Union[str, bytes], + filename: Union[str, bytes] = ..., mode: str = ..., *, type_comments: bool = ..., - feature_version: None | int | _typing.Tuple[int, int] = ..., + feature_version: Union[None, int, _typing.Tuple[int, int]] = ..., ) -> AST: ... else: @overload - def parse(source: str | bytes, filename: str | bytes = ..., mode: Literal["exec"] = ...) -> Module: ... + def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: Literal["exec"] = ...) -> Module: ... @overload - def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ... + def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ... if sys.version_info >= (3, 9): def unparse(ast_obj: AST) -> str: ... @@ -188,20 +188,20 @@ def copy_location(new_node: _T, old_node: AST) -> _T: ... if sys.version_info >= (3, 9): def dump( - node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: int | str | None = ... + node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: Union[int, str, None] = ... ) -> str: ... else: def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: _T) -> _T: ... -def get_docstring(node: AST, clean: bool = ...) -> str | None: ... +def get_docstring(node: AST, clean: bool = ...) -> Optional[str]: ... def increment_lineno(node: _T, n: int = ...) -> _T: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[_typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: str | AST) -> Any: ... +def literal_eval(node_or_string: Union[str, AST]) -> Any: ... if sys.version_info >= (3, 8): - def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> str | None: ... + def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> Optional[str]: ... def walk(node: AST) -> Iterator[AST]: ... diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 2a188c7d0477..35bd142b8017 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -1,7 +1,7 @@ import typing from _typeshed import StrPath from datetime import tzinfo -from typing import Any, Iterable, Protocol, Sequence, Set, Type +from typing import Any, Iterable, Optional, Protocol, Sequence, Set, Type _T = typing.TypeVar("_T", bound="ZoneInfo") @@ -16,14 +16,14 @@ class ZoneInfo(tzinfo): @classmethod def no_cache(cls: Type[_T], key: str) -> _T: ... @classmethod - def from_file(cls: Type[_T], __fobj: _IOBytes, key: str | None = ...) -> _T: ... + def from_file(cls: Type[_T], __fobj: _IOBytes, key: Optional[str] = ...) -> _T: ... @classmethod def clear_cache(cls, *, only_keys: Iterable[str] = ...) -> None: ... # Note: Both here and in clear_cache, the types allow the use of `str` where # a sequence of strings is required. This should be remedied if a solution # to this typing bug is found: https://github.com/python/typing/issues/256 -def reset_tzpath(to: Sequence[StrPath] | None = ...) -> None: ... +def reset_tzpath(to: Optional[Sequence[StrPath]] = ...) -> None: ... def available_timezones() -> Set[str]: ... TZPATH: Sequence[str] diff --git a/stubs/Jinja2/jinja2/nodes.pyi b/stubs/Jinja2/jinja2/nodes.pyi index 2f680dbc72be..84871975d3e2 100644 --- a/stubs/Jinja2/jinja2/nodes.pyi +++ b/stubs/Jinja2/jinja2/nodes.pyi @@ -1,5 +1,5 @@ import typing -from typing import Any +from typing import Any, Optional class Impossible(Exception): ... @@ -10,7 +10,7 @@ class EvalContext: environment: Any autoescape: Any volatile: bool - def __init__(self, environment, template_name: Any | None = ...) -> None: ... + def __init__(self, environment, template_name: Optional[Any] = ...) -> None: ... def save(self): ... def revert(self, old): ... @@ -21,8 +21,8 @@ class Node: attributes: Any abstract: bool def __init__(self, *fields, **attributes) -> None: ... - def iter_fields(self, exclude: Any | None = ..., only: Any | None = ...): ... - def iter_child_nodes(self, exclude: Any | None = ..., only: Any | None = ...): ... + def iter_fields(self, exclude: Optional[Any] = ..., only: Optional[Any] = ...): ... + def iter_child_nodes(self, exclude: Optional[Any] = ..., only: Optional[Any] = ...): ... def find(self, node_type): ... def find_all(self, node_type): ... def set_ctx(self, ctx): ... @@ -89,20 +89,20 @@ class AssignBlock(Stmt): class Expr(Node): abstract: bool - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... def can_assign(self): ... class BinExpr(Expr): fields: Any operator: Any abstract: bool - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class UnaryExpr(Expr): fields: Any operator: Any abstract: bool - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Name(Expr): fields: Any @@ -113,71 +113,71 @@ class Literal(Expr): class Const(Literal): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... @classmethod - def from_untrusted(cls, value, lineno: Any | None = ..., environment: Any | None = ...): ... + def from_untrusted(cls, value, lineno: Optional[Any] = ..., environment: Optional[Any] = ...): ... class TemplateData(Literal): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Tuple(Literal): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... def can_assign(self): ... class List(Literal): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Dict(Literal): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Pair(Helper): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Keyword(Helper): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class CondExpr(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Filter(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Test(Expr): fields: Any class Call(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Getitem(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... def can_assign(self): ... class Getattr(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... def can_assign(self): ... class Slice(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Concat(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Compare(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Operand(Helper): fields: Any @@ -205,11 +205,11 @@ class Pow(BinExpr): class And(BinExpr): operator: str - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Or(BinExpr): operator: str - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class Not(UnaryExpr): operator: str @@ -235,11 +235,11 @@ class InternalName(Expr): class MarkSafe(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class MarkSafeIfAutoescape(Expr): fields: Any - def as_const(self, eval_ctx: Any | None = ...): ... + def as_const(self, eval_ctx: Optional[Any] = ...): ... class ContextReference(Expr): ... class Continue(Stmt): ... diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index bf22203db5d6..80b21672db27 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -16,10 +16,12 @@ from typing import ( KeysView, Mapping, NoReturn, + Optional, Pattern, Tuple, Type, TypeVar, + Union, ValuesView, overload, ) @@ -54,10 +56,10 @@ def create_unbound_method(func: types.FunctionType, cls: type) -> types.Function Iterator = object def get_method_function(meth: types.MethodType) -> types.FunctionType: ... -def get_method_self(meth: types.MethodType) -> object | None: ... -def get_function_closure(fun: types.FunctionType) -> Tuple[types._Cell, ...] | None: ... +def get_method_self(meth: types.MethodType) -> Optional[object]: ... +def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ... def get_function_code(fun: types.FunctionType) -> types.CodeType: ... -def get_function_defaults(fun: types.FunctionType) -> Tuple[Any, ...] | None: ... +def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ... def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ... def iterkeys(d: Mapping[_K, Any]) -> typing.Iterator[_K]: ... def itervalues(d: Mapping[Any, _V]) -> typing.Iterator[_V]: ... @@ -77,43 +79,47 @@ def int2byte(i: int) -> bytes: ... def byte2int(bs: binary_type) -> int: ... def indexbytes(buf: binary_type, i: int) -> int: ... def iterbytes(buf: binary_type) -> typing.Iterator[int]: ... -def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: str | None = ...) -> None: ... +def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: Optional[str] = ...) -> None: ... @overload -def assertRaisesRegex(self: unittest.TestCase, msg: str | None = ...) -> Any: ... +def assertRaisesRegex(self: unittest.TestCase, msg: Optional[str] = ...) -> Any: ... @overload def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... def assertRegex( - self: unittest.TestCase, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: str | None = ... + self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: Optional[str] = ... ) -> None: ... exec_ = exec -def reraise(tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ... -def raise_from(value: BaseException | Type[BaseException], from_value: BaseException | None) -> NoReturn: ... +def reraise( + tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ... +) -> NoReturn: ... +def raise_from(value: Union[BaseException, Type[BaseException]], from_value: Optional[BaseException]) -> NoReturn: ... print_ = print def with_metaclass(meta: type, *bases: type) -> type: ... def add_metaclass(metaclass: type) -> Callable[[_T], _T]: ... -def ensure_binary(s: bytes | str, encoding: str = ..., errors: str = ...) -> bytes: ... -def ensure_str(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ... -def ensure_text(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ... +def ensure_binary(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> bytes: ... +def ensure_str(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> str: ... +def ensure_text(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> str: ... def python_2_unicode_compatible(klass: _T) -> _T: ... class _LazyDescriptor: name: str def __init__(self, name: str) -> None: ... - def __get__(self, obj: object | None, type: type | None = ...) -> Any: ... + def __get__(self, obj: Optional[object], type: Optional[type] = ...) -> Any: ... class MovedModule(_LazyDescriptor): mod: str - def __init__(self, name: str, old: str, new: str | None = ...) -> None: ... + def __init__(self, name: str, old: str, new: Optional[str] = ...) -> None: ... def __getattr__(self, attr: str) -> Any: ... class MovedAttribute(_LazyDescriptor): mod: str attr: str - def __init__(self, name: str, old_mod: str, new_mod: str, old_attr: str | None = ..., new_attr: str | None = ...) -> None: ... + def __init__( + self, name: str, old_mod: str, new_mod: str, old_attr: Optional[str] = ..., new_attr: Optional[str] = ... + ) -> None: ... -def add_move(move: MovedModule | MovedAttribute) -> None: ... +def add_move(move: Union[MovedModule, MovedAttribute]) -> None: ... def remove_move(name: str) -> None: ... diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index 1991733f4c08..139e58aac246 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -1,5 +1,5 @@ import typing -from typing import Any, Iterator +from typing import Any, Iterator, Optional, Union class NodeVisitor: def visit(self, node: AST) -> Any: ... @@ -8,15 +8,15 @@ class NodeVisitor: class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> None: ... -def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ... +def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: AST) -> AST: ... -def get_docstring(node: AST, clean: bool = ...) -> bytes | None: ... +def get_docstring(node: AST, clean: bool = ...) -> Optional[bytes]: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: str | AST) -> Any: ... +def literal_eval(node_or_string: Union[str, AST]) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... PyCF_ONLY_AST: int @@ -58,7 +58,7 @@ class FunctionDef(stmt): args: arguments body: typing.List[stmt] decorator_list: typing.List[expr] - type_comment: str | None + type_comment: Optional[str] class ClassDef(stmt): name: identifier @@ -67,7 +67,7 @@ class ClassDef(stmt): decorator_list: typing.List[expr] class Return(stmt): - value: expr | None + value: Optional[expr] class Delete(stmt): targets: typing.List[expr] @@ -75,7 +75,7 @@ class Delete(stmt): class Assign(stmt): targets: typing.List[expr] value: expr - type_comment: str | None + type_comment: Optional[str] class AugAssign(stmt): target: expr @@ -83,7 +83,7 @@ class AugAssign(stmt): value: expr class Print(stmt): - dest: expr | None + dest: Optional[expr] values: typing.List[expr] nl: bool @@ -92,7 +92,7 @@ class For(stmt): iter: expr body: typing.List[stmt] orelse: typing.List[stmt] - type_comment: str | None + type_comment: Optional[str] class While(stmt): test: expr @@ -106,14 +106,14 @@ class If(stmt): class With(stmt): context_expr: expr - optional_vars: expr | None + optional_vars: Optional[expr] body: typing.List[stmt] - type_comment: str | None + type_comment: Optional[str] class Raise(stmt): - type: expr | None - inst: expr | None - tback: expr | None + type: Optional[expr] + inst: Optional[expr] + tback: Optional[expr] class TryExcept(stmt): body: typing.List[stmt] @@ -126,20 +126,20 @@ class TryFinally(stmt): class Assert(stmt): test: expr - msg: expr | None + msg: Optional[expr] class Import(stmt): names: typing.List[alias] class ImportFrom(stmt): - module: identifier | None + module: Optional[identifier] names: typing.List[alias] - level: int | None + level: Optional[int] class Exec(stmt): body: expr - globals: expr | None - locals: expr | None + globals: Optional[expr] + locals: Optional[expr] class Global(stmt): names: typing.List[identifier] @@ -155,9 +155,9 @@ class slice(AST): ... _slice = slice # this lets us type the variable named 'slice' below class Slice(slice): - lower: expr | None - upper: expr | None - step: expr | None + lower: Optional[expr] + upper: Optional[expr] + step: Optional[expr] class ExtSlice(slice): dims: typing.List[slice] @@ -218,7 +218,7 @@ class GeneratorExp(expr): generators: typing.List[comprehension] class Yield(expr): - value: expr | None + value: Optional[expr] class Compare(expr): left: expr @@ -229,17 +229,17 @@ class Call(expr): func: expr args: typing.List[expr] keywords: typing.List[keyword] - starargs: expr | None - kwargs: expr | None + starargs: Optional[expr] + kwargs: Optional[expr] class Repr(expr): value: expr class Num(expr): - n: int | float | complex + n: Union[int, float, complex] class Str(expr): - s: str | bytes + s: Union[str, bytes] kind: str class Attribute(expr): @@ -310,18 +310,18 @@ class comprehension(AST): ifs: typing.List[expr] class ExceptHandler(AST): - type: expr | None - name: expr | None + type: Optional[expr] + name: Optional[expr] body: typing.List[stmt] lineno: int col_offset: int class arguments(AST): args: typing.List[expr] - vararg: identifier | None - kwarg: identifier | None + vararg: Optional[identifier] + kwarg: Optional[identifier] defaults: typing.List[expr] - type_comments: typing.List[str | None] + type_comments: typing.List[Optional[str]] class keyword(AST): arg: identifier @@ -329,7 +329,7 @@ class keyword(AST): class alias(AST): name: identifier - asname: identifier | None + asname: Optional[identifier] class TypeIgnore(AST): lineno: int From b85dc8d742deb97fba79d4a1d7f993a74e14f1cf Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:32:15 +0300 Subject: [PATCH 11/13] revert stdlib/_thread.pyi --- stdlib/_thread.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 049c7e1e3ef4..513678499223 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -1,7 +1,7 @@ import sys from threading import Thread from types import TracebackType -from typing import Any, Callable, Dict, NoReturn, Tuple, Type +from typing import Any, Callable, Dict, NoReturn, Optional, Tuple, Type error = RuntimeError @@ -15,7 +15,7 @@ class LockType: def locked(self) -> bool: ... def __enter__(self) -> bool: ... def __exit__( - self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] ) -> None: ... def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> int: ... @@ -29,13 +29,13 @@ TIMEOUT_MAX: float if sys.version_info >= (3, 8): def get_native_id() -> int: ... # only available on some platforms - class _ExceptHookArgs(Tuple[Type[BaseException], BaseException | None, TracebackType | None, Thread | None]): + class _ExceptHookArgs(Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]): @property def exc_type(self) -> Type[BaseException]: ... @property - def exc_value(self) -> BaseException | None: ... + def exc_value(self) -> Optional[BaseException]: ... @property - def exc_traceback(self) -> TracebackType | None: ... + def exc_traceback(self) -> Optional[TracebackType]: ... @property - def thread(self) -> Thread | None: ... + def thread(self) -> Optional[Thread]: ... _excepthook: Callable[[_ExceptHookArgs], Any] From bdd51a8d4576cd0134b4eeff3892686b6877d4d8 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:35:42 +0300 Subject: [PATCH 12/13] black --- stubs/click/click/globals.pyi | 1 - stubs/colorama/colorama/winterm.pyi | 2 +- .../cryptography/hazmat/primitives/ciphers/aead.pyi | 1 - stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi | 1 - stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi | 1 - .../cryptography/hazmat/primitives/kdf/concatkdf.pyi | 1 - stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi | 1 - .../cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi | 1 - .../cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi | 1 - .../cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi | 1 - stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi | 1 - .../cryptography/hazmat/primitives/twofactor/hotp.pyi | 1 - .../cryptography/hazmat/primitives/twofactor/totp.pyi | 1 - stubs/paramiko/paramiko/kex_gss.pyi | 1 - stubs/paramiko/paramiko/sftp_handle.pyi | 1 - stubs/simplejson/simplejson/scanner.pyi | 1 - 16 files changed, 1 insertion(+), 16 deletions(-) diff --git a/stubs/click/click/globals.pyi b/stubs/click/click/globals.pyi index 75fb9017c48f..bdf259936476 100644 --- a/stubs/click/click/globals.pyi +++ b/stubs/click/click/globals.pyi @@ -1,4 +1,3 @@ - from click.core import Context def get_current_context(silent: bool = ...) -> Context: ... diff --git a/stubs/colorama/colorama/winterm.pyi b/stubs/colorama/colorama/winterm.pyi index 26e5434a5abb..a827463c000c 100644 --- a/stubs/colorama/colorama/winterm.pyi +++ b/stubs/colorama/colorama/winterm.pyi @@ -1,7 +1,7 @@ import sys if sys.platform == "win32": - + from . import win32 class WinColor: BLACK: int = ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi index 856c316b8a12..c6552a22813c 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi @@ -1,4 +1,3 @@ - class AESCCM(object): def __init__(self, key: bytes, tag_length: int | None) -> None: ... def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi b/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi index c59dda9cee54..ae05822a9016 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import CMACBackend from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi b/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi index c06e190999ff..102ec390c655 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi index 1eeb5f73d0ef..157609c30568 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/concatkdf.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import HashBackend, HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi index 34b0e1b5ee4d..95cae782c006 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/hkdf.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi index 843b5a383807..805450a1c594 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/pbkdf2.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import PBKDF2HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi index dd331356a84d..cd426b0e28d2 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/scrypt.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import ScryptBackend from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi b/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi index cc9cc9e14434..af74f2c07643 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/kdf/x963kdf.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import HashBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi b/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi index f81fce3ac612..33ca77d79ef1 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/keywrap.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import CipherBackend def aes_key_wrap(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend | None = ...) -> bytes: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi index 73ce4aa2e855..2cb453061748 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi index a3e81981ba5f..f6ba23e46276 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi @@ -1,4 +1,3 @@ - from cryptography.hazmat.backends.interfaces import HMACBackend from cryptography.hazmat.primitives.hashes import HashAlgorithm diff --git a/stubs/paramiko/paramiko/kex_gss.pyi b/stubs/paramiko/paramiko/kex_gss.pyi index 8c7ec249f479..1fd04c6e6391 100644 --- a/stubs/paramiko/paramiko/kex_gss.pyi +++ b/stubs/paramiko/paramiko/kex_gss.pyi @@ -1,4 +1,3 @@ - from paramiko.message import Message from paramiko.ssh_gss import _SSH_GSSAuth from paramiko.transport import Transport diff --git a/stubs/paramiko/paramiko/sftp_handle.pyi b/stubs/paramiko/paramiko/sftp_handle.pyi index 3c7cacca19b7..888e3c44ef08 100644 --- a/stubs/paramiko/paramiko/sftp_handle.pyi +++ b/stubs/paramiko/paramiko/sftp_handle.pyi @@ -1,4 +1,3 @@ - from paramiko.sftp_attr import SFTPAttributes from paramiko.util import ClosingContextManager diff --git a/stubs/simplejson/simplejson/scanner.pyi b/stubs/simplejson/simplejson/scanner.pyi index fb280813e65b..42b828a6905d 100644 --- a/stubs/simplejson/simplejson/scanner.pyi +++ b/stubs/simplejson/simplejson/scanner.pyi @@ -1,4 +1,3 @@ - class JSONDecodeError(ValueError): msg: str = ... doc: str = ... From be8a800e0ae7f5b6d675803c2302761d43a63e47 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 7 Aug 2021 18:40:06 +0300 Subject: [PATCH 13/13] more reverts --- stdlib/asyncio/tasks.pyi | 114 ++++++++------ stubs/click/click/core.pyi | 169 +++++++++++--------- stubs/requests/requests/sessions.pyi | 228 +++++++++++++-------------- 3 files changed, 275 insertions(+), 236 deletions(-) diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index cc96126c064b..c306e9655daa 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -26,17 +26,17 @@ FIRST_COMPLETED: str ALL_COMPLETED: str if sys.version_info >= (3, 10): - def as_completed(fs: Iterable[_FutureT[_T]], *, timeout: float | None = ...) -> Iterator[Future[_T]]: ... + def as_completed(fs: Iterable[_FutureT[_T]], *, timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ... else: def as_completed( - fs: Iterable[_FutureT[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ... + fs: Iterable[_FutureT[_T]], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ... ) -> Iterator[Future[_T]]: ... @overload -def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = ...) -> _FT: ... # type: ignore +def ensure_future(coro_or_future: _FT, *, loop: Optional[AbstractEventLoop] = ...) -> _FT: ... # type: ignore @overload -def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = ...) -> Task[_T]: ... +def ensure_future(coro_or_future: Awaitable[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Task[_T]: ... # Prior to Python 3.7 'async' was an alias for 'ensure_future'. # It became a keyword in 3.7. @@ -91,11 +91,11 @@ if sys.version_info >= (3, 10): return_exceptions: bool = ..., ) -> Future[List[Any]]: ... @overload - def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: bool = ...) -> Future[Tuple[_T1 | BaseException]]: ... + def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: bool = ...) -> Future[Tuple[Union[_T1, BaseException]]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, return_exceptions: bool = ... - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException]]: ... + ) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException]]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -103,7 +103,7 @@ if sys.version_info >= (3, 10): coro_or_future3: _FutureT[_T3], *, return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... + ) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException]]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -112,7 +112,9 @@ if sys.version_info >= (3, 10): coro_or_future4: _FutureT[_T4], *, return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... + ) -> Future[ + Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]] + ]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -123,20 +125,26 @@ if sys.version_info >= (3, 10): *, return_exceptions: bool = ..., ) -> Future[ - Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException,] + Tuple[ + Union[_T1, BaseException], + Union[_T2, BaseException], + Union[_T3, BaseException], + Union[_T4, BaseException], + Union[_T5, BaseException], + ] ]: ... else: @overload def gather( - coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ... + coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: Literal[False] = ... ) -> Future[Tuple[_T1]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: Literal[False] = ..., ) -> Future[Tuple[_T1, _T2]]: ... @overload @@ -145,7 +153,7 @@ else: coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], *, - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: Literal[False] = ..., ) -> Future[Tuple[_T1, _T2, _T3]]: ... @overload @@ -155,7 +163,7 @@ else: coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: Literal[False] = ..., ) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ... @overload @@ -166,7 +174,7 @@ else: coro_or_future4: _FutureT[_T4], coro_or_future5: _FutureT[_T5], *, - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: Literal[False] = ..., ) -> Future[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload @@ -178,30 +186,30 @@ else: coro_or_future5: _FutureT[Any], coro_or_future6: _FutureT[Any], *coros_or_futures: _FutureT[Any], - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ..., ) -> Future[List[Any]]: ... @overload def gather( - coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ... - ) -> Future[Tuple[_T1 | BaseException]]: ... + coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ... + ) -> Future[Tuple[Union[_T1, BaseException]]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException]]: ... + ) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException]]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], *, - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... + ) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException]]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -209,9 +217,11 @@ else: coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ..., - ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... + ) -> Future[ + Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]] + ]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -220,10 +230,16 @@ else: coro_or_future4: _FutureT[_T4], coro_or_future5: _FutureT[_T5], *, - loop: AbstractEventLoop | None = ..., + loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ..., ) -> Future[ - Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException,] + Tuple[ + Union[_T1, BaseException], + Union[_T2, BaseException], + Union[_T3, BaseException], + Union[_T4, BaseException], + Union[_T5, BaseException], + ] ]: ... def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... @@ -232,62 +248,68 @@ if sys.version_info >= (3, 10): def shield(arg: _FutureT[_T]) -> Future[_T]: ... def sleep(delay: float, result: _T = ...) -> Future[_T]: ... @overload - def wait(fs: Iterable[_FT], *, timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore + def wait(fs: Iterable[_FT], *, timeout: Optional[float] = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore @overload def wait( - fs: Iterable[Awaitable[_T]], *, timeout: float | None = ..., return_when: str = ... + fs: Iterable[Awaitable[_T]], *, timeout: Optional[float] = ..., return_when: str = ... ) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ... - def wait_for(fut: _FutureT[_T], timeout: float | None) -> Future[_T]: ... + def wait_for(fut: _FutureT[_T], timeout: Optional[float]) -> Future[_T]: ... else: - def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... - def sleep(delay: float, result: _T = ..., *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... + def shield(arg: _FutureT[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ... + def sleep(delay: float, result: _T = ..., *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ... @overload - def wait(fs: Iterable[_FT], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore + def wait(fs: Iterable[_FT], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore @overload def wait( - fs: Iterable[Awaitable[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ... + fs: Iterable[Awaitable[_T]], + *, + loop: Optional[AbstractEventLoop] = ..., + timeout: Optional[float] = ..., + return_when: str = ..., ) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ... - def wait_for(fut: _FutureT[_T], timeout: float | None, *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ... + def wait_for(fut: _FutureT[_T], timeout: Optional[float], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ... class Task(Future[_T], Generic[_T]): if sys.version_info >= (3, 8): def __init__( self, - coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], + coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ..., - name: str | None = ..., + name: Optional[str] = ..., ) -> None: ... else: def __init__( - self, coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, loop: AbstractEventLoop = ... + self, coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ... ) -> None: ... def __repr__(self) -> str: ... if sys.version_info >= (3, 8): - def get_coro(self) -> Generator[_TaskYieldType, None, _T] | Awaitable[_T]: ... + def get_coro(self) -> Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]]: ... def get_name(self) -> str: ... def set_name(self, __value: object) -> None: ... - def get_stack(self, *, limit: int | None = ...) -> List[FrameType]: ... - def print_stack(self, *, limit: int | None = ..., file: TextIO | None = ...) -> None: ... + def get_stack(self, *, limit: Optional[int] = ...) -> List[FrameType]: ... + def print_stack(self, *, limit: Optional[int] = ..., file: Optional[TextIO] = ...) -> None: ... if sys.version_info >= (3, 9): - def cancel(self, msg: str | None = ...) -> bool: ... + def cancel(self, msg: Optional[str] = ...) -> bool: ... else: def cancel(self) -> bool: ... if sys.version_info < (3, 9): @classmethod - def current_task(cls, loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... + def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... @classmethod - def all_tasks(cls, loop: AbstractEventLoop | None = ...) -> Set[Task[Any]]: ... + def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... if sys.version_info < (3, 7): def _wakeup(self, fut: Future[Any]) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... if sys.version_info >= (3, 7): - def all_tasks(loop: AbstractEventLoop | None = ...) -> Set[Task[Any]]: ... + def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... if sys.version_info >= (3, 8): - def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, name: str | None = ...) -> Task[_T]: ... + def create_task( + coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, name: Optional[str] = ... + ) -> Task[_T]: ... else: - def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T]) -> Task[_T]: ... - def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... + def create_task(coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]]) -> Task[_T]: ... + def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... diff --git a/stubs/click/click/core.pyi b/stubs/click/click/core.pyi index 8a3723332b64..e655f515a44c 100644 --- a/stubs/click/click/core.pyi +++ b/stubs/click/click/core.pyi @@ -1,4 +1,19 @@ -from typing import Any, Callable, ContextManager, Dict, Iterable, List, Mapping, NoReturn, Sequence, Set, Tuple, TypeVar, Union +from typing import ( + Any, + Callable, + ContextManager, + Dict, + Iterable, + List, + Mapping, + NoReturn, + Optional, + Sequence, + Set, + Tuple, + TypeVar, + Union, +) from click.formatting import HelpFormatter from click.parser import OptionParser @@ -6,53 +21,53 @@ from click.parser import OptionParser _CC = TypeVar("_CC", bound=Callable[[], Any]) def invoke_param_callback( - callback: Callable[[Context, Parameter, str | None], Any], ctx: Context, param: Parameter, value: str | None + callback: Callable[[Context, Parameter, Optional[str]], Any], ctx: Context, param: Parameter, value: Optional[str] ) -> Any: ... -def augment_usage_errors(ctx: Context, param: Parameter | None = ...) -> ContextManager[None]: ... +def augment_usage_errors(ctx: Context, param: Optional[Parameter] = ...) -> ContextManager[None]: ... def iter_params_for_processing( invocation_order: Sequence[Parameter], declaration_order: Iterable[Parameter] ) -> Iterable[Parameter]: ... class Context: - parent: Context | None + parent: Optional[Context] command: Command - info_name: str | None + info_name: Optional[str] params: Dict[Any, Any] args: List[str] protected_args: List[str] obj: Any - default_map: Mapping[str, Any] | None - invoked_subcommand: str | None - terminal_width: int | None - max_content_width: int | None + default_map: Optional[Mapping[str, Any]] + invoked_subcommand: Optional[str] + terminal_width: Optional[int] + max_content_width: Optional[int] allow_extra_args: bool allow_interspersed_args: bool ignore_unknown_options: bool help_option_names: List[str] - token_normalize_func: Callable[[str], str] | None + token_normalize_func: Optional[Callable[[str], str]] resilient_parsing: bool - auto_envvar_prefix: str | None - color: bool | None + auto_envvar_prefix: Optional[str] + color: Optional[bool] _meta: Dict[str, Any] _close_callbacks: List[Any] _depth: int def __init__( self, command: Command, - parent: Context | None = ..., - info_name: str | None = ..., - obj: Any | None = ..., - auto_envvar_prefix: str | None = ..., - default_map: Mapping[str, Any] | None = ..., - terminal_width: int | None = ..., - max_content_width: int | None = ..., + parent: Optional[Context] = ..., + info_name: Optional[str] = ..., + obj: Optional[Any] = ..., + auto_envvar_prefix: Optional[str] = ..., + default_map: Optional[Mapping[str, Any]] = ..., + terminal_width: Optional[int] = ..., + max_content_width: Optional[int] = ..., resilient_parsing: bool = ..., - allow_extra_args: bool | None = ..., - allow_interspersed_args: bool | None = ..., - ignore_unknown_options: bool | None = ..., - help_option_names: List[str] | None = ..., - token_normalize_func: Callable[[str], str] | None = ..., - color: bool | None = ..., + allow_extra_args: Optional[bool] = ..., + allow_interspersed_args: Optional[bool] = ..., + ignore_unknown_options: Optional[bool] = ..., + help_option_names: Optional[List[str]] = ..., + token_normalize_func: Optional[Callable[[str], str]] = ..., + color: Optional[bool] = ..., ) -> None: ... @property def meta(self) -> Dict[str, Any]: ... @@ -68,11 +83,11 @@ class Context: def lookup_default(self, name: str) -> Any: ... def fail(self, message: str) -> NoReturn: ... def abort(self) -> NoReturn: ... - def exit(self, code: int | str = ...) -> NoReturn: ... + def exit(self, code: Union[int, str] = ...) -> NoReturn: ... def get_usage(self) -> str: ... def get_help(self) -> str: ... - def invoke(self, callback: Command | Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... - def forward(self, callback: Command | Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... + def invoke(self, callback: Union[Command, Callable[..., Any]], *args: Any, **kwargs: Any) -> Any: ... + def forward(self, callback: Union[Command, Callable[..., Any]], *args: Any, **kwargs: Any) -> Any: ... class BaseCommand: allow_extra_args: bool @@ -80,28 +95,28 @@ class BaseCommand: ignore_unknown_options: bool name: str context_settings: Dict[Any, Any] - def __init__(self, name: str, context_settings: Dict[Any, Any] | None = ...) -> None: ... + def __init__(self, name: str, context_settings: Optional[Dict[Any, Any]] = ...) -> None: ... def get_usage(self, ctx: Context) -> str: ... def get_help(self, ctx: Context) -> str: ... - def make_context(self, info_name: str, args: List[str], parent: Context | None = ..., **extra: Any) -> Context: ... + def make_context(self, info_name: str, args: List[str], parent: Optional[Context] = ..., **extra: Any) -> Context: ... def parse_args(self, ctx: Context, args: List[str]) -> List[str]: ... def invoke(self, ctx: Context) -> Any: ... def main( self, - args: List[str] | None = ..., - prog_name: str | None = ..., - complete_var: str | None = ..., + args: Optional[List[str]] = ..., + prog_name: Optional[str] = ..., + complete_var: Optional[str] = ..., standalone_mode: bool = ..., **extra: Any, ) -> Any: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class Command(BaseCommand): - callback: Callable[..., Any] | None + callback: Optional[Callable[..., Any]] params: List[Parameter] - help: str | None - epilog: str | None - short_help: str | None + help: Optional[str] + epilog: Optional[str] + short_help: Optional[str] options_metavar: str add_help_option: bool no_args_is_help: bool @@ -110,12 +125,12 @@ class Command(BaseCommand): def __init__( self, name: str, - context_settings: Dict[Any, Any] | None = ..., - callback: Callable[..., Any] | None = ..., - params: List[Parameter] | None = ..., - help: str | None = ..., - epilog: str | None = ..., - short_help: str | None = ..., + context_settings: Optional[Dict[Any, Any]] = ..., + callback: Optional[Callable[..., Any]] = ..., + params: Optional[List[Parameter]] = ..., + help: Optional[str] = ..., + epilog: Optional[str] = ..., + short_help: Optional[str] = ..., options_metavar: str = ..., add_help_option: bool = ..., no_args_is_help: bool = ..., @@ -126,7 +141,7 @@ class Command(BaseCommand): def format_usage(self, ctx: Context, formatter: HelpFormatter) -> None: ... def collect_usage_pieces(self, ctx: Context) -> List[str]: ... def get_help_option_names(self, ctx: Context) -> Set[str]: ... - def get_help_option(self, ctx: Context) -> Option | None: ... + def get_help_option(self, ctx: Context) -> Optional[Option]: ... def make_parser(self, ctx: Context) -> OptionParser: ... def get_short_help_str(self, limit: int = ...) -> str: ... def format_help(self, ctx: Context, formatter: HelpFormatter) -> None: ... @@ -145,45 +160,47 @@ class MultiCommand(Command): result_callback: Callable[..., Any] def __init__( self, - name: str | None = ..., + name: Optional[str] = ..., invoke_without_command: bool = ..., - no_args_is_help: bool | None = ..., - subcommand_metavar: str | None = ..., + no_args_is_help: Optional[bool] = ..., + subcommand_metavar: Optional[str] = ..., chain: bool = ..., - result_callback: Callable[..., Any] | None = ..., + result_callback: Optional[Callable[..., Any]] = ..., **attrs: Any, ) -> None: ... def resultcallback(self, replace: bool = ...) -> Callable[[_F], _F]: ... def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None: ... def resolve_command(self, ctx: Context, args: List[str]) -> Tuple[str, Command, List[str]]: ... - def get_command(self, ctx: Context, cmd_name: str) -> Command | None: ... + def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]: ... def list_commands(self, ctx: Context) -> Iterable[str]: ... class Group(MultiCommand): commands: Dict[str, Command] - def __init__(self, name: str | None = ..., commands: Dict[str, Command] | None = ..., **attrs: Any) -> None: ... - def add_command(self, cmd: Command, name: str | None = ...) -> None: ... + def __init__(self, name: Optional[str] = ..., commands: Optional[Dict[str, Command]] = ..., **attrs: Any) -> None: ... + def add_command(self, cmd: Command, name: Optional[str] = ...) -> None: ... def command(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], Command]: ... def group(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], Group]: ... class CommandCollection(MultiCommand): sources: List[MultiCommand] - def __init__(self, name: str | None = ..., sources: List[MultiCommand] | None = ..., **attrs: Any) -> None: ... + def __init__(self, name: Optional[str] = ..., sources: Optional[List[MultiCommand]] = ..., **attrs: Any) -> None: ... def add_source(self, multi_cmd: MultiCommand) -> None: ... class _ParamType: name: str is_composite: bool - envvar_list_splitter: str | None - def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> Any: ... + envvar_list_splitter: Optional[str] + def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> Any: ... def get_metavar(self, param: Parameter) -> str: ... def get_missing_message(self, param: Parameter) -> str: ... - def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> Any: ... + def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> Any: ... def split_envvar_value(self, rv: str) -> List[str]: ... - def fail(self, message: str, param: Parameter | None = ..., ctx: Context | None = ...) -> NoReturn: ... + def fail(self, message: str, param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> NoReturn: ... # This type is here to resolve https://github.com/python/mypy/issues/5275 -_ConvertibleType = Union[type, _ParamType, Tuple[type | _ParamType, ...], Callable[[str], Any], Callable[[str | None], Any]] +_ConvertibleType = Union[ + type, _ParamType, Tuple[Union[type, _ParamType], ...], Callable[[str], Any], Callable[[Optional[str]], Any] +] class Parameter: param_type_name: str @@ -192,26 +209,26 @@ class Parameter: secondary_opts: List[str] type: _ParamType required: bool - callback: Callable[[Context, Parameter, str], Any] | None + callback: Optional[Callable[[Context, Parameter, str], Any]] nargs: int multiple: bool expose_value: bool default: Any is_eager: bool - metavar: str | None - envvar: str | List[str] | None + metavar: Optional[str] + envvar: Union[str, List[str], None] def __init__( self, - param_decls: Iterable[str] | None = ..., - type: _ConvertibleType | None = ..., + param_decls: Optional[Iterable[str]] = ..., + type: Optional[_ConvertibleType] = ..., required: bool = ..., - default: Any | None = ..., - callback: Callable[[Context, Parameter, str], Any] | None = ..., - nargs: int | None = ..., - metavar: str | None = ..., + default: Optional[Any] = ..., + callback: Optional[Callable[[Context, Parameter, str], Any]] = ..., + nargs: Optional[int] = ..., + metavar: Optional[str] = ..., expose_value: bool = ..., is_eager: bool = ..., - envvar: str | List[str] | None = ..., + envvar: Optional[Union[str, List[str]]] = ..., ) -> None: ... @property def human_readable_name(self) -> str: ... @@ -224,7 +241,7 @@ class Parameter: def value_is_missing(self, value: Any) -> bool: ... def full_process_value(self, ctx: Context, value: Any) -> Any: ... def resolve_envvar_value(self, ctx: Context) -> str: ... - def value_from_envvar(self, ctx: Context) -> str | List[str]: ... + def value_from_envvar(self, ctx: Context) -> Union[str, List[str]]: ... def handle_parse_result(self, ctx: Context, opts: Dict[str, Any], args: List[str]) -> Tuple[Any, List[str]]: ... def get_help_record(self, ctx: Context) -> Tuple[str, str]: ... def get_usage_pieces(self, ctx: Context) -> List[str]: ... @@ -240,25 +257,25 @@ class Option(Parameter): count: bool multiple: bool allow_from_autoenv: bool - help: str | None + help: Optional[str] hidden: bool show_default: bool show_choices: bool show_envvar: bool def __init__( self, - param_decls: Iterable[str] | None = ..., + param_decls: Optional[Iterable[str]] = ..., show_default: bool = ..., - prompt: bool | str = ..., + prompt: Union[bool, str] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., - is_flag: bool | None = ..., - flag_value: Any | None = ..., + is_flag: Optional[bool] = ..., + flag_value: Optional[Any] = ..., multiple: bool = ..., count: bool = ..., allow_from_autoenv: bool = ..., - type: _ConvertibleType | None = ..., - help: str | None = ..., + type: Optional[_ConvertibleType] = ..., + help: Optional[str] = ..., hidden: bool = ..., show_choices: bool = ..., show_envvar: bool = ..., @@ -267,4 +284,4 @@ class Option(Parameter): def prompt_for_value(self, ctx: Context) -> Any: ... class Argument(Parameter): - def __init__(self, param_decls: Iterable[str] | None = ..., required: bool | None = ..., **attrs: Any) -> None: ... + def __init__(self, param_decls: Optional[Iterable[str]] = ..., required: Optional[bool] = ..., **attrs: Any) -> None: ... diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index e63409439299..e3d3c3a349be 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -55,20 +55,20 @@ _Params = Union[ SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType], Tuple[_ParamsMappingKeyType, _ParamsMappingValueType], Iterable[Tuple[_ParamsMappingKeyType, _ParamsMappingValueType]], - Text | bytes, + Union[Text, bytes], ] _SessionT = TypeVar("_SessionT", bound=Session) class Session(SessionRedirectMixin): __attrs__: Any headers: CaseInsensitiveDict[Text] - auth: None | Tuple[Text, Text] | _auth.AuthBase | Callable[[PreparedRequest], PreparedRequest] + auth: Union[None, Tuple[Text, Text], _auth.AuthBase, Callable[[PreparedRequest], PreparedRequest]] proxies: MutableMapping[Text, Text] hooks: _Hooks params: _Params stream: bool - verify: None | bool | Text - cert: None | Text | Tuple[Text, Text] + verify: Union[None, bool, Text] + cert: Union[None, Text, Tuple[Text, Text]] max_redirects: int trust_env: bool cookies: RequestsCookieJar @@ -81,152 +81,152 @@ class Session(SessionRedirectMixin): def request( self, method: str, - url: str | bytes | Text, - params: _Params | None = ..., + url: Union[str, bytes, Text], + params: Optional[_Params] = ..., data: _Data = ..., - headers: MutableMapping[Text, Text] | None = ..., - cookies: None | RequestsCookieJar | MutableMapping[Text, Text] = ..., - files: MutableMapping[Text, IO[Any]] | None = ..., - auth: None | Tuple[Text, Text] | _auth.AuthBase | Callable[[PreparedRequest], PreparedRequest] = ..., - timeout: None | float | Tuple[float, float] | Tuple[float, None] = ..., - allow_redirects: bool | None = ..., - proxies: MutableMapping[Text, Text] | None = ..., - hooks: _HooksInput | None = ..., - stream: bool | None = ..., - verify: None | bool | Text = ..., - cert: Text | Tuple[Text, Text] | None = ..., - json: Any | None = ..., + headers: Optional[MutableMapping[Text, Text]] = ..., + cookies: Union[None, RequestsCookieJar, MutableMapping[Text, Text]] = ..., + files: Optional[MutableMapping[Text, IO[Any]]] = ..., + auth: Union[None, Tuple[Text, Text], _auth.AuthBase, Callable[[PreparedRequest], PreparedRequest]] = ..., + timeout: Union[None, float, Tuple[float, float], Tuple[float, None]] = ..., + allow_redirects: Optional[bool] = ..., + proxies: Optional[MutableMapping[Text, Text]] = ..., + hooks: Optional[_HooksInput] = ..., + stream: Optional[bool] = ..., + verify: Union[None, bool, Text] = ..., + cert: Union[Text, Tuple[Text, Text], None] = ..., + json: Optional[Any] = ..., ) -> Response: ... def get( self, - url: Text | bytes, - params: _Params | None = ..., - data: Any | None = ..., - headers: Any | None = ..., - cookies: Any | None = ..., - files: Any | None = ..., - auth: Any | None = ..., - timeout: Any | None = ..., + url: Union[Text, bytes], + params: Optional[_Params] = ..., + data: Optional[Any] = ..., + headers: Optional[Any] = ..., + cookies: Optional[Any] = ..., + files: Optional[Any] = ..., + auth: Optional[Any] = ..., + timeout: Optional[Any] = ..., allow_redirects: bool = ..., - proxies: Any | None = ..., - hooks: Any | None = ..., - stream: Any | None = ..., - verify: Any | None = ..., - cert: Any | None = ..., - json: Any | None = ..., + proxies: Optional[Any] = ..., + hooks: Optional[Any] = ..., + stream: Optional[Any] = ..., + verify: Optional[Any] = ..., + cert: Optional[Any] = ..., + json: Optional[Any] = ..., ) -> Response: ... def options( self, - url: Text | bytes, - params: _Params | None = ..., - data: Any | None = ..., - headers: Any | None = ..., - cookies: Any | None = ..., - files: Any | None = ..., - auth: Any | None = ..., - timeout: Any | None = ..., + url: Union[Text, bytes], + params: Optional[_Params] = ..., + data: Optional[Any] = ..., + headers: Optional[Any] = ..., + cookies: Optional[Any] = ..., + files: Optional[Any] = ..., + auth: Optional[Any] = ..., + timeout: Optional[Any] = ..., allow_redirects: bool = ..., - proxies: Any | None = ..., - hooks: Any | None = ..., - stream: Any | None = ..., - verify: Any | None = ..., - cert: Any | None = ..., - json: Any | None = ..., + proxies: Optional[Any] = ..., + hooks: Optional[Any] = ..., + stream: Optional[Any] = ..., + verify: Optional[Any] = ..., + cert: Optional[Any] = ..., + json: Optional[Any] = ..., ) -> Response: ... def head( self, - url: Text | bytes, - params: _Params | None = ..., - data: Any | None = ..., - headers: Any | None = ..., - cookies: Any | None = ..., - files: Any | None = ..., - auth: Any | None = ..., - timeout: Any | None = ..., + url: Union[Text, bytes], + params: Optional[_Params] = ..., + data: Optional[Any] = ..., + headers: Optional[Any] = ..., + cookies: Optional[Any] = ..., + files: Optional[Any] = ..., + auth: Optional[Any] = ..., + timeout: Optional[Any] = ..., allow_redirects: bool = ..., - proxies: Any | None = ..., - hooks: Any | None = ..., - stream: Any | None = ..., - verify: Any | None = ..., - cert: Any | None = ..., - json: Any | None = ..., + proxies: Optional[Any] = ..., + hooks: Optional[Any] = ..., + stream: Optional[Any] = ..., + verify: Optional[Any] = ..., + cert: Optional[Any] = ..., + json: Optional[Any] = ..., ) -> Response: ... def post( self, - url: Text | bytes, + url: Union[Text, bytes], data: _Data = ..., - json: Any | None = ..., - params: _Params | None = ..., - headers: Any | None = ..., - cookies: Any | None = ..., - files: Any | None = ..., - auth: Any | None = ..., - timeout: Any | None = ..., + json: Optional[Any] = ..., + params: Optional[_Params] = ..., + headers: Optional[Any] = ..., + cookies: Optional[Any] = ..., + files: Optional[Any] = ..., + auth: Optional[Any] = ..., + timeout: Optional[Any] = ..., allow_redirects: bool = ..., - proxies: Any | None = ..., - hooks: Any | None = ..., - stream: Any | None = ..., - verify: Any | None = ..., - cert: Any | None = ..., + proxies: Optional[Any] = ..., + hooks: Optional[Any] = ..., + stream: Optional[Any] = ..., + verify: Optional[Any] = ..., + cert: Optional[Any] = ..., ) -> Response: ... def put( self, - url: Text | bytes, + url: Union[Text, bytes], data: _Data = ..., - params: _Params | None = ..., - headers: Any | None = ..., - cookies: Any | None = ..., - files: Any | None = ..., - auth: Any | None = ..., - timeout: Any | None = ..., + params: Optional[_Params] = ..., + headers: Optional[Any] = ..., + cookies: Optional[Any] = ..., + files: Optional[Any] = ..., + auth: Optional[Any] = ..., + timeout: Optional[Any] = ..., allow_redirects: bool = ..., - proxies: Any | None = ..., - hooks: Any | None = ..., - stream: Any | None = ..., - verify: Any | None = ..., - cert: Any | None = ..., - json: Any | None = ..., + proxies: Optional[Any] = ..., + hooks: Optional[Any] = ..., + stream: Optional[Any] = ..., + verify: Optional[Any] = ..., + cert: Optional[Any] = ..., + json: Optional[Any] = ..., ) -> Response: ... def patch( self, - url: Text | bytes, + url: Union[Text, bytes], data: _Data = ..., - params: _Params | None = ..., - headers: Any | None = ..., - cookies: Any | None = ..., - files: Any | None = ..., - auth: Any | None = ..., - timeout: Any | None = ..., + params: Optional[_Params] = ..., + headers: Optional[Any] = ..., + cookies: Optional[Any] = ..., + files: Optional[Any] = ..., + auth: Optional[Any] = ..., + timeout: Optional[Any] = ..., allow_redirects: bool = ..., - proxies: Any | None = ..., - hooks: Any | None = ..., - stream: Any | None = ..., - verify: Any | None = ..., - cert: Any | None = ..., - json: Any | None = ..., + proxies: Optional[Any] = ..., + hooks: Optional[Any] = ..., + stream: Optional[Any] = ..., + verify: Optional[Any] = ..., + cert: Optional[Any] = ..., + json: Optional[Any] = ..., ) -> Response: ... def delete( self, - url: Text | bytes, - params: _Params | None = ..., - data: Any | None = ..., - headers: Any | None = ..., - cookies: Any | None = ..., - files: Any | None = ..., - auth: Any | None = ..., - timeout: Any | None = ..., + url: Union[Text, bytes], + params: Optional[_Params] = ..., + data: Optional[Any] = ..., + headers: Optional[Any] = ..., + cookies: Optional[Any] = ..., + files: Optional[Any] = ..., + auth: Optional[Any] = ..., + timeout: Optional[Any] = ..., allow_redirects: bool = ..., - proxies: Any | None = ..., - hooks: Any | None = ..., - stream: Any | None = ..., - verify: Any | None = ..., - cert: Any | None = ..., - json: Any | None = ..., + proxies: Optional[Any] = ..., + hooks: Optional[Any] = ..., + stream: Optional[Any] = ..., + verify: Optional[Any] = ..., + cert: Optional[Any] = ..., + json: Optional[Any] = ..., ) -> Response: ... def send(self, request: PreparedRequest, **kwargs) -> Response: ... def merge_environment_settings(self, url, proxies, stream, verify, cert): ... def get_adapter(self, url): ... def close(self) -> None: ... - def mount(self, prefix: Text | bytes, adapter: BaseAdapter) -> None: ... + def mount(self, prefix: Union[Text, bytes], adapter: BaseAdapter) -> None: ... def session() -> Session: ...